From 6b790cc3291018bfe41c88e1ae88c1d9a0c650f1 Mon Sep 17 00:00:00 2001 From: Robin Houston Date: Fri, 3 Feb 2012 18:41:47 +0000 Subject: Eliminate trailing spaces in test names Really, what was that about? --- spec/controllers/request_controller_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'spec/controllers/request_controller_spec.rb') diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb index 25dce3f22..1211e03bb 100644 --- a/spec/controllers/request_controller_spec.rb +++ b/spec/controllers/request_controller_spec.rb @@ -300,7 +300,7 @@ describe RequestController, "when showing one request" do }.should raise_error(ActiveRecord::RecordNotFound) end - it "should generate valid HTML verson of PDF attachments " do + it "should generate valid HTML verson of PDF attachments" do ir = info_requests(:fancy_dog_request) receive_incoming_mail('incoming-request-pdf-attachment.email', ir.incoming_email) ir.reload @@ -309,7 +309,7 @@ describe RequestController, "when showing one request" do response.should have_text(/Walberswick Parish Council/) end - it "should not cause a reparsing of the raw email, even when the result would be a 404 " do + it "should not cause a reparsing of the raw email, even when the result would be a 404" do ir = info_requests(:fancy_dog_request) receive_incoming_mail('incoming-request-two-same-name.email', ir.incoming_email) ir.reload -- cgit v1.2.3 From 8584824006b987fb260636fe65ff525f3b2acf52 Mon Sep 17 00:00:00 2001 From: Robin Houston Date: Fri, 3 Feb 2012 22:13:40 +0000 Subject: Test should not depend on nondeterministic order Issue #409 seems to be another problem of the same type as #408, though with the important difference that the bug in this case is in the test suite rather than the code under test. RequestMailer sends alert emails warning of overdue requests. However it does not specify the order that these messages are sent in, but runs over the overdue requests in whatever order they are returned by a database query (that does not have an order by clause). Therefore it is not safe for the test code to assume that the alert mails will have been sent in a particular order: just as with #408 it seems that they were *usually* sent in the order assumed by the test code, but occasionally not -- which would result in sporadic test failures. Closes #409. --- spec/controllers/request_controller_spec.rb | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'spec/controllers/request_controller_spec.rb') diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb index 1211e03bb..9018f76fe 100644 --- a/spec/controllers/request_controller_spec.rb +++ b/spec/controllers/request_controller_spec.rb @@ -1319,9 +1319,10 @@ describe RequestController, "sending overdue request alerts" do RequestMailer.alert_overdue_requests - deliveries = ActionMailer::Base.deliveries - deliveries.size.should == 2 - mail = deliveries[1] + chicken_mails = ActionMailer::Base.deliveries.select{|x| x.body =~ /chickens/} + chicken_mails.size.should == 1 + mail = chicken_mails[0] + mail.body.should =~ /promptly, as normally/ mail.to_addrs.first.to_s.should == info_requests(:naughty_chicken_request).user.name_and_email @@ -1347,9 +1348,10 @@ describe RequestController, "sending overdue request alerts" do RequestMailer.alert_overdue_requests - deliveries = ActionMailer::Base.deliveries - deliveries.size.should == 2 - mail = deliveries[1] + chicken_mails = ActionMailer::Base.deliveries.select{|x| x.body =~ /chickens/} + chicken_mails.size.should == 1 + mail = chicken_mails[0] + mail.body.should =~ /promptly, as normally/ mail.to_addrs.first.to_s.should == info_requests(:naughty_chicken_request).user.name_and_email end @@ -1372,9 +1374,10 @@ describe RequestController, "sending overdue request alerts" do RequestMailer.alert_overdue_requests - deliveries = ActionMailer::Base.deliveries - deliveries.size.should == 2 - mail = deliveries[1] + chicken_mails = ActionMailer::Base.deliveries.select{|x| x.body =~ /chickens/} + chicken_mails.size.should == 1 + mail = chicken_mails[0] + mail.body.should =~ /required by law/ mail.to_addrs.first.to_s.should == info_requests(:naughty_chicken_request).user.name_and_email -- cgit v1.2.3