System tests are used to test the application from the user's point of view. To test for specific exceptions, particularly regarding authorization permissions, controller tests fit better. Another option would be to test the page displayed shows a certain text, like "Internal server error". I'm choosing controller tests because they're faster and we're basically testing the same scenario many times and we've already got a test checking what happens when users access a page raising an exception.
20 lines
515 B
Ruby
20 lines
515 B
Ruby
require "rails_helper"
|
|
|
|
describe Budgets::BallotsController do
|
|
before { sign_in(create(:user, :level_two)) }
|
|
|
|
describe "GET show" do
|
|
it "raises an error if budget slug is not found" do
|
|
expect do
|
|
get :show, params: { budget_id: "wrong_budget" }
|
|
end.to raise_error ActiveRecord::RecordNotFound
|
|
end
|
|
|
|
it "raises an error if budget id is not found" do
|
|
expect do
|
|
get :show, params: { budget_id: 0 }
|
|
end.to raise_error ActiveRecord::RecordNotFound
|
|
end
|
|
end
|
|
end
|