3 class ChangesetCommentsControllerTest < ActionDispatch::IntegrationTest
5 # test all routes which lead to this controller
8 { :path => "/changeset/1/comments/feed", :method => :get },
9 { :controller => "changeset_comments", :action => "index", :id => "1", :format => "rss" }
12 { :path => "/history/comments/feed", :method => :get },
13 { :controller => "changeset_comments", :action => "index", :format => "rss" }
20 changeset = create(:changeset, :closed)
21 create_list(:changeset_comment, 3, :changeset => changeset)
23 get changesets_comments_feed_path(:format => "rss")
24 assert_response :success
25 assert_equal "application/rss+xml", @response.media_type
26 assert_select "rss", :count => 1 do
27 assert_select "channel", :count => 1 do
28 assert_select "item", :count => 3
32 get changesets_comments_feed_path(:format => "rss", :limit => 2)
33 assert_response :success
34 assert_equal "application/rss+xml", @response.media_type
35 assert_select "rss", :count => 1 do
36 assert_select "channel", :count => 1 do
37 assert_select "item", :count => 2
41 get changeset_comments_feed_path(:id => changeset.id, :format => "rss")
42 assert_response :success
43 assert_equal "application/rss+xml", @response.media_type
44 assert_select "rss", :count => 1 do
45 assert_select "channel", :count => 1 do
46 assert_select "item", :count => 3
49 # Rails::Dom::Testing.html_document_fragment.parse(icons)
50 # Gets comment Ids from HTML and checks that they are in descending order
53 assert_select "rss", :count => 1 do
54 assert_select "description", :count => 3 do |descriptions|
55 descriptions.children.each do |description|
56 changeset_dom = Rails::Dom::Testing.html_document_fragment.parse(description.content)
57 comment = changeset_dom.at_css(".changeset-comment-text")
60 id = comment.content.split[-1].to_i
61 assert_operator id, "<", last_comment_id if last_comment_id != -1
70 def test_feed_bad_limit
71 get changesets_comments_feed_path(:format => "rss", :limit => 0)
72 assert_response :bad_request
74 get changesets_comments_feed_path(:format => "rss", :limit => 100001)
75 assert_response :bad_request