create seed_spec and move there custom pages specs

This commit is contained in:
Jakub Krzus
2021-04-08 21:03:40 +01:00
parent 7e669e8e39
commit 8da5291d01
2 changed files with 30 additions and 21 deletions

View File

@@ -0,0 +1,30 @@
require "rails_helper"
describe "rake db:seed" do
it "generates all custom pages translations populated by db:seeds" do
default_locales = I18n.available_locales
begin
I18n.available_locales = [:ar, :bg, :bs, :ca, :cs, :da, :de, :el, :en, :es, :"es-PE", :eu, :fa, :fr,
:gl, :he, :hr, :id, :it, :ka, :nl, :oc, :pl, :"pt-BR",
:ro, :ru, :sl, :sq, :so, :sr, :sv, :tr, :val, :"zh-CN", :"zh-TW"]
SiteCustomization::Page.destroy_all
load Rails.root.join("db", "pages.rb")
paths = { accessibility: "pages.accessibility.title", conditions: "pages.conditions.title",
faq: "pages.help.faq.page.title", privacy: "pages.privacy.title",
welcome_not_verified: "welcome.welcome.title",
welcome_level_two_verified: "welcome.welcome.title",
welcome_level_three_verified: "welcome.welcome.title" }
I18n.available_locales.each do |locale|
I18n.locale = locale
paths.each do |slug, path|
site = SiteCustomization::Page.find_by(slug: slug).translations.find_by(locale: locale)
expect(site.title).to eq I18n.t(path)
end
end
end
ensure
I18n.available_locales = default_locales
end
end

View File

@@ -1,12 +1,6 @@
require "rails_helper"
describe "Admin custom pages", :admin do
I18n.available_locales = [:ar, :bg, :bs, :ca, :cs, :da, :de, :el, :en, :es, :"es-PE", :eu, :fa, :fr,
:gl, :he, :hr, :id, :it, :ka, :nl, :oc, :pl, :"pt-BR",
:ro, :ru, :sl, :sq, :so, :sr, :sv, :tr, :val, :"zh-CN", :"zh-TW"]
SiteCustomization::Page.destroy_all
Rails.application.load_seed
context "Index" do
scenario "lists all created custom pages" do
custom_page = create(:site_customization_page)
@@ -32,21 +26,6 @@ describe "Admin custom pages", :admin do
expect(page).to have_content slug
end
end
scenario "should contain all custom pages translations populated by db:seeds" do
paths = { accessibility: "pages.accessibility.title", conditions: "pages.conditions.title",
faq: "pages.help.faq.page.title", privacy: "pages.privacy.title",
welcome_not_verified: "welcome.welcome.title",
welcome_level_two_verified: "welcome.welcome.title",
welcome_level_three_verified: "welcome.welcome.title" }
I18n.available_locales.each do |locale|
I18n.locale = locale
paths.each do |slug, path|
site = SiteCustomization::Page.find_by(slug: slug).translations.find_by(locale: locale)
expect(site.title).to eq I18n.t(path)
end
end
end
end
context "Create" do