diff --git a/app/controllers/feeds_controller.rb b/app/controllers/feeds_controller.rb index cc70331aa..90b635eba 100644 --- a/app/controllers/feeds_controller.rb +++ b/app/controllers/feeds_controller.rb @@ -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 diff --git a/spec/controllers/feeds_controller_spec.rb b/spec/controllers/feeds_controller_spec.rb index 1345a81f8..6d11a4d26 100644 --- a/spec/controllers/feeds_controller_spec.rb +++ b/spec/controllers/feeds_controller_spec.rb @@ -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