Sha256: 255104ab92e4833b48df6cb6f918da8525648c4cc9cc6d1c1b148bfc2f19402b

Contents?: true

Size: 1.44 KB

Versions: 7

Compression:

Stored size: 1.44 KB

Contents

require 'spec_helper'

SimpleRoles.configure do |config|
  config.valid_roles = [:user, :admin, :editor]
end

describe 'Integration for SimpleRoles::Many' do
  before do
    setup_roles
    SimpleRoles::Packager.package User, :many
  end

  it "should all work" do
    admin_role = Role.find_by_name("admin")
    user = User.new(:name => "stanislaw")
    user.roles_list.should be_empty
    user.has_any_role?(:admin).should be_false
    user.roles = [ :admin ]
    user.roles_list.should include(:admin)
    user.roles.should include(:admin)
    user.has_role?(:admin).should be_true
    user.admin?.should be_true
    user.is_admin?.should be_true
    user.has_roles?(:admin).should be_true
    user.save!
    user.roles.should include(:admin)
    user = User.find_by_name! "stanislaw"
    user.roles.should include(:admin)
    user.remove_role(:admin)
    user.roles.should be_empty
    user.save!
    user.roles.should be_empty
    user.roles = [:admin, :user]
    user.roles.should == Array.new([:admin, :user])
    user.has_role?(:admin, :user).should be_true
    user.has_roles?([:admin, :user]).should be_true
    user.roles.size.should == 2
    user.roles = [:admin]
    user.roles.should include(:admin)
    user.add_role :user
    user.roles.should include(:user, :admin)
    user.has_any_role?(:user).should be_true
    user.has_any_role?(:user, :admin).should be_true
    user.has_any_role?([:user, :admin])
    user.has_any_role?(:blip).should be_false
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
simple_roles-0.0.12 spec/simple_roles/integration_many_spec.rb
simple_roles-0.0.11 spec/simple_roles/integration_many_spec.rb
simple_roles-0.0.10 spec/simple_roles/integration_many_spec.rb
simple_roles-0.0.9 spec/simple_roles/integration_many_spec.rb
simple_roles-0.0.8 spec/simple_roles/integration_many_spec.rb
simple_roles-0.0.7 spec/simple_roles/integration_many_spec.rb
simple_roles-0.0.6 spec/simple_roles/integration_many_spec.rb