Sha256: 32701cd31d1cb363dd2be6ad77989b95786c822f6718248dda15be186b92c56e

Contents?: true

Size: 967 Bytes

Versions: 26

Compression:

Stored size: 967 Bytes

Contents

require 'spec_helper'

describe ActiveFedora::Base do
  
  before(:all) do
    module SpecModel
      class Basic < ActiveFedora::Base
        class_attribute :callback_counter
        
        before_destroy :inc_counter

        def inc_counter
          self.class.callback_counter += 1
        end
      end
    end
  end
  
  after(:all) do
    Object.send(:remove_const, :SpecModel)
  end

  before do
    SpecModel::Basic.create!
    SpecModel::Basic.create!
    SpecModel::Basic.callback_counter = 0
  end


  describe ".destroy_all" do
    it "should remove both and run callbacks" do 
      SpecModel::Basic.destroy_all
      SpecModel::Basic.count.should == 0 
      SpecModel::Basic.callback_counter.should == 2
    end

  end

  describe ".delete_all" do
    it "should remove both and not run callbacks" do 
      SpecModel::Basic.delete_all
      SpecModel::Basic.count.should == 0
      SpecModel::Basic.callback_counter.should == 0
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
active-fedora-6.1.1 spec/integration/delete_all_spec.rb
active-fedora-6.1.0 spec/integration/delete_all_spec.rb
active-fedora-6.0.0 spec/integration/delete_all_spec.rb
active-fedora-6.0.0.rc7 spec/integration/delete_all_spec.rb
active-fedora-6.0.0.rc6 spec/integration/delete_all_spec.rb
active-fedora-6.0.0.rc5 spec/integration/delete_all_spec.rb