Module: Sso::Auth::SpecHelper
- Defined in:
- lib/sso/auth/spec_helper.rb
Instance Method Summary collapse
- #ability_for(user) ⇒ Object
- #another_user ⇒ Object
- #create_user ⇒ Object
- #user ⇒ Object
- #user_with_role(role, context = nil, prefix = nil, user = nil) ⇒ Object
Instance Method Details
#ability_for(user) ⇒ Object
5 6 7 |
# File 'lib/sso/auth/spec_helper.rb', line 5 def ability_for(user) Ability.new(user) end |
#another_user ⇒ Object
30 31 32 |
# File 'lib/sso/auth/spec_helper.rb', line 30 def another_user @another_user ||= create_user end |
#create_user ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/sso/auth/spec_helper.rb', line 9 def create_user @sequence ||= 0 @sequence += 1 User.new.tap do |user| user.uid = @sequence user.save(:validate => false) end end |
#user ⇒ Object
26 27 28 |
# File 'lib/sso/auth/spec_helper.rb', line 26 def user @user ||= create_user end |
#user_with_role(role, context = nil, prefix = nil, user = nil) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/sso/auth/spec_helper.rb', line 18 def user_with_role(role, context=nil, prefix=nil, user=nil) @roles ||= {} @roles["#{prefix}_#{role}"] ||= {} @roles["#{prefix}_#{role}"][context] ||= (user || create_user).tap do |user| user..create!({:context => context, :role => role}, :without_protection => true) end end |