Merge branch 'master' into notes
Conflicts: Gemfile.lock app/views/browse/_map.html.erb app/views/site/index.html.erb
This commit is contained in:
commit
0037502426
190 changed files with 3488 additions and 2999 deletions
|
@ -85,7 +85,7 @@ class MessageControllerTest < ActionController::TestCase
|
|||
m = Message.find(3)
|
||||
assert_equal users(:normal_user).id, m.from_user_id
|
||||
assert_equal users(:public_user).id, m.to_user_id
|
||||
assert_in_delta Time.now, m.sent_on, 1
|
||||
assert_in_delta Time.now, m.sent_on, 2
|
||||
assert_equal "Test Message", m.title
|
||||
assert_equal "Test message body", m.body
|
||||
assert_equal "markdown", m.body_format
|
||||
|
|
|
@ -751,6 +751,31 @@ OSM
|
|||
end
|
||||
end
|
||||
|
||||
##
|
||||
# remove all the members from a relation. the result is pretty useless, but
|
||||
# still technically valid.
|
||||
def test_remove_all_members
|
||||
check_changeset_modify(BoundingBox.new(3,3,5,5)) do |changeset_id|
|
||||
relation_xml = current_relations(:visible_relation).to_xml
|
||||
relation_xml.
|
||||
find("//osm/relation/member").
|
||||
each {|m| m.remove!}
|
||||
|
||||
# update changeset ID to point to new changeset
|
||||
update_changeset(relation_xml, changeset_id)
|
||||
|
||||
# upload the change
|
||||
content relation_xml
|
||||
put :update, :id => current_relations(:visible_relation).id
|
||||
assert_response :success, "can't update relation for remove all members test"
|
||||
checkrelation = Relation.find(current_relations(:visible_relation).id)
|
||||
assert_not_nil(checkrelation,
|
||||
"uploaded relation not found in database after upload")
|
||||
assert_equal(0, checkrelation.members.length,
|
||||
"relation contains members but they should have all been deleted")
|
||||
end
|
||||
end
|
||||
|
||||
# ============================================================
|
||||
# utility functions
|
||||
# ============================================================
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
|
||||
class SiteControllerTest < ActionController::TestCase
|
||||
fixtures :users
|
||||
api_fixtures
|
||||
|
||||
##
|
||||
# test all routes which lead to this controller
|
||||
|
@ -86,7 +86,6 @@ class SiteControllerTest < ActionController::TestCase
|
|||
|
||||
def assert_site_partials(count = 1)
|
||||
assert_template :partial => '_search', :count => count
|
||||
assert_template :partial => '_key', :count => count
|
||||
assert_template :partial => '_sidebar', :count => count
|
||||
end
|
||||
|
||||
|
@ -118,5 +117,38 @@ class SiteControllerTest < ActionController::TestCase
|
|||
get(:edit, nil, { 'user' => user.id })
|
||||
assert_response :success
|
||||
assert_template "index"
|
||||
end
|
||||
end
|
||||
|
||||
def test_edit_with_node
|
||||
@request.cookies["_osm_username"] = users(:public_user).display_name
|
||||
|
||||
user = users(:public_user)
|
||||
node = current_nodes(:visible_node)
|
||||
|
||||
get :edit, { :node => node.id }, { 'user' => user.id }
|
||||
assert_equal 1.0, assigns(:lat)
|
||||
assert_equal 1.0, assigns(:lon)
|
||||
end
|
||||
|
||||
def test_edit_with_way
|
||||
@request.cookies["_osm_username"] = users(:public_user).display_name
|
||||
|
||||
user = users(:public_user)
|
||||
way = current_ways(:visible_way)
|
||||
|
||||
get :edit, { :way => way.id }, { 'user' => user.id }
|
||||
assert_equal 3.0, assigns(:lat)
|
||||
assert_equal 3.0, assigns(:lon)
|
||||
end
|
||||
|
||||
def test_edit_with_gpx
|
||||
@request.cookies["_osm_username"] = users(:public_user).display_name
|
||||
|
||||
user = users(:public_user)
|
||||
gpx = gpx_files(:public_trace_file)
|
||||
|
||||
get :edit, { :gpx => gpx.id }, { 'user' => user.id }
|
||||
assert_equal 1.0, assigns(:lat)
|
||||
assert_equal 1.0, assigns(:lon)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,6 +6,10 @@ class UserControllerTest < ActionController::TestCase
|
|||
##
|
||||
# test all routes which lead to this controller
|
||||
def test_routes
|
||||
assert_routing(
|
||||
{ :path => "/api/0.6/user/1", :method => :get },
|
||||
{ :controller => "user", :action => "api_read", :id => "1" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/api/0.6/user/details", :method => :get },
|
||||
{ :controller => "user", :action => "api_details" }
|
||||
|
@ -520,7 +524,30 @@ class UserControllerTest < ActionController::TestCase
|
|||
assert_select "a[href=/blocks/new/test]", 1
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def test_user_api_read
|
||||
# check that a visible user is returned properly
|
||||
get :api_read, :id => users(:normal_user).id
|
||||
assert_response :success
|
||||
|
||||
# check that we aren't revealing private information
|
||||
assert_select "contributor-terms[pd]", false
|
||||
assert_select "home", false
|
||||
assert_select "languages", false
|
||||
|
||||
# check that a suspended user is not returned
|
||||
get :api_read, :id => users(:suspended_user).id
|
||||
assert_response :gone
|
||||
|
||||
# check that a deleted user is not returned
|
||||
get :api_read, :id => users(:deleted_user).id
|
||||
assert_response :gone
|
||||
|
||||
# check that a non-existent user is not returned
|
||||
get :api_read, :id => 0
|
||||
assert_response :not_found
|
||||
end
|
||||
|
||||
def test_user_api_details
|
||||
get :api_details
|
||||
assert_response :unauthorized
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue