JavaScript is used by about 98% of web users, so by testing without it enabled, we're only testing that the application works for a very reduced number of users. We proceeded this way in the past because CONSUL started using Rails 4.2 and truncating the database between JavaScript tests with database cleaner, which made these tests terribly slow. When we upgraded to Rails 5.1 and introduced system tests, we started using database transactions in JavaScript tests, making these tests much faster. So now we can use JavaScript tests everywhere without critically slowing down our test suite.
28 lines
601 B
Ruby
28 lines
601 B
Ruby
require "rails_helper"
|
|
|
|
describe "SDG Management" do
|
|
before { login_as(create(:administrator).user) }
|
|
|
|
context "SDG feature flag is enabled" 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" do
|
|
visit root_path
|
|
click_link "Menu"
|
|
|
|
expect(page).not_to have_link "SDG content"
|
|
end
|
|
end
|
|
end
|