Sha256: 8c5ae2c8ec74b7d0b72695f9fe13c0bba44b1cd5dcde891cf11c2b47d70cc1f2

Contents?: true

Size: 1.14 KB

Versions: 62

Compression:

Stored size: 1.14 KB

Contents

require 'test_helper'

module Workarea
  module Insights
    class NewProductsTest < TestCase
      setup :add_data, :time_travel

      def add_data
        create_product(id: 'five', created_at: Time.zone.local(2018, 10, 30, 23))
        create_product(id: 'four', created_at: Time.zone.local(2018, 10, 31, 5))
        create_product(id: 'three', created_at: Time.zone.local(2018, 10, 31, 11))
        create_product(id: 'two', created_at: Time.zone.local(2018, 10, 31, 17))
        create_product(id: 'one', created_at: Time.zone.local(2018, 10, 31, 23))
      end

      def time_travel
        travel_to Time.zone.local(2018, 11, 1)
      end

      def test_generate_monthly!
        NewProducts.generate_daily!
        assert_equal(1, NewProducts.count)

        new_products = NewProducts.first
        assert_equal(4, new_products.results.size)
        assert_equal('one', new_products.results.first['product_id'])
        assert_equal('two', new_products.results.second['product_id'])
        assert_equal('three', new_products.results.third['product_id'])
        assert_equal('four', new_products.results.fourth['product_id'])
      end
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-core-3.5.15 test/models/workarea/insights/new_products_test.rb
workarea-core-3.4.36 test/models/workarea/insights/new_products_test.rb
workarea-core-3.5.14 test/models/workarea/insights/new_products_test.rb
workarea-core-3.4.35 test/models/workarea/insights/new_products_test.rb
workarea-core-3.5.13 test/models/workarea/insights/new_products_test.rb
workarea-core-3.4.34 test/models/workarea/insights/new_products_test.rb
workarea-core-3.5.12 test/models/workarea/insights/new_products_test.rb
workarea-core-3.4.33 test/models/workarea/insights/new_products_test.rb
workarea-core-3.5.11 test/models/workarea/insights/new_products_test.rb
workarea-core-3.5.10 test/models/workarea/insights/new_products_test.rb
workarea-core-3.4.32 test/models/workarea/insights/new_products_test.rb
workarea-core-3.5.9 test/models/workarea/insights/new_products_test.rb
workarea-core-3.4.31 test/models/workarea/insights/new_products_test.rb
workarea-core-3.5.8 test/models/workarea/insights/new_products_test.rb
workarea-core-3.4.30 test/models/workarea/insights/new_products_test.rb
workarea-core-3.5.7 test/models/workarea/insights/new_products_test.rb
workarea-core-3.4.29 test/models/workarea/insights/new_products_test.rb
workarea-core-3.5.6 test/models/workarea/insights/new_products_test.rb
workarea-core-3.4.28 test/models/workarea/insights/new_products_test.rb
workarea-core-3.5.5 test/models/workarea/insights/new_products_test.rb