Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions app/controllers/feeds_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,12 @@ class Stringer < Sinatra::Base

ExportToOpml.new(Feed.all).to_xml
end

get "/feeds/refresh" do
FetchFeeds.enqueue(Feed.all)
end

get "/feeds/:feed_id/refresh" do
FetchFeeds.enqueue(Feed.find(params[:feed_id]))
end
end
21 changes: 21 additions & 0 deletions spec/controllers/feeds_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,25 @@
last_response.header["Content-Type"].should include 'xml'
end
end

describe "GET /feeds/refresh" do
it "Fetches all the feeds" do
Feed.stub(all: ['feed'])

FetchFeeds.should_receive(:enqueue).with(['feed'])

get "/feeds/refresh"
end
end

describe "GET /feeds/:feed_id/refresh" do
it "Fetches a feed given an id" do
feed_id = '123'

Feed.should_receive(:find).with(feed_id).and_return(['feed'])
FetchFeeds.should_receive(:enqueue).with(['feed'])

get "/feeds/#{feed_id}/refresh"
end
end
end