Sha256: dcb72f9d565832f37ce2fb7ef3f055d5c9299baf13d940993f56a2c6fb967409
Contents?: true
Size: 1.67 KB
Versions: 3
Compression:
Stored size: 1.67 KB
Contents
module AuthenticationHelpers def sign_in_as(user) controller.current_user = user end def sign_in sign_in_as(Factory(:user)) end def sign_out controller.current_user = nil end def current_user controller.current_user end def signed_in? controller.signed_in? end def sign_in_as_admin_of_account(account) user = Factory(:user) Factory(:account_membership, :user => user, :account => account, :admin => true) sign_in_as user end def sign_in_as_non_admin_of_account(account) user = Factory(:user) Factory(:account_membership, :user => user, :account => account, :admin => false) sign_in_as user end def sign_in_as_non_admin_of_project(project) user = sign_in_as_non_admin_of_account(project.account) Factory(:project_membership, :user => user, :project => project) end def sign_in_as_admin_of_project(project) user = sign_in_as_admin_of_account(project.account) Factory(:project_membership, :user => user, :project => project) end end RSpec::Matchers.define :be_signed_in do match do |controller| @controller = controller @controller.signed_in? && (@expected_user.nil? || @expected_user == @controller.current_user) end chain :as do |user| @expected_user = user end failure_message_for_should do message = "expected to be signed in" message << " as #{@expected_user.inspect}" if @expected_user message << " but was " if @controller.signed_in? message << "signed in as #{@controller.current_user.inspect}" else message << "not signed in" end message end failure_message_for_should_not do "didn't expect to be signed in" end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
saucy-0.1.3 | spec/support/authentication_helpers.rb |
saucy-0.1.2 | spec/support/authentication_helpers.rb |
saucy-0.1.1 | spec/support/authentication_helpers.rb |