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.
This commit is contained in:
Javi Martín
2019-04-29 12:26:17 +02:00
parent 12774c7484
commit 9427f01442
190 changed files with 14 additions and 54 deletions

View File

@@ -0,0 +1,71 @@
require "rails_helper"
describe "Custom content blocks" do
scenario "top links" do
create(:site_customization_content_block, name: "top_links", locale: "en",
body: "content for top links")
create(:site_customization_content_block, name: "top_links", locale: "es",
body: "contenido para top links")
visit "/?locale=en"
expect(page).to have_content("content for top links")
expect(page).not_to have_content("contenido para top links")
visit "/?locale=es"
expect(page).to have_content("contenido para top links")
expect(page).not_to have_content("content for top links")
end
scenario "footer" do
create(:site_customization_content_block, name: "footer", locale: "en",
body: "content for footer")
create(:site_customization_content_block, name: "footer", locale: "es",
body: "contenido para footer")
visit "/?locale=en"
expect(page).to have_content("content for footer")
expect(page).not_to have_content("contenido para footer")
visit "/?locale=es"
expect(page).to have_content("contenido para footer")
expect(page).not_to have_content("content for footer")
end
scenario "main navigation left" do
create(:site_customization_content_block, name: "subnavigation_left", locale: "en",
body: "content for left links")
create(:site_customization_content_block, name: "subnavigation_left", locale: "es",
body: "contenido para left links")
visit "/?locale=en"
expect(page).to have_content("content for left links")
expect(page).not_to have_content("contenido para left links")
visit "/?locale=es"
expect(page).to have_content("contenido para left links")
expect(page).not_to have_content("content for left links")
end
scenario "main navigation right" do
create(:site_customization_content_block, name: "subnavigation_right", locale: "en",
body: "content for right links")
create(:site_customization_content_block, name: "subnavigation_right", locale: "es",
body: "contenido para right links")
visit "/?locale=en"
expect(page).to have_content("content for right links")
expect(page).not_to have_content("contenido para right links")
visit "/?locale=es"
expect(page).to have_content("contenido para right links")
expect(page).not_to have_content("content for left links")
end
end

View File

@@ -0,0 +1,115 @@
require "rails_helper"
describe "Custom Pages" do
context "New custom page" do
context "Draft" do
scenario "See page" do
custom_page = create(:site_customization_page,
slug: "other-slug",
title_en: "Custom page",
content_en: "Text for new custom page",
print_content_flag: false
)
visit custom_page.url
expect(page.status_code).to eq(404)
end
end
context "Published" do
scenario "See page" do
custom_page = create(:site_customization_page, :published,
slug: "other-slug",
title_en: "Custom page",
content_en: "Text for new custom page",
print_content_flag: false
)
visit custom_page.url
expect(page).to have_title("Custom page")
expect(page).to have_selector("h1", text: "Custom page")
expect(page).to have_content("Text for new custom page")
expect(page).not_to have_content("Print this info")
end
scenario "Show all fields and text with links" do
custom_page = create(:site_customization_page, :published,
slug: "slug-with-all-fields-filled",
title_en: "Custom page",
subtitle_en: "This is my new custom page",
content_en: "Text for new custom page with a link to https://consul.dev",
print_content_flag: true
)
visit custom_page.url
expect(page).to have_title("Custom page")
expect(page).to have_selector("h1", text: "Custom page")
expect(page).to have_selector("h2", text: "This is my new custom page")
expect(page).to have_content("Text for new custom page with a link to https://consul.dev")
expect(page).to have_link("https://consul.dev")
expect(page).to have_content("Print this info")
end
scenario "Don't show subtitle if its blank" do
custom_page = create(:site_customization_page, :published,
slug: "slug-without-subtitle",
title_en: "Custom page",
subtitle_en: "",
content_en: "Text for new custom page",
print_content_flag: false
)
visit custom_page.url
expect(page).to have_title("Custom page")
expect(page).to have_selector("h1", text: "Custom page")
expect(page).to have_content("Text for new custom page")
expect(page).not_to have_selector("h2")
expect(page).not_to have_content("Print this info")
end
scenario "Listed in more information page" do
create(:site_customization_page, :published,
slug: "another-slug",
title_en: "Another custom page",
subtitle_en: "Subtitle for custom page",
more_info_flag: true
)
visit help_path
expect(page).to have_content("Another custom page")
end
scenario "Not listed in more information page" do
custom_page = create(:site_customization_page, :published,
slug: "another-slug", title_en: "Another custom page",
subtitle_en: "Subtitle for custom page",
more_info_flag: false
)
visit help_path
expect(page).not_to have_content("Another custom page")
visit custom_page.url
expect(page).to have_title("Another custom page")
expect(page).to have_selector("h1", text: "Another custom page")
expect(page).to have_content("Subtitle for custom page")
end
scenario "Show widget cards for that page" do
custom_page = create(:site_customization_page, :published)
create(:widget_card, page: custom_page, title: "Card Highlights")
visit custom_page.url
expect(page).to have_content "Card Highlights"
end
end
end
end

View File

@@ -0,0 +1,55 @@
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