Sha256: a46af8de4d44605b73dc11e9b06e2994100aa2de72ffa863dc0101d2c15c48e1
Contents?: true
Size: 1.29 KB
Versions: 1
Compression:
Stored size: 1.29 KB
Contents
require 'helper' class GroupedScope::HasManyThroughAssociationTest < GroupedScope::TestCase setup do setup_environment @e1 = FactoryGirl.create(:employee, :group_id => 1) @e1.departments << Department.hr << Department.finance @e2 = FactoryGirl.create(:employee, :group_id => 1) @e2.departments << Department.it @all_group_departments = [Department.hr, Department.it, Department.finance] end context 'For default association' do should 'scope to owner' do assert_sql(/employee_id = #{@e1.id}/) do @e1.departments(true) end end should 'scope count to owner' do assert_sql(/employee_id = #{@e1.id}/) do @e1.departments(true).count end end end context 'For grouped association' do should 'scope to group' do assert_sql(/employee_id IN \(#{@e1.id},#{@e2.id}\)/) do @e2.group.departments(true) end end should 'scope count to group' do assert_sql(/employee_id IN \(#{@e1.id},#{@e2.id}\)/) do @e1.group.departments(true).count end end should 'have a group count equal to sum of seperate owner counts' do assert_equal @e1.departments(true).count + @e2.departments(true).count, @e2.group.departments(true).count end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
grouped_scope-0.6.1 | test/grouped_scope/has_many_through_association_test.rb |