-
Notifications
You must be signed in to change notification settings - Fork 513
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AO3-6598 Slow query in challenge_signups#update and challenge_signups#create #4720
Changes from 6 commits
7ba62ed
392f52b
b79e34f
9d1dd1f
75b89d5
e7ac677
8b7abfa
5fbab68
bef074c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -131,6 +131,71 @@ | |
it_redirects_to_simple("#{collection_signups_path(open_signup.collection)}/"\ | ||
"#{open_signup.collection.prompts.first.challenge_signup_id}/edit") | ||
end | ||
|
||
context "prompt has tags" do | ||
before do | ||
# Delete existing prompt of current user | ||
open_signup.offers.first.destroy | ||
end | ||
let!(:canonical_character) { create(:canonical_character, name: "Sakura Kinomoto") } | ||
|
||
it "should accept canonical tags" do | ||
post :create, params: { | ||
collection_id: open_signup.collection.name, | ||
prompt_type: "offer", | ||
prompt: { | ||
description: "This is a description.", | ||
tag_set_attributes: { | ||
character_tagnames: ["Sakura Kinomoto"] | ||
} | ||
} | ||
} | ||
it_redirects_to_with_notice( | ||
collection_signup_path(open_signup.collection, open_signup), | ||
"Prompt was successfully added." | ||
) | ||
end | ||
|
||
it "should error if some tags aren't canonical" do | ||
post :create, params: { | ||
collection_id: open_signup.collection.name, | ||
prompt_type: "offer", | ||
prompt: { | ||
description: "This is a description.", | ||
tag_set_attributes: { | ||
character_tagnames: ["Sakura Typomoto"] | ||
} | ||
} | ||
} | ||
it_redirects_to_with_error( | ||
edit_collection_signup_path(open_signup.collection, open_signup), | ||
"That prompt would make your overall sign-up invalid, sorry." | ||
) | ||
expect(assigns[:prompt].errors[:base]).to eq( | ||
["^These character tags in your offer are not canonical and cannot be used in this challenge: Sakura Typomoto. To fix this, please ask your challenge moderator to set up a tag set for the challenge. New tags can be added to the tag set manually by the moderator or through open nominations."] | ||
) | ||
end | ||
|
||
it "shouldn't make needless checks on unused kind of tags" do | ||
expect_any_instance_of(PromptRestriction).to receive(:has_tags?).with("character").at_least(:once) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure where the second call to this method happens actually, might be worth investigating. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was also looking at this. My in-progress comment:
Your solution of combining it also looks okay, but I'm a bit hesitant to call save on the signup when it's the prompt that is getting created. Because this seems to be barely covered in tests, I think it may be better go for my more conservative solution. |
||
expect_any_instance_of(PromptRestriction).not_to receive(:has_tags?).with("relationship") | ||
|
||
post :create, params: { | ||
collection_id: open_signup.collection.name, | ||
prompt_type: "offer", | ||
prompt: { | ||
description: "This is a description.", | ||
tag_set_attributes: { | ||
character_tagnames: ["Sakura Kinomoto"] | ||
} | ||
} | ||
} | ||
it_redirects_to_with_notice( | ||
collection_signup_path(open_signup.collection, open_signup), | ||
"Prompt was successfully added." | ||
) | ||
end | ||
end | ||
end | ||
|
||
describe "update" do | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From how I understand it, if the challenge has no restriction at all, we don't check for canonicity, but if it has any sort of restriction, we make sure all tags are (at least) canonical? Is that intended behavior?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My knowledge of the challenge code is extremely rusty, but the Tag Options part of the Gift Exchange FAQ might help explain the intended/current behavior. The tl;dr is tags shouldn't need to be canonical if they're in one of the challenge's tag sets.