이상한 문제가 있습니다. 응용 프로그램 컨트롤러에는 을 사용하여 인증을 요구하는 before_filter
세트가 있으며 로그인 페이지로 필요한 경우 리디렉션됩니다.rspec은 skip_before_filter를 무시합니까?
라이브러리 컨트롤러에서 우리는 이것을 건너 뜁니다. before_filter
.
skip_before_filter :authenticate_user!, :only => :show
우리가 capybara
및 테스트가 실패 rspec
간단한 기능 테스트를 실행
it "should get only english articles within the category 'computers'" do
visit '/en/library/computers'
page.should have_content('computers')
end
이 필터를 건너 뛰지 않은 것처럼 보입니다. 페이지 내용은 로그인 페이지입니다.
rails server
으로 실행하면 문제가 없습니다.
왜 이런 식으로 행동하는지 또는이 문제를 해결하기 위해 무엇을 찾아야할까요?
UPDATE :
그것은이는 리눅스를 사용하여 발생하는 것을 추가 가치가있을 수도 있습니다. MacOS 10.7에서 "동일한"설정으로 제대로 작동합니다.
컨트롤러 코드 :
class Library::CategoriesController < ApplicationController
skip_before_filter :authenticate_user!, :only => [:show]
# GET /categories/1
# GET /categories/1.json
def show
@categories = Category.all
@category = Category.find(params[:id])
@articles = @category.articles.where(:locale => I18n.locale)
respond_to do |format|
format.html # show.html.erb
end
end
end
application_controller합니다 (set_i18n_locale_from_url없이)처럼 보인다
:
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :set_i18n_locale_from_url, :authenticate_user!
end
경로 :
namespace :library do
get '/' => 'library#index', :as => 'library'
resources :categories, :path => '', :only => [:show]
resources :categories, :path => '', :only => [] do
resources :articles, :path => '', :only => [:show]
end
end
내가이 똑같은 행동을보고하고있다. –