aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2013-12-18 19:31:04 +0000
committerLouise Crow <louise.crow@gmail.com>2014-01-13 12:36:43 +0000
commitafbc8370d78fc4a453e0a768139f4bc7dd35d348 (patch)
treef6361d76462e5248bfb4ce82adb812700eb0eff4
parent2c4421b1b65065b4c81d5d3c45f67875e20f810e (diff)
Add form for closing change request without action
For cases where we don't want to make the change suggested. There doesn't seem to be any obvious default text to use in the response to the person who requested the change.
-rw-r--r--app/controllers/admin_public_body_change_requests_controller.rb15
-rw-r--r--app/views/admin_public_body_change_requests/edit.html.erb8
-rw-r--r--spec/controllers/admin_public_body_change_requests_controller_spec.rb35
3 files changed, 58 insertions, 0 deletions
diff --git a/app/controllers/admin_public_body_change_requests_controller.rb b/app/controllers/admin_public_body_change_requests_controller.rb
new file mode 100644
index 000000000..d76cdc0e5
--- /dev/null
+++ b/app/controllers/admin_public_body_change_requests_controller.rb
@@ -0,0 +1,15 @@
+class AdminPublicBodyChangeRequestsController < AdminController
+
+ def edit
+ @change_request = PublicBodyChangeRequest.find(params[:id])
+ end
+
+ def update
+ @change_request = PublicBodyChangeRequest.find(params[:id])
+ @change_request.close!
+ @change_request.send_response(params[:subject], params[:response])
+ flash[:notice] = 'The change request has been closed and the user has been notified'
+ redirect_to admin_general_index_path
+ 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
new file mode 100644
index 000000000..cc9c5b5d9
--- /dev/null
+++ b/app/views/admin_public_body_change_requests/edit.html.erb
@@ -0,0 +1,8 @@
+<h1><%=@title%></h1>
+
+<%= form_tag admin_change_request_update_path(@change_request), :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" %>
+ </div>
+<% end %>
diff --git a/spec/controllers/admin_public_body_change_requests_controller_spec.rb b/spec/controllers/admin_public_body_change_requests_controller_spec.rb
new file mode 100644
index 000000000..b478e851d
--- /dev/null
+++ b/spec/controllers/admin_public_body_change_requests_controller_spec.rb
@@ -0,0 +1,35 @@
+# -*- coding: utf-8 -*-
+require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+
+describe AdminPublicBodyChangeRequestsController, "editing a change request" do
+
+ it "should render the edit template" do
+ change_request = FactoryGirl.create(:add_body_request)
+ get :edit, :id => change_request.id
+ response.should render_template("edit")
+ end
+
+end
+
+describe AdminPublicBodyChangeRequestsController, 'updating a change request' do
+
+ before do
+ @change_request = FactoryGirl.create(:add_body_request)
+ post :update, { :id => @change_request.id,
+ :response => 'Thanks but no',
+ :subject => 'Your request' }
+ end
+
+ it 'should close the change request' do
+ PublicBodyChangeRequest.find(@change_request.id).is_open.should == false
+ end
+
+ it 'should send a response email to the user who requested the change' do
+ deliveries = ActionMailer::Base.deliveries
+ deliveries.size.should == 1
+ mail = deliveries[0]
+ mail.subject.should == 'Your request'
+ mail.to.should == [@change_request.get_user_email]
+ mail.body.should =~ /Thanks but no/
+ end
+end