Module: EspAuth::SpecHelper
- Defined in:
- lib/esp_auth/spec_helper.rb
Instance Method Summary collapse
- #ability_for(user) ⇒ Object
- #another_subcontext(context) ⇒ Object
- #another_user ⇒ Object
- #child_1 ⇒ Object
- #child_1_1 ⇒ Object
- #child_1_2 ⇒ Object
- #child_2 ⇒ Object
- #create_context(parent = nil) ⇒ Object
- #create_subcontext(context) ⇒ Object
- #create_user ⇒ Object
- #root ⇒ Object
- #subcontext(context) ⇒ Object
- #user ⇒ Object
- #user_with_role(role, context = root, prefix = nil) ⇒ Object
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
62 63 64 |
# File 'lib/esp_auth/spec_helper.rb', line 62 def another_subcontext(context) @another_subcontext ||= create_subcontext(context) end |
#another_user ⇒ Object
26 27 28 |
# File 'lib/esp_auth/spec_helper.rb', line 26 def another_user @another_user ||= create_user end |
#child_1 ⇒ Object
42 43 44 |
# File 'lib/esp_auth/spec_helper.rb', line 42 def child_1 @child_1 ||= create_context root end |
#child_1_1 ⇒ Object
46 47 48 |
# File 'lib/esp_auth/spec_helper.rb', line 46 def child_1_1 @child_1_1 ||= create_context child_1 end |
#child_1_2 ⇒ Object
50 51 52 |
# File 'lib/esp_auth/spec_helper.rb', line 50 def child_1_2 @child_1_2 ||= create_context child_1 end |
#child_2 ⇒ Object
54 55 56 |
# File 'lib/esp_auth/spec_helper.rb', line 54 def child_2 @child_2 ||= create_context root end |
#create_context(parent = nil) ⇒ Object
30 31 32 |
# File 'lib/esp_auth/spec_helper.rb', line 30 def create_context(parent=nil) Context.create! :title => 'context', :parent => parent end |
#create_subcontext(context) ⇒ Object
34 35 36 |
# File 'lib/esp_auth/spec_helper.rb', line 34 def create_subcontext(context) Subcontext.create! :title => 'subcontext', :context => context end |
#create_user ⇒ Object
8 9 10 11 12 |
# File 'lib/esp_auth/spec_helper.rb', line 8 def create_user @sequence ||= 0 @sequence += 1 User.create! :uid => @sequence, :name => "user #{@sequence}" end |
#root ⇒ Object
38 39 40 |
# File 'lib/esp_auth/spec_helper.rb', line 38 def root @root ||= create_context end |
#subcontext(context) ⇒ Object
58 59 60 |
# File 'lib/esp_auth/spec_helper.rb', line 58 def subcontext(context) @subcontext ||= create_subcontext(context) end |
#user ⇒ Object
22 23 24 |
# File 'lib/esp_auth/spec_helper.rb', line 22 def user @user ||= create_user end |
#user_with_role(role, context = root, prefix = nil) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/esp_auth/spec_helper.rb', line 14 def user_with_role(role, context=root, prefix=nil) @roles ||= {} @roles["#{prefix}_#{role}"] ||= {} @roles["#{prefix}_#{role}"][context] ||= create_user.tap do |user| user..create! :context => context, :role => role end end |