diff options
5 files changed, 38 insertions, 27 deletions
diff --git a/app/controllers/admin_general_controller.rb b/app/controllers/admin_general_controller.rb index 753208c9a..f2414eeab 100644 --- a/app/controllers/admin_general_controller.rb +++ b/app/controllers/admin_general_controller.rb @@ -7,13 +7,6 @@ class AdminGeneralController < AdminController def index - # ensure we have a trailing slash - current_uri = request.env['REQUEST_URI'] - if params[:suppress_redirect].nil? && !(current_uri =~ /\/$/) - redirect_to admin_general_index_url + "/" - return - end - # Overview counts of things @public_body_count = PublicBody.count diff --git a/app/controllers/admin_public_body_change_requests_controller.rb b/app/controllers/admin_public_body_change_requests_controller.rb index d76cdc0e5..6ff03a2bd 100644 --- a/app/controllers/admin_public_body_change_requests_controller.rb +++ b/app/controllers/admin_public_body_change_requests_controller.rb @@ -7,8 +7,12 @@ class AdminPublicBodyChangeRequestsController < AdminController 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' + if params[:subject] && params[:response] + @change_request.send_response(params[:subject], params[:response]) + flash[:notice] = 'The change request has been closed and the user has been notified' + else + flash[:notice] = 'The change request has been closed' + end redirect_to admin_general_index_path end diff --git a/app/views/admin_general/index.html.erb b/app/views/admin_general/index.html.erb index f29258162..a1f2e1d2d 100644 --- a/app/views/admin_general/index.html.erb +++ b/app/views/admin_general/index.html.erb @@ -183,8 +183,12 @@ <div id="new-authorities" class="accordion-body collapse"> <% for @change_request in @new_body_requests %> <%= render :partial => 'change_request_summary'%> - <%= link_to("Close and respond", admin_change_request_edit_path(@change_request), :class => 'btn') %> - <%= link_to("Add authority", admin_body_new_path(:change_request_id => @change_request.id), :class => 'btn btn-primary') %> + <%= form_tag admin_change_request_update_path(@change_request), :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("Add authority", admin_body_new_path(:change_request_id => @change_request.id), :class => 'btn btn-primary') %> + <% end %> + <% end %> </div> </div> diff --git a/spec/controllers/admin_general_controller_spec.rb b/spec/controllers/admin_general_controller_spec.rb index 971960762..cc2ec41b4 100644 --- a/spec/controllers/admin_general_controller_spec.rb +++ b/spec/controllers/admin_general_controller_spec.rb @@ -8,13 +8,8 @@ describe AdminGeneralController do before { basic_auth_login @request } it "should render the front page" do - get :index, :suppress_redirect => 1 - response.should render_template('index') - end - - it "should redirect to include trailing slash" do get :index - response.should redirect_to admin_general_index_url(:trailing_slash => true) + response.should render_template('index') end 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 index b478e851d..003510e60 100644 --- a/spec/controllers/admin_public_body_change_requests_controller_spec.rb +++ b/spec/controllers/admin_public_body_change_requests_controller_spec.rb @@ -15,21 +15,36 @@ 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 + post :update, { :id => @change_request.id } 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/ + context 'when a response and subject are passed' do + + it 'should send a response email to the user who requested the change' do + post :update, { :id => @change_request.id, + :response => 'Thanks but no', + :subject => 'Your request' } + 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 + + context 'when no response or subject are passed' do + + it 'should send a response email to the user who requested the change' do + post :update, { :id => @change_request.id } + deliveries = ActionMailer::Base.deliveries + deliveries.size.should == 0 + end end + end |