Skip to content

Commit

Permalink
Rspec tests to check for handling of abstract model classes
Browse files Browse the repository at this point in the history
  • Loading branch information
dmeranda committed Nov 15, 2015
1 parent 587a10c commit 933b047
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions spec/association_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,27 @@ class OwnComment < Comment
end


context "with abstract base classes" do
before(:each) do
create_tables(
"posts", {}, {}
)
class PostBase < ActiveRecord::Base ; self.abstract_class = true ; end
class Post < PostBase ; end
end

it "should skip abstract classes" do
expect { PostBase.table_name }.to_not raise_error
expect( PostBase.table_name ).to be_nil
expect( !! PostBase.table_exists? ).to eq(false)
end

it "should work with classes derived from abstract classes" do
expect( Post.table_name ).to eq("posts")
expect( !! Post.table_exists? ).to eq(true)
end
end

if defined? ::ActiveRecord::Relation

context "regarding relations" do
Expand Down

0 comments on commit 933b047

Please sign in to comment.