0
我在我的項目中添加了Subdomain-fu。在ApplicationController中我有before_filter,它檢查url並將app.com重定向到www.app.com,www.subdomain.app.com到subdomain.app.com並檢查帳戶是否存在(如果不存在,則重定向到home):添加Subdomain-fu和重定向功能後,黃瓜/ webrat測試失敗
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
上面的代碼相當不錯。但添加此片段後,我的黃瓜測試,例如。這一個:
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 ...
成了失敗,錯誤:
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!"'
如果我評論這個的before_filter一切正常。 有人知道爲什麼嗎?