Sha256: fc1803fedede39f3a473d905c7930a3c2490649cf9b77aa4361f650dfd5988c2

Contents?: true

Size: 1.76 KB

Versions: 50

Compression:

Stored size: 1.76 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'
      delegate :swank, :to=>'someData'

      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

50 entries across 50 versions & 1 rubygems

Version Path
active-fedora-5.7.1 spec/unit/callback_spec.rb
active-fedora-5.7.0 spec/unit/callback_spec.rb
active-fedora-6.5.1 spec/unit/callback_spec.rb
active-fedora-6.5.0 spec/unit/callback_spec.rb
active-fedora-6.4.5 spec/unit/callback_spec.rb
active-fedora-6.4.4 spec/unit/callback_spec.rb
active-fedora-6.4.3 spec/unit/callback_spec.rb
active-fedora-6.4.2 spec/unit/callback_spec.rb
active-fedora-6.4.1 spec/unit/callback_spec.rb
active-fedora-6.4.0 spec/unit/callback_spec.rb
active-fedora-6.4.0.rc4 spec/unit/callback_spec.rb
active-fedora-6.4.0.rc3 spec/unit/callback_spec.rb
active-fedora-6.4.0.rc2 spec/unit/callback_spec.rb
active-fedora-6.4.0.rc1 spec/unit/callback_spec.rb
active-fedora-6.3.0 spec/unit/callback_spec.rb
active-fedora-6.2.0 spec/unit/callback_spec.rb
active-fedora-6.1.1 spec/unit/callback_spec.rb
active-fedora-6.1.0 spec/unit/callback_spec.rb
active-fedora-5.6.3 spec/unit/callback_spec.rb
active-fedora-6.0.0 spec/unit/callback_spec.rb