Created
September 25, 2010 23:01
-
-
Save hgmnz/597393 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# assumes the following or similar | |
module SessionHelpers | |
def sign_in_as(user) | |
@controller.current_user = user | |
return user | |
end | |
def sign_in | |
sign_in_as Factory(:email_confirmed_user) | |
end | |
def sign_out | |
@controller.current_user = nil | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# example usage in a controller | |
describe SomeController, 'authorization' do | |
it { should require_authentication_for(:get, :new) } | |
it { should require_authentication_for(:post, :create) } | |
context 'with an instance' do | |
# this context needed if the action will find the instance in the database | |
let(:something) { Factory(:something) } | |
it { should_not require_authentication_for(:get, :show, :id => something.id) } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment