हमें एक अजीब समस्या है। एप्लिकेशन नियंत्रक में हमारे पास before_filter
सेट है जिसके लिए devise
का उपयोग करके प्रमाणीकरण की आवश्यकता होती है और लॉगिन पृष्ठ पर आवश्यक होने पर रीडायरेक्ट की आवश्यकता होती है।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
के साथ चलाते हैं तो यह ठीक काम करता है।
कोई विचार यह इस तरह से व्यवहार करता है या इसे हल करने के लिए क्या देखना है?
अद्यतन:
यह भी कहा कि यह केवल लिनक्स का उपयोग होता है लायक हो सकता है। "समान" सेटअप के साथ मैकोज़ 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
मैं इस में ठीक उसी व्यवहार देख रहा हूँ। –