From 0facb801f84470f45da0e36d5dc66b546b2cdac2 Mon Sep 17 00:00:00 2001 From: Andy Allan Date: Thu, 25 May 2017 09:47:18 +0100 Subject: [PATCH] Refactor a few tests to use changeset factories. --- test/controllers/browse_controller_test.rb | 6 ++++-- test/controllers/relation_controller_test.rb | 18 ++++++++++-------- test/controllers/way_controller_test.rb | 4 ++-- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/test/controllers/browse_controller_test.rb b/test/controllers/browse_controller_test.rb index 12262b224..c08f55036 100644 --- a/test/controllers/browse_controller_test.rb +++ b/test/controllers/browse_controller_test.rb @@ -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 diff --git a/test/controllers/relation_controller_test.rb b/test/controllers/relation_controller_test.rb index 5f7516fd2..613e95d16 100644 --- a/test/controllers/relation_controller_test.rb +++ b/test/controllers/relation_controller_test.rb @@ -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 diff --git a/test/controllers/way_controller_test.rb b/test/controllers/way_controller_test.rb index 93994aa69..42a0413c7 100644 --- a/test/controllers/way_controller_test.rb +++ b/test/controllers/way_controller_test.rb @@ -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" -- 2.39.5