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.
51 lines
1.7 KiB
Ruby
51 lines
1.7 KiB
Ruby
require "rails_helper"
|
|
|
|
describe "Custom information texts", :admin do
|
|
scenario "Show custom texts instead of default ones" do
|
|
debate_key = "debates.index.section_footer.title"
|
|
proposal_key = "proposals.index.section_footer.title"
|
|
|
|
visit admin_site_customization_information_texts_path(tab: "debates")
|
|
fill_in "contents[content_#{debate_key}]values[value_en]", with: "Custom help about debates"
|
|
click_button "Save"
|
|
|
|
visit admin_site_customization_information_texts_path(tab: "proposals")
|
|
fill_in "contents[content_#{proposal_key}]values[value_en]", with: "Custom help about proposals"
|
|
click_button "Save"
|
|
|
|
visit debates_path
|
|
|
|
within("#section_help") do
|
|
expect(page).to have_content "Custom help about debates"
|
|
expect(page).not_to have_content "Help about debates"
|
|
end
|
|
|
|
visit proposals_path
|
|
|
|
within("#section_help") do
|
|
expect(page).to have_content "Custom help about proposals"
|
|
expect(page).not_to have_content "Help about proposals"
|
|
end
|
|
end
|
|
|
|
scenario "Show custom text with options" do
|
|
user = create(:user, username: "Rachel")
|
|
create(:budget_investment, author_id: user.id)
|
|
|
|
intro_key = "mailers.budget_investment_created.intro"
|
|
create(:i18n_content, key: intro_key, value_en: "Hi %{author}")
|
|
|
|
visit admin_site_customization_information_texts_path(tab: "mailers")
|
|
|
|
expect(page).to have_content "Hi %{author}"
|
|
|
|
fill_in "contents[content_#{intro_key}]values[value_en]", with: "Custom hi to %{author}"
|
|
click_button "Save"
|
|
|
|
visit admin_system_email_view_path("budget_investment_created")
|
|
|
|
expect(page).to have_content "Custom hi to Rachel"
|
|
expect(page).not_to have_content "%{author}"
|
|
end
|
|
end
|