-
Notifications
You must be signed in to change notification settings - Fork 786
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
Show merged stories on duplicate submission #1233
Show merged stories on duplicate submission #1233
Conversation
I've tried to add a test for this change by creating a # typed: false
require "rails_helper"
describe StoriesController do
let(:user) { create(:user) }
let(:story) { create(:story, user: user) }
describe "#check_url_dupe" do
it "fails when URL is missing" do
expect {
post :check_url_dupe, params: { story: { url: '' } }
}.to raise_error(ActionController::ParameterMissing)
end
it "should return an existing story" do
post :check_url_dupe, params: { story: { url: story.url } }, format: :html
expect(response).to include("Previous discussions for this story")
end
end
end The first test worked fine, but the second failed with:
I spent a while trying to figure where this Not sure if I'm being too naive and maybe creating tests for a controller is more complicated than that. |
That’s a real painful test failure to debug. I didn’t see it when I read your test, but after I pulled it down and got the exception for myself I caught that the test says I ran it with I’m concerned about the approach in your PR. Changing |
Oh my, thanks for catching that. It was going to take a while for me to figure that.
I was certainly not expecting a potential bug. Thanks for the tip in debugging it.
After running a "find all references" for this method, I got tricked into believing it wasn't used anywhere else, but now I see it in |
11e7b80
to
a90f46f
Compare
I actually added a keyword |
This adds too much complexity for this feature. I'm really suspicious of boolean arguments like you've added to |
I've bumped brakeman on the master branch to fix the build, you can merge that in or just rebase your PR. Using |
a90f46f
to
9f357c4
Compare
I'm a bit confused about why the check was against
Thanks for the heads up. I've rebased the branch before updating the PR. CI checks are green now. |
9f357c4
to
3610acb
Compare
3610acb
to
d0c17bc
Compare
I've also added tests for the changes. Can you please take a look at it again? |
Looks great, thanks for working through a weird bug and my design concerns on this one! |
You are welcome. Thanks for taking the time in reviewing and helping out to debug the test framework failures! P.s.: any chance I can get a site invitation as a late Christmas gift? I've been lurking there for a few years already. |
Probably the check was against I've sent an invite to your email, thanks again. |
Awesome, thanks! |
Closes #1215.
The approach consists in not filtering out merged stories (avoiding the
unmerged
filter) and showing them in the returned HTML.Please let me know if should we do it differently.