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.
28 lines
611 B
Ruby
28 lines
611 B
Ruby
require "rails_helper"
|
|
|
|
describe "SDG Management" do
|
|
before { login_as(create(:administrator).user) }
|
|
|
|
context "SDG feature flag is enabled", :js do
|
|
before { Setting["feature.sdg"] = true }
|
|
|
|
scenario "shows the SDG content link" do
|
|
visit root_path
|
|
click_link "Menu"
|
|
|
|
expect(page).to have_link "SDG content"
|
|
end
|
|
end
|
|
|
|
context "SDG feature is disabled" do
|
|
before { Setting["feature.sdg"] = false }
|
|
|
|
scenario "does not show the SDG Content link", :js do
|
|
visit root_path
|
|
click_link "Menu"
|
|
|
|
expect(page).not_to have_link "SDG content"
|
|
end
|
|
end
|
|
end
|