Created
February 6, 2013 02:11
-
-
Save dpickett/4719643 to your computer and use it in GitHub Desktop.
subdomain handling
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 PartnerSpecHelper | |
def with_partner_site_for(partner, &block) | |
old_host = Capybara.default_host.dup | |
old_app_host = Capybara.app_host.try(:dup) | |
host = "#{partner.subdomain}.example.com" | |
Capybara.default_host = "http://#{host}" | |
set_host!(host) | |
#Capybara.app_host = "http://#{partner.subdomain}.example.com:7171" if Capybara.current_driver == :webkit | |
begin | |
yield | |
rescue Exception => e | |
Capybara.default_host = old_host | |
Capybara.app_host = old_app_host | |
raise e | |
end | |
Capybara.default_host = old_host | |
Capybara.app_host = old_app_host | |
set_host!(old_host) | |
end | |
def set_host!(host) | |
host! host | |
if defined?(App) | |
App::Application.config.action_mailer.default_url_options = { | |
host: host | |
} | |
end | |
Rails.application.routes.default_url_options = { | |
host: host | |
} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment