Merge remote-tracking branch 'upstream/pull/2239'
[rails.git] / test / controllers / diary_entries_controller_test.rb
index 88a67ef1214a36b28bd67565874be57bef41747f..71684c65e74366e8235010b6ba1504f479f6abee 100644 (file)
@@ -664,6 +664,18 @@ class DiaryEntriesControllerTest < ActionController::TestCase
     assert_match "<title>&lt;script&gt;</title>", response.body
   end
 
+  def test_feed_delay
+    create(:diary_entry, :created_at => 7.hours.ago)
+    create(:diary_entry, :created_at => 5.hours.ago)
+    get :rss, :params => { :format => :rss }
+    assert_select "rss>channel>item", :count => 2
+
+    with_diary_feed_delay(6) do
+      get :rss, :params => { :format => :rss }
+      assert_select "rss>channel>item", :count => 1
+    end
+  end
+
   def test_show
     user = create(:user)
     suspended_user = create(:user, :suspended)
@@ -897,4 +909,13 @@ class DiaryEntriesControllerTest < ActionController::TestCase
       assert_select "a[href=?]", "/user/#{ERB::Util.u(entry.user.display_name)}/diary/#{entry.id}"
     end
   end
+
+  def with_diary_feed_delay(value)
+    diary_feed_delay = Settings.diary_feed_delay
+    Settings.diary_feed_delay = value
+
+    yield
+
+    Settings.diary_feed_delay = diary_feed_delay
+  end
 end