Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed subdomain resolution. Added specs for controller extensions.
- Loading branch information
Showing
8 changed files
with
87 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module ActsAsTenant | ||
VERSION = "0.3.1" | ||
VERSION = "0.3.2" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
require "spec_helper" | ||
|
||
#Setup test specific ApplicationController | ||
class Account | ||
attr_accessor :name | ||
end | ||
|
||
class ApplicationController2 < ActionController::Base | ||
include Rails.application.routes.url_helpers | ||
set_current_tenant_through_filter | ||
before_filter :your_method_that_finds_the_current_tenant | ||
|
||
def your_method_that_finds_the_current_tenant | ||
current_account = Account.new | ||
current_account.name = 'account1' | ||
set_current_tenant(current_account) | ||
end | ||
|
||
end | ||
|
||
# Start testing | ||
describe ApplicationController2, :type => :controller do | ||
controller do | ||
def index | ||
render :text => "custom called" | ||
end | ||
end | ||
|
||
it 'Finds the correct tenant using the filter command' do | ||
get :index | ||
ActsAsTenant.current_tenant.name.should eq 'account1' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
require "spec_helper" | ||
|
||
#Setup test specific ApplicationController | ||
class Account; end # this is so the spec will work in isolation | ||
|
||
class ApplicationController < ActionController::Base | ||
include Rails.application.routes.url_helpers | ||
set_current_tenant_by_subdomain | ||
end | ||
|
||
# Start testing | ||
describe ApplicationController, :type => :controller do | ||
controller do | ||
def index | ||
render :text => "custom called" | ||
end | ||
end | ||
|
||
it 'Finds the correct tenant with a subdomain.example.com' do | ||
@request.host = "account1.example.com" | ||
Account.should_receive(:where).with({subdomain: 'account1'}) {['account1']} | ||
get :index | ||
ActsAsTenant.current_tenant.should eq 'account1' | ||
end | ||
|
||
it 'Finds the correct tenant with a www.subdomain.example.com' do | ||
@request.host = "www.account1.example.com" | ||
Account.should_receive(:where).with({subdomain: 'account1'}) {['account1']} | ||
get :index | ||
ActsAsTenant.current_tenant.should eq 'account1' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters