, , . ,
before_filter :authenticate_user!
, , :authenticate_user! , . -
- , #authenticate_user! .
- , , , before_filter, , .
before_filter , :
describe ApplicationController do
describe 'GET /my_account' do
subject { get :my_account }
context 'with a logged-out session' do
it 'redirects to the homepage' do
response.should redirect_to root_url
end
end
context 'with a logged-in session' do
before { log_in(FactoryGirl.create :user) }
it { should render_template('my_account') }
end
end
describe 'private #authenticate_user!' do
subject { ApplicationController.send(:authenticate_user!) }
it 'calls the authentication logic' do
Authentication.expects(:attempt_login)
subject
end
end
end
, :authenticate_user! . , Rails!
, - . StackOverflow, !