assert_response :success
changeset_id = @response.body.to_i
- old_way = current_ways(:visible_way)
+ old_way = create(:way)
+ create(:way_node, :way => old_way, :node => create(:node, :lat => 1, :lon => 1))
diff = XML::Document.new
diff.root = XML::Node.new "osmChange"
modify = XML::Node.new "modify"
xml_old_way = old_way.to_xml_node
nd_ref = XML::Node.new "nd"
- nd_ref["ref"] = current_nodes(:visible_node).id.to_s
+ nd_ref["ref"] = create(:node, :lat => 3, :lon => 3).id.to_s
xml_old_way << nd_ref
xml_old_way["changeset"] = changeset_id.to_s
modify << xml_old_way
# check that the bounding box of a changeset gets updated correctly
# FIXME: This should really be moded to a integration test due to the with_controller
def test_changeset_bbox
+ way = create(:way)
+ create(:way_node, :way => way, :node => create(:node, :lat => 3, :lon => 3))
+
basic_authorization create(:user).email, "test"
# create a new changeset
# add (delete) a way to it, which contains a point at (3,3)
with_controller(WayController.new) do
- content update_changeset(current_ways(:visible_way).to_xml,
- changeset_id)
- put :delete, :id => current_ways(:visible_way).id
+ content update_changeset(way.to_xml, changeset_id)
+ put :delete, :id => way.id
assert_response :success, "Couldn't delete a way."
end
##
# 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
##
##
# 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