Sha256: 3e8f4fffd9cff12c5f4b65f1cd95b150c609939fe6bcc130a41094ddf3fb6633

Contents?: true

Size: 1.79 KB

Versions: 21

Compression:

Stored size: 1.79 KB

Contents

require 'spec_helper'

describe ActiveFedora::Base do
  before :all do
    class CallbackStub < ActiveFedora::Base
      has_metadata :type=>ActiveFedora::SimpleDatastream, :name=>"someData" do |m|
        m.field "fubar", :string
        m.field "swank", :text
      end
      delegate :fubar, :to=>'someData', multiple: true
      delegate :swank, :to=>'someData', multiple: true

      after_initialize :a_init
      before_save :b_save
      after_save :a_save
      before_create :b_create
      after_create :a_create
      before_update :b_update
      after_update :a_update
      after_find :a_find

      before_destroy :do_stuff

      def do_stuff
        :noop
      end
    end
  end
  after :all do
    Object.send(:remove_const, :CallbackStub)
  end

  it "Should have after_initialize, before_save,after_save, before_create, after_create, after_update, before_update, before_destroy" do
    CallbackStub.any_instance.should_receive(:a_init)
    CallbackStub.any_instance.should_receive :b_create
    CallbackStub.any_instance.should_receive :a_create
    CallbackStub.any_instance.should_receive(:b_save)
    CallbackStub.any_instance.should_receive(:a_save)
    cb = CallbackStub.new :pid => 'test:123'
    cb.save
end
 it "Should have after_initialize, before_save,after_save, before_create, after_create, after_update, before_update, before_destroy" do
    CallbackStub.any_instance.should_receive(:a_init)
    CallbackStub.any_instance.should_receive(:b_save)
    CallbackStub.any_instance.should_receive(:a_save)
    CallbackStub.any_instance.should_receive(:a_find)
    CallbackStub.any_instance.should_receive(:b_update)
    CallbackStub.any_instance.should_receive(:a_update)
    CallbackStub.any_instance.should_receive(:do_stuff)

    cb2 = CallbackStub.find('test:123')
    cb2.save

    cb2.destroy
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
active-fedora-6.7.8 spec/unit/callback_spec.rb
active-fedora-6.7.7 spec/unit/callback_spec.rb
active-fedora-6.7.6 spec/unit/callback_spec.rb
active-fedora-6.7.5 spec/unit/callback_spec.rb
active-fedora-6.7.4 spec/unit/callback_spec.rb
active-fedora-6.7.3 spec/unit/callback_spec.rb
active-fedora-6.7.2 spec/unit/callback_spec.rb
active-fedora-6.7.1 spec/unit/callback_spec.rb
active-fedora-6.7.0 spec/unit/callback_spec.rb
active-fedora-6.7.0.rc1 spec/unit/callback_spec.rb
active-fedora-6.6.1 spec/unit/callback_spec.rb
active-fedora-6.6.0 spec/unit/callback_spec.rb
active-fedora-6.6.0.rc5 spec/unit/callback_spec.rb
active-fedora-6.6.0.rc4 spec/unit/callback_spec.rb
active-fedora-6.6.0.rc3 spec/unit/callback_spec.rb
active-fedora-6.6.0.rc2 spec/unit/callback_spec.rb
active-fedora-6.6.0.rc1 spec/unit/callback_spec.rb
active-fedora-6.6.0.pre4 spec/unit/callback_spec.rb
active-fedora-6.6.0.pre3 spec/unit/callback_spec.rb
active-fedora-6.6.0.pre2 spec/unit/callback_spec.rb