diff options
author | Louise Crow <louise.crow@gmail.com> | 2012-10-04 12:37:53 +0100 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2012-10-04 12:37:53 +0100 |
commit | 33cf36a3dfafe64bd721e0627e2a99b56a94238c (patch) | |
tree | ad203ab96bdaa537ec44b6874b359aad4adcdc08 | |
parent | b6231086aa895c83bfeb1cc7067725a9b96e8d0d (diff) | |
parent | 772af44350723936778abe45e888b2fac36da726 (diff) |
Merge remote-tracking branch 'henare_github/full-url-in-admin-emails' into develop
-rwxr-xr-x | app/helpers/link_to_helper.rb | 3 | ||||
-rw-r--r-- | config/general.yml-example | 3 | ||||
-rw-r--r-- | config/test.yml | 4 | ||||
-rw-r--r-- | lib/configuration.rb | 2 | ||||
-rw-r--r-- | spec/helpers/link_to_helper_spec.rb | 25 | ||||
-rw-r--r-- | spec/models/request_mailer_spec.rb | 30 |
6 files changed, 61 insertions, 6 deletions
diff --git a/app/helpers/link_to_helper.rb b/app/helpers/link_to_helper.rb index c8ad7bc30..e4e52427b 100755 --- a/app/helpers/link_to_helper.rb +++ b/app/helpers/link_to_helper.rb @@ -222,8 +222,7 @@ module LinkToHelper # Admin pages def admin_url(relative_path) admin_url_prefix = Configuration::admin_base_url - admin_url_prefix = admin_general_index_path+"/" if admin_url_prefix.empty? - return admin_url_prefix + relative_path + (admin_url_prefix.empty? ? admin_general_index_url + '/' : admin_url_prefix) + relative_path end # About page URLs diff --git a/config/general.yml-example b/config/general.yml-example index 97af5f61d..b457b5ed6 100644 --- a/config/general.yml-example +++ b/config/general.yml-example @@ -83,7 +83,8 @@ TRACK_SENDER_NAME: 'Alaveteli Webmaster' # this up! RAW_EMAILS_LOCATION: 'files/raw_emails' -# The base URL for admin pages. +# The base URL for admin pages, must always end with a '/' +# e.g. https://www.example.com/secure/alaveteli-admin/ # If not specified, it will default to the path to the admin controller, # which is usually what you want. It is useful in situations where admin # requests are proxied via a secure server, for example. diff --git a/config/test.yml b/config/test.yml index 5811b1785..ef270dcf2 100644 --- a/config/test.yml +++ b/config/test.yml @@ -72,7 +72,7 @@ CONTACT_NAME: 'Alaveteli Webmaster' RAW_EMAILS_LOCATION: 'files/raw_emails' # The base URL for admin pages. You probably don't want to change this. -ADMIN_BASE_URL: '/admin/' +ADMIN_BASE_URL: '' # Where /stylesheets sits under for admin pages. See asset_host in # config/environment.rb. Can be full domain or relative path (not an @@ -125,4 +125,4 @@ EXCEPTION_NOTIFICATIONS_TO: MAX_REQUESTS_PER_USER_PER_DAY: 2 VARNISH_HOST: varnish.localdomain -SKIP_ADMIN_AUTH: true
\ No newline at end of file +SKIP_ADMIN_AUTH: true diff --git a/lib/configuration.rb b/lib/configuration.rb index e52f6e956..5f761a1f6 100644 --- a/lib/configuration.rb +++ b/lib/configuration.rb @@ -4,7 +4,7 @@ module Configuration DEFAULTS = { - :ADMIN_BASE_URL => '/admin/', + :ADMIN_BASE_URL => '', :ADMIN_PASSWORD => '', :ADMIN_PUBLIC_URL => '', :ADMIN_USERNAME => '', 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 |