]> git.openstreetmap.org Git - rails.git/commitdiff
Refactor a few tests to use changeset factories.
authorAndy Allan <git@gravitystorm.co.uk>
Thu, 25 May 2017 08:47:18 +0000 (09:47 +0100)
committerAndy Allan <git@gravitystorm.co.uk>
Wed, 31 May 2017 09:45:14 +0000 (10:45 +0100)
test/controllers/browse_controller_test.rb
test/controllers/relation_controller_test.rb
test/controllers/way_controller_test.rb

index 12262b22403bd73dba6882ec169637e0f08ab40f..c08f550367a11037d66ac22d14df7d2f7efe9adc 100644 (file)
@@ -70,8 +70,10 @@ class BrowseControllerTest < ActionController::TestCase
   end
 
   def test_read_changeset
-    browse_check "changeset", changesets(:normal_user_first_change).id, "browse/changeset"
-    browse_check "changeset", changesets(:public_user_first_change).id, "browse/changeset"
+    private_changeset = create(:changeset, :user => create(:user, :data_public => false))
+    changeset = create(:changeset)
+    browse_check "changeset", private_changeset.id, "browse/changeset"
+    browse_check "changeset", changeset.id, "browse/changeset"
   end
 
   def test_read_changeset_hidden_comments
index 5f7516fd24eecea90e365c21b1de5f7b09378b31..613e95d162a0e6d79a57306301dfa79785b4700a 100644 (file)
@@ -373,16 +373,18 @@ class RelationControllerTest < ActionController::TestCase
   # josm-dev.
   ## FIXME Move this to an integration test
   def test_update_relation_tags
-    basic_authorization "test@example.com", "test"
-    rel_id = current_relations(:multi_tag_relation).id
-    create_list(:relation_tag, 4, :relation => current_relations(:multi_tag_relation))
-    cs_id = changesets(:public_user_first_change).id
+    user = create(:user)
+    changeset = create(:changeset, :user => user)
+    relation = create(:relation)
+    create_list(:relation_tag, 4, :relation => relation)
+
+    basic_authorization user.email, "test"
 
-    with_relation(rel_id) do |rel|
+    with_relation(relation.id) do |rel|
       # alter one of the tags
       tag = rel.find("//osm/relation/tag").first
       tag["v"] = "some changed value"
-      update_changeset(rel, cs_id)
+      update_changeset(rel, changeset.id)
 
       # check that the downloaded tags are the same as the uploaded tags...
       new_version = with_update(rel) do |new_rel|
@@ -390,10 +392,10 @@ class RelationControllerTest < ActionController::TestCase
       end
 
       # check the original one in the current_* table again
-      with_relation(rel_id) { |r| assert_tags_equal rel, r }
+      with_relation(relation.id) { |r| assert_tags_equal rel, r }
 
       # now check the version in the history
-      with_relation(rel_id, new_version) { |r| assert_tags_equal rel, r }
+      with_relation(relation.id, new_version) { |r| assert_tags_equal rel, r }
     end
   end
 
index 93994aa694997b195126dd283c69ef2ec2baf64f..42a0413c771f49f329bb70a84c13d8064ca0d327 100644 (file)
@@ -406,7 +406,7 @@ class WayControllerTest < ActionController::TestCase
 
     # try and update in a closed changeset
     content update_changeset(private_way.to_xml,
-                             create(:changeset, :closed, :user => private_user))
+                             create(:changeset, :closed, :user => private_user).id)
     put :update, :id => private_way.id
     assert_require_public_data "update with closed changeset should be forbidden, when data isn't public"
 
@@ -444,7 +444,7 @@ class WayControllerTest < ActionController::TestCase
 
     # try and update in a closed changeset
     content update_changeset(way.to_xml,
-                             changesets(:normal_user_closed_change).id)
+                             create(:changeset, :closed, :user => user).id)
     put :update, :id => way.id
     assert_response :conflict, "update with closed changeset should be rejected"