-
-
Notifications
You must be signed in to change notification settings - Fork 50
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
Issue#669 bad page number parameters causing ArgumentError #1144
Changes from 2 commits
705c60c
d3c44ec
e8e068a
c34a8a8
5f9f3b9
02285ca
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 |
---|---|---|
|
@@ -15,6 +15,21 @@ | |
get :index | ||
expect(assigns[:rss]).to be_nil | ||
end | ||
|
||
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. Remove this stray extra line. |
||
it "should try to convert page param to an integer" do | ||
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. In my first review I didn't check where these tests were placed. They're under But where should they go? I didn't know so I hunted around. I discovered that So create a new file in this directory called require "spec_helper"
describe ApplicationController do
controller do
def index
render text: nil
end
end
describe "#validate_page_param" do
it "should try to convert page param to an integer" do
get :index, page: "2%5B&q"
expect(controller.params[:page]).to eq(2)
end
it "should default to page nil when no page number param is given" do
get :index, page: "%5B&q"
expect(controller.params[:page]).to eq(nil)
end
end
end 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. will do! |
||
VCR.use_cassette('planningalerts') do | ||
get :index, page: "2%5B&q" | ||
end | ||
expect(controller.params[:page]).to eq(2) | ||
end | ||
|
||
it "should default to page nil when no page number param is given" do | ||
VCR.use_cassette('planningalerts') do | ||
get :index, page: "%5B&q" | ||
end | ||
expect(controller.params[:page]).to eq(nil) | ||
end | ||
|
||
end | ||
|
||
describe "error checking on parameters used" 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.
Do not use unless with else. Rewrite these with the positive case first.
I also notice your indentation is a little out on the params lines - you need an extra space.