Sha256: 2e2e08e2cda4202e72e72aeb85b70fd4a9443923a6d41f740700eee713a545c4

Contents?: true

Size: 1.14 KB

Versions: 5

Compression:

Stored size: 1.14 KB

Contents

require File.expand_path('../abstract_unit', __FILE__)

class TestCalculations < ActiveSupport::TestCase
  fixtures :articles, :products, :tariffs, :product_tariffs, :suburbs, :streets, :restaurants,
           :dorms, :rooms, :room_attributes, :room_attribute_assignments, :students, :room_assignments, :users, :readings,
           :departments, :employees, :memberships, :membership_statuses

  def test_count
    assert_equal(3, Product.count(:include => :product_tariffs))
    assert_equal(3, Tariff.count(:include => :product_tariffs))

    expected = {Date.today => 2,
                Date.today.next => 1}

    assert_equal(expected, Tariff.count(:group => :start_date))
  end

  def test_count_distinct
    product = products(:first_product)
    assert_equal(2, product.product_tariffs.count(:distinct => true))
  end

  def test_count_includes
    count = Dorm.count(:include => :rooms,
                       :conditions => ["rooms.room_id = ?", 2])
    assert_equal(1, count)
  end

  def test_count_includes_dup_columns
    count = Tariff.includes(:product_tariffs).where("product_tariffs.tariff_id = ?", 2).count
    assert_equal(1, count)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
composite_primary_keys-5.0.5 test/test_calculations.rb
composite_primary_keys-5.0.4 test/test_calculations.rb
composite_primary_keys-5.0.2 test/test_calculations.rb
composite_primary_keys-5.0.1 test/test_calculations.rb
composite_primary_keys-5.0.0 test/test_calculations.rb