diff options
Diffstat (limited to 'spec/models')
32 files changed, 266 insertions, 105 deletions
diff --git a/spec/models/about_me_validator_spec.rb b/spec/models/about_me_validator_spec.rb index 5610cead8..c8078f44a 100644 --- a/spec/models/about_me_validator_spec.rb +++ b/spec/models/about_me_validator_spec.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe AboutMeValidator do diff --git a/spec/models/censor_rule_spec.rb b/spec/models/censor_rule_spec.rb index 4ecd2d3e1..314b060d2 100644 --- a/spec/models/censor_rule_spec.rb +++ b/spec/models/censor_rule_spec.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # == Schema Information # # Table name: censor_rules @@ -17,6 +18,42 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') +describe CensorRule do + + describe :apply_to_text do + + it 'applies the rule to the text' do + rule = FactoryGirl.build(:censor_rule, :text => 'secret') + text = 'Some secret text' + expect(rule.apply_to_text(text)).to eq('Some [REDACTED] text') + end + + it 'does not mutate the input' do + rule = FactoryGirl.build(:censor_rule, :text => 'secret') + text = 'Some secret text' + rule.apply_to_text(text) + expect(text).to eq('Some secret text') + end + + it 'returns the text if the rule is unmatched' do + rule = FactoryGirl.build(:censor_rule, :text => 'secret') + text = 'Some text' + expect(rule.apply_to_text(text)).to eq('Some text') + end + end + + describe :apply_to_text! do + + it 'mutates the input' do + rule = FactoryGirl.build(:censor_rule, :text => 'secret') + text = 'Some secret text' + rule.apply_to_text!(text) + expect(text).to eq('Some [REDACTED] text') + end + + end +end + describe CensorRule, "substituting things" do describe 'when using a text rule' do diff --git a/spec/models/change_email_validator_spec.rb b/spec/models/change_email_validator_spec.rb index b667a23d1..efa8ca819 100644 --- a/spec/models/change_email_validator_spec.rb +++ b/spec/models/change_email_validator_spec.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') def validator_with_user_and_params(user, params = {}) diff --git a/spec/models/contact_validator_spec.rb b/spec/models/contact_validator_spec.rb index 0f5403967..9d7c192a3 100644 --- a/spec/models/contact_validator_spec.rb +++ b/spec/models/contact_validator_spec.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe ContactValidator do diff --git a/spec/models/customstates.rb b/spec/models/customstates.rb index 942e1fcde..453453f20 100644 --- a/spec/models/customstates.rb +++ b/spec/models/customstates.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- module InfoRequestCustomStates def self.included(base) diff --git a/spec/models/foi_attachment_spec.rb b/spec/models/foi_attachment_spec.rb index 882723d1e..9583f4c76 100644 --- a/spec/models/foi_attachment_spec.rb +++ b/spec/models/foi_attachment_spec.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # == Schema Information # # Table name: foi_attachments @@ -17,45 +18,59 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe FoiAttachment do - before(:each) do - load_raw_emails_data - end + describe :body= do + + it "sets the body" do + attachment = FoiAttachment.new + attachment.body = "baz" + attachment.body.should == "baz" + end + + it "sets the size" do + attachment = FoiAttachment.new + attachment.body = "baz" + attachment.body.should == "baz" + attachment.display_size.should == "0K" + end + + it "reparses the body if it disappears" do + load_raw_emails_data + im = incoming_messages(:useless_incoming_message) + im.extract_attachments! + main = im.get_main_body_text_part + orig_body = main.body + main.delete_cached_file! + lambda { + im.get_main_body_text_part.body + }.should_not raise_error(Errno::ENOENT) + main.delete_cached_file! + main = im.get_main_body_text_part + main.body.should == orig_body + end - it "sets the body" do - attachment = FoiAttachment.new - attachment.body = "baz" - attachment.body.should == "baz" - end - it "sets the size" do - attachment = FoiAttachment.new - attachment.body = "baz" - attachment.body.should == "baz" - attachment.update_display_size! - attachment.display_size.should == "0K" end - it "reparses the body if it disappears" do - im = incoming_messages(:useless_incoming_message) - im.extract_attachments! - main = im.get_main_body_text_part - orig_body = main.body - main.delete_cached_file! - lambda { - im.get_main_body_text_part.body - }.should_not raise_error(Errno::ENOENT) - main.delete_cached_file! - main = im.get_main_body_text_part - main.body.should == orig_body + + describe :ensure_filename! do + + it 'should create a filename for an instance with a blank filename' do + attachment = FoiAttachment.new + attachment.filename = '' + attachment.ensure_filename! + attachment.filename.should == 'attachment.bin' + end end -end -describe FoiAttachment, "when ensuring a filename is present" do + describe :has_body_as_html? do + + it 'should be true for a pdf attachment' do + FactoryGirl.build(:pdf_attachment).has_body_as_html?.should be_true + end + + it 'should be false for an html attachment' do + FactoryGirl.build(:html_attachment).has_body_as_html?.should be_false + end - it 'should create a filename for an instance with a blank filename' do - attachment = FoiAttachment.new - attachment.filename = '' - attachment.ensure_filename! - attachment.filename.should == 'attachment.bin' end end diff --git a/spec/models/has_tag_string_tag_spec.rb b/spec/models/has_tag_string_tag_spec.rb index 759b3396f..bbcb00ca2 100644 --- a/spec/models/has_tag_string_tag_spec.rb +++ b/spec/models/has_tag_string_tag_spec.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe HasTagString::HasTagStringTag, " when fiddling with tag strings" do diff --git a/spec/models/holiday_import_spec.rb b/spec/models/holiday_import_spec.rb index 7ec5c04d5..eb0b33e0e 100644 --- a/spec/models/holiday_import_spec.rb +++ b/spec/models/holiday_import_spec.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe HolidayImport do diff --git a/spec/models/holiday_spec.rb b/spec/models/holiday_spec.rb index 2f8eeabd9..bd73e672b 100644 --- a/spec/models/holiday_spec.rb +++ b/spec/models/holiday_spec.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # == Schema Information # # Table name: holidays diff --git a/spec/models/incoming_message_spec.rb b/spec/models/incoming_message_spec.rb index f6e524de3..10bb3de62 100644 --- a/spec/models/incoming_message_spec.rb +++ b/spec/models/incoming_message_spec.rb @@ -1,4 +1,4 @@ -# coding: utf-8 +# -*- encoding : utf-8 -*- # == Schema Information # # Table name: incoming_messages @@ -263,7 +263,7 @@ describe IncomingMessage, " when dealing with incoming mail" do incoming_message = InfoRequest.holding_pen_request.incoming_messages[0] # This will raise an error if the bug in TMail hasn't been fixed - incoming_message.get_body_for_html_display() + incoming_message.get_body_for_html_display end @@ -282,7 +282,7 @@ end describe IncomingMessage, " display attachments" do it "should not show slashes in filenames" do - foi_attachment = FoiAttachment.new() + foi_attachment = FoiAttachment.new # http://www.whatdotheyknow.com/request/post_commercial_manager_librarie#incoming-17233 foi_attachment.filename = "FOI/09/066 RESPONSE TO FOI REQUEST RECEIVED 21st JANUARY 2009.txt" expected_display_filename = foi_attachment.filename.gsub(/\//, " ") @@ -290,7 +290,7 @@ describe IncomingMessage, " display attachments" do end it "should not show slashes in subject generated filenames" do - foi_attachment = FoiAttachment.new() + foi_attachment = FoiAttachment.new # http://www.whatdotheyknow.com/request/post_commercial_manager_librarie#incoming-17233 foi_attachment.within_rfc822_subject = "FOI/09/066 RESPONSE TO FOI REQUEST RECEIVED 21st JANUARY 2009" foi_attachment.content_type = 'text/plain' @@ -312,20 +312,20 @@ describe IncomingMessage, " folding quoted parts of emails" do it 'should fold a plain text lotus notes quoted part correctly' do text = "FOI Team\n\n\nInfo Requester <xxx@whatdotheyknow.com>=20\nSent by: Info Requester <request-bounce-xxxxx@whatdotheyknow.com>\n06/03/08 10:00\nPlease respond to\nInfo Requester <request-xxxx@whatdotheyknow.com>" - @incoming_message = IncomingMessage.new() + @incoming_message = IncomingMessage.new @incoming_message.stub_chain(:info_request, :user_name).and_return("Info Requester") @incoming_message.remove_lotus_quoting(text).should match(/FOLDED_QUOTED_SECTION/) end it 'should not error when trying to fold lotus notes quoted parts on a request with no user_name' do text = "hello" - @incoming_message = IncomingMessage.new() + @incoming_message = IncomingMessage.new @incoming_message.stub_chain(:info_request, :user_name).and_return(nil) @incoming_message.remove_lotus_quoting(text).should == 'hello' end it "cope with [ in user names properly" do - @incoming_message = IncomingMessage.new() + @incoming_message = IncomingMessage.new @incoming_message.stub_chain(:info_request, :user_name).and_return("Sir [ Bobble") # this gives a warning if [ is in the name text = @incoming_message.remove_lotus_quoting("Sir [ Bobble \nSent by: \n") @@ -357,7 +357,7 @@ describe IncomingMessage, " checking validity to reply to" do MailHandler.stub!(:get_from_address).and_return(email) MailHandler.stub!(:empty_return_path?).with(@mail).and_return(empty_return_path) MailHandler.stub!(:get_auto_submitted).with(@mail).and_return(autosubmitted) - @incoming_message = IncomingMessage.new() + @incoming_message = IncomingMessage.new @incoming_message.stub!(:mail).and_return(@mail) @incoming_message._calculate_valid_to_reply_to.should == result end @@ -431,21 +431,21 @@ describe IncomingMessage, " when censoring data" do @im = incoming_messages(:useless_incoming_message) - @censor_rule_1 = CensorRule.new() + @censor_rule_1 = CensorRule.new @censor_rule_1.text = "Stilton" @censor_rule_1.replacement = "Jarlsberg" @censor_rule_1.last_edit_editor = "unknown" @censor_rule_1.last_edit_comment = "none" @im.info_request.censor_rules << @censor_rule_1 - @censor_rule_2 = CensorRule.new() + @censor_rule_2 = CensorRule.new @censor_rule_2.text = "blue" @censor_rule_2.replacement = "yellow" @censor_rule_2.last_edit_editor = "unknown" @censor_rule_2.last_edit_comment = "none" @im.info_request.censor_rules << @censor_rule_2 - @regex_censor_rule = CensorRule.new() + @regex_censor_rule = CensorRule.new @regex_censor_rule.text = 'm[a-z][a-z][a-z]e' @regex_censor_rule.regexp = true @regex_censor_rule.replacement = 'cat' @@ -477,7 +477,7 @@ describe IncomingMessage, " when censoring whole users" do @im = incoming_messages(:useless_incoming_message) - @censor_rule_1 = CensorRule.new() + @censor_rule_1 = CensorRule.new @censor_rule_1.text = "Stilton" @censor_rule_1.replacement = "Gorgonzola" @censor_rule_1.last_edit_editor = "unknown" @@ -534,7 +534,7 @@ describe IncomingMessage, " when uudecoding bad messages" do im.stub!(:mail).and_return(mail) ir = info_requests(:fancy_dog_request) - @censor_rule = CensorRule.new() + @censor_rule = CensorRule.new @censor_rule.text = "moo" @censor_rule.replacement = "bah" @censor_rule.last_edit_editor = "unknown" @@ -707,3 +707,15 @@ describe IncomingMessage, 'when getting the body of a message for html display' end end + +describe IncomingMessage, 'when getting clipped attachment text' do + + it 'should clip to characters not bytes' do + incoming_message = FactoryGirl.build(:incoming_message) + # This character is 2 bytes so the string should get sliced unless + # we are handling multibyte chars correctly + multibyte_string = "å" * 500002 + incoming_message.stub!(:_get_attachment_text_internal).and_return(multibyte_string) + incoming_message.get_attachment_text_clipped.length.should == 500002 + end +end
\ No newline at end of file diff --git a/spec/models/info_request_batch_spec.rb b/spec/models/info_request_batch_spec.rb index 701422037..a8572e7ba 100644 --- a/spec/models/info_request_batch_spec.rb +++ b/spec/models/info_request_batch_spec.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # == Schema Information # # Table name: info_request_batches diff --git a/spec/models/info_request_event_spec.rb b/spec/models/info_request_event_spec.rb index 1299dfb63..ff20ab059 100644 --- a/spec/models/info_request_event_spec.rb +++ b/spec/models/info_request_event_spec.rb @@ -1,4 +1,4 @@ -# coding: utf-8 +# -*- encoding : utf-8 -*- # == Schema Information # # Table name: info_request_events @@ -111,7 +111,7 @@ describe InfoRequestEvent do describe "should know" do it "that it's an incoming message" do - event = InfoRequestEvent.new() + event = InfoRequestEvent.new event.stub!(:incoming_message_selective_columns).and_return(1) event.is_incoming_message?.should be_true event.is_outgoing_message?.should be_false diff --git a/spec/models/info_request_spec.rb b/spec/models/info_request_spec.rb index 1ead1e0bf..18120fbb5 100644 --- a/spec/models/info_request_spec.rb +++ b/spec/models/info_request_spec.rb @@ -1,4 +1,4 @@ -# encoding: utf-8 +# -*- encoding : utf-8 -*- # == Schema Information # # Table name: info_requests @@ -31,7 +31,7 @@ describe InfoRequest do describe :new do it 'sets the default law used' do - expect(InfoRequest.new().law_used).to eq('foi') + expect(InfoRequest.new.law_used).to eq('foi') end it 'sets the default law used if a body is eir-only' do @@ -658,17 +658,22 @@ describe InfoRequest do before do Time.stub!(:now).and_return(Time.utc(2007, 11, 9, 23, 59)) - @mock_comment_event = mock_model(InfoRequestEvent, :created_at => Time.now - 23.days, - :event_type => 'comment', - :response? => false) - mock_incoming_message = mock_model(IncomingMessage, :all_can_view? => true) - @mock_response_event = mock_model(InfoRequestEvent, :created_at => Time.now - 22.days, - :event_type => 'response', - :response? => true, - :incoming_message => mock_incoming_message) - @info_request = InfoRequest.new(:prominence => 'normal', - :awaiting_description => true, - :info_request_events => [@mock_response_event, @mock_comment_event]) + @info_request = FactoryGirl.create(:info_request, + :prominence => 'normal', + :awaiting_description => true) + @comment_event = FactoryGirl.create(:info_request_event, + :created_at => Time.now - 23.days, + :event_type => 'comment', + :info_request => @info_request) + @incoming_message = FactoryGirl.create(:incoming_message, + :prominence => 'normal', + :info_request => @info_request) + @response_event = FactoryGirl.create(:info_request_event, + :info_request => @info_request, + :created_at => Time.now - 22.days, + :event_type => 'response', + :incoming_message => @incoming_message) + @info_request.update_attribute(:awaiting_description, true) end it 'should return false if it is the holding pen' do @@ -682,7 +687,7 @@ describe InfoRequest do end it 'should return false if its last response event occurred less than 21 days ago' do - @mock_response_event.stub!(:created_at).and_return(Time.now - 20.days) + @response_event.update_attribute(:created_at, Time.now - 20.days) @info_request.is_old_unclassified?.should be_false end diff --git a/spec/models/mail_server_log_spec.rb b/spec/models/mail_server_log_spec.rb index 67709b130..6b38e1270 100644 --- a/spec/models/mail_server_log_spec.rb +++ b/spec/models/mail_server_log_spec.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # == Schema Information # # Table name: mail_server_logs diff --git a/spec/models/outgoing_message_spec.rb b/spec/models/outgoing_message_spec.rb index a3e2d1c68..8d43e2ef1 100644 --- a/spec/models/outgoing_message_spec.rb +++ b/spec/models/outgoing_message_spec.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # == Schema Information # # Table name: outgoing_messages @@ -18,6 +19,93 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') +describe OutgoingMessage do + + describe :initialize do + + it 'does not censor the #body' do + attrs = { :status => 'ready', + :message_type => 'initial_request', + :body => 'abc', + :what_doing => 'normal_sort' } + + message = FactoryGirl.create(:outgoing_message, attrs) + + OutgoingMessage.any_instance.should_not_receive(:body).and_call_original + OutgoingMessage.find(message.id) + end + + end + + describe :body do + + it 'returns the body attribute' do + attrs = { :status => 'ready', + :message_type => 'initial_request', + :body => 'abc', + :what_doing => 'normal_sort' } + + message = FactoryGirl.build(:outgoing_message, attrs) + expect(message.body).to eq('abc') + end + + it 'strips the body of leading and trailing whitespace' do + attrs = { :status => 'ready', + :message_type => 'initial_request', + :body => ' abc ', + :what_doing => 'normal_sort' } + + message = FactoryGirl.build(:outgoing_message, attrs) + expect(message.body).to eq('abc') + end + + it 'removes excess linebreaks that unnecessarily space it out' do + attrs = { :status => 'ready', + :message_type => 'initial_request', + :body => "ab\n\nc\n\n", + :what_doing => 'normal_sort' } + + message = FactoryGirl.build(:outgoing_message, attrs) + expect(message.body).to eq("ab\n\nc") + end + + it "applies the associated request's censor rules to the text" do + attrs = { :status => 'ready', + :message_type => 'initial_request', + :body => 'This sensitive text contains secret info!', + :what_doing => 'normal_sort' } + message = FactoryGirl.build(:outgoing_message, attrs) + + rules = [FactoryGirl.build(:censor_rule, :text => 'secret'), + FactoryGirl.build(:censor_rule, :text => 'sensitive')] + InfoRequest.any_instance.stub(:censor_rules).and_return(rules) + + expected = 'This [REDACTED] text contains [REDACTED] info!' + expect(message.body).to eq(expected) + end + + it "applies the given censor rules to the text" do + attrs = { :status => 'ready', + :message_type => 'initial_request', + :body => 'This sensitive text contains secret info!', + :what_doing => 'normal_sort' } + message = FactoryGirl.build(:outgoing_message, attrs) + + request_rules = [FactoryGirl.build(:censor_rule, :text => 'secret'), + FactoryGirl.build(:censor_rule, :text => 'sensitive')] + InfoRequest.any_instance.stub(:censor_rules).and_return(request_rules) + + censor_rules = [FactoryGirl.build(:censor_rule, :text => 'text'), + FactoryGirl.build(:censor_rule, :text => 'contains')] + + expected = 'This sensitive [REDACTED] [REDACTED] secret info!' + expect(message.body(:censor_rules => censor_rules)).to eq(expected) + end + + end + +end + describe OutgoingMessage, " when making an outgoing message" do before do @@ -26,7 +114,7 @@ describe OutgoingMessage, " when making an outgoing message" do :status => 'ready', :message_type => 'initial_request', :body => 'This request contains a foo@bar.com email address', - :last_sent_at => Time.now(), + :last_sent_at => Time.now, :what_doing => 'normal_sort' }) end @@ -57,6 +145,7 @@ describe OutgoingMessage, " when making an outgoing message" do info_request = mock_model(InfoRequest, :public_body => public_body, :url_title => 'a_test_title', :title => 'A test title', + :applicable_censor_rules => [], :apply_censor_rules_to_text! => nil, :is_batch_request_template? => false) outgoing_message = OutgoingMessage.new({ @@ -155,27 +244,6 @@ describe OutgoingMessage, " when making an outgoing message" do end end - -describe OutgoingMessage, " when censoring data" do - - before do - @om = outgoing_messages(:useless_outgoing_message) - - @censor_rule = CensorRule.new() - @censor_rule.text = "dog" - @censor_rule.replacement = "cat" - @censor_rule.last_edit_editor = "unknown" - @censor_rule.last_edit_comment = "none" - - @om.info_request.censor_rules << @censor_rule - end - - it "should apply censor rules to outgoing messages" do - @om.read_attribute(:body).should match(/fancy dog/) - @om.body.should match(/fancy cat/) - end -end - describe OutgoingMessage, "when validating the format of the message body" do it 'should handle a salutation with a bracket in it' do diff --git a/spec/models/post_redirect_spec.rb b/spec/models/post_redirect_spec.rb index 750e47cc3..7d0dfe395 100644 --- a/spec/models/post_redirect_spec.rb +++ b/spec/models/post_redirect_spec.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # == Schema Information # # Table name: post_redirects diff --git a/spec/models/profile_photo_spec.rb b/spec/models/profile_photo_spec.rb index e70f474a0..199c87500 100644 --- a/spec/models/profile_photo_spec.rb +++ b/spec/models/profile_photo_spec.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # == Schema Information # # Table name: profile_photos diff --git a/spec/models/public_body_category/category_collection_spec.rb b/spec/models/public_body_category/category_collection_spec.rb index 1fbcbe739..9ee684982 100644 --- a/spec/models/public_body_category/category_collection_spec.rb +++ b/spec/models/public_body_category/category_collection_spec.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') describe PublicBodyCategory::CategoryCollection do @@ -15,7 +16,7 @@ describe PublicBodyCategory::CategoryCollection do describe 'when asked for headings' do it 'should return a list of headings' do - @categories.headings().should == ['Local and regional', 'Miscellaneous'] + @categories.headings.should == ['Local and regional', 'Miscellaneous'] end end @@ -30,7 +31,7 @@ describe PublicBodyCategory::CategoryCollection do "Miscellaneous", ["other", "Miscellaneous", "miscellaneous"]] - @categories.with_headings().should == expected_categories + @categories.with_headings.should == expected_categories end end @@ -38,7 +39,7 @@ describe PublicBodyCategory::CategoryCollection do describe 'when asked for tags by headings' do it 'should return a hash of tags keyed by heading' do - @categories.by_heading().should == {'Local and regional' => ['local_council'], + @categories.by_heading.should == {'Local and regional' => ['local_council'], 'Miscellaneous' => ['other']} end end @@ -50,19 +51,19 @@ describe PublicBodyCategory::CategoryCollection do ["local_council", "Local councils", "a local council"], ["other", "Miscellaneous", "miscellaneous"] ] - @categories.with_description().should == expected_categories + @categories.with_description.should == expected_categories end end describe 'when asked for tags' do it 'should return a list of tags' do - @categories.tags().should == ["local_council", "other"] + @categories.tags.should == ["local_council", "other"] end end describe 'when asked for categories by tag' do it 'should return a hash of categories keyed by tag' do - @categories.by_tag().should == { + @categories.by_tag.should == { "local_council" => "Local councils", "other" => "Miscellaneous" } @@ -71,7 +72,7 @@ describe PublicBodyCategory::CategoryCollection do describe 'when asked for singular_by_tag' do it 'should return a hash of category descriptions keyed by tag' do - @categories.singular_by_tag().should == { + @categories.singular_by_tag.should == { "local_council" => "a local council", "other" => "miscellaneous" } diff --git a/spec/models/public_body_category_link_spec.rb b/spec/models/public_body_category_link_spec.rb index fd5608480..564f4126f 100644 --- a/spec/models/public_body_category_link_spec.rb +++ b/spec/models/public_body_category_link_spec.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # == Schema Information # # Table name: public_body_category_links diff --git a/spec/models/public_body_category_spec.rb b/spec/models/public_body_category_spec.rb index 297bd096a..c6b2a8fde 100644 --- a/spec/models/public_body_category_spec.rb +++ b/spec/models/public_body_category_spec.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # == Schema Information # # Table name: public_body_categories diff --git a/spec/models/public_body_change_request_spec.rb b/spec/models/public_body_change_request_spec.rb index 0c4cea67b..e35ffa692 100644 --- a/spec/models/public_body_change_request_spec.rb +++ b/spec/models/public_body_change_request_spec.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # == Schema Information # # Table name: public_body_change_requests @@ -21,7 +22,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe PublicBodyChangeRequest, 'when validating' do it 'should not be valid without a public body name' do - change_request = PublicBodyChangeRequest.new() + change_request = PublicBodyChangeRequest.new change_request.valid?.should be_false change_request.errors[:public_body_name].should == ['Please enter the name of the authority'] end diff --git a/spec/models/public_body_heading_spec.rb b/spec/models/public_body_heading_spec.rb index be3e7c7d2..8b46181b6 100644 --- a/spec/models/public_body_heading_spec.rb +++ b/spec/models/public_body_heading_spec.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # == Schema Information # # Table name: public_body_headings diff --git a/spec/models/public_body_spec.rb b/spec/models/public_body_spec.rb index cce017424..d6abf7b5f 100644 --- a/spec/models/public_body_spec.rb +++ b/spec/models/public_body_spec.rb @@ -1,4 +1,4 @@ -# encoding: UTF-8 +# -*- encoding : utf-8 -*- # == Schema Information # # Table name: public_bodies diff --git a/spec/models/purge_request_spec.rb b/spec/models/purge_request_spec.rb index 02b3d685d..642d5d2e2 100644 --- a/spec/models/purge_request_spec.rb +++ b/spec/models/purge_request_spec.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # == Schema Information # # Table name: purge_requests @@ -22,23 +23,23 @@ describe PurgeRequest, "purging things" do req = PurgeRequest.new(:url => "/begone_from_here", :model => "don't care", :model_id => "don't care") - req.save() - PurgeRequest.all().count.should == 1 - PurgeRequest.purge_all() - PurgeRequest.all().count.should == 0 + req.save + PurgeRequest.all.count.should == 1 + PurgeRequest.purge_all + PurgeRequest.all.count.should == 0 end it 'should fail silently for a misconfigured server' do FakeWeb.register_uri(:get, %r|brokenv|, :body => "BROKEN") - config = MySociety::Config.load_default() + config = MySociety::Config.load_default config['VARNISH_HOST'] = "brokencache" req = PurgeRequest.new(:url => "/begone_from_here", :model => "don't care", :model_id => "don't care") - req.save() - PurgeRequest.all().count.should == 1 - PurgeRequest.purge_all() - PurgeRequest.all().count.should == 0 + req.save + PurgeRequest.all.count.should == 1 + PurgeRequest.purge_all + PurgeRequest.all.count.should == 0 end end diff --git a/spec/models/raw_email_spec.rb b/spec/models/raw_email_spec.rb index aa82b0bc3..044c89d3f 100644 --- a/spec/models/raw_email_spec.rb +++ b/spec/models/raw_email_spec.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # == Schema Information # # Table name: raw_emails diff --git a/spec/models/spam_address_spec.rb b/spec/models/spam_address_spec.rb index f28440121..670b969b0 100644 --- a/spec/models/spam_address_spec.rb +++ b/spec/models/spam_address_spec.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # == Schema Information # # Table name: spam_addresses @@ -15,7 +16,7 @@ describe SpamAddress do describe :new do it 'requres an email address' do - SpamAddress.new().should_not be_valid + SpamAddress.new.should_not be_valid SpamAddress.new(:email => 'spam@example.org').should be_valid end diff --git a/spec/models/track_thing_spec.rb b/spec/models/track_thing_spec.rb index 3edf2d1ad..251a50803 100644 --- a/spec/models/track_thing_spec.rb +++ b/spec/models/track_thing_spec.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # == Schema Information # # Table name: track_things diff --git a/spec/models/track_things_sent_email_spec.rb b/spec/models/track_things_sent_email_spec.rb index 4675d0847..b31a989db 100644 --- a/spec/models/track_things_sent_email_spec.rb +++ b/spec/models/track_things_sent_email_spec.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # == Schema Information # # Table name: track_things_sent_emails diff --git a/spec/models/user_info_request_sent_alert_spec.rb b/spec/models/user_info_request_sent_alert_spec.rb index 69be1092b..6b4efa575 100644 --- a/spec/models/user_info_request_sent_alert_spec.rb +++ b/spec/models/user_info_request_sent_alert_spec.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # == Schema Information # # Table name: user_info_request_sent_alerts diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 2245a024f..009045bdf 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # == Schema Information # # Table name: users diff --git a/spec/models/widget_vote_spec.rb b/spec/models/widget_vote_spec.rb index b9f990eac..1a6d3833c 100644 --- a/spec/models/widget_vote_spec.rb +++ b/spec/models/widget_vote_spec.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # == Schema Information # # Table name: widget_votes diff --git a/spec/models/xapian_spec.rb b/spec/models/xapian_spec.rb index 678e3a2dc..b3f2e2b3c 100644 --- a/spec/models/xapian_spec.rb +++ b/spec/models/xapian_spec.rb @@ -1,4 +1,4 @@ -# encoding: utf-8 +# -*- encoding : utf-8 -*- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe User, " when indexing users with Xapian" do @@ -102,7 +102,7 @@ describe PublicBody, " when indexing requests by body they are to" do end # if you index via the Xapian TermGenerator, it ignores terms of this length, - # this checks we're using Document:::add_term() instead + # this checks we're using Document:::add_term instead it "should work with URL names that are longer than 64 characters" do # change the URL name of the body body = public_bodies(:geraldine_public_body) |