Skip to content

Commit

Permalink
Testing legacy has_many association options come thru in multiple pla…
Browse files Browse the repository at this point in the history
…ces.
  • Loading branch information
metaskills committed Sep 24, 2008
1 parent ddae2db commit bf5ae5f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
9 changes: 9 additions & 0 deletions test/grouped_scope/association_reflection_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ def setup
assert_equal @ungrouped_reflection.send(:derive_primary_key_name), @grouped_reflection.send(:derive_primary_key_name)
end

should 'honor explicit legacy reports association options like class_name and foreign_key' do
@ungrouped_reflection = LegacyEmployee.reflections[:reports]
@grouped_reflection = LegacyEmployee.reflections[:grouped_scope_reports]
[:class_name,:primary_key_name].each do |m|
assert_equal @ungrouped_reflection.send(m), @grouped_reflection.send(m),
"The method #{m.inspect} does not appear to be proxied to the ungrouped reflection."
end
end

end


Expand Down
18 changes: 17 additions & 1 deletion test/grouped_scope/self_grouping_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def setup
assert_same_elements [@e1,@e2], @e1.group
end

should 'member to find grouped associations of other member' do
should 'allow member to find grouped associations of other member' do
assert_same_elements @e1.reports, @e2.group.reports
end

Expand All @@ -119,6 +119,22 @@ def setup

end

context 'with different groups in legacy schema' do

setup do
@e1 = Factory(:legacy_employee_with_reports, :group_id => 1)
@e2 = Factory(:legacy_employee, :group_id => 1)
@e3 = Factory(:legacy_employee_with_reports, :group_id => 2)
@e4 = Factory(:legacy_employee, :group_id => 2)
end

should 'honor legacy reports association options like class_name and foreign_key' do
@e2.group.reports.all? { |r| r.is_a?(LegacyReport) }
end

end


end


Expand Down

0 comments on commit bf5ae5f

Please sign in to comment.