Skip to content

Commit

Permalink
Merge pull request stringer-rss#237 from jmazzi/feature/export_to_file
Browse files Browse the repository at this point in the history
Make export feeds serve a file
  • Loading branch information
matt swanson committed Jul 18, 2013
2 parents b39243e + f9fe38f commit 70c4036
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion app/controllers/feeds_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions spec/controllers/feeds_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 70c4036

Please sign in to comment.