I added Subdomain-fu in my project. In ApplicationController I have before_filter which checks url and redirects app.com to www.app.com, www.subdomain.app.com to subdomain.app.com and checks account existence (redirects to home if not exists):
before_filter :check_uri
def check_uri
if !subdomain?
redirect_to http_protocol + "www." + current_host + request.request_uri if !/^www\./.match(current_host)
elsif /^www\./.match(current_host)
redirect_to http_protocol + current_host.gsub(/^www\./, '') + request.request_uri
elsif !account_subdomain?
redirect_to http_protocol + "www" + current_host.gsub(account_subdomain, '')
end
end
Code above works pretty nice. But after adding this snippet my Cucumber tests, for ex. this one:
Scenario: Successful sign up
Given I am an anonymous user
And an Accept Language header
And I am on the home page
When I follow "Join now!"
And ...
became fail with error:
Webrat::NotFoundError: Could not find link with text or title or id "Join now!"
(eval):2:in `/^I follow "([^\"]*)"$/'
features/manage_users.feature:10:in `When I follow "Join now!"'
If I comment this before_filter everything works well. Does anybody know why?