shopping_mall 0.0.4 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/Rakefile +2 -2
- data/app/models/spree/zone_decorator.rb +0 -26
- data/lib/shopping_mall/version.rb +1 -1
- data/spec/spec_helper.rb +17 -13
- metadata +10 -11
- data/app/models/spree/zone_member_decorator.rb +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c31f20bcc6bebef0f76579bc3f50ba5d928bc1f
|
4
|
+
data.tar.gz: 48d1d76291834d7ab8fbe02b453a98956f800bfb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32942545208ca96bbf3ed987fd4cfdd43497488838222f15287b628fa42e4fc5548a73386b3dc3f3fdc38fb81c7bf94064062359a6136173eb450815005d4d39
|
7
|
+
data.tar.gz: adddba58ba6137d73cff51a5c2dc110f22301dd9636cc5718fa38fdf5e8d22e2aa69005cb5406cd4561edd5adb5f9387692cbcab85271add378d4773e0cfb808
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Shopping Mall
|
2
2
|
|
3
|
-
Multi-tenancy for Spree
|
3
|
+
Multi-tenancy for Spree 3.0.x using the [Apartment](https://github.com/influitive/apartment) gem and [Postgres](http://www.postgresql.org/) as the database.
|
4
4
|
|
5
5
|
[![Build Status](https://travis-ci.org/groundctrl/shopping_mall.svg?branch=master)](https://travis-ci.org/groundctrl/shopping_mall)
|
6
6
|
[![Code Climate](https://codeclimate.com/github/groundctrl/shopping_mall.png)](https://codeclimate.com/github/groundctrl/shopping_mall)
|
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@ require 'bundler'
|
|
2
2
|
Bundler::GemHelper.install_tasks
|
3
3
|
|
4
4
|
require 'rspec/core/rake_task'
|
5
|
-
require 'spree/testing_support/
|
5
|
+
require 'spree/testing_support/extension_rake'
|
6
6
|
|
7
7
|
RSpec::Core::RakeTask.new
|
8
8
|
|
@@ -12,5 +12,5 @@ desc 'Generates a dummy app for testing'
|
|
12
12
|
task :test_app do
|
13
13
|
ENV['LIB_NAME'] = 'shopping_mall'
|
14
14
|
ENV['DB'] = 'postgres'
|
15
|
-
Rake::Task[
|
15
|
+
Rake::Task["extension:test_app"].invoke
|
16
16
|
end
|
@@ -3,30 +3,4 @@ Spree::Zone.class_eval do
|
|
3
3
|
has_many :shipping_methods,
|
4
4
|
through: :shipping_methods_zones,
|
5
5
|
class_name: 'Spree::ShippingMethod'
|
6
|
-
|
7
|
-
scope :order_by_members, -> { order(:zone_members_count, :created_at) }
|
8
|
-
scope :where_country_or_state, ->(address) {
|
9
|
-
where(Spree::ZoneMember.arel_where_country_or_state(address))
|
10
|
-
}
|
11
|
-
scope :matching_zones_for, ->(address) {
|
12
|
-
includes(:zone_members).
|
13
|
-
where_country_or_state(address).
|
14
|
-
order_by_members.
|
15
|
-
references(:zones)
|
16
|
-
}
|
17
|
-
|
18
|
-
class << self
|
19
|
-
alias_method :old_match, :match
|
20
|
-
end
|
21
|
-
|
22
|
-
def self.match(address)
|
23
|
-
return unless address && matches = matching_zones_for(address)
|
24
|
-
|
25
|
-
%w(state country).each do |zone_kind|
|
26
|
-
match = matches.detect { |zone| zone_kind == zone.kind }
|
27
|
-
return match if match
|
28
|
-
end
|
29
|
-
|
30
|
-
matches.first
|
31
|
-
end
|
32
6
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
require 'simplecov'
|
2
|
-
|
2
|
+
|
3
|
+
SimpleCov.start do
|
4
|
+
add_filter 'spec/dummy'
|
5
|
+
end
|
3
6
|
|
4
7
|
ENV['RAILS_ENV'] = 'test'
|
5
8
|
|
@@ -10,34 +13,35 @@ rescue LoadError
|
|
10
13
|
exit
|
11
14
|
end
|
12
15
|
|
16
|
+
require 'pry-byebug'
|
13
17
|
require 'rspec/rails'
|
14
|
-
require 'shoulda-matchers'
|
15
|
-
require 'ffaker'
|
16
|
-
require 'database_cleaner'
|
17
18
|
require 'capybara'
|
18
|
-
require 'capybara/rspec'
|
19
|
-
require 'capybara/rails'
|
20
19
|
require 'capybara/poltergeist'
|
20
|
+
require 'capybara/rails'
|
21
|
+
require 'capybara/rspec'
|
22
|
+
require 'database_cleaner'
|
23
|
+
require 'ffaker'
|
24
|
+
require 'shoulda-matchers'
|
21
25
|
|
22
26
|
Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each {|f| require f }
|
23
27
|
|
24
|
-
require 'spree/testing_support/factories'
|
25
|
-
require 'spree/testing_support/controller_requests'
|
26
28
|
require 'spree/testing_support/authorization_helpers'
|
27
|
-
require 'spree/testing_support/url_helpers'
|
28
29
|
require 'spree/testing_support/capybara_ext'
|
30
|
+
require 'spree/testing_support/controller_requests'
|
31
|
+
require 'spree/testing_support/factories'
|
32
|
+
require 'spree/testing_support/url_helpers'
|
29
33
|
|
30
34
|
FactoryGirl.find_definitions
|
31
35
|
|
32
36
|
RSpec.configure do |config|
|
33
|
-
config.
|
34
|
-
|
35
|
-
config.include FactoryGirl::Syntax::Methods
|
37
|
+
config.infer_spec_type_from_file_location!
|
38
|
+
|
36
39
|
config.include Spree::TestingSupport::UrlHelpers
|
37
40
|
config.include Devise::TestHelpers, type: :controller
|
41
|
+
config.include FactoryGirl::Syntax::Methods
|
42
|
+
|
38
43
|
config.use_transactional_fixtures = false
|
39
44
|
config.expose_current_running_example_as :example
|
40
|
-
config.infer_spec_type_from_file_location!
|
41
45
|
|
42
46
|
config.before(:suite) do
|
43
47
|
DatabaseCleaner.strategy = :transaction
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shopping_mall
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vincent Franco
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-08-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: apartment
|
@@ -31,14 +31,14 @@ dependencies:
|
|
31
31
|
requirements:
|
32
32
|
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version:
|
34
|
+
version: 3.0.3
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version:
|
41
|
+
version: 3.0.3
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: ffaker
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -194,19 +194,19 @@ dependencies:
|
|
194
194
|
- !ruby/object:Gem::Version
|
195
195
|
version: '4.2'
|
196
196
|
- !ruby/object:Gem::Dependency
|
197
|
-
name: pry
|
197
|
+
name: pry-byebug
|
198
198
|
requirement: !ruby/object:Gem::Requirement
|
199
199
|
requirements:
|
200
200
|
- - "~>"
|
201
201
|
- !ruby/object:Gem::Version
|
202
|
-
version: '
|
202
|
+
version: '3.2'
|
203
203
|
type: :development
|
204
204
|
prerelease: false
|
205
205
|
version_requirements: !ruby/object:Gem::Requirement
|
206
206
|
requirements:
|
207
207
|
- - "~>"
|
208
208
|
- !ruby/object:Gem::Version
|
209
|
-
version: '
|
209
|
+
version: '3.2'
|
210
210
|
- !ruby/object:Gem::Dependency
|
211
211
|
name: pg
|
212
212
|
requirement: !ruby/object:Gem::Requirement
|
@@ -235,7 +235,7 @@ dependencies:
|
|
235
235
|
- - "~>"
|
236
236
|
- !ruby/object:Gem::Version
|
237
237
|
version: '2.5'
|
238
|
-
description: Multi-tenancy for Spree
|
238
|
+
description: Multi-tenancy for Spree 3.x.x
|
239
239
|
email:
|
240
240
|
executables: []
|
241
241
|
extensions: []
|
@@ -263,7 +263,6 @@ files:
|
|
263
263
|
- app/models/spree/user_decorator.rb
|
264
264
|
- app/models/spree/variant_decorator.rb
|
265
265
|
- app/models/spree/zone_decorator.rb
|
266
|
-
- app/models/spree/zone_member_decorator.rb
|
267
266
|
- config/initializers/shopping_mall_initializer.rb
|
268
267
|
- db/migrate/20140611225105_hatbm_to_hmt.rb
|
269
268
|
- lib/generators/shopping_mall/install_generator.rb
|
@@ -301,7 +300,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
301
300
|
requirements:
|
302
301
|
- - ">="
|
303
302
|
- !ruby/object:Gem::Version
|
304
|
-
version: 1.
|
303
|
+
version: 2.1.0
|
305
304
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
306
305
|
requirements:
|
307
306
|
- - ">="
|
@@ -313,7 +312,7 @@ rubyforge_project:
|
|
313
312
|
rubygems_version: 2.4.5
|
314
313
|
signing_key:
|
315
314
|
specification_version: 4
|
316
|
-
summary: Multi-tenancy for Spree
|
315
|
+
summary: Multi-tenancy for Spree 3.x.x
|
317
316
|
test_files:
|
318
317
|
- spec/features/tenancy_spec.rb
|
319
318
|
- spec/models/spree/option_type_decorator_spec.rb
|
@@ -1,16 +0,0 @@
|
|
1
|
-
Spree::ZoneMember.class_eval do
|
2
|
-
%w(country state).each do |type|
|
3
|
-
define_singleton_method "arel_and_in_#{type}_id" do |type_id|
|
4
|
-
send(:"with_#{type}_id", type_id).where_values.reduce(:and)
|
5
|
-
end
|
6
|
-
|
7
|
-
scope :"with_#{type}_id", ->(type_id) {
|
8
|
-
where(zoneable_type: "Spree::#{type.capitalize}", zoneable_id: type_id)
|
9
|
-
}
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.arel_where_country_or_state(address)
|
13
|
-
countries = arel_and_in_country_id address.country_id
|
14
|
-
countries.or(arel_and_in_state_id address.state_id)
|
15
|
-
end
|
16
|
-
end
|