Module: EspAuth::SpecHelper

Defined in:
lib/esp_auth/spec_helper.rb

Instance Method Summary collapse

Instance Method Details

#ability_for(user) ⇒ Object



4
5
6
# File 'lib/esp_auth/spec_helper.rb', line 4

def ability_for(user)
  Ability.new(user)
end

#another_subcontext(context) ⇒ Object



48
49
50
# File 'lib/esp_auth/spec_helper.rb', line 48

def another_subcontext(context)
  @another_subcontext ||= create_subcontext(context)
end

#another_userObject



12
13
14
# File 'lib/esp_auth/spec_helper.rb', line 12

def another_user
  @another_user ||= User.create! :uid => 2, :name => 'Another user'
end

#child_1Object



28
29
30
# File 'lib/esp_auth/spec_helper.rb', line 28

def child_1
  @child_1 ||= create_context root
end

#child_1_1Object



32
33
34
# File 'lib/esp_auth/spec_helper.rb', line 32

def child_1_1
  @child_1_1 ||= create_context child_1
end

#child_1_2Object



36
37
38
# File 'lib/esp_auth/spec_helper.rb', line 36

def child_1_2
  @child_1_2 ||= create_context child_1
end

#child_2Object



40
41
42
# File 'lib/esp_auth/spec_helper.rb', line 40

def child_2
  @child_2 ||= create_context root
end

#create_context(parent = nil) ⇒ Object



16
17
18
# File 'lib/esp_auth/spec_helper.rb', line 16

def create_context(parent=nil)
  Context.create! :title => 'context', :parent => parent
end

#create_subcontext(context) ⇒ Object



20
21
22
# File 'lib/esp_auth/spec_helper.rb', line 20

def create_subcontext(context)
  Subcontext.create! :title => 'subcontext', :context => context
end

#rootObject



24
25
26
# File 'lib/esp_auth/spec_helper.rb', line 24

def root
  @root ||= create_context
end

#subcontext(context) ⇒ Object



44
45
46
# File 'lib/esp_auth/spec_helper.rb', line 44

def subcontext(context)
  @subcontext ||= create_subcontext(context)
end

#userObject



8
9
10
# File 'lib/esp_auth/spec_helper.rb', line 8

def user
  @user ||= User.create! :uid => 1, :name => 'User'
end