Merge pull request #6606 from amatsuda/ar_relation_model_method

AR::Relation#model would be a better API than AR::Relation#klass
This commit is contained in:
Rafael Mendonça França 2012-08-21 14:43:19 -07:00
commit d168c1f7a7
2 changed files with 6 additions and 0 deletions

View File

@ -18,6 +18,7 @@ module ActiveRecord
attr_reader :table, :klass, :loaded
attr_accessor :default_scoped
alias :model :klass
alias :loaded? :loaded
alias :default_scoped? :default_scoped

View File

@ -19,6 +19,11 @@ module ActiveRecord
assert !relation.loaded, 'relation is not loaded'
end
def test_responds_to_model_and_returns_klass
relation = Relation.new :a, :b
assert_equal :a, relation.model
end
def test_initialize_single_values
relation = Relation.new :a, :b
(Relation::SINGLE_VALUE_METHODS - [:create_with]).each do |method|