diff --git a/app/controllers/tag_wranglers_controller.rb b/app/controllers/tag_wranglers_controller.rb index f3359580a32..d1f557e5f6e 100644 --- a/app/controllers/tag_wranglers_controller.rb +++ b/app/controllers/tag_wranglers_controller.rb @@ -62,7 +62,7 @@ def report_csv def create authorize :wrangling if logged_in_as_admin? - + saved_any_assignment = false unless params[:tag_fandom_string].blank? names = params[:tag_fandom_string].gsub(/$/, ',').split(',').map(&:strip) fandoms = Fandom.where('name IN (?)', names) @@ -77,6 +77,7 @@ def create end assignment = current_user.wrangling_assignments.build(fandom_id: fandom.id) assignment.save! + saved_any_assignment = true end flash[:error] = t(".noncanonical_fandoms_tried_assignment", count: noncanonical_fandoms.length, fandom_list: helpers.to_sentence(noncanonical_fandoms.map(&:name))) unless noncanonical_fandoms.empty? end @@ -90,12 +91,13 @@ def create unless user.nil? || user.fandoms.include?(fandom) assignment = user.wrangling_assignments.build(fandom_id: fandom.id) assignment.save! + saved_any_assignment = true end end end end - flash[:notice] = "Wranglers were successfully assigned!" end + flash[:notice] = "Wranglers were successfully assigned!" if saved_any_assignment redirect_to tag_wranglers_path(media_id: params[:media_id], fandom_string: params[:fandom_string], wrangler_id: params[:wrangler_id]) end diff --git a/features/tags_and_wrangling/tag_wrangling_more.feature b/features/tags_and_wrangling/tag_wrangling_more.feature index b19cfcc48fe..e3be487cc7f 100644 --- a/features/tags_and_wrangling/tag_wrangling_more.feature +++ b/features/tags_and_wrangling/tag_wrangling_more.feature @@ -120,6 +120,16 @@ Feature: Tag wrangling: assigning wranglers, using the filters on the Wranglers And "Testing" should not be assigned to the wrangler "tangler" When I edit the tag "Testing" Then I should see "Sign Up" + + Scenario: Wrangler can't self-assign a non-canonical fandom + Given I am logged in as a tag wrangler + And a canonical fandom "Canon" + And a non-canonical fandom "Uncanon" + When I am on the wranglers page + And I fill in "Enter as many fandoms as you like." with "Uncanon" + And I press "Assign" + Then I should see "Could not assign fandom Uncanon. Non-canonical fandoms cannot be assigned." + And I should not see "Wranglers were successfully assigned!" Scenario: Updating multiple tags works. Given a canonical fandom "Cowboy Bebop"