From f9fe38f31f25996cc742a187b6789d5debbeb525 Mon Sep 17 00:00:00 2001 From: Justin Mazzi Date: Thu, 18 Jul 2013 08:56:35 -0400 Subject: [PATCH] Make export serve a file --- app/controllers/feeds_controller.rb | 3 ++- spec/controllers/feeds_controller_spec.rb | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/controllers/feeds_controller.rb b/app/controllers/feeds_controller.rb index cc70331aa..b59e17534 100644 --- a/app/controllers/feeds_controller.rb +++ b/app/controllers/feeds_controller.rb @@ -48,7 +48,8 @@ class Stringer < Sinatra::Base end get "/feeds/export" do - content_type :xml + content_type 'application/octet-stream' + attachment 'stringer.xml' ExportToOpml.new(Feed.all).to_xml end diff --git a/spec/controllers/feeds_controller_spec.rb b/spec/controllers/feeds_controller_spec.rb index 1345a81f8..df0fcd669 100644 --- a/spec/controllers/feeds_controller_spec.rb +++ b/spec/controllers/feeds_controller_spec.rb @@ -117,11 +117,12 @@ it "returns an OPML file" do ExportToOpml.any_instance.should_receive(:to_xml).and_return(some_xml) - + get "/feeds/export" last_response.body.should eq some_xml - last_response.header["Content-Type"].should include 'xml' + last_response.header["Content-Type"].should include 'application/octet-stream' + last_response.header["Content-Disposition"].should == "attachment; filename=\"stringer.xml\"" end end end