From ad549eb4ceaa2a75b3d3059d577275d6f155a72b Mon Sep 17 00:00:00 2001 From: Lorin Thwaits Date: Sun, 26 Aug 2018 11:33:40 +0100 Subject: [PATCH] Verify that all tests work properly along with the store_base_sti_class gem --- spec/models/management_spec.rb | 6 ++++++ spec/models/pet_spec.rb | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/spec/models/management_spec.rb b/spec/models/management_spec.rb index 6ef5c60a6..ff7d51a37 100644 --- a/spec/models/management_spec.rb +++ b/spec/models/management_spec.rb @@ -6,6 +6,12 @@ it { is_expected.to be_versioned } it "utilises the base_class for STI classes having no type column" do + # Specific to the store_base_sti_class gem: + if ActiveRecord::Base.respond_to?(:store_base_sti_class) && + !ActiveRecord::Base.store_base_sti_class + skip("When using store_base_sti_class it is necessary to implement a type column") + end + expect(Management.inheritance_column).to eq("type") expect(Management.columns.map(&:name)).not_to include("type") diff --git a/spec/models/pet_spec.rb b/spec/models/pet_spec.rb index 47ff4652c..44d143db2 100644 --- a/spec/models/pet_spec.rb +++ b/spec/models/pet_spec.rb @@ -82,6 +82,10 @@ expect(versions.third.reify).to be_a(Cat) # Cheshire expect(versions.fourth.reify).to be_a(Cat) # Cheshire that was destroyed + # Properly records "destroy" events according to Issue #37 from the store_base_sti_class gem: + # https://github.com/appfolio/store_base_sti_class/issues/37 + expect(cat.versions.last.event).to eq("destroy") + # Creating an object from the base class is correctly identified as "Animal" expect(versions[5].reify).to be_an(Animal) # Muppets Drummer expect(versions[6].reify).to be_an(Animal) # Animal that was destroyed