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.27 test/models/workarea/insights/new_products_test.rb
workarea-core-3.5.26 test/models/workarea/insights/new_products_test.rb
workarea-core-3.4.45 test/models/workarea/insights/new_products_test.rb
workarea-core-3.5.25 test/models/workarea/insights/new_products_test.rb
workarea-core-3.5.23 test/models/workarea/insights/new_products_test.rb
workarea-core-3.4.44 test/models/workarea/insights/new_products_test.rb
workarea-core-3.5.22 test/models/workarea/insights/new_products_test.rb
workarea-core-3.4.43 test/models/workarea/insights/new_products_test.rb
workarea-core-3.5.21 test/models/workarea/insights/new_products_test.rb
workarea-core-3.4.42 test/models/workarea/insights/new_products_test.rb
workarea-core-3.5.20 test/models/workarea/insights/new_products_test.rb
workarea-core-3.4.41 test/models/workarea/insights/new_products_test.rb
workarea-core-3.5.19 test/models/workarea/insights/new_products_test.rb
workarea-core-3.4.40 test/models/workarea/insights/new_products_test.rb
workarea-core-3.5.18 test/models/workarea/insights/new_products_test.rb
workarea-core-3.4.39 test/models/workarea/insights/new_products_test.rb
workarea-core-3.5.17 test/models/workarea/insights/new_products_test.rb
workarea-core-3.4.38 test/models/workarea/insights/new_products_test.rb
workarea-core-3.5.16 test/models/workarea/insights/new_products_test.rb
workarea-core-3.4.37 test/models/workarea/insights/new_products_test.rb