From f560987ab0d3ea3471837a2b30d30c7101dc5616 Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Tue, 12 Jun 2012 09:55:16 +0100 Subject: Make emails requesting admin attention appear to come from the user who requested the attention, not the user who made the original request. --- spec/controllers/request_controller_spec.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'spec/controllers/request_controller_spec.rb') diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb index c70284748..daa26c71e 100644 --- a/spec/controllers/request_controller_spec.rb +++ b/spec/controllers/request_controller_spec.rb @@ -1883,6 +1883,16 @@ describe RequestController, "when reporting a request" do response.body.should include("The site administrators have reviewed this request") end + it "should send an email from the reporter to admins" do + ir = info_requests(:badger_request) + title = ir.url_title + post :report_request, :url_title => title + deliveries = ActionMailer::Base.deliveries + deliveries.size.should == 1 + mail = deliveries[0] + mail.subject.should =~ /attention_requested/ + mail.from.should include(@user.email) + end end -- cgit v1.2.3 From b132a2e3ccd5ac652f9dac17b36655386e993d9b Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Tue, 12 Jun 2012 09:56:08 +0100 Subject: Ensure attention-requesting tests pass by faking a logged in user --- spec/controllers/request_controller_spec.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'spec/controllers/request_controller_spec.rb') diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb index daa26c71e..fdddac556 100644 --- a/spec/controllers/request_controller_spec.rb +++ b/spec/controllers/request_controller_spec.rb @@ -1848,6 +1848,11 @@ end describe RequestController, "when reporting a request" do integrate_views + before do + @user = users(:robin_user) + session[:user_id] = @user.id + end + it "should mark a request as having been reported" do ir = info_requests(:badger_request) title = ir.url_title -- cgit v1.2.3 From 7ac45e7192d5f997acd21564cf163134f1c34c77 Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Tue, 12 Jun 2012 09:57:06 +0100 Subject: Use POST rather than GET for tests (this matches better what the UI does) --- spec/controllers/request_controller_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'spec/controllers/request_controller_spec.rb') diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb index fdddac556..705d96316 100644 --- a/spec/controllers/request_controller_spec.rb +++ b/spec/controllers/request_controller_spec.rb @@ -1858,7 +1858,7 @@ describe RequestController, "when reporting a request" do title = ir.url_title get :show, :url_title => title assigns[:info_request].attention_requested.should == false - get :report_request, :url_title => title + post :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" @@ -1866,10 +1866,10 @@ describe RequestController, "when reporting a request" do it "should not allow a request to be reported twice" do title = info_requests(:badger_request).url_title - get :report_request, :url_title => title + post :report_request, :url_title => title get :show, :url_title => title response.body.should include("has been reported") - get :report_request, :url_title => title + post :report_request, :url_title => title get :show, :url_title => title response.body.should include("has already been reported") end @@ -1878,7 +1878,7 @@ describe RequestController, "when reporting a request" do title = info_requests(:badger_request).url_title get :show, :url_title => title response.body.should include("Offensive?") - get :report_request, :url_title => title + post :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") -- cgit v1.2.3 From 4bb3e9d5ff49ec5fb108a5a618993248abcb3692 Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Fri, 15 Jun 2012 13:28:07 +0100 Subject: Revert "Set a "Content-Disposition: attachment" header when downloading files. Closes #428" This reverts commit 506af7a640f63b17000ccfc5e1344bbc3039c913. See issue #428 for a discussion --- spec/controllers/request_controller_spec.rb | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'spec/controllers/request_controller_spec.rb') diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb index 705d96316..28f56dcf6 100644 --- a/spec/controllers/request_controller_spec.rb +++ b/spec/controllers/request_controller_spec.rb @@ -290,6 +290,7 @@ describe RequestController, "when showing one request" do get :get_attachment, :incoming_message_id => ir.incoming_messages[1].id, :id => ir.id, :part => 2, :file_name => ['hello.txt'], :skip_cache => 1 response.content_type.should == "text/plain" response.should have_text(/Second hello/) + get :get_attachment, :incoming_message_id => ir.incoming_messages[1].id, :id => ir.id, :part => 3, :file_name => ['hello.txt'], :skip_cache => 1 response.content_type.should == "text/plain" response.should have_text(/First hello/) @@ -418,15 +419,6 @@ describe RequestController, "when showing one request" do response.should have_text(/an unusual sort of file/) end - it "should apply a content-disposition header" do - ir = info_requests(:fancy_dog_request) - receive_incoming_mail('incoming-request-attachment-unknown-extension.email', ir.incoming_email) - ir.reload - get :get_attachment, :incoming_message_id => ir.incoming_messages[1].id, :id => ir.id, :part => 2, :file_name => ['hello.qwglhm'], :skip_cache => 1 - response.headers.should include("Content-Disposition") - response.headers["Content-Disposition"].should include('hello.qwglhm') - end - it "should not download attachments with wrong file name" do ir = info_requests(:fancy_dog_request) receive_incoming_mail('incoming-request-two-same-name.email', ir.incoming_email) -- cgit v1.2.3 From 363e3aaeea5d185e47e22825bad865c31e3e6ed8 Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Tue, 19 Jun 2012 09:13:16 +0100 Subject: Correctly name the person who has requested something for admin attention --- spec/controllers/request_controller_spec.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'spec/controllers/request_controller_spec.rb') diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb index 28f56dcf6..13887749d 100644 --- a/spec/controllers/request_controller_spec.rb +++ b/spec/controllers/request_controller_spec.rb @@ -1889,6 +1889,7 @@ describe RequestController, "when reporting a request" do mail = deliveries[0] mail.subject.should =~ /attention_requested/ mail.from.should include(@user.email) + mail.body.should include(@user.name) end end -- cgit v1.2.3 From f35432197c85911d400a21ba4bfe099210a8811b Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Tue, 19 Jun 2012 12:32:06 +0100 Subject: Fix test to match current wording --- spec/controllers/request_controller_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec/controllers/request_controller_spec.rb') diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb index 13887749d..99ab4cc71 100644 --- a/spec/controllers/request_controller_spec.rb +++ b/spec/controllers/request_controller_spec.rb @@ -1877,7 +1877,7 @@ describe RequestController, "when reporting a request" do 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") + response.body.should =~ (/the site administrators.*have not hidden it/) end it "should send an email from the reporter to admins" do -- cgit v1.2.3 From 08dac0261325cd757b7146f9626f3c7b48cc672c Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Wed, 20 Jun 2012 10:11:03 +0100 Subject: Only invalidate a user's cached requests when their *name* changes. Otherwise we issue PURGEs every time, for example, we send out email alerts. --- spec/controllers/request_controller_spec.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'spec/controllers/request_controller_spec.rb') diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb index 99ab4cc71..01a663bf8 100644 --- a/spec/controllers/request_controller_spec.rb +++ b/spec/controllers/request_controller_spec.rb @@ -156,12 +156,18 @@ describe RequestController, "when changing things that appear on the request pag ir.public_body.save! PurgeRequest.all().map{|x| x.model_id}.should =~ ir.public_body.info_requests.map{|x| x.id} end - it "should purge the downstream cache when the user details are changed" do + it "should purge the downstream cache when the user name is changed" do ir = info_requests(:fancy_dog_request) ir.user.name = "Something new" ir.user.save! PurgeRequest.all().map{|x| x.model_id}.should =~ ir.user.info_requests.map{|x| x.id} end + it "should not purge the downstream cache when non-visible user details are changed" do + ir = info_requests(:fancy_dog_request) + ir.user.hashed_password = "some old hash" + ir.user.save! + PurgeRequest.all().count.should == 0 + end it "should purge the downstream cache when censor rules have changed" do # XXX really, CensorRules should execute expiry logic as part # of the after_save of the model. Currently this is part of -- cgit v1.2.3