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
Use Pretty Name in section Links + Bug Fix (#11300)
Matthew Kennedy8c0c34a50c7d
diff --git a/backend/app/assets/javascripts/spree/backend/global/select2_autocomplete.es6 b/backend/app/assets/javascripts/spree/backend/global/select2_autocomplete.es6index 4ec8d78fde..3b621dec05 100644--- a/backend/app/assets/javascripts/spree/backend/global/select2_autocomplete.es6+++ b/backend/app/assets/javascripts/spree/backend/global/select2_autocomplete.es6@@ -1,37 +1,25 @@// SELECT2 AUTOCOMPLETE JS-// This JavaScript file allows Spree developers to set up Select2 autocomplete search-// using the API v2 by simply adding data attributes to a select element with the class: 'select2autocomplete'-// as shown here: <select class="select2autocomplete"></select>.+// The JavaScript in this file allows Spree developers to set up Select2 autocomplete search+// using the API v2 by simply adding data attributes to a select element.// REQUIRED ATTRIBUTES-// You must provide a URL for the API V2, use the format shown below.-// See the backend.js file for other API V2 URL's.-//-// Example:+// You must provide a URL for the API V2, use the format shown below. See backend.js for other API V2 URL's.+// REQUIRED:// data-autocomplete-url-value="products_api_v2"-// OPTIONAL ATTRIBUTES-// These optional attributes have sensible defaults, you many not need to use them in many cases,-// but they do provide a powerful toolkit to refine your autocomplete search as required.-//-// Examples:-// data-autocomplete-placeholder-value="Seach Pages" <- Sets the placeholder | DEFAULT is: 'Search'-// data-autocomplete-clear-value="boolean" <- Allow select2 to be cleared | DEFAULT is: false (no clear button)-// data-autocomplete-multiple-value="boolean" <- Multiple or Single select | DEFAULT is: false (single)-// data-autocomplete-return-attr-value="pretty_name" <- Return Attribute. | DEFAULT is: 'name'-// data-autocomplete-min-input-value="4" <- Minimum input for search | DEFAULT is: 3-// data-autocomplete-search-query-value="title_i_cont" <- Custom search query | DEFAULT is: 'name_i_cont'-// data-autocomplete-custom-return-id-value="permalink" <- Return a custom attribute rather than the ID | DEFAULT: returns id+// OPTIONAL:+// data-autocomplete-placeholder-value="Seach Pages" <- Sets the placeholder | DEFAULT is: 'Search'.+// data-autocomplete-clear-value=boolean <- Allow select2 to be cleared | DEFAULT is: false (no clear button).+// data-autocomplete-multiple-value=boolean <- Multiple or Single select | DEFAULT is: false (single).+// data-autocomplete-return-attr-value="pretty_name" <- Return Attribute. | DEFAULT is: 'name'.+// data-autocomplete-min-input-value="4" <- Minimum input for search | DEFAULT is: 3.+// data-autocomplete-search-query-value="title_i_cont" <- Custom search query | DEFAULT is: 'name_i_cont'.+// data-autocomplete-custom-return-id-value="permalink" <- Return a custom attribute | DEFAULT: returns id.+// data-autocomplete-debug-mode-value=boolean <- Turn on console loggin of data returned by the request.//-// SECOND HARD CODED FILTER - (OPTIONAL)-// Use a second hard coded search filter param and term if you require a little more curation-// than just all results returning, an example of this in use can be seen in the menu_item search for Pages,-// here we only want to retuen Pages that have linkable slugs, not homepages, and so we filter those using the-// data attributes shown below.-//-// Examples:-// data-autocomplete-additional-query-value="type_not_eq" <- Additional hard coded query | DEFAULT: null (not used)-// data-autocomplete-additional-term-value="Spree::Cms::Pages::Homepage" <- Additional hard coded term | DEFAULT: null (not used)+// Add your own custom URL params to the request as needed+// EXAMPLE:+// data-autocomplete-additional-url-params-value="filter[type_not_eq]=Spree::Cms::Pages::Homepage"document.addEventListener('DOMContentLoaded', function() {loadAutoCompleteParams()@@ -45,10 +33,7 @@ function loadAutoCompleteParams() {function buildParamsFromDataAttrs(element) {$(element).select2Autocomplete({- // Required AttributesapiUrl: Spree.routes[element.dataset.autocompleteUrlValue],-- // Optional Attributesplaceholder: element.dataset.autocompletePlaceholderValue,allow_clear: element.dataset.autocompleteClearValue,multiple: element.dataset.autocompleteMultipleValue,@@ -56,21 +41,17 @@ function buildParamsFromDataAttrs(element) {minimum_input: element.dataset.autocompleteMinInputValue,search_query: element.dataset.autocompleteSearchQueryValue,custom_return_id: element.dataset.autocompleteCustomReturnIdValue,-- // Hard coded additional filter for those edge cases.- additional_query: element.dataset.autocompleteAdditionalQueryValue,- additional_term: element.dataset.autocompleteAdditionalTermValue+ additional_url_params: element.dataset.autocompleteAdditionalUrlParamsValue,+ debug_mode: element.dataset.autocompleteDebugModeValue})}-// Can also be called directly as javastript.$.fn.select2Autocomplete = function(params) {- // Required params- const apiUrl = params.apiUrl || null- const resourcePlural = apiUrl.match(/([^/]*)\/*$/)[1]- const resourceSingular = resourcePlural.slice(0, -1)+ let apiUrl = null+ let returnedFields- // Optional Params+ const resourcePlural = params.apiUrl.match(/([^/]*)\/*$/)[1]+ const resourceSingular = resourcePlural.slice(0, -1)const select2placeHolder = params.placeholder || Spree.translations.searchconst select2Multiple = params.multiple || falseconst select2allowClear = params.allow_clear || false@@ -78,9 +59,32 @@ $.fn.select2Autocomplete = function(params) {const minimumInput = params.minimum_input || 3const searchQuery = params.search_query || 'name_i_cont'const customReturnId = params.custom_return_id || null- const additionalQuery = params.additional_query || null- const additionalTerm = params.additional_term || null+ const additionalUrlParams = params.additional_url_params || null+ const DebugMode = params.debug_mode || null++ //+ // Set up a clean URL for sparseFields+ if (customReturnId == null) {+ returnedFields = returnAttribute+ } else {+ returnedFields = `${returnAttribute},${customReturnId}`+ }+ const sparseFields = `fields[${resourceSingular}]=${returnedFields}`++ //+ // Set up a clean URL for Additional URL Params+ if (additionalUrlParams != null) {+ // URL + Additional URL Params + Sparse Fields+ apiUrl = `${params.apiUrl}?${additionalUrlParams}&${sparseFields}`+ } else {+ // URL + Sparse Fields (the default response for a noraml Select2)+ apiUrl = `${params.apiUrl}?${sparseFields}`+ }+ if (DebugMode != null) console.log('Request URL:' + apiUrl)++ //+ // Format the returned values.function formatList(values) {if (customReturnId) {return values.map(function(obj) {@@ -99,58 +103,30 @@ $.fn.select2Autocomplete = function(params) {}}- if (additionalQuery == null && additionalTerm == null) {- this.select2({- multiple: select2Multiple,- allowClear: select2allowClear,- placeholder: select2placeHolder,- minimumInputLength: minimumInput,- ajax: {- url: apiUrl,- headers: Spree.apiV2Authentication(),- data: function(params) {- return {- fields: {- [resourceSingular]: returnAttribute- },- filter: {- [searchQuery]: params.term- }- }- },- processResults: function(json) {- return {- results: formatList(json.data)+ //+ // Set-up Select2 and make AJAX request.+ this.select2({+ multiple: select2Multiple,+ allowClear: select2allowClear,+ placeholder: select2placeHolder,+ minimumInputLength: minimumInput,+ ajax: {+ url: apiUrl,+ headers: Spree.apiV2Authentication(),+ data: function(params) {+ return {+ filter: {+ [searchQuery]: params.term}}- }- })- } else {- this.select2({- multiple: select2Multiple,- allowClear: select2allowClear,- placeholder: select2placeHolder,- minimumInputLength: minimumInput,- ajax: {- url: apiUrl,- headers: Spree.apiV2Authentication(),- data: function(params) {- return {- fields: {- [resourceSingular]: returnAttribute- },- filter: {- [searchQuery]: params.term,- [additionalQuery]: additionalTerm- }- }- },- processResults: function(json) {- return {- results: formatList(json.data)- }+ },+ processResults: function(json) {+ if (DebugMode != null) console.log(json)++ return {+ results: formatList(json.data)}}- })- }+ }+ })}diff --git a/backend/app/assets/javascripts/spree/backend/global/select2_populate.es6 b/backend/app/assets/javascripts/spree/backend/global/select2_populate.es6index 9c7106cbbc..a93ac86cd6 100644--- a/backend/app/assets/javascripts/spree/backend/global/select2_populate.es6+++ b/backend/app/assets/javascripts/spree/backend/global/select2_populate.es6@@ -1,11 +1,9 @@/**populateSelectOptionsFromApi(params)+ Allows you to easily fetch data from API (Platfrom v2) and populate an empty <select> with <option> tags, including a selected <option> tag.- Allows you to easily fetch data from API (Platfrom v2)- and populate an empty <select> with <option> tags,- including a selected <option> tag.-- ## EXAMPLE USE CASE called from ERB view file:+ ## EXAMPLE A+ # Populating a list of all taxons including a selected itempopulateSelectOptionsFromApi({targetElement: '#mySelectElement',@@ -16,6 +14,24 @@selectedOption: <%= @menu_item.linked_resource_id %><% end %>})++ ## EXAMPLE B+ # Populating a single selected item using filter and returning an attribute other than the ID++ <% if resource.link_one.present? %>+ <script>+ populateSelectOptionsFromApi({+ targetElement: "#<%= save_to %>Select2",+ apiUrl: Spree.routes.taxons_api_v2 + "?filter[permalink_matches]=<%= resource.send(save_to) %>",+ returnValueFromAttributes: 'permalink',+ returnOptionText: 'pretty_name',++ <% if resource.send(save_to) %>+ selectedOption: "<%= resource.send(save_to) %>"+ <% end %>+ })+ </script>+ <% end %>**/// eslint-disable-next-line no-unused-vars@@ -32,30 +48,40 @@ const handleErrors = function(response) {const createRequest = function(params, succeed, fail) {const targetElement = params.targetElementconst apiUrl = params.apiUrl- const returnAttribute = params.returnAttribute+ const returnOptionText = params.returnOptionText+ const returnValueFromAttributes = params.returnValueFromAttributes || nullconst selectedOption = params.selectedOptionconst selectEl = document.querySelector(targetElement)fetch(apiUrl, { headers: Spree.apiV2Authentication() }).then((response) => handleErrors(response))- .then((json) => succeed(json.data, returnAttribute, selectEl, selectedOption))+ .then((json) => succeed(json.data, returnValueFromAttributes, returnOptionText, selectEl, selectedOption)).catch((error) => fail(error, selectEl))}-const updateSelectSuccess = function(parsedData, returnAttribute, selectEl, selectedOption) {+const updateSelectSuccess = function(parsedData, returnValueFromAttributes, returnOptionText, selectEl, selectedOption) {+ const selectedOpt = selectEl.querySelector('option[selected]')+parsedData.forEach((object) => {const optionEl = document.createElement('option')- optionEl.value = object.id- optionEl.innerHTML = object.attributes[returnAttribute]- if (parseInt(selectedOption, 10) === parseInt(object.id, 10)) optionEl.selected = true+ if (returnValueFromAttributes == null) {+ optionEl.value = object.id+ if (parseInt(selectedOption, 10) === parseInt(object.id, 10)) optionEl.selected = true+ } else {+ optionEl.value = object.attributes[returnValueFromAttributes]+ if (selectedOpt.value === object.attributes[returnValueFromAttributes]) {+ selectedOpt.remove()++ optionEl.setAttribute('selected', 'selected')+ }+ }+ optionEl.innerHTML = object.attributes[returnOptionText]selectEl.appendChild(optionEl)})}const updateSelectError = function(error, selectEl) {- selectEl.disabled = true-console.log(error)}diff --git a/backend/app/views/spree/admin/cms_sections/types/_hero_image.html.erb b/backend/app/views/spree/admin/cms_sections/types/_hero_image.html.erbindex 11fc9d0fa9..3534c43bdf 100644--- a/backend/app/views/spree/admin/cms_sections/types/_hero_image.html.erb+++ b/backend/app/views/spree/admin/cms_sections/types/_hero_image.html.erb@@ -37,10 +37,9 @@<%= image_tag main_app.url_for(@cms_section.image_one) %></figure><% end %>- <%= f.field_container :image_one, class: ['form-group mb-0'] do %>- <%= f.file_field :image_one %>- <%= f.error_message_on :image_one %>- <% end %>++ <%= f.file_field :image_one %>+ <%= f.error_message_on :image_one %><% end %><small class="form-text text-muted"><%= Spree.t('admin.cms.hero.aspect_ratio') %></small></div>diff --git a/backend/app/views/spree/admin/cms_sections/types/_image_gallery.html.erb b/backend/app/views/spree/admin/cms_sections/types/_image_gallery.html.erbindex 370e958c6e..c3fd0d3b8c 100644--- a/backend/app/views/spree/admin/cms_sections/types/_image_gallery.html.erb+++ b/backend/app/views/spree/admin/cms_sections/types/_image_gallery.html.erb@@ -22,7 +22,7 @@<div class="row"><div class="col-12 col-md-4 mb-3">- <div class="card p-3">+ <div id="image_a_details" class="card p-3"><div class="text-center"><h4 class="pb-2"><%= Spree.t('admin.cms.image_gallery.image_a') %></h4><%= f.field_container :image_one, class: ['form-group'] do %>@@ -35,10 +35,9 @@<%= image_tag main_app.url_for(@cms_section.image_one) %></figure><% end %>- <%= f.field_container :image_one, class: ['form-group mb-0'] do %>- <%= f.file_field :image_one %>- <%= f.error_message_on :image_one %>- <% end %>++ <%= f.file_field :image_one %>+ <%= f.error_message_on :image_one %><% end %></div><small class="text-muted mb-4"><%= Spree.t('admin.cms.image_gallery.square_image') %></small>@@ -67,7 +66,7 @@</div><div class="col-12 col-md-4 mb-3">- <div class="card p-3">+ <div id="image_b_details" class="card p-3"><div class="text-center"><h4 class="pb-2"><%= Spree.t('admin.cms.image_gallery.image_b') %></h4><%= f.field_container :image_two, class: ['form-group'] do %>@@ -80,10 +79,9 @@<%= image_tag main_app.url_for(@cms_section.image_two) %></figure><% end %>- <%= f.field_container :image_two, class: ['form-group mb-0'] do %>- <%= f.file_field :image_two %>- <%= f.error_message_on :image_two %>- <% end %>++ <%= f.file_field :image_two %>+ <%= f.error_message_on :image_two %><% end %></div><small class="text-muted mb-4"><%= Spree.t('admin.cms.image_gallery.tall_image') %></small>@@ -112,7 +110,7 @@</div><div class="col-12 col-md-4 mb-3">- <div class="card p-3">+ <div id="image_c_details" class="card p-3"><div class="text-center"><h4 class="pb-2"><%= Spree.t('admin.cms.image_gallery.image_c') %></h4><%= f.field_container :image_three, class: ['form-group'] do %>@@ -125,10 +123,9 @@<%= image_tag main_app.url_for(@cms_section.image_three) %></figure><% end %>- <%= f.field_container :image_three, class: ['form-group mb-0'] do %>- <%= f.file_field :image_three %>- <%= f.error_message_on :image_three %>- <% end %>++ <%= f.file_field :image_three %>+ <%= f.error_message_on :image_three %><% end %></div><small class="text-muted mb-4"><%= Spree.t('admin.cms.image_gallery.square_image') %></small>diff --git a/backend/app/views/spree/admin/cms_sections/types/_side_by_side_images.html.erb b/backend/app/views/spree/admin/cms_sections/types/_side_by_side_images.html.erbindex 718d8cc9fe..0ab7f96abb 100644--- a/backend/app/views/spree/admin/cms_sections/types/_side_by_side_images.html.erb+++ b/backend/app/views/spree/admin/cms_sections/types/_side_by_side_images.html.erb@@ -1,6 +1,6 @@<div class="row pb-0"><div class="col-12 col-md-6 mb-3">- <div class="card p-3">+ <div id="left_image_details" class="card p-3"><div class="text-center"><h4 class="pb-2"><%= Spree.t('admin.cms.side_by_side.left_image') %></h4><%= f.field_container :image_one, class: ['form-group'] do %>@@ -51,7 +51,7 @@</div><div class="col-12 col-md-6 mb-3">- <div class="card p-3">+ <div id="right_image_details" class="card p-3"><div class="text-center"><h4 class="pb-2"><%= Spree.t('admin.cms.side_by_side.right_image') %></h4><%= f.field_container :image_two, class: ['form-group'] do %>diff --git a/backend/app/views/spree/admin/shared/cms/_spree_product.html.erb b/backend/app/views/spree/admin/shared/cms/_spree_product.html.erbindex 07f90c7415..f397452937 100644--- a/backend/app/views/spree/admin/shared/cms/_spree_product.html.erb+++ b/backend/app/views/spree/admin/shared/cms/_spree_product.html.erb@@ -1,14 +1,27 @@<%= f.field_container save_to, class: ['form-group'] do %><%= f.label save_to, Spree.t('admin.cms.link_to_product') %>- <%= f.select save_to,- options_from_collection_for_select([resource],- save_to, save_to, resource.send(save_to) || nil),- { include_blank: true },- class: 'select2autocomplete',- data: { autocomplete_placeholder_value: Spree.t('admin.navigation.seach_for_a_product'),- autocomplete_clear_value: true,- autocomplete_url_value: 'products_api_v2',- autocomplete_return_attr_value: 'name',- autocomplete_custom_return_id_value: 'slug' } %>+ <%= f.select save_to, options_from_collection_for_select([resource], save_to, save_to, resource.send(save_to) || nil), { include_blank: true },+ id: "cms_section_#{save_to}",+ data: { autocomplete_placeholder_value: Spree.t('admin.navigation.seach_for_a_product'),+ autocomplete_clear_value: true,+ autocomplete_url_value: 'products_api_v2',+ autocomplete_return_attr_value: 'name',+ autocomplete_custom_return_id_value: 'slug' } %>+<%= f.error_message_on :save_to %><% end %>++<% if resource.link_one.present? %>+ <script>+ populateSelectOptionsFromApi({+ targetElement: "#cms_section_<%= save_to %>",+ apiUrl: Spree.routes.products_api_v2 + "?filter[slug_matches]=<%= resource.send(save_to) %>",+ returnValueFromAttributes: 'slug',+ returnOptionText: 'name',++ <% if resource.send(save_to) %>+ selectedOption: "<%= resource.send(save_to) %>"+ <% end %>+ })+ </script>+<% end %>diff --git a/backend/app/views/spree/admin/shared/cms/_spree_taxon.html.erb b/backend/app/views/spree/admin/shared/cms/_spree_taxon.html.erbindex 273869b76d..780907afa3 100644--- a/backend/app/views/spree/admin/shared/cms/_spree_taxon.html.erb+++ b/backend/app/views/spree/admin/shared/cms/_spree_taxon.html.erb@@ -1,14 +1,27 @@<%= f.field_container save_to, class: ['form-group'] do %><%= f.label save_to, Spree.t('admin.cms.link_to_taxon') %>- <%= f.select save_to,- options_from_collection_for_select([resource],- save_to, save_to, resource.send(save_to) || nil),- { include_blank: true },- class: 'select2autocomplete',- data: { autocomplete_placeholder_value: Spree.t('admin.navigation.seach_for_a_taxon'),- autocomplete_clear_value: true,- autocomplete_url_value: 'taxons_api_v2',- autocomplete_return_attr_value: 'permalink',- autocomplete_custom_return_id_value: 'permalink' } %>+ <%= f.select save_to, options_from_collection_for_select([resource], save_to, save_to, resource.send(save_to) || nil), { include_blank: true },+ id: "cms_section_#{save_to}",+ data: { autocomplete_placeholder_value: Spree.t('admin.navigation.seach_for_a_taxon'),+ autocomplete_clear_value: true,+ autocomplete_url_value: 'taxons_api_v2',+ autocomplete_return_attr_value: 'pretty_name',+ autocomplete_custom_return_id_value: 'permalink' } %>+<%= f.error_message_on :save_to %><% end %>++<% if resource.link_one.present? %>+ <script>+ populateSelectOptionsFromApi({+ targetElement: "#cms_section_<%= save_to %>",+ apiUrl: Spree.routes.taxons_api_v2 + "?filter[permalink_matches]=<%= resource.send(save_to) %>",+ returnValueFromAttributes: 'permalink',+ returnOptionText: 'pretty_name',++ <% if resource.send(save_to) %>+ selectedOption: "<%= resource.send(save_to) %>"+ <% end %>+ })+ </script>+<% end %>diff --git a/backend/app/views/spree/admin/shared/linkables/_spree_cms_page.erb b/backend/app/views/spree/admin/shared/linkables/_spree_cms_page.erbindex a512a5fe4c..525ed9cc53 100644--- a/backend/app/views/spree/admin/shared/linkables/_spree_cms_page.erb+++ b/backend/app/views/spree/admin/shared/linkables/_spree_cms_page.erb@@ -16,12 +16,7 @@autocomplete_url_value: 'pages_api_v2',autocomplete_return_attr_value: 'title',autocomplete_search_query_value: 'title_i_cont',-- # Hard coded additional filter to filter out homepages from- # the results. Homepages don't have a slug, and we already have- # a dedicated Home Page link_to type.- autocomplete_additional_query_value: 'type_not_eq',- autocomplete_additional_term_value: 'Spree::Cms::Pages::Homepage' } %>+ autocomplete_additional_url_params_value: 'filter[type_not_eq]=Spree::Cms::Pages::Homepage' } %><%= f.error_message_on :linked_resource_id %><small class="form-text text-muted"><%= resource.link %></small>diff --git a/backend/spec/features/admin/cms_sections/featured_article_spec.rb b/backend/spec/features/admin/cms_sections/featured_article_spec.rbnew file mode 100644index 0000000000..c0bc5314fe--- /dev/null+++ b/backend/spec/features/admin/cms_sections/featured_article_spec.rb@@ -0,0 +1,107 @@+require 'spec_helper'++describe 'Featured Article section', type: :feature do+ stub_authorization!++ section_type = 'Featured Article'++ let!(:store) { Spree::Store.default }+ let!(:feature_page) { create(:cms_feature_page, store: store, title: 'Test Page') }+ let!(:taxon) { create(:taxon) }+ let!(:product) { create(:product) }+ let!(:cms_standard_page) { create(:cms_standard_page, store: store) }+ let!(:homepage) { create(:cms_homepage, store: store, title: 'Super Home Page') }+ let!(:section) { create(:cms_featured_article_section, cms_page: feature_page, name: "Test #{section_type}") }++ before do+ visit spree.edit_admin_cms_page_cms_section_path(feature_page, section)+ end++ context 'editing new page', js: true do+ it 'loads with correct defaults setings' do+ expect(page).to have_field('Name *', with: "Test #{section_type}")+ expect(page).to have_select('Section Type', selected: section_type)+ expect(page).to have_content("Options For: #{section_type}")+ expect(page).to have_select('Gutters', selected: 'No Gutters')+ end++ it 'saves WYSIWYG content to database' do+ rte_content = 'Ipsum blanditiis labore voluptates vero asperiores ullam excepturi'++ page.execute_script("$(tinymce.editors[0].setContent('#{rte_content}'))")++ click_on 'Update'++ expect(page).to have_field(id: 'cms_section_rte_content', with: "<p>#{rte_content}</p>", visible: :hidden, disabled: false)+ assert_admin_flash_alert_success('Section "Test Featured Article" has been successfully updated!')+ end++ it 'saves taxon path and loads it back into the view' do+ select2 taxon.name, from: 'Taxon', search: true++ click_on 'Update'++ expect(page).to have_content(taxon.permalink)+ assert_admin_flash_alert_success('Section "Test Featured Article" has been successfully updated!')+ end++ it 'saves product path and loads it back into the view' do+ select2 'Product', from: 'Link To'++ click_on 'Update'++ select2 product.name, from: 'Product', search: true++ click_on 'Update'++ expect(page).to have_content(product.slug)+ assert_admin_flash_alert_success('Section "Test Featured Article" has been successfully updated!')+ end++ it 'saves page path and loads it back into the view' do+ select2 'Page', from: 'Link To'++ click_on 'Update'++ select2 cms_standard_page.title, from: 'Page', search: true++ click_on 'Update'++ expect(page).to have_content(cms_standard_page.slug)+ assert_admin_flash_alert_success('Section "Test Featured Article" has been successfully updated!')+ end++ it 'does not display homepages in Link To Page results' do+ select2 'Page', from: 'Link To'++ click_on 'Update'++ select2_open label: 'Page'+ select2_search homepage.title, label: 'Page'++ wait_for_ajax do+ expect(page).to have_text('No results found')+ end+ end++ it 'allows admin to enter and save details' do+ fill_in 'Title', with: 'Trendy Styles'+ fill_in 'Subtitle', with: 'Shop Today'+ fill_in 'Button Text', with: 'Learn More'+ select2('Gutters', from: 'Gutters', exact_text: true)++ click_on 'Update'++ expect(page).to have_field('Title', with: 'Trendy Styles')+ expect(page).to have_field('Subtitle', with: 'Shop Today')+ expect(page).to have_field('Button Text', with: 'Learn More')+ expect(page).to have_select('Gutters', selected: 'Gutters')+ end++ it 'allows changing of the section name' do+ fill_in 'Name *', with: 'My New Section Name'+ click_on 'Update'+ expect(page).to have_field('Name *', with: 'My New Section Name')+ end+ end+enddiff --git a/backend/spec/features/admin/cms_sections/hero_image_spec.rb b/backend/spec/features/admin/cms_sections/hero_image_spec.rbnew file mode 100644index 0000000000..b5045eb92f--- /dev/null+++ b/backend/spec/features/admin/cms_sections/hero_image_spec.rb@@ -0,0 +1,107 @@+require 'spec_helper'++describe 'Hero Image section', type: :feature do+ stub_authorization!++ section_type = 'Hero Image'++ let!(:store) { Spree::Store.default }+ let!(:feature_page) { create(:cms_feature_page, store: store, title: 'Test Page') }+ let!(:taxon) { create(:taxon) }+ let!(:product) { create(:product) }+ let!(:cms_standard_page) { create(:cms_standard_page, store: store) }+ let!(:homepage) { create(:cms_homepage, store: store, title: 'Super Home Page') }+ let!(:section) { create(:cms_hero_image_section, cms_page: feature_page, name: "Test #{section_type}") }+ let(:file_path) { Rails.root + '../../spec/support/ror_ringer.jpeg' }++ before do+ visit spree.edit_admin_cms_page_cms_section_path(feature_page, section)+ end++ context 'editing new page', js: true do+ it 'loads with correct defaults setings' do+ expect(page).to have_field('Name *', with: "Test #{section_type}")+ expect(page).to have_select('Section Type', selected: section_type)+ expect(page).to have_content("Options For: #{section_type}")+ expect(page).to have_select('Gutters', selected: 'No Gutters')+ expect(page).to have_select('Fit To', selected: 'Screen')+ end++ it 'saves taxon path and loads it back into the view' do+ select2 taxon.name, from: 'Taxon', search: true++ click_on 'Update'++ expect(page).to have_content(taxon.permalink)+ assert_admin_flash_alert_success('Section "Test Hero Image" has been successfully updated!')+ end++ it 'admin should be able to add image' do+ attach_file('cms_section_image_one', file_path)++ click_button 'Update'++ expect(page).to have_content('successfully updated!')+ expect(page).to have_css('.admin-img-holder img')+ end++ it 'saves product path and loads it back into the view' do+ select2 'Product', from: 'Link To'++ click_on 'Update'++ select2 product.name, from: 'Product', search: true++ click_on 'Update'++ expect(page).to have_content(product.slug)+ assert_admin_flash_alert_success('Section "Test Hero Image" has been successfully updated!')+ end++ it 'saves page path and loads it back into the view' do+ select2 'Page', from: 'Link To'++ click_on 'Update'++ select2 cms_standard_page.title, from: 'Page', search: true++ click_on 'Update'++ expect(page).to have_content(cms_standard_page.slug)+ assert_admin_flash_alert_success('Section "Test Hero Image" has been successfully updated!')+ end++ it 'does not display homepages in Link To Page results' do+ select2 'Page', from: 'Link To'++ click_on 'Update'++ select2_open label: 'Page'+ select2_search homepage.title, label: 'Page'++ wait_for_ajax do+ expect(page).to have_text('No results found')+ end+ end++ it 'allows admin to enter and save details' do+ fill_in 'Title', with: 'Trendy Styles'+ fill_in 'Button Text', with: 'Learn More'+ select2('Gutters', from: 'Gutters', exact_text: true)+ select2('Container', from: 'Fit To', exact_text: true)++ click_on 'Update'++ expect(page).to have_field('Title', with: 'Trendy Styles')+ expect(page).to have_field('Button Text', with: 'Learn More')+ expect(page).to have_select('Fit To', selected: 'Container')+ expect(page).to have_select('Gutters', selected: 'Gutters')+ end++ it 'allows changing of the section name' do+ fill_in 'Name *', with: 'My New Section Name'+ click_on 'Update'+ expect(page).to have_field('Name *', with: 'My New Section Name')+ end+ end+enddiff --git a/backend/spec/features/admin/cms_sections/image_gallery_spec.rb b/backend/spec/features/admin/cms_sections/image_gallery_spec.rbnew file mode 100644index 0000000000..f965265ff6--- /dev/null+++ b/backend/spec/features/admin/cms_sections/image_gallery_spec.rb@@ -0,0 +1,222 @@+require 'spec_helper'++describe 'Image Gallery section', type: :feature do+ stub_authorization!++ section_type = 'Image Gallery'++ let!(:store) { Spree::Store.default }+ let!(:feature_page) { create(:cms_feature_page, store: store, title: 'Test Page') }+ let!(:section) { create(:cms_image_gallery_section, cms_page: feature_page, name: "Test #{section_type}") }+ let!(:taxonomy) { create(:taxon, name: 'Shirts', permalink: 'all-ts') }+ let!(:product) { create(:product, name: 'Zomg Shirt', slug: 'black-zomg-shirt') }+ let(:file_path) { Rails.root + '../../spec/support/ror_ringer.jpeg' }++ before do+ visit spree.edit_admin_cms_page_cms_section_path(feature_page, section)+ end++ context 'editing new page', js: true do+ it 'loads with correct defaults setings' do+ expect(page).to have_field('Name *', with: "Test #{section_type}")+ expect(page).to have_select('Section Type', selected: section_type)+ expect(page).to have_content("Options For: #{section_type}")++ within 'div#image_a_details' do+ expect(page).to have_content('Image A')+ expect(page).to have_content('Title')++ if Rails::VERSION::STRING >= '6.0'+ expect(page).to have_select('Link To', selected: 'Taxon')+ end+ end++ within 'div#image_b_details' do+ expect(page).to have_content('Image B')+ expect(page).to have_content('Title')++ if Rails::VERSION::STRING >= '6.0'+ expect(page).to have_select('Link To', selected: 'Taxon')+ end+ end++ within 'div#image_c_details' do+ expect(page).to have_content('Image C')+ expect(page).to have_content('Title')++ if Rails::VERSION::STRING >= '6.0'+ expect(page).to have_select('Link To', selected: 'Taxon')+ end+ end++ expect(page).to have_select('Layout Style', selected: 'Default')+ expect(page).to have_select('Fit To', selected: 'Container')+ expect(page).to have_select('Display labels', selected: 'Show')+ end++ it 'allows the selection of layout style and saves to database' do+ select2('Reversed', from: 'Layout Style')+ click_on 'Update'+ expect(page).to have_select('Layout Style', selected: 'Reversed')+ end++ it 'allows the selection of Fit To and saves to database' do+ select2('Screen', from: 'Fit To')+ click_on 'Update'+ expect(page).to have_select('Fit To', selected: 'Screen')+ end++ it 'allows the selection of Display Labels and saves to database' do+ select2('Hide', from: 'Display labels')+ click_on 'Update'+ expect(page).to have_select('Display labels', selected: 'Hide')+ end++ it 'allows changing of the section name' do+ fill_in 'Name *', with: 'My New Section Name'+ click_on 'Update'+ expect(page).to have_field('Name *', with: 'My New Section Name')+ end++ context 'Editing Image A' do+ it 'allows admin to enter and save details' do+ within 'div#image_a_details' do+ fill_in 'Title', with: 'Trendy Styles'+ end++ select2('Shirts', css: '#cms_section_link_one_field', search: true)++ click_on 'Update'++ within 'div#image_a_details' do+ expect(page).to have_field('Title', with: 'Trendy Styles')++ wait_for_ajax do+ expect(page).to have_select('Link To Taxon', selected: 'Shirts', value: 'all-ts', visible: :all)+ end+ end+ end++ if Rails::VERSION::STRING >= '6.0'+ it 'allows admin to change the link type and save a product' do+ select2('Product', css: '#cms_section_link_type_one_field')++ click_on 'Update'++ select2('Zomg Shirt', css: '#cms_section_link_one_field', search: true)++ click_on 'Update'++ within 'div#image_a_details' do+ wait_for_ajax do+ expect(page).to have_select('Link To Product', selected: 'Zomg Shirt', value: 'black-zomg-shirt', visible: :all)+ end+ end+ end+ end++ it 'admin should be able to add image' do+ attach_file('cms_section_image_one', file_path)++ click_button 'Update'++ expect(page).to have_content('successfully updated!')+ expect(page).to have_css('.admin-img-holder img')+ end+ end++ context 'Editing Image B' do+ it 'allows admin to enter and save details' do+ within 'div#image_b_details' do+ fill_in 'Title', with: 'Trendy Styles'+ end++ select2('Shirts', css: '#cms_section_link_two_field', search: true)++ click_on 'Update'++ within 'div#image_b_details' do+ expect(page).to have_field('Title', with: 'Trendy Styles')++ wait_for_ajax do+ expect(page).to have_select('Link To Taxon', selected: 'Shirts', value: 'all-ts', visible: :all)+ end+ end+ end++ if Rails::VERSION::STRING >= '6.0'+ it 'allows admin to change the link type and save a product' do+ select2('Product', css: '#cms_section_link_type_two_field')++ click_on 'Update'++ select2('Zomg Shirt', css: '#cms_section_link_two_field', search: true)++ click_on 'Update'++ within 'div#image_b_details' do+ wait_for_ajax do+ expect(page).to have_select('Link To Product', selected: 'Zomg Shirt', value: 'black-zomg-shirt', visible: :all)+ end+ end+ end+ end++ it 'admin should be able to add image' do+ attach_file('cms_section_image_two', file_path)++ click_button 'Update'++ expect(page).to have_content('successfully updated!')+ expect(page).to have_css('.admin-img-holder img')+ end+ end++ context 'Editing Image C' do+ it 'allows admin to enter and save details' do+ within 'div#image_c_details' do+ fill_in 'Title', with: 'Trendy Styles'+ end++ select2('Shirts', css: '#cms_section_link_three_field', search: true)++ click_on 'Update'++ within 'div#image_c_details' do+ expect(page).to have_field('Title', with: 'Trendy Styles')++ wait_for_ajax do+ expect(page).to have_select('Link To Taxon', selected: 'Shirts', value: 'all-ts', visible: :all)+ end+ end+ end++ if Rails::VERSION::STRING >= '6.0'+ it 'allows admin to change the link type and save a product' do+ select2('Product', css: '#cms_section_link_type_three_field')++ click_on 'Update'++ select2('Zomg Shirt', css: '#cms_section_link_three_field', search: true)++ click_on 'Update'++ within 'div#image_c_details' do+ wait_for_ajax do+ expect(page).to have_select('Link To Product', selected: 'Zomg Shirt', value: 'black-zomg-shirt', visible: :all)+ end+ end+ end+ end++ it 'admin should be able to add image' do+ attach_file('cms_section_image_three', file_path)++ click_button 'Update'++ expect(page).to have_content('successfully updated!')+ expect(page).to have_css('.admin-img-holder img')+ end+ end+ end+enddiff --git a/backend/spec/features/admin/cms_sections/product_carousel_spec.rb b/backend/spec/features/admin/cms_sections/product_carousel_spec.rbnew file mode 100644index 0000000000..bd890fb362--- /dev/null+++ b/backend/spec/features/admin/cms_sections/product_carousel_spec.rb@@ -0,0 +1,39 @@+require 'spec_helper'++describe 'Product Carousel section', type: :feature do+ stub_authorization!++ section_type = 'Product Carousel'++ let!(:store) { Spree::Store.default }+ let!(:feature_page) { create(:cms_feature_page, store: store, title: 'Test Page') }+ let!(:taxon) { create(:taxon) }+ let!(:section) { create(:cms_product_carousel_section, cms_page: feature_page, name: "Test #{section_type}") }++ before do+ visit spree.edit_admin_cms_page_cms_section_path(feature_page, section)+ end++ context 'editing new page', js: true do+ it 'loads with correct defaults setings' do+ expect(page).to have_field('Name *', with: "Test #{section_type}")+ expect(page).to have_select('Section Type', selected: section_type)+ expect(page).to have_content("Options For: #{section_type}")+ end++ it 'saves taxon path and loads it back into the view' do+ select2 taxon.name, from: 'Taxon', search: true++ click_on 'Update'++ expect(page).to have_content(taxon.permalink)+ assert_admin_flash_alert_success('Section "Test Product Carousel" has been successfully updated!')+ end++ it 'allows changing of the section name' do+ fill_in 'Name *', with: 'My New Section Name'+ click_on 'Update'+ expect(page).to have_field('Name *', with: 'My New Section Name')+ end+ end+enddiff --git a/backend/spec/features/admin/cms_sections/rich_text_content_spec.rb b/backend/spec/features/admin/cms_sections/rich_text_content_spec.rbnew file mode 100644index 0000000000..72d663bb67--- /dev/null+++ b/backend/spec/features/admin/cms_sections/rich_text_content_spec.rb@@ -0,0 +1,41 @@+require 'spec_helper'++describe 'Rich Text Content section', type: :feature do+ stub_authorization!++ section_type = 'Rich Text Content'++ let!(:store) { Spree::Store.default }+ let!(:feature_page) { create(:cms_feature_page, store: store, title: 'Test Page') }+ let!(:section) { create(:cms_rich_text_content_section, cms_page: feature_page, name: "Test #{section_type}") }++ before do+ visit spree.edit_admin_cms_page_cms_section_path(feature_page, section)+ end++ context 'editing new page', js: true do+ it 'loads with correct defaults setings' do+ expect(page).to have_field('Name *', with: "Test #{section_type}")+ expect(page).to have_select('Section Type', selected: section_type)+ expect(page).to have_content("Options For: #{section_type}")+ end++ it 'saves WYSIWYG content to database' do+ rte_content = 'Ipsum blanditiis labore voluptates vero asperiores ullam excepturi'++ page.execute_script("$(tinymce.editors[0].setContent('#{rte_content}'))")++ click_on 'Update'++ expect(page).to have_field(id: 'cms_section_rte_content', with: "<p>#{rte_content}</p>", visible: :hidden, disabled: false)+ assert_admin_flash_alert_success('Section "Test Rich Text Content" has been successfully updated!')+ end+++ it 'allows changing of the section name' do+ fill_in 'Name *', with: 'My New Section Name'+ click_on 'Update'+ expect(page).to have_field('Name *', with: 'My New Section Name')+ end+ end+enddiff --git a/backend/spec/features/admin/cms_sections/side_by_side_images_spec.rb b/backend/spec/features/admin/cms_sections/side_by_side_images_spec.rbnew file mode 100644index 0000000000..a526d85cf4--- /dev/null+++ b/backend/spec/features/admin/cms_sections/side_by_side_images_spec.rb@@ -0,0 +1,165 @@+require 'spec_helper'++describe 'Image Side By Side Images section', type: :feature do+ stub_authorization!++ section_type = 'Side By Side Images'++ let!(:store) { Spree::Store.default }+ let!(:feature_page) { create(:cms_feature_page, store: store, title: 'Test Page') }+ let!(:section) { create(:cms_side_by_side_images_section, cms_page: feature_page, name: "Test #{section_type}") }+ let!(:taxonomy) { create(:taxon, name: 'Shirts', permalink: 'all-ts') }+ let!(:product) { create(:product, name: 'Zomg Shirt', slug: 'black-zomg-shirt') }+ let(:file_path) { Rails.root + '../../spec/support/ror_ringer.jpeg' }++ before do+ visit spree.edit_admin_cms_page_cms_section_path(feature_page, section)+ end++ context 'editing new page', js: true do+ it 'loads with correct defaults setings' do+ expect(page).to have_field('Name *', with: "Test #{section_type}")+ expect(page).to have_select('Section Type', selected: section_type)+ expect(page).to have_content("Options For: #{section_type}")++ within 'div#left_image_details' do+ expect(page).to have_content('Left Image')+ expect(page).to have_field('Title')+ expect(page).to have_field('Subtitle')++ if Rails::VERSION::STRING >= '6.0'+ expect(page).to have_select('Link To', selected: 'Taxon')+ end+ end++ within 'div#right_image_details' do+ expect(page).to have_content('Right Image')+ expect(page).to have_field('Title')+ expect(page).to have_field('Subtitle')++ if Rails::VERSION::STRING >= '6.0'+ expect(page).to have_select('Link To', selected: 'Taxon')+ end+ end++ expect(page).to have_select('Fit To', selected: 'Container')+ expect(page).to have_select('Set Gutters', selected: 'Gutters')+ end++ it 'allows the selection of Fit To and saves to database' do+ select2('Screen', from: 'Fit To')+ click_on 'Update'+ expect(page).to have_select('Fit To', selected: 'Screen')+ end++ it 'allows the selection of Gutters and saves to database' do+ select2('No Gutters', from: 'Set Gutters')+ click_on 'Update'+ expect(page).to have_select('Set Gutters', selected: 'No Gutters')+ end++ it 'allows changing of the section name' do+ fill_in 'Name *', with: 'My New Section Name'+ click_on 'Update'+ expect(page).to have_field('Name *', with: 'My New Section Name')+ end++ context 'Editing Left Image' do+ it 'allows admin to enter and save details' do+ within 'div#left_image_details' do+ fill_in 'Title', with: 'Trendy Styles'+ fill_in 'Subtitle', with: 'Shop Today'+ end++ select2('Shirts', css: '#cms_section_link_one_field', search: true)++ click_on 'Update'++ within 'div#left_image_details' do+ expect(page).to have_field('Title', with: 'Trendy Styles')+ expect(page).to have_field('Subtitle', with: 'Shop Today')++ wait_for_ajax do+ expect(page).to have_select('Link To Taxon', selected: 'Shirts', value: 'all-ts', visible: :all)+ end+ end+ end++ if Rails::VERSION::STRING >= '6.0'+ it 'allows admin to change the link type and save a product' do+ select2('Product', css: '#cms_section_link_type_one_field')++ click_on 'Update'++ select2('Zomg Shirt', css: '#cms_section_link_one_field', search: true)++ click_on 'Update'++ within 'div#left_image_details' do+ wait_for_ajax do+ expect(page).to have_select('Link To Product', selected: 'Zomg Shirt', value: 'black-zomg-shirt', visible: :all)+ end+ end+ end+ end++ it 'admin should be able to add image' do+ attach_file('cms_section_image_one', file_path)++ click_button 'Update'++ expect(page).to have_content('successfully updated!')+ expect(page).to have_css('.admin-img-holder img')+ end+ end++ context 'Editing Right Image' do+ it 'allows admin to enter and save details' do+ within 'div#right_image_details' do+ fill_in 'Title', with: 'Trendy Styles'+ fill_in 'Subtitle', with: 'Shop Today'+ end++ select2('Shirts', css: '#cms_section_link_one_field', search: true)++ click_on 'Update'++ within 'div#right_image_details' do+ expect(page).to have_field('Title', with: 'Trendy Styles')+ expect(page).to have_field('Subtitle', with: 'Shop Today')++ wait_for_ajax do+ expect(page).to have_select('Link To Taxon', selected: 'Shirts', value: 'all-ts', visible: :all)+ end+ end+ end++ if Rails::VERSION::STRING >= '6.0'+ it 'allows admin to change the link type and save a product' do+ select2('Product', css: '#cms_section_link_type_one_field')++ click_on 'Update'++ select2('Zomg Shirt', css: '#cms_section_link_one_field', search: true)++ click_on 'Update'++ within 'div#right_image_details' do+ wait_for_ajax do+ expect(page).to have_select('Link To Product', selected: 'Zomg Shirt', value: 'black-zomg-shirt', visible: :all)+ end+ end+ end+ end++ it 'admin should be able to add image' do+ attach_file('cms_section_image_one', file_path)++ click_button 'Update'++ expect(page).to have_content('successfully updated!')+ expect(page).to have_css('.admin-img-holder img')+ end+ end+ end+enddiff --git a/core/app/models/spree/cms/sections/featured_article.rb b/core/app/models/spree/cms/sections/featured_article.rbindex fdf81e45c9..c1a18555bc 100644--- a/core/app/models/spree/cms/sections/featured_article.rb+++ b/core/app/models/spree/cms/sections/featured_article.rb@@ -1,6 +1,5 @@module Spree::Cms::Sectionsclass FeaturedArticle < Spree::CmsSection- before_save :reset_link_attributesafter_initialize :default_valuesstore :content, accessors: [:title, :subtitle, :button_text, :rte_content], coder: JSON@@ -14,12 +13,6 @@ module Spree::Cms::Sectionsprivate- def reset_link_attributes- if linked_resource_type_changed?- self.linked_resource_id = nil- end- end-def default_valuesself.gutters ||= 'No Gutters'self.fit ||= 'Screen'diff --git a/core/app/models/spree/cms/sections/hero_image.rb b/core/app/models/spree/cms/sections/hero_image.rbindex f02a210007..daf39e783b 100644--- a/core/app/models/spree/cms/sections/hero_image.rb+++ b/core/app/models/spree/cms/sections/hero_image.rb@@ -1,6 +1,5 @@module Spree::Cms::Sectionsclass HeroImage < Spree::CmsSection- before_save :reset_link_attributesafter_initialize :default_valuesstore :content, accessors: [:title, :button_text], coder: JSON@@ -30,14 +29,6 @@ module Spree::Cms::Sectionsprivate- def reset_link_attributes- if linked_resource_type_changed?- return if linked_resource_id_was.nil?-- self.linked_resource_id = nil- end- end-def default_valuesself.gutters ||= 'No Gutters'self.fit ||= 'Screen'diff --git a/core/app/models/spree/cms/sections/image_gallery.rb b/core/app/models/spree/cms/sections/image_gallery.rbindex 17f8d03185..ebb0931ad5 100644--- a/core/app/models/spree/cms/sections/image_gallery.rb+++ b/core/app/models/spree/cms/sections/image_gallery.rb@@ -1,7 +1,7 @@module Spree::Cms::Sectionsclass ImageGallery < Spree::CmsSectionafter_initialize :default_values- before_save :reset_link_attributes+ validate :reset_multiple_link_attributesLINKED_RESOURCE_TYPE = if Rails::VERSION::STRING < '6.0'['Spree::Taxon'].freeze@@ -70,7 +70,7 @@ module Spree::Cms::Sectionsprivate- def reset_link_attributes+ def reset_multiple_link_attributesreturn if Rails::VERSION::STRING < '6.0'if link_type_one_changed?diff --git a/core/app/models/spree/cms/sections/side_by_side_images.rb b/core/app/models/spree/cms/sections/side_by_side_images.rbindex 12f813c22f..408c2d7487 100644--- a/core/app/models/spree/cms/sections/side_by_side_images.rb+++ b/core/app/models/spree/cms/sections/side_by_side_images.rb@@ -1,7 +1,7 @@module Spree::Cms::Sectionsclass SideBySideImages < Spree::CmsSectionafter_initialize :default_values- before_save :reset_link_attributes+ validate :reset_multiple_link_attributesLINKED_RESOURCE_TYPE = if Rails::VERSION::STRING < '6.0'['Spree::Taxon'].freeze@@ -48,7 +48,7 @@ module Spree::Cms::Sectionsprivate- def reset_link_attributes+ def reset_multiple_link_attributesreturn if Rails::VERSION::STRING < '6.0'if link_type_one_changed?diff --git a/core/app/models/spree/cms_section.rb b/core/app/models/spree/cms_section.rbindex 9dafbbea70..accf7a12f1 100644--- a/core/app/models/spree/cms_section.rb+++ b/core/app/models/spree/cms_section.rb@@ -5,6 +5,8 @@ module Spreeacts_as_list scope: :cms_pagebelongs_to :cms_page, touch: true+ validate :reset_link_attributes+IMAGE_COUNT = ['one', 'two', 'three']IMAGE_TYPES = ['image/png', 'image/jpg', 'image/jpeg', 'image/gif'].freezeIMAGE_SIZE = ['sm', 'md', 'lg', 'xl']@@ -53,5 +55,15 @@ module Spreedef fullscreen?fit == 'Screen'end++ private++ def reset_link_attributes+ if linked_resource_type_changed?+ return if linked_resource_id_was.nil?++ self.linked_resource_id = nil+ end+ endendenddiff --git a/core/app/models/spree/taxon.rb b/core/app/models/spree/taxon.rbindex 4b07cf5773..8bbc0cc69b 100644--- a/core/app/models/spree/taxon.rb+++ b/core/app/models/spree/taxon.rb@@ -44,6 +44,7 @@ module Spreescope :for_store, ->(store) { joins(:taxonomy).where(spree_taxonomies: { store_id: store.id }) }self.whitelisted_ransackable_associations = %w[taxonomy]+ self.whitelisted_ransackable_attributes = %w[name permalink]scope :for_stores, ->(stores) { joins(:taxonomy).where(spree_taxonomies: { store_id: stores.ids }) }diff --git a/core/config/locales/en.yml b/core/config/locales/en.ymlindex 9d45513d29..622080a51a 100644--- a/core/config/locales/en.yml+++ b/core/config/locales/en.yml@@ -564,6 +564,7 @@ en:draft_mode: Draft Modefull_width: Full widthlink_to_taxon: Link to Taxon+ link_to_product: Link to Producttitle: Titlefit: Fit Toinfo_hero_image_body: "<p>The Hero Image section adds a large image with a button and tagline text to your page.</p>@@ -1349,6 +1350,7 @@ en:backordered_confirm_info: Selected item is backordered so expect delays. Are you sure you want to order it?overview: Overviewpackage_from: package from+ page: Pagepage_not_found: Sorry! Page you are looking can’t be found.pagination:next_page: next page »diff --git a/core/spec/models/spree/cms/sections/image_gallery_spec.rb b/core/spec/models/spree/cms/sections/image_gallery_spec.rbindex c35250f2e2..21c1607963 100644--- a/core/spec/models/spree/cms/sections/image_gallery_spec.rb+++ b/core/spec/models/spree/cms/sections/image_gallery_spec.rb@@ -58,7 +58,7 @@ describe Spree::Cms::Sections::ImageGallery, type: :model doendend- if Rails::VERSION::STRING >= '6.1'+ if Rails::VERSION::STRING >= '6.0'context 'when changing the link types for links one two and three' dolet!(:image_gallery_section) { create(:cms_image_gallery_section, cms_page: homepage) }diff --git a/core/spec/models/spree/cms/sections/side_by_side_images_spec.rb b/core/spec/models/spree/cms/sections/side_by_side_images_spec.rbindex 6044edbe19..378da7a0fb 100644--- a/core/spec/models/spree/cms/sections/side_by_side_images_spec.rb+++ b/core/spec/models/spree/cms/sections/side_by_side_images_spec.rb@@ -46,7 +46,7 @@ describe Spree::Cms::Sections::SideBySideImages, type: :model doendend- if Rails::VERSION::STRING >= '6.1'+ if Rails::VERSION::STRING >= '6.0'context 'when changing the link types for links one and two' dolet!(:side_by_side_images_section) { create(:cms_side_by_side_images_section, cms_page: homepage) }