Sha256: cfcb2cf3e7d3e262ca81c072254b6e1206a2c328258c85f3e1555422065d1f6e

Contents?: true

Size: 913 Bytes

Versions: 5

Compression:

Stored size: 913 Bytes

Contents

require "active_record/strategy_helper"
require 'active_record/models/ref_one'

def migrate_up
  CreateRefOne.up # run migration
  Config.add_roles [:user, :admin, :editor, :blogger]
end

def migrate_down
  CreateRefOne.down
end      

User.troles_strategy :ref_one 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', :trole => nil
  end

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

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


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

describe 'Troles strategy :ref_one' 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/active_record/strategies/one/ref_one_spec.rb
troles-0.6.0 spec/active_record/strategies/one/ref_one_spec.rb
troles-0.5.2 spec/active_record/strategies/one/ref_one_spec.rb
troles-0.5.1 spec/active_record/strategies/one/ref_one_spec.rb
troles-0.5.0 spec/active_record/strategies/one/ref_one_spec.rb