Sha256: 2c726d0def3d78dfefa1e597ce8e6e1c0a0b7d31419033a997a314ad6c574729

Contents?: true

Size: 715 Bytes

Versions: 9

Compression:

Stored size: 715 Bytes

Contents

require 'spec_helper'
class BeforeRecordUpdateCollection < RecordCollection::Base
  attribute :section
  attribute :admin
  before_record_update{|record| record.admin = true }
end
RSpec.describe BeforeRecordUpdateCollection do
  subject { described_class.new }
  it "executes on the record" do
    employee = Employee.create section: 'SE1', admin: false
    described_class.new([employee]).update({})
    employee.reload
    employee.admin.should be true
  end

  it "will be overriden by the actual update action (hence before)" do
    employee = Employee.create section: 'SE1', admin: false
    described_class.new([employee]).update(admin: false)
    employee.reload
    employee.admin.should be false
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
record_collection-0.10.4 spec/base/before_record_update_spec.rb
record_collection-0.10.3 spec/base/before_record_update_spec.rb
record_collection-0.10.2 spec/base/before_record_update_spec.rb
record_collection-0.10.1 spec/base/before_record_update_spec.rb
record_collection-0.10.0 spec/base/before_record_update_spec.rb
record_collection-0.9.2 spec/base/before_record_update_spec.rb
record_collection-0.9.1 spec/base/before_record_update_spec.rb
record_collection-0.9.0 spec/base/before_record_update_spec.rb
record_collection-0.8.3 spec/base/before_record_update_spec.rb