0
我使用魔法寶石進行用戶註冊/登錄。如何用rspec測試這個?
此寶石的一個功能是您要驗證的任何控制器上的require_login
before_filter。
我創建了一個dashboard
命名空間,我的應用程序,他們在登錄後例如/dashboard/reports
或/dashboard/employees
等
路線文件:
# Dashboard
namespace :dashboard do
# Recent Activity
get '' => redirect('/dashboard/recent-activity')
get 'recent-activity' => 'activities#index', :as => 'root'
# Other dashboard controllers and actions
end
我提取出的before_filter到它自己的控制器稱爲:
「app/controllers/dashboard/base_controller.rb」
class Dashboard::BaseController < ApplicationController
before_filter :require_login
end
我希望做的是使100%肯定的一種考驗,任何新的控制器我的儀表盤文件夾(或儀表板命名空間)中創建,從Dashboard::BaseController
繼承比如我的活動控制器例如:
class Dashboard::ActivitiesController < Dashboard::BaseController
我不想去幾個月創建控制器和小心讓它從ApplicationController中繼承其仍將會,但不會必須登錄功能。
我使用的RSpec