aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Landauer <matthew@openaustralia.org>2013-03-04 09:38:07 +1100
committerMatthew Landauer <matthew@openaustralia.org>2013-03-04 09:38:07 +1100
commit28e65f615c24b96225d24f3f1e0c03f229f8fe4e (patch)
tree25386c570ea3ff7a98ef0a3b322889c1e51ee75a
parentd16f5b29e106d6f5f8191b7f881386f281f98691 (diff)
Fix bug when user not owner of request changing state to requires_admin email should come from user making the change
-rw-r--r--app/controllers/request_controller.rb2
-rw-r--r--spec/controllers/request_controller_spec.rb15
2 files changed, 13 insertions, 4 deletions
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index 36ec7ee13..2cabb3cf0 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -408,7 +408,7 @@ class RequestController < ApplicationController
# Make the state change
old_described_state = info_request.described_state
- info_request.set_described_state(params[:incoming_message][:described_state])
+ info_request.set_described_state(params[:incoming_message][:described_state], authenticated_user)
# 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
diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb
index 0f39d01ce..567add473 100644
--- a/spec/controllers/request_controller_spec.rb
+++ b/spec/controllers/request_controller_spec.rb
@@ -1366,7 +1366,7 @@ describe RequestController, "when classifying an information request" do
it 'should classify the request' do
@dog_request.stub!(:calculate_status).and_return('rejected')
- @dog_request.should_receive(:set_described_state).with('rejected')
+ @dog_request.should_receive(:set_described_state).with('rejected', users(:silly_name_user))
post_status('rejected')
end
@@ -1405,6 +1405,15 @@ describe RequestController, "when classifying an information request" do
response.should redirect_to play_url
end
end
+
+ it "should send a mail from the user who changed the state to requires_admin" do
+ post :describe_state, :incoming_message => { :described_state => "requires_admin" }, :id => @dog_request.id, :incoming_message_id => incoming_messages(:useless_incoming_message), :last_info_request_event_id => @dog_request.last_event_id_needing_description
+
+ deliveries = ActionMailer::Base.deliveries
+ deliveries.size.should == 1
+ mail = deliveries[0]
+ mail.from_addrs.first.to_s.should == users(:silly_name_user).name_and_email
+ end
end
end
@@ -1420,7 +1429,7 @@ describe RequestController, "when classifying an information request" do
it 'should update the status of the request' do
@dog_request.stub!(:calculate_status).and_return('rejected')
- @dog_request.should_receive(:set_described_state).with('rejected')
+ @dog_request.should_receive(:set_described_state).with('rejected', @admin_user)
post_status('rejected')
end
@@ -1471,7 +1480,7 @@ describe RequestController, "when classifying an information request" do
it 'should update the status of the request' do
@dog_request.stub!(:calculate_status).and_return('rejected')
- @dog_request.should_receive(:set_described_state).with('rejected')
+ @dog_request.should_receive(:set_described_state).with('rejected', @admin_user)
post_status('rejected')
end