diff options
-rw-r--r-- | app/controllers/request_controller.rb | 10 | ||||
-rw-r--r-- | app/models/info_request.rb | 10 | ||||
-rw-r--r-- | spec/controllers/request_controller_spec.rb | 11 |
3 files changed, 16 insertions, 15 deletions
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index ea84d3b10..7716ba7e7 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -420,12 +420,22 @@ class RequestController < ApplicationController end # Make the state change + event = info_request.log_event("status_update", + { :user_id => authenticated_user.id, + :old_described_state => info_request.described_state, + :described_state => described_state, + }) + info_request.set_described_state(described_state, authenticated_user, message) # If you're not the *actual* requester. e.g. you are playing the # classification game, or you're doing this just because you are an # admin user (not because you also own the request). if !info_request.is_actual_owning_user?(authenticated_user) + # Create a classification event for league tables + RequestClassification.create!(:user_id => authenticated_user.id, + :info_request_event_id => event.id) + # Don't give advice on what to do next, as it isn't their request if session[:request_game] flash[:notice] = _('Thank you for updating the status of the request \'<a href="{{url}}">{{info_request_title}}</a>\'. There are some more requests below for you to classify.',:info_request_title=>CGI.escapeHTML(info_request.title), :url=>CGI.escapeHTML(request_path(info_request))) diff --git a/app/models/info_request.rb b/app/models/info_request.rb index c615a6a9e..adb944a7e 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -577,16 +577,6 @@ public end unless set_by.nil? || is_actual_owning_user?(set_by) || described_state == 'attention_requested' - # Log the status change by someone other than the requester - event = log_event("status_update", - { :user_id => set_by.id, - :old_described_state => old_described_state, - :described_state => described_state, - }) - # Create a classification event for league tables - RequestClassification.create!(:user_id => set_by.id, - :info_request_event_id => event.id) - RequestMailer.old_unclassified_updated(self).deliver if !is_external? end end diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb index 4161f1118..4e889e2a6 100644 --- a/spec/controllers/request_controller_spec.rb +++ b/spec/controllers/request_controller_spec.rb @@ -1440,8 +1440,8 @@ describe RequestController, "when classifying an information request" do post_status('rejected') end - it 'should not log a status update event' do - @dog_request.should_not_receive(:log_event) + it 'should log a status update event' do + @dog_request.should_receive(:log_event) post_status('rejected') end @@ -1494,11 +1494,12 @@ describe RequestController, "when classifying an information request" do @dog_request.awaiting_description.should == false @dog_request.described_state.should == 'rejected' @dog_request.get_last_response_event.should == info_request_events(:useless_incoming_message_event) - @dog_request.get_last_response_event.calculated_state.should == 'rejected' + @dog_request.info_request_events.last.event_type.should == "status_update" + @dog_request.info_request_events.last.calculated_state.should == 'rejected' end - it 'should not log a status update event' do - @dog_request.should_not_receive(:log_event) + it 'should log a status update event' do + @dog_request.should_receive(:log_event) post_status('rejected') end |