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.6.0.rc2 spec/integration/delete_all_spec.rb
active-fedora-6.6.0.rc1 spec/integration/delete_all_spec.rb
active-fedora-6.6.0.pre4 spec/integration/delete_all_spec.rb
active-fedora-6.6.0.pre3 spec/integration/delete_all_spec.rb
active-fedora-6.6.0.pre2 spec/integration/delete_all_spec.rb
active-fedora-6.6.0.pre1 spec/integration/delete_all_spec.rb
active-fedora-6.5.1 spec/integration/delete_all_spec.rb
active-fedora-6.5.0 spec/integration/delete_all_spec.rb
active-fedora-6.4.5 spec/integration/delete_all_spec.rb
active-fedora-6.4.4 spec/integration/delete_all_spec.rb
active-fedora-6.4.3 spec/integration/delete_all_spec.rb
active-fedora-6.4.2 spec/integration/delete_all_spec.rb
active-fedora-6.4.1 spec/integration/delete_all_spec.rb
active-fedora-6.4.0 spec/integration/delete_all_spec.rb
active-fedora-6.4.0.rc4 spec/integration/delete_all_spec.rb
active-fedora-6.4.0.rc3 spec/integration/delete_all_spec.rb
active-fedora-6.4.0.rc2 spec/integration/delete_all_spec.rb
active-fedora-6.4.0.rc1 spec/integration/delete_all_spec.rb
active-fedora-6.3.0 spec/integration/delete_all_spec.rb
active-fedora-6.2.0 spec/integration/delete_all_spec.rb