Skip to content

Commit

Permalink
High level test for HasManyAssociationTest.
Browse files Browse the repository at this point in the history
  • Loading branch information
metaskills committed Sep 24, 2008
1 parent a033391 commit 484ab36
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
18 changes: 12 additions & 6 deletions test/grouped_scope/has_many_association_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,22 @@ def setup
context 'For existing ungrouped has_many associations' do

context 'for an Employee' do


setup { @employee = Factory(:employee) }

should 'simply work' do
@employee = Factory(:employee)
assert_instance_of Array, @employee.reports
end

should 'scope existing associations to owner' do
@employee = Factory(:employee_with_reports)
assert_sql(/"reports".employee_id = 1/) do
@employee.reports.reload
should 'scope existing association to owner' do
assert_sql(/"reports".employee_id = #{@employee.id}/) do
@employee.reports(true)
end
end

should 'scope group association to group' do
assert_sql(/"reports".employee_id IN \(#{@employee.id}\)/) do
@employee.group.reports(true)
end
end

Expand Down
3 changes: 1 addition & 2 deletions test/grouped_scope/self_grouping_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ def setup
should 'respond to each' do
assert @employee.group.respond_to?(:each)
@employee.group.each do |employee|
# FIXME: Figure out why this does not work: assert_instance_of Employee, employee
assert_equal Employee.name, employee.class.name
assert_instance_of Employee, employee
end
end

Expand Down

0 comments on commit 484ab36

Please sign in to comment.