Files
grecia/spec/system/site_customization/information_texts_spec.rb
Javi Martín 9427f01442 Use system specs instead of feature specs
We get rid of database cleaner, and JavaScript tests are faster because
between tests we now rollback transactions instead of truncating the
database.
2020-04-24 15:43:54 +02:00

56 lines
1.8 KiB
Ruby

require "rails_helper"
describe "Custom information texts" do
scenario "Show custom texts instead of default ones" do
admin = create(:administrator)
login_as(admin.user)
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", :js do
admin = create(:administrator)
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}")
login_as(admin.user)
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