Merge remote-tracking branch 'upstream/pull/4612'

This commit is contained in:
Tom Hughes 2024-03-21 17:25:41 +00:00
commit b2acd6e49c
2 changed files with 35 additions and 7 deletions

View file

@ -130,13 +130,7 @@ module Api
# almost sensible ordering available. this would be much nicer if
# global (SVN-style) versioning were used - then that would be
# unambiguous.
elements.sort! do |a, b|
if a.timestamp == b.timestamp
a.version <=> b.version
else
a.timestamp <=> b.timestamp
end
end
elements.sort_by! { |e| [e.timestamp, e.version] }
# generate an output element for each operation. note: we avoid looking
# at the history because it is simpler - but it would be more correct to

View file

@ -1995,6 +1995,40 @@ module Api
end
end
test "sorts downloaded elements by timestamp" do
changeset = create(:changeset)
node1 = create(:old_node, :version => 2, :timestamp => "2020-02-01", :changeset => changeset)
node0 = create(:old_node, :version => 2, :timestamp => "2020-01-01", :changeset => changeset)
get changeset_download_path(changeset)
assert_response :success
assert_dom "modify", :count => 2 do |modify|
assert_dom modify[0], ">node", :count => 1 do |node|
assert_dom node, ">@id", node0.node_id.to_s
end
assert_dom modify[1], ">node", :count => 1 do |node|
assert_dom node, ">@id", node1.node_id.to_s
end
end
end
test "sorts downloaded elements by version" do
changeset = create(:changeset)
node1 = create(:old_node, :version => 3, :timestamp => "2020-01-01", :changeset => changeset)
node0 = create(:old_node, :version => 2, :timestamp => "2020-01-01", :changeset => changeset)
get changeset_download_path(changeset)
assert_response :success
assert_dom "modify", :count => 2 do |modify|
assert_dom modify[0], ">node", :count => 1 do |node|
assert_dom node, ">@id", node0.node_id.to_s
end
assert_dom modify[1], ">node", :count => 1 do |node|
assert_dom node, ">@id", node1.node_id.to_s
end
end
end
##
# 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