]> git.openstreetmap.org Git - rails.git/blob - test/controllers/changeset_comments_controller_test.rb
Merge remote-tracking branch 'upstream/pull/2431'
[rails.git] / test / controllers / changeset_comments_controller_test.rb
1 require "test_helper"
2
3 class ChangesetCommentsControllerTest < ActionController::TestCase
4   ##
5   # test all routes which lead to this controller
6   def test_routes
7     assert_routing(
8       { :path => "/changeset/1/comments/feed", :method => :get },
9       { :controller => "changeset_comments", :action => "index", :id => "1", :format => "rss" }
10     )
11     assert_routing(
12       { :path => "/history/comments/feed", :method => :get },
13       { :controller => "changeset_comments", :action => "index", :format => "rss" }
14     )
15   end
16
17   ##
18   # test comments feed
19   def test_feed
20     changeset = create(:changeset, :closed)
21     create_list(:changeset_comment, 3, :changeset => changeset)
22
23     get :index, :params => { :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
29       end
30     end
31
32     get :index, :params => { :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
38       end
39     end
40
41     get :index, :params => { :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
47       end
48     end
49   end
50
51   ##
52   # test comments feed
53   def test_feed_bad_limit
54     get :index, :params => { :format => "rss", :limit => 0 }
55     assert_response :bad_request
56
57     get :index, :params => { :format => "rss", :limit => 100001 }
58     assert_response :bad_request
59   end
60 end