Added more fixtures and tests for node versioning calls.
This commit is contained in:
parent
e7147d0d7a
commit
6a276202e5
7 changed files with 137 additions and 8 deletions
6
test/fixtures/changesets.yml
vendored
6
test/fixtures/changesets.yml
vendored
|
@ -16,3 +16,9 @@ normal_user_closed_change:
|
|||
user_id: 1
|
||||
created_at: "2007-01-01 00:00:00"
|
||||
open: 0
|
||||
|
||||
normal_user_version_change:
|
||||
id: 4
|
||||
user_id: 1
|
||||
created_at: "2008-01-01 00:00:00"
|
||||
open: 1
|
||||
|
|
14
test/fixtures/current_node_tags.yml
vendored
14
test/fixtures/current_node_tags.yml
vendored
|
@ -13,3 +13,17 @@ t3:
|
|||
k: test
|
||||
v: yes
|
||||
|
||||
t4:
|
||||
id: 4
|
||||
k: test
|
||||
v: yes
|
||||
|
||||
nv_t1:
|
||||
id: 15
|
||||
k: testing
|
||||
v: added in node version 3
|
||||
|
||||
nv_t2:
|
||||
id: 15
|
||||
k: testing two
|
||||
v: modified in node version 4
|
||||
|
|
9
test/fixtures/current_nodes.yml
vendored
9
test/fixtures/current_nodes.yml
vendored
|
@ -141,3 +141,12 @@ node_totally_wrong:
|
|||
tile: <%= QuadTile.tile_for_point(200,200) %>
|
||||
timestamp: 2007-01-01 00:00:00
|
||||
|
||||
node_with_versions:
|
||||
id: 15
|
||||
latitude: <%= 1*SCALE %>
|
||||
longitude: <%= 1*SCALE %>
|
||||
changeset_id: 4
|
||||
visible: 1
|
||||
version: 4
|
||||
tile: <%= QuadTile.tile_for_point(1,1) %>
|
||||
timestamp: 2008-01-01 00:04:00
|
||||
|
|
32
test/fixtures/node_tags.yml
vendored
32
test/fixtures/node_tags.yml
vendored
|
@ -6,7 +6,7 @@ t1:
|
|||
|
||||
t2:
|
||||
id: 3
|
||||
k: testused
|
||||
k: test
|
||||
v: yes
|
||||
version: 1
|
||||
|
||||
|
@ -15,3 +15,33 @@ t3:
|
|||
k: test
|
||||
v: yes
|
||||
version: 1
|
||||
|
||||
nv3_t1:
|
||||
id: 15
|
||||
k: testing
|
||||
v: added in node version 3
|
||||
version: 3
|
||||
|
||||
nv3_t2:
|
||||
id: 15
|
||||
k: testing two
|
||||
v: added in node version 3
|
||||
version: 3
|
||||
|
||||
nv3_t3:
|
||||
id: 15
|
||||
k: testing three
|
||||
v: added in node version 3
|
||||
version: 3
|
||||
|
||||
nv4_t1:
|
||||
id: 15
|
||||
k: testing
|
||||
v: added in node version 3
|
||||
version: 4
|
||||
|
||||
nv4_t2:
|
||||
id: 15
|
||||
k: testing two
|
||||
v: modified in node version 4
|
||||
version: 4
|
||||
|
|
39
test/fixtures/nodes.yml
vendored
39
test/fixtures/nodes.yml
vendored
|
@ -141,3 +141,42 @@ node_totally_wrong:
|
|||
tile: <%= QuadTile.tile_for_point(200,200) %>
|
||||
timestamp: 2007-01-01 00:00:00
|
||||
|
||||
node_with_versions_v1:
|
||||
id: 15
|
||||
latitude: <%= 1*SCALE %>
|
||||
longitude: <%= 1*SCALE %>
|
||||
changeset_id: 4
|
||||
visible: 1
|
||||
version: 1
|
||||
tile: <%= QuadTile.tile_for_point(1,1) %>
|
||||
timestamp: 2008-01-01 00:01:00
|
||||
|
||||
node_with_versions_v2:
|
||||
id: 15
|
||||
latitude: <%= 2*SCALE %>
|
||||
longitude: <%= 2*SCALE %>
|
||||
changeset_id: 4
|
||||
visible: 1
|
||||
version: 2
|
||||
tile: <%= QuadTile.tile_for_point(1,1) %>
|
||||
timestamp: 2008-01-01 00:02:00
|
||||
|
||||
node_with_versions_v3:
|
||||
id: 15
|
||||
latitude: <%= 1*SCALE %>
|
||||
longitude: <%= 1*SCALE %>
|
||||
changeset_id: 4
|
||||
visible: 1
|
||||
version: 3
|
||||
tile: <%= QuadTile.tile_for_point(1,1) %>
|
||||
timestamp: 2008-01-01 00:03:00
|
||||
|
||||
node_with_versions_v4:
|
||||
id: 15
|
||||
latitude: <%= 1*SCALE %>
|
||||
longitude: <%= 1*SCALE %>
|
||||
changeset_id: 4
|
||||
visible: 1
|
||||
version: 4
|
||||
tile: <%= QuadTile.tile_for_point(1,1) %>
|
||||
timestamp: 2008-01-01 00:04:00
|
||||
|
|
|
@ -83,18 +83,47 @@ class OldNodeControllerTest < Test::Unit::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
##
|
||||
# Test that getting the current version is identical to picking
|
||||
# that version with the version URI call.
|
||||
def test_current_version
|
||||
check_current_version(current_nodes(:visible_node))
|
||||
check_current_version(current_nodes(:used_node_1))
|
||||
check_current_version(current_nodes(:used_node_2))
|
||||
check_current_version(current_nodes(:node_used_by_relationship))
|
||||
check_current_version(current_nodes(:node_with_versions))
|
||||
end
|
||||
|
||||
def check_current_version(node_id)
|
||||
# get the current version of the node
|
||||
current_node = with_controller(NodeController.new) do
|
||||
get :read, :id => node_id
|
||||
assert_response :success, "cant get current node #{node_id}"
|
||||
Node.from_xml(@response.body)
|
||||
end
|
||||
assert_not_nil current_node, "getting node #{node_id} returned nil"
|
||||
|
||||
# get the "old" version of the node from the old_node interface
|
||||
get :version, :id => node_id, :version => current_node.version
|
||||
assert_response :success, "cant get old node #{node_id}, v#{current_node.version}"
|
||||
old_node = Node.from_xml(@response.body)
|
||||
|
||||
# check the nodes are the same
|
||||
assert_nodes_are_equal current_node, old_node
|
||||
end
|
||||
|
||||
##
|
||||
# for some reason a==b is false, but there doesn't seem to be any
|
||||
# difference between the nodes, so i'm checking all the attributes
|
||||
# manually and blaming it on ActiveRecord
|
||||
def assert_nodes_are_equal(a, b)
|
||||
assert_equal a.id, b.id, "node IDs"
|
||||
assert_equal a.latitude, b.latitude, "latitude"
|
||||
assert_equal a.longitude, b.longitude, "longitude"
|
||||
assert_equal a.changeset_id, b.changeset_id, "changeset ID"
|
||||
assert_equal a.visible, b.visible, "visible"
|
||||
assert_equal a.version, b.version, "version"
|
||||
assert_equal a.tags, b.tags, "tags"
|
||||
assert_equal a.latitude, b.latitude, "latitude on node #{a.id}"
|
||||
assert_equal a.longitude, b.longitude, "longitude on node #{a.id}"
|
||||
assert_equal a.changeset_id, b.changeset_id, "changeset ID on node #{a.id}"
|
||||
assert_equal a.visible, b.visible, "visible on node #{a.id}"
|
||||
assert_equal a.version, b.version, "version on node #{a.id}"
|
||||
assert_equal a.tags, b.tags, "tags on node #{a.id}"
|
||||
end
|
||||
|
||||
##
|
||||
|
|
|
@ -6,10 +6,12 @@ class CurrentNodeTagTest < Test::Unit::TestCase
|
|||
set_fixture_class :current_node_tags => :NodeTag
|
||||
|
||||
def test_tag_count
|
||||
assert_equal 3, NodeTag.count
|
||||
assert_equal 6, NodeTag.count
|
||||
node_tag_count(:visible_node, 1)
|
||||
node_tag_count(:invisible_node, 1)
|
||||
node_tag_count(:used_node_1, 1)
|
||||
node_tag_count(:used_node_2, 1)
|
||||
node_tag_count(:node_with_versions, 2)
|
||||
end
|
||||
|
||||
def node_tag_count (node, count)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue