Sha256: 30e6efb2a87cd0609caf82a5fccd94589daa5857f8e516fe4c2051654f910afa

Contents?: true

Size: 1.03 KB

Versions: 12

Compression:

Stored size: 1.03 KB

Contents

require "rails_helper"

describe Animal, type: :model do
  it { is_expected.to be_versioned }

  describe "STI", versioning: true do
    it { expect(Animal.inheritance_column).to eq("species") }

    describe "updates to the `inheritance_column`" do
      subject { Cat.create!(name: "Leo") }

      it "should be allowed" do
        subject.update_attributes(name: "Spike", species: "Dog")
        dog = Animal.find(subject.id)
        expect(dog).to be_instance_of(Dog)
      end
    end

    context "with callback-methods" do
      context "when only has_paper_trail set in super class" do
        let(:callback_cat) { Cat.create(name: "Markus") }

        it "trails all events" do
          callback_cat.update_attributes(name: "Billie")
          callback_cat.destroy
          expect(callback_cat.versions.collect(&:event)).to eq %w(create update destroy)
        end

        it "does not break reify" do
          callback_cat.destroy
          expect { callback_cat.versions.last.reify }.not_to raise_error
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/paper_trail-5.2.3/spec/models/animal_spec.rb
paper_trail-6.0.2 spec/models/animal_spec.rb
paper_trail-6.0.1 spec/models/animal_spec.rb
paper_trail-6.0.0 spec/models/animal_spec.rb
paper_trail-5.2.3 spec/models/animal_spec.rb
paper_trail-5.2.2 spec/models/animal_spec.rb
paper_trail-5.2.1 spec/models/animal_spec.rb
paper_trail-5.2.0 spec/models/animal_spec.rb
paper_trail-5.1.1 spec/models/animal_spec.rb
paper_trail-5.1.0 spec/models/animal_spec.rb
paper_trail-5.0.1 spec/models/animal_spec.rb
paper_trail-5.0.0 spec/models/animal_spec.rb