aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/helpers/link_to_helper_spec.rb25
-rw-r--r--spec/models/request_mailer_spec.rb30
2 files changed, 55 insertions, 0 deletions
diff --git a/spec/helpers/link_to_helper_spec.rb b/spec/helpers/link_to_helper_spec.rb
index 9ec0afce1..ef89e8bf9 100644
--- a/spec/helpers/link_to_helper_spec.rb
+++ b/spec/helpers/link_to_helper_spec.rb
@@ -48,4 +48,29 @@ describe LinkToHelper do
end
+ describe 'admin_url' do
+ context 'with no ADMIN_BASE_URL set' do
+ it 'should prepend the admin general index path to a simple string' do
+ admin_url('unclassified').should == 'http://test.host/en/admin/unclassified'
+ end
+
+ it 'should prepend the admin general index path to a deeper URL' do
+ admin_url('request/show/123').should == 'http://test.host/en/admin/request/show/123'
+ end
+ end
+
+ context 'with ADMIN_BASE_URL set' do
+ before(:each) do
+ Configuration::should_receive(:admin_base_url).and_return('https://www.example.com/secure/alaveteli-admin/')
+ end
+
+ it 'should prepend the admin base URL to a simple string' do
+ admin_url('unclassified').should == 'https://www.example.com/secure/alaveteli-admin/unclassified'
+ end
+
+ it 'should prepend the admin base URL to a deeper URL' do
+ admin_url('request/show/123').should == 'https://www.example.com/secure/alaveteli-admin/request/show/123'
+ end
+ end
+ end
end
diff --git a/spec/models/request_mailer_spec.rb b/spec/models/request_mailer_spec.rb
index 84804d4ca..906756784 100644
--- a/spec/models/request_mailer_spec.rb
+++ b/spec/models/request_mailer_spec.rb
@@ -327,3 +327,33 @@ describe RequestMailer, 'when sending mail when someone has updated an old uncla
end
+describe RequestMailer, 'requires_admin' 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)
+ end
+
+ it 'body should contain the full admin URL' do
+ mail = RequestMailer.deliver_requires_admin(@info_request)
+
+ mail.body.should include('http://test.host/en/admin/request/show/123')
+ end
+
+ context 'has an ADMIN_BASE_URL set' do
+ before(:each) do
+ Configuration::should_receive(:admin_base_url).and_return('http://our.proxy.server/admin/alaveteli/')
+ 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
+ end
+end