Skip to content

Commit

Permalink
Merge pull request #154 from plicjo/master
Browse files Browse the repository at this point in the history
Fix Rspec/Rails deprecation warnings
  • Loading branch information
ErwinM committed Mar 13, 2017
2 parents afbb1cc + 7efb251 commit 118aab8
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Alternatively, you could locate the tenant using the method `set_current_tenant_
```ruby
class ApplicationController < ActionController::Base
set_current_tenant_through_filter
before_filter :your_method_that_finds_the_current_tenant
before_action :your_method_that_finds_the_current_tenant

def your_method_that_finds_the_current_tenant
current_account = Account.find_it
Expand All @@ -67,7 +67,7 @@ class ApplicationController < ActionController::Base
end
```

Setting the `current_tenant` yourself, requires you to declare `set_current_tenant_through_filter` at the top of your application_controller to tell acts_as_tenant that you are going to use a before_filter to setup the current tenant. Next you should actually setup that before_filter to fetch the current tenant and pass it to `acts_as_tenant` by using `set_current_tenant(current_tenant)` in the before_filter.
Setting the `current_tenant` yourself, requires you to declare `set_current_tenant_through_filter` at the top of your application_controller to tell acts_as_tenant that you are going to use a before_action to setup the current tenant. Next you should actually setup that before_action to fetch the current tenant and pass it to `acts_as_tenant` by using `set_current_tenant(current_tenant)` in the before_action.


### Setting the current tenant for a block ###
Expand Down
2 changes: 1 addition & 1 deletion acts_as_tenant.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Gem::Specification.new do |s|

s.add_development_dependency('rspec', '>=3.0')
s.add_development_dependency('rspec-rails')
s.add_development_dependency('database_cleaner', '~> 1.3.0')
s.add_development_dependency('database_cleaner', '~> 1.5.3')
s.add_development_dependency('sqlite3')
#s.add_development_dependency('mongoid', '~> 4.0')

Expand Down
6 changes: 3 additions & 3 deletions lib/acts_as_tenant/controller_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def set_current_tenant_by_subdomain(tenant = :account, column = :subdomain )
self.tenant_column = column.to_sym

self.class_eval do
before_filter :find_tenant_by_subdomain
before_action :find_tenant_by_subdomain
helper_method :current_tenant

private
Expand Down Expand Up @@ -42,7 +42,7 @@ def set_current_tenant_by_subdomain_or_domain(tenant = :account, primary_column
self.tenant_second_column = second_column.to_sym

self.class_eval do
before_filter :find_tenant_by_subdomain_or_domain
before_action :find_tenant_by_subdomain_or_domain
helper_method :current_tenant

private
Expand All @@ -62,7 +62,7 @@ def current_tenant


# This method sets up a method that allows manual setting of the current_tenant. This method should
# be used in a before_filter. In addition, a helper is setup that returns the current_tenant
# be used in a before_action. In addition, a helper is setup that returns the current_tenant
def set_current_tenant_through_filter
self.class_eval do
helper_method :current_tenant
Expand Down
2 changes: 1 addition & 1 deletion spec/acts_as_tenant/model_extensions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
@project = @account.projects.create!(:name => 'bar')
end

it { expect {@project.account_id = @account.id + 1}.to raise_error }
it { expect {@project.account_id = @account.id + 1}.to raise_error(ActsAsTenant::Errors::TenantIsImmutable) }
end

describe 'setting tenant_id to the same value should not error' do
Expand Down
6 changes: 3 additions & 3 deletions spec/acts_as_tenant/tenant_by_filter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Account
class ApplicationController2 < ActionController::Base
include Rails.application.routes.url_helpers
set_current_tenant_through_filter
before_filter :your_method_that_finds_the_current_tenant
before_action :your_method_that_finds_the_current_tenant

def your_method_that_finds_the_current_tenant
current_account = Account.new
Expand All @@ -22,12 +22,12 @@ def your_method_that_finds_the_current_tenant
describe ApplicationController2, :type => :controller do
controller do
def index
render :text => "custom called"
render :plain => "custom called"
end
end

it 'Finds the correct tenant using the filter command' do
get :index
expect(ActsAsTenant.current_tenant.name).to eq 'account1'
end
end
end
4 changes: 2 additions & 2 deletions spec/acts_as_tenant/tenant_by_subdomain_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class ApplicationController < ActionController::Base
describe ApplicationController, :type => :controller do
controller do
def index
render :text => "custom called"
render :plain => "custom called"
end
end

Expand All @@ -29,4 +29,4 @@ def index
get :index
expect(ActsAsTenant.current_tenant).to eq 'account1'
end
end
end

0 comments on commit 118aab8

Please sign in to comment.