aboutsummaryrefslogtreecommitdiffstats
path: root/spec/models/public_body_spec.rb
diff options
context:
space:
mode:
authorGareth Rees <gareth@mysociety.org>2015-01-23 15:12:50 +0000
committerGareth Rees <gareth@mysociety.org>2015-02-04 15:02:00 +0000
commit93c137a906715c194dc64044556c148d813c87a3 (patch)
treec7479f296aa16b9eb50a0bcea6edd08daa5104dc /spec/models/public_body_spec.rb
parent3fe8f773df749988a1d88141330e65b13eb43ab6 (diff)
Nicer capitalize first letter only
String#capitalize downcases remaining letters, so: > 'heLLo WorLd'.capitalize # => "Hello world" Our version only works on the first character of the String, preserving the case of the rest of the String: > 'heLLo WorLd'.sub(/\S/) { |m| Unicode.upcase(m) } # => 'HeLLo WorLd' Also handle unicode.
Diffstat (limited to 'spec/models/public_body_spec.rb')
-rw-r--r--spec/models/public_body_spec.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/spec/models/public_body_spec.rb b/spec/models/public_body_spec.rb
index db38e3a15..3415dc28b 100644
--- a/spec/models/public_body_spec.rb
+++ b/spec/models/public_body_spec.rb
@@ -37,6 +37,17 @@ describe PublicBody do
expect(public_body.type_of_authority).to eq('A public authority')
end
+ it 'handles Unicode' do
+ category = FactoryGirl.create(:public_body_category, :category_tag => 'spec',
+ :description => 'ünicode category')
+ heading = FactoryGirl.create(:public_body_heading)
+ heading.add_category(category)
+ public_body = FactoryGirl.create(:public_body, :tag_string => 'spec')
+
+
+ expect(public_body.type_of_authority).to eq('Ünicode category')
+ end
+
context 'when associated with one category' do
it 'returns the capitalised category description' do