Sha256: 73d8fc7df53206ef339ee53c4cc544d01ff7eae5aac473ca90932766f3aaa064
Contents?: true
Size: 1.63 KB
Versions: 1
Compression:
Stored size: 1.63 KB
Contents
require 'helper' class TestCohortScope < Test::Unit::TestCase def setup Citizen.minimum_cohort_size = 3 @date_range = (Date.parse('1980-01-01')..Date.parse('1990-01-01')) end def style @style ||= Style.find_by_period 'arts and crafts' end context '.sanitize_constraints' do should 'remove nil constraints' do constraints = CohortScope::Cohort.sanitize_constraints Style, :eh => :tu, :bru => :te, :caesar => nil assert_does_not_contain constraints.keys, :caesar end should 'keep normal constraints' do constraints = CohortScope::Cohort.sanitize_constraints Style, :eh => :tu, :bru => :te, :caesar => nil assert_equal :tu, constraints[:eh] end should 'include constraints that are models' do gob = Resident.find_by_name 'Gob' constraints = CohortScope::Cohort.sanitize_constraints House, :resident => gob assert_equal gob.house_id, constraints[:house_id] end should 'include constraints that are models not related by primary key' do constraints = CohortScope::Cohort.sanitize_constraints House, :style => style assert_equal 'arts and crafts', constraints['period'] end end context '.association_primary_key' do should 'include constraints that are models related by a primary key' do gob = Resident.find_by_name('Gob') key = CohortScope::Cohort.association_primary_key Resident, :house assert_equal 'resident_id', key end should 'include constraints that are models related by a non-primary key' do key = CohortScope::Cohort.association_primary_key House, :style assert_equal 'period', key end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cohort_scope-0.1.0 | test/test_cohort.rb |