私たちは奇妙な問題を抱えています。アプリケーションコントローラでは、devise
を使用して認証が必要な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:
これが唯一のLinuxを使用して発生したことを追加する価値があるかもしれません。 「同じ」設定の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
私はこれと同じ振る舞いを見ています。 –