From 64eb387b83846ead2bbce76c26224533ea24ebc9 Mon Sep 17 00:00:00 2001 From: Henare Degan Date: Wed, 3 Oct 2012 17:53:38 +1000 Subject: Requires admin attention emails should include a full URL to the admin page of the request so you can click it, not just a relative path --- spec/models/request_mailer_spec.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'spec/models') diff --git a/spec/models/request_mailer_spec.rb b/spec/models/request_mailer_spec.rb index 84804d4ca..57041b417 100644 --- a/spec/models/request_mailer_spec.rb +++ b/spec/models/request_mailer_spec.rb @@ -327,3 +327,18 @@ describe RequestMailer, 'when sending mail when someone has updated an old uncla end +describe RequestMailer, 'requires_admin' do + it 'body should contain the full admin URL' do + user = mock_model(User, :name_and_email => 'Bruce Jones', + :name => 'Bruce Jones') + info_request = mock_model(InfoRequest, :user => user, + :described_state => 'error_message', + :title => 'Test request', + :url_title => 'test_request', + :law_used_short => 'FOI', + :id => 123) + mail = RequestMailer.deliver_requires_admin(info_request) + + mail.body.should include('http://test.host/admin/request/show/123') + end +end -- cgit v1.2.3 From ad141d768561cfc8f6617dc2de3eeb24255e154f Mon Sep 17 00:00:00 2001 From: Henare Degan Date: Thu, 4 Oct 2012 11:58:07 +1000 Subject: Add failing test for when ADMIN_BASE_URL is set --- spec/models/request_mailer_spec.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'spec/models') diff --git a/spec/models/request_mailer_spec.rb b/spec/models/request_mailer_spec.rb index 57041b417..586b4e605 100644 --- a/spec/models/request_mailer_spec.rb +++ b/spec/models/request_mailer_spec.rb @@ -341,4 +341,21 @@ describe RequestMailer, 'requires_admin' do mail.body.should include('http://test.host/admin/request/show/123') end + + context 'has an ADMIN_BASE_URL set' do + it 'body should contain the full admin URL' do + Configuration::should_receive(:admin_base_url).and_return('http://our.proxy.server/admin/alaveteli/') + user = mock_model(User, :name_and_email => 'Bruce Jones', + :name => 'Bruce Jones') + info_request = mock_model(InfoRequest, :user => user, + :described_state => 'error_message', + :title => 'Test request', + :url_title => 'test_request', + :law_used_short => 'FOI', + :id => 123) + mail = RequestMailer.deliver_requires_admin(info_request) + + mail.body.should include('http://our.proxy.server/admin/alaveteli/request/show/123') + end + end end -- cgit v1.2.3 From 562a96e629d135789f3d3c415dcc097eac1354b5 Mon Sep 17 00:00:00 2001 From: Henare Degan Date: Thu, 4 Oct 2012 14:25:28 +1000 Subject: Refactor tests --- spec/models/request_mailer_spec.rb | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) (limited to 'spec/models') diff --git a/spec/models/request_mailer_spec.rb b/spec/models/request_mailer_spec.rb index 586b4e605..db558df61 100644 --- a/spec/models/request_mailer_spec.rb +++ b/spec/models/request_mailer_spec.rb @@ -328,32 +328,30 @@ describe RequestMailer, 'when sending mail when someone has updated an old uncla end describe RequestMailer, 'requires_admin' do - it 'body should contain the full admin URL' do + before(:each) do user = mock_model(User, :name_and_email => 'Bruce Jones', :name => 'Bruce Jones') - info_request = mock_model(InfoRequest, :user => user, - :described_state => 'error_message', - :title => 'Test request', - :url_title => 'test_request', - :law_used_short => 'FOI', - :id => 123) - mail = RequestMailer.deliver_requires_admin(info_request) + @info_request = mock_model(InfoRequest, :user => user, + :described_state => 'error_message', + :title => 'Test request', + :url_title => 'test_request', + :law_used_short => 'FOI', + :id => 123) + end + + it 'body should contain the full admin URL' do + mail = RequestMailer.deliver_requires_admin(@info_request) mail.body.should include('http://test.host/admin/request/show/123') end context 'has an ADMIN_BASE_URL set' do - it 'body should contain the full admin URL' do + before(:each) do Configuration::should_receive(:admin_base_url).and_return('http://our.proxy.server/admin/alaveteli/') - user = mock_model(User, :name_and_email => 'Bruce Jones', - :name => 'Bruce Jones') - info_request = mock_model(InfoRequest, :user => user, - :described_state => 'error_message', - :title => 'Test request', - :url_title => 'test_request', - :law_used_short => 'FOI', - :id => 123) - mail = RequestMailer.deliver_requires_admin(info_request) + end + + it 'body should contain the full admin URL' do + mail = RequestMailer.deliver_requires_admin(@info_request) mail.body.should include('http://our.proxy.server/admin/alaveteli/request/show/123') end -- cgit v1.2.3 From 772af44350723936778abe45e888b2fac36da726 Mon Sep 17 00:00:00 2001 From: Henare Degan Date: Thu, 4 Oct 2012 15:32:39 +1000 Subject: Fix failing test added in ad141d7 --- spec/models/request_mailer_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec/models') diff --git a/spec/models/request_mailer_spec.rb b/spec/models/request_mailer_spec.rb index db558df61..906756784 100644 --- a/spec/models/request_mailer_spec.rb +++ b/spec/models/request_mailer_spec.rb @@ -342,7 +342,7 @@ describe RequestMailer, 'requires_admin' do it 'body should contain the full admin URL' do mail = RequestMailer.deliver_requires_admin(@info_request) - mail.body.should include('http://test.host/admin/request/show/123') + mail.body.should include('http://test.host/en/admin/request/show/123') end context 'has an ADMIN_BASE_URL set' do -- cgit v1.2.3