Standardise on double quoted strings
This commit is contained in:
parent
5cbd4038ed
commit
dc2a2c8ebd
230 changed files with 1809 additions and 1812 deletions
|
@ -1,5 +1,5 @@
|
|||
require 'test_helper'
|
||||
require 'stringio'
|
||||
require "test_helper"
|
||||
require "stringio"
|
||||
include Potlatch
|
||||
|
||||
class AmfControllerTest < ActionController::TestCase
|
||||
|
@ -129,35 +129,35 @@ class AmfControllerTest < ActionController::TestCase
|
|||
|
||||
# check contents of message
|
||||
map = amf_result "/1"
|
||||
assert_equal 0, map[0], 'map error code should be 0'
|
||||
assert_equal "", map[1], 'map error text should be empty'
|
||||
assert_equal 0, map[0], "map error code should be 0"
|
||||
assert_equal "", map[1], "map error text should be empty"
|
||||
|
||||
# check the formatting of the message
|
||||
assert_equal 5, map.length, 'map should have length 5'
|
||||
assert_equal 5, map.length, "map should have length 5"
|
||||
assert_equal Array, map[2].class, 'map "ways" element should be an array'
|
||||
assert_equal Array, map[3].class, 'map "nodes" element should be an array'
|
||||
assert_equal Array, map[4].class, 'map "relations" element should be an array'
|
||||
map[2].each do |w|
|
||||
assert_equal 2, w.length, 'way should be (id, version) pair'
|
||||
assert 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 2, w.length, "way should be (id, version) pair"
|
||||
assert w[0] == w[0].floor, "way ID should be an integer"
|
||||
assert w[1] == w[1].floor, "way version should be an integer"
|
||||
end
|
||||
|
||||
map[3].each do |n|
|
||||
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 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[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_equal Array, a[3].class, 'node tags should be array'
|
||||
assert n[4] == n[4].floor, 'node version should be an integer'
|
||||
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 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[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_equal Array, a[3].class, "node tags should be array"
|
||||
assert n[4] == n[4].floor, "node version should be an integer"
|
||||
end
|
||||
|
||||
map[4].each do |r|
|
||||
assert_equal 2, r.length, 'relation should be (id, version) pair'
|
||||
assert 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 2, r.length, "relation should be (id, version) pair"
|
||||
assert r[0] == r[0].floor, "relation ID should be an integer"
|
||||
assert r[1] == r[1].floor, "relation version should be an integer"
|
||||
end
|
||||
|
||||
# TODO: looks like amf_controller changed since this test was written
|
||||
|
@ -166,7 +166,7 @@ class AmfControllerTest < ActionController::TestCase
|
|||
assert ways.include?(current_ways(:used_way).id),
|
||||
"map should include used way"
|
||||
assert !ways.include?(current_ways(:invisible_way).id),
|
||||
'map should not include deleted way'
|
||||
"map should not include deleted way"
|
||||
end
|
||||
|
||||
##
|
||||
|
@ -214,15 +214,15 @@ class AmfControllerTest < ActionController::TestCase
|
|||
|
||||
# check contents of message
|
||||
map = amf_result "/1"
|
||||
assert_equal 0, map[0], 'first map element should be 0'
|
||||
assert_equal "", map[1], 'second map element should be an empty string'
|
||||
assert_equal Array, map[2].class, 'third map element should be an array'
|
||||
assert_equal 0, map[0], "first map element should be 0"
|
||||
assert_equal "", map[1], "second map element should be an empty string"
|
||||
assert_equal Array, map[2].class, "third map element should be an array"
|
||||
# TODO: looks like amf_controller changed since this test was written
|
||||
# so someone who knows what they're doing should check this!
|
||||
assert !map[2].include?(current_ways(:used_way).id),
|
||||
"map should not include used way"
|
||||
assert map[2].include?(current_ways(:invisible_way).id),
|
||||
'map should include deleted way'
|
||||
"map should include deleted way"
|
||||
end
|
||||
|
||||
def test_whichways_deleted_toobig
|
||||
|
@ -280,7 +280,7 @@ class AmfControllerTest < ActionController::TestCase
|
|||
# instead of a version number...
|
||||
# try to get version 1
|
||||
v1 = ways(:way_with_versions_v1)
|
||||
{ latest.id => '',
|
||||
{ latest.id => "",
|
||||
v1.way_id => v1.timestamp.strftime("%d %b %Y, %H:%M:%S")
|
||||
}.each do |id, t|
|
||||
amf_content "getway_old", "/1", [id, t]
|
||||
|
@ -323,8 +323,8 @@ class AmfControllerTest < ActionController::TestCase
|
|||
v1 = ways(:way_with_versions_v1)
|
||||
# try to get last visible version of non-existent way
|
||||
# try to get specific version of non-existent way
|
||||
[[0, ''],
|
||||
[0, '1 Jan 1970, 00:00:00'],
|
||||
[[0, ""],
|
||||
[0, "1 Jan 1970, 00:00:00"],
|
||||
[v1.way_id, (v1.timestamp - 10).strftime("%d %b %Y, %H:%M:%S")]
|
||||
].each do |id, t|
|
||||
amf_content "getway_old", "/1", [id, t]
|
||||
|
@ -350,7 +350,7 @@ class AmfControllerTest < ActionController::TestCase
|
|||
history = amf_result("/1")
|
||||
|
||||
# ['way',wayid,history]
|
||||
assert_equal 'way', history[0]
|
||||
assert_equal "way", history[0]
|
||||
assert_equal latest.id, history[1]
|
||||
# We use dates rather than version numbers here, because you might
|
||||
# have moved a node within a way (i.e. way version not incremented).
|
||||
|
@ -368,7 +368,7 @@ class AmfControllerTest < ActionController::TestCase
|
|||
history = amf_result("/1")
|
||||
|
||||
# ['way',wayid,history]
|
||||
assert_equal history[0], 'way'
|
||||
assert_equal history[0], "way"
|
||||
assert_equal history[1], 0
|
||||
assert history[2].empty?
|
||||
end
|
||||
|
@ -384,16 +384,16 @@ class AmfControllerTest < ActionController::TestCase
|
|||
# ['node',nodeid,history]
|
||||
# note that (as per getway_history) we actually round up
|
||||
# to the next second
|
||||
assert_equal history[0], 'node',
|
||||
assert_equal history[0], "node",
|
||||
'first element should be "node"'
|
||||
assert_equal history[1], latest.id,
|
||||
'second element should be the input node ID'
|
||||
"second element should be the input node ID"
|
||||
assert_equal history[2].first[0],
|
||||
(latest.timestamp + 1).strftime("%d %b %Y, %H:%M:%S"),
|
||||
'first element in third element (array) should be the latest version'
|
||||
"first element in third element (array) should be the latest version"
|
||||
assert_equal history[2].last[0],
|
||||
(nodes(:node_with_versions_v1).timestamp + 1).strftime("%d %b %Y, %H:%M:%S"),
|
||||
'last element in third element (array) should be the initial version'
|
||||
"last element in third element (array) should be the initial version"
|
||||
end
|
||||
|
||||
def test_getnode_history_nonexistent
|
||||
|
@ -404,7 +404,7 @@ class AmfControllerTest < ActionController::TestCase
|
|||
history = amf_result("/1")
|
||||
|
||||
# ['node',nodeid,history]
|
||||
assert_equal history[0], 'node'
|
||||
assert_equal history[0], "node"
|
||||
assert_equal history[1], 0
|
||||
assert history[2].empty?
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
require 'test_helper'
|
||||
require 'api_controller'
|
||||
require "test_helper"
|
||||
require "api_controller"
|
||||
|
||||
class ApiControllerTest < ActionController::TestCase
|
||||
api_fixtures
|
||||
|
@ -231,7 +231,7 @@ class ApiControllerTest < ActionController::TestCase
|
|||
# http://wiki.openstreetmap.org/wiki/Rails#Installing_the_quadtile_functions
|
||||
# or by looking at the readme in db/README
|
||||
def test_changes_simple
|
||||
Timecop.freeze(Time.parse('2010-04-03 10:55:00'))
|
||||
Timecop.freeze(Time.parse("2010-04-03 10:55:00"))
|
||||
get :changes
|
||||
assert_response :success
|
||||
# print @response.body
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
require 'test_helper'
|
||||
require 'browse_controller'
|
||||
require "test_helper"
|
||||
require "browse_controller"
|
||||
|
||||
class BrowseControllerTest < ActionController::TestCase
|
||||
api_fixtures
|
||||
|
@ -46,35 +46,35 @@ class BrowseControllerTest < ActionController::TestCase
|
|||
end
|
||||
|
||||
def test_read_relation
|
||||
browse_check 'relation', relations(:visible_relation).relation_id, 'browse/feature'
|
||||
browse_check "relation", relations(:visible_relation).relation_id, "browse/feature"
|
||||
end
|
||||
|
||||
def test_read_relation_history
|
||||
browse_check 'relation_history', relations(:visible_relation).relation_id, 'browse/history'
|
||||
browse_check "relation_history", relations(:visible_relation).relation_id, "browse/history"
|
||||
end
|
||||
|
||||
def test_read_way
|
||||
browse_check 'way', ways(:visible_way).way_id, 'browse/feature'
|
||||
browse_check "way", ways(:visible_way).way_id, "browse/feature"
|
||||
end
|
||||
|
||||
def test_read_way_history
|
||||
browse_check 'way_history', ways(:visible_way).way_id, 'browse/history'
|
||||
browse_check "way_history", ways(:visible_way).way_id, "browse/history"
|
||||
end
|
||||
|
||||
def test_read_node
|
||||
browse_check 'node', nodes(:visible_node).node_id, 'browse/feature'
|
||||
browse_check "node", nodes(:visible_node).node_id, "browse/feature"
|
||||
end
|
||||
|
||||
def test_read_node_history
|
||||
browse_check 'node_history', nodes(:visible_node).node_id, 'browse/history'
|
||||
browse_check "node_history", nodes(:visible_node).node_id, "browse/history"
|
||||
end
|
||||
|
||||
def test_read_changeset
|
||||
browse_check 'changeset', changesets(:normal_user_first_change).id, 'browse/changeset'
|
||||
browse_check "changeset", changesets(:normal_user_first_change).id, "browse/changeset"
|
||||
end
|
||||
|
||||
def test_read_note
|
||||
browse_check 'note', notes(:open_note).id, 'browse/note'
|
||||
browse_check "note", notes(:open_note).id, "browse/note"
|
||||
end
|
||||
|
||||
##
|
||||
|
@ -114,7 +114,7 @@ class BrowseControllerTest < ActionController::TestCase
|
|||
def test_redacted_way_history
|
||||
get :way_history, :id => ways(:way_with_redacted_versions_v1).way_id
|
||||
assert_response :success
|
||||
assert_template 'browse/history'
|
||||
assert_template "browse/history"
|
||||
|
||||
# there are 4 revisions of the redacted way, but only 2
|
||||
# should be showing details here.
|
||||
|
@ -126,7 +126,7 @@ class BrowseControllerTest < ActionController::TestCase
|
|||
def test_redacted_relation_history
|
||||
get :relation_history, :id => relations(:relation_with_redacted_versions_v1).relation_id
|
||||
assert_response :success
|
||||
assert_template 'browse/history'
|
||||
assert_template "browse/history"
|
||||
|
||||
# there are 4 revisions of the redacted relation, but only 2
|
||||
# should be showing details here.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
require 'test_helper'
|
||||
require 'changeset_controller'
|
||||
require "test_helper"
|
||||
require "changeset_controller"
|
||||
|
||||
class ChangesetControllerTest < ActionController::TestCase
|
||||
api_fixtures
|
||||
|
@ -464,7 +464,7 @@ EOF
|
|||
changeset_id = changesets(:public_user_first_change).id
|
||||
%w(node way relation).each do |type|
|
||||
delete.find("//osmChange/delete/#{type}").each do |n|
|
||||
n['changeset'] = changeset_id.to_s
|
||||
n["changeset"] = changeset_id.to_s
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -517,7 +517,7 @@ EOF
|
|||
content "<osm><changeset>" +
|
||||
"<tag k='created_by' v='osm test suite checking changesets'/>" +
|
||||
"</changeset></osm>"
|
||||
assert_difference('Changeset.count', 1) do
|
||||
assert_difference("Changeset.count", 1) do
|
||||
put :create
|
||||
end
|
||||
assert_response :success
|
||||
|
@ -726,7 +726,7 @@ EOF
|
|||
assert_equal 2, Node.find(new_node_id).tags.size, "new node should have two tags"
|
||||
assert_equal [new_node_id, 3], Way.find(1).nds, "way nodes should match"
|
||||
Relation.find(1).members.each do |type, id, _role|
|
||||
if type == 'node'
|
||||
if type == "node"
|
||||
assert_equal new_node_id, id, "relation should contain new node"
|
||||
end
|
||||
end
|
||||
|
@ -1544,39 +1544,39 @@ EOF
|
|||
assert_response :success, "can't get changesets by user and open"
|
||||
assert_changesets [1]
|
||||
|
||||
get :query, :time => '2007-12-31'
|
||||
get :query, :time => "2007-12-31"
|
||||
assert_response :success, "can't get changesets by time-since"
|
||||
assert_changesets [1, 2, 4, 5, 6]
|
||||
|
||||
get :query, :time => '2008-01-01T12:34Z'
|
||||
get :query, :time => "2008-01-01T12:34Z"
|
||||
assert_response :success, "can't get changesets by time-since with hour"
|
||||
assert_changesets [1, 2, 4, 5, 6]
|
||||
|
||||
get :query, :time => '2007-12-31T23:59Z,2008-01-01T00:01Z'
|
||||
get :query, :time => "2007-12-31T23:59Z,2008-01-01T00:01Z"
|
||||
assert_response :success, "can't get changesets by time-range"
|
||||
assert_changesets [1, 5, 6]
|
||||
|
||||
get :query, :open => 'true'
|
||||
get :query, :open => "true"
|
||||
assert_response :success, "can't get changesets by open-ness"
|
||||
assert_changesets [1, 2, 4]
|
||||
|
||||
get :query, :closed => 'true'
|
||||
get :query, :closed => "true"
|
||||
assert_response :success, "can't get changesets by closed-ness"
|
||||
assert_changesets [3, 5, 6, 7, 8]
|
||||
|
||||
get :query, :closed => 'true', :user => users(:normal_user).id
|
||||
get :query, :closed => "true", :user => users(:normal_user).id
|
||||
assert_response :success, "can't get changesets by closed-ness and user"
|
||||
assert_changesets [3, 6, 8]
|
||||
|
||||
get :query, :closed => 'true', :user => users(:public_user).id
|
||||
get :query, :closed => "true", :user => users(:public_user).id
|
||||
assert_response :success, "can't get changesets by closed-ness and user"
|
||||
assert_changesets [7]
|
||||
|
||||
get :query, :changesets => '1,2,3'
|
||||
get :query, :changesets => "1,2,3"
|
||||
assert_response :success, "can't get changesets by id (as comma-separated string)"
|
||||
assert_changesets [1, 2, 3]
|
||||
|
||||
get :query, :changesets => ''
|
||||
get :query, :changesets => ""
|
||||
assert_response :bad_request, "should be a bad request since changesets is empty"
|
||||
end
|
||||
|
||||
|
@ -1619,8 +1619,8 @@ EOF
|
|||
changeset = changesets(:normal_user_first_change)
|
||||
new_changeset = changeset.to_xml
|
||||
new_tag = XML::Node.new "tag"
|
||||
new_tag['k'] = "tagtesting"
|
||||
new_tag['v'] = "valuetesting"
|
||||
new_tag["k"] = "tagtesting"
|
||||
new_tag["v"] = "valuetesting"
|
||||
new_changeset.find("//osm/changeset").first << new_tag
|
||||
content new_changeset
|
||||
|
||||
|
@ -1642,8 +1642,8 @@ EOF
|
|||
changeset = changesets(:public_user_first_change)
|
||||
new_changeset = changeset.to_xml
|
||||
new_tag = XML::Node.new "tag"
|
||||
new_tag['k'] = "tagtesting"
|
||||
new_tag['v'] = "valuetesting"
|
||||
new_tag["k"] = "tagtesting"
|
||||
new_tag["v"] = "valuetesting"
|
||||
new_changeset.find("//osm/changeset").first << new_tag
|
||||
content new_changeset
|
||||
|
||||
|
@ -1676,8 +1676,8 @@ EOF
|
|||
changeset = changesets(:normal_user_first_change)
|
||||
new_changeset = changeset.to_xml
|
||||
new_tag = XML::Node.new "tag"
|
||||
new_tag['k'] = "testing"
|
||||
new_tag['v'] = "testing"
|
||||
new_tag["k"] = "testing"
|
||||
new_tag["v"] = "testing"
|
||||
new_changeset.find("//osm/changeset").first << new_tag
|
||||
|
||||
content new_changeset
|
||||
|
@ -1719,9 +1719,9 @@ EOF
|
|||
|
||||
# loop until we fill the changeset with nodes
|
||||
offset.times do |i|
|
||||
node_xml['lat'] = rand.to_s
|
||||
node_xml['lon'] = rand.to_s
|
||||
node_xml['version'] = (i + 1).to_s
|
||||
node_xml["lat"] = rand.to_s
|
||||
node_xml["lon"] = rand.to_s
|
||||
node_xml["version"] = (i + 1).to_s
|
||||
|
||||
content node_doc
|
||||
put :update, :id => node_id
|
||||
|
@ -1729,9 +1729,9 @@ EOF
|
|||
end
|
||||
|
||||
# trying again should fail
|
||||
node_xml['lat'] = rand.to_s
|
||||
node_xml['lon'] = rand.to_s
|
||||
node_xml['version'] = offset.to_s
|
||||
node_xml["lat"] = rand.to_s
|
||||
node_xml["lon"] = rand.to_s
|
||||
node_xml["version"] = offset.to_s
|
||||
|
||||
content node_doc
|
||||
put :update, :id => node_id
|
||||
|
@ -1756,7 +1756,7 @@ EOF
|
|||
assert_template :layout => "map"
|
||||
assert_select "h2", :text => "Changesets", :count => 1
|
||||
|
||||
get :list, :format => "html", :list => '1', :bbox => '-180,-90,90,180'
|
||||
get :list, :format => "html", :list => "1", :bbox => "-180,-90,90,180"
|
||||
assert_response :success
|
||||
assert_template "list"
|
||||
|
||||
|
@ -1782,7 +1782,7 @@ EOF
|
|||
assert_template :layout => "xhr"
|
||||
assert_select "h2", :text => "Changesets", :count => 1
|
||||
|
||||
get :list, :format => "html", :list => '1', :bbox => '-180,-90,90,180'
|
||||
get :list, :format => "html", :list => "1", :bbox => "-180,-90,90,180"
|
||||
assert_response :success
|
||||
assert_template "list"
|
||||
|
||||
|
@ -1814,7 +1814,7 @@ EOF
|
|||
def test_list_user_not_found
|
||||
get :list, :format => "html", :display_name => "Some random user"
|
||||
assert_response :not_found
|
||||
assert_template 'user/no_such_user'
|
||||
assert_template "user/no_such_user"
|
||||
end
|
||||
|
||||
##
|
||||
|
@ -1870,10 +1870,10 @@ EOF
|
|||
##
|
||||
# create comment success
|
||||
def test_create_comment_success
|
||||
basic_authorization(users(:public_user).email, 'test')
|
||||
basic_authorization(users(:public_user).email, "test")
|
||||
|
||||
assert_difference('ChangesetComment.count') do
|
||||
post :comment, :id => changesets(:normal_user_closed_change).id, :text => 'This is a comment'
|
||||
assert_difference("ChangesetComment.count") do
|
||||
post :comment, :id => changesets(:normal_user_closed_change).id, :text => "This is a comment"
|
||||
end
|
||||
assert_response :success
|
||||
end
|
||||
|
@ -1882,32 +1882,32 @@ EOF
|
|||
# create comment fail
|
||||
def test_create_comment_fail
|
||||
# unauthorized
|
||||
post :comment, :id => changesets(:normal_user_closed_change).id, :text => 'This is a comment'
|
||||
post :comment, :id => changesets(:normal_user_closed_change).id, :text => "This is a comment"
|
||||
assert_response :unauthorized
|
||||
|
||||
basic_authorization(users(:public_user).email, 'test')
|
||||
basic_authorization(users(:public_user).email, "test")
|
||||
|
||||
# bad changeset id
|
||||
assert_no_difference('ChangesetComment.count') do
|
||||
post :comment, :id => 999111, :text => 'This is a comment'
|
||||
assert_no_difference("ChangesetComment.count") do
|
||||
post :comment, :id => 999111, :text => "This is a comment"
|
||||
end
|
||||
assert_response :not_found
|
||||
|
||||
# not closed changeset
|
||||
assert_no_difference('ChangesetComment.count') do
|
||||
post :comment, :id => changesets(:normal_user_first_change).id, :text => 'This is a comment'
|
||||
assert_no_difference("ChangesetComment.count") do
|
||||
post :comment, :id => changesets(:normal_user_first_change).id, :text => "This is a comment"
|
||||
end
|
||||
assert_response :conflict
|
||||
|
||||
# no text
|
||||
assert_no_difference('ChangesetComment.count') do
|
||||
assert_no_difference("ChangesetComment.count") do
|
||||
post :comment, :id => changesets(:normal_user_closed_change).id
|
||||
end
|
||||
assert_response :bad_request
|
||||
|
||||
# empty text
|
||||
assert_no_difference('ChangesetComment.count') do
|
||||
post :comment, :id => changesets(:normal_user_closed_change).id, :text => ''
|
||||
assert_no_difference("ChangesetComment.count") do
|
||||
post :comment, :id => changesets(:normal_user_closed_change).id, :text => ""
|
||||
end
|
||||
assert_response :bad_request
|
||||
end
|
||||
|
@ -1915,10 +1915,10 @@ EOF
|
|||
##
|
||||
# test subscribe success
|
||||
def test_subscribe_success
|
||||
basic_authorization(users(:public_user).email, 'test')
|
||||
basic_authorization(users(:public_user).email, "test")
|
||||
changeset = changesets(:normal_user_closed_change)
|
||||
|
||||
assert_difference('changeset.subscribers.count') do
|
||||
assert_difference("changeset.subscribers.count") do
|
||||
post :subscribe, :id => changeset.id
|
||||
end
|
||||
assert_response :success
|
||||
|
@ -1929,29 +1929,29 @@ EOF
|
|||
def test_subscribe_fail
|
||||
# unauthorized
|
||||
changeset = changesets(:normal_user_closed_change)
|
||||
assert_no_difference('changeset.subscribers.count') do
|
||||
assert_no_difference("changeset.subscribers.count") do
|
||||
post :subscribe, :id => changeset.id
|
||||
end
|
||||
assert_response :unauthorized
|
||||
|
||||
basic_authorization(users(:public_user).email, 'test')
|
||||
basic_authorization(users(:public_user).email, "test")
|
||||
|
||||
# bad changeset id
|
||||
assert_no_difference('changeset.subscribers.count') do
|
||||
assert_no_difference("changeset.subscribers.count") do
|
||||
post :subscribe, :id => 999111
|
||||
end
|
||||
assert_response :not_found
|
||||
|
||||
# not closed changeset
|
||||
changeset = changesets(:normal_user_first_change)
|
||||
assert_no_difference('changeset.subscribers.count') do
|
||||
assert_no_difference("changeset.subscribers.count") do
|
||||
post :subscribe, :id => changeset.id
|
||||
end
|
||||
assert_response :conflict
|
||||
|
||||
# trying to subscribe when already subscribed
|
||||
changeset = changesets(:normal_user_subscribed_change)
|
||||
assert_no_difference('changeset.subscribers.count') do
|
||||
assert_no_difference("changeset.subscribers.count") do
|
||||
post :subscribe, :id => changeset.id
|
||||
end
|
||||
assert_response :conflict
|
||||
|
@ -1960,10 +1960,10 @@ EOF
|
|||
##
|
||||
# test unsubscribe success
|
||||
def test_unsubscribe_success
|
||||
basic_authorization(users(:public_user).email, 'test')
|
||||
basic_authorization(users(:public_user).email, "test")
|
||||
changeset = changesets(:normal_user_subscribed_change)
|
||||
|
||||
assert_difference('changeset.subscribers.count', -1) do
|
||||
assert_difference("changeset.subscribers.count", -1) do
|
||||
post :unsubscribe, :id => changeset.id
|
||||
end
|
||||
assert_response :success
|
||||
|
@ -1974,29 +1974,29 @@ EOF
|
|||
def test_unsubscribe_fail
|
||||
# unauthorized
|
||||
changeset = changesets(:normal_user_closed_change)
|
||||
assert_no_difference('changeset.subscribers.count') do
|
||||
assert_no_difference("changeset.subscribers.count") do
|
||||
post :unsubscribe, :id => changeset.id
|
||||
end
|
||||
assert_response :unauthorized
|
||||
|
||||
basic_authorization(users(:public_user).email, 'test')
|
||||
basic_authorization(users(:public_user).email, "test")
|
||||
|
||||
# bad changeset id
|
||||
assert_no_difference('changeset.subscribers.count', -1) do
|
||||
assert_no_difference("changeset.subscribers.count", -1) do
|
||||
post :unsubscribe, :id => 999111
|
||||
end
|
||||
assert_response :not_found
|
||||
|
||||
# not closed changeset
|
||||
changeset = changesets(:normal_user_first_change)
|
||||
assert_no_difference('changeset.subscribers.count', -1) do
|
||||
assert_no_difference("changeset.subscribers.count", -1) do
|
||||
post :unsubscribe, :id => changeset.id
|
||||
end
|
||||
assert_response :conflict
|
||||
|
||||
# trying to unsubscribe when not subscribed
|
||||
changeset = changesets(:normal_user_closed_change)
|
||||
assert_no_difference('changeset.subscribers.count') do
|
||||
assert_no_difference("changeset.subscribers.count") do
|
||||
post :unsubscribe, :id => changeset.id
|
||||
end
|
||||
assert_response :not_found
|
||||
|
@ -2007,20 +2007,20 @@ EOF
|
|||
def test_hide_comment_fail
|
||||
# unauthorized
|
||||
comment = changeset_comments(:normal_comment_1)
|
||||
assert('comment.visible') do
|
||||
assert("comment.visible") do
|
||||
post :hide_comment, :id => comment.id
|
||||
assert_response :unauthorized
|
||||
end
|
||||
|
||||
basic_authorization(users(:public_user).email, 'test')
|
||||
basic_authorization(users(:public_user).email, "test")
|
||||
|
||||
# not a moderator
|
||||
assert('comment.visible') do
|
||||
assert("comment.visible") do
|
||||
post :hide_comment, :id => comment.id
|
||||
assert_response :forbidden
|
||||
end
|
||||
|
||||
basic_authorization(users(:moderator_user).email, 'test')
|
||||
basic_authorization(users(:moderator_user).email, "test")
|
||||
|
||||
# bad comment id
|
||||
post :hide_comment, :id => 999111
|
||||
|
@ -2032,9 +2032,9 @@ EOF
|
|||
def test_hide_comment_success
|
||||
comment = changeset_comments(:normal_comment_1)
|
||||
|
||||
basic_authorization(users(:moderator_user).email, 'test')
|
||||
basic_authorization(users(:moderator_user).email, "test")
|
||||
|
||||
assert('!comment.visible') do
|
||||
assert("!comment.visible") do
|
||||
post :hide_comment, :id => comment.id
|
||||
end
|
||||
assert_response :success
|
||||
|
@ -2045,20 +2045,20 @@ EOF
|
|||
def test_unhide_comment_fail
|
||||
# unauthorized
|
||||
comment = changeset_comments(:normal_comment_1)
|
||||
assert('comment.visible') do
|
||||
assert("comment.visible") do
|
||||
post :unhide_comment, :id => comment.id
|
||||
assert_response :unauthorized
|
||||
end
|
||||
|
||||
basic_authorization(users(:public_user).email, 'test')
|
||||
basic_authorization(users(:public_user).email, "test")
|
||||
|
||||
# not a moderator
|
||||
assert('comment.visible') do
|
||||
assert("comment.visible") do
|
||||
post :unhide_comment, :id => comment.id
|
||||
assert_response :forbidden
|
||||
end
|
||||
|
||||
basic_authorization(users(:moderator_user).email, 'test')
|
||||
basic_authorization(users(:moderator_user).email, "test")
|
||||
|
||||
# bad comment id
|
||||
post :unhide_comment, :id => 999111
|
||||
|
@ -2070,9 +2070,9 @@ EOF
|
|||
def test_unhide_comment_success
|
||||
comment = changeset_comments(:normal_comment_1)
|
||||
|
||||
basic_authorization(users(:moderator_user).email, 'test')
|
||||
basic_authorization(users(:moderator_user).email, "test")
|
||||
|
||||
assert('!comment.visible') do
|
||||
assert("!comment.visible") do
|
||||
post :unhide_comment, :id => comment.id
|
||||
end
|
||||
assert_response :success
|
||||
|
@ -2128,16 +2128,16 @@ EOF
|
|||
# check the bbox
|
||||
doc = XML::Parser.string(@response.body).parse
|
||||
changeset = doc.find("//osm/changeset").first
|
||||
assert_equal bbox[0], changeset['min_lon'].to_f, "min lon"
|
||||
assert_equal bbox[1], changeset['min_lat'].to_f, "min lat"
|
||||
assert_equal bbox[2], changeset['max_lon'].to_f, "max lon"
|
||||
assert_equal bbox[3], changeset['max_lat'].to_f, "max lat"
|
||||
assert_equal bbox[0], changeset["min_lon"].to_f, "min lon"
|
||||
assert_equal bbox[1], changeset["min_lat"].to_f, "min lat"
|
||||
assert_equal bbox[2], changeset["max_lon"].to_f, "max lon"
|
||||
assert_equal bbox[3], changeset["max_lat"].to_f, "max lat"
|
||||
end
|
||||
|
||||
##
|
||||
# update the changeset_id of a way element
|
||||
def update_changeset(xml, changeset_id)
|
||||
xml_attr_rewrite(xml, 'changeset', changeset_id)
|
||||
xml_attr_rewrite(xml, "changeset", changeset_id)
|
||||
end
|
||||
|
||||
##
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require 'test_helper'
|
||||
require "test_helper"
|
||||
|
||||
class DiaryEntryControllerTest < ActionController::TestCase
|
||||
fixtures :users, :diary_entries, :diary_comments, :languages
|
||||
|
@ -91,7 +91,7 @@ class DiaryEntryControllerTest < ActionController::TestCase
|
|||
assert_redirected_to :controller => :user, :action => "login", :referer => "/diary/new"
|
||||
# Now pretend to login by using the session hash, with the
|
||||
# id of the person we want to login as through session(:user)=user.id
|
||||
get(:new, nil, 'user' => users(:normal_user).id)
|
||||
get(:new, nil, "user" => users(:normal_user).id)
|
||||
assert_response :success
|
||||
# print @response.body
|
||||
|
||||
|
@ -123,7 +123,7 @@ class DiaryEntryControllerTest < ActionController::TestCase
|
|||
assert_redirected_to :controller => :user, :action => "login", :referer => "/user/#{entry.user.display_name}/diary/#{entry.id}/edit"
|
||||
|
||||
# Verify that you get a not found error, when you pass a bogus id
|
||||
get(:edit, { :display_name => entry.user.display_name, :id => 9999 }, { 'user' => entry.user.id })
|
||||
get(:edit, { :display_name => entry.user.display_name, :id => 9999 }, { "user" => entry.user.id })
|
||||
assert_response :not_found
|
||||
assert_select "div.content-heading", :count => 1 do
|
||||
assert_select "h2", :text => "No entry with the id: 9999", :count => 1
|
||||
|
@ -131,7 +131,7 @@ class DiaryEntryControllerTest < ActionController::TestCase
|
|||
|
||||
# Now pass the id, and check that you can edit it, when using the same
|
||||
# user as the person who created the entry
|
||||
get(:edit, { :display_name => entry.user.display_name, :id => entry.id }, { 'user' => entry.user.id })
|
||||
get(:edit, { :display_name => entry.user.display_name, :id => entry.id }, { "user" => entry.user.id })
|
||||
assert_response :success
|
||||
assert_select "title", :text => /Edit diary entry/, :count => 1
|
||||
assert_select "div.content-heading", :count => 1 do
|
||||
|
@ -157,17 +157,17 @@ class DiaryEntryControllerTest < ActionController::TestCase
|
|||
new_latitude = "1.1"
|
||||
new_longitude = "2.2"
|
||||
new_language_code = "en"
|
||||
post(:edit, { :display_name => entry.user.display_name, :id => entry.id, 'commit' => 'save',
|
||||
'diary_entry' => { 'title' => new_title, 'body' => new_body, 'latitude' => new_latitude,
|
||||
'longitude' => new_longitude, 'language_code' => new_language_code } },
|
||||
{ 'user' => entry.user.id })
|
||||
post(:edit, { :display_name => entry.user.display_name, :id => entry.id, "commit" => "save",
|
||||
"diary_entry" => { "title" => new_title, "body" => new_body, "latitude" => new_latitude,
|
||||
"longitude" => new_longitude, "language_code" => new_language_code } },
|
||||
{ "user" => entry.user.id })
|
||||
assert_response :redirect
|
||||
assert_redirected_to :action => :view, :display_name => entry.user.display_name, :id => entry.id
|
||||
|
||||
# Now check that the new data is rendered, when logged in
|
||||
get :view, { :display_name => entry.user.display_name, :id => entry.id }, { 'user' => entry.user.id }
|
||||
get :view, { :display_name => entry.user.display_name, :id => entry.id }, { "user" => entry.user.id }
|
||||
assert_response :success
|
||||
assert_template 'diary_entry/view'
|
||||
assert_template "diary_entry/view"
|
||||
assert_select "title", :text => /Users' diaries | /, :count => 1
|
||||
assert_select "div.content-heading", :count => 1 do
|
||||
assert_select "h2", :text => /#{entry.user.display_name}'s diary/, :count => 1
|
||||
|
@ -184,9 +184,9 @@ class DiaryEntryControllerTest < ActionController::TestCase
|
|||
end
|
||||
|
||||
# and when not logged in as the user who wrote the entry
|
||||
get :view, { :display_name => entry.user.display_name, :id => entry.id }, { 'user' => entry.user.id }
|
||||
get :view, { :display_name => entry.user.display_name, :id => entry.id }, { "user" => entry.user.id }
|
||||
assert_response :success
|
||||
assert_template 'diary_entry/view'
|
||||
assert_template "diary_entry/view"
|
||||
assert_select "title", :text => /Users' diaries | /, :count => 1
|
||||
assert_select "div.content-heading", :count => 1 do
|
||||
assert_select "h2", :text => /#{users(:normal_user).display_name}'s diary/, :count => 1
|
||||
|
@ -205,7 +205,7 @@ class DiaryEntryControllerTest < ActionController::TestCase
|
|||
end
|
||||
|
||||
def test_edit_diary_entry_i18n
|
||||
get :edit, { :display_name => users(:normal_user).display_name, :id => diary_entries(:normal_user_entry_1).id }, { 'user' => users(:normal_user).id }
|
||||
get :edit, { :display_name => users(:normal_user).display_name, :id => diary_entries(:normal_user_entry_1).id }, { "user" => users(:normal_user).id }
|
||||
assert_response :success
|
||||
assert_select "span[class=translation_missing]", false, "Missing translation in edit diary entry"
|
||||
end
|
||||
|
@ -245,9 +245,9 @@ class DiaryEntryControllerTest < ActionController::TestCase
|
|||
new_longitude = "2.2"
|
||||
new_language_code = "en"
|
||||
assert_difference "DiaryEntry.count", 1 do
|
||||
post(:new, { 'commit' => 'save',
|
||||
'diary_entry' => { 'title' => new_title, 'body' => new_body, 'latitude' => new_latitude,
|
||||
'longitude' => new_longitude, 'language_code' => new_language_code } },
|
||||
post(:new, { "commit" => "save",
|
||||
"diary_entry" => { "title" => new_title, "body" => new_body, "latitude" => new_latitude,
|
||||
"longitude" => new_longitude, "language_code" => new_language_code } },
|
||||
{ :user => users(:normal_user).id })
|
||||
end
|
||||
assert_response :redirect
|
||||
|
@ -310,13 +310,13 @@ class DiaryEntryControllerTest < ActionController::TestCase
|
|||
def test_listing_diary_entries
|
||||
get :list
|
||||
assert_response :success, "Should be able to list the diary entries in locale"
|
||||
assert_template 'list', "Should use the list template in locale"
|
||||
assert_template "list", "Should use the list template in locale"
|
||||
assert_select "span[class=translation_missing]", false, "Missing translation in list of diary entries"
|
||||
|
||||
# Now try to find a specific user's diary entry
|
||||
get :list, :display_name => users(:normal_user).display_name
|
||||
assert_response :success, "Should be able to list the diary entries for a user in locale"
|
||||
assert_template 'list', "Should use the list template for a user in locale"
|
||||
assert_template "list", "Should use the list template for a user in locale"
|
||||
assert_no_missing_translations
|
||||
end
|
||||
|
||||
|
@ -344,7 +344,7 @@ class DiaryEntryControllerTest < ActionController::TestCase
|
|||
# end
|
||||
|
||||
def test_rss_language_with_no_entries
|
||||
get :rss, :language => 'sl', :format => :rss
|
||||
get :rss, :language => "sl", :format => :rss
|
||||
assert_response :success, "Should be able to get a specific language diary RSS"
|
||||
assert_select "rss>channel>item", :count => 0 # , "Diary entries should be filtered by language"
|
||||
end
|
||||
|
@ -357,7 +357,7 @@ class DiaryEntryControllerTest < ActionController::TestCase
|
|||
|
||||
def test_rss_nonexisting_user
|
||||
# Try a user that has never existed
|
||||
get :rss, :display_name => 'fakeUsername76543', :format => :rss
|
||||
get :rss, :display_name => "fakeUsername76543", :format => :rss
|
||||
assert_response :not_found, "Should not be able to get a nonexisting users diary RSS"
|
||||
|
||||
# Try a suspended user
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require 'test_helper'
|
||||
require "test_helper"
|
||||
|
||||
class DirectionsControllerTest < ActionController::TestCase
|
||||
##
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require 'test_helper'
|
||||
require "test_helper"
|
||||
|
||||
class ExportControllerTest < ActionController::TestCase
|
||||
##
|
||||
|
@ -17,7 +17,7 @@ class ExportControllerTest < ActionController::TestCase
|
|||
###
|
||||
# test the finish action for raw OSM data
|
||||
def test_finish_osm
|
||||
get :finish, :minlon => 0, :minlat => 50, :maxlon => 1, :maxlat => 51, :format => 'osm'
|
||||
get :finish, :minlon => 0, :minlat => 50, :maxlon => 1, :maxlat => 51, :format => "osm"
|
||||
assert_response :redirect
|
||||
assert_redirected_to "http://api.openstreetmap.org/api/#{API_VERSION}/map?bbox=0.0,50.0,1.0,51.0"
|
||||
end
|
||||
|
@ -25,7 +25,7 @@ class ExportControllerTest < ActionController::TestCase
|
|||
###
|
||||
# test the finish action for mapnik images
|
||||
def test_finish_mapnik
|
||||
get :finish, :minlon => 0, :minlat => 50, :maxlon => 1, :maxlat => 51, :format => 'mapnik', :mapnik_format => 'test', :mapnik_scale => '12'
|
||||
get :finish, :minlon => 0, :minlat => 50, :maxlon => 1, :maxlat => 51, :format => "mapnik", :mapnik_format => "test", :mapnik_scale => "12"
|
||||
assert_response :redirect
|
||||
assert_redirected_to "http://render.openstreetmap.org/cgi-bin/export?bbox=0.0,50.0,1.0,51.0&scale=12&format=test"
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# coding: utf-8
|
||||
|
||||
require 'test_helper'
|
||||
require 'geocoder_controller'
|
||||
require "test_helper"
|
||||
require "geocoder_controller"
|
||||
|
||||
class GeocoderControllerTest < ActionController::TestCase
|
||||
##
|
||||
|
@ -49,10 +49,10 @@ class GeocoderControllerTest < ActionController::TestCase
|
|||
# Test identification of basic lat/lon pairs
|
||||
def test_identify_latlon_basic
|
||||
[
|
||||
'50.06773 14.37742',
|
||||
'50.06773, 14.37742',
|
||||
'+50.06773 +14.37742',
|
||||
'+50.06773, +14.37742'
|
||||
"50.06773 14.37742",
|
||||
"50.06773, 14.37742",
|
||||
"+50.06773 +14.37742",
|
||||
"+50.06773, +14.37742"
|
||||
].each do |code|
|
||||
latlon_check code, 50.06773, 14.37742
|
||||
end
|
||||
|
@ -62,10 +62,10 @@ class GeocoderControllerTest < ActionController::TestCase
|
|||
# Test identification of lat/lon pairs using N/E with degrees
|
||||
def test_identify_latlon_ne_d
|
||||
[
|
||||
'N50.06773 E14.37742',
|
||||
'N50.06773, E14.37742',
|
||||
'50.06773N 14.37742E',
|
||||
'50.06773N, 14.37742E'
|
||||
"N50.06773 E14.37742",
|
||||
"N50.06773, E14.37742",
|
||||
"50.06773N 14.37742E",
|
||||
"50.06773N, 14.37742E"
|
||||
].each do |code|
|
||||
latlon_check code, 50.06773, 14.37742
|
||||
end
|
||||
|
@ -75,10 +75,10 @@ class GeocoderControllerTest < ActionController::TestCase
|
|||
# Test identification of lat/lon pairs using N/W with degrees
|
||||
def test_identify_latlon_nw_d
|
||||
[
|
||||
'N50.06773 W14.37742',
|
||||
'N50.06773, W14.37742',
|
||||
'50.06773N 14.37742W',
|
||||
'50.06773N, 14.37742W'
|
||||
"N50.06773 W14.37742",
|
||||
"N50.06773, W14.37742",
|
||||
"50.06773N 14.37742W",
|
||||
"50.06773N, 14.37742W"
|
||||
].each do |code|
|
||||
latlon_check code, 50.06773, -14.37742
|
||||
end
|
||||
|
@ -88,10 +88,10 @@ class GeocoderControllerTest < ActionController::TestCase
|
|||
# Test identification of lat/lon pairs using S/E with degrees
|
||||
def test_identify_latlon_se_d
|
||||
[
|
||||
'S50.06773 E14.37742',
|
||||
'S50.06773, E14.37742',
|
||||
'50.06773S 14.37742E',
|
||||
'50.06773S, 14.37742E'
|
||||
"S50.06773 E14.37742",
|
||||
"S50.06773, E14.37742",
|
||||
"50.06773S 14.37742E",
|
||||
"50.06773S, 14.37742E"
|
||||
].each do |code|
|
||||
latlon_check code, -50.06773, 14.37742
|
||||
end
|
||||
|
@ -101,10 +101,10 @@ class GeocoderControllerTest < ActionController::TestCase
|
|||
# Test identification of lat/lon pairs using S/W with degrees
|
||||
def test_identify_latlon_sw_d
|
||||
[
|
||||
'S50.06773 W14.37742',
|
||||
'S50.06773, W14.37742',
|
||||
'50.06773S 14.37742W',
|
||||
'50.06773S, 14.37742W'
|
||||
"S50.06773 W14.37742",
|
||||
"S50.06773, W14.37742",
|
||||
"50.06773S 14.37742W",
|
||||
"50.06773S, 14.37742W"
|
||||
].each do |code|
|
||||
latlon_check code, -50.06773, -14.37742
|
||||
end
|
||||
|
@ -114,12 +114,12 @@ class GeocoderControllerTest < ActionController::TestCase
|
|||
# Test identification of lat/lon pairs using N/E with degrees/mins
|
||||
def test_identify_latlon_ne_dm
|
||||
[
|
||||
'N 50° 04.064 E 014° 22.645',
|
||||
"N 50° 04.064 E 014° 22.645",
|
||||
"N 50° 04.064' E 014° 22.645",
|
||||
"N 50° 04.064', E 014° 22.645'",
|
||||
'N50° 04.064 E14° 22.645',
|
||||
'N 50 04.064 E 014 22.645',
|
||||
'N50 4.064 E14 22.645',
|
||||
"N50° 04.064 E14° 22.645",
|
||||
"N 50 04.064 E 014 22.645",
|
||||
"N50 4.064 E14 22.645",
|
||||
"50° 04.064' N, 014° 22.645' E"
|
||||
].each do |code|
|
||||
latlon_check code, 50.06773, 14.37742
|
||||
|
@ -130,12 +130,12 @@ class GeocoderControllerTest < ActionController::TestCase
|
|||
# Test identification of lat/lon pairs using N/W with degrees/mins
|
||||
def test_identify_latlon_nw_dm
|
||||
[
|
||||
'N 50° 04.064 W 014° 22.645',
|
||||
"N 50° 04.064 W 014° 22.645",
|
||||
"N 50° 04.064' W 014° 22.645",
|
||||
"N 50° 04.064', W 014° 22.645'",
|
||||
'N50° 04.064 W14° 22.645',
|
||||
'N 50 04.064 W 014 22.645',
|
||||
'N50 4.064 W14 22.645',
|
||||
"N50° 04.064 W14° 22.645",
|
||||
"N 50 04.064 W 014 22.645",
|
||||
"N50 4.064 W14 22.645",
|
||||
"50° 04.064' N, 014° 22.645' W"
|
||||
].each do |code|
|
||||
latlon_check code, 50.06773, -14.37742
|
||||
|
@ -146,12 +146,12 @@ class GeocoderControllerTest < ActionController::TestCase
|
|||
# Test identification of lat/lon pairs using S/E with degrees/mins
|
||||
def test_identify_latlon_se_dm
|
||||
[
|
||||
'S 50° 04.064 E 014° 22.645',
|
||||
"S 50° 04.064 E 014° 22.645",
|
||||
"S 50° 04.064' E 014° 22.645",
|
||||
"S 50° 04.064', E 014° 22.645'",
|
||||
'S50° 04.064 E14° 22.645',
|
||||
'S 50 04.064 E 014 22.645',
|
||||
'S50 4.064 E14 22.645',
|
||||
"S50° 04.064 E14° 22.645",
|
||||
"S 50 04.064 E 014 22.645",
|
||||
"S50 4.064 E14 22.645",
|
||||
"50° 04.064' S, 014° 22.645' E"
|
||||
].each do |code|
|
||||
latlon_check code, -50.06773, 14.37742
|
||||
|
@ -162,12 +162,12 @@ class GeocoderControllerTest < ActionController::TestCase
|
|||
# Test identification of lat/lon pairs using S/W with degrees/mins
|
||||
def test_identify_latlon_sw_dm
|
||||
[
|
||||
'S 50° 04.064 W 014° 22.645',
|
||||
"S 50° 04.064 W 014° 22.645",
|
||||
"S 50° 04.064' W 014° 22.645",
|
||||
"S 50° 04.064', W 014° 22.645'",
|
||||
'S50° 04.064 W14° 22.645',
|
||||
'S 50 04.064 W 014 22.645',
|
||||
'S50 4.064 W14 22.645',
|
||||
"S50° 04.064 W14° 22.645",
|
||||
"S 50 04.064 W 014 22.645",
|
||||
"S50 4.064 W14 22.645",
|
||||
"50° 04.064' S, 014° 22.645' W"
|
||||
].each do |code|
|
||||
latlon_check code, -50.06773, -14.37742
|
||||
|
@ -181,8 +181,8 @@ class GeocoderControllerTest < ActionController::TestCase
|
|||
"N 50° 4' 03.828\" E 14° 22' 38.712\"",
|
||||
"N 50° 4' 03.828\", E 14° 22' 38.712\"",
|
||||
"N 50° 4′ 03.828″, E 14° 22′ 38.712″",
|
||||
'N50 4 03.828 E14 22 38.712',
|
||||
'N50 4 03.828, E14 22 38.712',
|
||||
"N50 4 03.828 E14 22 38.712",
|
||||
"N50 4 03.828, E14 22 38.712",
|
||||
"50°4'3.828\"N 14°22'38.712\"E"
|
||||
].each do |code|
|
||||
latlon_check code, 50.06773, 14.37742
|
||||
|
@ -196,8 +196,8 @@ class GeocoderControllerTest < ActionController::TestCase
|
|||
"N 50° 4' 03.828\" W 14° 22' 38.712\"",
|
||||
"N 50° 4' 03.828\", W 14° 22' 38.712\"",
|
||||
"N 50° 4′ 03.828″, W 14° 22′ 38.712″",
|
||||
'N50 4 03.828 W14 22 38.712',
|
||||
'N50 4 03.828, W14 22 38.712',
|
||||
"N50 4 03.828 W14 22 38.712",
|
||||
"N50 4 03.828, W14 22 38.712",
|
||||
"50°4'3.828\"N 14°22'38.712\"W"
|
||||
].each do |code|
|
||||
latlon_check code, 50.06773, -14.37742
|
||||
|
@ -211,8 +211,8 @@ class GeocoderControllerTest < ActionController::TestCase
|
|||
"S 50° 4' 03.828\" E 14° 22' 38.712\"",
|
||||
"S 50° 4' 03.828\", E 14° 22' 38.712\"",
|
||||
"S 50° 4′ 03.828″, E 14° 22′ 38.712″",
|
||||
'S50 4 03.828 E14 22 38.712',
|
||||
'S50 4 03.828, E14 22 38.712',
|
||||
"S50 4 03.828 E14 22 38.712",
|
||||
"S50 4 03.828, E14 22 38.712",
|
||||
"50°4'3.828\"S 14°22'38.712\"E"
|
||||
].each do |code|
|
||||
latlon_check code, -50.06773, 14.37742
|
||||
|
@ -226,8 +226,8 @@ class GeocoderControllerTest < ActionController::TestCase
|
|||
"S 50° 4' 03.828\" W 14° 22' 38.712\"",
|
||||
"S 50° 4' 03.828\", W 14° 22' 38.712\"",
|
||||
"S 50° 4′ 03.828″, W 14° 22′ 38.712″",
|
||||
'S50 4 03.828 W14 22 38.712',
|
||||
'S50 4 03.828, W14 22 38.712',
|
||||
"S50 4 03.828 W14 22 38.712",
|
||||
"S50 4 03.828, W14 22 38.712",
|
||||
"50°4'3.828\"S 14°22'38.712\"W"
|
||||
].each do |code|
|
||||
latlon_check code, -50.06773, -14.37742
|
||||
|
@ -238,8 +238,8 @@ class GeocoderControllerTest < ActionController::TestCase
|
|||
# Test identification of US zipcodes
|
||||
def test_identify_us_postcode
|
||||
[
|
||||
'12345',
|
||||
'12345-6789'
|
||||
"12345",
|
||||
"12345-6789"
|
||||
].each do |code|
|
||||
post :search, query: code
|
||||
assert_response :success
|
||||
|
@ -252,12 +252,12 @@ class GeocoderControllerTest < ActionController::TestCase
|
|||
# http://en.wikipedia.org/wiki/Postcodes_in_the_United_Kingdom
|
||||
def test_identify_uk_postcode
|
||||
[
|
||||
'EC1A 1BB',
|
||||
'W1A 1HQ',
|
||||
'M1 1AA',
|
||||
'B33 8TH',
|
||||
'CR2 6XH',
|
||||
'DN55 1PT'
|
||||
"EC1A 1BB",
|
||||
"W1A 1HQ",
|
||||
"M1 1AA",
|
||||
"B33 8TH",
|
||||
"CR2 6XH",
|
||||
"DN55 1PT"
|
||||
].each do |code|
|
||||
search_check code, %w(uk_postcode osm_nominatim)
|
||||
end
|
||||
|
@ -266,13 +266,13 @@ class GeocoderControllerTest < ActionController::TestCase
|
|||
##
|
||||
# Test identification of Canadian postcodes
|
||||
def test_identify_ca_postcode
|
||||
search_check 'A1B 2C3', %w(ca_postcode osm_nominatim)
|
||||
search_check "A1B 2C3", %w(ca_postcode osm_nominatim)
|
||||
end
|
||||
|
||||
##
|
||||
# Test identification fall through to the default case
|
||||
def test_identify_default
|
||||
search_check 'foo bar baz', ['osm_nominatim']
|
||||
search_check "foo bar baz", ["osm_nominatim"]
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require 'test_helper'
|
||||
require "test_helper"
|
||||
|
||||
class MessageControllerTest < ActionController::TestCase
|
||||
fixtures :users, :messages
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require 'test_helper'
|
||||
require "test_helper"
|
||||
|
||||
class NodeControllerTest < ActionController::TestCase
|
||||
api_fixtures
|
||||
|
@ -39,7 +39,7 @@ class NodeControllerTest < ActionController::TestCase
|
|||
changeset = changesets(:normal_user_first_change)
|
||||
# create a minimal xml file
|
||||
content("<osm><node lat='#{lat}' lon='#{lon}' changeset='#{changeset.id}'/></osm>")
|
||||
assert_difference('OldNode.count', 0) do
|
||||
assert_difference("OldNode.count", 0) do
|
||||
put :create
|
||||
end
|
||||
# hope for unauthorized
|
||||
|
@ -55,7 +55,7 @@ class NodeControllerTest < ActionController::TestCase
|
|||
changeset = changesets(:normal_user_first_change)
|
||||
# create a minimal xml file
|
||||
content("<osm><node lat='#{lat}' lon='#{lon}' changeset='#{changeset.id}'/></osm>")
|
||||
assert_difference('Node.count', 0) do
|
||||
assert_difference("Node.count", 0) do
|
||||
put :create
|
||||
end
|
||||
# hope for success
|
||||
|
@ -298,19 +298,19 @@ class NodeControllerTest < ActionController::TestCase
|
|||
assert_require_public_data("update with changeset=0 should be forbidden, when data isn't public")
|
||||
|
||||
## try and submit invalid updates
|
||||
content xml_attr_rewrite(current_nodes(:visible_node).to_xml, 'lat', 91.0)
|
||||
content xml_attr_rewrite(current_nodes(:visible_node).to_xml, "lat", 91.0)
|
||||
put :update, :id => current_nodes(:visible_node).id
|
||||
assert_require_public_data "node at lat=91 should be forbidden, when data isn't public"
|
||||
|
||||
content xml_attr_rewrite(current_nodes(:visible_node).to_xml, 'lat', -91.0)
|
||||
content xml_attr_rewrite(current_nodes(:visible_node).to_xml, "lat", -91.0)
|
||||
put :update, :id => current_nodes(:visible_node).id
|
||||
assert_require_public_data "node at lat=-91 should be forbidden, when data isn't public"
|
||||
|
||||
content xml_attr_rewrite(current_nodes(:visible_node).to_xml, 'lon', 181.0)
|
||||
content xml_attr_rewrite(current_nodes(:visible_node).to_xml, "lon", 181.0)
|
||||
put :update, :id => current_nodes(:visible_node).id
|
||||
assert_require_public_data "node at lon=181 should be forbidden, when data isn't public"
|
||||
|
||||
content xml_attr_rewrite(current_nodes(:visible_node).to_xml, 'lon', -181.0)
|
||||
content xml_attr_rewrite(current_nodes(:visible_node).to_xml, "lon", -181.0)
|
||||
put :update, :id => current_nodes(:visible_node).id
|
||||
assert_require_public_data "node at lon=-181 should be forbidden, when data isn't public"
|
||||
|
||||
|
@ -350,19 +350,19 @@ class NodeControllerTest < ActionController::TestCase
|
|||
assert_response :conflict, "update with changeset=0 should be rejected"
|
||||
|
||||
## try and submit invalid updates
|
||||
content xml_attr_rewrite(current_nodes(:visible_node).to_xml, 'lat', 91.0)
|
||||
content xml_attr_rewrite(current_nodes(:visible_node).to_xml, "lat", 91.0)
|
||||
put :update, :id => current_nodes(:visible_node).id
|
||||
assert_response :bad_request, "node at lat=91 should be rejected"
|
||||
|
||||
content xml_attr_rewrite(current_nodes(:visible_node).to_xml, 'lat', -91.0)
|
||||
content xml_attr_rewrite(current_nodes(:visible_node).to_xml, "lat", -91.0)
|
||||
put :update, :id => current_nodes(:visible_node).id
|
||||
assert_response :bad_request, "node at lat=-91 should be rejected"
|
||||
|
||||
content xml_attr_rewrite(current_nodes(:visible_node).to_xml, 'lon', 181.0)
|
||||
content xml_attr_rewrite(current_nodes(:visible_node).to_xml, "lon", 181.0)
|
||||
put :update, :id => current_nodes(:visible_node).id
|
||||
assert_response :bad_request, "node at lon=181 should be rejected"
|
||||
|
||||
content xml_attr_rewrite(current_nodes(:visible_node).to_xml, 'lon', -181.0)
|
||||
content xml_attr_rewrite(current_nodes(:visible_node).to_xml, "lon", -181.0)
|
||||
put :update, :id => current_nodes(:visible_node).id
|
||||
assert_response :bad_request, "node at lon=-181 should be rejected"
|
||||
|
||||
|
@ -371,19 +371,19 @@ class NodeControllerTest < ActionController::TestCase
|
|||
|
||||
# try and submit a version behind
|
||||
content xml_attr_rewrite(current_nodes(:visible_node).to_xml,
|
||||
'version', current_node_version - 1)
|
||||
"version", current_node_version - 1)
|
||||
put :update, :id => current_nodes(:visible_node).id
|
||||
assert_response :conflict, "should have failed on old version number"
|
||||
|
||||
# try and submit a version ahead
|
||||
content xml_attr_rewrite(current_nodes(:visible_node).to_xml,
|
||||
'version', current_node_version + 1)
|
||||
"version", current_node_version + 1)
|
||||
put :update, :id => current_nodes(:visible_node).id
|
||||
assert_response :conflict, "should have failed on skipped version number"
|
||||
|
||||
# try and submit total crap in the version field
|
||||
content xml_attr_rewrite(current_nodes(:visible_node).to_xml,
|
||||
'version', 'p1r4t3s!')
|
||||
"version", "p1r4t3s!")
|
||||
put :update, :id => current_nodes(:visible_node).id
|
||||
assert_response :conflict,
|
||||
"should not be able to put 'p1r4at3s!' in the version field"
|
||||
|
@ -442,8 +442,8 @@ class NodeControllerTest < ActionController::TestCase
|
|||
|
||||
# add an identical tag to the node
|
||||
tag_xml = XML::Node.new("tag")
|
||||
tag_xml['k'] = current_node_tags(:public_v_t1).k
|
||||
tag_xml['v'] = current_node_tags(:public_v_t1).v
|
||||
tag_xml["k"] = current_node_tags(:public_v_t1).k
|
||||
tag_xml["v"] = current_node_tags(:public_v_t1).v
|
||||
|
||||
# add the tag into the existing xml
|
||||
node_xml = current_nodes(:public_visible_node).to_xml
|
||||
|
@ -467,7 +467,7 @@ class NodeControllerTest < ActionController::TestCase
|
|||
# use unquoted and therefore allow code injection...
|
||||
content "<osm><node lat='0' lon='0' changeset='#{changeset_id}'>" +
|
||||
'<tag k="#{@user.inspect}" v="0"/>' +
|
||||
'</node></osm>'
|
||||
"</node></osm>"
|
||||
put :create
|
||||
assert_require_public_data "Shouldn't be able to create with non-public user"
|
||||
|
||||
|
@ -479,7 +479,7 @@ class NodeControllerTest < ActionController::TestCase
|
|||
# use unquoted and therefore allow code injection...
|
||||
content "<osm><node lat='0' lon='0' changeset='#{changeset_id}'>" +
|
||||
'<tag k="#{@user.inspect}" v="0"/>' +
|
||||
'</node></osm>'
|
||||
"</node></osm>"
|
||||
put :create
|
||||
assert_response :success
|
||||
nodeid = @response.body
|
||||
|
@ -496,7 +496,7 @@ class NodeControllerTest < ActionController::TestCase
|
|||
|
||||
# check the tags are not corrupted
|
||||
assert_equal checknode.tags, apinode.tags
|
||||
assert apinode.tags.include?('#{@user.inspect}')
|
||||
assert apinode.tags.include?("\#{@user.inspect}")
|
||||
end
|
||||
|
||||
def basic_authorization(user, pass)
|
||||
|
@ -510,7 +510,7 @@ class NodeControllerTest < ActionController::TestCase
|
|||
##
|
||||
# update the changeset_id of a node element
|
||||
def update_changeset(xml, changeset_id)
|
||||
xml_attr_rewrite(xml, 'changeset', changeset_id)
|
||||
xml_attr_rewrite(xml, "changeset", changeset_id)
|
||||
end
|
||||
|
||||
##
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require 'test_helper'
|
||||
require "test_helper"
|
||||
|
||||
class NotesControllerTest < ActionController::TestCase
|
||||
fixtures :users, :notes, :note_comments
|
||||
|
@ -122,8 +122,8 @@ class NotesControllerTest < ActionController::TestCase
|
|||
end
|
||||
|
||||
def test_create_success
|
||||
assert_difference('Note.count') do
|
||||
assert_difference('NoteComment.count') do
|
||||
assert_difference("Note.count") do
|
||||
assert_difference("NoteComment.count") do
|
||||
post :create, :lat => -1.0, :lon => -1.0, :text => "This is a comment", :format => "json"
|
||||
end
|
||||
end
|
||||
|
@ -156,65 +156,65 @@ class NotesControllerTest < ActionController::TestCase
|
|||
end
|
||||
|
||||
def test_create_fail
|
||||
assert_no_difference('Note.count') do
|
||||
assert_no_difference('NoteComment.count') do
|
||||
assert_no_difference("Note.count") do
|
||||
assert_no_difference("NoteComment.count") do
|
||||
post :create, :lon => -1.0, :text => "This is a comment"
|
||||
end
|
||||
end
|
||||
assert_response :bad_request
|
||||
|
||||
assert_no_difference('Note.count') do
|
||||
assert_no_difference('NoteComment.count') do
|
||||
assert_no_difference("Note.count") do
|
||||
assert_no_difference("NoteComment.count") do
|
||||
post :create, :lat => -1.0, :text => "This is a comment"
|
||||
end
|
||||
end
|
||||
assert_response :bad_request
|
||||
|
||||
assert_no_difference('Note.count') do
|
||||
assert_no_difference('NoteComment.count') do
|
||||
assert_no_difference("Note.count") do
|
||||
assert_no_difference("NoteComment.count") do
|
||||
post :create, :lat => -1.0, :lon => -1.0
|
||||
end
|
||||
end
|
||||
assert_response :bad_request
|
||||
|
||||
assert_no_difference('Note.count') do
|
||||
assert_no_difference('NoteComment.count') do
|
||||
assert_no_difference("Note.count") do
|
||||
assert_no_difference("NoteComment.count") do
|
||||
post :create, :lat => -1.0, :lon => -1.0, :text => ""
|
||||
end
|
||||
end
|
||||
assert_response :bad_request
|
||||
|
||||
assert_no_difference('Note.count') do
|
||||
assert_no_difference('NoteComment.count') do
|
||||
assert_no_difference("Note.count") do
|
||||
assert_no_difference("NoteComment.count") do
|
||||
post :create, :lat => -100.0, :lon => -1.0, :text => "This is a comment"
|
||||
end
|
||||
end
|
||||
assert_response :bad_request
|
||||
|
||||
assert_no_difference('Note.count') do
|
||||
assert_no_difference('NoteComment.count') do
|
||||
assert_no_difference("Note.count") do
|
||||
assert_no_difference("NoteComment.count") do
|
||||
post :create, :lat => -1.0, :lon => -200.0, :text => "This is a comment"
|
||||
end
|
||||
end
|
||||
assert_response :bad_request
|
||||
|
||||
assert_no_difference('Note.count') do
|
||||
assert_no_difference('NoteComment.count') do
|
||||
post :create, :lat => 'abc', :lon => -1.0, :text => "This is a comment"
|
||||
assert_no_difference("Note.count") do
|
||||
assert_no_difference("NoteComment.count") do
|
||||
post :create, :lat => "abc", :lon => -1.0, :text => "This is a comment"
|
||||
end
|
||||
end
|
||||
assert_response :bad_request
|
||||
|
||||
assert_no_difference('Note.count') do
|
||||
assert_no_difference('NoteComment.count') do
|
||||
post :create, :lat => -1.0, :lon => 'abc', :text => "This is a comment"
|
||||
assert_no_difference("Note.count") do
|
||||
assert_no_difference("NoteComment.count") do
|
||||
post :create, :lat => -1.0, :lon => "abc", :text => "This is a comment"
|
||||
end
|
||||
end
|
||||
assert_response :bad_request
|
||||
end
|
||||
|
||||
def test_comment_success
|
||||
assert_difference('NoteComment.count') do
|
||||
assert_difference("NoteComment.count") do
|
||||
post :comment, :id => notes(:open_note_with_comment).id, :text => "This is an additional comment", :format => "json"
|
||||
end
|
||||
assert_response :success
|
||||
|
@ -242,32 +242,32 @@ class NotesControllerTest < ActionController::TestCase
|
|||
end
|
||||
|
||||
def test_comment_fail
|
||||
assert_no_difference('NoteComment.count') do
|
||||
assert_no_difference("NoteComment.count") do
|
||||
post :comment, :text => "This is an additional comment"
|
||||
end
|
||||
assert_response :bad_request
|
||||
|
||||
assert_no_difference('NoteComment.count') do
|
||||
assert_no_difference("NoteComment.count") do
|
||||
post :comment, :id => notes(:open_note_with_comment).id
|
||||
end
|
||||
assert_response :bad_request
|
||||
|
||||
assert_no_difference('NoteComment.count') do
|
||||
assert_no_difference("NoteComment.count") do
|
||||
post :comment, :id => notes(:open_note_with_comment).id, :text => ""
|
||||
end
|
||||
assert_response :bad_request
|
||||
|
||||
assert_no_difference('NoteComment.count') do
|
||||
assert_no_difference("NoteComment.count") do
|
||||
post :comment, :id => 12345, :text => "This is an additional comment"
|
||||
end
|
||||
assert_response :not_found
|
||||
|
||||
assert_no_difference('NoteComment.count') do
|
||||
assert_no_difference("NoteComment.count") do
|
||||
post :comment, :id => notes(:hidden_note_with_comment).id, :text => "This is an additional comment"
|
||||
end
|
||||
assert_response :gone
|
||||
|
||||
assert_no_difference('NoteComment.count') do
|
||||
assert_no_difference("NoteComment.count") do
|
||||
post :comment, :id => notes(:closed_note_with_comment).id, :text => "This is an additional comment"
|
||||
end
|
||||
assert_response :conflict
|
||||
|
@ -478,7 +478,7 @@ class NotesControllerTest < ActionController::TestCase
|
|||
assert_equal "This is a hide comment", js["properties"]["comments"].last["text"]
|
||||
assert_equal "moderator", js["properties"]["comments"].last["user"]
|
||||
|
||||
get :show, :id => notes(:open_note_with_comment).id, :format => 'json'
|
||||
get :show, :id => notes(:open_note_with_comment).id, :format => "json"
|
||||
assert_response :gone
|
||||
end
|
||||
|
||||
|
@ -501,7 +501,7 @@ class NotesControllerTest < ActionController::TestCase
|
|||
end
|
||||
|
||||
def test_index_success
|
||||
get :index, :bbox => '1,1,1.2,1.2', :format => 'rss'
|
||||
get :index, :bbox => "1,1,1.2,1.2", :format => "rss"
|
||||
assert_response :success
|
||||
assert_equal "application/rss+xml", @response.content_type
|
||||
assert_select "rss", :count => 1 do
|
||||
|
@ -510,7 +510,7 @@ class NotesControllerTest < ActionController::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
get :index, :bbox => '1,1,1.2,1.2', :format => 'json'
|
||||
get :index, :bbox => "1,1,1.2,1.2", :format => "json"
|
||||
assert_response :success
|
||||
assert_equal "application/json", @response.content_type
|
||||
js = ActiveSupport::JSON.decode(@response.body)
|
||||
|
@ -518,14 +518,14 @@ class NotesControllerTest < ActionController::TestCase
|
|||
assert_equal "FeatureCollection", js["type"]
|
||||
assert_equal 2, js["features"].count
|
||||
|
||||
get :index, :bbox => '1,1,1.2,1.2', :format => 'xml'
|
||||
get :index, :bbox => "1,1,1.2,1.2", :format => "xml"
|
||||
assert_response :success
|
||||
assert_equal "application/xml", @response.content_type
|
||||
assert_select "osm", :count => 1 do
|
||||
assert_select "note", :count => 2
|
||||
end
|
||||
|
||||
get :index, :bbox => '1,1,1.2,1.2', :format => 'gpx'
|
||||
get :index, :bbox => "1,1,1.2,1.2", :format => "gpx"
|
||||
assert_response :success
|
||||
assert_equal "application/gpx+xml", @response.content_type
|
||||
assert_select "gpx", :count => 1 do
|
||||
|
@ -534,7 +534,7 @@ class NotesControllerTest < ActionController::TestCase
|
|||
end
|
||||
|
||||
def test_index_empty_area
|
||||
get :index, :bbox => '5,5,5.1,5.1', :format => 'rss'
|
||||
get :index, :bbox => "5,5,5.1,5.1", :format => "rss"
|
||||
assert_response :success
|
||||
assert_equal "application/rss+xml", @response.content_type
|
||||
assert_select "rss", :count => 1 do
|
||||
|
@ -543,7 +543,7 @@ class NotesControllerTest < ActionController::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
get :index, :bbox => '5,5,5.1,5.1', :format => 'json'
|
||||
get :index, :bbox => "5,5,5.1,5.1", :format => "json"
|
||||
assert_response :success
|
||||
assert_equal "application/json", @response.content_type
|
||||
js = ActiveSupport::JSON.decode(@response.body)
|
||||
|
@ -551,14 +551,14 @@ class NotesControllerTest < ActionController::TestCase
|
|||
assert_equal "FeatureCollection", js["type"]
|
||||
assert_equal 0, js["features"].count
|
||||
|
||||
get :index, :bbox => '5,5,5.1,5.1', :format => 'xml'
|
||||
get :index, :bbox => "5,5,5.1,5.1", :format => "xml"
|
||||
assert_response :success
|
||||
assert_equal "application/xml", @response.content_type
|
||||
assert_select "osm", :count => 1 do
|
||||
assert_select "note", :count => 0
|
||||
end
|
||||
|
||||
get :index, :bbox => '5,5,5.1,5.1', :format => 'gpx'
|
||||
get :index, :bbox => "5,5,5.1,5.1", :format => "gpx"
|
||||
assert_response :success
|
||||
assert_equal "application/gpx+xml", @response.content_type
|
||||
assert_select "gpx", :count => 1 do
|
||||
|
@ -567,25 +567,25 @@ class NotesControllerTest < ActionController::TestCase
|
|||
end
|
||||
|
||||
def test_index_large_area
|
||||
get :index, :bbox => '-2.5,-2.5,2.5,2.5', :format => :json
|
||||
get :index, :bbox => "-2.5,-2.5,2.5,2.5", :format => :json
|
||||
assert_response :success
|
||||
assert_equal "application/json", @response.content_type
|
||||
|
||||
get :index, :l => '-2.5', :b => '-2.5', :r => '2.5', :t => '2.5', :format => :json
|
||||
get :index, :l => "-2.5", :b => "-2.5", :r => "2.5", :t => "2.5", :format => :json
|
||||
assert_response :success
|
||||
assert_equal "application/json", @response.content_type
|
||||
|
||||
get :index, :bbox => '-10,-10,12,12', :format => :json
|
||||
get :index, :bbox => "-10,-10,12,12", :format => :json
|
||||
assert_response :bad_request
|
||||
assert_equal "text/plain", @response.content_type
|
||||
|
||||
get :index, :l => '-10', :b => '-10', :r => '12', :t => '12', :format => :json
|
||||
get :index, :l => "-10", :b => "-10", :r => "12", :t => "12", :format => :json
|
||||
assert_response :bad_request
|
||||
assert_equal "text/plain", @response.content_type
|
||||
end
|
||||
|
||||
def test_index_closed
|
||||
get :index, :bbox => '1,1,1.7,1.7', :closed => '7', :format => 'json'
|
||||
get :index, :bbox => "1,1,1.7,1.7", :closed => "7", :format => "json"
|
||||
assert_response :success
|
||||
assert_equal "application/json", @response.content_type
|
||||
js = ActiveSupport::JSON.decode(@response.body)
|
||||
|
@ -593,7 +593,7 @@ class NotesControllerTest < ActionController::TestCase
|
|||
assert_equal "FeatureCollection", js["type"]
|
||||
assert_equal 4, js["features"].count
|
||||
|
||||
get :index, :bbox => '1,1,1.7,1.7', :closed => '0', :format => 'json'
|
||||
get :index, :bbox => "1,1,1.7,1.7", :closed => "0", :format => "json"
|
||||
assert_response :success
|
||||
assert_equal "application/json", @response.content_type
|
||||
js = ActiveSupport::JSON.decode(@response.body)
|
||||
|
@ -601,7 +601,7 @@ class NotesControllerTest < ActionController::TestCase
|
|||
assert_equal "FeatureCollection", js["type"]
|
||||
assert_equal 4, js["features"].count
|
||||
|
||||
get :index, :bbox => '1,1,1.7,1.7', :closed => '-1', :format => 'json'
|
||||
get :index, :bbox => "1,1,1.7,1.7", :closed => "-1", :format => "json"
|
||||
assert_response :success
|
||||
assert_equal "application/json", @response.content_type
|
||||
js = ActiveSupport::JSON.decode(@response.body)
|
||||
|
@ -611,40 +611,40 @@ class NotesControllerTest < ActionController::TestCase
|
|||
end
|
||||
|
||||
def test_index_bad_params
|
||||
get :index, :bbox => '-2.5,-2.5,2.5'
|
||||
get :index, :bbox => "-2.5,-2.5,2.5"
|
||||
assert_response :bad_request
|
||||
|
||||
get :index, :bbox => '-2.5,-2.5,2.5,2.5,2.5'
|
||||
get :index, :bbox => "-2.5,-2.5,2.5,2.5,2.5"
|
||||
assert_response :bad_request
|
||||
|
||||
get :index, :b => '-2.5', :r => '2.5', :t => '2.5'
|
||||
get :index, :b => "-2.5", :r => "2.5", :t => "2.5"
|
||||
assert_response :bad_request
|
||||
|
||||
get :index, :l => '-2.5', :r => '2.5', :t => '2.5'
|
||||
get :index, :l => "-2.5", :r => "2.5", :t => "2.5"
|
||||
assert_response :bad_request
|
||||
|
||||
get :index, :l => '-2.5', :b => '-2.5', :t => '2.5'
|
||||
get :index, :l => "-2.5", :b => "-2.5", :t => "2.5"
|
||||
assert_response :bad_request
|
||||
|
||||
get :index, :l => '-2.5', :b => '-2.5', :r => '2.5'
|
||||
get :index, :l => "-2.5", :b => "-2.5", :r => "2.5"
|
||||
assert_response :bad_request
|
||||
|
||||
get :index, :bbox => '1,1,1.7,1.7', :limit => '0', :format => 'json'
|
||||
get :index, :bbox => "1,1,1.7,1.7", :limit => "0", :format => "json"
|
||||
assert_response :bad_request
|
||||
|
||||
get :index, :bbox => '1,1,1.7,1.7', :limit => '10001', :format => 'json'
|
||||
get :index, :bbox => "1,1,1.7,1.7", :limit => "10001", :format => "json"
|
||||
assert_response :bad_request
|
||||
end
|
||||
|
||||
def test_search_success
|
||||
get :search, :q => 'note 1', :format => 'xml'
|
||||
get :search, :q => "note 1", :format => "xml"
|
||||
assert_response :success
|
||||
assert_equal "application/xml", @response.content_type
|
||||
assert_select "osm", :count => 1 do
|
||||
assert_select "note", :count => 1
|
||||
end
|
||||
|
||||
get :search, :q => 'note 1', :format => 'json'
|
||||
get :search, :q => "note 1", :format => "json"
|
||||
assert_response :success
|
||||
assert_equal "application/json", @response.content_type
|
||||
js = ActiveSupport::JSON.decode(@response.body)
|
||||
|
@ -652,7 +652,7 @@ class NotesControllerTest < ActionController::TestCase
|
|||
assert_equal "FeatureCollection", js["type"]
|
||||
assert_equal 1, js["features"].count
|
||||
|
||||
get :search, :q => 'note 1', :format => 'rss'
|
||||
get :search, :q => "note 1", :format => "rss"
|
||||
assert_response :success
|
||||
assert_equal "application/rss+xml", @response.content_type
|
||||
assert_select "rss", :count => 1 do
|
||||
|
@ -661,7 +661,7 @@ class NotesControllerTest < ActionController::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
get :search, :q => 'note 1', :format => 'gpx'
|
||||
get :search, :q => "note 1", :format => "gpx"
|
||||
assert_response :success
|
||||
assert_equal "application/gpx+xml", @response.content_type
|
||||
assert_select "gpx", :count => 1 do
|
||||
|
@ -670,14 +670,14 @@ class NotesControllerTest < ActionController::TestCase
|
|||
end
|
||||
|
||||
def test_search_no_match
|
||||
get :search, :q => 'no match', :format => 'xml'
|
||||
get :search, :q => "no match", :format => "xml"
|
||||
assert_response :success
|
||||
assert_equal "application/xml", @response.content_type
|
||||
assert_select "osm", :count => 1 do
|
||||
assert_select "note", :count => 0
|
||||
end
|
||||
|
||||
get :search, :q => 'no match', :format => 'json'
|
||||
get :search, :q => "no match", :format => "json"
|
||||
assert_response :success
|
||||
assert_equal "application/json", @response.content_type
|
||||
js = ActiveSupport::JSON.decode(@response.body)
|
||||
|
@ -685,7 +685,7 @@ class NotesControllerTest < ActionController::TestCase
|
|||
assert_equal "FeatureCollection", js["type"]
|
||||
assert_equal 0, js["features"].count
|
||||
|
||||
get :search, :q => 'no match', :format => 'rss'
|
||||
get :search, :q => "no match", :format => "rss"
|
||||
assert_response :success
|
||||
assert_equal "application/rss+xml", @response.content_type
|
||||
assert_select "rss", :count => 1 do
|
||||
|
@ -694,7 +694,7 @@ class NotesControllerTest < ActionController::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
get :search, :q => 'no match', :format => 'gpx'
|
||||
get :search, :q => "no match", :format => "gpx"
|
||||
assert_response :success
|
||||
assert_equal "application/gpx+xml", @response.content_type
|
||||
assert_select "gpx", :count => 1 do
|
||||
|
@ -706,10 +706,10 @@ class NotesControllerTest < ActionController::TestCase
|
|||
get :search
|
||||
assert_response :bad_request
|
||||
|
||||
get :search, :q => 'no match', :limit => '0', :format => 'json'
|
||||
get :search, :q => "no match", :limit => "0", :format => "json"
|
||||
assert_response :bad_request
|
||||
|
||||
get :search, :q => 'no match', :limit => '10001', :format => 'json'
|
||||
get :search, :q => "no match", :limit => "10001", :format => "json"
|
||||
assert_response :bad_request
|
||||
end
|
||||
|
||||
|
@ -740,10 +740,10 @@ class NotesControllerTest < ActionController::TestCase
|
|||
get :feed, :bbox => "1,1,1.2,1.2,1.2", :format => "rss"
|
||||
assert_response :bad_request
|
||||
|
||||
get :feed, :bbox => "1,1,1.2,1.2", :limit => '0', :format => "rss"
|
||||
get :feed, :bbox => "1,1,1.2,1.2", :limit => "0", :format => "rss"
|
||||
assert_response :bad_request
|
||||
|
||||
get :feed, :bbox => "1,1,1.2,1.2", :limit => '10001', :format => "rss"
|
||||
get :feed, :bbox => "1,1,1.2,1.2", :limit => "10001", :format => "rss"
|
||||
assert_response :bad_request
|
||||
end
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require 'test_helper'
|
||||
require "test_helper"
|
||||
|
||||
class OauthClientsControllerTest < ActionController::TestCase
|
||||
fixtures :users, :client_applications
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require 'test_helper'
|
||||
require "test_helper"
|
||||
|
||||
class OauthControllerTest < ActionController::TestCase
|
||||
##
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
require 'test_helper'
|
||||
require 'old_node_controller'
|
||||
require "test_helper"
|
||||
require "old_node_controller"
|
||||
|
||||
class OldNodeControllerTest < ActionController::TestCase
|
||||
api_fixtures
|
||||
|
@ -46,38 +46,38 @@ class OldNodeControllerTest < ActionController::TestCase
|
|||
versions = {}
|
||||
|
||||
# save a version for later checking
|
||||
versions[xml_node['version']] = xml_doc.to_s
|
||||
versions[xml_node["version"]] = xml_doc.to_s
|
||||
|
||||
# randomly move the node about
|
||||
20.times do
|
||||
# move the node somewhere else
|
||||
xml_node['lat'] = precision(rand * 180 - 90).to_s
|
||||
xml_node['lon'] = precision(rand * 360 - 180).to_s
|
||||
xml_node["lat"] = precision(rand * 180 - 90).to_s
|
||||
xml_node["lon"] = precision(rand * 360 - 180).to_s
|
||||
with_controller(NodeController.new) do
|
||||
content xml_doc
|
||||
put :update, :id => nodeid
|
||||
assert_response :forbidden, "Should have rejected node update"
|
||||
xml_node['version'] = @response.body.to_s
|
||||
xml_node["version"] = @response.body.to_s
|
||||
end
|
||||
# save a version for later checking
|
||||
versions[xml_node['version']] = xml_doc.to_s
|
||||
versions[xml_node["version"]] = xml_doc.to_s
|
||||
end
|
||||
|
||||
# add a bunch of random tags
|
||||
30.times do
|
||||
xml_tag = XML::Node.new("tag")
|
||||
xml_tag['k'] = random_string
|
||||
xml_tag['v'] = random_string
|
||||
xml_tag["k"] = random_string
|
||||
xml_tag["v"] = random_string
|
||||
xml_node << xml_tag
|
||||
with_controller(NodeController.new) do
|
||||
content xml_doc
|
||||
put :update, :id => nodeid
|
||||
assert_response :forbidden,
|
||||
"should have rejected node #{nodeid} (#{@response.body}) with forbidden"
|
||||
xml_node['version'] = @response.body.to_s
|
||||
xml_node["version"] = @response.body.to_s
|
||||
end
|
||||
# save a version for later checking
|
||||
versions[xml_node['version']] = xml_doc.to_s
|
||||
versions[xml_node["version"]] = xml_doc.to_s
|
||||
end
|
||||
|
||||
# probably should check that they didn't get written to the database
|
||||
|
@ -95,38 +95,38 @@ class OldNodeControllerTest < ActionController::TestCase
|
|||
versions = {}
|
||||
|
||||
# save a version for later checking
|
||||
versions[xml_node['version']] = xml_doc.to_s
|
||||
versions[xml_node["version"]] = xml_doc.to_s
|
||||
|
||||
# randomly move the node about
|
||||
20.times do
|
||||
# move the node somewhere else
|
||||
xml_node['lat'] = precision(rand * 180 - 90).to_s
|
||||
xml_node['lon'] = precision(rand * 360 - 180).to_s
|
||||
xml_node["lat"] = precision(rand * 180 - 90).to_s
|
||||
xml_node["lon"] = precision(rand * 360 - 180).to_s
|
||||
with_controller(NodeController.new) do
|
||||
content xml_doc
|
||||
put :update, :id => nodeid
|
||||
assert_response :success
|
||||
xml_node['version'] = @response.body.to_s
|
||||
xml_node["version"] = @response.body.to_s
|
||||
end
|
||||
# save a version for later checking
|
||||
versions[xml_node['version']] = xml_doc.to_s
|
||||
versions[xml_node["version"]] = xml_doc.to_s
|
||||
end
|
||||
|
||||
# add a bunch of random tags
|
||||
30.times do
|
||||
xml_tag = XML::Node.new("tag")
|
||||
xml_tag['k'] = random_string
|
||||
xml_tag['v'] = random_string
|
||||
xml_tag["k"] = random_string
|
||||
xml_tag["v"] = random_string
|
||||
xml_node << xml_tag
|
||||
with_controller(NodeController.new) do
|
||||
content xml_doc
|
||||
put :update, :id => nodeid
|
||||
assert_response :success,
|
||||
"couldn't update node #{nodeid} (#{@response.body})"
|
||||
xml_node['version'] = @response.body.to_s
|
||||
xml_node["version"] = @response.body.to_s
|
||||
end
|
||||
# save a version for later checking
|
||||
versions[xml_node['version']] = xml_doc.to_s
|
||||
versions[xml_node["version"]] = xml_doc.to_s
|
||||
end
|
||||
|
||||
# check all the versions
|
||||
|
@ -244,14 +244,14 @@ class OldNodeControllerTest < ActionController::TestCase
|
|||
# the appropriate flag
|
||||
get :version, :id => node.node_id, :version => node.version
|
||||
assert_response :forbidden, "After redaction, node should be gone for moderator, when flag not passed."
|
||||
get :version, :id => node.node_id, :version => node.version, :show_redactions => 'true'
|
||||
get :version, :id => node.node_id, :version => node.version, :show_redactions => "true"
|
||||
assert_response :success, "After redaction, node should not be gone for moderator, when flag passed."
|
||||
|
||||
# and when accessed via history
|
||||
get :history, :id => node.node_id
|
||||
assert_response :success, "Redaction shouldn't have stopped history working."
|
||||
assert_select "osm node[id='#{node.node_id}'][version='#{node.version}']", 0, "node #{node.node_id} version #{node.version} should not be present in the history for moderators when not passing flag."
|
||||
get :history, :id => node.node_id, :show_redactions => 'true'
|
||||
get :history, :id => node.node_id, :show_redactions => "true"
|
||||
assert_response :success, "Redaction 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 still be present in the history for moderators when passing flag."
|
||||
end
|
||||
|
@ -308,10 +308,10 @@ class OldNodeControllerTest < ActionController::TestCase
|
|||
# returns a 16 character long string with some nasty characters in it.
|
||||
# this ought to stress-test the tag handling as well as the versioning.
|
||||
def random_string
|
||||
letters = [['!', '"', '$', '&', ';', '@'],
|
||||
('a'..'z').to_a,
|
||||
('A'..'Z').to_a,
|
||||
('0'..'9').to_a].flatten
|
||||
letters = [["!", '"', "$", "&", ";", "@"],
|
||||
("a".."z").to_a,
|
||||
("A".."Z").to_a,
|
||||
("0".."9").to_a].flatten
|
||||
(1..16).map { |_i| letters[rand(letters.length)] }.join
|
||||
end
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
require 'test_helper'
|
||||
require 'old_relation_controller'
|
||||
require "test_helper"
|
||||
require "old_relation_controller"
|
||||
|
||||
class OldRelationControllerTest < ActionController::TestCase
|
||||
api_fixtures
|
||||
|
@ -111,14 +111,14 @@ class OldRelationControllerTest < ActionController::TestCase
|
|||
# the appropriate flag
|
||||
get :version, :id => relation.relation_id, :version => relation.version
|
||||
assert_response :forbidden, "After redaction, node should be gone for moderator, when flag not passed."
|
||||
get :version, :id => relation.relation_id, :version => relation.version, :show_redactions => 'true'
|
||||
get :version, :id => relation.relation_id, :version => relation.version, :show_redactions => "true"
|
||||
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}']", 0, "relation #{relation.relation_id} version #{relation.version} should not be present in the history for moderators when not passing flag."
|
||||
get :history, :id => relation.relation_id, :show_redactions => 'true'
|
||||
get :history, :id => relation.relation_id, :show_redactions => "true"
|
||||
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
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
require 'test_helper'
|
||||
require 'old_way_controller'
|
||||
require "test_helper"
|
||||
require "old_way_controller"
|
||||
|
||||
class OldWayControllerTest < ActionController::TestCase
|
||||
api_fixtures
|
||||
|
@ -137,14 +137,14 @@ class OldWayControllerTest < ActionController::TestCase
|
|||
# the appropriate flag
|
||||
get :version, :id => way.way_id, :version => way.version
|
||||
assert_response :forbidden, "After redaction, node should be gone for moderator, when flag not passed."
|
||||
get :version, :id => way.way_id, :version => way.version, :show_redactions => 'true'
|
||||
get :version, :id => way.way_id, :version => way.version, :show_redactions => "true"
|
||||
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}']", 0, "way #{way.way_id} version #{way.version} should not be present in the history for moderators when not passing flag."
|
||||
get :history, :id => way.way_id, :show_redactions => 'true'
|
||||
get :history, :id => way.way_id, :show_redactions => "true"
|
||||
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
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
require 'test_helper'
|
||||
require 'redactions_controller'
|
||||
require "test_helper"
|
||||
require "redactions_controller"
|
||||
|
||||
class RedactionsControllerTest < ActionController::TestCase
|
||||
api_fixtures
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
require 'test_helper'
|
||||
require 'relation_controller'
|
||||
require "test_helper"
|
||||
require "relation_controller"
|
||||
|
||||
class RelationControllerTest < ActionController::TestCase
|
||||
api_fixtures
|
||||
|
@ -337,7 +337,7 @@ class RelationControllerTest < ActionController::TestCase
|
|||
with_relation(rel_id) do |rel|
|
||||
# alter one of the tags
|
||||
tag = rel.find("//osm/relation/tag").first
|
||||
tag['v'] = 'some changed value'
|
||||
tag["v"] = "some changed value"
|
||||
update_changeset(rel, cs_id)
|
||||
|
||||
# check that the downloaded tags are the same as the uploaded tags...
|
||||
|
@ -366,7 +366,7 @@ class RelationControllerTest < ActionController::TestCase
|
|||
with_relation(rel_id) do |rel|
|
||||
# alter one of the tags
|
||||
tag = rel.find("//osm/relation/tag").first
|
||||
tag['v'] = 'some changed value'
|
||||
tag["v"] = "some changed value"
|
||||
update_changeset(rel, cs_id)
|
||||
|
||||
# check that the downloaded tags are the same as the uploaded tags...
|
||||
|
@ -566,8 +566,8 @@ class RelationControllerTest < ActionController::TestCase
|
|||
relation_xml = current_relations(:visible_relation).to_xml
|
||||
relation_element = relation_xml.find("//osm/relation").first
|
||||
new_tag = XML::Node.new("tag")
|
||||
new_tag['k'] = "some_new_tag"
|
||||
new_tag['v'] = "some_new_value"
|
||||
new_tag["k"] = "some_new_tag"
|
||||
new_tag["v"] = "some_new_value"
|
||||
relation_element << new_tag
|
||||
|
||||
# update changeset ID to point to new changeset
|
||||
|
@ -596,9 +596,9 @@ class RelationControllerTest < ActionController::TestCase
|
|||
relation_xml = Relation.find(relation_id).to_xml
|
||||
relation_element = relation_xml.find("//osm/relation").first
|
||||
new_member = XML::Node.new("member")
|
||||
new_member['ref'] = element.id.to_s
|
||||
new_member['type'] = element.class.to_s.downcase
|
||||
new_member['role'] = "some_role"
|
||||
new_member["ref"] = element.id.to_s
|
||||
new_member["type"] = element.class.to_s.downcase
|
||||
new_member["role"] = "some_role"
|
||||
relation_element << new_member
|
||||
|
||||
# update changeset ID to point to new changeset
|
||||
|
@ -667,13 +667,13 @@ OSM
|
|||
|
||||
# insert a member at the front
|
||||
new_member = XML::Node.new "member"
|
||||
new_member['ref'] = 5.to_s
|
||||
new_member['type'] = 'node'
|
||||
new_member['role'] = 'new first'
|
||||
new_member["ref"] = 5.to_s
|
||||
new_member["type"] = "node"
|
||||
new_member["role"] = "new first"
|
||||
doc.find("//osm/relation").first.child.prev = new_member
|
||||
# update the version, should be 1?
|
||||
doc.find("//osm/relation").first['id'] = relation_id.to_s
|
||||
doc.find("//osm/relation").first['version'] = 1.to_s
|
||||
doc.find("//osm/relation").first["id"] = relation_id.to_s
|
||||
doc.find("//osm/relation").first["version"] = 1.to_s
|
||||
|
||||
# upload the next version of the relation
|
||||
content doc
|
||||
|
@ -800,11 +800,11 @@ OSM
|
|||
new_doc = XML::Parser.string(xml).parse
|
||||
|
||||
doc_members = doc.find("//osm/relation/member").collect do |m|
|
||||
[m['ref'].to_i, m['type'].to_sym, m['role']]
|
||||
[m["ref"].to_i, m["type"].to_sym, m["role"]]
|
||||
end
|
||||
|
||||
new_members = new_doc.find("//osm/relation/member").collect do |m|
|
||||
[m['ref'].to_i, m['type'].to_sym, m['role']]
|
||||
[m["ref"].to_i, m["type"].to_sym, m["role"]]
|
||||
end
|
||||
|
||||
doc_members.zip(new_members).each do |d, n|
|
||||
|
@ -898,14 +898,14 @@ OSM
|
|||
# the parsed XML doc is retured.
|
||||
def with_update_diff(rel)
|
||||
rel_id = rel.find("//osm/relation").first["id"].to_i
|
||||
cs_id = rel.find("//osm/relation").first['changeset'].to_i
|
||||
cs_id = rel.find("//osm/relation").first["changeset"].to_i
|
||||
version = nil
|
||||
|
||||
with_controller(ChangesetController.new) do
|
||||
doc = OSM::API.new.get_xml_doc
|
||||
change = XML::Node.new 'osmChange'
|
||||
change = XML::Node.new "osmChange"
|
||||
doc.root = change
|
||||
modify = XML::Node.new 'modify'
|
||||
modify = XML::Node.new "modify"
|
||||
change << modify
|
||||
modify << doc.import(rel.find("//osm/relation").first)
|
||||
|
||||
|
@ -928,8 +928,8 @@ OSM
|
|||
##
|
||||
# returns a k->v hash of tags from an xml doc
|
||||
def get_tags_as_hash(a)
|
||||
a.find("//osm/relation/tag").sort_by { |v| v['k'] }.each_with_object({}) do |v, h|
|
||||
h[v['k']] = v['v']
|
||||
a.find("//osm/relation/tag").sort_by { |v| v["k"] }.each_with_object({}) do |v, h|
|
||||
h[v["k"]] = v["v"]
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -952,7 +952,7 @@ OSM
|
|||
##
|
||||
# update the changeset_id of a node element
|
||||
def update_changeset(xml, changeset_id)
|
||||
xml_attr_rewrite(xml, 'changeset', changeset_id)
|
||||
xml_attr_rewrite(xml, "changeset", changeset_id)
|
||||
end
|
||||
|
||||
##
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require 'test_helper'
|
||||
require "test_helper"
|
||||
|
||||
class SearchControllerTest < ActionController::TestCase
|
||||
##
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require 'test_helper'
|
||||
require "test_helper"
|
||||
|
||||
class SiteControllerTest < ActionController::TestCase
|
||||
api_fixtures
|
||||
|
@ -86,56 +86,56 @@ class SiteControllerTest < ActionController::TestCase
|
|||
def test_index
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_template 'index'
|
||||
assert_template "index"
|
||||
end
|
||||
|
||||
# Test the index page redirects
|
||||
def test_index_redirect
|
||||
get :index, :lat => 4, :lon => 5
|
||||
assert_redirected_to :controller => :site, :action => :index, :anchor => 'map=5/4/5'
|
||||
assert_redirected_to :controller => :site, :action => :index, :anchor => "map=5/4/5"
|
||||
|
||||
get :index, :lat => 4, :lon => 5, :zoom => 3
|
||||
assert_redirected_to :controller => :site, :action => :index, :anchor => 'map=3/4/5'
|
||||
assert_redirected_to :controller => :site, :action => :index, :anchor => "map=3/4/5"
|
||||
|
||||
get :index, :layers => 'T'
|
||||
assert_redirected_to :controller => :site, :action => :index, :anchor => 'layers=T'
|
||||
get :index, :layers => "T"
|
||||
assert_redirected_to :controller => :site, :action => :index, :anchor => "layers=T"
|
||||
|
||||
get :index, :notes => 'yes'
|
||||
assert_redirected_to :controller => :site, :action => :index, :anchor => 'layers=N'
|
||||
get :index, :notes => "yes"
|
||||
assert_redirected_to :controller => :site, :action => :index, :anchor => "layers=N"
|
||||
|
||||
get :index, :lat => 4, :lon => 5, :zoom => 3, :layers => 'T'
|
||||
assert_redirected_to :controller => :site, :action => :index, :anchor => 'map=3/4/5&layers=T'
|
||||
get :index, :lat => 4, :lon => 5, :zoom => 3, :layers => "T"
|
||||
assert_redirected_to :controller => :site, :action => :index, :anchor => "map=3/4/5&layers=T"
|
||||
end
|
||||
|
||||
# Test the permalink redirect
|
||||
def test_permalink
|
||||
get :permalink, :code => 'wBz3--'
|
||||
get :permalink, :code => "wBz3--"
|
||||
assert_response :redirect
|
||||
assert_redirected_to :controller => :site, :action => :index, :anchor => 'map=3/4.8779296875/3.955078125'
|
||||
assert_redirected_to :controller => :site, :action => :index, :anchor => "map=3/4.8779296875/3.955078125"
|
||||
|
||||
get :permalink, :code => 'wBz3--', :m => ''
|
||||
get :permalink, :code => "wBz3--", :m => ""
|
||||
assert_response :redirect
|
||||
assert_redirected_to :controller => :site, :action => :index, :mlat => '4.8779296875', :mlon => '3.955078125', :anchor => 'map=3/4.8779296875/3.955078125'
|
||||
assert_redirected_to :controller => :site, :action => :index, :mlat => "4.8779296875", :mlon => "3.955078125", :anchor => "map=3/4.8779296875/3.955078125"
|
||||
|
||||
get :permalink, :code => 'wBz3--', :layers => 'T'
|
||||
get :permalink, :code => "wBz3--", :layers => "T"
|
||||
assert_response :redirect
|
||||
assert_redirected_to :controller => :site, :action => :index, :anchor => 'map=3/4.8779296875/3.955078125&layers=T'
|
||||
assert_redirected_to :controller => :site, :action => :index, :anchor => "map=3/4.8779296875/3.955078125&layers=T"
|
||||
|
||||
get :permalink, :code => 'wBz3--', :node => 1
|
||||
get :permalink, :code => "wBz3--", :node => 1
|
||||
assert_response :redirect
|
||||
assert_redirected_to :controller => :browse, :action => :node, :id => 1, :anchor => 'map=3/4.8779296875/3.955078125'
|
||||
assert_redirected_to :controller => :browse, :action => :node, :id => 1, :anchor => "map=3/4.8779296875/3.955078125"
|
||||
|
||||
get :permalink, :code => 'wBz3--', :way => 2
|
||||
get :permalink, :code => "wBz3--", :way => 2
|
||||
assert_response :redirect
|
||||
assert_redirected_to :controller => :browse, :action => :way, :id => 2, :anchor => 'map=3/4.8779296875/3.955078125'
|
||||
assert_redirected_to :controller => :browse, :action => :way, :id => 2, :anchor => "map=3/4.8779296875/3.955078125"
|
||||
|
||||
get :permalink, :code => 'wBz3--', :relation => 3
|
||||
get :permalink, :code => "wBz3--", :relation => 3
|
||||
assert_response :redirect
|
||||
assert_redirected_to :controller => :browse, :action => :relation, :id => 3, :anchor => 'map=3/4.8779296875/3.955078125'
|
||||
assert_redirected_to :controller => :browse, :action => :relation, :id => 3, :anchor => "map=3/4.8779296875/3.955078125"
|
||||
|
||||
get :permalink, :code => 'wBz3--', :changeset => 4
|
||||
get :permalink, :code => "wBz3--", :changeset => 4
|
||||
assert_response :redirect
|
||||
assert_redirected_to :controller => :browse, :action => :changeset, :id => 4, :anchor => 'map=3/4.8779296875/3.955078125'
|
||||
assert_redirected_to :controller => :browse, :action => :changeset, :id => 4, :anchor => "map=3/4.8779296875/3.955078125"
|
||||
end
|
||||
|
||||
# Test the key page
|
||||
|
@ -254,13 +254,13 @@ class SiteControllerTest < ActionController::TestCase
|
|||
# Test the edit page redirects
|
||||
def test_edit_redirect
|
||||
get :edit, :lat => 4, :lon => 5
|
||||
assert_redirected_to :controller => :site, :action => :edit, :anchor => 'map=5/4/5'
|
||||
assert_redirected_to :controller => :site, :action => :edit, :anchor => "map=5/4/5"
|
||||
|
||||
get :edit, :lat => 4, :lon => 5, :zoom => 3
|
||||
assert_redirected_to :controller => :site, :action => :edit, :anchor => 'map=3/4/5'
|
||||
assert_redirected_to :controller => :site, :action => :edit, :anchor => "map=3/4/5"
|
||||
|
||||
get :edit, :lat => 4, :lon => 5, :zoom => 3, :editor => 'id'
|
||||
assert_redirected_to :controller => :site, :action => :edit, :editor => 'id', :anchor => 'map=3/4/5'
|
||||
get :edit, :lat => 4, :lon => 5, :zoom => 3, :editor => "id"
|
||||
assert_redirected_to :controller => :site, :action => :edit, :editor => "id", :anchor => "map=3/4/5"
|
||||
end
|
||||
|
||||
# Test the copyright page
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require 'test_helper'
|
||||
require "test_helper"
|
||||
|
||||
class SwfControllerTest < ActionController::TestCase
|
||||
##
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require 'test_helper'
|
||||
require "test_helper"
|
||||
|
||||
class TraceControllerTest < ActionController::TestCase
|
||||
fixtures :users, :gpx_files
|
||||
|
@ -173,11 +173,11 @@ class TraceControllerTest < ActionController::TestCase
|
|||
def test_list_mine
|
||||
# First try to get it when not logged in
|
||||
get :mine
|
||||
assert_redirected_to :controller => 'user', :action => 'login', :referer => '/traces/mine'
|
||||
assert_redirected_to :controller => "user", :action => "login", :referer => "/traces/mine"
|
||||
|
||||
# Now try when logged in
|
||||
get :mine, {}, { :user => users(:public_user).id }
|
||||
assert_redirected_to :controller => 'trace', :action => 'list', :display_name => users(:public_user).display_name
|
||||
assert_redirected_to :controller => "trace", :action => "list", :display_name => users(:public_user).display_name
|
||||
|
||||
# Fetch the actual list
|
||||
get :list, { :display_name => users(:public_user).display_name }, { :user => users(:public_user).id }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require 'test_helper'
|
||||
require "test_helper"
|
||||
|
||||
class UserBlocksControllerTest < ActionController::TestCase
|
||||
fixtures :users, :user_roles, :user_blocks
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require 'test_helper'
|
||||
require "test_helper"
|
||||
|
||||
class UserControllerTest < ActionController::TestCase
|
||||
fixtures :users
|
||||
|
@ -222,8 +222,8 @@ class UserControllerTest < ActionController::TestCase
|
|||
def test_user_create_success
|
||||
user = new_user
|
||||
|
||||
assert_difference('User.count', 1) do
|
||||
assert_difference('ActionMailer::Base.deliveries.size', 1) do
|
||||
assert_difference("User.count", 1) do
|
||||
assert_difference("ActionMailer::Base.deliveries.size", 1) do
|
||||
post :save, {}, { :new_user => user }
|
||||
end
|
||||
end
|
||||
|
@ -235,7 +235,7 @@ class UserControllerTest < ActionController::TestCase
|
|||
assert_match /#{@url}/, register_email.body.to_s
|
||||
|
||||
# Check the page
|
||||
assert_redirected_to :action => 'confirm', :display_name => user.display_name
|
||||
assert_redirected_to :action => "confirm", :display_name => user.display_name
|
||||
|
||||
ActionMailer::Base.deliveries.clear
|
||||
end
|
||||
|
@ -244,14 +244,14 @@ class UserControllerTest < ActionController::TestCase
|
|||
user = new_user
|
||||
user.email = users(:public_user).email
|
||||
|
||||
assert_no_difference('User.count') do
|
||||
assert_no_difference('ActionMailer::Base.deliveries.size') do
|
||||
assert_no_difference("User.count") do
|
||||
assert_no_difference("ActionMailer::Base.deliveries.size") do
|
||||
post :save, {}, { :new_user => user }
|
||||
end
|
||||
end
|
||||
|
||||
assert_response :success
|
||||
assert_template 'new'
|
||||
assert_template "new"
|
||||
assert_select "form > fieldset > div.form-row > input.field_with_errors#user_email"
|
||||
end
|
||||
|
||||
|
@ -259,14 +259,14 @@ class UserControllerTest < ActionController::TestCase
|
|||
user = new_user
|
||||
user.email = users(:public_user).email.upcase
|
||||
|
||||
assert_no_difference('User.count') do
|
||||
assert_no_difference('ActionMailer::Base.deliveries.size') do
|
||||
assert_no_difference("User.count") do
|
||||
assert_no_difference("ActionMailer::Base.deliveries.size") do
|
||||
post :save, {}, { :new_user => user }
|
||||
end
|
||||
end
|
||||
|
||||
assert_response :success
|
||||
assert_template 'new'
|
||||
assert_template "new"
|
||||
assert_select "form > fieldset > div.form-row > input.field_with_errors#user_email"
|
||||
end
|
||||
|
||||
|
@ -274,14 +274,14 @@ class UserControllerTest < ActionController::TestCase
|
|||
user = new_user
|
||||
user.display_name = users(:public_user).display_name
|
||||
|
||||
assert_no_difference('User.count') do
|
||||
assert_no_difference('ActionMailer::Base.deliveries.size') do
|
||||
assert_no_difference("User.count") do
|
||||
assert_no_difference("ActionMailer::Base.deliveries.size") do
|
||||
post :save, {}, { :new_user => user }
|
||||
end
|
||||
end
|
||||
|
||||
assert_response :success
|
||||
assert_template 'new'
|
||||
assert_template "new"
|
||||
assert_select "form > fieldset > div.form-row > input.field_with_errors#user_display_name"
|
||||
end
|
||||
|
||||
|
@ -289,28 +289,28 @@ class UserControllerTest < ActionController::TestCase
|
|||
user = new_user
|
||||
user.display_name = users(:public_user).display_name.upcase
|
||||
|
||||
assert_no_difference('User.count') do
|
||||
assert_no_difference('ActionMailer::Base.deliveries.size') do
|
||||
assert_no_difference("User.count") do
|
||||
assert_no_difference("ActionMailer::Base.deliveries.size") do
|
||||
post :save, {}, { :new_user => user }
|
||||
end
|
||||
end
|
||||
|
||||
assert_response :success
|
||||
assert_template 'new'
|
||||
assert_template "new"
|
||||
assert_select "form > fieldset > div.form-row > input.field_with_errors#user_display_name"
|
||||
end
|
||||
|
||||
def test_user_save_referer_params
|
||||
user = new_user
|
||||
|
||||
assert_difference('User.count', 1) do
|
||||
assert_difference('ActionMailer::Base.deliveries.size', 1) do
|
||||
assert_difference("User.count", 1) do
|
||||
assert_difference("ActionMailer::Base.deliveries.size", 1) do
|
||||
post :save, {}, { :new_user => user,
|
||||
:referer => '/edit?editor=id#map=1/2/3' }
|
||||
:referer => "/edit?editor=id#map=1/2/3" }
|
||||
end
|
||||
end
|
||||
|
||||
assert_equal welcome_path(:editor => 'id', :zoom => 1, :lat => 2, :lon => 3),
|
||||
assert_equal welcome_path(:editor => "id", :zoom => 1, :lat => 2, :lon => 3),
|
||||
user.tokens.order("id DESC").first.referer
|
||||
|
||||
ActionMailer::Base.deliveries.clear
|
||||
|
@ -325,7 +325,7 @@ class UserControllerTest < ActionController::TestCase
|
|||
@request.cookies["_osm_session"] = user.display_name
|
||||
post :confirm, :confirm_string => token.token
|
||||
|
||||
assert_redirected_to :action => 'confirm'
|
||||
assert_redirected_to :action => "confirm"
|
||||
assert_match /expired/, flash[:error]
|
||||
end
|
||||
|
||||
|
@ -336,7 +336,7 @@ class UserControllerTest < ActionController::TestCase
|
|||
@request.cookies["_osm_session"] = user.display_name
|
||||
post :confirm, :confirm_string => token.token
|
||||
|
||||
assert_redirected_to :action => 'login'
|
||||
assert_redirected_to :action => "login"
|
||||
assert_match /confirmed/, flash[:error]
|
||||
end
|
||||
|
||||
|
@ -370,7 +370,7 @@ class UserControllerTest < ActionController::TestCase
|
|||
|
||||
# Test resetting using the address as recorded for a user that has an
|
||||
# address which is duplicated in a different case by another user
|
||||
assert_difference('ActionMailer::Base.deliveries.size', 1) do
|
||||
assert_difference("ActionMailer::Base.deliveries.size", 1) do
|
||||
post :lost_password, :user => { :email => users(:normal_user).email }
|
||||
end
|
||||
assert_response :redirect
|
||||
|
@ -383,7 +383,7 @@ class UserControllerTest < ActionController::TestCase
|
|||
|
||||
# Test resetting using an address that matches a different user
|
||||
# that has the same address in a different case
|
||||
assert_difference('ActionMailer::Base.deliveries.size', 1) do
|
||||
assert_difference("ActionMailer::Base.deliveries.size", 1) do
|
||||
post :lost_password, :user => { :email => users(:normal_user).email.upcase }
|
||||
end
|
||||
assert_response :redirect
|
||||
|
@ -396,7 +396,7 @@ class UserControllerTest < ActionController::TestCase
|
|||
|
||||
# Test resetting using an address that is a case insensitive match
|
||||
# for more than one user but not an exact match for either
|
||||
assert_difference('ActionMailer::Base.deliveries.size', 0) do
|
||||
assert_difference("ActionMailer::Base.deliveries.size", 0) do
|
||||
post :lost_password, :user => { :email => users(:normal_user).email.titlecase }
|
||||
end
|
||||
assert_response :success
|
||||
|
@ -405,7 +405,7 @@ class UserControllerTest < ActionController::TestCase
|
|||
|
||||
# Test resetting using the address as recorded for a user that has an
|
||||
# address which is case insensitively unique
|
||||
assert_difference('ActionMailer::Base.deliveries.size', 1) do
|
||||
assert_difference("ActionMailer::Base.deliveries.size", 1) do
|
||||
post :lost_password, :user => { :email => users(:public_user).email }
|
||||
end
|
||||
assert_response :redirect
|
||||
|
@ -418,7 +418,7 @@ class UserControllerTest < ActionController::TestCase
|
|||
|
||||
# Test resetting using an address that matches a user that has the
|
||||
# same (case insensitively unique) address in a different case
|
||||
assert_difference('ActionMailer::Base.deliveries.size', 1) do
|
||||
assert_difference("ActionMailer::Base.deliveries.size", 1) do
|
||||
post :lost_password, :user => { :email => users(:public_user).email.upcase }
|
||||
end
|
||||
assert_response :redirect
|
||||
|
@ -521,7 +521,7 @@ class UserControllerTest < ActionController::TestCase
|
|||
|
||||
# Changing email to one that exists should fail
|
||||
user.new_email = users(:public_user).email
|
||||
assert_no_difference('ActionMailer::Base.deliveries.size') do
|
||||
assert_no_difference("ActionMailer::Base.deliveries.size") do
|
||||
post :account, { :display_name => user.display_name, :user => user.attributes }, { "user" => user.id }
|
||||
end
|
||||
assert_response :success
|
||||
|
@ -532,7 +532,7 @@ class UserControllerTest < ActionController::TestCase
|
|||
|
||||
# Changing email to one that exists should fail, regardless of case
|
||||
user.new_email = users(:public_user).email.upcase
|
||||
assert_no_difference('ActionMailer::Base.deliveries.size') do
|
||||
assert_no_difference("ActionMailer::Base.deliveries.size") do
|
||||
post :account, { :display_name => user.display_name, :user => user.attributes }, { "user" => user.id }
|
||||
end
|
||||
assert_response :success
|
||||
|
@ -543,7 +543,7 @@ class UserControllerTest < ActionController::TestCase
|
|||
|
||||
# Changing email to one that doesn't exist should work
|
||||
user.new_email = "new_tester@example.com"
|
||||
assert_difference('ActionMailer::Base.deliveries.size', 1) do
|
||||
assert_difference("ActionMailer::Base.deliveries.size", 1) do
|
||||
post :account, { :display_name => user.display_name, :user => user.attributes }, { "user" => user.id }
|
||||
end
|
||||
assert_response :success
|
||||
|
@ -772,7 +772,7 @@ class UserControllerTest < ActionController::TestCase
|
|||
assert_nil Friend.where(:user_id => user.id, :friend_user_id => friend.id).first
|
||||
|
||||
# When logged in a POST should add the friendship
|
||||
assert_difference('ActionMailer::Base.deliveries.size', 1) do
|
||||
assert_difference("ActionMailer::Base.deliveries.size", 1) do
|
||||
post :make_friend, { :display_name => friend.display_name }, { "user" => user }
|
||||
end
|
||||
assert_redirected_to user_path(:display_name => friend.display_name)
|
||||
|
@ -784,7 +784,7 @@ class UserControllerTest < ActionController::TestCase
|
|||
ActionMailer::Base.deliveries.clear
|
||||
|
||||
# A second POST should report that the friendship already exists
|
||||
assert_no_difference('ActionMailer::Base.deliveries.size') do
|
||||
assert_no_difference("ActionMailer::Base.deliveries.size") do
|
||||
post :make_friend, { :display_name => friend.display_name }, { "user" => user }
|
||||
end
|
||||
assert_redirected_to user_path(:display_name => friend.display_name)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require 'test_helper'
|
||||
require "test_helper"
|
||||
|
||||
class UserPreferenceControllerTest < ActionController::TestCase
|
||||
fixtures :users, :user_preferences
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require 'test_helper'
|
||||
require "test_helper"
|
||||
|
||||
class UserRolesControllerTest < ActionController::TestCase
|
||||
fixtures :users, :user_roles
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
require 'test_helper'
|
||||
require 'way_controller'
|
||||
require "test_helper"
|
||||
require "way_controller"
|
||||
|
||||
class WayControllerTest < ActionController::TestCase
|
||||
api_fixtures
|
||||
|
@ -369,8 +369,8 @@ class WayControllerTest < ActionController::TestCase
|
|||
|
||||
# add an identical tag to the way
|
||||
tag_xml = XML::Node.new("tag")
|
||||
tag_xml['k'] = current_way_tags(:t1).k
|
||||
tag_xml['v'] = current_way_tags(:t1).v
|
||||
tag_xml["k"] = current_way_tags(:t1).k
|
||||
tag_xml["v"] = current_way_tags(:t1).v
|
||||
|
||||
# add the tag into the existing xml
|
||||
way_xml = current_ways(:visible_way).to_xml
|
||||
|
@ -388,8 +388,8 @@ class WayControllerTest < ActionController::TestCase
|
|||
|
||||
# add an identical tag to the way
|
||||
tag_xml = XML::Node.new("tag")
|
||||
tag_xml['k'] = current_way_tags(:t1).k
|
||||
tag_xml['v'] = current_way_tags(:t1).v
|
||||
tag_xml["k"] = current_way_tags(:t1).k
|
||||
tag_xml["v"] = current_way_tags(:t1).v
|
||||
|
||||
# add the tag into the existing xml
|
||||
way_xml = current_ways(:visible_way).to_xml
|
||||
|
@ -412,8 +412,8 @@ class WayControllerTest < ActionController::TestCase
|
|||
|
||||
# create duplicate tag
|
||||
tag_xml = XML::Node.new("tag")
|
||||
tag_xml['k'] = "i_am_a_duplicate"
|
||||
tag_xml['v'] = "foobar"
|
||||
tag_xml["k"] = "i_am_a_duplicate"
|
||||
tag_xml["v"] = "foobar"
|
||||
|
||||
# add the tag into the existing xml
|
||||
way_xml = current_ways(:visible_way).to_xml
|
||||
|
@ -433,8 +433,8 @@ class WayControllerTest < ActionController::TestCase
|
|||
|
||||
# create duplicate tag
|
||||
tag_xml = XML::Node.new("tag")
|
||||
tag_xml['k'] = "i_am_a_duplicate"
|
||||
tag_xml['v'] = "foobar"
|
||||
tag_xml["k"] = "i_am_a_duplicate"
|
||||
tag_xml["v"] = "foobar"
|
||||
|
||||
# add the tag into the existing xml
|
||||
way_xml = current_ways(:visible_way).to_xml
|
||||
|
@ -519,7 +519,7 @@ class WayControllerTest < ActionController::TestCase
|
|||
##
|
||||
# update the changeset_id of a node element
|
||||
def update_changeset(xml, changeset_id)
|
||||
xml_attr_rewrite(xml, 'changeset', changeset_id)
|
||||
xml_attr_rewrite(xml, "changeset", changeset_id)
|
||||
end
|
||||
|
||||
##
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue