Move exception tests to controller specs

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.
This commit is contained in:
Javi Martín
2021-03-30 13:28:49 +02:00
parent abd6a1971f
commit 02981324ab
53 changed files with 509 additions and 379 deletions

View File

@@ -0,0 +1,13 @@
require "rails_helper"
describe Moderation::DebatesController do
before { sign_in(create(:moderator).user) }
describe "GET index" do
it "raises an exception when the feature is disabled" do
Setting["process.debates"] = false
expect { get :index }.to raise_exception(FeatureFlags::FeatureDisabled)
end
end
end