Skip to content

Commit

Permalink
AO3-6784 Fix error 500 on nominations show/index with tag in wrong ca…
Browse files Browse the repository at this point in the history
…tegory (#4887)
  • Loading branch information
Bilka2 authored Aug 2, 2024
1 parent c7619e8 commit 9cbfc60
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/helpers/tag_sets_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def nomination_status(nomination=nil)
end

def nomination_tag_information(nominated_tag)
tag_object = nominated_tag.type.gsub(/Nomination/, '').constantize.find_by_name(nominated_tag.tagname)
tag_object = Tag.find_by(name: nominated_tag.tagname)
status = "nonexistent"
tooltip = ts("This tag has never been used before. Check the spelling!")
title = ts("nonexistent tag")
Expand Down
3 changes: 3 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ services:
- redis
- es
- mc
# Make `docker compose attach web` work for debugging
stdin_open: true
tty: true
chrome:
profiles:
- test
Expand Down
10 changes: 9 additions & 1 deletion features/step_definitions/tag_set_steps.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
# encoding: utf-8
Given "a nominated tag set {string} with a tag nomination in the wrong category" do |tag_set_name|
pseud = FactoryBot.create(:pseud, user: FactoryBot.create(:user, login: "tagsetter"))
owned_tag_set = FactoryBot.create(:owned_tag_set, title: tag_set_name, owner: pseud)
tag_set_nomination = FactoryBot.create(:tag_set_nomination, pseud: pseud, owned_tag_set: owned_tag_set)
FactoryBot.create(:relationship, name: "rel tag")
invalid_nom = tag_set_nomination.fandom_nominations.build(tagname: "rel tag") # intentional mismatch in tag category
invalid_nom.save(validate: false)
end

When /^I follow the add new tag ?set link$/ do
step %{I follow "New Tag Set"}
end
Expand Down
2 changes: 2 additions & 0 deletions features/support/paths.rb
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@ def path_to(page_name)
edit_tag_set_path(OwnedTagSet.find_by(title: $1))
when /^the "(.*)" tag ?set page$/i
tag_set_path(OwnedTagSet.find_by(title: $1))
when /^the "(.*)" tag ?set nominations page$/i
tag_set_nominations_path(OwnedTagSet.find_by(title: Regexp.last_match(1)))
when /^the Open Doors tools page$/i
opendoors_tools_path
when /^the Open Doors external authors page$/i
Expand Down
31 changes: 31 additions & 0 deletions features/tag_sets/tag_set_nominations.feature
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,34 @@ Feature: Nominating and reviewing nominations for a tag set
And I submit
Then I should see "The tag Veronica Mars is already in the archive as a Character tag. (All tags have to be unique.) Try being more specific, for instance tacking on the medium or the fandom."

Scenario: If a tag was nominated as another type of tag, "My Nominations" and "Review Nominations" can still be accessed
Given a nominated tag set "bad" with a tag nomination in the wrong category
And I am logged in as "tagsetter"
And I go to the "bad" tag set page
# preexisting non-canonical tag
When I follow "My Nominations"
Then I should see "My Nominations for bad"
And I should see "rel tag"
When I go to the "bad" tag set nominations page
Then I should see "Fandoms (1 left to review)"
And I should see "rel tag"
# canonical tag
When the tag "rel tag" is canonized
And I go to the "bad" tag set page
When I follow "My Nominations"
Then I should see "My Nominations for bad"
And I should see "rel tag"
When I go to the "bad" tag set nominations page
Then I should see "Fandoms (1 left to review)"
And I should see "rel tag"
# synonym tag
When the tag "rel tag" is decanonized
And a canonical relationship "canon tag"
And a synonym "rel tag" of the tag "canon tag"
And I go to the "bad" tag set page
When I follow "My Nominations"
Then I should see "My Nominations for bad"
And I should see "rel tag"
When I go to the "bad" tag set nominations page
Then I should see "Fandoms (1 left to review)"
And I should see "rel tag (canon tag)"

0 comments on commit 9cbfc60

Please sign in to comment.