Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add tests for set_sequence_name etc

  • Loading branch information...
commit fd7ca98bb6218de42b821d48db083ea8c0e97d67 1 parent 34609d6
@jonleighton jonleighton authored
View
2  activerecord/lib/active_record/base.rb
@@ -707,7 +707,7 @@ def inheritance_column
if self == Base
'type'
else
- defined?(@inheritance_column) ? @inheritance_column : superclass.inheritance_column
+ (@inheritance_column ||= nil) || superclass.inheritance_column
end
end
View
22 activerecord/test/cases/base_test.rb
@@ -1510,6 +1510,28 @@ def test_set_inheritance_column_with_block
assert_equal "type_id", k.inheritance_column
end
+ def test_set_sequence_name_with_value
+ k = Class.new( ActiveRecord::Base )
+ k.sequence_name = "foo"
+ assert_equal "foo", k.sequence_name
+
+ k.set_sequence_name "bar"
+ assert_equal "bar", k.sequence_name
+ end
+
+ def test_set_sequence_name_with_block
+ k = Class.new( ActiveRecord::Base )
+ k.table_name = "projects"
+ orig_name = k.sequence_name
+
+ if orig_name
+ k.set_sequence_name { original_sequence_name + "_lol" }
+ assert_equal orig_name + "_lol", k.sequence_name
+ else
+ skip "sequences not supported by db"
+ end
+ end
+
def test_count_with_join
res = Post.count_by_sql "SELECT COUNT(*) FROM posts LEFT JOIN comments ON posts.id=comments.post_id WHERE posts.#{QUOTED_TYPE} = 'Post'"
Please sign in to comment.
Something went wrong with that request. Please try again.