secret
Created

  • Download Gist
application_controller.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
# This will append the account name to all links and read it out as the account
# name in all tests.
class ApplicationController < ActionController::Base
def default_url_options(options=nil)
if Rails.env.test?
{ :account_name => current_account_name }
else
{}
end
end
def current_account_name
name = request.subdomains.first
name = params[:account_name] if Rails.env.test?
name
end
def current_account
Account.find_by_subdomain(current_account_name)
end
end

Thanks man! This gist saved my day.

If you actually want to test the subdomains: https://gist.github.com/1939812

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.