multi_client 3.1.0 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.rdoc +8 -0
- data/app/models/multi_client/client.rb +4 -0
- data/app/services/multi_client/create_client_service.rb +1 -0
- data/lib/generators/multi_client/install/install_generator.rb +4 -0
- data/lib/generators/multi_client/install/templates/client.rb +2 -0
- data/lib/multi_client/spec_helpers/feature.rb +21 -0
- data/lib/multi_client/version.rb +1 -1
- data/lib/tasks/multi_client_tasks.rake +2 -2
- data/spec/factories/multi_client/client_factories.rb +2 -2
- metadata +4 -3
- data/lib/multi_client/spec_helper.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e18e3181ca39656c1dec3e8c0aa13b11c3de851
|
4
|
+
data.tar.gz: 092f67ee29528eb30dc0751134a5f4cf16802fca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1dfa2f9539cfb8ac70bbc56b094580a34427d505c289fcefa876819ce7fa36da0d353f966d841577f750f3d86629c9c1368ed45bf4284606eb7854a41d938c95
|
7
|
+
data.tar.gz: fd64e7e683086961627b5ba7e26cfce6c4745fe7ebce16ef401d442a7180ebc3aee0da59cc4dede0eda4f722cafbdfea8c2638e7b859f49ff035d8a38ff4ced5
|
data/README.rdoc
CHANGED
@@ -56,6 +56,14 @@ Add migrations and migrate
|
|
56
56
|
Post.all
|
57
57
|
end
|
58
58
|
|
59
|
+
= How do I setup my application so that a client is looked up automatically?
|
60
|
+
|
61
|
+
# app/controllers/application_controller.rb
|
62
|
+
class ApplicationController < ActionController::Base
|
63
|
+
include MultiClient::ControllerWithClient
|
64
|
+
helper_method :current_client
|
65
|
+
end
|
66
|
+
|
59
67
|
= Gotchas
|
60
68
|
|
61
69
|
== include MultiClient::ModelWithClient::ActiveSupport::Concern after calls to any class methods.
|
@@ -32,6 +32,10 @@ module MultiClient
|
|
32
32
|
self.current_id = where(identifier: identifier).first.try(:id)
|
33
33
|
end
|
34
34
|
|
35
|
+
def self.set_current_by_subdomain(subdomain)
|
36
|
+
self.current_id = where(subdomain: subdomain).first.try(:id)
|
37
|
+
end
|
38
|
+
|
35
39
|
def self.unset_current
|
36
40
|
self.current_id = nil
|
37
41
|
end
|
@@ -18,6 +18,7 @@ module MultiClient
|
|
18
18
|
say "Input is valid"
|
19
19
|
ActiveRecord::Base.transaction do
|
20
20
|
response.client = create_client
|
21
|
+
return response unless response.client.persisted?
|
21
22
|
Client.with_client(response.client) do
|
22
23
|
# response.client_setting = create_client_setting
|
23
24
|
response.roles, response.permissions = create_default_roles_and_permissions if create_roles_and_permissions == true
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module MultiClient
|
2
|
+
module SpecHelpers
|
3
|
+
module Feature
|
4
|
+
def with_client(client, &block)
|
5
|
+
MultiClient::Client.with_client(client) { block.call }
|
6
|
+
end
|
7
|
+
|
8
|
+
def use_subdomain(subdomain)
|
9
|
+
Capybara.current_session.driver.reset!
|
10
|
+
Capybara.default_host = Capybara.default_host.sub(/(.*?\/\/)(.*?)(\..*)/, "\\1#{subdomain}\\3")
|
11
|
+
end
|
12
|
+
|
13
|
+
def with_subdomain(subdomain, &block)
|
14
|
+
original_host = Capybara.default_host
|
15
|
+
use_subdomain(subdomain)
|
16
|
+
yield
|
17
|
+
Capybara.default_host = original_host
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/multi_client/version.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
namespace :multi_client do
|
2
2
|
namespace :create do
|
3
|
-
desc "
|
3
|
+
desc "Creates the master Tenant"
|
4
4
|
task create_master: :environment do
|
5
5
|
if MultiClient::Client.exists?(subdomain: 'master')
|
6
6
|
puts "Master tenant already exists"
|
7
7
|
next
|
8
8
|
end
|
9
9
|
if MultiClient::Client.enabled.create!(subdomain: 'master', identifier: MultiClient::Configuration.master_client_identifier)
|
10
|
-
puts "Created master tenant"
|
10
|
+
puts "Created master tenant (#{MultiClient::Configuration.master_client_identifier})"
|
11
11
|
end
|
12
12
|
puts "Done"
|
13
13
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
FactoryGirl.define do
|
2
2
|
factory :multi_client_client, class: MultiClient::Client do
|
3
|
-
sequence(:identifier)
|
4
|
-
sequence(:subdomain)
|
3
|
+
sequence(:identifier) { |i| "client.identifier.#{i}"}
|
4
|
+
sequence(:subdomain) { |i| "client#{i}"}
|
5
5
|
enabled true
|
6
6
|
|
7
7
|
trait(:master) do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: multi_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roberto Vasquez Angel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -151,6 +151,7 @@ files:
|
|
151
151
|
- config/routes.rb
|
152
152
|
- db/migrate/001_create_multi_client_clients.rb
|
153
153
|
- lib/generators/multi_client/install/install_generator.rb
|
154
|
+
- lib/generators/multi_client/install/templates/client.rb
|
154
155
|
- lib/generators/multi_client/install/templates/initializer.rb
|
155
156
|
- lib/multi_client.rb
|
156
157
|
- lib/multi_client/configuration.rb
|
@@ -158,7 +159,7 @@ files:
|
|
158
159
|
- lib/multi_client/master_subdomain.rb
|
159
160
|
- lib/multi_client/no_subdomain.rb
|
160
161
|
- lib/multi_client/non_master_subdomain.rb
|
161
|
-
- lib/multi_client/
|
162
|
+
- lib/multi_client/spec_helpers/feature.rb
|
162
163
|
- lib/multi_client/subdomain.rb
|
163
164
|
- lib/multi_client/version.rb
|
164
165
|
- lib/tasks/multi_client_tasks.rake
|
@@ -1,9 +0,0 @@
|
|
1
|
-
module MultiClient
|
2
|
-
module SpecHelper
|
3
|
-
def use_client(client)
|
4
|
-
MultiClient::Client.current_id = client.id
|
5
|
-
Capybara.current_session.driver.reset!
|
6
|
-
Capybara.default_host = Capybara.default_host.sub(/(.*?\/\/)(.*?)(\..*)/, "\\1#{client.subdomain}\\3")
|
7
|
-
end
|
8
|
-
end
|
9
|
-
end
|