aboutsummaryrefslogtreecommitdiffstats
path: root/spec/models
diff options
context:
space:
mode:
authorMark Longair <mhl@pobox.com>2013-10-04 17:29:21 +0100
committerMark Longair <mhl@pobox.com>2013-10-04 17:29:21 +0100
commit6a857d9a42629da7c430ddf6c865cb7eb73a8901 (patch)
tree7cefba76990385b8acb51594cbff1baccd2e739a /spec/models
parentabfbb63875850922052da6e0626bdba4e137af65 (diff)
Fix upcasing of a non-US-ASCII first letter under Ruby 1.8
In the rare circumstance that someone created a public body whose name started with a lower case letter outside [a-z] with Alaveteli running under Ruby 1.8, the letter would not be upcased correctly before saving to the first_letter column. This commit fixes that by using a Unicode-aware upcase function.
Diffstat (limited to 'spec/models')
-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 b0cb15f27..0324e3f5a 100644
--- a/spec/models/public_body_spec.rb
+++ b/spec/models/public_body_spec.rb
@@ -190,6 +190,17 @@ describe PublicBody, " when saving" do
@public_body.first_letter.should == 'T'
end
+ it "should update first letter, even if it's a multibyte character" do
+ pb = PublicBody.new(:name => 'åccents, lower-case',
+ :short_name => 'ALC',
+ :request_email => 'foo@localhost',
+ :last_edit_editor => 'test',
+ :last_edit_comment => '')
+ pb.first_letter.should be_nil
+ pb.save!
+ pb.first_letter.should == 'Å'
+ end
+
it "should save the name when renaming an existing public body" do
public_body = public_bodies(:geraldine_public_body)
public_body.name = "Mark's Public Body"