aboutsummaryrefslogtreecommitdiffstats
path: root/spec/models
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/incoming_message_spec.rb47
-rw-r--r--spec/models/info_request_spec.rb12
-rw-r--r--spec/models/mail_server_log_spec.rb166
-rw-r--r--spec/models/track_thing_spec.rb9
-rw-r--r--spec/models/user_spec.rb98
5 files changed, 265 insertions, 67 deletions
diff --git a/spec/models/incoming_message_spec.rb b/spec/models/incoming_message_spec.rb
index cf84b4595..b038c43d9 100644
--- a/spec/models/incoming_message_spec.rb
+++ b/spec/models/incoming_message_spec.rb
@@ -12,6 +12,14 @@ describe IncomingMessage, " when dealing with incoming mail" do
ActionMailer::Base.deliveries.clear
end
+ it 'should correctly parse multipart mails with a linebreak in the boundary marker' do
+ ir = info_requests(:fancy_dog_request)
+ receive_incoming_mail('space-boundary.email', ir.incoming_email)
+ message = ir.incoming_messages[1]
+ message.mail.parts.size.should == 2
+ message.mail.multipart?.should == true
+ end
+
it "should return the mail Date header date for sent at" do
@im.parse_raw_email!(true)
@im.reload
@@ -60,7 +68,6 @@ describe IncomingMessage, " when dealing with incoming mail" do
is not good utf-8' do
ir = info_requests(:fancy_dog_request)
receive_incoming_mail('no-part-charset-bad-utf8.email', ir.incoming_email)
- puts ir.incoming_messages.inspect
message = ir.incoming_messages[1]
message.parse_raw_email!
message.get_main_body_text_internal.should include("The above text was badly encoded")
@@ -125,21 +132,45 @@ end
describe IncomingMessage, " folding quoted parts of emails" do
- it "cope with [ in user names properly" do
- @user = mock_model(User)
- @user.stub!(:name).and_return("Sir [ Bobble")
- @info_request = mock_model(InfoRequest)
- @info_request.stub!(:user).and_return(@user)
- @info_request.stub!(:user_name).and_return(@user.name)
+ it 'should fold an example lotus notes quoted part converted from HTML correctly' do
+ ir = info_requests(:fancy_dog_request)
+ receive_incoming_mail('lotus-notes-quoting.email', ir.incoming_email)
+ message = ir.incoming_messages[1]
+ message.get_main_body_text_folded.should match(/FOLDED_QUOTED_SECTION/)
+ end
+ 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.info_request = @info_request
+ @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 "cope with [ in user names properly" do
+ @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")
text.should == "\n\nFOLDED_QUOTED_SECTION"
end
+ it 'should fold an example of another kind of forward quoting' do
+ ir = info_requests(:fancy_dog_request)
+ receive_incoming_mail('forward-quoting-example.email', ir.incoming_email)
+ message = ir.incoming_messages[1]
+ message.get_main_body_text_folded.should match(/FOLDED_QUOTED_SECTION/)
+ end
+
+ it 'should fold a further example of forward quoting' do
+ ir = info_requests(:fancy_dog_request)
+ receive_incoming_mail('forward-quoting-example-2.email', ir.incoming_email)
+ message = ir.incoming_messages[1]
+ body_text = message.get_main_body_text_folded
+ body_text.should match(/FOLDED_QUOTED_SECTION/)
+ # check that the quoted section incorporates both quoted messages
+ body_text.should_not match('Subject: RE: Freedom of Information request')
+ end
+
end
describe IncomingMessage, " checking validity to reply to" do
diff --git a/spec/models/info_request_spec.rb b/spec/models/info_request_spec.rb
index 204c600d9..2aeac2fec 100644
--- a/spec/models/info_request_spec.rb
+++ b/spec/models/info_request_spec.rb
@@ -441,16 +441,16 @@ describe InfoRequest do
describe 'when applying censor rules' do
before do
- @global_rule = mock_model(CensorRule, :apply_to_text! => nil,
+ @global_rule = safe_mock_model(CensorRule, :apply_to_text! => nil,
:apply_to_binary! => nil)
- @user_rule = mock_model(CensorRule, :apply_to_text! => nil,
+ @user_rule = safe_mock_model(CensorRule, :apply_to_text! => nil,
:apply_to_binary! => nil)
- @request_rule = mock_model(CensorRule, :apply_to_text! => nil,
+ @request_rule = safe_mock_model(CensorRule, :apply_to_text! => nil,
:apply_to_binary! => nil)
- @body_rule = mock_model(CensorRule, :apply_to_text! => nil,
+ @body_rule = safe_mock_model(CensorRule, :apply_to_text! => nil,
:apply_to_binary! => nil)
- @user = mock_model(User, :censor_rules => [@user_rule])
- @body = mock_model(PublicBody, :censor_rules => [@body_rule])
+ @user = safe_mock_model(User, :censor_rules => [@user_rule])
+ @body = safe_mock_model(PublicBody, :censor_rules => [@body_rule])
@info_request = InfoRequest.new(:prominence => 'normal',
:awaiting_description => true,
:title => 'title')
diff --git a/spec/models/mail_server_log_spec.rb b/spec/models/mail_server_log_spec.rb
new file mode 100644
index 000000000..d0a1d202f
--- /dev/null
+++ b/spec/models/mail_server_log_spec.rb
@@ -0,0 +1,166 @@
+require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+
+describe MailServerLog do
+ describe ".load_file" do
+ before :each do
+ Configuration.stub!(:incoming_email_domain).and_return("example.com")
+ File.stub_chain(:stat, :mtime).and_return(DateTime.new(2012, 10, 10))
+ end
+
+ let(:log) {[
+ "This is a line of a logfile relevant to foi+request-1234@example.com",
+ "This is the second line for the same foi+request-1234@example.com email address"
+ ]}
+
+ let(:ir) { info_requests(:fancy_dog_request) }
+
+ it "loads relevant lines of an uncompressed exim log file" do
+ File.should_receive(:open).with("/var/log/exim4/exim-mainlog-2012-10-10", "r").and_return(log)
+ InfoRequest.should_receive(:find_by_incoming_email).with("request-1234@example.com").twice.and_return(ir)
+ MailServerLog.load_file("/var/log/exim4/exim-mainlog-2012-10-10")
+
+ ir.mail_server_logs.count.should == 2
+ log = ir.mail_server_logs[0]
+ log.order.should == 1
+ log.line.should == "This is a line of a logfile relevant to foi+request-1234@example.com"
+
+ log = ir.mail_server_logs[1]
+ log.order.should == 2
+ log.line.should == "This is the second line for the same foi+request-1234@example.com email address"
+ end
+
+ it "doesn't load the log file twice if it's unchanged" do
+ File.should_receive(:open).with("/var/log/exim4/exim-mainlog-2012-10-10", "r").once.and_return([])
+
+ MailServerLog.load_file("/var/log/exim4/exim-mainlog-2012-10-10")
+ MailServerLog.load_file("/var/log/exim4/exim-mainlog-2012-10-10")
+ end
+
+ it "loads the log file again if it's changed" do
+ File.should_receive(:open).with("/var/log/exim4/exim-mainlog-2012-10-10", "r").twice.and_return([])
+ MailServerLog.load_file("/var/log/exim4/exim-mainlog-2012-10-10")
+ File.stub_chain(:stat, :mtime).and_return(DateTime.new(2012, 10, 11))
+ MailServerLog.load_file("/var/log/exim4/exim-mainlog-2012-10-10")
+ end
+
+ it "doesn't end up with two copies of each line when the same file is actually loaded twice" do
+ File.should_receive(:open).with("/var/log/exim4/exim-mainlog-2012-10-10", "r").twice.and_return(log)
+ InfoRequest.should_receive(:find_by_incoming_email).with("request-1234@example.com").any_number_of_times.and_return(ir)
+
+ MailServerLog.load_file("/var/log/exim4/exim-mainlog-2012-10-10")
+ ir.mail_server_logs.count.should == 2
+
+ File.stub_chain(:stat, :mtime).and_return(DateTime.new(2012, 10, 11))
+ MailServerLog.load_file("/var/log/exim4/exim-mainlog-2012-10-10")
+ ir.mail_server_logs.count.should == 2
+ end
+
+ it "easily handles gzip compress log files" do
+ File.should_not_receive(:open)
+ Zlib::GzipReader.should_receive(:open).with("/var/log/exim4/exim-mainlog-2012-10-10.gz").and_return([])
+ MailServerLog.load_file("/var/log/exim4/exim-mainlog-2012-10-10.gz")
+ end
+ end
+
+ describe ".email_addresses_on_line" do
+ before :each do
+ Configuration.stub!(:incoming_email_domain).and_return("example.com")
+ Configuration.stub!(:incoming_email_prefix).and_return("foi+")
+ end
+
+ it "recognises a single incoming email" do
+ MailServerLog.email_addresses_on_line("a random log line foi+request-14-e0e09f97@example.com has an email").should ==
+ ["foi+request-14-e0e09f97@example.com"]
+ end
+
+ it "recognises two email addresses on the same line" do
+ MailServerLog.email_addresses_on_line("two email addresses here foi+request-10-1234@example.com and foi+request-14-e0e09f97@example.com").should ==
+ ["foi+request-10-1234@example.com", "foi+request-14-e0e09f97@example.com"]
+ end
+
+ it "returns an empty array when there is an email address from a different domain" do
+ MailServerLog.email_addresses_on_line("other foi+request-10-1234@foo.com").should be_empty
+ end
+
+ it "ignores an email with a different prefix" do
+ MailServerLog.email_addresses_on_line("foitest+request-14-e0e09f97@example.com").should be_empty
+ end
+
+ it "ignores an email where the . is substituted for something else" do
+ MailServerLog.email_addresses_on_line("foi+request-14-e0e09f97@exampledcom").should be_empty
+ end
+ end
+
+ context "Postfix" do
+ let(:log) {[
+"Oct 3 16:39:35 host postfix/pickup[2257]: CB55836EE58C: uid=1003 from=<foitest+request-14-e0e09f97@example.com>",
+"Oct 3 16:39:35 host postfix/cleanup[7674]: CB55836EE58C: message-id=<ogm-15+506bdda7a4551-20ee@example.com>",
+"Oct 3 16:39:35 host postfix/qmgr[1673]: 9634B16F7F7: from=<foitest+request-10-1234@example.com>, size=368, nrcpt=1 (queue active)",
+"Oct 3 16:39:35 host postfix/qmgr[15615]: CB55836EE58C: from=<foitest+request-14-e0e09f97@example.com>, size=1695, nrcpt=1 (queue active)",
+"Oct 3 16:39:38 host postfix/smtp[7676]: CB55836EE58C: to=<foi@some.gov.au>, relay=aspmx.l.google.com[74.125.25.27]:25, delay=2.5, delays=0.13/0.02/1.7/0.59, dsn=2.0.0, status=sent (250 2.0.0 OK 1349246383 j9si1676296paw.328)",
+"Oct 3 16:39:38 host postfix/smtp[1681]: 9634B16F7F7: to=<kdent@example.com>, relay=none, delay=46, status=deferred (connect to 216.150.150.131[216.150.150.131]: No route to host)",
+"Oct 3 16:39:38 host postfix/qmgr[15615]: CB55836EE58C: removed",
+ ]}
+
+ describe ".load_postfix_log_data" do
+ # Postfix logs for a single email go over multiple lines. They are all tied together with the Queue ID.
+ # See http://onlamp.com/onlamp/2004/01/22/postfix.html
+ it "loads the postfix log and untangles seperate email transactions using the queue ID" do
+ Configuration.stub!(:incoming_email_domain).and_return("example.com")
+ log.stub!(:rewind)
+ ir1 = info_requests(:fancy_dog_request)
+ ir2 = info_requests(:naughty_chicken_request)
+ InfoRequest.should_receive(:find_by_incoming_email).with("request-14-e0e09f97@example.com").any_number_of_times.and_return(ir1)
+ InfoRequest.should_receive(:find_by_incoming_email).with("request-10-1234@example.com").any_number_of_times.and_return(ir2)
+ MailServerLog.load_postfix_log_data(log, MailServerLogDone.new(:filename => "foo", :last_stat => DateTime.now))
+ # TODO: Check that each log line is attached to the correct request
+ ir1.mail_server_logs.count.should == 5
+ ir1.mail_server_logs[0].order.should == 1
+ ir1.mail_server_logs[0].line.should == "Oct 3 16:39:35 host postfix/pickup[2257]: CB55836EE58C: uid=1003 from=<foitest+request-14-e0e09f97@example.com>"
+ ir1.mail_server_logs[1].order.should == 2
+ ir1.mail_server_logs[1].line.should == "Oct 3 16:39:35 host postfix/cleanup[7674]: CB55836EE58C: message-id=<ogm-15+506bdda7a4551-20ee@example.com>"
+ ir1.mail_server_logs[2].order.should == 4
+ ir1.mail_server_logs[2].line.should == "Oct 3 16:39:35 host postfix/qmgr[15615]: CB55836EE58C: from=<foitest+request-14-e0e09f97@example.com>, size=1695, nrcpt=1 (queue active)"
+ ir1.mail_server_logs[3].order.should == 5
+ ir1.mail_server_logs[3].line.should == "Oct 3 16:39:38 host postfix/smtp[7676]: CB55836EE58C: to=<foi@some.gov.au>, relay=aspmx.l.google.com[74.125.25.27]:25, delay=2.5, delays=0.13/0.02/1.7/0.59, dsn=2.0.0, status=sent (250 2.0.0 OK 1349246383 j9si1676296paw.328)"
+ ir1.mail_server_logs[4].order.should == 7
+ ir1.mail_server_logs[4].line.should == "Oct 3 16:39:38 host postfix/qmgr[15615]: CB55836EE58C: removed"
+ ir2.mail_server_logs.count.should == 2
+ ir2.mail_server_logs[0].order.should == 3
+ ir2.mail_server_logs[0].line.should == "Oct 3 16:39:35 host postfix/qmgr[1673]: 9634B16F7F7: from=<foitest+request-10-1234@example.com>, size=368, nrcpt=1 (queue active)"
+ ir2.mail_server_logs[1].order.should == 6
+ ir2.mail_server_logs[1].line.should == "Oct 3 16:39:38 host postfix/smtp[1681]: 9634B16F7F7: to=<kdent@example.com>, relay=none, delay=46, status=deferred (connect to 216.150.150.131[216.150.150.131]: No route to host)"
+ end
+ end
+
+ describe ".scan_for_postfix_queue_ids" do
+ it "returns the queue ids of interest with the connected email addresses" do
+ Configuration.stub!(:incoming_email_domain).and_return("example.com")
+ MailServerLog.scan_for_postfix_queue_ids(log).should == {
+ "CB55836EE58C" => ["request-14-e0e09f97@example.com"],
+ "9634B16F7F7" => ["request-10-1234@example.com"]
+ }
+ end
+ end
+
+ describe ".extract_postfix_queue_id_from_syslog_line" do
+ it "returns nil if there is no queue id" do
+ MailServerLog.extract_postfix_queue_id_from_syslog_line("Oct 7 07:16:48 kedumba postfix/smtp[14294]: connect to mail.neilcopp.com.au[110.142.151.66]:25: Connection refused").should be_nil
+ end
+ end
+
+ describe ".request_postfix_sent?" do
+ it "returns true when the logs say the message was sent" do
+ ir = info_requests(:fancy_dog_request)
+ ir.mail_server_logs.create!(:line => "Oct 10 16:58:38 kedumba postfix/smtp[26358]: A664436F218D: to=<contact@openaustraliafoundation.org.au>, relay=aspmx.l.google.com[74.125.25.26]:25, delay=2.7, delays=0.16/0.02/1.8/0.67, dsn=2.0.0, status=sent (250 2.0.0 OK 1349848723 e6si653316paw.346)", :order => 1)
+ MailServerLog.request_postfix_sent?(ir).should be_true
+ end
+
+ it "returns false when the logs say the message hasn't been sent" do
+ ir = info_requests(:fancy_dog_request)
+ ir.mail_server_logs.create!(:line => "Oct 10 13:22:49 kedumba postfix/smtp[11876]: 6FB9036F1307: to=<foo@example.com>, relay=mta7.am0.yahoodns.net[74.6.136.244]:25, delay=1.5, delays=0.03/0/0.48/1, dsn=5.0.0, status=bounced (host mta7.am0.yahoodns.net[74.6.136.244] said: 554 delivery error: dd Sorry your message to foo@example.com cannot be delivered. This account has been disabled or discontinued [#102]. - mta1272.mail.sk1.yahoo.com (in reply to end of DATA command))", :order => 1)
+ MailServerLog.request_postfix_sent?(ir).should be_false
+ end
+ end
+ end
+end
diff --git a/spec/models/track_thing_spec.rb b/spec/models/track_thing_spec.rb
index 345629bd6..c42eb5e8b 100644
--- a/spec/models/track_thing_spec.rb
+++ b/spec/models/track_thing_spec.rb
@@ -35,10 +35,11 @@ describe TrackThing, "when tracking changes" do
end
it "will make some sane descriptions of search-based tracks" do
- tests = [['bob variety:user', "users matching text 'bob'"],
- ['bob (variety:sent OR variety:followup_sent OR variety:response OR variety:comment) (latest_status:successful OR latest_status:partially_successful OR latest_status:rejected OR latest_status:not_held)', "comments or requests which are successful or unsuccessful matching text 'bob'"],
- ['(latest_status:waiting_response OR latest_status:waiting_clarification OR waiting_classification:true)', 'requests which are awaiting a response']]
- for query, description in tests
+ tests = { 'bob variety:user' => "users matching text 'bob'",
+ 'bob (variety:sent OR variety:followup_sent OR variety:response OR variety:comment) (latest_status:successful OR latest_status:partially_successful OR latest_status:rejected OR latest_status:not_held)' => "comments or requests which are successful or unsuccessful matching text 'bob'",
+ '(latest_status:waiting_response OR latest_status:waiting_clarification OR waiting_classification:true)' => 'requests which are awaiting a response',
+ ' (variety:sent OR variety:followup_sent OR variety:response OR variety:comment)' => 'all requests or comments' }
+ tests.each do |query, description|
track_thing = TrackThing.create_track_for_search_query(query)
track_thing.track_query_description.should == description
end
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 03b2f34f9..e31c3f1b5 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -1,42 +1,42 @@
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
-describe User, "making up the URL name" do
+describe User, "making up the URL name" do
before do
@user = User.new
end
- it 'should remove spaces, and make lower case' do
+ it 'should remove spaces, and make lower case' do
@user.name = 'Some Name'
@user.url_name.should == 'some_name'
end
- it 'should not allow a numeric name' do
+ it 'should not allow a numeric name' do
@user.name = '1234'
@user.url_name.should == 'user'
end
end
-describe User, "showing the name" do
+describe User, "showing the name" do
before do
@user = User.new
@user.name = 'Some Name '
end
- it 'should strip whitespace' do
+ it 'should strip whitespace' do
@user.name.should == 'Some Name'
end
- it 'should show if user has been banned' do
+ it 'should show if user has been banned' do
@user.ban_text = "Naughty user"
@user.name.should == 'Some Name (Account suspended)'
end
end
-
+
describe User, " when authenticating" do
before do
- @empty_user = User.new
+ @empty_user = User.new
@full_user = User.new
@full_user.name = "Sensible User"
@@ -71,7 +71,7 @@ end
describe User, " when saving" do
before do
- @user = User.new
+ @user = User.new
end
it "should not save without setting some parameters" do
@@ -80,7 +80,7 @@ describe User, " when saving" do
it "should not save with misformatted email" do
@user.name = "Mr. Silly"
- @user.password = "insecurepassword"
+ @user.password = "insecurepassword"
@user.email = "mousefooble"
@user.should have(1).error_on(:email)
end
@@ -88,58 +88,58 @@ describe User, " when saving" do
it "should not allow an email address as a name" do
@user.name = "silly@example.com"
@user.email = "silly@example.com"
- @user.password = "insecurepassword"
+ @user.password = "insecurepassword"
@user.should have(1).error_on(:name)
end
it "should not save with no password" do
@user.name = "Mr. Silly"
- @user.password = ""
+ @user.password = ""
@user.email = "silly@localhost"
@user.should have(1).error_on(:hashed_password)
end
it "should save with reasonable name, password and email" do
@user.name = "Mr. Reasonable"
- @user.password = "insecurepassword"
+ @user.password = "insecurepassword"
@user.email = "reasonable@localhost"
@user.save!
end
it "should let you make two users with same name" do
@user.name = "Mr. Flobble"
- @user.password = "insecurepassword"
+ @user.password = "insecurepassword"
@user.email = "flobble@localhost"
@user.save!
- @user2 = User.new
+ @user2 = User.new
@user2.name = "Mr. Flobble"
- @user2.password = "insecurepassword"
+ @user2.password = "insecurepassword"
@user2.email = "flobble2@localhost"
@user2.save!
end
-
+
it 'should mark the model for reindexing in xapian if the no_xapian_reindex flag is set to false' do
@user.name = "Mr. First"
- @user.password = "insecurepassword"
+ @user.password = "insecurepassword"
@user.email = "reasonable@localhost"
@user.no_xapian_reindex = false
@user.should_receive(:xapian_mark_needs_index)
@user.save!
end
-
+
it 'should mark the model for reindexing in xapian if the no_xapian_reindex flag is not set' do
@user.name = "Mr. Second"
- @user.password = "insecurepassword"
+ @user.password = "insecurepassword"
@user.email = "reasonable@localhost"
@user.no_xapian_reindex = nil
@user.should_receive(:xapian_mark_needs_index)
@user.save!
end
-
- it 'should not mark the model for reindexing in xapian if the no_xapian_reindex flag is set' do
+
+ it 'should not mark the model for reindexing in xapian if the no_xapian_reindex flag is set' do
@user.name = "Mr. Third"
- @user.password = "insecurepassword"
+ @user.password = "insecurepassword"
@user.email = "reasonable@localhost"
@user.no_xapian_reindex = true
@user.should_not_receive(:xapian_mark_needs_index)
@@ -149,47 +149,47 @@ describe User, " when saving" do
end
-describe User, "when reindexing referencing models" do
+describe User, "when reindexing referencing models" do
- before do
+ before do
@request_event = safe_mock_model(InfoRequestEvent, :xapian_mark_needs_index => true)
@request = safe_mock_model(InfoRequest, :info_request_events => [@request_event])
@comment_event = safe_mock_model(InfoRequestEvent, :xapian_mark_needs_index => true)
@comment = safe_mock_model(Comment, :info_request_events => [@comment_event])
@user = User.new(:comments => [@comment], :info_requests => [@request])
end
-
- it 'should reindex events associated with that user\'s comments when URL changes' do
+
+ it 'should reindex events associated with that user\'s comments when URL changes' do
@user.stub!(:changes).and_return({'url_name' => 1})
@comment_event.should_receive(:xapian_mark_needs_index)
@user.reindex_referencing_models
end
-
- it 'should reindex events associated with that user\'s requests when URL changes' do
+
+ it 'should reindex events associated with that user\'s requests when URL changes' do
@user.stub!(:changes).and_return({'url_name' => 1})
@request_event.should_receive(:xapian_mark_needs_index)
@user.reindex_referencing_models
end
-
- describe 'when no_xapian_reindex is set' do
- before do
+
+ describe 'when no_xapian_reindex is set' do
+ before do
@user.no_xapian_reindex = true
end
-
- it 'should not reindex events associated with that user\'s comments when URL changes' do
+
+ it 'should not reindex events associated with that user\'s comments when URL changes' do
@user.stub!(:changes).and_return({'url_name' => 1})
@comment_event.should_not_receive(:xapian_mark_needs_index)
@user.reindex_referencing_models
end
-
- it 'should not reindex events associated with that user\'s requests when URL changes' do
+
+ it 'should not reindex events associated with that user\'s requests when URL changes' do
@user.stub!(:changes).and_return({'url_name' => 1})
@request_event.should_not_receive(:xapian_mark_needs_index)
@user.reindex_referencing_models
end
-
+
end
-
+
end
describe User, "when checking abilities" do
@@ -208,26 +208,26 @@ describe User, "when checking abilities" do
end
-describe User, 'when asked if a user owns every request' do
-
- before do
+describe User, 'when asked if a user owns every request' do
+
+ before do
@mock_user = mock_model(User)
end
-
- it 'should return false if no user is passed' do
+
+ it 'should return false if no user is passed' do
User.owns_every_request?(nil).should be_false
end
-
- it 'should return true if the user has "requires admin" power' do
+
+ it 'should return true if the user has "requires admin" power' do
@mock_user.stub!(:owns_every_request?).and_return true
User.owns_every_request?(@mock_user).should be_true
end
-
- it 'should return false if the user does not have "requires admin" power' do
+
+ it 'should return false if the user does not have "requires admin" power' do
@mock_user.stub!(:owns_every_request?).and_return false
User.owns_every_request?(@mock_user).should be_false
end
-
+
end
describe User, " when making name and email address" do
@@ -296,7 +296,7 @@ describe User, "when emails have bounced" do
it "should record bounces" do
User.record_bounce_for_email("bob@localhost", "The reason we think the email bounced (e.g. a bounce message)")
-
+
user = User.find_user_by_email("bob@localhost")
user.email_bounced_at.should_not be_nil
user.email_bounce_message.should == "The reason we think the email bounced (e.g. a bounce message)"