Created
May 1, 2013 00:53
-
-
Save kdiogenes/5493049 to your computer and use it in GitHub Desktop.
multi-tenancy rails
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
1) User sign in signs in as an account owner successfully | |
Failure/Error: page.current_url.should == sign_in_url | |
expected: "http://test1.example.com/sign_in" | |
got: "http://www.example.com/" (using ==) | |
# ./spec/features/users/sign_in_spec.rb:11:in `block (3 levels) in <top (required)>' |
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
1) User sign in signs in as an account owner successfully | |
Failure/Error: visit subscribem.root_path | |
ActionController::RoutingError: | |
No route matches [GET] "/sign_in" | |
# ./spec/features/users/sign_in_spec.rb:10:in `block (3 levels) in <top (required)>' |
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
require 'spec_helper' | |
feature 'User sign in' do | |
extend SubdomainHelpers | |
let!(:account) { FactoryGirl.create(:account) } | |
let(:sign_in_url) { "http://#{account.subdomain}.example.com/sign_in" } | |
let(:root_url) { "http://#{account.subdomain}.example.com/" } | |
within_account_subdomain do | |
scenario "signs in as an account owner successfully" do | |
visit subscribem.root_path | |
page.current_url.should == sign_in_url | |
fill_in "Email", :with => account.owner.email | |
fill_in "Password", :with => "password" | |
click_button "Sign in" | |
page.should have_content("You are now signed in.") | |
page.current_url.should == root_url | |
end | |
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
module SubdomainHelpers | |
def within_account_subdomain(&block) | |
context "within a subdomain" do | |
let(:subdomain_url) { "http://#{account.subdomain}.example.com" } | |
before { Capybara.default_host = subdomain_url } | |
after { Capybara.default_host = "http://example.com" } | |
yield | |
end | |
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
module SubdomainHelpers | |
def within_account_subdomain(&block) | |
let(:subdomain_url) { "http://#{account.subdomain}.example.com" } | |
before { Capybara.default_host = subdomain_url } | |
after { Capybara.default_host = "http://example.com" } | |
yield | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment