solidus_multi_domain 1.1.3 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1b9c1fa3385d3591e2108d27bf82b62191b0de5b
4
- data.tar.gz: 87f182e7c3081372437abd54cca46068b9bc77eb
3
+ metadata.gz: 7b8bdc0340da89be57fbe0bc2b9bb9bf6044576e
4
+ data.tar.gz: 5973b260b06c23a72a87aa8e8337ae441dec038f
5
5
  SHA512:
6
- metadata.gz: 22245c44898f38230eca433a29d6e8605db1987ac25e7a0513acb5a1fc93c0c3fecfa12bd29e2e84061c428f525780d57859f3901bba585b673d1ad86427c02f
7
- data.tar.gz: 8785ecb9d2d1fc91146b2374c9ef7d717fa355b7be15e4aed53ac0649a0a5d7933796c0782975612b423d3460909ecc921c958da27e8e5eff8494dbf206a6367
6
+ metadata.gz: d66c31d78d2f144edd1b3b145ca0226968f9e52eb7e15fc332c8583287ae906f6c047c924e42b0f5ed6e84b78a46da7210df147667771d3027ad7b3d55091869
7
+ data.tar.gz: d3f62ce75db1290aa3eb6369d18dbcfec2c77b1f213777ad846b693b9032a27af584ed36cfc008e6bc386aaa82a52ca59c89bd15bc6af8d5aa483c03febb3bbb
@@ -1,7 +1,19 @@
1
1
  Spree::Tracker.class_eval do
2
2
  belongs_to :store
3
3
 
4
- def self.current(store_key)
5
- Spree::Tracker.where(active: true).joins(:store).where("spree_stores.code = ? OR spree_stores.url LIKE ?", store_key, "%#{store_key}%").first
4
+ def self.current(store)
5
+ if store.is_a?(Spree::Store)
6
+ Spree::Tracker.where(active: true, store_id: store).first
7
+ else
8
+ # TODO: Remove in 2.0
9
+ ActiveSupport::Deprecation.warn <<-EOS.squish, caller
10
+ Calling Spree::Tracker.current with a string is DEPRECATED. Instead
11
+ pass it an instance of Spree::Store.
12
+ EOS
13
+ Spree::Tracker.where(active: true).joins(:store).where(
14
+ "spree_stores.code = ? OR spree_stores.url LIKE ?",
15
+ store, "%#{store}%"
16
+ ).first
17
+ end
6
18
  end
7
19
  end
@@ -15,7 +15,7 @@ module SpreeMultiDomain
15
15
  end
16
16
 
17
17
  def current_tracker
18
- @current_tracker ||= Spree::Tracker.current(store_key)
18
+ @current_tracker ||= Spree::Tracker.current(current_store)
19
19
  end
20
20
 
21
21
  def get_taxonomies
@@ -27,10 +27,5 @@ module SpreeMultiDomain
27
27
  def add_current_store_id_to_params
28
28
  params[:current_store_id] = current_store.try(:id)
29
29
  end
30
-
31
- private
32
- def store_key
33
- request.headers['HTTP_SPREE_STORE'] || request.env['SERVER_NAME']
34
- end
35
30
  end
36
31
  end
@@ -3,7 +3,7 @@
3
3
  Gem::Specification.new do |s|
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.name = "solidus_multi_domain"
6
- s.version = "1.1.3"
6
+ s.version = "1.2.0"
7
7
  s.summary = "Adds multiple site support to Solidus"
8
8
  s.description = "Multiple Solidus stores on different domains - single unified backed for processing orders."
9
9
  s.required_ruby_version = ">= 2.1"
@@ -9,11 +9,21 @@ describe Spree::Tracker do
9
9
  @tracker2 = FactoryGirl.create(:tracker, store: @another_store)
10
10
  end
11
11
 
12
- it "pulls out the current tracker based on store code" do
13
- expect(Spree::Tracker.current('STORE2')).to eq @tracker2
12
+ it "finds tracker by store" do
13
+ expect(Spree::Tracker.current(@store)).to eq @tracker
14
14
  end
15
15
 
16
- it "pulls out the current tracker" do
17
- expect(Spree::Tracker.current(@store.url)).to eq @tracker
16
+ it "finds tracker based on store code" do
17
+ aggregate_failures do
18
+ expect(ActiveSupport::Deprecation).to receive(:warn)
19
+ expect(Spree::Tracker.current('STORE2')).to eq @tracker2
20
+ end
21
+ end
22
+
23
+ it "finds tracker based on store url" do
24
+ aggregate_failures do
25
+ expect(ActiveSupport::Deprecation).to receive(:warn)
26
+ expect(Spree::Tracker.current(@store.url)).to eq @tracker
27
+ end
18
28
  end
19
29
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_multi_domain
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Solidus Team