diff options
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/incoming_message_spec.rb | 4 | ||||
-rw-r--r-- | spec/models/profile_photo_spec.rb | 22 | ||||
-rw-r--r-- | spec/models/public_body_spec.rb | 31 |
3 files changed, 48 insertions, 9 deletions
diff --git a/spec/models/incoming_message_spec.rb b/spec/models/incoming_message_spec.rb index c0a7e5340..c27870afc 100644 --- a/spec/models/incoming_message_spec.rb +++ b/spec/models/incoming_message_spec.rb @@ -165,7 +165,7 @@ describe IncomingMessage, " when dealing with incoming mail" do message = File.read(file) parsed = IncomingMessage.remove_quoted_sections(message) expected = File.read("#{file}.expected") - parsed.should include(expected) + parsed.should be_equal_modulo_whitespace_to expected end end @@ -462,7 +462,7 @@ describe IncomingMessage, " when censoring data" do data.should == "His email was x\000x\000x\000@\000x\000x\000x\000.\000x\000x\000x\000, indeed" end - it 'should handle multibyte characters correctly', :focus => true do + it 'should handle multibyte characters correctly' do orig_data = 'á' data = orig_data.dup @regex_censor_rule = CensorRule.new() diff --git a/spec/models/profile_photo_spec.rb b/spec/models/profile_photo_spec.rb index 0e157e2c5..e70f474a0 100644 --- a/spec/models/profile_photo_spec.rb +++ b/spec/models/profile_photo_spec.rb @@ -10,12 +10,12 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') -describe ProfilePhoto, "when constructing a new photo" do +describe ProfilePhoto, "when constructing a new photo" do - before do + before do @mock_user = mock_model(User) end - + it 'should take no image as invalid' do profile_photo = ProfilePhoto.new(:data => nil, :user => @mock_user) profile_photo.valid?.should == false @@ -26,7 +26,15 @@ describe ProfilePhoto, "when constructing a new photo" do profile_photo.valid?.should == false end - it 'should accept and convert a PNG to right size' do + it 'should translate a no image error message' do + I18n.with_locale(:es) do + profile_photo = ProfilePhoto.new(:data => nil, :user => @mock_user) + profile_photo.valid?.should == false + profile_photo.errors[:data].should == ['Por favor elige el fichero que contiene tu foto'] + end + end + + it 'should accept and convert a PNG to right size' do data = load_file_fixture("parrot.png") profile_photo = ProfilePhoto.new(:data => data, :user => @mock_user) profile_photo.valid?.should == true @@ -35,7 +43,7 @@ describe ProfilePhoto, "when constructing a new photo" do profile_photo.image.rows.should == 96 end - it 'should accept and convert a JPEG to right format and size' do + it 'should accept and convert a JPEG to right format and size' do data = load_file_fixture("parrot.jpg") profile_photo = ProfilePhoto.new(:data => data, :user => @mock_user) profile_photo.valid?.should == true @@ -44,7 +52,7 @@ describe ProfilePhoto, "when constructing a new photo" do profile_photo.image.rows.should == 96 end - it 'should accept a draft PNG and not resize it' do + it 'should accept a draft PNG and not resize it' do data = load_file_fixture("parrot.png") profile_photo = ProfilePhoto.new(:data => data, :draft => true) profile_photo.valid?.should == true @@ -53,6 +61,6 @@ describe ProfilePhoto, "when constructing a new photo" do profile_photo.image.rows.should == 289 end - + end diff --git a/spec/models/public_body_spec.rb b/spec/models/public_body_spec.rb index ed24ced52..dc09bdfa6 100644 --- a/spec/models/public_body_spec.rb +++ b/spec/models/public_body_spec.rb @@ -300,6 +300,37 @@ describe PublicBody, "when searching" do end end +describe PublicBody, "when asked for the internal_admin_body" do + before(:each) do + # Make sure that there's no internal_admin_body before each of + # these tests: + PublicBody.connection.delete("DELETE FROM public_bodies WHERE url_name = 'internal_admin_body'") + PublicBody.connection.delete("DELETE FROM public_body_translations WHERE url_name = 'internal_admin_body'") + end + + it "should create the internal_admin_body if it didn't exist" do + iab = PublicBody.internal_admin_body + iab.should_not be_nil + end + + it "should find the internal_admin_body even if the default locale has changed since it was created" do + with_default_locale("en") do + I18n.with_locale(:en) do + iab = PublicBody.internal_admin_body + iab.should_not be_nil + end + end + with_default_locale("es") do + I18n.with_locale(:es) do + iab = PublicBody.internal_admin_body + iab.should_not be_nil + end + end + end + +end + + describe PublicBody, " when dealing public body locales" do it "shouldn't fail if it internal_admin_body was created in a locale other than the default" do # first time, do it with the non-default locale |