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.

permit params for shopify and discord (#12922)

Devin Zhanga51ba7dadef1
diff --git a/admin/app/controllers/spree/admin/storefront_controller.rb b/admin/app/controllers/spree/admin/storefront_controller.rb
index 2bb443eb38..9a93775f4e 100644
--- a/admin/app/controllers/spree/admin/storefront_controller.rb
+++ b/admin/app/controllers/spree/admin/storefront_controller.rb
@@ -29,7 +29,7 @@ module Spree
:meta_description, :meta_title, :meta_keywords, :seo_robots,
:facebook, :twitter, :instagram, :linkedin, :youtube, :tiktok, :pinterest,
:storefront_custom_code_head, :storefront_custom_code_body_start,
- :storefront_custom_code_body_end, :storefront_password
+ :storefront_custom_code_body_end, :storefront_password, :spotify, :discord
)
end
diff --git a/admin/spec/controllers/spree/admin/storefront_controller_spec.rb b/admin/spec/controllers/spree/admin/storefront_controller_spec.rb
index e48e9c76a0..7f4a0be8d6 100644
--- a/admin/spec/controllers/spree/admin/storefront_controller_spec.rb
+++ b/admin/spec/controllers/spree/admin/storefront_controller_spec.rb
@@ -23,7 +23,15 @@ describe Spree::Admin::StorefrontController do
{
name: 'New Store Name',
meta_description: 'This is a cool store',
- storefront_password: 'password'
+ storefront_password: 'password',
+ facebook: 'https://www.facebook.com/spreecommerce',
+ instagram: 'https://www.instagram.com/spreecommerce',
+ twitter: 'https://www.twitter.com/spreecommerce',
+ youtube: 'https://www.youtube.com/spreecommerce',
+ pinterest: 'https://www.pinterest.com/spreecommerce',
+ tiktok: 'spreecommerce',
+ spotify: 'https://www.spotify.com/spreecommerce',
+ discord: 'https://www.discord.com/spreecommerce'
}
end
@@ -35,6 +43,14 @@ describe Spree::Admin::StorefrontController do
expect(store.reload.name).to eq('New Store Name')
expect(store.meta_description).to eq('This is a cool store')
expect(store.storefront_password).to eq('password')
+ expect(store.facebook).to eq('https://www.facebook.com/spreecommerce')
+ expect(store.instagram).to eq('https://www.instagram.com/spreecommerce')
+ expect(store.twitter).to eq('https://www.twitter.com/spreecommerce')
+ expect(store.youtube).to eq('https://www.youtube.com/spreecommerce')
+ expect(store.pinterest).to eq('https://www.pinterest.com/spreecommerce')
+ expect(store.tiktok).to eq('spreecommerce')
+ expect(store.spotify).to eq('https://www.spotify.com/spreecommerce')
+ expect(store.discord).to eq('https://www.discord.com/spreecommerce')
end
context 'when removing assets' do
diff --git a/core/app/models/spree/page_link.rb b/core/app/models/spree/page_link.rb
index 866583a8ba..ceba49e20e 100644
--- a/core/app/models/spree/page_link.rb
+++ b/core/app/models/spree/page_link.rb
@@ -30,6 +30,7 @@ module Spree
def formatted_url
return if url.blank?
+ return url if url.start_with?("mailto:")
@formatted_url ||= url.match(/http:\/\/|https:\/\//) ? url : "http://#{url}"
end
diff --git a/core/spec/models/spree/page_link_spec.rb b/core/spec/models/spree/page_link_spec.rb
index 65dd4218a7..e146b6b8dc 100644
--- a/core/spec/models/spree/page_link_spec.rb
+++ b/core/spec/models/spree/page_link_spec.rb
@@ -35,4 +35,32 @@ RSpec.describe Spree::PageLink, type: :model do
end
end
end
+
+ describe '#formatted_url' do
+ it 'returns the formatted url' do
+ page_link = build(:page_link, url: 'https://www.google.com')
+ expect(page_link.formatted_url).to eq('https://www.google.com')
+ end
+
+ context 'url without http' do
+ it 'returns the formatted url' do
+ page_link = build(:page_link, url: 'www.google.com')
+ expect(page_link.formatted_url).to eq('http://www.google.com')
+ end
+ end
+
+ context 'mailto links' do
+ it 'returns the formatted url' do
+ page_link = build(:page_link, url: 'mailto:[email protected]')
+ expect(page_link.formatted_url).to eq('mailto:[email protected]')
+ end
+ end
+
+ context 'url is blank' do
+ it 'returns nil' do
+ page_link = build(:page_link, url: nil)
+ expect(page_link.formatted_url).to be_nil
+ end
+ end
+ end
end
diff --git a/storefront/app/views/themes/default/spree/shared/icons/_discord.html.erb b/storefront/app/views/themes/default/spree/shared/icons/_discord.html.erb
index b718832be6..7c3cf4cb3f 100644
--- a/storefront/app/views/themes/default/spree/shared/icons/_discord.html.erb
+++ b/storefront/app/views/themes/default/spree/shared/icons/_discord.html.erb
@@ -1,9 +1,3 @@
-<svg
- xmlns='http://www.w3.org/2000/svg'
- width='16'
- height='16'
- viewBox='0 0 16 16'
- fill='currentColor'
->
- <path d="M18.942 5.556a16.299 16.299 0 0 0-4.126-1.297c-.178.321-.385.754-.529 1.097a15.175 15.175 0 0 0-4.573 0 11.583 11.583 0 0 0-.535-1.097 16.274 16.274 0 0 0-4.129 1.3c-2.611 3.946-3.319 7.794-2.965 11.587a16.494 16.494 0 0 0 5.061 2.593 12.65 12.65 0 0 0 1.084-1.785 10.689 10.689 0 0 1-1.707-.831c.143-.106.283-.217.418-.331 3.291 1.539 6.866 1.539 10.118 0 .137.114.277.225.418.331-.541.326-1.114.606-1.71.832a12.52 12.52 0 0 0 1.084 1.785 16.46 16.46 0 0 0 5.064-2.595c.415-4.396-.709-8.209-2.973-11.589zM8.678 14.813c-.988 0-1.798-.922-1.798-2.045s.793-2.047 1.798-2.047 1.815.922 1.798 2.047c.001 1.123-.793 2.045-1.798 2.045zm6.644 0c-.988 0-1.798-.922-1.798-2.045s.793-2.047 1.798-2.047 1.815.922 1.798 2.047c0 1.123-.793 2.045-1.798 2.045z"/>
+<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-discord" viewBox="0 0 16 16">
+ <path d="M13.545 2.907a13.2 13.2 0 0 0-3.257-1.011.05.05 0 0 0-.052.025c-.141.25-.297.577-.406.833a12.2 12.2 0 0 0-3.658 0 8 8 0 0 0-.412-.833.05.05 0 0 0-.052-.025c-1.125.194-2.22.534-3.257 1.011a.04.04 0 0 0-.021.018C.356 6.024-.213 9.047.066 12.032q.003.022.021.037a13.3 13.3 0 0 0 3.995 2.02.05.05 0 0 0 .056-.019q.463-.63.818-1.329a.05.05 0 0 0-.01-.059l-.018-.011a9 9 0 0 1-1.248-.595.05.05 0 0 1-.02-.066l.015-.019q.127-.095.248-.195a.05.05 0 0 1 .051-.007c2.619 1.196 5.454 1.196 8.041 0a.05.05 0 0 1 .053.007q.121.1.248.195a.05.05 0 0 1-.004.085 8 8 0 0 1-1.249.594.05.05 0 0 0-.03.03.05.05 0 0 0 .003.041c.24.465.515.909.817 1.329a.05.05 0 0 0 .056.019 13.2 13.2 0 0 0 4.001-2.02.05.05 0 0 0 .021-.037c.334-3.451-.559-6.449-2.366-9.106a.03.03 0 0 0-.02-.019m-8.198 7.307c-.789 0-1.438-.724-1.438-1.612s.637-1.613 1.438-1.613c.807 0 1.45.73 1.438 1.613 0 .888-.637 1.612-1.438 1.612m5.316 0c-.788 0-1.438-.724-1.438-1.612s.637-1.613 1.438-1.613c.807 0 1.451.73 1.438 1.613 0 .888-.631 1.612-1.438 1.612"/>
</svg>