Module: Tuberack::Helpers

Defined in:
lib/tuberack/helpers.rb

Instance Method Summary collapse

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_abilityObject



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_loginObject



3
4
5
6
# File 'lib/tuberack/helpers.rb', line 3

def 
  current_user.stubs(:has_role?).returns(true)
   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