multi_client 3.1.0 → 3.1.1

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: ee973e7a43f9052c0584bd35622074e9454978e0
4
- data.tar.gz: dbd4564e532229f97fe85972aed59cfbb8e01b29
3
+ metadata.gz: 3e18e3181ca39656c1dec3e8c0aa13b11c3de851
4
+ data.tar.gz: 092f67ee29528eb30dc0751134a5f4cf16802fca
5
5
  SHA512:
6
- metadata.gz: 2e6387041fa8d3823bb1aea9ee3a1d0e4ca1f1bfd720bbee7dc56e16e2c248367ecbd5d2e23f7844d3b76880eda87f59ac0a9221133bbe7b4ec4bc0e4a9c1dd8
7
- data.tar.gz: 4986730268411211e589f8605b51360fe78e86a88853ec0fc252b9da286941c0911950def3a00bff6df17ae93782ebe8a02b81de46e95206b039ef0bac4b34db
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
@@ -8,6 +8,10 @@ module MultiClient
8
8
  def generate_intializer
9
9
  copy_file 'initializer.rb', 'config/initializers/multi_client.rb'
10
10
  end
11
+
12
+ def generate_client_model
13
+ copy_file 'client.rb', 'app/models/client.rb'
14
+ end
11
15
  end
12
16
  end
13
17
  end
@@ -0,0 +1,2 @@
1
+ class Client < MultiClient::Client
2
+ end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module MultiClient
2
- VERSION = '3.1.0'.freeze
2
+ VERSION = '3.1.1'.freeze
3
3
  end
@@ -1,13 +1,13 @@
1
1
  namespace :multi_client do
2
2
  namespace :create do
3
- desc "Explaining what the task does"
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.0
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: 2016-05-23 00:00:00.000000000 Z
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/spec_helper.rb
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