Skip to content

Commit

Permalink
Verify that all tests work properly along with the store_base_sti_cla…
Browse files Browse the repository at this point in the history
…ss gem
  • Loading branch information
lorint committed Aug 26, 2018
1 parent cd8a5ca commit ad549eb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions spec/models/management_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
4 changes: 4 additions & 0 deletions spec/models/pet_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ad549eb

Please sign in to comment.