shopping_mall 0.0.1 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +82 -21
- data/app/models/spree/property_decorator.rb +0 -10
- data/app/models/spree/roles_user.rb +1 -1
- data/lib/generators/shopping_mall/install_generator.rb +3 -8
- data/lib/generators/templates/shopping_mall.rb +5 -3
- data/lib/shopping_mall.rb +1 -2
- data/lib/shopping_mall/version.rb +1 -1
- data/lib/tasks/tenant.rake +65 -0
- data/spec/features/tenancy_spec.rb +1 -0
- data/spec/models/spree/property_decorator_spec.rb +0 -9
- data/spec/shopping_mall/config_spec.rb +43 -9
- data/spec/spec_helper.rb +12 -3
- metadata +12 -32
- data/.gitignore +0 -27
- data/.rspec +0 -1
- data/.travis.yml +0 -7
- data/Gemfile +0 -6
- data/LICENSE.txt +0 -22
- data/lib/tasks/db.rake +0 -41
- data/shopping_mall.gemspec +0 -40
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b5fc44e44f6874db096fe4cb4e71d5fbc3795c9
|
4
|
+
data.tar.gz: 90083938a7dcea8726c21baf9064aaedc01aab64
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3656cfe63e4b35ee5f31b94c70a0b69122f943a969c430c0fabe1f8f9e95a3c278154745602cc660aefe10a30d911e68b7f8e7aa46768b52ee7a70b210fa95c7
|
7
|
+
data.tar.gz: 542079ae4d5dee56f4672ae578cfaa586b5507e0a4db1dca915764a15d5b4f91d41d15d4a3a33af0c03e761af9b979f1564199f9851f63405589abe5aeda644a
|
data/README.md
CHANGED
@@ -1,33 +1,28 @@
|
|
1
1
|
# Shopping Mall
|
2
2
|
|
3
|
-
Multi-tenancy for Spree 2.
|
3
|
+
Multi-tenancy for Spree 2.4.x using the [Apartment](https://github.com/influitive/apartment) gem and [Postgres](http://www.postgresql.org/) as the database. This is very alpha. Pull requests are welcomed.
|
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)
|
7
7
|
|
8
|
+
|
8
9
|
## Installation
|
9
10
|
|
10
|
-
#### Bleeding edge
|
11
11
|
Add this line to your Spree application's Gemfile:
|
12
12
|
|
13
|
-
gem '
|
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.)
|
13
|
+
gem 'shopping_mall'
|
19
14
|
|
20
|
-
|
15
|
+
Then run the bundle command to install it:
|
21
16
|
|
17
|
+
bundle install
|
22
18
|
|
23
19
|
#### Generators
|
24
|
-
Run the bundle command to install it
|
25
20
|
|
26
|
-
After installing ShoppingMall
|
21
|
+
After installing ShoppingMall, run the generator:
|
27
22
|
|
28
23
|
rails generate shopping_mall:install
|
29
24
|
|
30
|
-
|
25
|
+
This will adds a `shopping_mall.rb` initializer to your app, and adds the following to your `application.rb`:
|
31
26
|
|
32
27
|
```ruby
|
33
28
|
config.middleware.insert_before(
|
@@ -35,27 +30,31 @@ config.middleware.insert_before(
|
|
35
30
|
'ShoppingMall::Escalator'
|
36
31
|
)
|
37
32
|
```
|
38
|
-
|
33
|
+
|
34
|
+
> See [https://github.com/influitive/apartment/issues/134](https://github.com/influitive/apartment/issues/134) for more information on this insert_before hack.
|
35
|
+
|
39
36
|
|
40
37
|
## Config
|
41
38
|
|
42
|
-
The following config options should be set up in the `shopping_mall.rb` initializer
|
39
|
+
The following config options should be set up in the `shopping_mall.rb` initializer:
|
43
40
|
|
44
|
-
config/initializers/shopping_mall.rb
|
45
|
-
|
46
41
|
#### Escalators
|
47
42
|
|
48
|
-
Escalators are thinly wrapped Apartment::Elevators, the current escalators available are: `Subdomain`, `Domain`, and `FirstSubdomain`
|
43
|
+
Escalators are thinly wrapped Apartment::Elevators, the current escalators available are: `Subdomain`, `Domain`, and `FirstSubdomain`. The default escalator is `Subdomain`.
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
config.escalator = 'Subdomain'
|
47
|
+
```
|
49
48
|
|
50
49
|
#### Excluding Models
|
51
50
|
|
52
|
-
If you have some models that should always access the
|
51
|
+
If you have some models that should always access the `public` (global) 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
52
|
|
54
53
|
```ruby
|
55
54
|
config.excluded_models = ["Spree::User", ...] # these models will not be multi-tenanted, but remain in the global (public) namespace
|
56
55
|
```
|
57
56
|
|
58
|
-
Out of the box ShoppingMall has the following Spree models excluded
|
57
|
+
Out of the box ShoppingMall has the following Spree models excluded:
|
59
58
|
|
60
59
|
```ruby
|
61
60
|
[
|
@@ -63,6 +62,7 @@ Out of the box ShoppingMall has the following Spree models excluded
|
|
63
62
|
'Spree::Property',
|
64
63
|
'Spree::Prototype',
|
65
64
|
'Spree::Role',
|
65
|
+
'Spree::RolesUser',
|
66
66
|
'Spree::State',
|
67
67
|
'Spree::TaxRate',
|
68
68
|
'Spree::Tracker',
|
@@ -72,7 +72,67 @@ Out of the box ShoppingMall has the following Spree models excluded
|
|
72
72
|
]
|
73
73
|
```
|
74
74
|
|
75
|
-
> NOTE: Rails will always access the
|
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
|
+
## Create Tenant (Rake Task)
|
79
|
+
|
80
|
+
The tenant name will change depending on the escalator you are using. See the [Escalators](#escalators) section for more information.
|
81
|
+
|
82
|
+
rake tenant:create['tenant_name_here']
|
83
|
+
|
84
|
+
If the tenant already exists, it will *not* be overwritten. It will need to be *dropped* before it can be recreated.
|
85
|
+
|
86
|
+
#### Subdomain
|
87
|
+
|
88
|
+
This escalator will use the entire subdomain, including nested subdomains. If your domain is `foo.example.com`, the rake task you would need to run is:
|
89
|
+
|
90
|
+
rake tenant:create['foo']
|
91
|
+
|
92
|
+
If your domain is `foo.bar.example.com`, the rake task you would need to run is:
|
93
|
+
|
94
|
+
rake tenant:create['foo.bar']
|
95
|
+
|
96
|
+
You can also exclude certain subdomains. Create a file named `subdomain_exclusions.rb` in `config/initializers/apartment`. Inside it add:
|
97
|
+
|
98
|
+
```ruby
|
99
|
+
Apartment::Elevators::Subdomain.excluded_subdomains = ['www']
|
100
|
+
```
|
101
|
+
|
102
|
+
Typical subdomains may include: `public`, `www` and `admin`
|
103
|
+
|
104
|
+
#### Domain
|
105
|
+
|
106
|
+
Domains elevators exclude subdomains and TLD such as `.com` or `.co.uk`. If your domain is `www.example.com`, `example.com` or `www.example.co.uk`, the rake task you would need to run is:
|
107
|
+
|
108
|
+
rake tenant:create['example']
|
109
|
+
|
110
|
+
Note that if the URL is anything other than `www`, it will be used as part of the tenant. This means `foo.example.com` would need to be:
|
111
|
+
|
112
|
+
rake tenant:create['foo.example']
|
113
|
+
|
114
|
+
#### FirstSubdomain
|
115
|
+
|
116
|
+
This is similar to the Subdomain elevator. This will use the first available subdomain. If your domain is `foo.example.com` or `foo.bar.example.com`, the rake task you would need to run is:
|
117
|
+
|
118
|
+
rake tenant:create['foo']
|
119
|
+
|
120
|
+
#### Admin User
|
121
|
+
|
122
|
+
While creating a tenant, you will be asked to create an admin at the same time. If you accept, you will be prompted to supply an email address and a password for the new admin user. If the user already exists, whether the user is an admin or not, the user will neither be created nor assigned to the admin role.
|
123
|
+
|
124
|
+
> NOTE: This admin user will be created on the tenant provided in the `tenant:create` Rake task. If `users` is a shared table and the admin needs to be a global admin, this should be applied to the user in the Spree admin rather than in the Rake task.
|
125
|
+
|
126
|
+
|
127
|
+
## Drop Tenant (Rake Task)
|
128
|
+
|
129
|
+
You must confirm dropping the tenant before the action runs. To drop a tenant, run the following Rake task:
|
130
|
+
|
131
|
+
rake tenant:drop['tenant_name_here']
|
132
|
+
|
133
|
+
> NOTE: Dropping a tenant is a destructive action. Dropping a tenant will remove all data for this tenant. There is no way to retrieve the data in the future unless backups are available.
|
134
|
+
|
135
|
+
> NOTE: The `public` tenant cannot be dropped from here.
|
76
136
|
|
77
137
|
|
78
138
|
## Testing
|
@@ -85,9 +145,10 @@ Running tests
|
|
85
145
|
|
86
146
|
bundle exec rake spec
|
87
147
|
|
148
|
+
|
88
149
|
## Contributing
|
89
150
|
|
90
|
-
1. Fork it ( https://github.com/groundctrl/
|
151
|
+
1. Fork it ( https://github.com/groundctrl/shopping_mall/fork )
|
91
152
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
92
153
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
93
154
|
4. Push to the branch (`git push origin my-new-feature`)
|
@@ -3,14 +3,4 @@ Spree::Property.class_eval do
|
|
3
3
|
has_many :prototypes,
|
4
4
|
through: :properties_prototypes,
|
5
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
6
|
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
require 'rails/generators/base'
|
2
|
-
|
3
1
|
module ShoppingMall
|
4
2
|
module Generators
|
5
3
|
class InstallGenerator < Rails::Generators::Base
|
4
|
+
class_option :auto_run_migrations, type: :boolean, default: true
|
5
|
+
|
6
6
|
source_root File.expand_path('../../templates', __FILE__)
|
7
7
|
|
8
8
|
desc 'Creates initializer and inserts middleware'
|
@@ -29,12 +29,7 @@ module ShoppingMall
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def run_migrations
|
32
|
-
|
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
|
32
|
+
run 'bundle exec rake db:migrate'
|
38
33
|
end
|
39
34
|
end
|
40
35
|
end
|
@@ -1,12 +1,14 @@
|
|
1
1
|
ShoppingMall.configure do |config|
|
2
2
|
# Available escalators %w[Subdomain Domain FirstSubdomain]
|
3
3
|
config.escalator = 'Subdomain'
|
4
|
+
|
4
5
|
# By default ShoppingMall excludes the following Spree models
|
5
6
|
# [
|
6
7
|
# 'Spree::Country',
|
7
8
|
# 'Spree::Property',
|
8
9
|
# 'Spree::Prototype',
|
9
10
|
# 'Spree::Role',
|
11
|
+
# 'Spree::RolesUser',
|
10
12
|
# 'Spree::State',
|
11
13
|
# 'Spree::TaxRate',
|
12
14
|
# 'Spree::Tracker',
|
@@ -14,7 +16,7 @@ ShoppingMall.configure do |config|
|
|
14
16
|
# 'Spree::Zone',
|
15
17
|
# 'Spree::ZoneMember'
|
16
18
|
# ]
|
17
|
-
|
18
|
-
#
|
19
|
-
#config.
|
19
|
+
|
20
|
+
# Feel free to exclude what you want!
|
21
|
+
# config.excluded_models = ['Spree::AwesomeModel']
|
20
22
|
end
|
data/lib/shopping_mall.rb
CHANGED
@@ -3,17 +3,16 @@ require 'apartment'
|
|
3
3
|
require 'apartment/elevators/domain'
|
4
4
|
require 'apartment/elevators/first_subdomain'
|
5
5
|
require 'apartment/elevators/subdomain'
|
6
|
-
require 'shopping_mall/version'
|
7
6
|
require 'shopping_mall/engine'
|
8
7
|
require 'shopping_mall/escalator'
|
9
8
|
|
10
9
|
module ShoppingMall
|
11
|
-
|
12
10
|
DEFAULT_SPREE_EXCLUSIONS = [
|
13
11
|
'Spree::Country',
|
14
12
|
'Spree::Property',
|
15
13
|
'Spree::Prototype',
|
16
14
|
'Spree::Role',
|
15
|
+
'Spree::RolesUser',
|
17
16
|
'Spree::State',
|
18
17
|
'Spree::TaxRate',
|
19
18
|
'Spree::Tracker',
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'highline/import'
|
2
|
+
|
3
|
+
namespace :tenant do
|
4
|
+
desc 'Create a new tenant.'
|
5
|
+
task :create, [:tenant] => [:environment] do |t, args|
|
6
|
+
if args.tenant.blank?
|
7
|
+
raise "You must supply a tenant with `rake tenant:create['tenant']`"
|
8
|
+
end
|
9
|
+
|
10
|
+
tenant = args.tenant.gsub('-', '_')
|
11
|
+
|
12
|
+
ActiveRecord::Base.establish_connection
|
13
|
+
|
14
|
+
if schema_in_use?(tenant)
|
15
|
+
raise "Tenant `#{tenant}` already exists. Will not overwrite."
|
16
|
+
end
|
17
|
+
|
18
|
+
Apartment::Tenant.create(tenant)
|
19
|
+
|
20
|
+
puts 'Tenant created successfully'
|
21
|
+
ENV['RAILS_CACHE_ID'] = tenant
|
22
|
+
|
23
|
+
Apartment::Tenant.process(tenant) do
|
24
|
+
# Hack the current method so we're able to return a gateway
|
25
|
+
# without a RAILS_ENV
|
26
|
+
Spree::Gateway.class_eval do
|
27
|
+
def self.current
|
28
|
+
Spree::Gateway::Bogus.new
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
desc 'Drop an existing tenant.'
|
35
|
+
task :drop, [:tenant] => [:environment] do |t, args|
|
36
|
+
if args.tenant.blank? or args.tenant.downcase == 'public'
|
37
|
+
raise "You must supply a tenant name, with `rake tenant:drop['tenant']`"
|
38
|
+
end
|
39
|
+
|
40
|
+
tenant = args.tenant.gsub('-', '_')
|
41
|
+
|
42
|
+
if agree('WARNING: This is a destructive action. Dropping a tenant will
|
43
|
+
remove all data for this tenant. There is no way to retrieve the
|
44
|
+
data in the future unless backups are available. Are you sure you
|
45
|
+
wish to continue? [Y/n]', true)
|
46
|
+
begin
|
47
|
+
Apartment::Tenant.drop(args.tenant)
|
48
|
+
puts "Tenant `#{tenant}` has been dropped. It is no longer available."
|
49
|
+
rescue => err
|
50
|
+
raise err
|
51
|
+
end
|
52
|
+
else
|
53
|
+
puts 'No tenants have been dropped.'
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# Check is schema is currently in use
|
58
|
+
def schema_in_use?(tenant)
|
59
|
+
schema = ActiveRecord::Base.connection
|
60
|
+
.execute("SELECT schema_name
|
61
|
+
FROM information_schema.schemata
|
62
|
+
WHERE schema_name = '#{tenant}'")
|
63
|
+
schema.ntuples > 0
|
64
|
+
end
|
65
|
+
end
|
@@ -9,13 +9,4 @@ describe Spree::Property do
|
|
9
9
|
expect(property.prototypes.size).to eq 1
|
10
10
|
end
|
11
11
|
end
|
12
|
-
|
13
|
-
context '#find_all_by_prototype' do
|
14
|
-
it 'returns all found properties' do
|
15
|
-
properties = (1..5).map { create(:property) }
|
16
|
-
prototype = create :prototype, properties: properties
|
17
|
-
|
18
|
-
expect(Spree::Property.find_all_by_prototype(prototype)).to eq properties
|
19
|
-
end
|
20
|
-
end
|
21
12
|
end
|
@@ -1,30 +1,64 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe ShoppingMall do
|
4
|
+
let(:exclusions) { ['Spree::User'] }
|
5
|
+
|
4
6
|
context '#configure' do
|
5
|
-
it '
|
6
|
-
expect(
|
7
|
-
|
7
|
+
it 'has default excluded_models on initialize' do
|
8
|
+
expect(ShoppingMall.excluded_models).to eq(
|
9
|
+
ShoppingMall::DEFAULT_SPREE_EXCLUSIONS
|
8
10
|
)
|
9
11
|
end
|
10
12
|
|
11
13
|
it 'excluded_models is a pass-through to Apartment' do
|
12
|
-
|
13
|
-
ShoppingMall.configure { |config| config.excluded_models = exclusions }
|
14
|
+
ShoppingMall.excluded_models = exclusions
|
14
15
|
expect(Apartment.excluded_models).to eq exclusions
|
15
16
|
end
|
16
17
|
|
17
|
-
it 'has
|
18
|
+
it 'has default escalator of `Subdomain` on initialize' do
|
18
19
|
expect(ShoppingMall.escalator).to eq 'Subdomain'
|
19
20
|
end
|
20
21
|
|
21
|
-
it '
|
22
|
+
it 'has default escalator_class of `"Apartment::Elevators::Subdomain`' do
|
22
23
|
expect(ShoppingMall.escalator_class).to eq Apartment::Elevators::Subdomain
|
23
24
|
end
|
24
25
|
|
25
|
-
it '
|
26
|
-
ShoppingMall.configure
|
26
|
+
it 'sets values correctly' do
|
27
|
+
ShoppingMall.configure do |config|
|
28
|
+
config.excluded_models = exclusions
|
29
|
+
config.escalator = 'Domain'
|
30
|
+
end
|
31
|
+
|
32
|
+
expect(ShoppingMall.excluded_models).to eq exclusions
|
27
33
|
expect(ShoppingMall.escalator).to eq 'Domain'
|
34
|
+
expect(ShoppingMall.escalator_class).to eq Apartment::Elevators::Domain
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context '#excluded_models' do
|
39
|
+
it 'sets a custom value for `excluded_models`' do
|
40
|
+
ShoppingMall.excluded_models = exclusions
|
41
|
+
expect(ShoppingMall.excluded_models).to eq exclusions
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context '#escalator' do
|
46
|
+
ShoppingMall::ESCALATORS.each do |escalator|
|
47
|
+
it "sets and returns `#{escalator}` as the escalator" do
|
48
|
+
ShoppingMall.escalator = escalator
|
49
|
+
expect(ShoppingMall.escalator).to eq escalator
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context '#escalator_class' do
|
55
|
+
ShoppingMall::ESCALATORS.each do |escalator|
|
56
|
+
it "returns `#{escalator}` as the escalator_class" do
|
57
|
+
ShoppingMall.escalator = escalator
|
58
|
+
expect(ShoppingMall.escalator_class).to eq(
|
59
|
+
"Apartment::Elevators::#{escalator}".constantize
|
60
|
+
)
|
61
|
+
end
|
28
62
|
end
|
29
63
|
end
|
30
64
|
|
data/spec/spec_helper.rb
CHANGED
@@ -1,9 +1,15 @@
|
|
1
1
|
require 'simplecov'
|
2
2
|
SimpleCov.start 'rails'
|
3
3
|
|
4
|
-
ENV[
|
4
|
+
ENV['RAILS_ENV'] = 'test'
|
5
|
+
|
6
|
+
begin
|
7
|
+
require File.expand_path('../dummy/config/environment.rb', __FILE__)
|
8
|
+
rescue LoadError
|
9
|
+
puts 'Could not load dummy application. Run `bundle exec rake test_app` first'
|
10
|
+
exit
|
11
|
+
end
|
5
12
|
|
6
|
-
require File.expand_path('../dummy/config/environment.rb', __FILE__)
|
7
13
|
require 'rspec/rails'
|
8
14
|
require 'shoulda-matchers'
|
9
15
|
require 'ffaker'
|
@@ -19,6 +25,7 @@ require 'spree/testing_support/factories'
|
|
19
25
|
require 'spree/testing_support/controller_requests'
|
20
26
|
require 'spree/testing_support/authorization_helpers'
|
21
27
|
require 'spree/testing_support/url_helpers'
|
28
|
+
require 'spree/testing_support/capybara_ext'
|
22
29
|
|
23
30
|
FactoryGirl.find_definitions
|
24
31
|
|
@@ -27,6 +34,7 @@ RSpec.configure do |config|
|
|
27
34
|
config.include Spree::TestingSupport::ControllerRequests
|
28
35
|
config.include FactoryGirl::Syntax::Methods
|
29
36
|
config.include Spree::TestingSupport::UrlHelpers
|
37
|
+
config.include Devise::TestHelpers, type: :controller
|
30
38
|
config.use_transactional_fixtures = false
|
31
39
|
config.expose_current_running_example_as :example
|
32
40
|
config.infer_spec_type_from_file_location!
|
@@ -37,7 +45,8 @@ RSpec.configure do |config|
|
|
37
45
|
end
|
38
46
|
|
39
47
|
config.before do
|
40
|
-
|
48
|
+
strategy = example.metadata[:js] ? :truncation : :transaction
|
49
|
+
DatabaseCleaner.strategy = strategy
|
41
50
|
DatabaseCleaner.start
|
42
51
|
end
|
43
52
|
|
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: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vincent Franco
|
@@ -9,36 +9,36 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2015-03-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
15
|
+
name: apartment
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version:
|
20
|
+
version: '0.25'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version:
|
27
|
+
version: '0.25'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
|
-
name:
|
29
|
+
name: spree
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version:
|
34
|
+
version: 2.4.0
|
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: 2.4.0
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: ffaker
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -221,20 +221,6 @@ dependencies:
|
|
221
221
|
- - "~>"
|
222
222
|
- !ruby/object:Gem::Version
|
223
223
|
version: '0.11'
|
224
|
-
- !ruby/object:Gem::Dependency
|
225
|
-
name: debugger
|
226
|
-
requirement: !ruby/object:Gem::Requirement
|
227
|
-
requirements:
|
228
|
-
- - "~>"
|
229
|
-
- !ruby/object:Gem::Version
|
230
|
-
version: '1.6'
|
231
|
-
type: :development
|
232
|
-
prerelease: false
|
233
|
-
version_requirements: !ruby/object:Gem::Requirement
|
234
|
-
requirements:
|
235
|
-
- - "~>"
|
236
|
-
- !ruby/object:Gem::Version
|
237
|
-
version: '1.6'
|
238
224
|
- !ruby/object:Gem::Dependency
|
239
225
|
name: shoulda-matchers
|
240
226
|
requirement: !ruby/object:Gem::Requirement
|
@@ -249,17 +235,12 @@ dependencies:
|
|
249
235
|
- - "~>"
|
250
236
|
- !ruby/object:Gem::Version
|
251
237
|
version: '2.5'
|
252
|
-
description: Multi-tenancy for Spree
|
238
|
+
description: Multi-tenancy for Spree 2.4.x
|
253
239
|
email:
|
254
240
|
executables: []
|
255
241
|
extensions: []
|
256
242
|
extra_rdoc_files: []
|
257
243
|
files:
|
258
|
-
- ".gitignore"
|
259
|
-
- ".rspec"
|
260
|
-
- ".travis.yml"
|
261
|
-
- Gemfile
|
262
|
-
- LICENSE.txt
|
263
244
|
- README.md
|
264
245
|
- Rakefile
|
265
246
|
- app/models/spree/option_type_decorator.rb
|
@@ -291,8 +272,7 @@ files:
|
|
291
272
|
- lib/shopping_mall/engine.rb
|
292
273
|
- lib/shopping_mall/escalator.rb
|
293
274
|
- lib/shopping_mall/version.rb
|
294
|
-
- lib/tasks/
|
295
|
-
- shopping_mall.gemspec
|
275
|
+
- lib/tasks/tenant.rake
|
296
276
|
- spec/features/tenancy_spec.rb
|
297
277
|
- spec/models/spree/option_type_decorator_spec.rb
|
298
278
|
- spec/models/spree/option_value_decorator_spec.rb
|
@@ -330,10 +310,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
330
310
|
requirements:
|
331
311
|
- none
|
332
312
|
rubyforge_project:
|
333
|
-
rubygems_version: 2.
|
313
|
+
rubygems_version: 2.4.5
|
334
314
|
signing_key:
|
335
315
|
specification_version: 4
|
336
|
-
summary: Multi-tenancy for Spree
|
316
|
+
summary: Multi-tenancy for Spree 2.4.x
|
337
317
|
test_files:
|
338
318
|
- spec/features/tenancy_spec.rb
|
339
319
|
- spec/models/spree/option_type_decorator_spec.rb
|
data/.gitignore
DELETED
@@ -1,27 +0,0 @@
|
|
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
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--color -d
|
data/.travis.yml
DELETED
data/Gemfile
DELETED
data/LICENSE.txt
DELETED
@@ -1,22 +0,0 @@
|
|
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/lib/tasks/db.rake
DELETED
@@ -1,41 +0,0 @@
|
|
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
|
data/shopping_mall.gemspec
DELETED
@@ -1,40 +0,0 @@
|
|
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
|