aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Landauer <matthew@openaustralia.org>2013-02-15 13:57:28 +1100
committerMatthew Landauer <matthew@openaustralia.org>2013-02-15 14:47:02 +1100
commit902631ec4f5e1a16b8f08a2ed0ccc86ad2b72c6c (patch)
tree87462de4229fa19519260ca76212affbd884e82a
parent4c9f7f7f12a47b516137bf000c3f36120033a077 (diff)
Stop using admin_url to generate absolute url for the admin interface
-rw-r--r--app/controllers/admin_censor_rule_controller.rb12
-rw-r--r--app/controllers/admin_public_body_controller.rb4
-rw-r--r--app/controllers/admin_request_controller.rb2
-rwxr-xr-xapp/helpers/link_to_helper.rb12
-rw-r--r--app/views/admin_general/index.rhtml2
-rw-r--r--app/views/admin_public_body/_one_list.rhtml2
-rw-r--r--app/views/admin_public_body/_tags.rhtml2
-rw-r--r--app/views/comment/_single_comment.rhtml2
-rw-r--r--app/views/layouts/admin.rhtml16
-rw-r--r--app/views/request/_correspondence.rhtml2
-rw-r--r--spec/helpers/link_to_helper_spec.rb26
-rw-r--r--spec/models/request_mailer_spec.rb12
12 files changed, 25 insertions, 69 deletions
diff --git a/app/controllers/admin_censor_rule_controller.rb b/app/controllers/admin_censor_rule_controller.rb
index 5381921bf..f6abc70df 100644
--- a/app/controllers/admin_censor_rule_controller.rb
+++ b/app/controllers/admin_censor_rule_controller.rb
@@ -26,9 +26,9 @@ class AdminCensorRuleController < AdminController
end
flash[:notice] = 'CensorRule was successfully created.'
if !@censor_rule.info_request.nil?
- redirect_to admin_url('request/show/' + @censor_rule.info_request.id.to_s)
+ redirect_to admin_request_show_url(@censor_rule.info_request)
elsif !@censor_rule.user.nil?
- redirect_to admin_url('user/show/' + @censor_rule.user.id.to_s)
+ redirect_to admin_user_show_url(@censor_rule.user)
else
raise "internal error"
end
@@ -53,9 +53,9 @@ class AdminCensorRuleController < AdminController
end
flash[:notice] = 'CensorRule was successfully updated.'
if !@censor_rule.info_request.nil?
- redirect_to admin_url('request/show/' + @censor_rule.info_request.id.to_s)
+ redirect_to admin_request_show_url(@censor_rule.info_request)
elsif !@censor_rule.user.nil?
- redirect_to admin_url('user/show/' + @censor_rule.user.id.to_s)
+ redirect_to admin_user_show_url(@censor_rule.user)
else
raise "internal error"
end
@@ -79,9 +79,9 @@ class AdminCensorRuleController < AdminController
flash[:notice] = "CensorRule was successfully destroyed."
if !info_request.nil?
- redirect_to admin_url('request/show/' + info_request.id.to_s)
+ redirect_to admin_request_show_url(info_request)
elsif !user.nil?
- redirect_to admin_url('user/show/' + user.id.to_s)
+ redirect_to admin_user_show_url(user)
else
raise "internal error"
end
diff --git a/app/controllers/admin_public_body_controller.rb b/app/controllers/admin_public_body_controller.rb
index ac12e97b2..bb5e98852 100644
--- a/app/controllers/admin_public_body_controller.rb
+++ b/app/controllers/admin_public_body_controller.rb
@@ -92,7 +92,7 @@ class AdminPublicBodyController < AdminController
@public_body = PublicBody.new(params[:public_body])
if @public_body.save
flash[:notice] = 'PublicBody was successfully created.'
- redirect_to admin_url('body/show/' + @public_body.id.to_s)
+ redirect_to admin_body_show_url(@public_body)
else
render :action => 'new'
end
@@ -111,7 +111,7 @@ class AdminPublicBodyController < AdminController
@public_body = PublicBody.find(params[:id])
if @public_body.update_attributes(params[:public_body])
flash[:notice] = 'PublicBody was successfully updated.'
- redirect_to admin_url('body/show/' + @public_body.id.to_s)
+ redirect_to admin_body_show_url(@public_body)
else
render :action => 'edit'
end
diff --git a/app/controllers/admin_request_controller.rb b/app/controllers/admin_request_controller.rb
index 49f40b098..51f5e0aff 100644
--- a/app/controllers/admin_request_controller.rb
+++ b/app/controllers/admin_request_controller.rb
@@ -114,7 +114,7 @@ class AdminRequestController < AdminController
# expire cached files
expire_for_request(@info_request)
flash[:notice] = "Request #{url_title} has been completely destroyed. Email of user who made request: " + user.email
- redirect_to admin_url('request/list')
+ redirect_to admin_request_list_url
end
def edit_outgoing
diff --git a/app/helpers/link_to_helper.rb b/app/helpers/link_to_helper.rb
index 6e0a6f355..bd59f24d0 100755
--- a/app/helpers/link_to_helper.rb
+++ b/app/helpers/link_to_helper.rb
@@ -23,7 +23,7 @@ module LinkToHelper
end
def request_admin_url(info_request)
- return admin_url('request/show/' + info_request.id.to_s)
+ admin_request_show_url(info_request)
end
def request_admin_link(info_request, name="admin", cls=nil)
@@ -103,7 +103,7 @@ module LinkToHelper
end
def public_body_admin_url(public_body)
- return admin_url('body/show/' + public_body.id.to_s)
+ admin_body_show_url(public_body)
end
def public_body_both_links(public_body)
@@ -190,7 +190,7 @@ module LinkToHelper
end
def user_admin_url(user)
- return admin_url('user/show/' + user.id.to_s)
+ admin_user_show_url(user)
end
def user_admin_link(user, name="admin", cls=nil)
@@ -260,12 +260,6 @@ module LinkToHelper
link_to h(query), search_url(query)
end
- # Admin pages
- def admin_url(relative_path)
- admin_url_prefix = Configuration::admin_base_url
- (admin_url_prefix.empty? ? admin_general_index_url + '/' : admin_url_prefix) + relative_path
- end
-
# About page URLs
def about_url
return help_general_url(:action => 'about')
diff --git a/app/views/admin_general/index.rhtml b/app/views/admin_general/index.rhtml
index a7dfba90f..3b4a86a58 100644
--- a/app/views/admin_general/index.rhtml
+++ b/app/views/admin_general/index.rhtml
@@ -97,7 +97,7 @@
<% end %>
</ul>
- <p>(<%= link_to "Full list", admin_url("unclassified") %>, or play public
+ <p>(<%= link_to "Full list", admin_request_list_old_unclassified_url %>, or play public
<%= link_to "Categorisation game", categorise_play_url(:only_path => true) %>)
</p>
<% end %>
diff --git a/app/views/admin_public_body/_one_list.rhtml b/app/views/admin_public_body/_one_list.rhtml
index e0d2399d0..7bf07e879 100644
--- a/app/views/admin_public_body/_one_list.rhtml
+++ b/app/views/admin_public_body/_one_list.rhtml
@@ -17,7 +17,7 @@
<% end %>
</table>
-<% form_tag(admin_url("body/mass_tag_add"), :method => "post", :class => "forms_on_one_line" ) do %>
+<% form_tag(admin_body_mass_tag_add_url, :method => "post", :class => "forms_on_one_line" ) do %>
<p>
<%= text_field_tag 'new_tag', params[:new_tag], { :size => 15, :id => "mass_add_tag_new_tag_" + table_name } %>
<%= hidden_field_tag(:query, params[:query], { :id => "mass_add_tag_query_" + table_name } ) %>
diff --git a/app/views/admin_public_body/_tags.rhtml b/app/views/admin_public_body/_tags.rhtml
index 6172e0864..e6eeed287 100644
--- a/app/views/admin_public_body/_tags.rhtml
+++ b/app/views/admin_public_body/_tags.rhtml
@@ -4,7 +4,7 @@
<% else %>
<%= link_to(h(t.name), list_public_bodies_url(:tag => t.name)) %>
<% end %>
- (<a href="<%= admin_url('body/list') %>?query=<%= h(t.name)%>">admin</a>)
+ (<a href="<%= admin_body_list_url %>?query=<%= h(t.name)%>">admin</a>)
<% end %>
diff --git a/app/views/comment/_single_comment.rhtml b/app/views/comment/_single_comment.rhtml
index d428aef14..1529c76de 100644
--- a/app/views/comment/_single_comment.rhtml
+++ b/app/views/comment/_single_comment.rhtml
@@ -19,7 +19,7 @@
<% if !comment.id.nil? %>
<%= link_to "Link to this", comment_path(comment), :class => "link_to_this" %>
<% if !@user.nil? && @user.admin_page_links? %>
- | <%= link_to "Admin", admin_url("request/edit_comment/" + comment.id.to_s) %>
+ | <%= link_to "Admin", admin_request_edit_comment_url(comment) %>
<% end %>
<!-- | <%= link_to _('Report abuse'), comment_path(comment) %> -->
<% end %>
diff --git a/app/views/layouts/admin.rhtml b/app/views/layouts/admin.rhtml
index a9bc0556b..d6a7eec73 100644
--- a/app/views/layouts/admin.rhtml
+++ b/app/views/layouts/admin.rhtml
@@ -13,15 +13,15 @@
<p>
<strong><%= link_to 'Alaveteli', frontpage_url %> admin:</strong>
- <%= link_to 'Summary', admin_url("") %>
- | <%= link_to 'Timeline', admin_url("timeline") %>
- | <%= link_to 'Stats', admin_url("stats") %>
- | <%= link_to 'Debug', admin_url("debug") %>
+ <%= link_to 'Summary', admin_general_index_url %>
+ | <%= link_to 'Timeline', admin_timeline_url %>
+ | <%= link_to 'Stats', admin_stats_url %>
+ | <%= link_to 'Debug', admin_debug_url %>
<strong>View:</strong>
- <%= link_to 'Authorities', admin_url("body/list") %>
- | <%= link_to 'Requests', admin_url("request/list") %>
- | <%= link_to 'Users', admin_url("user/list") %>
- | <%= link_to 'Tracks', admin_url("track/list") %>
+ <%= link_to 'Authorities', admin_body_list_url %>
+ | <%= link_to 'Requests', admin_request_list_url %>
+ | <%= link_to 'Users', admin_user_list_url %>
+ | <%= link_to 'Tracks', admin_track_list_url %>
</p>
<%= render :partial => 'general/locale_switcher' %>
diff --git a/app/views/request/_correspondence.rhtml b/app/views/request/_correspondence.rhtml
index e15ac4d27..445f7c825 100644
--- a/app/views/request/_correspondence.rhtml
+++ b/app/views/request/_correspondence.rhtml
@@ -21,7 +21,7 @@ if not incoming_message.nil?
<p class="event_actions">
<% if !@user.nil? && @user.admin_page_links? %>
- <%= link_to "Admin", admin_url("request/show_raw_email/" + incoming_message.raw_email_id.to_s) %> |
+ <%= link_to "Admin", admin_request_show_raw_email_url(incoming_message.raw_email_id) %> |
<% end %>
<%= link_to _("Link to this"), incoming_message_path(incoming_message), :class => "link_to_this" %>
</p>
diff --git a/spec/helpers/link_to_helper_spec.rb b/spec/helpers/link_to_helper_spec.rb
index eea5935f8..3e997f9f9 100644
--- a/spec/helpers/link_to_helper_spec.rb
+++ b/spec/helpers/link_to_helper_spec.rb
@@ -36,32 +36,6 @@ 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
-
describe 'simple_date' do
it 'should respect time zones' do
Time.use_zone('Australia/Sydney') do
diff --git a/spec/models/request_mailer_spec.rb b/spec/models/request_mailer_spec.rb
index 5edc8edb6..ac30c4844 100644
--- a/spec/models/request_mailer_spec.rb
+++ b/spec/models/request_mailer_spec.rb
@@ -344,16 +344,4 @@ describe RequestMailer, 'requires_admin' do
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