From ea38e8a51085fb975dd1b6161604e69a5fd72a3d Mon Sep 17 00:00:00 2001 From: Ben Atkins Date: Sun, 1 Mar 2015 14:02:31 -0500 Subject: [PATCH] Add RSpec test case for #404 --- spec/models/animal_spec.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 spec/models/animal_spec.rb diff --git a/spec/models/animal_spec.rb b/spec/models/animal_spec.rb new file mode 100644 index 00000000..ce1a748d --- /dev/null +++ b/spec/models/animal_spec.rb @@ -0,0 +1,19 @@ +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 + end +end