shopping_mall 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +27 -0
- data/.rspec +1 -0
- data/.travis.yml +7 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +22 -0
- data/README.md +94 -0
- data/Rakefile +16 -0
- data/app/models/spree/option_type_decorator.rb +7 -0
- data/app/models/spree/option_types_prototype.rb +6 -0
- data/app/models/spree/option_value_decorator.rb +6 -0
- data/app/models/spree/option_values_variant.rb +6 -0
- data/app/models/spree/order_decorator.rb +6 -0
- data/app/models/spree/orders_promotion.rb +6 -0
- data/app/models/spree/product_decorator.rb +6 -0
- data/app/models/spree/products_promotion_rule.rb +6 -0
- data/app/models/spree/promotion_decorator.rb +4 -0
- data/app/models/spree/promotion_rule_decorator.rb +6 -0
- data/app/models/spree/properties_prototype.rb +6 -0
- data/app/models/spree/property_decorator.rb +16 -0
- data/app/models/spree/prototype_decorator.rb +10 -0
- data/app/models/spree/role_decorator.rb +4 -0
- data/app/models/spree/roles_user.rb +6 -0
- data/app/models/spree/shipping_method_decorator.rb +4 -0
- data/app/models/spree/shipping_methods_zone.rb +6 -0
- data/app/models/spree/user_decorator.rb +4 -0
- data/app/models/spree/variant_decorator.rb +6 -0
- data/app/models/spree/zone_decorator.rb +32 -0
- data/app/models/spree/zone_member_decorator.rb +16 -0
- data/config/initializers/shopping_mall_initializer.rb +3 -0
- data/db/migrate/20140611225105_hatbm_to_hmt.rb +17 -0
- data/lib/generators/shopping_mall/install_generator.rb +41 -0
- data/lib/generators/templates/shopping_mall.rb +20 -0
- data/lib/shopping_mall/engine.rb +18 -0
- data/lib/shopping_mall/escalator.rb +20 -0
- data/lib/shopping_mall/version.rb +3 -0
- data/lib/shopping_mall.rb +50 -0
- data/lib/tasks/db.rake +41 -0
- data/shopping_mall.gemspec +40 -0
- data/spec/features/tenancy_spec.rb +13 -0
- data/spec/models/spree/option_type_decorator_spec.rb +12 -0
- data/spec/models/spree/option_value_decorator_spec.rb +12 -0
- data/spec/models/spree/order_decorator_spec.rb +13 -0
- data/spec/models/spree/product_decorator_spec.rb +12 -0
- data/spec/models/spree/promotion_decorator_spec.rb +12 -0
- data/spec/models/spree/property_decorator_spec.rb +21 -0
- data/spec/models/spree/prototype_decorator_spec.rb +19 -0
- data/spec/models/spree/role_decorator_spec.rb +14 -0
- data/spec/models/spree/shipping_method_decorator_spec.rb +12 -0
- data/spec/models/spree/user_decorator_spec.rb +16 -0
- data/spec/models/spree/variant_decorator_spec.rb +13 -0
- data/spec/models/spree/zone_decorator_spec.rb +78 -0
- data/spec/shopping_mall/config_spec.rb +37 -0
- data/spec/shopping_mall/escalator_spec.rb +31 -0
- data/spec/spec_helper.rb +49 -0
- metadata +353 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 80758149dcc1e0346c9e1abfe3517d3b98eb1ed5
|
4
|
+
data.tar.gz: 56a568442842bf76231302dba3fd02ab72e40306
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1cf4fb7093cfe5c15b5b311c886d482b3df460f0c6ee2fe623b8e6d5757d40cece08ed884882daada120a791f941daea9727f28b36e1efa12ea3e8fe21a2d521
|
7
|
+
data.tar.gz: 6f85554940b37823252822bce83fa503857f77c21fa24565011f3bbc56a3658b38b708545b5c9ece813c13860bc4efd181f5472d84c731b607176f4b698253dd
|
data/.gitignore
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
*.gem
|
2
|
+
.DS_Store
|
3
|
+
*.rbc
|
4
|
+
.bundle
|
5
|
+
.config
|
6
|
+
.yardoc
|
7
|
+
.ruby-version
|
8
|
+
Gemfile.lock
|
9
|
+
InstalledFiles
|
10
|
+
_yardoc
|
11
|
+
coverage
|
12
|
+
doc/
|
13
|
+
lib/bundler/man
|
14
|
+
pkg
|
15
|
+
rdoc
|
16
|
+
spec/reports
|
17
|
+
test/tmp
|
18
|
+
test/version_tmp
|
19
|
+
tmp
|
20
|
+
spec/dummy/*
|
21
|
+
db/*.sqlite3
|
22
|
+
*.bundle
|
23
|
+
*.so
|
24
|
+
*.o
|
25
|
+
*.a
|
26
|
+
mkmf.log
|
27
|
+
rspec.log
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color -d
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 ground(ctrl)
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
# Shopping Mall
|
2
|
+
|
3
|
+
Multi-tenancy for Spree 2.3+ using Apartment! This is very alpha. Pull requests are welcomed.
|
4
|
+
|
5
|
+
[![Build Status](https://travis-ci.org/groundctrl/shopping_mall.svg?branch=master)](https://travis-ci.org/groundctrl/shopping_mall)
|
6
|
+
[![Code Climate](https://codeclimate.com/github/groundctrl/shopping_mall.png)](https://codeclimate.com/github/groundctrl/shopping_mall)
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
#### Bleeding edge
|
11
|
+
Add this line to your Spree application's Gemfile:
|
12
|
+
|
13
|
+
gem 'spree', github: 'groundctrl/shopping_mall'
|
14
|
+
|
15
|
+
|
16
|
+
#### Gem (Not ready yet.)
|
17
|
+
Add this line to your Spree application's Gemfile:
|
18
|
+
> NOTE: Gem is yet to be released (Spree 2.3 isn't out yet.)
|
19
|
+
|
20
|
+
gem 'shopping_mall' # Soon.
|
21
|
+
|
22
|
+
|
23
|
+
#### Generators
|
24
|
+
Run the bundle command to install it
|
25
|
+
|
26
|
+
After installing ShoppingMall you'll need to run the generator:
|
27
|
+
|
28
|
+
rails generate shopping_mall:install
|
29
|
+
|
30
|
+
Install adds a `shopping_mall.rb` initializer to your app, and adds the following to your `application.rb`:
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
config.middleware.insert_before(
|
34
|
+
'ActiveRecord::ConnectionAdapters::ConnectionManagement',
|
35
|
+
'ShoppingMall::Escalator'
|
36
|
+
)
|
37
|
+
```
|
38
|
+
See https://github.com/influitive/apartment/issues/134 for more information on this insert_before hack.
|
39
|
+
|
40
|
+
## Config
|
41
|
+
|
42
|
+
The following config options should be set up in the `shopping_mall.rb` initializer in your apps config:
|
43
|
+
|
44
|
+
config/initializers/shopping_mall.rb
|
45
|
+
|
46
|
+
#### Escalators
|
47
|
+
|
48
|
+
Escalators are thinly wrapped Apartment::Elevators, the current escalators available are: `Subdomain`, `Domain`, and `FirstSubdomain`
|
49
|
+
|
50
|
+
#### Excluding Models
|
51
|
+
|
52
|
+
If you have some models that should always access the 'public' tenant, you can specify this by configuring Apartment using `ShoppingMall.configure`. This will yield a config object for you. You can set excluded models like so:
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
config.excluded_models = ["Spree::User", ...] # these models will not be multi-tenanted, but remain in the global (public) namespace
|
56
|
+
```
|
57
|
+
|
58
|
+
Out of the box ShoppingMall has the following Spree models excluded
|
59
|
+
|
60
|
+
```ruby
|
61
|
+
[
|
62
|
+
'Spree::Country',
|
63
|
+
'Spree::Property',
|
64
|
+
'Spree::Prototype',
|
65
|
+
'Spree::Role',
|
66
|
+
'Spree::State',
|
67
|
+
'Spree::TaxRate',
|
68
|
+
'Spree::Tracker',
|
69
|
+
'Spree::User',
|
70
|
+
'Spree::Zone',
|
71
|
+
'Spree::ZoneMember'
|
72
|
+
]
|
73
|
+
```
|
74
|
+
|
75
|
+
> NOTE: Rails will always access the 'public' tenant when accessing these models, but note that tables will be created in all schemas. This may not be ideal, but its done this way because otherwise rails wouldn't be able to properly generate the schema.rb file.
|
76
|
+
|
77
|
+
|
78
|
+
## Testing
|
79
|
+
|
80
|
+
Generate a dummy application
|
81
|
+
|
82
|
+
bundle exec rake test_app
|
83
|
+
|
84
|
+
Running tests
|
85
|
+
|
86
|
+
bundle exec rake spec
|
87
|
+
|
88
|
+
## Contributing
|
89
|
+
|
90
|
+
1. Fork it ( https://github.com/groundctrl/apartment_spree/fork )
|
91
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
92
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
93
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
94
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
3
|
+
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
require 'spree/testing_support/common_rake'
|
6
|
+
|
7
|
+
RSpec::Core::RakeTask.new
|
8
|
+
|
9
|
+
task :default => [:spec]
|
10
|
+
|
11
|
+
desc 'Generates a dummy app for testing'
|
12
|
+
task :test_app do
|
13
|
+
ENV['LIB_NAME'] = 'shopping_mall'
|
14
|
+
ENV['DB'] = 'postgres'
|
15
|
+
Rake::Task['common:test_app'].invoke 'Spree::User'
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
Spree::Property.class_eval do
|
2
|
+
has_many :properties_prototypes, class_name: 'Spree::PropertiesPrototype'
|
3
|
+
has_many :prototypes,
|
4
|
+
through: :properties_prototypes,
|
5
|
+
class_name: 'Spree::Prototype'
|
6
|
+
|
7
|
+
class << self
|
8
|
+
alias_method :old_find_all_by_prototype, :find_all_by_prototype
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.find_all_by_prototype(prototype)
|
12
|
+
id = prototype
|
13
|
+
id = prototype.id if prototype.class == Spree::Prototype
|
14
|
+
Spree::PropertiesPrototype.where(prototype_id: id).map(&:property)
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
Spree::Prototype.class_eval do
|
2
|
+
has_many :properties_prototypes, class_name: 'Spree::PropertiesPrototype'
|
3
|
+
has_many :properties,
|
4
|
+
through: :properties_prototypes,
|
5
|
+
class_name: 'Spree::Property'
|
6
|
+
has_many :option_types_prototypes
|
7
|
+
has_many :option_types,
|
8
|
+
through: :option_types_prototypes,
|
9
|
+
class_name: 'Spree::OptionType'
|
10
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
Spree::Zone.class_eval do
|
2
|
+
has_many :shipping_methods_zones, class_name: 'Spree::ShippingMethodsZone'
|
3
|
+
has_many :shipping_methods,
|
4
|
+
through: :shipping_methods_zones,
|
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
|
+
end
|
@@ -0,0 +1,16 @@
|
|
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
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class HatbmToHmt < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
tables_to_mutate.each { |tbl| add_column tbl, :id, :primary_key }
|
4
|
+
end
|
5
|
+
|
6
|
+
def tables_to_mutate
|
7
|
+
[
|
8
|
+
:spree_option_types_prototypes,
|
9
|
+
:spree_option_values_variants,
|
10
|
+
:spree_orders_promotions,
|
11
|
+
:spree_products_promotion_rules,
|
12
|
+
:spree_properties_prototypes,
|
13
|
+
:spree_roles_users,
|
14
|
+
:spree_shipping_methods_zones
|
15
|
+
]
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'rails/generators/base'
|
2
|
+
|
3
|
+
module ShoppingMall
|
4
|
+
module Generators
|
5
|
+
class InstallGenerator < Rails::Generators::Base
|
6
|
+
source_root File.expand_path('../../templates', __FILE__)
|
7
|
+
|
8
|
+
desc 'Creates initializer and inserts middleware'
|
9
|
+
|
10
|
+
def copy_initializer
|
11
|
+
template 'shopping_mall.rb', 'config/initializers/shopping_mall.rb'
|
12
|
+
end
|
13
|
+
|
14
|
+
def copy_middleware
|
15
|
+
application do
|
16
|
+
<<-STR
|
17
|
+
|
18
|
+
# Inserted with shopping_mall:install
|
19
|
+
config.middleware.insert_before(
|
20
|
+
'ActiveRecord::ConnectionAdapters::ConnectionManagement',
|
21
|
+
'ShoppingMall::Escalator'
|
22
|
+
)
|
23
|
+
STR
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def add_migrations
|
28
|
+
run 'bundle exec rake railties:install:migrations FROM=shopping_mall'
|
29
|
+
end
|
30
|
+
|
31
|
+
def run_migrations
|
32
|
+
res = ask 'Would you like to run the migrations now? [Y/n]'
|
33
|
+
if ['', 'y'].include?(res.downcase)
|
34
|
+
run 'bundle exec rake db:migrate'
|
35
|
+
else
|
36
|
+
logger 'Skipping rake db:migrate, don\'t forget to run it!'
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
ShoppingMall.configure do |config|
|
2
|
+
# Available escalators %w[Subdomain Domain FirstSubdomain]
|
3
|
+
config.escalator = 'Subdomain'
|
4
|
+
# By default ShoppingMall excludes the following Spree models
|
5
|
+
# [
|
6
|
+
# 'Spree::Country',
|
7
|
+
# 'Spree::Property',
|
8
|
+
# 'Spree::Prototype',
|
9
|
+
# 'Spree::Role',
|
10
|
+
# 'Spree::State',
|
11
|
+
# 'Spree::TaxRate',
|
12
|
+
# 'Spree::Tracker',
|
13
|
+
# 'Spree::User',
|
14
|
+
# 'Spree::Zone',
|
15
|
+
# 'Spree::ZoneMember'
|
16
|
+
# ]
|
17
|
+
#
|
18
|
+
# Feel free to exclude what you want!
|
19
|
+
#config.exluded_models = ['Some::AwesomeModel']
|
20
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module ShoppingMall
|
2
|
+
class Engine < Rails::Engine
|
3
|
+
require 'spree/core'
|
4
|
+
isolate_namespace Spree
|
5
|
+
engine_name 'shopping_mall'
|
6
|
+
|
7
|
+
config.autoload_paths += Dir["#{config.root}/lib"]
|
8
|
+
config.generators { |gen| gen.test_framework :rspec }
|
9
|
+
|
10
|
+
def self.activate
|
11
|
+
Dir[File.join(__dir__, '../../app/**/*_decorator*.rb')].each do |klass|
|
12
|
+
Rails.application.config.cache_classes ? require(klass) : load(klass)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
config.to_prepare(&method(:activate).to_proc)
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module ShoppingMall
|
2
|
+
class Escalator
|
3
|
+
attr_reader :app, :escalator
|
4
|
+
|
5
|
+
def initialize(app)
|
6
|
+
@app = app
|
7
|
+
@escalator = _escalator_factory app
|
8
|
+
end
|
9
|
+
|
10
|
+
def call(env)
|
11
|
+
escalator.call env
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def _escalator_factory(app)
|
17
|
+
ShoppingMall.escalator_class.new app
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spree_core'
|
2
|
+
require 'apartment'
|
3
|
+
require 'apartment/elevators/domain'
|
4
|
+
require 'apartment/elevators/first_subdomain'
|
5
|
+
require 'apartment/elevators/subdomain'
|
6
|
+
require 'shopping_mall/version'
|
7
|
+
require 'shopping_mall/engine'
|
8
|
+
require 'shopping_mall/escalator'
|
9
|
+
|
10
|
+
module ShoppingMall
|
11
|
+
|
12
|
+
DEFAULT_SPREE_EXCLUSIONS = [
|
13
|
+
'Spree::Country',
|
14
|
+
'Spree::Property',
|
15
|
+
'Spree::Prototype',
|
16
|
+
'Spree::Role',
|
17
|
+
'Spree::State',
|
18
|
+
'Spree::TaxRate',
|
19
|
+
'Spree::Tracker',
|
20
|
+
'Spree::User',
|
21
|
+
'Spree::Zone',
|
22
|
+
'Spree::ZoneMember'
|
23
|
+
]
|
24
|
+
|
25
|
+
ESCALATORS = %w(Domain FirstSubdomain Subdomain)
|
26
|
+
|
27
|
+
def self.configure
|
28
|
+
yield self if block_given?
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.excluded_models
|
32
|
+
Apartment.excluded_models
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.excluded_models=(models)
|
36
|
+
Apartment.configure { |config| config.excluded_models = models }
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.escalator
|
40
|
+
@escalator ||= 'Subdomain'
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.escalator=(escalator)
|
44
|
+
@escalator = escalator
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.escalator_class
|
48
|
+
"Apartment::Elevators::#{escalator}".constantize
|
49
|
+
end
|
50
|
+
end
|
data/lib/tasks/db.rake
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
namespace :tenant do
|
2
|
+
desc "Bootstraps a new tenant."
|
3
|
+
task :bootstrap, [:db_name] => [:environment] do |t, args|
|
4
|
+
if args[:db_name].blank?
|
5
|
+
abort %q(You must supply db_name, with "rake tenant:bootstrap['the_db_name']")
|
6
|
+
end
|
7
|
+
|
8
|
+
db_name = args[:db_name].gsub('-','_')
|
9
|
+
|
10
|
+
puts "Creating database: #{db_name}"
|
11
|
+
ActiveRecord::Base.establish_connection
|
12
|
+
ActiveRecord::Base.connection.execute("DROP SCHEMA IF EXISTS #{db_name} CASCADE")
|
13
|
+
Apartment::Database.create db_name
|
14
|
+
|
15
|
+
ENV['RAILS_CACHE_ID'] = db_name
|
16
|
+
Apartment::Database.process(db_name) do
|
17
|
+
ENV['AUTO_ACCEPT'] = 'true'
|
18
|
+
ENV['SKIP_NAG'] = 'yes'
|
19
|
+
if Rails.env.production?
|
20
|
+
admin = Spree::User.find_or_create_by(email: email).tap do |user|
|
21
|
+
user.email = 'god@apartment.com'
|
22
|
+
user.login = user.email
|
23
|
+
user.password = 'elevateme'
|
24
|
+
user.password_confirmation = 'elevateme'
|
25
|
+
end
|
26
|
+
|
27
|
+
admin.roles << Spree::Role.find_or_create_by_name('admin')
|
28
|
+
admin.save
|
29
|
+
end
|
30
|
+
|
31
|
+
# Hack the current method so we're able to return a gateway without a RAILS_ENV
|
32
|
+
Spree::Gateway.class_eval do
|
33
|
+
def self.current
|
34
|
+
Spree::Gateway::Bogus.new
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
puts "Bootstrap completed successfully"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'shopping_mall/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.platform = Gem::Platform::RUBY
|
8
|
+
spec.name = 'shopping_mall'
|
9
|
+
spec.version = ShoppingMall::VERSION
|
10
|
+
spec.authors = ['Vincent Franco', 'David Freerksen']
|
11
|
+
spec.summary = 'Multi-tenancy for Spree >= 2.3'
|
12
|
+
spec.license = 'MIT'
|
13
|
+
spec.description = spec.summary
|
14
|
+
spec.required_ruby_version = '>= 1.9.3'
|
15
|
+
|
16
|
+
spec.homepage = 'http://github.com/groundctrl/shopping_mall'
|
17
|
+
spec.files = `git ls-files`.split("\n")
|
18
|
+
spec.test_files = `git ls-files -- spec/*`.split("\n")
|
19
|
+
spec.require_path = 'lib'
|
20
|
+
spec.has_rdoc = false
|
21
|
+
spec.requirements << 'none'
|
22
|
+
|
23
|
+
spec.add_dependency 'spree_core', '~> 2.3.0.beta'
|
24
|
+
spec.add_dependency 'apartment', '~> 0.24'
|
25
|
+
spec.add_development_dependency 'ffaker', '~> 1.16'
|
26
|
+
spec.add_development_dependency 'capybara', '~> 2.2'
|
27
|
+
spec.add_development_dependency 'database_cleaner', '1.2'
|
28
|
+
spec.add_development_dependency 'poltergeist', '1.5'
|
29
|
+
spec.add_development_dependency 'rspec-rails', '~> 2.14'
|
30
|
+
spec.add_development_dependency 'factory_girl', '~> 4.4'
|
31
|
+
spec.add_development_dependency 'sqlite3', '~> 1.3'
|
32
|
+
spec.add_development_dependency 'simplecov', '~> 0.7'
|
33
|
+
spec.add_development_dependency 'coffee-rails', '~> 4.0'
|
34
|
+
spec.add_development_dependency 'sass-rails', '~> 4.0'
|
35
|
+
spec.add_development_dependency 'guard-rspec', '~> 4.2'
|
36
|
+
spec.add_development_dependency 'pry', '~> 0.9'
|
37
|
+
spec.add_development_dependency 'pg', '~> 0.11'
|
38
|
+
spec.add_development_dependency 'debugger', '~> 1.6'
|
39
|
+
spec.add_development_dependency 'shoulda-matchers', '~> 2.5'
|
40
|
+
end
|