diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/admin_request_controller_spec.rb | 43 | ||||
-rw-r--r-- | spec/controllers/request_controller_spec.rb | 41 |
2 files changed, 84 insertions, 0 deletions
diff --git a/spec/controllers/admin_request_controller_spec.rb b/spec/controllers/admin_request_controller_spec.rb index ece1fe389..b0468822a 100644 --- a/spec/controllers/admin_request_controller_spec.rb +++ b/spec/controllers/admin_request_controller_spec.rb @@ -86,6 +86,27 @@ describe AdminRequestController, "when administering the holding pen" do response.should redirect_to(:controller=>'admin_request', :action=>'show', :id=>101) InfoRequest.holding_pen_request.incoming_messages.length.should == 0 end + it "allows redelivery to more than one request" do + ir1 = info_requests(:fancy_dog_request) + ir1.allow_new_responses_from = 'nobody' + ir1.handle_rejected_responses = 'holding_pen' + ir1.save! + ir1.incoming_messages.length.should == 1 + ir2 = info_requests(:another_boring_request) + ir2.incoming_messages.length.should == 1 + + receive_incoming_mail('incoming-request-plain.email', ir1.incoming_email, "frob@nowhere.com") + InfoRequest.holding_pen_request.incoming_messages.length.should == 1 + + new_im = InfoRequest.holding_pen_request.incoming_messages[0] + post :redeliver_incoming, :redeliver_incoming_message_id => new_im.id, :url_title => "#{ir1.url_title},#{ir2.url_title}" + ir1.reload + ir1.incoming_messages.length.should == 2 + ir2.reload + ir2.incoming_messages.length.should == 2 + response.should redirect_to(:controller=>'admin_request', :action=>'show', :id=>ir2.id) + InfoRequest.holding_pen_request.incoming_messages.length.should == 0 + end it "guesses a misdirected request" do ir = info_requests(:fancy_dog_request) @@ -110,4 +131,26 @@ describe AdminRequestController, "when administering the holding pen" do assert_equal File.exists?(raw_email), false end + it "shows a suitable default 'your email has been hidden' message" do + ir = info_requests(:fancy_dog_request) + get :show, :id => ir.id + assigns[:request_hidden_user_explanation].should include(ir.user.name) + assigns[:request_hidden_user_explanation].should include("vexatious") + get :show, :id => ir.id, :reason => "not_foi" + assigns[:request_hidden_user_explanation].should_not include("vexatious") + assigns[:request_hidden_user_explanation].should include("not a valid FOI") + end + + it "hides requests and sends a notification email that it has done so" do + ir = info_requests(:fancy_dog_request) + post :hide_request, :id => ir.id, :explanation => "Foo", :reason => "vexatious" + ir.reload + ir.prominence.should == "requester_only" + ir.described_state.should == "vexatious" + deliveries = ActionMailer::Base.deliveries + deliveries.size.should == 1 + mail = deliveries[0] + mail.body.should =~ /Foo/ + end + end diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb index d52c8eaf4..c70284748 100644 --- a/spec/controllers/request_controller_spec.rb +++ b/spec/controllers/request_controller_spec.rb @@ -1845,3 +1845,44 @@ describe RequestController, "when showing similar requests" do end +describe RequestController, "when reporting a request" do + integrate_views + + it "should mark a request as having been reported" do + ir = info_requests(:badger_request) + title = ir.url_title + get :show, :url_title => title + assigns[:info_request].attention_requested.should == false + get :report_request, :url_title => title + get :show, :url_title => title + assigns[:info_request].attention_requested.should == true + assigns[:info_request].described_state.should == "attention_requested" + end + + it "should not allow a request to be reported twice" do + title = info_requests(:badger_request).url_title + get :report_request, :url_title => title + get :show, :url_title => title + response.body.should include("has been reported") + get :report_request, :url_title => title + get :show, :url_title => title + response.body.should include("has already been reported") + end + + it "should let users know a request has been reported" do + title = info_requests(:badger_request).url_title + get :show, :url_title => title + response.body.should include("Offensive?") + get :report_request, :url_title => title + get :show, :url_title => title + response.body.should_not include("Offensive?") + response.body.should include("This request has been reported") + info_requests(:badger_request).set_described_state("successful") + get :show, :url_title => title + response.body.should_not include("This request has been reported") + response.body.should include("The site administrators have reviewed this request") + end + +end + + |