Sha256: 1d9573a7311e45c081e9a60d632ab0615e6fa6d42ab72f8e50435b7062ba4f85

Contents?: true

Size: 1.13 KB

Versions: 23

Compression:

Stored size: 1.13 KB

Contents

require 'spec_helper'

describe Consul::ActiveRecord do

  describe '.authorize_values_for' do

    it 'should be a shortcut for .assignable_values_for :attribute, :through => lambda { ::Power.current }' do
      klass = Note.disposable_copy
      klass.should_receive(:assignable_values_for).with(:attribute, :option => 'option', :through => kind_of(Proc))
      klass.class_eval do
        authorize_values_for :attribute, :option => 'option'
      end
    end

    it 'should not generate a getter and setter for a @power field (change from previous versions)' do
      klass = Note.disposable_copy do
        authorize_values_for :attribute
      end
      note = klass.new
      note.should_not respond_to(:power)
      note.should_not respond_to(:power=)
    end

    it 'should obtain assignable values from Power.current' do
      Power.current = Power.new
      klass = User.disposable_copy do
        authorize_values_for :role
      end
      user = klass.new
      user.assignable_roles.should =~ %w[guest admin]
      user.should allow_value('guest').for(:role)
      user.should_not allow_value('invalid-value').for(:role)
    end

  end

end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
consul-0.12.2 spec/shared/consul/active_record_spec.rb
consul-0.12.1 spec/shared/consul/active_record_spec.rb
consul-0.12.0 spec/shared/consul/active_record_spec.rb
consul-0.11.2 spec/shared/consul/active_record_spec.rb
consul-0.11.1 spec/shared/consul/active_record_spec.rb
consul-0.11.0 spec/shared/consul/active_record_spec.rb
consul-0.10.2 spec/shared/consul/active_record_spec.rb
consul-0.10.1 spec/shared/consul/active_record_spec.rb
consul-0.10.0 spec/shared/consul/active_record_spec.rb
consul-0.9.1 spec/shared/consul/active_record_spec.rb
consul-0.9.0 spec/shared/consul/active_record_spec.rb
consul-0.8.0 spec/shared/consul/active_record_spec.rb
consul-0.7.0 spec/shared/consul/active_record_spec.rb
consul-0.6.1 spec/shared/consul/active_record_spec.rb
consul-0.6.0 spec/shared/consul/active_record_spec.rb
consul-0.5.0 spec/shared/consul/active_record_spec.rb
consul-0.4.2 spec/shared/consul/active_record_spec.rb
consul-0.4.1 spec/shared/consul/active_record_spec.rb
consul-0.4.0 spec/shared/consul/active_record_spec.rb
consul-0.3.0 spec/consul/active_record_spec.rb