aboutsummaryrefslogtreecommitdiffstats
path: root/spec/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'spec/helpers')
-rw-r--r--spec/helpers/link_to_helper_spec.rb43
1 files changed, 40 insertions, 3 deletions
diff --git a/spec/helpers/link_to_helper_spec.rb b/spec/helpers/link_to_helper_spec.rb
index 3e997f9f9..5233f3f7f 100644
--- a/spec/helpers/link_to_helper_spec.rb
+++ b/spec/helpers/link_to_helper_spec.rb
@@ -8,11 +8,10 @@ describe LinkToHelper do
before do
@mock_request = mock_model(InfoRequest, :url_title => 'test_title')
- @old_filters = ActionController::Routing::Routes.filters
- ActionController::Routing::Routes.filters = RoutingFilter::Chain.new
+ RoutingFilter.active = false
end
after do
- ActionController::Routing::Routes.filters = @old_filters
+ RoutingFilter.active = true
end
@@ -26,6 +25,18 @@ describe LinkToHelper do
end
+ describe "when appending something to a URL" do
+ it 'should append to things without query strings' do
+ main_url('/a', '.json').should == 'http://test.host/a.json'
+ end
+ it 'should append to things with query strings' do
+ main_url('/a?z=1', '.json').should == 'http://test.host/a.json?z=1'
+ end
+ it 'should fail silently with invalid URLs' do
+ main_url('/a?z=9%', '.json').should == 'http://test.host/a?z=9%'
+ end
+ end
+
describe 'when displaying a user admin link for a request' do
it 'should return the text "An anonymous user (external)" in the case where there is no external username' do
@@ -36,6 +47,32 @@ 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
+ AlaveteliConfiguration::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
+
describe 'simple_date' do
it 'should respect time zones' do
Time.use_zone('Australia/Sydney') do