aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--spec/controllers/request_controller_spec.rb24
-rw-r--r--spec/fixtures/incoming-request-two-same-name.email27
2 files changed, 51 insertions, 0 deletions
diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb
index faaffb709..3afbd5015 100644
--- a/spec/controllers/request_controller_spec.rb
+++ b/spec/controllers/request_controller_spec.rb
@@ -44,6 +44,11 @@ describe RequestController, "when showing one request" do
assigns[:info_request].should == info_requests(:fancy_dog_request)
end
+ it "should redirect from a numeric URL to pretty one" do
+ get :show, :url_title => info_requests(:naughty_chicken_request).id
+ response.should redirect_to(:action => 'show', :url_title => info_requests(:naughty_chicken_request).url_title)
+ end
+
it "should show incoming messages" do
get :show, :url_title => 'why_do_you_have_such_a_fancy_dog'
size_before = assigns[:info_request_events].size
@@ -54,6 +59,25 @@ describe RequestController, "when showing one request" do
get :show, :url_title => 'why_do_you_have_such_a_fancy_dog'
(assigns[:info_request_events].size - size_before).should == 1
end
+
+ it "should download attachments" do
+ get :show, :url_title => 'why_do_you_have_such_a_fancy_dog'
+ response.content_type.should == "text/html"
+ size_before = assigns[:info_request_events].size
+
+ ir = info_requests(:fancy_dog_request)
+ receive_incoming_mail('incoming-request-two-same-name.email', ir.incoming_email)
+
+ get :show, :url_title => 'why_do_you_have_such_a_fancy_dog'
+ (assigns[:info_request_events].size - size_before).should == 1
+
+ get :get_attachment, :incoming_message_id => ir.incoming_messages[1].id, :id => ir.id, :part => 2
+ 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
+ response.content_type.should == "text/plain"
+ response.should have_text(/First hello/)
+ end
end
# XXX do this for invalid ids
diff --git a/spec/fixtures/incoming-request-two-same-name.email b/spec/fixtures/incoming-request-two-same-name.email
new file mode 100644
index 000000000..f0ab9f29c
--- /dev/null
+++ b/spec/fixtures/incoming-request-two-same-name.email
@@ -0,0 +1,27 @@
+From: Francis Irving <francis@flourish.org>
+To: FOI Person <EMAIL_TO>
+Subject: Same attachment twice
+Content-Type: multipart/mixed; boundary="Q68bSM7Ycu6FN28Q"
+Content-Disposition: inline
+
+
+--Q68bSM7Ycu6FN28Q
+Content-Type: text/plain; charset=us-ascii
+Content-Disposition: inline
+
+
+
+--Q68bSM7Ycu6FN28Q
+Content-Type: text/plain; charset=us-ascii
+Content-Disposition: attachment; filename="hello.txt"
+
+Second hello
+
+--Q68bSM7Ycu6FN28Q
+Content-Type: text/plain; charset=us-ascii
+Content-Disposition: attachment; filename="hello.txt"
+
+First hello
+
+--Q68bSM7Ycu6FN28Q--
+