3 module ChangesetComments
4 class FeedsControllerTest < ActionDispatch::IntegrationTest
6 # test all routes which lead to this controller
9 { :path => "/changeset/1/comments/feed", :method => :get },
10 { :controller => "changeset_comments/feeds", :action => "show", :changeset_id => "1", :format => "rss" }
13 { :path => "/history/comments/feed", :method => :get },
14 { :controller => "changeset_comments/feeds", :action => "show", :format => "rss" }
21 changeset = create(:changeset, :closed)
22 create_list(:changeset_comment, 3, :changeset => changeset)
24 get changesets_comments_feed_path(:format => "rss")
25 assert_response :success
26 assert_equal "application/rss+xml", @response.media_type
27 assert_select "rss", :count => 1 do
28 assert_select "channel", :count => 1 do
29 assert_select "item", :count => 3
33 get changesets_comments_feed_path(:format => "rss", :limit => 2)
34 assert_response :success
35 assert_equal "application/rss+xml", @response.media_type
36 assert_select "rss", :count => 1 do
37 assert_select "channel", :count => 1 do
38 assert_select "item", :count => 2
42 get changeset_comments_feed_path(changeset, :format => "rss")
43 assert_response :success
44 assert_equal "application/rss+xml", @response.media_type
46 assert_select "rss", :count => 1 do
47 assert_select "channel", :count => 1 do
48 assert_select "item", :count => 3 do |items|
50 assert_select item, "link", :count => 1 do |link|
51 match = assert_match(/^#{changeset_url changeset}#c(\d+)$/, link.text)
52 comment_id = match[1].to_i
53 assert_operator comment_id, "<", last_comment_id if last_comment_id != -1
54 last_comment_id = comment_id
64 def test_feed_bad_limit
65 get changesets_comments_feed_path(:format => "rss", :limit => 0)
66 assert_response :bad_request
68 get changesets_comments_feed_path(:format => "rss", :limit => 100001)
69 assert_response :bad_request
73 with_settings(:web_timeout => -1) do
74 get changesets_comments_feed_path
76 assert_response :error
77 assert_equal "application/rss+xml; charset=utf-8", @response.header["Content-Type"]
78 assert_dom "rss>channel>title", :text => "OpenStreetMap changeset discussion"
79 assert_dom "rss>channel>description", :text => /the list of changeset comments you requested took too long to retrieve/
82 def test_feed_changeset_timeout
83 with_settings(:web_timeout => -1) do
84 get changeset_comments_feed_path(123)
86 assert_response :error
87 assert_equal "application/rss+xml; charset=utf-8", @response.header["Content-Type"]
88 assert_dom "rss>channel>title", :text => "OpenStreetMap changeset #123 discussion"
89 assert_dom "rss>channel>description", :text => /the list of changeset comments you requested took too long to retrieve/