require 'test_helper' class ConditionalItemTest < ActiveSupport::TestCase def setup 8.times { |index| (index % 2) > 0 ? ConditionalItem.create(:tag => 'todo') : ConditionalItem.create(:tag => 'bad')} @items = ConditionalItem.find(:all, :conditions => "position IS NOT NULL", :order => 'id') @ids = @items.map(&:id) end include SimpleTests include SimpleGaplessTests include ConditionalTests protected def ordered_ids ConditionalItem.find(:all, :order => 'position', :conditions => "position IS NOT NULL").map(&:id) end def create(tag, *args) ConditionalItem.create(:tag => tag || 'todo') end def create_with_conditions_not_met create('bad_tag') end def fail_conditions(item) item.tag = 'bad_tag' item.save end def pass_conditions(item) item.tag = 'todo' item.save end end