Merge pull request #4434 from jakrzus/default_pages
rake db:seed generates default custom pages for all languages
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
if SiteCustomization::Page.find_by(slug: "accessibility").nil?
|
||||
page = SiteCustomization::Page.new(slug: "accessibility", status: "published")
|
||||
def generate_content(page)
|
||||
page.title = I18n.t("pages.accessibility.title")
|
||||
|
||||
content = ""
|
||||
@@ -29,11 +28,13 @@ if SiteCustomization::Page.find_by(slug: "accessibility").nil?
|
||||
</thead>
|
||||
<tbody>"
|
||||
I18n.t("pages.accessibility.keyboard_shortcuts.navigation_table.rows").each do |row|
|
||||
if row.present?
|
||||
content << " <tr>
|
||||
<td class='text-center'>#{row[:key_column]}</td>
|
||||
<td>#{row[:page_column]}</td>
|
||||
</tr>"
|
||||
end
|
||||
end
|
||||
content << " </tbody>
|
||||
</table>
|
||||
<p>#{I18n.t("pages.accessibility.keyboard_shortcuts.browser_table.description")}</p>
|
||||
@@ -53,11 +54,13 @@ if SiteCustomization::Page.find_by(slug: "accessibility").nil?
|
||||
</thead>
|
||||
<tbody>"
|
||||
I18n.t("pages.accessibility.keyboard_shortcuts.browser_table.rows").each do |row|
|
||||
if row.present?
|
||||
content << " <tr>
|
||||
<td>#{row[:browser_column]}</td>
|
||||
<td>#{row[:key_column]}</td>
|
||||
</tr>"
|
||||
end
|
||||
end
|
||||
content << " </tbody>
|
||||
</table>
|
||||
<h2>#{I18n.t("pages.accessibility.textsize.title")}</h2>
|
||||
@@ -75,18 +78,22 @@ if SiteCustomization::Page.find_by(slug: "accessibility").nil?
|
||||
</thead>
|
||||
<tbody>"
|
||||
I18n.t("pages.accessibility.textsize.browser_settings_table.rows").each do |row|
|
||||
if row.present?
|
||||
content << " <tr>
|
||||
<td>#{row[:browser_column]}</td>
|
||||
<td>#{row[:action_column]}</td>
|
||||
</tr>"
|
||||
end
|
||||
end
|
||||
content << " </tbody>
|
||||
</table>"
|
||||
content << "<p>#{I18n.t("pages.accessibility.textsize.browser_shortcuts_table.description")}</p>
|
||||
<ul>"
|
||||
I18n.t("pages.accessibility.textsize.browser_shortcuts_table.rows").each do |row|
|
||||
if row.present?
|
||||
content << "<li><strong>#{row[:shortcut_column]}</strong> #{row[:description_column]}</li>"
|
||||
end
|
||||
end
|
||||
content << "</ul>
|
||||
<h2>#{I18n.t("pages.accessibility.compatibility.title")}</h2>
|
||||
<p>#{I18n.t("pages.accessibility.compatibility.description")}</p>"
|
||||
@@ -94,3 +101,10 @@ if SiteCustomization::Page.find_by(slug: "accessibility").nil?
|
||||
page.content = content
|
||||
page.save!
|
||||
end
|
||||
|
||||
if SiteCustomization::Page.find_by(slug: "accessibility").nil?
|
||||
page = SiteCustomization::Page.new(slug: "accessibility", status: "published")
|
||||
I18n.available_locales.each do |locale|
|
||||
I18n.with_locale(locale) { generate_content(page) }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
if SiteCustomization::Page.find_by(slug: "conditions").nil?
|
||||
page = SiteCustomization::Page.new(slug: "conditions", status: "published")
|
||||
page.print_content_flag = true
|
||||
def generate_content(page)
|
||||
page.title = I18n.t("pages.conditions.title")
|
||||
page.subtitle = I18n.t("pages.conditions.subtitle")
|
||||
page.content = "<p>#{I18n.t("pages.conditions.description")}</p>"
|
||||
page.save!
|
||||
end
|
||||
|
||||
if SiteCustomization::Page.find_by(slug: "conditions").nil?
|
||||
page = SiteCustomization::Page.new(slug: "conditions", status: "published")
|
||||
page.print_content_flag = true
|
||||
I18n.available_locales.each do |locale|
|
||||
I18n.with_locale(locale) { generate_content(page) }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
if SiteCustomization::Page.find_by(slug: "faq").nil?
|
||||
page = SiteCustomization::Page.new(slug: "faq", status: "published")
|
||||
def generate_content(page)
|
||||
page.title = I18n.t("pages.help.faq.page.title")
|
||||
page.content = "<p>#{I18n.t("pages.help.faq.page.description")}</p>"
|
||||
page.save!
|
||||
end
|
||||
if SiteCustomization::Page.find_by(slug: "faq").nil?
|
||||
page = SiteCustomization::Page.new(slug: "faq", status: "published")
|
||||
I18n.available_locales.each do |locale|
|
||||
I18n.with_locale(locale) { generate_content(page) }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
if SiteCustomization::Page.find_by(slug: "privacy").nil?
|
||||
page = SiteCustomization::Page.new(slug: "privacy", status: "published")
|
||||
page.print_content_flag = true
|
||||
def generate_content(page)
|
||||
page.title = I18n.t("pages.privacy.title")
|
||||
page.content = I18n.t("pages.privacy.subtitle")
|
||||
page.save!
|
||||
end
|
||||
|
||||
if SiteCustomization::Page.find_by(slug: "privacy").nil?
|
||||
page = SiteCustomization::Page.new(slug: "privacy", status: "published")
|
||||
page.print_content_flag = true
|
||||
I18n.available_locales.each do |locale|
|
||||
I18n.with_locale(locale) { generate_content(page) }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
if SiteCustomization::Page.find_by(slug: "welcome_level_three_verified").nil?
|
||||
page = SiteCustomization::Page.new(slug: "welcome_level_three_verified", status: "published")
|
||||
def generate_content(page)
|
||||
page.title = I18n.t("welcome.welcome.title")
|
||||
|
||||
page.content = "<p>#{I18n.t("welcome.welcome.user_permission_info")}</p>
|
||||
@@ -17,3 +16,10 @@ if SiteCustomization::Page.find_by(slug: "welcome_level_three_verified").nil?
|
||||
<p><a href='/'>#{I18n.t("welcome.welcome.start_using_consul")}</a></p>"
|
||||
page.save!
|
||||
end
|
||||
|
||||
if SiteCustomization::Page.find_by(slug: "welcome_level_three_verified").nil?
|
||||
page = SiteCustomization::Page.new(slug: "welcome_level_three_verified", status: "published")
|
||||
I18n.available_locales.each do |locale|
|
||||
I18n.with_locale(locale) { generate_content(page) }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
if SiteCustomization::Page.find_by(slug: "welcome_level_two_verified").nil?
|
||||
page = SiteCustomization::Page.new(slug: "welcome_level_two_verified", status: "published")
|
||||
def generate_content(page)
|
||||
page.title = I18n.t("welcome.welcome.title")
|
||||
|
||||
page.content = "<p>#{I18n.t("welcome.welcome.user_permission_info")}</p>
|
||||
@@ -23,3 +22,9 @@ if SiteCustomization::Page.find_by(slug: "welcome_level_two_verified").nil?
|
||||
<p><a href='/'>#{I18n.t("welcome.welcome.go_to_index")}</a></p>"
|
||||
page.save!
|
||||
end
|
||||
if SiteCustomization::Page.find_by(slug: "welcome_level_two_verified").nil?
|
||||
page = SiteCustomization::Page.new(slug: "welcome_level_two_verified", status: "published")
|
||||
I18n.available_locales.each do |locale|
|
||||
I18n.with_locale(locale) { generate_content(page) }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
if SiteCustomization::Page.find_by(slug: "welcome_not_verified").nil?
|
||||
page = SiteCustomization::Page.new(slug: "welcome_not_verified", status: "published")
|
||||
def generate_content(page)
|
||||
page.title = I18n.t("welcome.welcome.title")
|
||||
|
||||
page.content = "<p>#{I18n.t("welcome.welcome.user_permission_info")}</p>
|
||||
@@ -23,3 +22,9 @@ if SiteCustomization::Page.find_by(slug: "welcome_not_verified").nil?
|
||||
<p><a href='/'>#{I18n.t("welcome.welcome.go_to_index")}</a></p>"
|
||||
page.save!
|
||||
end
|
||||
if SiteCustomization::Page.find_by(slug: "welcome_not_verified").nil?
|
||||
page = SiteCustomization::Page.new(slug: "welcome_not_verified", status: "published")
|
||||
I18n.available_locales.each do |locale|
|
||||
I18n.with_locale(locale) { generate_content(page) }
|
||||
end
|
||||
end
|
||||
|
||||
30
spec/lib/tasks/seed_spec.rb
Normal file
30
spec/lib/tasks/seed_spec.rb
Normal 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
|
||||
ensure
|
||||
I18n.available_locales = default_locales
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user