X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/9d2f920feb9dce028b985e8d452538d3df7a1d9c..f7a35c5895b1bd830a9bf2c08ce36e265deb3e4c:/test/controllers/changeset_controller_test.rb diff --git a/test/controllers/changeset_controller_test.rb b/test/controllers/changeset_controller_test.rb index 5205714df..575eed765 100644 --- a/test/controllers/changeset_controller_test.rb +++ b/test/controllers/changeset_controller_test.rb @@ -244,8 +244,8 @@ class ChangesetControllerTest < ActionController::TestCase # test that it really is closed now cs = Changeset.find(cs_id) - assert(!cs.is_open?, - "changeset should be closed now (#{cs.closed_at} > #{Time.now.getutc}.") + assert_not(cs.is_open?, + "changeset should be closed now (#{cs.closed_at} > #{Time.now.getutc}.") end ## @@ -557,7 +557,7 @@ CHANGESET end def test_repeated_changeset_create - 30.times do + 3.times do basic_authorization create(:user).email, "test" # create a temporary changeset @@ -580,8 +580,7 @@ CHANGESET assert_response :success, "Should be able to create a changeset: #{@response.body}" changeset_id = @response.body.to_i - # upload some widely-spaced nodes, spiralling positive and negative to cause - # largest bbox over-expansion possible. + # upload some widely-spaced nodes, spiralling positive and negative diff = < @@ -619,7 +618,7 @@ CHANGESET assert cs.min_lon >= -180 * GeoRecord::SCALE, "Minimum longitude (#{cs.min_lon / GeoRecord::SCALE}) should be >= -180 to be valid." assert cs.max_lon <= 180 * GeoRecord::SCALE, "Maximum longitude (#{cs.max_lon / GeoRecord::SCALE}) should be <= 180 to be valid." assert cs.min_lat >= -90 * GeoRecord::SCALE, "Minimum latitude (#{cs.min_lat / GeoRecord::SCALE}) should be >= -90 to be valid." - assert cs.max_lat >= 90 * GeoRecord::SCALE, "Maximum latitude (#{cs.max_lat / GeoRecord::SCALE}) should be <= 90 to be valid." + assert cs.max_lat <= 90 * GeoRecord::SCALE, "Maximum latitude (#{cs.max_lat / GeoRecord::SCALE}) should be <= 90 to be valid." end ## @@ -1568,11 +1567,10 @@ CHANGESET # get the bounding box back from the changeset get :read, :params => { :id => changeset_id } assert_response :success, "Couldn't read back changeset for the third time." - # note that the 3.1 here is because of the bbox overexpansion assert_select "osm>changeset[min_lon='1.0000000']", 1 - assert_select "osm>changeset[max_lon='3.1000000']", 1 + assert_select "osm>changeset[max_lon='3.0000000']", 1 assert_select "osm>changeset[min_lat='1.0000000']", 1 - assert_select "osm>changeset[max_lat='3.1000000']", 1 + assert_select "osm>changeset[max_lat='3.0000000']", 1 end ## @@ -1877,9 +1875,9 @@ CHANGESET assert_equal Changeset::MAX_ELEMENTS + 1, changeset.num_changes # check that the changeset is now closed as well - assert(!changeset.is_open?, - "changeset should have been auto-closed by exceeding " \ - "element limit.") + assert_not(changeset.is_open?, + "changeset should have been auto-closed by exceeding " \ + "element limit.") end ## @@ -2246,6 +2244,13 @@ CHANGESET post :subscribe, :params => { :id => changeset.id } end assert_response :success + + # not closed changeset + changeset = create(:changeset) + assert_difference "changeset.subscribers.count", 1 do + post :subscribe, :params => { :id => changeset.id } + end + assert_response :success end ## @@ -2268,13 +2273,6 @@ CHANGESET end assert_response :not_found - # not closed changeset - changeset = create(:changeset) - assert_no_difference "changeset.subscribers.count" do - post :subscribe, :params => { :id => changeset.id } - end - assert_response :conflict - # trying to subscribe when already subscribed changeset = create(:changeset, :closed) changeset.subscribers.push(user) @@ -2296,6 +2294,15 @@ CHANGESET post :unsubscribe, :params => { :id => changeset.id } end assert_response :success + + # not closed changeset + changeset = create(:changeset) + changeset.subscribers.push(user) + + assert_difference "changeset.subscribers.count", -1 do + post :unsubscribe, :params => { :id => changeset.id } + end + assert_response :success end ## @@ -2316,13 +2323,6 @@ CHANGESET end assert_response :not_found - # not closed changeset - changeset = create(:changeset) - assert_no_difference "changeset.subscribers.count" do - post :unsubscribe, :params => { :id => changeset.id } - end - assert_response :conflict - # trying to unsubscribe when not subscribed changeset = create(:changeset, :closed) assert_no_difference "changeset.subscribers.count" do