Sha256: f9baa14ecf5ae706abd00d22b683c68fff7f30317abcfdd039abe332e8c6b5ca

Contents?: true

Size: 861 Bytes

Versions: 5

Compression:

Stored size: 861 Bytes

Contents

require "mongoid/strategy_helper"

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

module UserSetup
  def find_role name
    Role.where(:name => name.to_sym).first
  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


require 'troles/common/api_spec' # Common API examples  

describe 'Troles strategy :ref_many' do
  it_should_behave_like "Common API"
  # it_should_behave_like "Troles API"  
end    

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
troles-0.6.1 spec/mongoid/strategies/many/ref_many_spec.rb
troles-0.6.0 spec/mongoid/strategies/many/ref_many_spec.rb
troles-0.5.2 spec/mongoid/strategies/many/ref_many_spec.rb
troles-0.5.1 spec/mongoid/strategies/many/ref_many_spec.rb
troles-0.5.0 spec/mongoid/strategies/many/ref_many_spec.rb