Sha256: 79629cccabc51de7d9a4df82e55a8dcdf99d2c137b432dce20dc23e04043a057

Contents?: true

Size: 880 Bytes

Versions: 2

Compression:

Stored size: 880 Bytes

Contents

require 'strategy_helper'

User.troles_strategy :ref_many do |c|
  c.valid_roles = [:user, :admin, :blogger, :editor]
end.configure!

Config.add_roles [:user, :admin, :editor, :blogger]

module UserSetup
  def find_role name
    Role.where :name => name.to_sym
  end
  
  def create_no_roles_user
    Factory.create :user, :name => 'no roles', :troles => []
  end

  def create_user
    Factory.create :user, :name => 'normal', :troles => [ find_role(:user) ]
  end

  def create_admin_user
    Factory.create :user, :name => 'admin', :troles => [ find_role(:admin) ]
  end

  def create_complex_user
    Factory.create :user, :name => 'user and admin', :troles => [ find_role(:user), find_role(:admin) ]
  end
end

describe 'Troles strategy ref_many' do
  it_behaves_like "Common API"
  it_behaves_like "Common API for multiple roles"  

  it_behaves_like "Troles API"  
end    

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
troles-0.5.1 spec/troles/strategies/ref_many_spec.rb
troles-0.5.0 spec/troles/strategies/ref_many_spec.rb