Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
localize links for hero and feature article sections.
Matthew Kennedy8631c5658cfa
diff --git a/frontend/app/views/spree/shared/cms/sections/_featured_article.html.erb b/frontend/app/views/spree/shared/cms/sections/_featured_article.html.erbindex b0398a0ae6..69eab84f72 100644--- a/frontend/app/views/spree/shared/cms/sections/_featured_article.html.erb+++ b/frontend/app/views/spree/shared/cms/sections/_featured_article.html.erb@@ -20,7 +20,7 @@</div><% if section.button_text.present? && section.link.present? %>- <%= link_to section.button_text, section.link, class: 'btn text-center spree-btn btn-outline-primary w-75' %>+ <%= link_to section.button_text, spree_localized_link(section), class: 'btn text-center spree-btn btn-outline-primary w-75' %><% end %></div></div>diff --git a/frontend/app/views/spree/shared/cms/sections/_hero_image.html.erb b/frontend/app/views/spree/shared/cms/sections/_hero_image.html.erbindex e89f05ec78..ca08c15236 100644--- a/frontend/app/views/spree/shared/cms/sections/_hero_image.html.erb+++ b/frontend/app/views/spree/shared/cms/sections/_hero_image.html.erb@@ -52,7 +52,7 @@<% if section.link.present? && section.button_text.present? %><div>- <%= link_to section.button_text, section.link, class: 'btn btn-primary spree-btn px-5' %>+ <%= link_to section.button_text, spree_localized_link(section), class: 'btn btn-primary spree-btn px-5' %></div><% end %></div>diff --git a/frontend/spec/features/cms_sections/featured_article_spec.rb b/frontend/spec/features/cms_sections/featured_article_spec.rbnew file mode 100644index 0000000000..bb82fabf8b--- /dev/null+++ b/frontend/spec/features/cms_sections/featured_article_spec.rb@@ -0,0 +1,49 @@+require 'spec_helper'++describe 'Visiting the homepage with featured article section', type: :feature, js: true do+ let!(:store) { Spree::Store.default }++ let!(:en_feature_page) { create(:cms_feature_page, store: store, locale: 'en', slug: 'english-feature') }+ let!(:en_homepage) { create(:cms_homepage, store: store, locale: 'en') }+ let!(:en_hp_featured_article_section) { create(:cms_featured_article_section, cms_page: en_homepage, linked_resource: en_feature_page) }++ let!(:fr_feature_page) { create(:cms_feature_page, store: store, locale: 'fr', slug: 'french-feature') }+ let!(:fr_homepage) { create(:cms_homepage, store: store, locale: 'fr') }+ let!(:fr_hp_featured_article_section) { create(:cms_featured_article_section, cms_page: fr_homepage, linked_resource: fr_feature_page) }++ context 'when page is viewed in default language' do+ before do+ en_featured_article_section = Spree::CmsSection.find(en_hp_featured_article_section.id)++ en_featured_article_section.update!(title: 'Featured Article Title', button_text: 'Featured Article Button Text')+ visit spree.root_path+ end++ it 'the Featured Article section displays the link without a language denomination' do+ expect(page).to have_selector(:css, 'a[href="/pages/english-feature"]', text: "FEATURED ARTICLE BUTTON TEXT")+ end++ it 'the Featured Article section displays the title text' do+ expect(page).to have_content('Featured Article Title')+ end+ end++ context 'when page is viewed in a none default language' do+ before do+ store.update(default_locale: 'en', supported_locales: 'en,fr')++ fr_featured_article_section = Spree::CmsSection.find(fr_hp_featured_article_section.id)++ fr_featured_article_section.update!(title: 'FR_FA_Title', button_text: 'FR FA BTN TXT')+ visit '/fr'+ end++ it 'the Featured Article section displays the link without a language denomination' do+ expect(page).to have_selector(:css, 'a[href="/fr/pages/french-feature"]', text: "FR FA BTN TXT")+ end++ it 'the Featured Article section displays the title text translated' do+ expect(page).to have_content('FR_FA_Title')+ end+ end+enddiff --git a/frontend/spec/features/cms_sections/hero_image_spec.rb b/frontend/spec/features/cms_sections/hero_image_spec.rbnew file mode 100644index 0000000000..9b65540e1f--- /dev/null+++ b/frontend/spec/features/cms_sections/hero_image_spec.rb@@ -0,0 +1,49 @@+require 'spec_helper'++describe 'Visiting the homepage with hero section', type: :feature, js: true do+ let!(:store) { Spree::Store.default }++ let!(:en_feature_page) { create(:cms_feature_page, store: store, locale: 'en', slug: 'english-feature') }+ let!(:en_homepage) { create(:cms_homepage, store: store, locale: 'en') }+ let!(:en_hp_hero_section) { create(:cms_hero_image_section, cms_page: en_homepage, linked_resource: en_feature_page) }++ let!(:fr_feature_page) { create(:cms_feature_page, store: store, locale: 'fr', slug: 'french-feature') }+ let!(:fr_homepage) { create(:cms_homepage, store: store, locale: 'fr') }+ let!(:fr_hp_hero_section) { create(:cms_hero_image_section, cms_page: fr_homepage, linked_resource: fr_feature_page) }++ context 'when page is viewed in default language' do+ before do+ en_hero_section = Spree::CmsSection.find(en_hp_hero_section.id)++ en_hero_section.update!(title: 'Hero Title', button_text: 'Hero Button Text')+ visit spree.root_path+ end++ it 'the hero section displays the link without a language denomination' do+ expect(page).to have_selector(:css, 'a[href="/pages/english-feature"]', text: "HERO BUTTON TEXT")+ end++ it 'the hero section displays the title text' do+ expect(page).to have_content('Hero Title')+ end+ end++ context 'when page is viewed in a none default language' do+ before do+ store.update(default_locale: 'en', supported_locales: 'en,fr')++ fr_hero_section = Spree::CmsSection.find(fr_hp_hero_section.id)++ fr_hero_section.update!(title: 'FR_Hero_Title', button_text: 'FR HERO BTN TXT')+ visit '/fr'+ end++ it 'the hero section displays the link without a language denomination' do+ expect(page).to have_selector(:css, 'a[href="/fr/pages/french-feature"]', text: "FR HERO BTN TXT")+ end++ it 'the hero section displays the title text translated' do+ expect(page).to have_content('FR_Hero_Title')+ end+ end+end