From: Tom Hughes Date: Sat, 10 Jan 2015 12:33:36 +0000 (+0000) Subject: Fix invalid CSS selectors X-Git-Tag: live~4811 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/6af8f8a9e37e92c139779fbb5fb2590ad040993e?ds=sidebyside Fix invalid CSS selectors --- diff --git a/test/controllers/api_controller_test.rb b/test/controllers/api_controller_test.rb index 6426184fc..a0421c033 100644 --- a/test/controllers/api_controller_test.rb +++ b/test/controllers/api_controller_test.rb @@ -67,8 +67,8 @@ class ApiControllerTest < ActionController::TestCase end assert_response :success, "Expected scucess with the map call" assert_select "osm[version='#{API_VERSION}'][generator='#{GENERATOR}']", :count => 1 do - assert_select "bounds[minlon=#{minlon}][minlat=#{minlat}][maxlon=#{maxlon}][maxlat=#{maxlat}]", :count => 1 - assert_select "node[id=#{node.id}][lat=#{node.lat}][lon=#{node.lon}][version=#{node.version}][changeset=#{node.changeset_id}][visible=#{node.visible}][timestamp=#{node.timestamp.xmlschema}]", :count => 1 do + assert_select "bounds[minlon='#{minlon}'][minlat='#{minlat}'][maxlon='#{maxlon}'][maxlat='#{maxlat}']", :count => 1 + assert_select "node[id='#{node.id}'][lat='#{node.lat}'][lon='#{node.lon}'][version='#{node.version}'][changeset='#{node.changeset_id}'][visible='#{node.visible}'][timestamp='#{node.timestamp.xmlschema}']", :count => 1 do # This should really be more generic assert_select "tag[k='test'][v='yes']" end @@ -84,8 +84,8 @@ class ApiControllerTest < ActionController::TestCase get :map, :bbox => bbox assert_response :success, "The map call should have succeeded" assert_select "osm[version='#{API_VERSION}'][generator='#{GENERATOR}']", :count => 1 do - assert_select "bounds[minlon=#{node.lon}][minlat=#{node.lat}][maxlon=#{node.lon}][maxlat=#{node.lat}]", :count => 1 - assert_select "node[id=#{node.id}][lat=#{node.lat}][lon=#{node.lon}][version=#{node.version}][changeset=#{node.changeset_id}][visible=#{node.visible}][timestamp=#{node.timestamp.xmlschema}]", :count => 1 do + assert_select "bounds[minlon='#{node.lon}'][minlat='#{node.lat}'][maxlon='#{node.lon}'][maxlat='#{node.lat}']", :count => 1 + assert_select "node[id='#{node.id}'][lat='#{node.lat}'][lon='#{node.lon}'][version='#{node.version}'][changeset='#{node.changeset_id}'][visible='#{node.visible}'][timestamp='#{node.timestamp.xmlschema}']", :count => 1 do # This should really be more generic assert_select "tag[k='test'][v='yes']" end @@ -102,7 +102,7 @@ class ApiControllerTest < ActionController::TestCase bbox = "#{minlon},#{minlat},#{maxlon},#{maxlat}" get :trackpoints, :bbox => bbox assert_response :success - assert_select "gpx[version=1.0][creator=OpenStreetMap.org][xmlns=http://www.topografix.com/GPX/1/0]", :count => 1 do + assert_select "gpx[version='1.0'][creator='OpenStreetMap.org'][xmlns='http://www.topografix.com/GPX/1/0']", :count => 1 do assert_select "trk" do assert_select "trkseg" end @@ -118,7 +118,7 @@ class ApiControllerTest < ActionController::TestCase bbox = "#{minlon},#{minlat},#{maxlon},#{maxlat}" get :trackpoints, :bbox => bbox assert_response :success - assert_select "gpx[version=1.0][creator=OpenStreetMap.org][xmlns=http://www.topografix.com/GPX/1/0]", :count => 1 do + assert_select "gpx[version='1.0'][creator='OpenStreetMap.org'][xmlns='http://www.topografix.com/GPX/1/0']", :count => 1 do assert_select "trk", :count => 1 do assert_select "trk > trkseg", :count => 2 do |trksegs| trksegs.each do |trkseg| @@ -140,7 +140,7 @@ class ApiControllerTest < ActionController::TestCase bbox = "#{minlon},#{minlat},#{maxlon},#{maxlat}" get :trackpoints, :bbox => bbox assert_response :success - assert_select "gpx[version=1.0][creator=OpenStreetMap.org][xmlns=http://www.topografix.com/GPX/1/0]", :count => 1 do + assert_select "gpx[version='1.0'][creator='OpenStreetMap.org'][xmlns='http://www.topografix.com/GPX/1/0']", :count => 1 do assert_select "trk", :count => 1 do assert_select "trk>name", :count => 1 assert_select "trk>desc", :count => 1 @@ -287,13 +287,13 @@ class ApiControllerTest < ActionController::TestCase assert_response :success assert_select "osm[version='#{API_VERSION}'][generator='#{GENERATOR}']", :count => 1 do assert_select "api", :count => 1 do - assert_select "version[minimum=#{API_VERSION}][maximum=#{API_VERSION}]", :count => 1 - assert_select "area[maximum=#{MAX_REQUEST_AREA}]", :count => 1 - assert_select "tracepoints[per_page=#{TRACEPOINTS_PER_PAGE}]", :count => 1 - assert_select "changesets[maximum_elements=#{Changeset::MAX_ELEMENTS}]", :count => 1 - assert_select "status[database=online]", :count => 1 - assert_select "status[api=online]", :count => 1 - assert_select "status[gpx=online]", :count => 1 + assert_select "version[minimum='#{API_VERSION}'][maximum='#{API_VERSION}']", :count => 1 + assert_select "area[maximum='#{MAX_REQUEST_AREA}']", :count => 1 + assert_select "tracepoints[per_page='#{TRACEPOINTS_PER_PAGE}']", :count => 1 + assert_select "changesets[maximum_elements='#{Changeset::MAX_ELEMENTS}']", :count => 1 + assert_select "status[database='online']", :count => 1 + assert_select "status[api='online']", :count => 1 + assert_select "status[gpx='online']", :count => 1 end end end @@ -313,7 +313,7 @@ class ApiControllerTest < ActionController::TestCase assert_select "osm > permissions", :count => 1 do assert_select "permission", :count => ClientApplication.all_permissions.size ClientApplication.all_permissions.each do |p| - assert_select "permission[name=#{p}]", :count => 1 + assert_select "permission[name='#{p}']", :count => 1 end end end @@ -329,9 +329,9 @@ class ApiControllerTest < ActionController::TestCase assert_response :success assert_select "osm > permissions", :count => 1 do assert_select "permission", :count => 2 - assert_select "permission[name=allow_read_prefs]", :count => 1 - assert_select "permission[name=allow_write_api]", :count => 1 - assert_select "permission[name=allow_read_gpx]", :count => 0 + assert_select "permission[name='allow_read_prefs']", :count => 1 + assert_select "permission[name='allow_write_api']", :count => 1 + assert_select "permission[name='allow_read_gpx']", :count => 0 end end end diff --git a/test/controllers/changeset_controller_test.rb b/test/controllers/changeset_controller_test.rb index 461738330..230c1f014 100644 --- a/test/controllers/changeset_controller_test.rb +++ b/test/controllers/changeset_controller_test.rb @@ -184,15 +184,15 @@ class ChangesetControllerTest < ActionController::TestCase get :read, :id => changeset_id assert_response :success, "cannot get first changeset" - assert_select "osm[version=#{API_VERSION}][generator=\"OpenStreetMap server\"]", 1 - assert_select "osm>changeset[id=#{changeset_id}]", 1 + assert_select "osm[version='#{API_VERSION}'][generator='OpenStreetMap server']", 1 + assert_select "osm>changeset[id='#{changeset_id}']", 1 assert_select "osm>changeset>discussion", 0 get :read, :id => changeset_id, :include_discussion => true assert_response :success, "cannot get first changeset with comments" - assert_select "osm[version=#{API_VERSION}][generator=\"OpenStreetMap server\"]", 1 - assert_select "osm>changeset[id=#{changeset_id}]", 1 + assert_select "osm[version='#{API_VERSION}'][generator='OpenStreetMap server']", 1 + assert_select "osm>changeset[id='#{changeset_id}']", 1 assert_select "osm>changeset>discussion", 1 end @@ -631,7 +631,7 @@ EOF "can't do a conditional delete of in use objects: #{@response.body}" # check the returned payload - assert_select "diffResult[version=#{API_VERSION}][generator=\"OpenStreetMap server\"]", 1 + assert_select "diffResult[version='#{API_VERSION}'][generator='OpenStreetMap server']", 1 assert_select "diffResult>node", 1 assert_select "diffresult>way", 1 assert_select "diffResult>relation", 1 @@ -1207,7 +1207,7 @@ EOF "failed to return error in XML format" # check the returned payload - assert_select "osmError[version=#{API_VERSION}][generator=\"OpenStreetMap server\"]", 1 + assert_select "osmError[version='#{API_VERSION}'][generator='OpenStreetMap server']", 1 assert_select "osmError>status", 1 assert_select "osmError>message", 1 @@ -1395,10 +1395,10 @@ EOF # FIXME needs more assert_select tests assert_select "osmChange[version='#{API_VERSION}'][generator='#{GENERATOR}']" do assert_select "create", :count => 5 - assert_select "create>node[id=#{nodes(:used_node_2).node_id}][visible=#{nodes(:used_node_2).visible?}][version=#{nodes(:used_node_2).version}]" do - assert_select "tag[k=#{node_tags(:t3).k}][v=#{node_tags(:t3).v}]" + assert_select "create>node[id='#{nodes(:used_node_2).node_id}'][visible='#{nodes(:used_node_2).visible?}'][version='#{nodes(:used_node_2).version}']" do + assert_select "tag[k='#{node_tags(:t3).k}'][v='#{node_tags(:t3).v}']" end - assert_select "create>node[id=#{nodes(:visible_node).node_id}]" + assert_select "create>node[id='#{nodes(:visible_node).node_id}']" end end @@ -1424,10 +1424,10 @@ EOF # get the bounding box back from the changeset get :read, :id => changeset_id assert_response :success, "Couldn't read back changeset." - assert_select "osm>changeset[min_lon=1.0]", 1 - assert_select "osm>changeset[max_lon=1.0]", 1 - assert_select "osm>changeset[min_lat=2.0]", 1 - assert_select "osm>changeset[max_lat=2.0]", 1 + assert_select "osm>changeset[min_lon='1.0']", 1 + assert_select "osm>changeset[max_lon='1.0']", 1 + assert_select "osm>changeset[min_lat='2.0']", 1 + assert_select "osm>changeset[max_lat='2.0']", 1 # add another node to it with_controller(NodeController.new) do @@ -1439,10 +1439,10 @@ EOF # get the bounding box back from the changeset get :read, :id => changeset_id assert_response :success, "Couldn't read back changeset for the second time." - assert_select "osm>changeset[min_lon=1.0]", 1 - assert_select "osm>changeset[max_lon=2.0]", 1 - assert_select "osm>changeset[min_lat=1.0]", 1 - assert_select "osm>changeset[max_lat=2.0]", 1 + assert_select "osm>changeset[min_lon='1.0']", 1 + assert_select "osm>changeset[max_lon='2.0']", 1 + assert_select "osm>changeset[min_lat='1.0']", 1 + assert_select "osm>changeset[max_lat='2.0']", 1 # add (delete) a way to it, which contains a point at (3,3) with_controller(WayController.new) do @@ -1456,10 +1456,10 @@ EOF get :read, :id => changeset_id assert_response :success, "Couldn't read back changeset for the third time." # note that the 3.1 here is because of the bbox overexpansion - assert_select "osm>changeset[min_lon=1.0]", 1 - assert_select "osm>changeset[max_lon=3.1]", 1 - assert_select "osm>changeset[min_lat=1.0]", 1 - assert_select "osm>changeset[max_lat=3.1]", 1 + assert_select "osm>changeset[min_lon='1.0']", 1 + assert_select "osm>changeset[max_lon='3.1']", 1 + assert_select "osm>changeset[min_lat='1.0']", 1 + assert_select "osm>changeset[max_lat='3.1']", 1 end ## @@ -1675,7 +1675,7 @@ EOF put :update, :id => changeset.id assert_response :success - assert_select "osm>changeset[id=#{changeset.id}]", 1 + assert_select "osm>changeset[id='#{changeset.id}']", 1 assert_select "osm>changeset>tag", 2 assert_select "osm>changeset>tag[k=tagtesting][v=valuetesting]", 1 end @@ -1876,8 +1876,8 @@ EOF assert_select "osmChange", 1 # this changeset contains node 17 in versions 1 & 2, but 1 should # be hidden. - assert_select "osmChange node[id=17]", 1 - assert_select "osmChange node[id=17][version=1]", 0 + assert_select "osmChange node[id='17']", 1 + assert_select "osmChange node[id='17'][version='1']", 0 end ## @@ -2123,7 +2123,7 @@ EOF def assert_changesets(ids) assert_select "osm>changeset", ids.size ids.each do |id| - assert_select "osm>changeset[id=#{id}]", 1 + assert_select "osm>changeset[id='#{id}']", 1 end end @@ -2136,7 +2136,7 @@ EOF # check exactly one changeset assert_select "osm>changeset", 1 - assert_select "osm>changeset[id=#{changeset_id}]", 1 + assert_select "osm>changeset[id='#{changeset_id}']", 1 # check the bbox doc = XML::Parser.string(@response.body).parse diff --git a/test/controllers/message_controller_test.rb b/test/controllers/message_controller_test.rb index 1d8416880..1476831cf 100644 --- a/test/controllers/message_controller_test.rb +++ b/test/controllers/message_controller_test.rb @@ -78,7 +78,7 @@ class MessageControllerTest < ActionController::TestCase assert_select "title", "OpenStreetMap | Send message" assert_select "form[action='#{new_message_path(:display_name => users(:public_user).display_name)}']", :count => 1 do assert_select "input#message_title", :count => 1 do - assert_select "[value=Test Message]" + assert_select "[value='Test Message']" end assert_select "textarea#message_body", :text => "", :count => 1 assert_select "input[type='submit'][value='Send']", :count => 1 @@ -97,7 +97,7 @@ class MessageControllerTest < ActionController::TestCase assert_select "title", "OpenStreetMap | Send message" assert_select "form[action='#{new_message_path(:display_name => users(:public_user).display_name)}']", :count => 1 do assert_select "input#message_title", :count => 1 do - assert_select "[value=]" + assert_select "[value='']" end assert_select "textarea#message_body", :text => "Test message body", :count => 1 assert_select "input[type='submit'][value='Send']", :count => 1 diff --git a/test/controllers/node_controller_test.rb b/test/controllers/node_controller_test.rb index 3d689bb3f..9663ed4fb 100644 --- a/test/controllers/node_controller_test.rb +++ b/test/controllers/node_controller_test.rb @@ -434,11 +434,11 @@ class NodeControllerTest < ActionController::TestCase assert_response :success assert_select "osm" do assert_select "node", :count => 5 - assert_select "node[id=1][visible=true]", :count => 1 - assert_select "node[id=2][visible=false]", :count => 1 - assert_select "node[id=4][visible=true]", :count => 1 - assert_select "node[id=15][visible=true]", :count => 1 - assert_select "node[id=17][visible=false]", :count => 1 + assert_select "node[id='1'][visible='true']", :count => 1 + assert_select "node[id='2'][visible='false']", :count => 1 + assert_select "node[id='4'][visible='true']", :count => 1 + assert_select "node[id='15'][visible='true']", :count => 1 + assert_select "node[id='17'][visible='false']", :count => 1 end # check error when a non-existent node is included diff --git a/test/controllers/notes_controller_test.rb b/test/controllers/notes_controller_test.rb index 6f2125193..430d018e2 100644 --- a/test/controllers/notes_controller_test.rb +++ b/test/controllers/notes_controller_test.rb @@ -375,7 +375,7 @@ class NotesControllerTest < ActionController::TestCase assert_response :success assert_equal "application/xml", @response.content_type assert_select "osm", :count => 1 do - assert_select "note[lat=#{notes(:open_note).lat}][lon=#{notes(:open_note).lon}]", :count => 1 do + assert_select "note[lat='#{notes(:open_note).lat}'][lon='#{notes(:open_note).lon}']", :count => 1 do assert_select "id", notes(:open_note).id assert_select "url", note_url(notes(:open_note), :format => "xml") assert_select "comment_url", comment_note_url(notes(:open_note), :format => "xml") @@ -424,7 +424,7 @@ class NotesControllerTest < ActionController::TestCase assert_response :success assert_equal "application/gpx+xml", @response.content_type assert_select "gpx", :count => 1 do - assert_select "wpt[lat=#{notes(:open_note).lat}][lon=#{notes(:open_note).lon}]", :count => 1 do + assert_select "wpt[lat='#{notes(:open_note).lat}'][lon='#{notes(:open_note).lon}']", :count => 1 do assert_select "extension", :count => 1 do assert_select "id", notes(:open_note).id assert_select "url", note_url(notes(:open_note), :format => "gpx") diff --git a/test/controllers/old_node_controller_test.rb b/test/controllers/old_node_controller_test.rb index 5b0436348..f4e88ddd0 100644 --- a/test/controllers/old_node_controller_test.rb +++ b/test/controllers/old_node_controller_test.rb @@ -224,13 +224,13 @@ class OldNodeControllerTest < ActionController::TestCase 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, "redacted node #{node.node_id} version #{node.version} shouldn't be present in the history." + assert_select "osm node[id='#{node.node_id}'][version='#{node.version}']", 0, "redacted node #{node.node_id} version #{node.version} shouldn't be present in the history." # not even to a logged-in user basic_authorization(users(:public_user).email, "test") 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, "redacted node #{node.node_id} version #{node.version} shouldn't be present in the history, even when logged in." + assert_select "osm node[id='#{node.node_id}'][version='#{node.version}']", 0, "redacted node #{node.node_id} version #{node.version} shouldn't be present in the history, even when logged in." end ## @@ -253,10 +253,10 @@ class OldNodeControllerTest < ActionController::TestCase # 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." + 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' 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." + 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 # testing that if the moderator drops auth, he can't see the @@ -278,7 +278,7 @@ class OldNodeControllerTest < ActionController::TestCase # 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, "redacted node #{node.node_id} version #{node.version} shouldn't be present in the history." + assert_select "osm node[id='#{node.node_id}'][version='#{node.version}']", 0, "redacted node #{node.node_id} version #{node.version} shouldn't be present in the history." end def do_redact_node(node, redaction) diff --git a/test/controllers/old_relation_controller_test.rb b/test/controllers/old_relation_controller_test.rb index 1db613cd4..ea1550ab4 100644 --- a/test/controllers/old_relation_controller_test.rb +++ b/test/controllers/old_relation_controller_test.rb @@ -87,14 +87,14 @@ class OldRelationControllerTest < ActionController::TestCase 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, "redacted relation #{relation.relation_id} version #{relation.version} shouldn't be present in the history." + assert_select "osm relation[id='#{relation.relation_id}'][version='#{relation.version}']", 0, "redacted relation #{relation.relation_id} version #{relation.version} shouldn't be present in the history." # not even to a logged-in user basic_authorization(users(:public_user).email, "test") get :version, :id => relation.relation_id, :version => relation.version 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, "redacted node #{relation.relation_id} version #{relation.version} shouldn't be present in the history, even when logged in." + assert_select "osm relation[id='#{relation.relation_id}'][version='#{relation.version}']", 0, "redacted node #{relation.relation_id} version #{relation.version} shouldn't be present in the history, even when logged in." end ## @@ -117,10 +117,10 @@ class OldRelationControllerTest < ActionController::TestCase # 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." + 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' 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." + 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 # testing that if the moderator drops auth, he can't see the @@ -142,7 +142,7 @@ class OldRelationControllerTest < ActionController::TestCase # 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, "redacted relation #{relation.relation_id} version #{relation.version} shouldn't be present in the history." + assert_select "osm relation[id='#{relation.relation_id}'][version='#{relation.version}']", 0, "redacted relation #{relation.relation_id} version #{relation.version} shouldn't be present in the history." end ## diff --git a/test/controllers/old_way_controller_test.rb b/test/controllers/old_way_controller_test.rb index 40315caa5..306a48615 100644 --- a/test/controllers/old_way_controller_test.rb +++ b/test/controllers/old_way_controller_test.rb @@ -113,14 +113,14 @@ class OldWayControllerTest < ActionController::TestCase 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, "redacted way #{way.way_id} version #{way.version} shouldn't be present in the history." + assert_select "osm way[id='#{way.way_id}'][version='#{way.version}']", 0, "redacted way #{way.way_id} version #{way.version} shouldn't be present in the history." # not even to a logged-in user basic_authorization(users(:public_user).email, "test") get :version, :id => way.way_id, :version => way.version 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, "redacted node #{way.way_id} version #{way.version} shouldn't be present in the history, even when logged in." + assert_select "osm way[id='#{way.way_id}'][version='#{way.version}']", 0, "redacted node #{way.way_id} version #{way.version} shouldn't be present in the history, even when logged in." end ## @@ -143,10 +143,10 @@ class OldWayControllerTest < ActionController::TestCase # 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." + 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' 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." + 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 # testing that if the moderator drops auth, he can't see the @@ -168,7 +168,7 @@ class OldWayControllerTest < ActionController::TestCase # 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, "redacted way #{way.way_id} version #{way.version} shouldn't be present in the history." + assert_select "osm way[id='#{way.way_id}'][version='#{way.version}']", 0, "redacted way #{way.way_id} version #{way.version} shouldn't be present in the history." end ## diff --git a/test/controllers/relation_controller_test.rb b/test/controllers/relation_controller_test.rb index 66d601284..d7a9bf536 100644 --- a/test/controllers/relation_controller_test.rb +++ b/test/controllers/relation_controller_test.rb @@ -91,7 +91,7 @@ class RelationControllerTest < ActionController::TestCase assert_response :success # count one osm element - assert_select "osm[version=#{API_VERSION}][generator=\"OpenStreetMap server\"]", 1 + assert_select "osm[version='#{API_VERSION}'][generator='OpenStreetMap server']", 1 # we should have only the expected number of relations assert_select "osm>relation", expected_relations.size @@ -99,8 +99,7 @@ class RelationControllerTest < ActionController::TestCase # and each of them should contain the node we originally searched for expected_relations.each do |r| relation_id = current_relations(r).id - assert_select "osm>relation#?", relation_id - assert_select "osm>relation#?>member[type=\"#{type}\"][ref=#{id}]", relation_id + assert_select "osm>relation[id='#{relation_id}']>member[type='#{type}'][ref='#{id}']", 1 end end @@ -130,10 +129,10 @@ class RelationControllerTest < ActionController::TestCase assert_response :success assert_select "osm" do assert_select "relation", :count => 4 - assert_select "relation[id=1][visible=true]", :count => 1 - assert_select "relation[id=2][visible=false]", :count => 1 - assert_select "relation[id=4][visible=true]", :count => 1 - assert_select "relation[id=7][visible=true]", :count => 1 + assert_select "relation[id='1'][visible='true']", :count => 1 + assert_select "relation[id='2'][visible='false']", :count => 1 + assert_select "relation[id='4'][visible='true']", :count => 1 + assert_select "relation[id='7'][visible='true']", :count => 1 end # check error when a non-existent relation is included @@ -862,11 +861,11 @@ OSM get :read, :id => changeset_id assert_response :success, "can't re-read changeset for modify test" assert_select "osm>changeset", 1, "Changeset element doesn't exist in #{@response.body}" - assert_select "osm>changeset[id=#{changeset_id}]", 1, "Changeset id=#{changeset_id} doesn't exist in #{@response.body}" - assert_select "osm>changeset[min_lon=#{bbox.min_lon}]", 1, "Changeset min_lon wrong in #{@response.body}" - assert_select "osm>changeset[min_lat=#{bbox.min_lat}]", 1, "Changeset min_lat wrong in #{@response.body}" - assert_select "osm>changeset[max_lon=#{bbox.max_lon}]", 1, "Changeset max_lon wrong in #{@response.body}" - assert_select "osm>changeset[max_lat=#{bbox.max_lat}]", 1, "Changeset max_lat wrong in #{@response.body}" + assert_select "osm>changeset[id='#{changeset_id}']", 1, "Changeset id=#{changeset_id} doesn't exist in #{@response.body}" + assert_select "osm>changeset[min_lon='#{bbox.min_lon}']", 1, "Changeset min_lon wrong in #{@response.body}" + assert_select "osm>changeset[min_lat='#{bbox.min_lat}']", 1, "Changeset min_lat wrong in #{@response.body}" + assert_select "osm>changeset[max_lon='#{bbox.max_lon}']", 1, "Changeset max_lon wrong in #{@response.body}" + assert_select "osm>changeset[max_lat='#{bbox.max_lat}']", 1, "Changeset max_lat wrong in #{@response.body}" end end diff --git a/test/controllers/user_controller_test.rb b/test/controllers/user_controller_test.rb index a39e07efc..75d057b9f 100644 --- a/test/controllers/user_controller_test.rb +++ b/test/controllers/user_controller_test.rb @@ -195,13 +195,13 @@ class UserControllerTest < ActionController::TestCase end assert_select "body", :count => 1 do assert_select "div#content", :count => 1 do - assert_select "form[action='/user/new'][method=post]", :count => 1 do - assert_select "input[id=user_email]", :count => 1 - assert_select "input[id=user_email_confirmation]", :count => 1 - assert_select "input[id=user_display_name]", :count => 1 - assert_select "input[id=user_pass_crypt][type=password]", :count => 1 - assert_select "input[id=user_pass_crypt_confirmation][type=password]", :count => 1 - assert_select "input[type=submit][value=Sign Up]", :count => 1 + assert_select "form[action='/user/new'][method='post']", :count => 1 do + assert_select "input[id='user_email']", :count => 1 + assert_select "input[id='user_email_confirmation']", :count => 1 + assert_select "input[id='user_display_name']", :count => 1 + assert_select "input[id='user_pass_crypt'][type='password']", :count => 1 + assert_select "input[id='user_pass_crypt_confirmation'][type='password']", :count => 1 + assert_select "input[type='submit'][value='Sign Up']", :count => 1 end end end @@ -568,42 +568,42 @@ class UserControllerTest < ActionController::TestCase get :view, {:display_name => "test"} assert_response :success assert_select "div#userinformation" do - assert_select "a[href^=/user/test/history]", 1 - assert_select "a[href=/user/test/traces]", 1 - assert_select "a[href=/user/test/diary]", 1 - assert_select "a[href=/user/test/diary/comments]", 1 - assert_select "a[href=/user/test/account]", 0 - assert_select "a[href=/user/test/blocks]", 0 - assert_select "a[href=/user/test/blocks_by]", 0 - assert_select "a[href=/blocks/new/test]", 0 + assert_select "a[href^='/user/test/history']", 1 + assert_select "a[href='/user/test/traces']", 1 + assert_select "a[href='/user/test/diary']", 1 + assert_select "a[href='/user/test/diary/comments']", 1 + assert_select "a[href='/user/test/account']", 0 + assert_select "a[href='/user/test/blocks']", 0 + assert_select "a[href='/user/test/blocks_by']", 0 + assert_select "a[href='/blocks/new/test']", 0 end # Test a user who has been blocked get :view, {:display_name => "blocked"} assert_response :success assert_select "div#userinformation" do - assert_select "a[href^=/user/blocked/history]", 1 - assert_select "a[href=/user/blocked/traces]", 1 - assert_select "a[href=/user/blocked/diary]", 1 - assert_select "a[href=/user/blocked/diary/comments]", 1 - assert_select "a[href=/user/blocked/account]", 0 - assert_select "a[href=/user/blocked/blocks]", 1 - assert_select "a[href=/user/blocked/blocks_by]", 0 - assert_select "a[href=/blocks/new/blocked]", 0 + assert_select "a[href^='/user/blocked/history']", 1 + assert_select "a[href='/user/blocked/traces']", 1 + assert_select "a[href='/user/blocked/diary']", 1 + assert_select "a[href='/user/blocked/diary/comments']", 1 + assert_select "a[href='/user/blocked/account']", 0 + assert_select "a[href='/user/blocked/blocks']", 1 + assert_select "a[href='/user/blocked/blocks_by']", 0 + assert_select "a[href='/blocks/new/blocked']", 0 end # Test a moderator who has applied blocks get :view, {:display_name => "moderator"} assert_response :success assert_select "div#userinformation" do - assert_select "a[href^=/user/moderator/history]", 1 - assert_select "a[href=/user/moderator/traces]", 1 - assert_select "a[href=/user/moderator/diary]", 1 - assert_select "a[href=/user/moderator/diary/comments]", 1 - assert_select "a[href=/user/moderator/account]", 0 - assert_select "a[href=/user/moderator/blocks]", 0 - assert_select "a[href=/user/moderator/blocks_by]", 1 - assert_select "a[href=/blocks/new/moderator]", 0 + assert_select "a[href^='/user/moderator/history']", 1 + assert_select "a[href='/user/moderator/traces']", 1 + assert_select "a[href='/user/moderator/diary']", 1 + assert_select "a[href='/user/moderator/diary/comments']", 1 + assert_select "a[href='/user/moderator/account']", 0 + assert_select "a[href='/user/moderator/blocks']", 0 + assert_select "a[href='/user/moderator/blocks_by']", 1 + assert_select "a[href='/blocks/new/moderator']", 0 end # Login as a normal user @@ -613,14 +613,14 @@ class UserControllerTest < ActionController::TestCase get :view, {:display_name => "test"} assert_response :success assert_select "div#userinformation" do - assert_select "a[href^=/user/test/history]", 1 - assert_select "a[href=/traces/mine]", 1 - assert_select "a[href=/user/test/diary]", 1 - assert_select "a[href=/user/test/diary/comments]", 1 - assert_select "a[href=/user/test/account]", 1 - assert_select "a[href=/user/test/blocks]", 0 - assert_select "a[href=/user/test/blocks_by]", 0 - assert_select "a[href=/blocks/new/test]", 0 + assert_select "a[href^='/user/test/history']", 1 + assert_select "a[href='/traces/mine']", 1 + assert_select "a[href='/user/test/diary']", 1 + assert_select "a[href='/user/test/diary/comments']", 1 + assert_select "a[href='/user/test/account']", 1 + assert_select "a[href='/user/test/blocks']", 0 + assert_select "a[href='/user/test/blocks_by']", 0 + assert_select "a[href='/blocks/new/test']", 0 end # Login as a moderator @@ -630,14 +630,14 @@ class UserControllerTest < ActionController::TestCase get :view, {:display_name => "test"} assert_response :success assert_select "div#userinformation" do - assert_select "a[href^=/user/test/history]", 1 - assert_select "a[href=/user/test/traces]", 1 - assert_select "a[href=/user/test/diary]", 1 - assert_select "a[href=/user/test/diary/comments]", 1 - assert_select "a[href=/user/test/account]", 0 - assert_select "a[href=/user/test/blocks]", 0 - assert_select "a[href=/user/test/blocks_by]", 0 - assert_select "a[href=/blocks/new/test]", 1 + assert_select "a[href^='/user/test/history']", 1 + assert_select "a[href='/user/test/traces']", 1 + assert_select "a[href='/user/test/diary']", 1 + assert_select "a[href='/user/test/diary/comments']", 1 + assert_select "a[href='/user/test/account']", 0 + assert_select "a[href='/user/test/blocks']", 0 + assert_select "a[href='/user/test/blocks_by']", 0 + assert_select "a[href='/blocks/new/test']", 1 end end @@ -649,21 +649,21 @@ class UserControllerTest < ActionController::TestCase # check the data that is returned assert_select "description", :count => 1, :text => "test" assert_select "contributor-terms", :count => 1 do - assert_select "[agreed=true]" + assert_select "[agreed='true']" end assert_select "img", :count => 1 assert_select "roles", :count => 1 do assert_select "role", :count => 0 end assert_select "changesets", :count => 1 do - assert_select "[count=0]" + assert_select "[count='0']" end assert_select "traces", :count => 1 do - assert_select "[count=0]" + assert_select "[count='0']" end assert_select "blocks", :count => 1 do assert_select "received", :count => 1 do - assert_select "[count=0][active=0]" + assert_select "[count='0'][active='0']" end assert_select "issued", :count => 0 end @@ -700,36 +700,36 @@ class UserControllerTest < ActionController::TestCase # check the data that is returned assert_select "description", :count => 1, :text => "test" assert_select "contributor-terms", :count => 1 do - assert_select "[agreed=true][pd=false]" + assert_select "[agreed='true'][pd='false']" end assert_select "img", :count => 1 assert_select "roles", :count => 1 do assert_select "role", :count => 0 end assert_select "changesets", :count => 1 do - assert_select "[count=0]", :count => 1 + assert_select "[count='0']", :count => 1 end assert_select "traces", :count => 1 do - assert_select "[count=0]", :count => 1 + assert_select "[count='0']", :count => 1 end assert_select "blocks", :count => 1 do assert_select "received", :count => 1 do - assert_select "[count=0][active=0]" + assert_select "[count='0'][active='0']" end assert_select "issued", :count => 0 end assert_select "home", :count => 1 do - assert_select "[lat=12.1][lon=12.1][zoom=3]" + assert_select "[lat='12.1'][lon='12.1'][zoom='3']" end assert_select "languages", :count => 1 do assert_select "lang", :count => 1, :text => "en" end assert_select "messages", :count => 1 do assert_select "received", :count => 1 do - assert_select "[count=1][unread=0]" + assert_select "[count='1'][unread='0']" end assert_select "sent", :count => 1 do - assert_select "[count=1]" + assert_select "[count='1']" end end end @@ -756,8 +756,8 @@ class UserControllerTest < ActionController::TestCase assert_response :success assert_template :make_friend assert_select "form" do - assert_select "input[type=hidden][name=referer]", 0 - assert_select "input[type=submit]", 1 + assert_select "input[type='hidden'][name='referer']", 0 + assert_select "input[type='submit']", 1 end assert_nil Friend.where(:user_id => user.id, :friend_user_id => friend.id).first @@ -766,8 +766,8 @@ class UserControllerTest < ActionController::TestCase assert_response :success assert_template :make_friend assert_select "form" do - assert_select "input[type=hidden][name=referer][value=/test]", 1 - assert_select "input[type=submit]", 1 + assert_select "input[type='hidden'][name='referer'][value='/test']", 1 + assert_select "input[type='submit']", 1 end assert_nil Friend.where(:user_id => user.id, :friend_user_id => friend.id).first @@ -814,8 +814,8 @@ class UserControllerTest < ActionController::TestCase assert_response :success assert_template :remove_friend assert_select "form" do - assert_select "input[type=hidden][name=referer]", 0 - assert_select "input[type=submit]", 1 + assert_select "input[type='hidden'][name='referer']", 0 + assert_select "input[type='submit']", 1 end assert Friend.where(:user_id => user.id, :friend_user_id => friend.id).first @@ -824,8 +824,8 @@ class UserControllerTest < ActionController::TestCase assert_response :success assert_template :remove_friend assert_select "form" do - assert_select "input[type=hidden][name=referer][value=/test]", 1 - assert_select "input[type=submit]", 1 + assert_select "input[type='hidden'][name='referer'][value='/test']", 1 + assert_select "input[type='submit']", 1 end assert Friend.where(:user_id => user.id, :friend_user_id => friend.id).first diff --git a/test/controllers/way_controller_test.rb b/test/controllers/way_controller_test.rb index 6e2ee3b0f..ca87e6543 100644 --- a/test/controllers/way_controller_test.rb +++ b/test/controllers/way_controller_test.rb @@ -67,14 +67,14 @@ class WayControllerTest < ActionController::TestCase assert_response :success # Check the way is correctly returned - assert_select "osm way[id=#{way.id}][version=#{way.version}][visible=#{way.visible}]", 1 + assert_select "osm way[id='#{way.id}'][version='#{way.version}'][visible='#{way.visible}']", 1 # check that each node in the way appears once in the output as a # reference and as the node element. way.nodes.each do |n| count = (way.nodes - (way.nodes - [n])).length - assert_select "osm way nd[ref=#{n.id}]", count - assert_select "osm node[id=#{n.id}][version=#{n.version}][lat=#{n.lat}][lon=#{n.lon}]", 1 + assert_select "osm way nd[ref='#{n.id}']", count + assert_select "osm node[id='#{n.id}'][version='#{n.version}'][lat='#{n.lat}'][lon='#{n.lon}']", 1 end end end @@ -95,10 +95,10 @@ class WayControllerTest < ActionController::TestCase assert_response :success assert_select "osm" do assert_select "way", :count => 4 - assert_select "way[id=1][visible=true]", :count => 1 - assert_select "way[id=2][visible=false]", :count => 1 - assert_select "way[id=4][visible=true]", :count => 1 - assert_select "way[id=6][visible=true]", :count => 1 + assert_select "way[id='1'][visible='true']", :count => 1 + assert_select "way[id='2'][visible='false']", :count => 1 + assert_select "way[id='4'][visible='true']", :count => 1 + assert_select "way[id='6'][visible='true']", :count => 1 end # check error when a non-existent way is included @@ -515,7 +515,7 @@ class WayControllerTest < ActionController::TestCase # check the full ways to ensure we're not missing anything expected_way_ids.each do |id| - way_xml = ways_xml.find("//osm/way[@id=#{id}]").first + way_xml = ways_xml.find("//osm/way[@id='#{id}']").first assert_ways_are_equal(Way.find(id), Way.from_xml_node(way_xml)) end