aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/request_controller_spec.rb14
-rw-r--r--spec/lib/sendmail_return_path_spec.rb4
-rw-r--r--spec/lib/timezone_fixes_spec.rb21
-rw-r--r--spec/models/request_mailer_spec.rb2
4 files changed, 18 insertions, 23 deletions
diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb
index 430259426..6f25b605a 100644
--- a/spec/controllers/request_controller_spec.rb
+++ b/spec/controllers/request_controller_spec.rb
@@ -1031,7 +1031,7 @@ describe RequestController, "when creating a new request" do
mail = deliveries[0]
mail.body.should =~ /This is a silly letter. It is too short to be interesting./
- response.should redirect_to(:action => 'show', :url_title => ir.url_title)
+ response.should redirect_to show_new_request_url(:url_title => ir.url_title)
# This test uses an explicit path because it's relied in
# Google Analytics goals:
response.redirected_to.should =~ /request\/why_is_your_quango_called_gerald\/new$/
@@ -1069,7 +1069,7 @@ describe RequestController, "when creating a new request" do
ir.url_title.should_not == ir2.url_title
- response.should redirect_to(:action => 'show', :url_title => ir2.url_title)
+ response.should redirect_to show_new_request_url(:url_title => ir2.url_title)
end
it 'should respect the rate limit' do
@@ -1081,14 +1081,14 @@ describe RequestController, "when creating a new request" do
:title => "What is the answer to the ultimate question?", :tag_string => "" },
:outgoing_message => { :body => "Please supply the answer from your files." },
:submitted_new_request => 1, :preview => 0
- response.should redirect_to(:action => 'show', :url_title => 'what_is_the_answer_to_the_ultima')
+ response.should redirect_to show_new_request_url(:url_title => 'what_is_the_answer_to_the_ultima')
post :new, :info_request => { :public_body_id => @body.id,
:title => "Why did the chicken cross the road?", :tag_string => "" },
:outgoing_message => { :body => "Please send me all the relevant documents you hold." },
:submitted_new_request => 1, :preview => 0
- response.should redirect_to(:action => 'show', :url_title => 'why_did_the_chicken_cross_the_ro')
+ response.should redirect_to show_new_request_url(:url_title => 'why_did_the_chicken_cross_the_ro')
post :new, :info_request => { :public_body_id => @body.id,
:title => "What's black and white and red all over?", :tag_string => "" },
@@ -1108,20 +1108,20 @@ describe RequestController, "when creating a new request" do
:title => "What is the answer to the ultimate question?", :tag_string => "" },
:outgoing_message => { :body => "Please supply the answer from your files." },
:submitted_new_request => 1, :preview => 0
- response.should redirect_to(:action => 'show', :url_title => 'what_is_the_answer_to_the_ultima')
+ response.should redirect_to show_new_request_url(:url_title => 'what_is_the_answer_to_the_ultima')
post :new, :info_request => { :public_body_id => @body.id,
:title => "Why did the chicken cross the road?", :tag_string => "" },
:outgoing_message => { :body => "Please send me all the relevant documents you hold." },
:submitted_new_request => 1, :preview => 0
- response.should redirect_to(:action => 'show', :url_title => 'why_did_the_chicken_cross_the_ro')
+ response.should redirect_to show_new_request_url(:url_title => 'why_did_the_chicken_cross_the_ro')
post :new, :info_request => { :public_body_id => @body.id,
:title => "What's black and white and red all over?", :tag_string => "" },
:outgoing_message => { :body => "Please send all minutes of meetings and email records that address this question." },
:submitted_new_request => 1, :preview => 0
- response.should redirect_to(:action => 'show', :url_title => 'whats_black_and_white_and_red_al')
+ response.should redirect_to show_new_request_url(:url_title => 'whats_black_and_white_and_red_al')
end
end
diff --git a/spec/lib/sendmail_return_path_spec.rb b/spec/lib/sendmail_return_path_spec.rb
index 7708edb35..137869b6e 100644
--- a/spec/lib/sendmail_return_path_spec.rb
+++ b/spec/lib/sendmail_return_path_spec.rb
@@ -28,7 +28,7 @@ describe "when sending email with an altered return path" do
Net::SMTP.stub!(:new).and_return(mock_smtp)
with_delivery_method :smtp do
- ContactMailer.deliver_message(
+ ContactMailer.deliver_to_admin_message(
"Mr. Test", "test@localhost", "Test script spec/lib/sendmail_return_path_spec.rb",
"This is just a test for a test script", nil, nil, nil
)
@@ -42,7 +42,7 @@ describe "when sending email with an altered return path" do
with_stub_popen do
IO.should_receive(:popen).once.with('/usr/sbin/sendmail -i -t -f "test@localhost"', "w+")
with_delivery_method :sendmail do
- ContactMailer.deliver_message(
+ ContactMailer.deliver_to_admin_message(
"Mr. Test", "test@localhost", "Test script spec/lib/sendmail_return_path_spec.rb",
"This is just a test for a test script", nil, nil, nil
)
diff --git a/spec/lib/timezone_fixes_spec.rb b/spec/lib/timezone_fixes_spec.rb
index 525bd7561..9d6ade526 100644
--- a/spec/lib/timezone_fixes_spec.rb
+++ b/spec/lib/timezone_fixes_spec.rb
@@ -11,14 +11,13 @@ describe "when doing things with timezones" do
with_active_record_default_timezone :utc do
time = Time.local(2000)
mail_server_log_done = MailServerLogDone.create('last_stat' => time, 'filename' => 'dummy')
- raw_saved_time = MailServerLogDone.find(mail_server_log_done.id).read_attribute(:last_stat)
+ raw_saved_time = MailServerLogDone.find(mail_server_log_done.id).attributes_before_type_cast["last_stat"]
saved_time = MailServerLogDone.find(mail_server_log_done.id).last_stat
assert_equal time, saved_time
- assert_equal saved_time, raw_saved_time
# Time is created in EST by local method (using ENV['TZ'])
assert_equal [0, 0, 0, 1, 1, 2000, 6, 1, false, "EST"], time.to_a
# Due to :utc active_record_default_timezone, everything saved as UTC
- assert_equal [0, 0, 5, 1, 1, 2000, 6, 1, false, "UTC"], raw_saved_time.to_a
+ assert_equal "2000-01-01 05:00:00", raw_saved_time
# As config.time_zone is UTC (from config default), times returned in UTC
assert_equal [0, 0, 5, 1, 1, 2000, 6, 1, false, "UTC"], saved_time.to_a
end
@@ -33,14 +32,12 @@ describe "when doing things with timezones" do
Time.use_zone 'Central Time (US & Canada)' do
time = Time.zone.local(2000)
mail_server_log_done = MailServerLogDone.create('last_stat' => time, 'filename' => 'dummy')
- raw_saved_time = MailServerLogDone.find(mail_server_log_done.id).read_attribute(:last_stat)
+ raw_saved_time = MailServerLogDone.find(mail_server_log_done.id).attributes_before_type_cast["last_stat"]
saved_time = MailServerLogDone.find(mail_server_log_done.id).last_stat
- assert_equal time, saved_time
- assert_equal saved_time, raw_saved_time
# Time is created in CST by Time.local (as Time.zone has been set)
assert_equal [0, 0, 0, 1, 1, 2000, 6, 1, false, "CST"], time.to_a
# Due to :utc active_record_default_timezone, everything saved as UTC
- assert_equal [0, 0, 6, 1, 1, 2000, 6, 1, false, "UTC"], raw_saved_time.to_a
+ assert_equal "2000-01-01 06:00:00", raw_saved_time
# Times returned in CST due to Time.use_zone and ActiveRecord::time_zone_aware_attributes
# being true
assert_equal [0, 0, 0, 1, 1, 2000, 6, 1, false, "CST"], saved_time.to_a
@@ -55,14 +52,13 @@ describe "when doing things with timezones" do
with_active_record_default_timezone :local do
time = Time.utc(2000)
mail_server_log_done = MailServerLogDone.create('last_stat' => time, 'filename' => 'dummy')
- raw_saved_time = MailServerLogDone.find(mail_server_log_done.id).read_attribute(:last_stat)
+ raw_saved_time = MailServerLogDone.find(mail_server_log_done.id).attributes_before_type_cast["last_stat"]
saved_time = MailServerLogDone.find(mail_server_log_done.id).last_stat
assert_equal time, saved_time
- assert_equal saved_time, raw_saved_time
# Time is created in UTC by Time.utc method
assert_equal [0, 0, 0, 1, 1, 2000, 6, 1, false, "UTC"], time.to_a
# Due to :local active_record_default_timezone, saved as EST
- assert_equal [0, 0, 19, 31, 12, 1999, 5, 365, false, "EST"], raw_saved_time.to_a
+ assert_equal "1999-12-31 19:00:00", raw_saved_time
# As config.time_zone is UTC (from config default), times returned in UTC
assert_equal [0, 0, 0, 1, 1, 2000, 6, 1, false, "UTC"], saved_time.to_a
end
@@ -76,14 +72,13 @@ describe "when doing things with timezones" do
Time.use_zone 'Central Time (US & Canada)' do
time = Time.zone.local(2000)
mail_server_log_done = MailServerLogDone.create('last_stat' => time, 'filename' => 'dummy')
- raw_saved_time = MailServerLogDone.find(mail_server_log_done.id).read_attribute(:last_stat)
+ raw_saved_time = MailServerLogDone.find(mail_server_log_done.id).attributes_before_type_cast["last_stat"]
saved_time = MailServerLogDone.find(mail_server_log_done.id).last_stat
assert_equal time, saved_time
- assert_equal saved_time, raw_saved_time
# Time is created in CST by Time.zone.local
assert_equal [0, 0, 0, 1, 1, 2000, 6, 1, false, "CST"], time.to_a
# Due to :local active_record_default_timezone, saved as EST
- assert_equal [0, 0, 1, 1, 1, 2000, 6, 1, false, "EST"], raw_saved_time.to_a
+ assert_equal "2000-01-01 01:00:00", raw_saved_time
# Due to Time.use_zone, and ActiveRecord::time_zone_aware_attributes
# being true, time returned in CST
assert_equal [0, 0, 0, 1, 1, 2000, 6, 1, false, "CST"], saved_time.to_a
diff --git a/spec/models/request_mailer_spec.rb b/spec/models/request_mailer_spec.rb
index 0f09e6926..5edc8edb6 100644
--- a/spec/models/request_mailer_spec.rb
+++ b/spec/models/request_mailer_spec.rb
@@ -98,7 +98,7 @@ describe RequestMailer, " when receiving incoming mail" do
mail.multipart?.should == true
mail.parts.size.should == 2
message_part = mail.parts[0].to_s
- bounced_mail = MailHandler.mail_from_raw_email(mail.parts[1].body, decode=false)
+ bounced_mail = MailHandler.mail_from_raw_email(mail.parts[1].body)
bounced_mail.to.should == [ ir.incoming_email ]
bounced_mail.from.should == [ 'geraldinequango@localhost' ]
bounced_mail.body.include?("That's so totally a rubbish question").should be_true