Module: Tuberack::Helpers
- Defined in:
- lib/tuberack/helpers.rb
Instance Method Summary collapse
- #can(object) ⇒ Object
- #cancan_ability ⇒ Object
- #cannot(object) ⇒ Object
- #integration_login ⇒ Object
- #user_ability(role) ⇒ Object
Instance Method Details
#can(object) ⇒ Object
21 22 23 24 |
# File 'lib/tuberack/helpers.rb', line 21 def can object cancan_ability unless defined? @ability @ability.can :manage, object end |
#cancan_ability ⇒ Object
14 15 16 17 18 19 |
# File 'lib/tuberack/helpers.rb', line 14 def cancan_ability @ability = Object.new @ability.extend(CanCan::Ability) @controller.stubs(:current_user).returns(current_user) @controller.stubs(:current_ability).returns(@ability) end |
#cannot(object) ⇒ Object
26 27 28 29 |
# File 'lib/tuberack/helpers.rb', line 26 def cannot object cancan_ability unless defined? @ability @ability.cannot :manage, object end |
#integration_login ⇒ Object
3 4 5 6 |
# File 'lib/tuberack/helpers.rb', line 3 def integration_login current_user.stubs(:has_role?).returns(true) login_as current_user end |
#user_ability(role) ⇒ Object
8 9 10 11 12 |
# File 'lib/tuberack/helpers.rb', line 8 def user_ability role current_user.stubs(:has_role?).returns(false) current_user.stubs(:has_role?).with(role).returns(true) current_user end |