Sha256: dbc9fe8ccb5e50a749b9b93360d776b35c6a133e738d667392097c42338fd461

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'test_help'

require 'simple_tests'
require 'simple_gapless_tests'
require 'simple_gap_tests'
require 'scoped_tests'
require 'conditional_tests'

class ActiveSupport::TestCase
  self.use_transactional_fixtures = true
  self.use_instantiated_fixtures  = false
  
  # Asserts expected items ids order matches the actual items ids ordered by position
  def assert_equal_ids(expected, *args)
    if args.empty?
      assert_equal expected.map{ |index| @ids[index-1]}, ordered_ids
    elsif !@ids.is_a?(Hash)
      assert_equal expected.map{ |index| @ids[index-1]}, ordered_ids(args.first)
    else
      assert_equal expected.map{ |index| @ids[args.first][index-1]}, ordered_ids(args.first)
    end
  end
  
  def reload_items(except=nil)
    @items.each { |item| item.reload unless item == except}
  end
  
  def positions(except=nil)
    reload_items(except)
    @items.reject do |item|
      item == except
    end.map(&:list_position)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
aguids-positionable-0.2.1 test/rails_root/test/test_helper.rb
aguids-positionable-0.2.2 test/rails_root/test/test_helper.rb