Yet more tests...
This commit is contained in:
parent
51c5be98f7
commit
35be112092
6 changed files with 209 additions and 1 deletions
|
@ -74,6 +74,16 @@ class BrowseControllerTest < ActionController::TestCase
|
|||
browse_check "changeset", changesets(:public_user_first_change).id, "browse/changeset"
|
||||
end
|
||||
|
||||
def test_read_changeset_hidden_comments
|
||||
browse_check "changeset", changesets(:normal_user_closed_change).id, "browse/changeset"
|
||||
assert_select "div.changeset-comments ul li", :count => 3
|
||||
|
||||
session[:user] = users(:moderator_user).id
|
||||
|
||||
browse_check "changeset", changesets(:normal_user_closed_change).id, "browse/changeset"
|
||||
assert_select "div.changeset-comments ul li", :count => 4
|
||||
end
|
||||
|
||||
def test_read_note
|
||||
browse_check "note", notes(:open_note).id, "browse/note"
|
||||
end
|
||||
|
|
|
@ -278,6 +278,61 @@ class OldNodeControllerTest < ActionController::TestCase
|
|||
assert_select "osm node[id='#{node.node_id}'][version='#{node.version}']", 0, "redacted node #{node.node_id} version #{node.version} shouldn't be present in the history."
|
||||
end
|
||||
|
||||
##
|
||||
# test the unredaction of an old version of a node, while not being
|
||||
# authorised.
|
||||
def test_unredact_node_unauthorised
|
||||
node = nodes(:redacted_node_redacted_version)
|
||||
|
||||
post :redact, :id => node.node_id, :version => node.version
|
||||
assert_response :unauthorized, "should need to be authenticated to unredact."
|
||||
end
|
||||
|
||||
##
|
||||
# test the unredaction of an old version of a node, while being
|
||||
# authorised as a normal user.
|
||||
def test_unredact_node_normal_user
|
||||
node = nodes(:redacted_node_redacted_version)
|
||||
basic_authorization(users(:public_user).email, "test")
|
||||
|
||||
post :redact, :id => node.node_id, :version => node.version
|
||||
assert_response :forbidden, "should need to be moderator to unredact."
|
||||
end
|
||||
|
||||
##
|
||||
# test the unredaction of an old version of a node, while being
|
||||
# authorised as a moderator.
|
||||
def test_unredact_node_moderator
|
||||
node = nodes(:redacted_node_redacted_version)
|
||||
basic_authorization(users(:moderator_user).email, "test")
|
||||
|
||||
post :redact, :id => node.node_id, :version => node.version
|
||||
assert_response :success, "should be OK to redact old version as moderator."
|
||||
|
||||
# check moderator can now see the redacted data, when not
|
||||
# passing the aspecial flag
|
||||
get :version, :id => node.node_id, :version => node.version
|
||||
assert_response :success, "After unredaction, node should not be gone for moderator."
|
||||
|
||||
# and when accessed via history
|
||||
get :history, :id => node.node_id
|
||||
assert_response :success, "Unredaction shouldn't have stopped history working."
|
||||
assert_select "osm node[id='#{node.node_id}'][version='#{node.version}']", 1, "node #{node.node_id} version #{node.version} should now be present in the history for moderators without passing flag."
|
||||
|
||||
basic_authorization(users(:normal_user).email, "test")
|
||||
|
||||
# check normal user can now see the redacted data
|
||||
get :version, :id => node.node_id, :version => node.version
|
||||
assert_response :success, "After unredaction, node should not be gone for moderator."
|
||||
|
||||
# and when accessed via history
|
||||
get :history, :id => node.node_id
|
||||
assert_response :success, "Unredaction shouldn't have stopped history working."
|
||||
assert_select "osm node[id='#{node.node_id}'][version='#{node.version}']", 1, "node #{node.node_id} version #{node.version} should now be present in the history for moderators without passing flag."
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def do_redact_node(node, redaction)
|
||||
get :version, :id => node.node_id, :version => node.version
|
||||
assert_response :success, "should be able to get version #{node.version} of node #{node.node_id}."
|
||||
|
|
|
@ -145,6 +145,61 @@ class OldRelationControllerTest < ActionController::TestCase
|
|||
assert_select "osm relation[id='#{relation.relation_id}'][version='#{relation.version}']", 0, "redacted relation #{relation.relation_id} version #{relation.version} shouldn't be present in the history."
|
||||
end
|
||||
|
||||
##
|
||||
# test the unredaction of an old version of a relation, while not being
|
||||
# authorised.
|
||||
def test_unredact_relation_unauthorised
|
||||
relation = relations(:relation_with_redacted_versions_v3)
|
||||
|
||||
post :redact, :id => relation.relation_id, :version => relation.version
|
||||
assert_response :unauthorized, "should need to be authenticated to unredact."
|
||||
end
|
||||
|
||||
##
|
||||
# test the unredaction of an old version of a relation, while being
|
||||
# authorised as a normal user.
|
||||
def test_unredact_relation_normal_user
|
||||
relation = relations(:relation_with_redacted_versions_v3)
|
||||
basic_authorization(users(:public_user).email, "test")
|
||||
|
||||
post :redact, :id => relation.relation_id, :version => relation.version
|
||||
assert_response :forbidden, "should need to be moderator to unredact."
|
||||
end
|
||||
|
||||
##
|
||||
# test the unredaction of an old version of a relation, while being
|
||||
# authorised as a moderator.
|
||||
def test_unredact_relation_moderator
|
||||
relation = relations(:relation_with_redacted_versions_v3)
|
||||
basic_authorization(users(:moderator_user).email, "test")
|
||||
|
||||
post :redact, :id => relation.relation_id, :version => relation.version
|
||||
assert_response :success, "should be OK to unredact old version as moderator."
|
||||
|
||||
# check moderator can still see the redacted data, without passing
|
||||
# the appropriate flag
|
||||
get :version, :id => relation.relation_id, :version => relation.version
|
||||
assert_response :success, "After redaction, node should not be gone for moderator, when flag passed."
|
||||
|
||||
# and when accessed via history
|
||||
get :history, :id => relation.relation_id
|
||||
assert_response :success, "Redaction shouldn't have stopped history working."
|
||||
assert_select "osm relation[id='#{relation.relation_id}'][version='#{relation.version}']", 1, "relation #{relation.relation_id} version #{relation.version} should still be present in the history for moderators when passing flag."
|
||||
|
||||
basic_authorization(users(:normal_user).email, "test")
|
||||
|
||||
# check normal user can now see the redacted data
|
||||
get :version, :id => relation.relation_id, :version => relation.version
|
||||
assert_response :success, "After redaction, node should not be gone for moderator, when flag passed."
|
||||
|
||||
# and when accessed via history
|
||||
get :history, :id => relation.relation_id
|
||||
assert_response :success, "Redaction shouldn't have stopped history working."
|
||||
assert_select "osm relation[id='#{relation.relation_id}'][version='#{relation.version}']", 1, "relation #{relation.relation_id} version #{relation.version} should still be present in the history for moderators when passing flag."
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
##
|
||||
# check that the current version of a relation is equivalent to the
|
||||
# version which we're getting from the versions call.
|
||||
|
|
|
@ -171,6 +171,61 @@ class OldWayControllerTest < ActionController::TestCase
|
|||
assert_select "osm way[id='#{way.way_id}'][version='#{way.version}']", 0, "redacted way #{way.way_id} version #{way.version} shouldn't be present in the history."
|
||||
end
|
||||
|
||||
##
|
||||
# test the unredaction of an old version of a way, while not being
|
||||
# authorised.
|
||||
def test_unredact_way_unauthorised
|
||||
way = ways(:way_with_redacted_versions_v3)
|
||||
|
||||
post :redact, :id => way.way_id, :version => way.version
|
||||
assert_response :unauthorized, "should need to be authenticated to unredact."
|
||||
end
|
||||
|
||||
##
|
||||
# test the unredaction of an old version of a way, while being
|
||||
# authorised as a normal user.
|
||||
def test_unredact_way_normal_user
|
||||
way = ways(:way_with_redacted_versions_v3)
|
||||
basic_authorization(users(:public_user).email, "test")
|
||||
|
||||
post :redact, :id => way.way_id, :version => way.version
|
||||
assert_response :forbidden, "should need to be moderator to unredact."
|
||||
end
|
||||
|
||||
##
|
||||
# test the unredaction of an old version of a way, while being
|
||||
# authorised as a moderator.
|
||||
def test_unredact_way_moderator
|
||||
way = ways(:way_with_redacted_versions_v3)
|
||||
basic_authorization(users(:moderator_user).email, "test")
|
||||
|
||||
post :redact, :id => way.way_id, :version => way.version
|
||||
assert_response :success, "should be OK to unredact old version as moderator."
|
||||
|
||||
# check moderator can still see the redacted data, without passing
|
||||
# the appropriate flag
|
||||
get :version, :id => way.way_id, :version => way.version
|
||||
assert_response :success, "After redaction, node should not be gone for moderator, when flag passed."
|
||||
|
||||
# and when accessed via history
|
||||
get :history, :id => way.way_id
|
||||
assert_response :success, "Redaction shouldn't have stopped history working."
|
||||
assert_select "osm way[id='#{way.way_id}'][version='#{way.version}']", 1, "way #{way.way_id} version #{way.version} should still be present in the history for moderators when passing flag."
|
||||
|
||||
basic_authorization(users(:normal_user).email, "test")
|
||||
|
||||
# check normal user can now see the redacted data
|
||||
get :version, :id => way.way_id, :version => way.version
|
||||
assert_response :success, "After redaction, node should not be gone for moderator, when flag passed."
|
||||
|
||||
# and when accessed via history
|
||||
get :history, :id => way.way_id
|
||||
assert_response :success, "Redaction shouldn't have stopped history working."
|
||||
assert_select "osm way[id='#{way.way_id}'][version='#{way.version}']", 1, "way #{way.way_id} version #{way.version} should still be present in the history for moderators when passing flag."
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
##
|
||||
# check that the current version of a way is equivalent to the
|
||||
# version which we're getting from the versions call.
|
||||
|
|
|
@ -105,10 +105,15 @@ class RelationControllerTest < ActionController::TestCase
|
|||
|
||||
def test_full
|
||||
# check the "full" mode
|
||||
get :full, :id => 999999
|
||||
assert_response :not_found
|
||||
|
||||
get :full, :id => current_relations(:invisible_relation).id
|
||||
assert_response :gone
|
||||
|
||||
get :full, :id => current_relations(:visible_relation).id
|
||||
assert_response :success
|
||||
# FIXME: check whether this contains the stuff we want!
|
||||
print @response.body if $VERBOSE
|
||||
end
|
||||
|
||||
##
|
||||
|
@ -382,6 +387,19 @@ class RelationControllerTest < ActionController::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
def test_update_wrong_id
|
||||
basic_authorization users(:public_user).email, "test"
|
||||
rel_id = current_relations(:multi_tag_relation).id
|
||||
cs_id = changesets(:public_user_first_change).id
|
||||
|
||||
with_relation(rel_id) do |rel|
|
||||
update_changeset(rel, cs_id)
|
||||
content rel
|
||||
put :update, :id => current_relations(:visible_relation).id
|
||||
assert_response :bad_request
|
||||
end
|
||||
end
|
||||
|
||||
# -------------------------------------
|
||||
# Test creating some invalid relations.
|
||||
# -------------------------------------
|
||||
|
|
|
@ -91,6 +91,21 @@ class SiteControllerTest < ActionController::TestCase
|
|||
|
||||
# Test the index page redirects
|
||||
def test_index_redirect
|
||||
get :index, :node => 123
|
||||
assert_redirected_to :controller => :browse, :action => :node, :id => 123
|
||||
|
||||
get :index, :way => 123
|
||||
assert_redirected_to :controller => :browse, :action => :way, :id => 123
|
||||
|
||||
get :index, :relation => 123
|
||||
assert_redirected_to :controller => :browse, :action => :relation, :id => 123
|
||||
|
||||
get :index, :note => 123
|
||||
assert_redirected_to :controller => :browse, :action => :note, :id => 123
|
||||
|
||||
get :index, :query => "test"
|
||||
assert_redirected_to :controller => :geocoder, :action => :search, :query => "test"
|
||||
|
||||
get :index, :lat => 4, :lon => 5
|
||||
assert_redirected_to :controller => :site, :action => :index, :anchor => "map=5/4/5"
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue