Skip to content

armgit / spree

Public Imported from GitHub
0

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.

improve tests for values on change of type

Matthew Kennedy276e8db6e885
diff --git a/core/spec/models/spree/cms/sections/image_gallery_spec.rb b/core/spec/models/spree/cms/sections/image_gallery_spec.rb
index 0f7985e7c6..c35250f2e2 100644
--- a/core/spec/models/spree/cms/sections/image_gallery_spec.rb
+++ b/core/spec/models/spree/cms/sections/image_gallery_spec.rb
@@ -77,9 +77,23 @@ describe Spree::Cms::Sections::ImageGallery, type: :model do
section.reload
end
+ it 'link_one, link_two and save the initail values' do
+ section = Spree::CmsSection.find(image_gallery_section.id)
+
+ expect(section.link_one).to eql 'Shirt 1'
+ expect(section.link_two).to eql 'Shirt 2'
+ expect(section.link_three).to eql 'Shirt 3'
+ end
+
it 'link_one, link_two and link_three are reset to nil' do
section = Spree::CmsSection.find(image_gallery_section.id)
+ section.content[:link_type_one] = 'Spree::Taxon'
+ section.content[:link_type_two] = 'Spree::Taxon'
+ section.content[:link_type_three] = 'Spree::Taxon'
+ section.save!
+ section.reload
+
expect(section.link_one).to be nil
expect(section.link_two).to be nil
expect(section.link_three).to be nil
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.rb
index 6059b2f207..6044edbe19 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
@@ -63,9 +63,21 @@ describe Spree::Cms::Sections::SideBySideImages, type: :model do
section.reload
end
- it 'link_one and link_two are reset to nil' do
+ it 'link_one and link_two save the values correctly' do
section = Spree::CmsSection.find(side_by_side_images_section.id)
+ expect(section.link_one).to eql 'Shirt 1'
+ expect(section.link_two).to eql 'Shirt 2'
+ end
+
+ it 'link_one and link_two are reset to nil when type is changed' do
+ section = Spree::CmsSection.find(side_by_side_images_section.id)
+
+ section.content[:link_type_one] = 'Spree::Taxon'
+ section.content[:link_type_two] = 'Spree::Taxon'
+ section.save!
+ section.reload
+
expect(section.link_one).to be nil
expect(section.link_two).to be nil
end