Skip to content

Commit

Permalink
Use two changesets in comments feeds tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonKhorev committed Jul 16, 2024
1 parent 71d3371 commit f56bbe5
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions test/controllers/changeset_comments_feeds_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ def test_routes
end

def test_show
changeset = create(:changeset, :closed)
create_list(:changeset_comment, 3, :changeset => changeset)
changeset1 = create(:changeset, :closed)
changeset2 = create(:changeset, :closed)
create_list(:changeset_comment, 1, :changeset => changeset1)
create_list(:changeset_comment, 2, :changeset => changeset2)

get changeset_comments_feed_path(:format => "rss")
assert_response :success
Expand All @@ -36,16 +38,25 @@ def test_show
end
end

get changeset_changeset_comments_feed_path(changeset, :format => "rss")
get changeset_changeset_comments_feed_path(changeset1, :format => "rss")
assert_response :success
assert_equal "application/rss+xml", @response.media_type
assert_select "rss", :count => 1 do
assert_select "channel", :count => 1 do
assert_select "item", :count => 1
end
end

last_comment_id = -1
get changeset_changeset_comments_feed_path(changeset2, :format => "rss")
assert_response :success
assert_equal "application/rss+xml", @response.media_type
assert_select "rss", :count => 1 do
assert_select "channel", :count => 1 do
assert_select "item", :count => 3 do |items|
assert_select "item", :count => 2 do |items|
items.each do |item|
assert_select item, "link", :count => 1 do |link|
match = assert_match(/^#{changeset_url changeset}#c(\d+)$/, link.text)
match = assert_match(/^#{changeset_url changeset2}#c(\d+)$/, link.text)
comment_id = match[1].to_i
assert_operator comment_id, "<", last_comment_id if last_comment_id != -1
last_comment_id = comment_id
Expand Down

0 comments on commit f56bbe5

Please sign in to comment.