Skip to content

Commit

Permalink
Make sure that a few private methods are delegated as well for Associ…
Browse files Browse the repository at this point in the history
…ationReflection.
  • Loading branch information
metaskills committed Sep 23, 2008
1 parent 8937532 commit ba7de6c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/grouped_scope/association_reflection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class AssociationReflection < ActiveRecord::Reflection::AssociationReflection
delegate m, :to => :ungrouped_reflection
end
end
delegate :derive_class_name, :to => :ungrouped_reflection

def initialize(active_record,ungrouped_name)
@active_record = active_record
Expand Down
12 changes: 11 additions & 1 deletion test/grouped_scope/association_reflection_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def setup
end

should 'delegate core instance methods to #ungrouped_reflection' do
[:class_name,:klass,:table_name,:quoted_table_name,:primary_key_name,
[:class_name,:klass,:table_name,:quoted_table_name,:primary_key_name,:active_record,
:association_foreign_key,:counter_cache_column,:source_reflection].each do |m|
assert_equal Employee.reflections[:reports].send(m),
Employee.reflections[:grouped_scope_reports].send(m),
Expand All @@ -42,6 +42,16 @@ def setup
assert_not_equal Employee.reflections[:reports].options, Employee.reflections[:grouped_scope_reports].options
end

should 'derive class name to same as ungrouped reflection' do
assert_equal Employee.reflections[:reports].send(:derive_class_name),
Employee.reflections[:grouped_scope_reports].send(:derive_class_name)
end

should 'derive primary key name to same as ungrouped reflection' do
assert_equal Employee.reflections[:reports].send(:derive_primary_key_name),
Employee.reflections[:grouped_scope_reports].send(:derive_primary_key_name)
end

end


Expand Down

0 comments on commit ba7de6c

Please sign in to comment.