From: Andy Allan Date: Wed, 31 May 2017 16:39:58 +0000 (+0100) Subject: Rework the changeset feed tests. X-Git-Tag: live~3411 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/2bcdf9abaa6e6892d4b30241465293e2bd10ceb7?ds=sidebyside Rework the changeset feed tests. These now include explicit tests for the changesets expected, as well as refactoring so that they don't rely on fixtures. --- diff --git a/test/controllers/changeset_controller_test.rb b/test/controllers/changeset_controller_test.rb index d90ee0eee..50a66744a 100644 --- a/test/controllers/changeset_controller_test.rb +++ b/test/controllers/changeset_controller_test.rb @@ -2036,37 +2036,46 @@ EOF ## # This should display the last 20 changesets closed def test_feed + changeset = create(:changeset, :num_changes => 1) + _empty_changeset = create(:changeset, :num_changes => 0) + get :feed, :format => :atom assert_response :success assert_template "list" assert_equal "application/atom+xml", response.content_type - check_feed_result(Changeset.all) + check_feed_result([changeset]) end ## # This should display the last 20 changesets closed in a specific area def test_feed_bbox + changeset = create(:changeset, :num_changes => 1, :min_lat => 5 * GeoRecord::SCALE, :min_lon => 5 * GeoRecord::SCALE, :max_lat => 5 * GeoRecord::SCALE, :max_lon => 5 * GeoRecord::SCALE) + closed_changeset = create(:changeset, :closed, :num_changes => 1, :min_lat => 5 * GeoRecord::SCALE, :min_lon => 5 * GeoRecord::SCALE, :max_lat => 5 * GeoRecord::SCALE, :max_lon => 5 * GeoRecord::SCALE) + _elsewhere_changeset = create(:changeset, :num_changes => 1, :min_lat => -5 * GeoRecord::SCALE, :min_lon => -5 * GeoRecord::SCALE, :max_lat => -5 * GeoRecord::SCALE, :max_lon => -5 * GeoRecord::SCALE) + _empty_changeset = create(:changeset, :num_changes => 0, :min_lat => -5 * GeoRecord::SCALE, :min_lon => -5 * GeoRecord::SCALE, :max_lat => -5 * GeoRecord::SCALE, :max_lon => -5 * GeoRecord::SCALE) + get :feed, :format => :atom, :bbox => "4.5,4.5,5.5,5.5" assert_response :success assert_template "list" assert_equal "application/atom+xml", response.content_type - check_feed_result(Changeset.where("min_lon < 55000000 and max_lon > 45000000 and min_lat < 55000000 and max_lat > 45000000")) + check_feed_result([changeset, closed_changeset]) end ## # Checks the display of the user changesets feed def test_feed_user user = create(:user) - create_list(:changeset, 3, :user => user, :num_changes => 4) + changesets = create_list(:changeset, 3, :user => user, :num_changes => 4) + _other_changeset = create(:changeset) get :feed, :format => :atom, :display_name => user.display_name assert_response :success assert_template "list" assert_equal "application/atom+xml", response.content_type - check_feed_result(user.changesets) + check_feed_result(changesets) end ## @@ -2480,9 +2489,6 @@ EOF ## # check the result of a feed def check_feed_result(changesets) - changesets = changesets.where("num_changes > 0") - .order(:created_at => :desc) - .limit(20) assert changesets.size <= 20 assert_select "feed", :count => [changesets.size, 1].min do