From 4eeea7e70556aeb712575dc14ca17016e9768f5f Mon Sep 17 00:00:00 2001 From: Andy Allan Date: Sun, 30 Oct 2016 12:23:23 +0100 Subject: [PATCH] Remove the changesets_subscribers fixture. Since there is no ChangesetsSubscribers model, we can't use a factory. Instead we create the associations explicitly when needed. --- .rubocop_todo.yml | 2 +- test/controllers/changeset_controller_test.rb | 13 ++++++++++--- test/fixtures/changesets_subscribers.yml | 15 --------------- 3 files changed, 11 insertions(+), 19 deletions(-) delete mode 100644 test/fixtures/changesets_subscribers.yml diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 95ddea8f8..83d561ef1 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -64,7 +64,7 @@ Metrics/BlockNesting: # Offense count: 62 # Configuration parameters: CountComments. Metrics/ClassLength: - Max: 1652 + Max: 1658 # Offense count: 69 Metrics/CyclomaticComplexity: diff --git a/test/controllers/changeset_controller_test.rb b/test/controllers/changeset_controller_test.rb index a9a838aff..e77083f2d 100644 --- a/test/controllers/changeset_controller_test.rb +++ b/test/controllers/changeset_controller_test.rb @@ -3,7 +3,6 @@ require "changeset_controller" class ChangesetControllerTest < ActionController::TestCase api_fixtures - fixtures :changesets_subscribers ## # test all routes which lead to this controller @@ -1986,9 +1985,15 @@ EOF end assert_response :success + changeset = changesets(:normal_user_subscribed_change) + changeset.subscribers.push(users(:normal_user)) + changeset.subscribers.push(users(:public_user)) + changeset.subscribers.push(users(:suspended_user)) + changeset.subscribers.push(users(:deleted_user)) + assert_difference "ChangesetComment.count", 1 do assert_difference "ActionMailer::Base.deliveries.size", 1 do - post :comment, :id => changesets(:normal_user_subscribed_change).id, :text => "This is a comment" + post :comment, :id => changeset.id, :text => "This is a comment" end end assert_response :success @@ -2004,7 +2009,7 @@ EOF assert_difference "ChangesetComment.count", 1 do assert_difference "ActionMailer::Base.deliveries.size", 2 do - post :comment, :id => changesets(:normal_user_subscribed_change).id, :text => "This is a comment" + post :comment, :id => changeset.id, :text => "This is a comment" end end assert_response :success @@ -2095,6 +2100,7 @@ EOF # trying to subscribe when already subscribed changeset = changesets(:normal_user_subscribed_change) + changeset.subscribers.push(users(:public_user)) assert_no_difference "changeset.subscribers.count" do post :subscribe, :id => changeset.id end @@ -2106,6 +2112,7 @@ EOF def test_unsubscribe_success basic_authorization(users(:public_user).email, "test") changeset = changesets(:normal_user_subscribed_change) + changeset.subscribers.push(users(:public_user)) assert_difference "changeset.subscribers.count", -1 do post :unsubscribe, :id => changeset.id diff --git a/test/fixtures/changesets_subscribers.yml b/test/fixtures/changesets_subscribers.yml deleted file mode 100644 index c75287832..000000000 --- a/test/fixtures/changesets_subscribers.yml +++ /dev/null @@ -1,15 +0,0 @@ -t1: - changeset_id: 8 - subscriber_id: 2 - -t2: - changeset_id: 8 - subscriber_id: 1 - -t3: - changeset_id: 8 - subscriber_id: 10 - -t4: - changeset_id: 8 - subscriber_id: 11 -- 2.39.5