Skip to content

BUG: ActiveRecord::StatementInvalid: PG::NumericValueOutOfRange #331

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

Merged
merged 1 commit into from
May 4, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion app/controllers/teams_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,18 @@ def team_from_params(opts)
if opts[:slug].present?
Team.where(slug: opts[:slug].downcase).first
else
Team.find(opts[:id])
if valid_id?(opts[:id])
Team.find(opts[:id])
else
nil
end
end
end

def valid_id?(id)
id.to_i.to_s == id && id.to_i < 2147483647
end

def replace_section(section_name)
section_name = section_name.tr('-', '_')
"$('##{section_name}').replaceWith('#{escape_javascript(render(:partial => section_name))}');"
Expand Down
7 changes: 7 additions & 0 deletions spec/controllers/teams_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@
get :show, slug: team.slug, job_id: 'not-a-real-job-slug'
expect(assigns(:job_page)).to eq(false)
end

context 'when searching by an out of bounds or non-integer id' do
it 'should render 404' do
get :show, id: '54209333547a9e5'
expect(response).to have_http_status(404)
end
end
end

describe '#create' do
Expand Down