Use find instead of find_by_id
Better raise a 404 HTML NotFound exception than any other unexpected error.
This commit is contained in:
committed by
Javi Martín
parent
22076dd95c
commit
b122302c58
25
spec/controllers/budgets/ballots/lines_controller_spec.rb
Normal file
25
spec/controllers/budgets/ballots/lines_controller_spec.rb
Normal file
@@ -0,0 +1,25 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Budgets::Ballot::LinesController do
|
||||
|
||||
describe "#load_budget" do
|
||||
|
||||
it "raises an error if budget slug is not found" do
|
||||
controller.params[:budget_id] = "wrong_budget"
|
||||
|
||||
expect do
|
||||
controller.send(:load_budget)
|
||||
end.to raise_error ActiveRecord::RecordNotFound
|
||||
end
|
||||
|
||||
it "raises an error if budget id is not found" do
|
||||
controller.params[:budget_id] = 0
|
||||
|
||||
expect do
|
||||
controller.send(:load_budget)
|
||||
end.to raise_error ActiveRecord::RecordNotFound
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user