Fix rubocop-minitest warnings
This commit is contained in:
parent
da3aad3080
commit
7a1615bc55
29 changed files with 256 additions and 290 deletions
|
@ -90,40 +90,6 @@ Metrics/ParameterLists:
|
||||||
Metrics/PerceivedComplexity:
|
Metrics/PerceivedComplexity:
|
||||||
Max: 25
|
Max: 25
|
||||||
|
|
||||||
# Offense count: 2
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
Minitest/AssertEmpty:
|
|
||||||
Exclude:
|
|
||||||
- 'test/controllers/api/amf_controller_test.rb'
|
|
||||||
|
|
||||||
# Offense count: 6
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
Minitest/AssertEqual:
|
|
||||||
Exclude:
|
|
||||||
- 'test/controllers/api/amf_controller_test.rb'
|
|
||||||
|
|
||||||
# Offense count: 27
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
Minitest/AssertIncludes:
|
|
||||||
Exclude:
|
|
||||||
- 'test/controllers/api/amf_controller_test.rb'
|
|
||||||
- 'test/controllers/api/nodes_controller_test.rb'
|
|
||||||
- 'test/helpers/browse_helper_test.rb'
|
|
||||||
- 'test/lib/i18n_test.rb'
|
|
||||||
- 'test/models/node_test.rb'
|
|
||||||
- 'test/models/old_node_test.rb'
|
|
||||||
- 'test/models/user_test.rb'
|
|
||||||
|
|
||||||
# Offense count: 104
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
Minitest/AssertTruthy:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
# Offense count: 110
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
Minitest/RefuteFalse:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
# Offense count: 6
|
# Offense count: 6
|
||||||
Naming/AccessorMethodName:
|
Naming/AccessorMethodName:
|
||||||
Exclude:
|
Exclude:
|
||||||
|
|
|
@ -181,32 +181,32 @@ module Api
|
||||||
assert_equal Array, map[4].class, 'map "relations" element should be an array'
|
assert_equal Array, map[4].class, 'map "relations" element should be an array'
|
||||||
map[2].each do |w|
|
map[2].each do |w|
|
||||||
assert_equal 2, w.length, "way should be (id, version) pair"
|
assert_equal 2, w.length, "way should be (id, version) pair"
|
||||||
assert w[0] == w[0].floor, "way ID should be an integer"
|
assert_equal w[0], w[0].floor, "way ID should be an integer"
|
||||||
assert w[1] == w[1].floor, "way version should be an integer"
|
assert_equal w[1], w[1].floor, "way version should be an integer"
|
||||||
end
|
end
|
||||||
|
|
||||||
map[3].each do |n|
|
map[3].each do |n|
|
||||||
assert_equal 5, w.length, "node should be (id, lat, lon, [tags], version) tuple"
|
assert_equal 5, w.length, "node should be (id, lat, lon, [tags], version) tuple"
|
||||||
assert n[0] == n[0].floor, "node ID should be an integer"
|
assert_equal n[0], n[0].floor, "node ID should be an integer"
|
||||||
assert n[1] >= minlat - 0.01, "node lat should be greater than min"
|
assert n[1] >= minlat - 0.01, "node lat should be greater than min"
|
||||||
assert n[1] <= maxlat - 0.01, "node lat should be less than max"
|
assert n[1] <= maxlat - 0.01, "node lat should be less than max"
|
||||||
assert n[2] >= minlon - 0.01, "node lon should be greater than min"
|
assert n[2] >= minlon - 0.01, "node lon should be greater than min"
|
||||||
assert n[2] <= maxlon - 0.01, "node lon should be less than max"
|
assert n[2] <= maxlon - 0.01, "node lon should be less than max"
|
||||||
assert_equal Array, a[3].class, "node tags should be array"
|
assert_equal Array, a[3].class, "node tags should be array"
|
||||||
assert n[4] == n[4].floor, "node version should be an integer"
|
assert_equal n[4], n[4].floor, "node version should be an integer"
|
||||||
end
|
end
|
||||||
|
|
||||||
map[4].each do |r|
|
map[4].each do |r|
|
||||||
assert_equal 2, r.length, "relation should be (id, version) pair"
|
assert_equal 2, r.length, "relation should be (id, version) pair"
|
||||||
assert r[0] == r[0].floor, "relation ID should be an integer"
|
assert_equal r[0], r[0].floor, "relation ID should be an integer"
|
||||||
assert r[1] == r[1].floor, "relation version should be an integer"
|
assert_equal r[1], r[1].floor, "relation version should be an integer"
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: looks like amf_controller changed since this test was written
|
# TODO: looks like amf_controller changed since this test was written
|
||||||
# so someone who knows what they're doing should check this!
|
# so someone who knows what they're doing should check this!
|
||||||
ways = map[2].collect { |x| x[0] }
|
ways = map[2].collect { |x| x[0] }
|
||||||
assert ways.include?(way.id),
|
assert_includes ways, way.id,
|
||||||
"map should include used way"
|
"map should include used way"
|
||||||
assert_not ways.include?(deleted_way.id),
|
assert_not ways.include?(deleted_way.id),
|
||||||
"map should not include deleted way"
|
"map should not include deleted way"
|
||||||
end
|
end
|
||||||
|
@ -271,8 +271,8 @@ module Api
|
||||||
# so someone who knows what they're doing should check this!
|
# so someone who knows what they're doing should check this!
|
||||||
assert_not map[2].include?(way.id),
|
assert_not map[2].include?(way.id),
|
||||||
"map should not include visible way"
|
"map should not include visible way"
|
||||||
assert map[2].include?(deleted_way.id),
|
assert_includes map[2], deleted_way.id,
|
||||||
"map should include deleted way"
|
"map should include deleted way"
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_whichways_deleted_toobig
|
def test_whichways_deleted_toobig
|
||||||
|
@ -428,7 +428,7 @@ module Api
|
||||||
# ['way',wayid,history]
|
# ['way',wayid,history]
|
||||||
assert_equal history[0], "way"
|
assert_equal history[0], "way"
|
||||||
assert_equal history[1], 0
|
assert_equal history[1], 0
|
||||||
assert history[2].empty?
|
assert_empty history[2]
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_getnode_history
|
def test_getnode_history
|
||||||
|
@ -466,7 +466,7 @@ module Api
|
||||||
# ['node',nodeid,history]
|
# ['node',nodeid,history]
|
||||||
assert_equal history[0], "node"
|
assert_equal history[0], "node"
|
||||||
assert_equal history[1], 0
|
assert_equal history[1], 0
|
||||||
assert history[2].empty?
|
assert_empty history[2]
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_findgpx_bad_user
|
def test_findgpx_bad_user
|
||||||
|
@ -847,7 +847,7 @@ module Api
|
||||||
assert_equal nd.version + 1, result[4]
|
assert_equal nd.version + 1, result[4]
|
||||||
|
|
||||||
current_node = Node.find(result[3].to_i)
|
current_node = Node.find(result[3].to_i)
|
||||||
assert_equal false, current_node.visible
|
assert_not current_node.visible
|
||||||
end
|
end
|
||||||
|
|
||||||
# try deleting a node that is already deleted
|
# try deleting a node that is already deleted
|
||||||
|
@ -978,14 +978,14 @@ module Api
|
||||||
|
|
||||||
new_node = Node.find(new_node_id)
|
new_node = Node.find(new_node_id)
|
||||||
assert_equal 1, new_node.version
|
assert_equal 1, new_node.version
|
||||||
assert_equal true, new_node.visible
|
assert new_node.visible
|
||||||
assert_equal 4.56, new_node.lon
|
assert_equal 4.56, new_node.lon
|
||||||
assert_equal 12.34, new_node.lat
|
assert_equal 12.34, new_node.lat
|
||||||
assert_equal({ "test" => "new" }, new_node.tags)
|
assert_equal({ "test" => "new" }, new_node.tags)
|
||||||
|
|
||||||
changed_node = Node.find(d)
|
changed_node = Node.find(d)
|
||||||
assert_equal 2, changed_node.version
|
assert_equal 2, changed_node.version
|
||||||
assert_equal true, changed_node.visible
|
assert changed_node.visible
|
||||||
assert_equal 12.34, changed_node.lon
|
assert_equal 12.34, changed_node.lon
|
||||||
assert_equal 4.56, changed_node.lat
|
assert_equal 4.56, changed_node.lat
|
||||||
assert_equal({ "test" => "ok" }, changed_node.tags)
|
assert_equal({ "test" => "ok" }, changed_node.tags)
|
||||||
|
@ -993,7 +993,7 @@ module Api
|
||||||
# node is not deleted because our other ways are using it
|
# node is not deleted because our other ways are using it
|
||||||
deleted_node = Node.find(a)
|
deleted_node = Node.find(a)
|
||||||
assert_equal 1, deleted_node.version
|
assert_equal 1, deleted_node.version
|
||||||
assert_equal true, deleted_node.visible
|
assert deleted_node.visible
|
||||||
end
|
end
|
||||||
|
|
||||||
# check that we can update a way
|
# check that we can update a way
|
||||||
|
@ -1073,21 +1073,21 @@ module Api
|
||||||
|
|
||||||
new_node = Node.find(new_node_id)
|
new_node = Node.find(new_node_id)
|
||||||
assert_equal 1, new_node.version
|
assert_equal 1, new_node.version
|
||||||
assert_equal true, new_node.visible
|
assert new_node.visible
|
||||||
assert_equal 4.56, new_node.lon
|
assert_equal 4.56, new_node.lon
|
||||||
assert_equal 12.34, new_node.lat
|
assert_equal 12.34, new_node.lat
|
||||||
assert_equal({ "test" => "new" }, new_node.tags)
|
assert_equal({ "test" => "new" }, new_node.tags)
|
||||||
|
|
||||||
changed_node = Node.find(b)
|
changed_node = Node.find(b)
|
||||||
assert_equal 2, changed_node.version
|
assert_equal 2, changed_node.version
|
||||||
assert_equal true, changed_node.visible
|
assert changed_node.visible
|
||||||
assert_equal 12.34, changed_node.lon
|
assert_equal 12.34, changed_node.lon
|
||||||
assert_equal 4.56, changed_node.lat
|
assert_equal 4.56, changed_node.lat
|
||||||
assert_equal({ "test" => "ok" }, changed_node.tags)
|
assert_equal({ "test" => "ok" }, changed_node.tags)
|
||||||
|
|
||||||
deleted_node = Node.find(d)
|
deleted_node = Node.find(d)
|
||||||
assert_equal 2, deleted_node.version
|
assert_equal 2, deleted_node.version
|
||||||
assert_equal false, deleted_node.visible
|
assert_not deleted_node.visible
|
||||||
end
|
end
|
||||||
|
|
||||||
# check that we can delete a way
|
# check that we can delete a way
|
||||||
|
@ -1120,7 +1120,7 @@ module Api
|
||||||
|
|
||||||
new_way = Way.find(way.id)
|
new_way = Way.find(way.id)
|
||||||
assert_equal way.version + 1, new_way.version
|
assert_equal way.version + 1, new_way.version
|
||||||
assert_equal false, new_way.visible
|
assert_not new_way.visible
|
||||||
|
|
||||||
way.nds.each do |node_id|
|
way.nds.each do |node_id|
|
||||||
assert_equal result[4][node_id.to_s].nil?, Node.find(node_id).visible
|
assert_equal result[4][node_id.to_s].nil?, Node.find(node_id).visible
|
||||||
|
@ -1146,10 +1146,10 @@ module Api
|
||||||
|
|
||||||
new_way = Way.find(way.id)
|
new_way = Way.find(way.id)
|
||||||
assert_equal way.version, new_way.version
|
assert_equal way.version, new_way.version
|
||||||
assert_equal true, new_way.visible
|
assert new_way.visible
|
||||||
|
|
||||||
way.nds.each do |node_id|
|
way.nds.each do |node_id|
|
||||||
assert_equal true, Node.find(node_id).visible
|
assert Node.find(node_id).visible
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1180,7 +1180,7 @@ module Api
|
||||||
assert_equal 1, new_relation.version
|
assert_equal 1, new_relation.version
|
||||||
assert_equal [["Node", node.id, "node"], ["Way", way.id, "way"], ["Relation", relation.id, "relation"]], new_relation.members
|
assert_equal [["Node", node.id, "node"], ["Way", way.id, "way"], ["Relation", relation.id, "relation"]], new_relation.members
|
||||||
assert_equal({ "test" => "new" }, new_relation.tags)
|
assert_equal({ "test" => "new" }, new_relation.tags)
|
||||||
assert_equal true, new_relation.visible
|
assert new_relation.visible
|
||||||
end
|
end
|
||||||
|
|
||||||
# check that we can update a relation
|
# check that we can update a relation
|
||||||
|
@ -1207,7 +1207,7 @@ module Api
|
||||||
assert_equal relation.version + 1, new_relation.version
|
assert_equal relation.version + 1, new_relation.version
|
||||||
assert_equal relation.members, new_relation.members
|
assert_equal relation.members, new_relation.members
|
||||||
assert_equal({ "test" => "ok" }, new_relation.tags)
|
assert_equal({ "test" => "ok" }, new_relation.tags)
|
||||||
assert_equal true, new_relation.visible
|
assert new_relation.visible
|
||||||
end
|
end
|
||||||
|
|
||||||
# check that we can delete a relation
|
# check that we can delete a relation
|
||||||
|
@ -1234,7 +1234,7 @@ module Api
|
||||||
assert_equal relation.version + 1, new_relation.version
|
assert_equal relation.version + 1, new_relation.version
|
||||||
assert_equal [], new_relation.members
|
assert_equal [], new_relation.members
|
||||||
assert_equal({}, new_relation.tags)
|
assert_equal({}, new_relation.tags)
|
||||||
assert_equal false, new_relation.visible
|
assert_not new_relation.visible
|
||||||
end
|
end
|
||||||
|
|
||||||
# check that we can't delete a relation that is in use
|
# check that we can't delete a relation that is in use
|
||||||
|
@ -1258,7 +1258,7 @@ module Api
|
||||||
assert_equal relation.version, new_relation.version
|
assert_equal relation.version, new_relation.version
|
||||||
assert_equal relation.members, new_relation.members
|
assert_equal relation.members, new_relation.members
|
||||||
assert_equal relation.tags, new_relation.tags
|
assert_equal relation.tags, new_relation.tags
|
||||||
assert_equal true, new_relation.visible
|
assert new_relation.visible
|
||||||
end
|
end
|
||||||
|
|
||||||
# check that we can open a changeset
|
# check that we can open a changeset
|
||||||
|
@ -1276,7 +1276,7 @@ module Api
|
||||||
assert_equal "", result[1]
|
assert_equal "", result[1]
|
||||||
|
|
||||||
cs = Changeset.find(new_cs_id)
|
cs = Changeset.find(new_cs_id)
|
||||||
assert_equal true, cs.is_open?
|
assert cs.is_open?
|
||||||
assert_equal({ "comment" => "new", "source" => "new" }, cs.tags)
|
assert_equal({ "comment" => "new", "source" => "new" }, cs.tags)
|
||||||
|
|
||||||
old_cs_id = new_cs_id
|
old_cs_id = new_cs_id
|
||||||
|
@ -1294,11 +1294,11 @@ module Api
|
||||||
assert_equal "", result[1]
|
assert_equal "", result[1]
|
||||||
|
|
||||||
cs = Changeset.find(old_cs_id)
|
cs = Changeset.find(old_cs_id)
|
||||||
assert_equal false, cs.is_open?
|
assert_not cs.is_open?
|
||||||
assert_equal({ "comment" => "newer", "source" => "new" }, cs.tags)
|
assert_equal({ "comment" => "newer", "source" => "new" }, cs.tags)
|
||||||
|
|
||||||
cs = Changeset.find(new_cs_id)
|
cs = Changeset.find(new_cs_id)
|
||||||
assert_equal true, cs.is_open?
|
assert cs.is_open?
|
||||||
assert_equal({ "comment" => "newer", "source" => "newer" }, cs.tags)
|
assert_equal({ "comment" => "newer", "source" => "newer" }, cs.tags)
|
||||||
|
|
||||||
old_cs_id = new_cs_id
|
old_cs_id = new_cs_id
|
||||||
|
@ -1314,7 +1314,7 @@ module Api
|
||||||
assert_nil result[2]
|
assert_nil result[2]
|
||||||
|
|
||||||
cs = Changeset.find(old_cs_id)
|
cs = Changeset.find(old_cs_id)
|
||||||
assert_equal false, cs.is_open?
|
assert_not cs.is_open?
|
||||||
assert_equal({ "comment" => "newer", "source" => "newer" }, cs.tags)
|
assert_equal({ "comment" => "newer", "source" => "newer" }, cs.tags)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1334,7 +1334,7 @@ module Api
|
||||||
assert_equal "", result[1]
|
assert_equal "", result[1]
|
||||||
|
|
||||||
cs = Changeset.find(cs_id)
|
cs = Changeset.find(cs_id)
|
||||||
assert_equal true, cs.is_open?
|
assert cs.is_open?
|
||||||
assert_equal({ "comment" => "new", "source" => "new" }, cs.tags)
|
assert_equal({ "comment" => "new", "source" => "new" }, cs.tags)
|
||||||
|
|
||||||
post :amf_write, :body => amf_content("startchangeset", "/1", ["#{user2.email}:test", {}, cs_id, "delete", 0])
|
post :amf_write, :body => amf_content("startchangeset", "/1", ["#{user2.email}:test", {}, cs_id, "delete", 0])
|
||||||
|
@ -1347,7 +1347,7 @@ module Api
|
||||||
assert_equal "The user doesn't own that changeset", result[1]
|
assert_equal "The user doesn't own that changeset", result[1]
|
||||||
|
|
||||||
cs = Changeset.find(cs_id)
|
cs = Changeset.find(cs_id)
|
||||||
assert_equal true, cs.is_open?
|
assert cs.is_open?
|
||||||
assert_equal({ "comment" => "new", "source" => "new" }, cs.tags)
|
assert_equal({ "comment" => "new", "source" => "new" }, cs.tags)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1369,7 +1369,7 @@ module Api
|
||||||
assert_equal "", result[1]
|
assert_equal "", result[1]
|
||||||
|
|
||||||
cs = Changeset.find(new_cs_id)
|
cs = Changeset.find(new_cs_id)
|
||||||
assert_equal true, cs.is_open?
|
assert cs.is_open?
|
||||||
assert_equal({ "comment" => "foobar" }, cs.tags)
|
assert_equal({ "comment" => "foobar" }, cs.tags)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -125,38 +125,38 @@ module Api
|
||||||
def test_destroy_comment_fail
|
def test_destroy_comment_fail
|
||||||
# unauthorized
|
# unauthorized
|
||||||
comment = create(:changeset_comment)
|
comment = create(:changeset_comment)
|
||||||
assert_equal true, comment.visible
|
assert comment.visible
|
||||||
|
|
||||||
post :destroy, :params => { :id => comment.id }
|
post :destroy, :params => { :id => comment.id }
|
||||||
assert_response :unauthorized
|
assert_response :unauthorized
|
||||||
assert_equal true, comment.reload.visible
|
assert comment.reload.visible
|
||||||
|
|
||||||
basic_authorization create(:user).email, "test"
|
basic_authorization create(:user).email, "test"
|
||||||
|
|
||||||
# not a moderator
|
# not a moderator
|
||||||
post :destroy, :params => { :id => comment.id }
|
post :destroy, :params => { :id => comment.id }
|
||||||
assert_response :forbidden
|
assert_response :forbidden
|
||||||
assert_equal true, comment.reload.visible
|
assert comment.reload.visible
|
||||||
|
|
||||||
basic_authorization create(:moderator_user).email, "test"
|
basic_authorization create(:moderator_user).email, "test"
|
||||||
|
|
||||||
# bad comment id
|
# bad comment id
|
||||||
post :destroy, :params => { :id => 999111 }
|
post :destroy, :params => { :id => 999111 }
|
||||||
assert_response :not_found
|
assert_response :not_found
|
||||||
assert_equal true, comment.reload.visible
|
assert comment.reload.visible
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# test hide comment succes
|
# test hide comment succes
|
||||||
def test_hide_comment_success
|
def test_hide_comment_success
|
||||||
comment = create(:changeset_comment)
|
comment = create(:changeset_comment)
|
||||||
assert_equal true, comment.visible
|
assert comment.visible
|
||||||
|
|
||||||
basic_authorization create(:moderator_user).email, "test"
|
basic_authorization create(:moderator_user).email, "test"
|
||||||
|
|
||||||
post :destroy, :params => { :id => comment.id }
|
post :destroy, :params => { :id => comment.id }
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal false, comment.reload.visible
|
assert_not comment.reload.visible
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -164,38 +164,38 @@ module Api
|
||||||
def test_restore_comment_fail
|
def test_restore_comment_fail
|
||||||
# unauthorized
|
# unauthorized
|
||||||
comment = create(:changeset_comment, :visible => false)
|
comment = create(:changeset_comment, :visible => false)
|
||||||
assert_equal false, comment.visible
|
assert_not comment.visible
|
||||||
|
|
||||||
post :restore, :params => { :id => comment.id }
|
post :restore, :params => { :id => comment.id }
|
||||||
assert_response :unauthorized
|
assert_response :unauthorized
|
||||||
assert_equal false, comment.reload.visible
|
assert_not comment.reload.visible
|
||||||
|
|
||||||
basic_authorization create(:user).email, "test"
|
basic_authorization create(:user).email, "test"
|
||||||
|
|
||||||
# not a moderator
|
# not a moderator
|
||||||
post :restore, :params => { :id => comment.id }
|
post :restore, :params => { :id => comment.id }
|
||||||
assert_response :forbidden
|
assert_response :forbidden
|
||||||
assert_equal false, comment.reload.visible
|
assert_not comment.reload.visible
|
||||||
|
|
||||||
basic_authorization create(:moderator_user).email, "test"
|
basic_authorization create(:moderator_user).email, "test"
|
||||||
|
|
||||||
# bad comment id
|
# bad comment id
|
||||||
post :restore, :params => { :id => 999111 }
|
post :restore, :params => { :id => 999111 }
|
||||||
assert_response :not_found
|
assert_response :not_found
|
||||||
assert_equal false, comment.reload.visible
|
assert_not comment.reload.visible
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# test unhide comment succes
|
# test unhide comment succes
|
||||||
def test_unhide_comment_success
|
def test_unhide_comment_success
|
||||||
comment = create(:changeset_comment, :visible => false)
|
comment = create(:changeset_comment, :visible => false)
|
||||||
assert_equal false, comment.visible
|
assert_not comment.visible
|
||||||
|
|
||||||
basic_authorization create(:moderator_user).email, "test"
|
basic_authorization create(:moderator_user).email, "test"
|
||||||
|
|
||||||
post :restore, :params => { :id => comment.id }
|
post :restore, :params => { :id => comment.id }
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal true, comment.reload.visible
|
assert comment.reload.visible
|
||||||
end
|
end
|
||||||
|
|
||||||
# This test ensures that token capabilities behave correctly for a method that
|
# This test ensures that token capabilities behave correctly for a method that
|
||||||
|
|
|
@ -477,10 +477,10 @@ module Api
|
||||||
assert_select "diffResult>relation", 2
|
assert_select "diffResult>relation", 2
|
||||||
|
|
||||||
# check that everything was deleted
|
# check that everything was deleted
|
||||||
assert_equal false, Node.find(used_node.id).visible
|
assert_not Node.find(used_node.id).visible
|
||||||
assert_equal false, Way.find(used_way.id).visible
|
assert_not Way.find(used_way.id).visible
|
||||||
assert_equal false, Relation.find(super_relation.id).visible
|
assert_not Relation.find(super_relation.id).visible
|
||||||
assert_equal false, Relation.find(used_relation.id).visible
|
assert_not Relation.find(used_relation.id).visible
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -502,7 +502,7 @@ module Api
|
||||||
assert_select "diffResult>node", 1
|
assert_select "diffResult>node", 1
|
||||||
|
|
||||||
# check that everything was deleted
|
# check that everything was deleted
|
||||||
assert_equal false, Node.find(node.id).visible
|
assert_not Node.find(node.id).visible
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_repeated_changeset_create
|
def test_repeated_changeset_create
|
||||||
|
@ -604,10 +604,10 @@ module Api
|
||||||
assert_equal "Precondition failed: Way #{used_way.id} is still used by relations #{relation.id}.", @response.body
|
assert_equal "Precondition failed: Way #{used_way.id} is still used by relations #{relation.id}.", @response.body
|
||||||
|
|
||||||
# check that nothing was, in fact, deleted
|
# check that nothing was, in fact, deleted
|
||||||
assert_equal true, Node.find(used_node.id).visible
|
assert Node.find(used_node.id).visible
|
||||||
assert_equal true, Way.find(used_way.id).visible
|
assert Way.find(used_way.id).visible
|
||||||
assert_equal true, Relation.find(relation.id).visible
|
assert Relation.find(relation.id).visible
|
||||||
assert_equal true, Relation.find(other_relation.id).visible
|
assert Relation.find(other_relation.id).visible
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -670,9 +670,9 @@ module Api
|
||||||
assert_equal used_relation.version, doc.find("//diffResult/relation").first["new_version"].to_i
|
assert_equal used_relation.version, doc.find("//diffResult/relation").first["new_version"].to_i
|
||||||
|
|
||||||
# check that nothing was, in fact, deleted
|
# check that nothing was, in fact, deleted
|
||||||
assert_equal true, Node.find(used_node.id).visible
|
assert Node.find(used_node.id).visible
|
||||||
assert_equal true, Way.find(used_way.id).visible
|
assert Way.find(used_way.id).visible
|
||||||
assert_equal true, Relation.find(used_relation.id).visible
|
assert Relation.find(used_relation.id).visible
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
|
@ -82,7 +82,7 @@ module Api
|
||||||
assert_in_delta lat * 10000000, checknode.latitude, 1, "saved node does not match requested latitude"
|
assert_in_delta lat * 10000000, checknode.latitude, 1, "saved node does not match requested latitude"
|
||||||
assert_in_delta lon * 10000000, checknode.longitude, 1, "saved node does not match requested longitude"
|
assert_in_delta lon * 10000000, checknode.longitude, 1, "saved node does not match requested longitude"
|
||||||
assert_equal changeset.id, checknode.changeset_id, "saved node does not belong to changeset that it was created in"
|
assert_equal changeset.id, checknode.changeset_id, "saved node does not belong to changeset that it was created in"
|
||||||
assert_equal true, checknode.visible, "saved node is not visible"
|
assert checknode.visible, "saved node is not visible"
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_create_invalid_xml
|
def test_create_invalid_xml
|
||||||
|
@ -494,7 +494,7 @@ module Api
|
||||||
# test adding tags to a node
|
# test adding tags to a node
|
||||||
def test_duplicate_tags
|
def test_duplicate_tags
|
||||||
existing_tag = create(:node_tag)
|
existing_tag = create(:node_tag)
|
||||||
assert_equal true, existing_tag.node.changeset.user.data_public
|
assert existing_tag.node.changeset.user.data_public
|
||||||
# setup auth
|
# setup auth
|
||||||
basic_authorization existing_tag.node.changeset.user.email, "test"
|
basic_authorization existing_tag.node.changeset.user.email, "test"
|
||||||
|
|
||||||
|
@ -556,7 +556,7 @@ module Api
|
||||||
|
|
||||||
# check the tags are not corrupted
|
# check the tags are not corrupted
|
||||||
assert_equal checknode.tags, apinode.tags
|
assert_equal checknode.tags, apinode.tags
|
||||||
assert apinode.tags.include?("\#{@user.inspect}")
|
assert_includes apinode.tags, "\#{@user.inspect}"
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
|
@ -304,8 +304,8 @@ module Api
|
||||||
"saved relation does not belong in the changeset it was assigned to"
|
"saved relation does not belong in the changeset it was assigned to"
|
||||||
assert_equal user.id, checkrelation.changeset.user_id,
|
assert_equal user.id, checkrelation.changeset.user_id,
|
||||||
"saved relation does not belong to user that created it"
|
"saved relation does not belong to user that created it"
|
||||||
assert_equal true, checkrelation.visible,
|
assert checkrelation.visible,
|
||||||
"saved relation is not visible"
|
"saved relation is not visible"
|
||||||
# ok the relation is there but can we also retrieve it?
|
# ok the relation is there but can we also retrieve it?
|
||||||
get :show, :params => { :id => relationid }
|
get :show, :params => { :id => relationid }
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
@ -334,8 +334,8 @@ module Api
|
||||||
"saved relation does not belong in the changeset it was assigned to"
|
"saved relation does not belong in the changeset it was assigned to"
|
||||||
assert_equal user.id, checkrelation.changeset.user_id,
|
assert_equal user.id, checkrelation.changeset.user_id,
|
||||||
"saved relation does not belong to user that created it"
|
"saved relation does not belong to user that created it"
|
||||||
assert_equal true, checkrelation.visible,
|
assert checkrelation.visible,
|
||||||
"saved relation is not visible"
|
"saved relation is not visible"
|
||||||
# ok the relation is there but can we also retrieve it?
|
# ok the relation is there but can we also retrieve it?
|
||||||
|
|
||||||
get :show, :params => { :id => relationid }
|
get :show, :params => { :id => relationid }
|
||||||
|
@ -364,8 +364,8 @@ module Api
|
||||||
"saved relation does not belong in the changeset it was assigned to"
|
"saved relation does not belong in the changeset it was assigned to"
|
||||||
assert_equal user.id, checkrelation.changeset.user_id,
|
assert_equal user.id, checkrelation.changeset.user_id,
|
||||||
"saved relation does not belong to user that created it"
|
"saved relation does not belong to user that created it"
|
||||||
assert_equal true, checkrelation.visible,
|
assert checkrelation.visible,
|
||||||
"saved relation is not visible"
|
"saved relation is not visible"
|
||||||
# ok the relation is there but can we also retrieve it?
|
# ok the relation is there but can we also retrieve it?
|
||||||
|
|
||||||
get :show, :params => { :id => relationid }
|
get :show, :params => { :id => relationid }
|
||||||
|
@ -395,8 +395,8 @@ module Api
|
||||||
"saved relation does not belong in the changeset it was assigned to"
|
"saved relation does not belong in the changeset it was assigned to"
|
||||||
assert_equal user.id, checkrelation.changeset.user_id,
|
assert_equal user.id, checkrelation.changeset.user_id,
|
||||||
"saved relation does not belong to user that created it"
|
"saved relation does not belong to user that created it"
|
||||||
assert_equal true, checkrelation.visible,
|
assert checkrelation.visible,
|
||||||
"saved relation is not visible"
|
"saved relation is not visible"
|
||||||
# ok the relation is there but can we also retrieve it?
|
# ok the relation is there but can we also retrieve it?
|
||||||
get :show, :params => { :id => relationid }
|
get :show, :params => { :id => relationid }
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
|
@ -210,7 +210,7 @@ module Api
|
||||||
assert_equal "New Trace", trace.description
|
assert_equal "New Trace", trace.description
|
||||||
assert_equal %w[new trace], trace.tags.order(:tag).collect(&:tag)
|
assert_equal %w[new trace], trace.tags.order(:tag).collect(&:tag)
|
||||||
assert_equal "trackable", trace.visibility
|
assert_equal "trackable", trace.visibility
|
||||||
assert_equal false, trace.inserted
|
assert_not trace.inserted
|
||||||
assert_equal File.new(fixture).read, File.new(trace.trace_name).read
|
assert_equal File.new(fixture).read, File.new(trace.trace_name).read
|
||||||
trace.destroy
|
trace.destroy
|
||||||
assert_equal "trackable", user.preferences.where(:k => "gps.trace.visibility").first.v
|
assert_equal "trackable", user.preferences.where(:k => "gps.trace.visibility").first.v
|
||||||
|
@ -228,7 +228,7 @@ module Api
|
||||||
assert_equal "New Trace", trace.description
|
assert_equal "New Trace", trace.description
|
||||||
assert_equal %w[new trace], trace.tags.order(:tag).collect(&:tag)
|
assert_equal %w[new trace], trace.tags.order(:tag).collect(&:tag)
|
||||||
assert_equal "public", trace.visibility
|
assert_equal "public", trace.visibility
|
||||||
assert_equal false, trace.inserted
|
assert_not trace.inserted
|
||||||
assert_equal File.new(fixture).read, File.new(trace.trace_name).read
|
assert_equal File.new(fixture).read, File.new(trace.trace_name).read
|
||||||
trace.destroy
|
trace.destroy
|
||||||
assert_equal "public", user.preferences.where(:k => "gps.trace.visibility").first.v
|
assert_equal "public", user.preferences.where(:k => "gps.trace.visibility").first.v
|
||||||
|
@ -247,7 +247,7 @@ module Api
|
||||||
assert_equal "New Trace", trace.description
|
assert_equal "New Trace", trace.description
|
||||||
assert_equal %w[new trace], trace.tags.order(:tag).collect(&:tag)
|
assert_equal %w[new trace], trace.tags.order(:tag).collect(&:tag)
|
||||||
assert_equal "private", trace.visibility
|
assert_equal "private", trace.visibility
|
||||||
assert_equal false, trace.inserted
|
assert_not trace.inserted
|
||||||
assert_equal File.new(fixture).read, File.new(trace.trace_name).read
|
assert_equal File.new(fixture).read, File.new(trace.trace_name).read
|
||||||
trace.destroy
|
trace.destroy
|
||||||
assert_equal "private", second_user.preferences.where(:k => "gps.trace.visibility").first.v
|
assert_equal "private", second_user.preferences.where(:k => "gps.trace.visibility").first.v
|
||||||
|
|
|
@ -190,8 +190,8 @@ module Api
|
||||||
"saved way does not belong to the correct changeset"
|
"saved way does not belong to the correct changeset"
|
||||||
assert_equal user.id, checkway.changeset.user_id,
|
assert_equal user.id, checkway.changeset.user_id,
|
||||||
"saved way does not belong to user that created it"
|
"saved way does not belong to user that created it"
|
||||||
assert_equal true, checkway.visible,
|
assert checkway.visible,
|
||||||
"saved way is not visible"
|
"saved way is not visible"
|
||||||
end
|
end
|
||||||
|
|
||||||
# -------------------------------------
|
# -------------------------------------
|
||||||
|
|
|
@ -740,7 +740,7 @@ class DiaryEntriesControllerTest < ActionController::TestCase
|
||||||
post :hide,
|
post :hide,
|
||||||
:params => { :display_name => user.display_name, :id => diary_entry.id }
|
:params => { :display_name => user.display_name, :id => diary_entry.id }
|
||||||
assert_response :forbidden
|
assert_response :forbidden
|
||||||
assert_equal true, DiaryEntry.find(diary_entry.id).visible
|
assert DiaryEntry.find(diary_entry.id).visible
|
||||||
|
|
||||||
# Now try as a normal user
|
# Now try as a normal user
|
||||||
post :hide,
|
post :hide,
|
||||||
|
@ -748,7 +748,7 @@ class DiaryEntriesControllerTest < ActionController::TestCase
|
||||||
:session => { :user => user }
|
:session => { :user => user }
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_redirected_to :controller => :errors, :action => :forbidden
|
assert_redirected_to :controller => :errors, :action => :forbidden
|
||||||
assert_equal true, DiaryEntry.find(diary_entry.id).visible
|
assert DiaryEntry.find(diary_entry.id).visible
|
||||||
|
|
||||||
# Now try as a moderator
|
# Now try as a moderator
|
||||||
post :hide,
|
post :hide,
|
||||||
|
@ -756,7 +756,7 @@ class DiaryEntriesControllerTest < ActionController::TestCase
|
||||||
:session => { :user => create(:moderator_user) }
|
:session => { :user => create(:moderator_user) }
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_redirected_to :action => :index, :display_name => user.display_name
|
assert_redirected_to :action => :index, :display_name => user.display_name
|
||||||
assert_equal false, DiaryEntry.find(diary_entry.id).visible
|
assert_not DiaryEntry.find(diary_entry.id).visible
|
||||||
|
|
||||||
# Reset
|
# Reset
|
||||||
diary_entry.reload.update(:visible => true)
|
diary_entry.reload.update(:visible => true)
|
||||||
|
@ -767,7 +767,7 @@ class DiaryEntriesControllerTest < ActionController::TestCase
|
||||||
:session => { :user => create(:administrator_user) }
|
:session => { :user => create(:administrator_user) }
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_redirected_to :action => :index, :display_name => user.display_name
|
assert_redirected_to :action => :index, :display_name => user.display_name
|
||||||
assert_equal false, DiaryEntry.find(diary_entry.id).visible
|
assert_not DiaryEntry.find(diary_entry.id).visible
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_unhide
|
def test_unhide
|
||||||
|
@ -778,7 +778,7 @@ class DiaryEntriesControllerTest < ActionController::TestCase
|
||||||
post :unhide,
|
post :unhide,
|
||||||
:params => { :display_name => user.display_name, :id => diary_entry.id }
|
:params => { :display_name => user.display_name, :id => diary_entry.id }
|
||||||
assert_response :forbidden
|
assert_response :forbidden
|
||||||
assert_equal false, DiaryEntry.find(diary_entry.id).visible
|
assert_not DiaryEntry.find(diary_entry.id).visible
|
||||||
|
|
||||||
# Now try as a normal user
|
# Now try as a normal user
|
||||||
post :unhide,
|
post :unhide,
|
||||||
|
@ -786,7 +786,7 @@ class DiaryEntriesControllerTest < ActionController::TestCase
|
||||||
:session => { :user => user }
|
:session => { :user => user }
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_redirected_to :controller => :errors, :action => :forbidden
|
assert_redirected_to :controller => :errors, :action => :forbidden
|
||||||
assert_equal false, DiaryEntry.find(diary_entry.id).visible
|
assert_not DiaryEntry.find(diary_entry.id).visible
|
||||||
|
|
||||||
# Finally try as an administrator
|
# Finally try as an administrator
|
||||||
post :unhide,
|
post :unhide,
|
||||||
|
@ -794,7 +794,7 @@ class DiaryEntriesControllerTest < ActionController::TestCase
|
||||||
:session => { :user => create(:administrator_user) }
|
:session => { :user => create(:administrator_user) }
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_redirected_to :action => :index, :display_name => user.display_name
|
assert_redirected_to :action => :index, :display_name => user.display_name
|
||||||
assert_equal true, DiaryEntry.find(diary_entry.id).visible
|
assert DiaryEntry.find(diary_entry.id).visible
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_hidecomment
|
def test_hidecomment
|
||||||
|
@ -806,7 +806,7 @@ class DiaryEntriesControllerTest < ActionController::TestCase
|
||||||
post :hidecomment,
|
post :hidecomment,
|
||||||
:params => { :display_name => user.display_name, :id => diary_entry.id, :comment => diary_comment.id }
|
:params => { :display_name => user.display_name, :id => diary_entry.id, :comment => diary_comment.id }
|
||||||
assert_response :forbidden
|
assert_response :forbidden
|
||||||
assert_equal true, DiaryComment.find(diary_comment.id).visible
|
assert DiaryComment.find(diary_comment.id).visible
|
||||||
|
|
||||||
# Now try as a normal user
|
# Now try as a normal user
|
||||||
post :hidecomment,
|
post :hidecomment,
|
||||||
|
@ -814,7 +814,7 @@ class DiaryEntriesControllerTest < ActionController::TestCase
|
||||||
:session => { :user => user }
|
:session => { :user => user }
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_redirected_to :controller => :errors, :action => :forbidden
|
assert_redirected_to :controller => :errors, :action => :forbidden
|
||||||
assert_equal true, DiaryComment.find(diary_comment.id).visible
|
assert DiaryComment.find(diary_comment.id).visible
|
||||||
|
|
||||||
# Try as a moderator
|
# Try as a moderator
|
||||||
post :hidecomment,
|
post :hidecomment,
|
||||||
|
@ -822,7 +822,7 @@ class DiaryEntriesControllerTest < ActionController::TestCase
|
||||||
:session => { :user => create(:moderator_user) }
|
:session => { :user => create(:moderator_user) }
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_redirected_to :action => :show, :display_name => user.display_name, :id => diary_entry.id
|
assert_redirected_to :action => :show, :display_name => user.display_name, :id => diary_entry.id
|
||||||
assert_equal false, DiaryComment.find(diary_comment.id).visible
|
assert_not DiaryComment.find(diary_comment.id).visible
|
||||||
|
|
||||||
# Reset
|
# Reset
|
||||||
diary_comment.reload.update(:visible => true)
|
diary_comment.reload.update(:visible => true)
|
||||||
|
@ -833,7 +833,7 @@ class DiaryEntriesControllerTest < ActionController::TestCase
|
||||||
:session => { :user => create(:administrator_user) }
|
:session => { :user => create(:administrator_user) }
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_redirected_to :action => :show, :display_name => user.display_name, :id => diary_entry.id
|
assert_redirected_to :action => :show, :display_name => user.display_name, :id => diary_entry.id
|
||||||
assert_equal false, DiaryComment.find(diary_comment.id).visible
|
assert_not DiaryComment.find(diary_comment.id).visible
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_unhidecomment
|
def test_unhidecomment
|
||||||
|
@ -845,7 +845,7 @@ class DiaryEntriesControllerTest < ActionController::TestCase
|
||||||
post :unhidecomment,
|
post :unhidecomment,
|
||||||
:params => { :display_name => user.display_name, :id => diary_entry.id, :comment => diary_comment.id }
|
:params => { :display_name => user.display_name, :id => diary_entry.id, :comment => diary_comment.id }
|
||||||
assert_response :forbidden
|
assert_response :forbidden
|
||||||
assert_equal false, DiaryComment.find(diary_comment.id).visible
|
assert_not DiaryComment.find(diary_comment.id).visible
|
||||||
|
|
||||||
# Now try as a normal user
|
# Now try as a normal user
|
||||||
post :unhidecomment,
|
post :unhidecomment,
|
||||||
|
@ -853,7 +853,7 @@ class DiaryEntriesControllerTest < ActionController::TestCase
|
||||||
:session => { :user => user }
|
:session => { :user => user }
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_redirected_to :controller => :errors, :action => :forbidden
|
assert_redirected_to :controller => :errors, :action => :forbidden
|
||||||
assert_equal false, DiaryComment.find(diary_comment.id).visible
|
assert_not DiaryComment.find(diary_comment.id).visible
|
||||||
|
|
||||||
# Finally try as an administrator
|
# Finally try as an administrator
|
||||||
post :unhidecomment,
|
post :unhidecomment,
|
||||||
|
@ -861,7 +861,7 @@ class DiaryEntriesControllerTest < ActionController::TestCase
|
||||||
:session => { :user => administrator_user }
|
:session => { :user => administrator_user }
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_redirected_to :action => :show, :display_name => user.display_name, :id => diary_entry.id
|
assert_redirected_to :action => :show, :display_name => user.display_name, :id => diary_entry.id
|
||||||
assert_equal true, DiaryComment.find(diary_comment.id).visible
|
assert DiaryComment.find(diary_comment.id).visible
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_comments
|
def test_comments
|
||||||
|
|
|
@ -95,13 +95,13 @@ class IssuesControllerTest < ActionController::TestCase
|
||||||
session[:user] = create(:administrator_user).id
|
session[:user] = create(:administrator_user).id
|
||||||
get :resolve, :params => { :id => issue.id }
|
get :resolve, :params => { :id => issue.id }
|
||||||
assert_response :not_found
|
assert_response :not_found
|
||||||
assert_equal false, issue.reload.resolved?
|
assert_not issue.reload.resolved?
|
||||||
|
|
||||||
# Resolve issue as moderator
|
# Resolve issue as moderator
|
||||||
session[:user] = create(:moderator_user).id
|
session[:user] = create(:moderator_user).id
|
||||||
get :resolve, :params => { :id => issue.id }
|
get :resolve, :params => { :id => issue.id }
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_equal true, issue.reload.resolved?
|
assert issue.reload.resolved?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_resolve_administrator
|
def test_resolve_administrator
|
||||||
|
@ -123,13 +123,13 @@ class IssuesControllerTest < ActionController::TestCase
|
||||||
session[:user] = create(:moderator_user).id
|
session[:user] = create(:moderator_user).id
|
||||||
get :resolve, :params => { :id => issue.id }
|
get :resolve, :params => { :id => issue.id }
|
||||||
assert_response :not_found
|
assert_response :not_found
|
||||||
assert_equal false, issue.reload.resolved?
|
assert_not issue.reload.resolved?
|
||||||
|
|
||||||
# Resolve issue as administrator
|
# Resolve issue as administrator
|
||||||
session[:user] = create(:administrator_user).id
|
session[:user] = create(:administrator_user).id
|
||||||
get :resolve, :params => { :id => issue.id }
|
get :resolve, :params => { :id => issue.id }
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_equal true, issue.reload.resolved?
|
assert issue.reload.resolved?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_ignore_moderator
|
def test_ignore_moderator
|
||||||
|
@ -151,13 +151,13 @@ class IssuesControllerTest < ActionController::TestCase
|
||||||
session[:user] = create(:administrator_user).id
|
session[:user] = create(:administrator_user).id
|
||||||
get :ignore, :params => { :id => issue.id }
|
get :ignore, :params => { :id => issue.id }
|
||||||
assert_response :not_found
|
assert_response :not_found
|
||||||
assert_equal false, issue.reload.ignored?
|
assert_not issue.reload.ignored?
|
||||||
|
|
||||||
# Ignore issue as moderator
|
# Ignore issue as moderator
|
||||||
session[:user] = create(:moderator_user).id
|
session[:user] = create(:moderator_user).id
|
||||||
get :ignore, :params => { :id => issue.id }
|
get :ignore, :params => { :id => issue.id }
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_equal true, issue.reload.ignored?
|
assert issue.reload.ignored?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_ignore_administrator
|
def test_ignore_administrator
|
||||||
|
@ -179,13 +179,13 @@ class IssuesControllerTest < ActionController::TestCase
|
||||||
session[:user] = create(:moderator_user).id
|
session[:user] = create(:moderator_user).id
|
||||||
get :ignore, :params => { :id => issue.id }
|
get :ignore, :params => { :id => issue.id }
|
||||||
assert_response :not_found
|
assert_response :not_found
|
||||||
assert_equal false, issue.reload.ignored?
|
assert_not issue.reload.ignored?
|
||||||
|
|
||||||
# Ignore issue as administrator
|
# Ignore issue as administrator
|
||||||
session[:user] = create(:administrator_user).id
|
session[:user] = create(:administrator_user).id
|
||||||
get :ignore, :params => { :id => issue.id }
|
get :ignore, :params => { :id => issue.id }
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_equal true, issue.reload.ignored?
|
assert issue.reload.ignored?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_reopen_moderator
|
def test_reopen_moderator
|
||||||
|
@ -209,13 +209,13 @@ class IssuesControllerTest < ActionController::TestCase
|
||||||
session[:user] = create(:administrator_user).id
|
session[:user] = create(:administrator_user).id
|
||||||
get :reopen, :params => { :id => issue.id }
|
get :reopen, :params => { :id => issue.id }
|
||||||
assert_response :not_found
|
assert_response :not_found
|
||||||
assert_equal false, issue.reload.open?
|
assert_not issue.reload.open?
|
||||||
|
|
||||||
# Reopen issue as moderator
|
# Reopen issue as moderator
|
||||||
session[:user] = create(:moderator_user).id
|
session[:user] = create(:moderator_user).id
|
||||||
get :reopen, :params => { :id => issue.id }
|
get :reopen, :params => { :id => issue.id }
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_equal true, issue.reload.open?
|
assert issue.reload.open?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_reopen_administrator
|
def test_reopen_administrator
|
||||||
|
@ -239,12 +239,12 @@ class IssuesControllerTest < ActionController::TestCase
|
||||||
session[:user] = create(:moderator_user).id
|
session[:user] = create(:moderator_user).id
|
||||||
get :reopen, :params => { :id => issue.id }
|
get :reopen, :params => { :id => issue.id }
|
||||||
assert_response :not_found
|
assert_response :not_found
|
||||||
assert_equal false, issue.reload.open?
|
assert_not issue.reload.open?
|
||||||
|
|
||||||
# Reopen issue as administrator
|
# Reopen issue as administrator
|
||||||
session[:user] = create(:administrator_user).id
|
session[:user] = create(:administrator_user).id
|
||||||
get :reopen, :params => { :id => issue.id }
|
get :reopen, :params => { :id => issue.id }
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_equal true, issue.reload.open?
|
assert issue.reload.open?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -266,7 +266,7 @@ class MessagesControllerTest < ActionController::TestCase
|
||||||
assert_select "textarea#message_body", :count => 1
|
assert_select "textarea#message_body", :count => 1
|
||||||
assert_select "input[type='submit'][value='Send']", :count => 1
|
assert_select "input[type='submit'][value='Send']", :count => 1
|
||||||
end
|
end
|
||||||
assert_equal true, Message.find(unread_message.id).message_read
|
assert Message.find(unread_message.id).message_read
|
||||||
|
|
||||||
# Asking to reply to a message with no ID should fail
|
# Asking to reply to a message with no ID should fail
|
||||||
assert_raise ActionController::UrlGenerationError do
|
assert_raise ActionController::UrlGenerationError do
|
||||||
|
@ -306,7 +306,7 @@ class MessagesControllerTest < ActionController::TestCase
|
||||||
get :show, :params => { :id => unread_message.id }
|
get :show, :params => { :id => unread_message.id }
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_template "show"
|
assert_template "show"
|
||||||
assert_equal false, Message.find(unread_message.id).message_read
|
assert_not Message.find(unread_message.id).message_read
|
||||||
|
|
||||||
# Login as the message recipient
|
# Login as the message recipient
|
||||||
session[:user] = recipient_user.id
|
session[:user] = recipient_user.id
|
||||||
|
@ -315,7 +315,7 @@ class MessagesControllerTest < ActionController::TestCase
|
||||||
get :show, :params => { :id => unread_message.id }
|
get :show, :params => { :id => unread_message.id }
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_template "show"
|
assert_template "show"
|
||||||
assert_equal true, Message.find(unread_message.id).message_read
|
assert Message.find(unread_message.id).message_read
|
||||||
|
|
||||||
# Asking to read a message with no ID should fail
|
# Asking to read a message with no ID should fail
|
||||||
assert_raise ActionController::UrlGenerationError do
|
assert_raise ActionController::UrlGenerationError do
|
||||||
|
@ -399,24 +399,24 @@ class MessagesControllerTest < ActionController::TestCase
|
||||||
# Check that the marking a message read works
|
# Check that the marking a message read works
|
||||||
post :mark, :params => { :message_id => unread_message.id, :mark => "read" }
|
post :mark, :params => { :message_id => unread_message.id, :mark => "read" }
|
||||||
assert_redirected_to inbox_messages_path
|
assert_redirected_to inbox_messages_path
|
||||||
assert_equal true, Message.find(unread_message.id).message_read
|
assert Message.find(unread_message.id).message_read
|
||||||
|
|
||||||
# Check that the marking a message unread works
|
# Check that the marking a message unread works
|
||||||
post :mark, :params => { :message_id => unread_message.id, :mark => "unread" }
|
post :mark, :params => { :message_id => unread_message.id, :mark => "unread" }
|
||||||
assert_redirected_to inbox_messages_path
|
assert_redirected_to inbox_messages_path
|
||||||
assert_equal false, Message.find(unread_message.id).message_read
|
assert_not Message.find(unread_message.id).message_read
|
||||||
|
|
||||||
# Check that the marking a message read via XHR works
|
# Check that the marking a message read via XHR works
|
||||||
post :mark, :xhr => true, :params => { :message_id => unread_message.id, :mark => "read" }
|
post :mark, :xhr => true, :params => { :message_id => unread_message.id, :mark => "read" }
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_template "mark"
|
assert_template "mark"
|
||||||
assert_equal true, Message.find(unread_message.id).message_read
|
assert Message.find(unread_message.id).message_read
|
||||||
|
|
||||||
# Check that the marking a message unread via XHR works
|
# Check that the marking a message unread via XHR works
|
||||||
post :mark, :xhr => true, :params => { :message_id => unread_message.id, :mark => "unread" }
|
post :mark, :xhr => true, :params => { :message_id => unread_message.id, :mark => "unread" }
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_template "mark"
|
assert_template "mark"
|
||||||
assert_equal false, Message.find(unread_message.id).message_read
|
assert_not Message.find(unread_message.id).message_read
|
||||||
|
|
||||||
# Asking to mark a message with no ID should fail
|
# Asking to mark a message with no ID should fail
|
||||||
assert_raise ActionController::UrlGenerationError do
|
assert_raise ActionController::UrlGenerationError do
|
||||||
|
@ -458,16 +458,16 @@ class MessagesControllerTest < ActionController::TestCase
|
||||||
assert_redirected_to inbox_messages_path
|
assert_redirected_to inbox_messages_path
|
||||||
assert_equal "Message deleted", flash[:notice]
|
assert_equal "Message deleted", flash[:notice]
|
||||||
m = Message.find(read_message.id)
|
m = Message.find(read_message.id)
|
||||||
assert_equal true, m.from_user_visible
|
assert m.from_user_visible
|
||||||
assert_equal false, m.to_user_visible
|
assert_not m.to_user_visible
|
||||||
|
|
||||||
# Check that the destroying a sent message works
|
# Check that the destroying a sent message works
|
||||||
delete :destroy, :params => { :id => sent_message.id, :referer => outbox_messages_path }
|
delete :destroy, :params => { :id => sent_message.id, :referer => outbox_messages_path }
|
||||||
assert_redirected_to outbox_messages_path
|
assert_redirected_to outbox_messages_path
|
||||||
assert_equal "Message deleted", flash[:notice]
|
assert_equal "Message deleted", flash[:notice]
|
||||||
m = Message.find(sent_message.id)
|
m = Message.find(sent_message.id)
|
||||||
assert_equal false, m.from_user_visible
|
assert_not m.from_user_visible
|
||||||
assert_equal true, m.to_user_visible
|
assert m.to_user_visible
|
||||||
|
|
||||||
# Asking to destroy a message with no ID should fail
|
# Asking to destroy a message with no ID should fail
|
||||||
assert_raise ActionController::UrlGenerationError do
|
assert_raise ActionController::UrlGenerationError do
|
||||||
|
|
|
@ -565,7 +565,7 @@ class TracesControllerTest < ActionController::TestCase
|
||||||
assert_equal "New Trace", trace.description
|
assert_equal "New Trace", trace.description
|
||||||
assert_equal %w[new trace], trace.tags.order(:tag).collect(&:tag)
|
assert_equal %w[new trace], trace.tags.order(:tag).collect(&:tag)
|
||||||
assert_equal "trackable", trace.visibility
|
assert_equal "trackable", trace.visibility
|
||||||
assert_equal false, trace.inserted
|
assert_not trace.inserted
|
||||||
assert_equal File.new(fixture).read, File.new(trace.trace_name).read
|
assert_equal File.new(fixture).read, File.new(trace.trace_name).read
|
||||||
trace.destroy
|
trace.destroy
|
||||||
assert_equal "trackable", user.preferences.where(:k => "gps.trace.visibility").first.v
|
assert_equal "trackable", user.preferences.where(:k => "gps.trace.visibility").first.v
|
||||||
|
@ -673,7 +673,7 @@ class TracesControllerTest < ActionController::TestCase
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_redirected_to :action => :index, :display_name => public_trace_file.user.display_name
|
assert_redirected_to :action => :index, :display_name => public_trace_file.user.display_name
|
||||||
trace = Trace.find(public_trace_file.id)
|
trace = Trace.find(public_trace_file.id)
|
||||||
assert_equal false, trace.visible
|
assert_not trace.visible
|
||||||
|
|
||||||
# Finally with a trace that is destroyed by an admin
|
# Finally with a trace that is destroyed by an admin
|
||||||
public_trace_file = create(:trace, :visibility => "public")
|
public_trace_file = create(:trace, :visibility => "public")
|
||||||
|
@ -683,7 +683,7 @@ class TracesControllerTest < ActionController::TestCase
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_redirected_to :action => :index, :display_name => public_trace_file.user.display_name
|
assert_redirected_to :action => :index, :display_name => public_trace_file.user.display_name
|
||||||
trace = Trace.find(public_trace_file.id)
|
trace = Trace.find(public_trace_file.id)
|
||||||
assert_equal false, trace.visible
|
assert_not trace.visible
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -120,7 +120,7 @@ class UserBlocksControllerTest < ActionController::TestCase
|
||||||
# Viewing an active block should work, but shouldn't mark it as seen
|
# Viewing an active block should work, but shouldn't mark it as seen
|
||||||
get :show, :params => { :id => active_block.id }
|
get :show, :params => { :id => active_block.id }
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal true, UserBlock.find(active_block.id).needs_view
|
assert UserBlock.find(active_block.id).needs_view
|
||||||
|
|
||||||
# Login as the blocked user
|
# Login as the blocked user
|
||||||
session[:user] = active_block.user.id
|
session[:user] = active_block.user.id
|
||||||
|
@ -128,7 +128,7 @@ class UserBlocksControllerTest < ActionController::TestCase
|
||||||
# Now viewing it should mark it as seen
|
# Now viewing it should mark it as seen
|
||||||
get :show, :params => { :id => active_block.id }
|
get :show, :params => { :id => active_block.id }
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal false, UserBlock.find(active_block.id).needs_view
|
assert_not UserBlock.find(active_block.id).needs_view
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -261,7 +261,7 @@ class UserBlocksControllerTest < ActionController::TestCase
|
||||||
assert_in_delta Time.now, b.created_at, 1
|
assert_in_delta Time.now, b.created_at, 1
|
||||||
assert_in_delta Time.now, b.updated_at, 1
|
assert_in_delta Time.now, b.updated_at, 1
|
||||||
assert_in_delta Time.now + 12.hours, b.ends_at, 1
|
assert_in_delta Time.now + 12.hours, b.ends_at, 1
|
||||||
assert_equal false, b.needs_view
|
assert_not b.needs_view
|
||||||
assert_equal "Vandalism", b.reason
|
assert_equal "Vandalism", b.reason
|
||||||
assert_equal "markdown", b.reason_format
|
assert_equal "markdown", b.reason_format
|
||||||
assert_equal moderator_user.id, b.creator_id
|
assert_equal moderator_user.id, b.creator_id
|
||||||
|
@ -334,7 +334,7 @@ class UserBlocksControllerTest < ActionController::TestCase
|
||||||
assert_equal "Block updated.", flash[:notice]
|
assert_equal "Block updated.", flash[:notice]
|
||||||
b = UserBlock.find(active_block.id)
|
b = UserBlock.find(active_block.id)
|
||||||
assert_in_delta Time.now, b.updated_at, 1
|
assert_in_delta Time.now, b.updated_at, 1
|
||||||
assert_equal true, b.needs_view
|
assert b.needs_view
|
||||||
assert_equal "Vandalism", b.reason
|
assert_equal "Vandalism", b.reason
|
||||||
|
|
||||||
# We should get an error if no block ID is specified
|
# We should get an error if no block ID is specified
|
||||||
|
|
|
@ -632,9 +632,9 @@ class UsersControllerTest < ActionController::TestCase
|
||||||
|
|
||||||
user.reload
|
user.reload
|
||||||
|
|
||||||
assert_equal true, user.consider_pd
|
assert user.consider_pd
|
||||||
assert_not_nil user.terms_agreed
|
assert_not_nil user.terms_agreed
|
||||||
assert_equal true, user.terms_seen
|
assert user.terms_seen
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_terms_not_seen_with_referer
|
def test_terms_not_seen_with_referer
|
||||||
|
@ -653,9 +653,9 @@ class UsersControllerTest < ActionController::TestCase
|
||||||
|
|
||||||
user.reload
|
user.reload
|
||||||
|
|
||||||
assert_equal true, user.consider_pd
|
assert user.consider_pd
|
||||||
assert_not_nil user.terms_agreed
|
assert_not_nil user.terms_agreed
|
||||||
assert_equal true, user.terms_seen
|
assert user.terms_seen
|
||||||
end
|
end
|
||||||
|
|
||||||
# Check that if you haven't seen the terms, and make a request that requires authentication,
|
# Check that if you haven't seen the terms, and make a request that requires authentication,
|
||||||
|
@ -674,7 +674,7 @@ class UsersControllerTest < ActionController::TestCase
|
||||||
post :go_public, :session => { :user => user }
|
post :go_public, :session => { :user => user }
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_redirected_to :action => :account, :display_name => user.display_name
|
assert_redirected_to :action => :account, :display_name => user.display_name
|
||||||
assert_equal true, User.find(user.id).data_public
|
assert User.find(user.id).data_public
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_lost_password
|
def test_lost_password
|
||||||
|
@ -792,7 +792,7 @@ class UsersControllerTest < ActionController::TestCase
|
||||||
assert_equal user.id, session[:user]
|
assert_equal user.id, session[:user]
|
||||||
user.reload
|
user.reload
|
||||||
assert_equal "active", user.status
|
assert_equal "active", user.status
|
||||||
assert_equal true, user.email_valid
|
assert user.email_valid
|
||||||
assert_equal user, User.authenticate(:username => user.email, :password => "new_password")
|
assert_equal user, User.authenticate(:username => user.email, :password => "new_password")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1304,8 +1304,8 @@ class UsersControllerTest < ActionController::TestCase
|
||||||
assert_equal "", user.description
|
assert_equal "", user.description
|
||||||
assert_nil user.home_lat
|
assert_nil user.home_lat
|
||||||
assert_nil user.home_lon
|
assert_nil user.home_lon
|
||||||
assert_equal false, user.avatar.attached?
|
assert_not user.avatar.attached?
|
||||||
assert_equal false, user.email_valid
|
assert_not user.email_valid
|
||||||
assert_nil user.new_email
|
assert_nil user.new_email
|
||||||
assert_nil user.auth_provider
|
assert_nil user.auth_provider
|
||||||
assert_nil user.auth_uid
|
assert_nil user.auth_uid
|
||||||
|
|
|
@ -16,11 +16,11 @@ class ApplicationHelperTest < ActionView::TestCase
|
||||||
text = "Test #{link} is <b>made</b> into a link"
|
text = "Test #{link} is <b>made</b> into a link"
|
||||||
|
|
||||||
html = linkify(text)
|
html = linkify(text)
|
||||||
assert_equal true, html.html_safe?
|
assert html.html_safe?
|
||||||
assert_dom_equal "Test <a href=\"#{link}\" rel=\"nofollow\">#{link}</a> is <b>made</b> into a link", html
|
assert_dom_equal "Test <a href=\"#{link}\" rel=\"nofollow\">#{link}</a> is <b>made</b> into a link", html
|
||||||
|
|
||||||
html = linkify(text.html_safe)
|
html = linkify(text.html_safe)
|
||||||
assert_equal true, html.html_safe?
|
assert html.html_safe?
|
||||||
assert_dom_equal "Test <a href=\"#{link}\" rel=\"nofollow\">#{link}</a> is <b>made</b> into a link", html
|
assert_dom_equal "Test <a href=\"#{link}\" rel=\"nofollow\">#{link}</a> is <b>made</b> into a link", html
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -28,11 +28,11 @@ class ApplicationHelperTest < ActionView::TestCase
|
||||||
text = "Test #{link} is not <b>made</b> into a link"
|
text = "Test #{link} is not <b>made</b> into a link"
|
||||||
|
|
||||||
html = linkify(text)
|
html = linkify(text)
|
||||||
assert_equal true, html.html_safe?
|
assert html.html_safe?
|
||||||
assert_dom_equal "Test #{link} is not <b>made</b> into a link", html
|
assert_dom_equal "Test #{link} is not <b>made</b> into a link", html
|
||||||
|
|
||||||
html = linkify(text.html_safe)
|
html = linkify(text.html_safe)
|
||||||
assert_equal true, html.html_safe?
|
assert html.html_safe?
|
||||||
assert_dom_equal "Test #{link} is not <b>made</b> into a link", html
|
assert_dom_equal "Test #{link} is not <b>made</b> into a link", html
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -112,24 +112,24 @@ class BrowseHelperTest < ActionView::TestCase
|
||||||
|
|
||||||
tags = icon_tags(node)
|
tags = icon_tags(node)
|
||||||
assert_equal 3, tags.count
|
assert_equal 3, tags.count
|
||||||
assert tags.include?(%w[building yes])
|
assert_includes tags, %w[building yes]
|
||||||
assert tags.include?(%w[tourism museum])
|
assert_includes tags, %w[tourism museum]
|
||||||
assert tags.include?(%w[shop gift])
|
assert_includes tags, %w[shop gift]
|
||||||
|
|
||||||
add_old_tags_selection(node_v2)
|
add_old_tags_selection(node_v2)
|
||||||
add_old_tags_selection(node_v1)
|
add_old_tags_selection(node_v1)
|
||||||
|
|
||||||
tags = icon_tags(node_v2)
|
tags = icon_tags(node_v2)
|
||||||
assert_equal 3, tags.count
|
assert_equal 3, tags.count
|
||||||
assert tags.include?(%w[building yes])
|
assert_includes tags, %w[building yes]
|
||||||
assert tags.include?(%w[tourism museum])
|
assert_includes tags, %w[tourism museum]
|
||||||
assert tags.include?(%w[shop gift])
|
assert_includes tags, %w[shop gift]
|
||||||
|
|
||||||
tags = icon_tags(node_v1)
|
tags = icon_tags(node_v1)
|
||||||
assert_equal 3, tags.count
|
assert_equal 3, tags.count
|
||||||
assert tags.include?(%w[building yes])
|
assert_includes tags, %w[building yes]
|
||||||
assert tags.include?(%w[tourism museum])
|
assert_includes tags, %w[tourism museum]
|
||||||
assert tags.include?(%w[shop gift])
|
assert_includes tags, %w[shop gift]
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_old_tags_selection(old_node)
|
def add_old_tags_selection(old_node)
|
||||||
|
|
|
@ -36,19 +36,19 @@ class I18nTest < ActiveSupport::TestCase
|
||||||
next if subvalue.nil?
|
next if subvalue.nil?
|
||||||
|
|
||||||
subvalue.scan(/%\{(\w+)\}/) do
|
subvalue.scan(/%\{(\w+)\}/) do
|
||||||
assert variables.include?(Regexp.last_match(1)), "#{key}.#{subkey} uses unknown interpolation variable #{Regexp.last_match(1)}"
|
assert_includes variables, Regexp.last_match(1), "#{key}.#{subkey} uses unknown interpolation variable #{Regexp.last_match(1)}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
assert value.is_a?(String), "#{key} is not a string"
|
assert value.is_a?(String), "#{key} is not a string"
|
||||||
|
|
||||||
value.scan(/%\{(\w+)\}/) do
|
value.scan(/%\{(\w+)\}/) do
|
||||||
assert variables.include?(Regexp.last_match(1)), "#{key} uses unknown interpolation variable #{Regexp.last_match(1)}"
|
assert_includes variables, Regexp.last_match(1), "#{key} uses unknown interpolation variable #{Regexp.last_match(1)}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
assert %w[ltr rtl].include?(I18n.t("html.dir", :locale => locale)), "html.dir must be ltr or rtl"
|
assert_includes %w[ltr rtl], I18n.t("html.dir", :locale => locale), "html.dir must be ltr or rtl"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,30 +2,30 @@ require "test_helper"
|
||||||
|
|
||||||
class PasswordHashTest < ActiveSupport::TestCase
|
class PasswordHashTest < ActiveSupport::TestCase
|
||||||
def test_md5_without_salt
|
def test_md5_without_salt
|
||||||
assert_equal true, PasswordHash.check("5f4dcc3b5aa765d61d8327deb882cf99", nil, "password")
|
assert PasswordHash.check("5f4dcc3b5aa765d61d8327deb882cf99", nil, "password")
|
||||||
assert_equal false, PasswordHash.check("5f4dcc3b5aa765d61d8327deb882cf99", nil, "wrong")
|
assert_not PasswordHash.check("5f4dcc3b5aa765d61d8327deb882cf99", nil, "wrong")
|
||||||
assert_equal true, PasswordHash.upgrade?("5f4dcc3b5aa765d61d8327deb882cf99", nil)
|
assert PasswordHash.upgrade?("5f4dcc3b5aa765d61d8327deb882cf99", nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_md5_with_salt
|
def test_md5_with_salt
|
||||||
assert_equal true, PasswordHash.check("67a1e09bb1f83f5007dc119c14d663aa", "salt", "password")
|
assert PasswordHash.check("67a1e09bb1f83f5007dc119c14d663aa", "salt", "password")
|
||||||
assert_equal false, PasswordHash.check("67a1e09bb1f83f5007dc119c14d663aa", "salt", "wrong")
|
assert_not PasswordHash.check("67a1e09bb1f83f5007dc119c14d663aa", "salt", "wrong")
|
||||||
assert_equal false, PasswordHash.check("67a1e09bb1f83f5007dc119c14d663aa", "wrong", "password")
|
assert_not PasswordHash.check("67a1e09bb1f83f5007dc119c14d663aa", "wrong", "password")
|
||||||
assert_equal true, PasswordHash.upgrade?("67a1e09bb1f83f5007dc119c14d663aa", "salt")
|
assert PasswordHash.upgrade?("67a1e09bb1f83f5007dc119c14d663aa", "salt")
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_pbkdf2_1000_32_sha512
|
def test_pbkdf2_1000_32_sha512
|
||||||
assert_equal true, PasswordHash.check("ApT/28+FsTBLa/J8paWfgU84SoRiTfeY8HjKWhgHy08=", "sha512!1000!HR4z+hAvKV2ra1gpbRybtoNzm/CNKe4cf7bPKwdUNrk=", "password")
|
assert PasswordHash.check("ApT/28+FsTBLa/J8paWfgU84SoRiTfeY8HjKWhgHy08=", "sha512!1000!HR4z+hAvKV2ra1gpbRybtoNzm/CNKe4cf7bPKwdUNrk=", "password")
|
||||||
assert_equal false, PasswordHash.check("ApT/28+FsTBLa/J8paWfgU84SoRiTfeY8HjKWhgHy08=", "sha512!1000!HR4z+hAvKV2ra1gpbRybtoNzm/CNKe4cf7bPKwdUNrk=", "wrong")
|
assert_not PasswordHash.check("ApT/28+FsTBLa/J8paWfgU84SoRiTfeY8HjKWhgHy08=", "sha512!1000!HR4z+hAvKV2ra1gpbRybtoNzm/CNKe4cf7bPKwdUNrk=", "wrong")
|
||||||
assert_equal false, PasswordHash.check("ApT/28+FsTBLa/J8paWfgU84SoRiTfeY8HjKWhgHy08=", "sha512!1000!HR4z+hAvKV2ra1gwrongtoNzm/CNKe4cf7bPKwdUNrk=", "password")
|
assert_not PasswordHash.check("ApT/28+FsTBLa/J8paWfgU84SoRiTfeY8HjKWhgHy08=", "sha512!1000!HR4z+hAvKV2ra1gwrongtoNzm/CNKe4cf7bPKwdUNrk=", "password")
|
||||||
assert_equal true, PasswordHash.upgrade?("ApT/28+FsTBLa/J8paWfgU84SoRiTfeY8HjKWhgHy08=", "sha512!1000!HR4z+hAvKV2ra1gpbRybtoNzm/CNKe4cf7bPKwdUNrk=")
|
assert PasswordHash.upgrade?("ApT/28+FsTBLa/J8paWfgU84SoRiTfeY8HjKWhgHy08=", "sha512!1000!HR4z+hAvKV2ra1gpbRybtoNzm/CNKe4cf7bPKwdUNrk=")
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_pbkdf2_10000_32_sha512
|
def test_pbkdf2_10000_32_sha512
|
||||||
assert_equal true, PasswordHash.check("3wYbPiOxk/tU0eeIDjUhdvi8aDP3AbFtwYKKxF1IhGg=", "sha512!10000!OUQLgtM7eD8huvanFT5/WtWaCwdOdrir8QOtFwxhO0A=", "password")
|
assert PasswordHash.check("3wYbPiOxk/tU0eeIDjUhdvi8aDP3AbFtwYKKxF1IhGg=", "sha512!10000!OUQLgtM7eD8huvanFT5/WtWaCwdOdrir8QOtFwxhO0A=", "password")
|
||||||
assert_equal false, PasswordHash.check("3wYbPiOxk/tU0eeIDjUhdvi8aDP3AbFtwYKKxF1IhGg=", "sha512!10000!OUQLgtM7eD8huvanFT5/WtWaCwdOdrir8QOtFwxhO0A=", "wrong")
|
assert_not PasswordHash.check("3wYbPiOxk/tU0eeIDjUhdvi8aDP3AbFtwYKKxF1IhGg=", "sha512!10000!OUQLgtM7eD8huvanFT5/WtWaCwdOdrir8QOtFwxhO0A=", "wrong")
|
||||||
assert_equal false, PasswordHash.check("3wYbPiOxk/tU0eeIDjUhdvi8aDP3AbFtwYKKxF1IhGg=", "sha512!10000!OUQLgtMwronguvanFT5/WtWaCwdOdrir8QOtFwxhO0A=", "password")
|
assert_not PasswordHash.check("3wYbPiOxk/tU0eeIDjUhdvi8aDP3AbFtwYKKxF1IhGg=", "sha512!10000!OUQLgtMwronguvanFT5/WtWaCwdOdrir8QOtFwxhO0A=", "password")
|
||||||
assert_equal false, PasswordHash.upgrade?("3wYbPiOxk/tU0eeIDjUhdvi8aDP3AbFtwYKKxF1IhGg=", "sha512!10000!OUQLgtM7eD8huvanFT5/WtWaCwdOdrir8QOtFwxhO0A=")
|
assert_not PasswordHash.upgrade?("3wYbPiOxk/tU0eeIDjUhdvi8aDP3AbFtwYKKxF1IhGg=", "sha512!10000!OUQLgtM7eD8huvanFT5/WtWaCwdOdrir8QOtFwxhO0A=")
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_default
|
def test_default
|
||||||
|
@ -33,11 +33,11 @@ class PasswordHashTest < ActiveSupport::TestCase
|
||||||
hash2, salt2 = PasswordHash.create("password")
|
hash2, salt2 = PasswordHash.create("password")
|
||||||
assert_not_equal hash1, hash2
|
assert_not_equal hash1, hash2
|
||||||
assert_not_equal salt1, salt2
|
assert_not_equal salt1, salt2
|
||||||
assert_equal true, PasswordHash.check(hash1, salt1, "password")
|
assert PasswordHash.check(hash1, salt1, "password")
|
||||||
assert_equal false, PasswordHash.check(hash1, salt1, "wrong")
|
assert_not PasswordHash.check(hash1, salt1, "wrong")
|
||||||
assert_equal true, PasswordHash.check(hash2, salt2, "password")
|
assert PasswordHash.check(hash2, salt2, "password")
|
||||||
assert_equal false, PasswordHash.check(hash2, salt2, "wrong")
|
assert_not PasswordHash.check(hash2, salt2, "wrong")
|
||||||
assert_equal false, PasswordHash.upgrade?(hash1, salt1)
|
assert_not PasswordHash.upgrade?(hash1, salt1)
|
||||||
assert_equal false, PasswordHash.upgrade?(hash2, salt2)
|
assert_not PasswordHash.upgrade?(hash2, salt2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,16 +2,16 @@ require "test_helper"
|
||||||
|
|
||||||
class UTF8Test < ActiveSupport::TestCase
|
class UTF8Test < ActiveSupport::TestCase
|
||||||
def test_valid?
|
def test_valid?
|
||||||
assert_equal true, UTF8.valid?("test")
|
assert UTF8.valid?("test")
|
||||||
assert_equal true, UTF8.valid?("vergrößern")
|
assert UTF8.valid?("vergrößern")
|
||||||
assert_equal true, UTF8.valid?("ルシステムにも対応します")
|
assert UTF8.valid?("ルシステムにも対応します")
|
||||||
assert_equal true, UTF8.valid?("輕觸搖晃的遊戲")
|
assert UTF8.valid?("輕觸搖晃的遊戲")
|
||||||
|
|
||||||
assert_equal false, UTF8.valid?("\xC0") # always invalid utf8
|
assert_not UTF8.valid?("\xC0") # always invalid utf8
|
||||||
assert_equal false, UTF8.valid?("\xC2\x4a") # 2-byte multibyte identifier, followed by plain ASCII
|
assert_not UTF8.valid?("\xC2\x4a") # 2-byte multibyte identifier, followed by plain ASCII
|
||||||
assert_equal false, UTF8.valid?("\xC2\xC2") # 2-byte multibyte identifier, followed by another one
|
assert_not UTF8.valid?("\xC2\xC2") # 2-byte multibyte identifier, followed by another one
|
||||||
assert_equal false, UTF8.valid?("\x4a\x82") # plain ASCII, followed by multibyte continuation
|
assert_not UTF8.valid?("\x4a\x82") # plain ASCII, followed by multibyte continuation
|
||||||
assert_equal false, UTF8.valid?("\x82\x82") # multibyte continuations without multibyte identifier
|
assert_not UTF8.valid?("\x82\x82") # multibyte continuations without multibyte identifier
|
||||||
assert_equal false, UTF8.valid?("\xe1\x82\x4a") # three-byte identifier, contination and (incorrectly) plain ASCII
|
assert_not UTF8.valid?("\xe1\x82\x4a") # three-byte identifier, contination and (incorrectly) plain ASCII
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,55 +4,55 @@ class NodeTest < ActiveSupport::TestCase
|
||||||
def test_node_too_far_north
|
def test_node_too_far_north
|
||||||
node = build(:node, :latitude => 90.01 * OldNode::SCALE)
|
node = build(:node, :latitude => 90.01 * OldNode::SCALE)
|
||||||
node.validate
|
node.validate
|
||||||
assert node.errors.full_messages.include?("Node is not in the world")
|
assert_includes node.errors.full_messages, "Node is not in the world"
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_node_north_limit
|
def test_node_north_limit
|
||||||
node = build(:node, :latitude => 90 * OldNode::SCALE)
|
node = build(:node, :latitude => 90 * OldNode::SCALE)
|
||||||
node.validate
|
node.validate
|
||||||
assert_equal false, node.errors.full_messages.include?("Node is not in the world")
|
assert_not_includes node.errors.full_messages, "Node is not in the world"
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_node_too_far_south
|
def test_node_too_far_south
|
||||||
node = build(:node, :latitude => -90.01 * OldNode::SCALE)
|
node = build(:node, :latitude => -90.01 * OldNode::SCALE)
|
||||||
node.validate
|
node.validate
|
||||||
assert node.errors.full_messages.include?("Node is not in the world")
|
assert_includes node.errors.full_messages, "Node is not in the world"
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_node_south_limit
|
def test_node_south_limit
|
||||||
node = build(:node, :latitude => -90 * OldNode::SCALE)
|
node = build(:node, :latitude => -90 * OldNode::SCALE)
|
||||||
node.validate
|
node.validate
|
||||||
assert_equal false, node.errors.full_messages.include?("Node is not in the world")
|
assert_not_includes node.errors.full_messages, "Node is not in the world"
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_node_too_far_west
|
def test_node_too_far_west
|
||||||
node = build(:node, :longitude => -180.01 * OldNode::SCALE)
|
node = build(:node, :longitude => -180.01 * OldNode::SCALE)
|
||||||
node.validate
|
node.validate
|
||||||
assert node.errors.full_messages.include?("Node is not in the world")
|
assert_includes node.errors.full_messages, "Node is not in the world"
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_node_west_limit
|
def test_node_west_limit
|
||||||
node = build(:node, :longitude => -180 * OldNode::SCALE)
|
node = build(:node, :longitude => -180 * OldNode::SCALE)
|
||||||
node.validate
|
node.validate
|
||||||
assert_equal false, node.errors.full_messages.include?("Node is not in the world")
|
assert_not_includes node.errors.full_messages, "Node is not in the world"
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_node_too_far_east
|
def test_node_too_far_east
|
||||||
node = build(:node, :longitude => 180.01 * OldNode::SCALE)
|
node = build(:node, :longitude => 180.01 * OldNode::SCALE)
|
||||||
node.validate
|
node.validate
|
||||||
assert node.errors.full_messages.include?("Node is not in the world")
|
assert_includes node.errors.full_messages, "Node is not in the world"
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_node_east_limit
|
def test_node_east_limit
|
||||||
node = build(:node, :longitude => 180 * OldNode::SCALE)
|
node = build(:node, :longitude => 180 * OldNode::SCALE)
|
||||||
node.validate
|
node.validate
|
||||||
assert_equal false, node.errors.full_messages.include?("Node is not in the world")
|
assert_not_includes node.errors.full_messages, "Node is not in the world"
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_totally_wrong
|
def test_totally_wrong
|
||||||
node = build(:node, :latitude => 200 * OldNode::SCALE, :longitude => 200 * OldNode::SCALE)
|
node = build(:node, :latitude => 200 * OldNode::SCALE, :longitude => 200 * OldNode::SCALE)
|
||||||
node.validate
|
node.validate
|
||||||
assert node.errors.full_messages.include?("Node is not in the world")
|
assert_includes node.errors.full_messages, "Node is not in the world"
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_lat_lon
|
def test_lat_lon
|
||||||
|
@ -147,7 +147,7 @@ class NodeTest < ActiveSupport::TestCase
|
||||||
assert_equal node_template.latitude, node.latitude
|
assert_equal node_template.latitude, node.latitude
|
||||||
assert_equal node_template.longitude, node.longitude
|
assert_equal node_template.longitude, node.longitude
|
||||||
assert_equal node_template.changeset_id, node.changeset_id
|
assert_equal node_template.changeset_id, node.changeset_id
|
||||||
assert_equal false, node.visible
|
assert_not node.visible
|
||||||
# assert_equal node_template.tags, node.tags
|
# assert_equal node_template.tags, node.tags
|
||||||
|
|
||||||
assert_equal OldNode.where(:node_id => node_template.id).count, 2
|
assert_equal OldNode.where(:node_id => node_template.id).count, 2
|
||||||
|
@ -156,7 +156,7 @@ class NodeTest < ActiveSupport::TestCase
|
||||||
assert_equal node_template.latitude, old_node.latitude
|
assert_equal node_template.latitude, old_node.latitude
|
||||||
assert_equal node_template.longitude, old_node.longitude
|
assert_equal node_template.longitude, old_node.longitude
|
||||||
assert_equal node_template.changeset_id, old_node.changeset_id
|
assert_equal node_template.changeset_id, old_node.changeset_id
|
||||||
assert_equal false, old_node.visible
|
assert_not old_node.visible
|
||||||
# assert_equal node_template.tags, old_node.tags
|
# assert_equal node_template.tags, old_node.tags
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -37,14 +37,14 @@ class NoteTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_visible?
|
def test_visible?
|
||||||
assert_equal true, create(:note, :status => "open").visible?
|
assert create(:note, :status => "open").visible?
|
||||||
assert_equal true, create(:note, :status => "closed").visible?
|
assert create(:note, :status => "closed").visible?
|
||||||
assert_equal false, create(:note, :status => "hidden").visible?
|
assert_not create(:note, :status => "hidden").visible?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_closed?
|
def test_closed?
|
||||||
assert_equal true, create(:note, :status => "closed", :closed_at => Time.now).closed?
|
assert create(:note, :status => "closed", :closed_at => Time.now).closed?
|
||||||
assert_equal false, create(:note, :status => "open", :closed_at => nil).closed?
|
assert_not create(:note, :status => "open", :closed_at => nil).closed?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_author
|
def test_author
|
||||||
|
|
|
@ -12,7 +12,7 @@ class OauthNonceTest < ActiveSupport::TestCase
|
||||||
assert_not_equal false, nonce1, "First nonce should be unique. Check your test database is empty."
|
assert_not_equal false, nonce1, "First nonce should be unique. Check your test database is empty."
|
||||||
|
|
||||||
nonce2 = OauthNonce.remember(string, timestamp)
|
nonce2 = OauthNonce.remember(string, timestamp)
|
||||||
assert_equal false, nonce2, "Shouldn't be able to remember the same nonce twice."
|
assert_not nonce2, "Shouldn't be able to remember the same nonce twice."
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -21,7 +21,7 @@ class OauthNonceTest < ActiveSupport::TestCase
|
||||||
string = "0123456789ABCDEF"
|
string = "0123456789ABCDEF"
|
||||||
|
|
||||||
nonce1 = OauthNonce.remember(string, Time.now.to_i - 86430)
|
nonce1 = OauthNonce.remember(string, Time.now.to_i - 86430)
|
||||||
assert_equal false, nonce1, "Nonces over a day in the past should be rejected"
|
assert_not nonce1, "Nonces over a day in the past should be rejected"
|
||||||
|
|
||||||
nonce2 = OauthNonce.remember(string, Time.now.to_i - 86370)
|
nonce2 = OauthNonce.remember(string, Time.now.to_i - 86370)
|
||||||
assert_not_equal false, nonce2, "Nonces under a day in the past should be rejected"
|
assert_not_equal false, nonce2, "Nonces under a day in the past should be rejected"
|
||||||
|
|
|
@ -5,19 +5,19 @@ class OauthTokenTest < ActiveSupport::TestCase
|
||||||
# check that after calling invalidate! on a token, it is invalid.
|
# check that after calling invalidate! on a token, it is invalid.
|
||||||
def test_token_invalidation
|
def test_token_invalidation
|
||||||
tok = OauthToken.new
|
tok = OauthToken.new
|
||||||
assert_equal false, tok.invalidated?, "Token should be created valid."
|
assert_not tok.invalidated?, "Token should be created valid."
|
||||||
tok.invalidate!
|
tok.invalidate!
|
||||||
assert_equal true, tok.invalidated?, "Token should now be invalid."
|
assert tok.invalidated?, "Token should now be invalid."
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# check that an authorized token is authorised and can be invalidated
|
# check that an authorized token is authorised and can be invalidated
|
||||||
def test_token_authorisation
|
def test_token_authorisation
|
||||||
tok = RequestToken.create(:client_application => create(:client_application))
|
tok = RequestToken.create(:client_application => create(:client_application))
|
||||||
assert_equal false, tok.authorized?, "Token should be created unauthorised."
|
assert_not tok.authorized?, "Token should be created unauthorised."
|
||||||
tok.authorize!(create(:user))
|
tok.authorize!(create(:user))
|
||||||
assert_equal true, tok.authorized?, "Token should now be authorised."
|
assert tok.authorized?, "Token should now be authorised."
|
||||||
tok.invalidate!
|
tok.invalidate!
|
||||||
assert_equal false, tok.authorized?, "Token should now be invalid."
|
assert_not tok.authorized?, "Token should now be invalid."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,55 +4,55 @@ class OldNodeTest < ActiveSupport::TestCase
|
||||||
def test_node_too_far_north
|
def test_node_too_far_north
|
||||||
node = build(:old_node, :latitude => 90.01 * OldNode::SCALE)
|
node = build(:old_node, :latitude => 90.01 * OldNode::SCALE)
|
||||||
node.validate
|
node.validate
|
||||||
assert node.errors.full_messages.include?("Node is not in the world")
|
assert_includes node.errors.full_messages, "Node is not in the world"
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_node_north_limit
|
def test_node_north_limit
|
||||||
node = build(:old_node, :latitude => 90 * OldNode::SCALE)
|
node = build(:old_node, :latitude => 90 * OldNode::SCALE)
|
||||||
node.validate
|
node.validate
|
||||||
assert_equal false, node.errors.full_messages.include?("Node is not in the world")
|
assert_not_includes node.errors.full_messages, "Node is not in the world"
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_node_too_far_south
|
def test_node_too_far_south
|
||||||
node = build(:old_node, :latitude => -90.01 * OldNode::SCALE)
|
node = build(:old_node, :latitude => -90.01 * OldNode::SCALE)
|
||||||
node.validate
|
node.validate
|
||||||
assert node.errors.full_messages.include?("Node is not in the world")
|
assert_includes node.errors.full_messages, "Node is not in the world"
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_node_south_limit
|
def test_node_south_limit
|
||||||
node = build(:old_node, :latitude => -90 * OldNode::SCALE)
|
node = build(:old_node, :latitude => -90 * OldNode::SCALE)
|
||||||
node.validate
|
node.validate
|
||||||
assert_equal false, node.errors.full_messages.include?("Node is not in the world")
|
assert_not_includes node.errors.full_messages, "Node is not in the world"
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_node_too_far_west
|
def test_node_too_far_west
|
||||||
node = build(:old_node, :longitude => -180.01 * OldNode::SCALE)
|
node = build(:old_node, :longitude => -180.01 * OldNode::SCALE)
|
||||||
node.validate
|
node.validate
|
||||||
assert node.errors.full_messages.include?("Node is not in the world")
|
assert_includes node.errors.full_messages, "Node is not in the world"
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_node_west_limit
|
def test_node_west_limit
|
||||||
node = build(:old_node, :longitude => -180 * OldNode::SCALE)
|
node = build(:old_node, :longitude => -180 * OldNode::SCALE)
|
||||||
node.validate
|
node.validate
|
||||||
assert_equal false, node.errors.full_messages.include?("Node is not in the world")
|
assert_not_includes node.errors.full_messages, "Node is not in the world"
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_node_too_far_east
|
def test_node_too_far_east
|
||||||
node = build(:old_node, :longitude => 180.01 * OldNode::SCALE)
|
node = build(:old_node, :longitude => 180.01 * OldNode::SCALE)
|
||||||
node.validate
|
node.validate
|
||||||
assert node.errors.full_messages.include?("Node is not in the world")
|
assert_includes node.errors.full_messages, "Node is not in the world"
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_node_east_limit
|
def test_node_east_limit
|
||||||
node = build(:old_node, :longitude => 180 * OldNode::SCALE)
|
node = build(:old_node, :longitude => 180 * OldNode::SCALE)
|
||||||
node.validate
|
node.validate
|
||||||
assert_equal false, node.errors.full_messages.include?("Node is not in the world")
|
assert_not_includes node.errors.full_messages, "Node is not in the world"
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_totally_wrong
|
def test_totally_wrong
|
||||||
node = build(:old_node, :latitude => 200 * OldNode::SCALE, :longitude => 200 * OldNode::SCALE)
|
node = build(:old_node, :latitude => 200 * OldNode::SCALE, :longitude => 200 * OldNode::SCALE)
|
||||||
node.validate
|
node.validate
|
||||||
assert node.errors.full_messages.include?("Node is not in the world")
|
assert_includes node.errors.full_messages, "Node is not in the world"
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_lat_lon
|
def test_lat_lon
|
||||||
|
|
|
@ -4,7 +4,7 @@ class RedactionTest < ActiveSupport::TestCase
|
||||||
def test_cannot_redact_current
|
def test_cannot_redact_current
|
||||||
n = create(:node)
|
n = create(:node)
|
||||||
r = create(:redaction)
|
r = create(:redaction)
|
||||||
assert_equal(false, n.redacted?, "Expected node to not be redacted already.")
|
assert_not(n.redacted?, "Expected node to not be redacted already.")
|
||||||
assert_raise(OSM::APICannotRedactError) do
|
assert_raise(OSM::APICannotRedactError) do
|
||||||
n.redact!(r)
|
n.redact!(r)
|
||||||
end
|
end
|
||||||
|
@ -14,7 +14,7 @@ class RedactionTest < ActiveSupport::TestCase
|
||||||
node = create(:node, :with_history)
|
node = create(:node, :with_history)
|
||||||
node_v1 = node.old_nodes.find_by(:version => 1)
|
node_v1 = node.old_nodes.find_by(:version => 1)
|
||||||
r = create(:redaction)
|
r = create(:redaction)
|
||||||
assert_equal(false, node_v1.redacted?, "Expected node to not be redacted already.")
|
assert_not(node_v1.redacted?, "Expected node to not be redacted already.")
|
||||||
assert_raise(OSM::APICannotRedactError) do
|
assert_raise(OSM::APICannotRedactError) do
|
||||||
node_v1.redact!(r)
|
node_v1.redact!(r)
|
||||||
end
|
end
|
||||||
|
@ -26,11 +26,11 @@ class RedactionTest < ActiveSupport::TestCase
|
||||||
node_v2 = node.old_nodes.find_by(:version => 2)
|
node_v2 = node.old_nodes.find_by(:version => 2)
|
||||||
r = create(:redaction)
|
r = create(:redaction)
|
||||||
|
|
||||||
assert_equal(false, node_v1.redacted?, "Expected node to not be redacted already.")
|
assert_not(node_v1.redacted?, "Expected node to not be redacted already.")
|
||||||
assert_nothing_raised do
|
assert_nothing_raised do
|
||||||
node_v1.redact!(r)
|
node_v1.redact!(r)
|
||||||
end
|
end
|
||||||
assert_equal(true, node_v1.redacted?, "Expected node version 1 to be redacted after redact! call.")
|
assert(node_v1.redacted?, "Expected node version 1 to be redacted after redact! call.")
|
||||||
assert_equal(false, node_v2.redacted?, "Expected node version 2 to not be redacted after redact! call.")
|
assert_not(node_v2.redacted?, "Expected node version 2 to not be redacted after redact! call.")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,9 +2,9 @@ require "test_helper"
|
||||||
|
|
||||||
class RequestTokenTest < ActiveSupport::TestCase
|
class RequestTokenTest < ActiveSupport::TestCase
|
||||||
def test_oob
|
def test_oob
|
||||||
assert_equal true, RequestToken.new.oob?
|
assert RequestToken.new.oob?
|
||||||
assert_equal true, RequestToken.new(:callback_url => "oob").oob?
|
assert RequestToken.new(:callback_url => "oob").oob?
|
||||||
assert_equal true, RequestToken.new(:callback_url => "OOB").oob?
|
assert RequestToken.new(:callback_url => "OOB").oob?
|
||||||
assert_equal false, RequestToken.new(:callback_url => "http://test.host/").oob?
|
assert_not RequestToken.new(:callback_url => "http://test.host/").oob?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -108,27 +108,27 @@ class TraceTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_public?
|
def test_public?
|
||||||
assert_equal true, build(:trace, :visibility => "public").public?
|
assert build(:trace, :visibility => "public").public?
|
||||||
assert_equal false, build(:trace, :visibility => "private").public?
|
assert_not build(:trace, :visibility => "private").public?
|
||||||
assert_equal false, build(:trace, :visibility => "trackable").public?
|
assert_not build(:trace, :visibility => "trackable").public?
|
||||||
assert_equal true, build(:trace, :visibility => "identifiable").public?
|
assert build(:trace, :visibility => "identifiable").public?
|
||||||
assert_equal true, build(:trace, :deleted, :visibility => "public").public?
|
assert build(:trace, :deleted, :visibility => "public").public?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_trackable?
|
def test_trackable?
|
||||||
assert_equal false, build(:trace, :visibility => "public").trackable?
|
assert_not build(:trace, :visibility => "public").trackable?
|
||||||
assert_equal false, build(:trace, :visibility => "private").trackable?
|
assert_not build(:trace, :visibility => "private").trackable?
|
||||||
assert_equal true, build(:trace, :visibility => "trackable").trackable?
|
assert build(:trace, :visibility => "trackable").trackable?
|
||||||
assert_equal true, build(:trace, :visibility => "identifiable").trackable?
|
assert build(:trace, :visibility => "identifiable").trackable?
|
||||||
assert_equal false, build(:trace, :deleted, :visibility => "public").trackable?
|
assert_not build(:trace, :deleted, :visibility => "public").trackable?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_identifiable?
|
def test_identifiable?
|
||||||
assert_equal false, build(:trace, :visibility => "public").identifiable?
|
assert_not build(:trace, :visibility => "public").identifiable?
|
||||||
assert_equal false, build(:trace, :visibility => "private").identifiable?
|
assert_not build(:trace, :visibility => "private").identifiable?
|
||||||
assert_equal false, build(:trace, :visibility => "trackable").identifiable?
|
assert_not build(:trace, :visibility => "trackable").identifiable?
|
||||||
assert_equal true, build(:trace, :visibility => "identifiable").identifiable?
|
assert build(:trace, :visibility => "identifiable").identifiable?
|
||||||
assert_equal false, build(:trace, :deleted, :visibility => "public").identifiable?
|
assert_not build(:trace, :deleted, :visibility => "public").identifiable?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_mime_type
|
def test_mime_type
|
||||||
|
@ -218,22 +218,22 @@ class TraceTest < ActiveSupport::TestCase
|
||||||
trace = create(:trace, :fixture => "a")
|
trace = create(:trace, :fixture => "a")
|
||||||
icon_path = File.join(Settings.gpx_image_dir, "#{trace.id}_icon.gif")
|
icon_path = File.join(Settings.gpx_image_dir, "#{trace.id}_icon.gif")
|
||||||
FileUtils.rm(icon_path)
|
FileUtils.rm(icon_path)
|
||||||
assert_equal false, File.exist?(icon_path)
|
assert_not File.exist?(icon_path)
|
||||||
|
|
||||||
trace.import
|
trace.import
|
||||||
|
|
||||||
assert_equal true, File.exist?(icon_path)
|
assert File.exist?(icon_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_import_creates_large_picture
|
def test_import_creates_large_picture
|
||||||
trace = create(:trace, :fixture => "a")
|
trace = create(:trace, :fixture => "a")
|
||||||
large_picture_path = File.join(Settings.gpx_image_dir, "#{trace.id}.gif")
|
large_picture_path = File.join(Settings.gpx_image_dir, "#{trace.id}.gif")
|
||||||
FileUtils.rm(large_picture_path)
|
FileUtils.rm(large_picture_path)
|
||||||
assert_equal false, File.exist?(large_picture_path)
|
assert_not File.exist?(large_picture_path)
|
||||||
|
|
||||||
trace.import
|
trace.import
|
||||||
|
|
||||||
assert_equal true, File.exist?(large_picture_path)
|
assert File.exist?(large_picture_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_import_handles_bz2
|
def test_import_handles_bz2
|
||||||
|
|
|
@ -36,7 +36,7 @@ class UserPreferenceTest < ActiveSupport::TestCase
|
||||||
up.user = create(:user)
|
up.user = create(:user)
|
||||||
up.k = key * i
|
up.k = key * i
|
||||||
up.v = val * i
|
up.v = val * i
|
||||||
assert_equal false, up.valid?
|
assert_not up.valid?
|
||||||
assert_raise(ActiveRecord::RecordInvalid) { up.save! }
|
assert_raise(ActiveRecord::RecordInvalid) { up.save! }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -26,7 +26,7 @@ class UserTest < ActiveSupport::TestCase
|
||||||
:description => "desc"
|
:description => "desc"
|
||||||
)
|
)
|
||||||
assert_not new_user.save
|
assert_not new_user.save
|
||||||
assert new_user.errors[:email].include?("has already been taken")
|
assert_includes new_user.errors[:email], "has already been taken"
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_unique_display_name
|
def test_unique_display_name
|
||||||
|
@ -40,7 +40,7 @@ class UserTest < ActiveSupport::TestCase
|
||||||
:description => "desc"
|
:description => "desc"
|
||||||
)
|
)
|
||||||
assert_not new_user.save
|
assert_not new_user.save
|
||||||
assert new_user.errors[:display_name].include?("has already been taken")
|
assert_includes new_user.errors[:display_name], "has already been taken"
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_email_valid
|
def test_email_valid
|
||||||
|
@ -224,36 +224,36 @@ class UserTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_visible?
|
def test_visible?
|
||||||
assert_equal true, build(:user, :pending).visible?
|
assert build(:user, :pending).visible?
|
||||||
assert_equal true, build(:user, :active).visible?
|
assert build(:user, :active).visible?
|
||||||
assert_equal true, build(:user, :confirmed).visible?
|
assert build(:user, :confirmed).visible?
|
||||||
assert_equal false, build(:user, :suspended).visible?
|
assert_not build(:user, :suspended).visible?
|
||||||
assert_equal false, build(:user, :deleted).visible?
|
assert_not build(:user, :deleted).visible?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_active?
|
def test_active?
|
||||||
assert_equal false, build(:user, :pending).active?
|
assert_not build(:user, :pending).active?
|
||||||
assert_equal true, build(:user, :active).active?
|
assert build(:user, :active).active?
|
||||||
assert_equal true, build(:user, :confirmed).active?
|
assert build(:user, :confirmed).active?
|
||||||
assert_equal false, build(:user, :suspended).active?
|
assert_not build(:user, :suspended).active?
|
||||||
assert_equal false, build(:user, :deleted).active?
|
assert_not build(:user, :deleted).active?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_moderator?
|
def test_moderator?
|
||||||
assert_equal false, create(:user).moderator?
|
assert_not create(:user).moderator?
|
||||||
assert_equal true, create(:moderator_user).moderator?
|
assert create(:moderator_user).moderator?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_administrator?
|
def test_administrator?
|
||||||
assert_equal false, create(:user).administrator?
|
assert_not create(:user).administrator?
|
||||||
assert_equal true, create(:administrator_user).administrator?
|
assert create(:administrator_user).administrator?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_has_role?
|
def test_has_role?
|
||||||
assert_equal false, create(:user).has_role?("administrator")
|
assert_not create(:user).has_role?("administrator")
|
||||||
assert_equal false, create(:user).has_role?("moderator")
|
assert_not create(:user).has_role?("moderator")
|
||||||
assert_equal true, create(:administrator_user).has_role?("administrator")
|
assert create(:administrator_user).has_role?("administrator")
|
||||||
assert_equal true, create(:moderator_user).has_role?("moderator")
|
assert create(:moderator_user).has_role?("moderator")
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_delete
|
def test_delete
|
||||||
|
@ -263,10 +263,10 @@ class UserTest < ActiveSupport::TestCase
|
||||||
assert user.description.blank?
|
assert user.description.blank?
|
||||||
assert_nil user.home_lat
|
assert_nil user.home_lat
|
||||||
assert_nil user.home_lon
|
assert_nil user.home_lon
|
||||||
assert_equal false, user.avatar.attached?
|
assert_not user.avatar.attached?
|
||||||
assert_equal "deleted", user.status
|
assert_equal "deleted", user.status
|
||||||
assert_equal false, user.visible?
|
assert_not user.visible?
|
||||||
assert_equal false, user.active?
|
assert_not user.active?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_to_xml
|
def test_to_xml
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue