aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2014-11-04 21:10:59 +0000
committerLouise Crow <louise.crow@gmail.com>2014-12-18 14:03:49 +0000
commit095e216f43eba4081730335ba6be90e12ce02b8c (patch)
tree7f22dfc8ecf52e2c26143722f8367a1261159da6
parent7e3e9c438cff0bee6111adcbc3533dc9b68d75d6 (diff)
Move change request actions to use RESTful routes.
-rw-r--r--app/views/admin_general/index.html.erb8
-rw-r--r--app/views/admin_public_body_change_requests/edit.html.erb2
-rw-r--r--app/views/contact_mailer/add_public_body.text.erb2
-rw-r--r--app/views/contact_mailer/update_public_body_email.text.erb2
-rw-r--r--config/routes.rb7
-rw-r--r--spec/controllers/public_body_change_requests_controller_spec.rb10
6 files changed, 18 insertions, 13 deletions
diff --git a/app/views/admin_general/index.html.erb b/app/views/admin_general/index.html.erb
index 1107b0e93..ba0563bb6 100644
--- a/app/views/admin_general/index.html.erb
+++ b/app/views/admin_general/index.html.erb
@@ -183,9 +183,9 @@
<div id="new-authorities" class="accordion-body collapse">
<% for @change_request in @new_body_requests %>
<%= render :partial => 'change_request_summary'%>
- <%= form_tag admin_change_request_update_path(@change_request), :class => "form form-horizontal" do %>
+ <%= form_tag admin_change_request_path(@change_request), :method => 'put', :class => "form form-horizontal" do %>
<%= submit_tag 'Close', :class => "btn btn-danger" %>
- <%= link_to("Close and respond", admin_change_request_edit_path(@change_request), :class => 'btn') %>
+ <%= link_to("Close and respond", edit_admin_change_request_path(@change_request), :class => 'btn') %>
<%= link_to("Add authority", new_admin_body_path(:change_request_id => @change_request.id), :class => 'btn btn-primary') %>
<% end %>
@@ -202,9 +202,9 @@
<div id="update-authorities" class="accordion-body collapse">
<% for @change_request in @body_update_requests %>
<%= render :partial => 'change_request_summary' %>
- <%= form_tag admin_change_request_update_path(@change_request), :class => "form form-horizontal" do %>
+ <%= form_tag admin_change_request_path(@change_request), :class => "form form-horizontal", :method => 'put' do %>
<%= submit_tag 'Close', :class => "btn btn-danger" %>
- <%= link_to("Close and respond", admin_change_request_edit_path(@change_request), :class => 'btn') %>
+ <%= link_to("Close and respond", edit_admin_change_request_path(@change_request), :class => 'btn') %>
<%= link_to("Make update", edit_admin_body_path(@change_request.public_body, :change_request_id => @change_request.id), :class => 'btn btn-primary') %>
<% end %>
<% end %>
diff --git a/app/views/admin_public_body_change_requests/edit.html.erb b/app/views/admin_public_body_change_requests/edit.html.erb
index cc9c5b5d9..aaf457084 100644
--- a/app/views/admin_public_body_change_requests/edit.html.erb
+++ b/app/views/admin_public_body_change_requests/edit.html.erb
@@ -1,6 +1,6 @@
<h1><%=@title%></h1>
-<%= form_tag admin_change_request_update_path(@change_request), :class => "form form-horizontal" do %>
+<%= form_tag admin_change_request_path(@change_request), :method => 'put', :class => "form form-horizontal" do %>
<%= render :partial => 'admin_public_body_change_requests/response'%>
<div class="form-actions">
<%= submit_tag 'Close', :accesskey => 'c', :class => "btn btn-primary" %>
diff --git a/app/views/contact_mailer/add_public_body.text.erb b/app/views/contact_mailer/add_public_body.text.erb
index f3dc23aac..306a70432 100644
--- a/app/views/contact_mailer/add_public_body.text.erb
+++ b/app/views/contact_mailer/add_public_body.text.erb
@@ -16,4 +16,4 @@
<%= new_admin_body_url(:change_request_id => @change_request.id, :only_path => false ) %>
<%= _('Close the request and respond:') %>
-<%= admin_change_request_edit_url(:id => @change_request.id, :only_path => false ) %>
+<%= edit_admin_change_request_url(@change_request, :only_path => false ) %>
diff --git a/app/views/contact_mailer/update_public_body_email.text.erb b/app/views/contact_mailer/update_public_body_email.text.erb
index f45a640ce..e849463d0 100644
--- a/app/views/contact_mailer/update_public_body_email.text.erb
+++ b/app/views/contact_mailer/update_public_body_email.text.erb
@@ -13,4 +13,4 @@
<%= edit_admin_body_path(@change_request.public_body, :change_request_id => @change_request.id, :only_path => false) %>
<%= _('Close the request and respond:') %>
-<%= admin_change_request_edit_url(:id => @change_request.id, :only_path => false ) %>
+<%= edit_admin_change_request_url(@change_request, :only_path => false ) %>
diff --git a/config/routes.rb b/config/routes.rb
index b3d1fd677..3f361138f 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -199,8 +199,11 @@ Alaveteli::Application.routes.draw do
####
#### AdminPublicBodyChangeRequest controller
- match '/admin/change_request/edit/:id' => 'admin_public_body_change_requests#edit', :as => :admin_change_request_edit
- match '/admin/change_request/update/:id' => 'admin_public_body_change_requests#update', :as => :admin_change_request_update
+ scope '/admin', :as => 'admin' do
+ resources :change_requests,
+ :controller => 'admin_public_body_change_requests',
+ :only => [:edit, :update]
+ end
####
#### AdminGeneral controller
diff --git a/spec/controllers/public_body_change_requests_controller_spec.rb b/spec/controllers/public_body_change_requests_controller_spec.rb
index 1c0b2ab35..4053b2f40 100644
--- a/spec/controllers/public_body_change_requests_controller_spec.rb
+++ b/spec/controllers/public_body_change_requests_controller_spec.rb
@@ -28,6 +28,7 @@ describe PublicBodyChangeRequestsController, "creating a change request" do
it "should send an email to the site contact address" do
post :create, {:public_body_change_request => @change_request_params}
+ change_request_id = assigns[:change_request].id
deliveries = ActionMailer::Base.deliveries
deliveries.size.should == 1
mail = deliveries[0]
@@ -37,8 +38,8 @@ describe PublicBodyChangeRequestsController, "creating a change request" do
mail.body.should include('new_body@example.com')
mail.body.should include('New Body')
mail.body.should include("Please")
- mail.body.should include('http://test.host/admin/bodies/new?change_request_id=')
- mail.body.should include('http://test.host/admin/change_request/edit/')
+ mail.body.should include("http://test.host/admin/bodies/new?change_request_id=#{change_request_id}")
+ mail.body.should include("http://test.host/admin/change_requests/#{change_request_id}/edit")
end
it 'should show a notice' do
@@ -83,6 +84,7 @@ describe PublicBodyChangeRequestsController, "creating a change request" do
it 'should send an email to the site contact address' do
post :create, {:public_body_change_request => @change_request_params}
+ change_request_id = assigns[:change_request].id
deliveries = ActionMailer::Base.deliveries
deliveries.size.should == 1
mail = deliveries[0]
@@ -92,8 +94,8 @@ describe PublicBodyChangeRequestsController, "creating a change request" do
mail.body.should include('new_body@example.com')
mail.body.should include(@public_body.name)
mail.body.should include("Please")
- mail.body.should include("http://test.host/admin/bodies/#{@public_body.id}/edit?change_request_id=")
- mail.body.should include('http://test.host/admin/change_request/edit/')
+ mail.body.should include("http://test.host/admin/bodies/#{@public_body.id}/edit?change_request_id=#{change_request_id}")
+ mail.body.should include("http://test.host/admin/change_requests/#{change_request_id}/edit")
end
it 'should show a notice' do