Sha256: 5f41a2781b4365989512b99b96683415cb8e32f24173044149557460dcfd31a7

Contents?: true

Size: 1.24 KB

Versions: 62

Compression:

Stored size: 1.24 KB

Contents

require 'test_helper'

module Workarea
  module Insights
    class BaseTest < TestCase
      def test_reporting_on
        travel_to Time.zone.local(2019, 1, 9, 11)
        assert_equal(Time.zone.local(2019, 1, 8, 11), Base.create!.reporting_on)
      end

      def test_by_dashboard
        one = Base.create!(dashboards: %w(catalog people))
        two = Base.create!(dashboards: %w(catalog))
        three = Base.create!(dashboards: %w(people))

        assert_equal([three, two, one], Base.by_dashboard('catalog', 'people').to_a)
      end

      def test_current
        assert_instance_of(Base, Base.current)

        last_month = Base.create!(created_at: 1.month.ago)
        assert_equal(last_month, Base.current)

        last_week = Base.create!(created_at: 1.week.ago)
        assert_equal(last_week, Base.current)
      end

      def test_include?
        id = BSON::ObjectId.new
        instance = Base.create!(results: [{ 'category_id' => id }])

        assert(instance.include?(category_id: id))
        assert(instance.include?(category_id: id.to_s))
        assert(instance.include?('category_id' => id))
        assert(instance.include?('category_id' => id.to_s))
        refute(instance.include?(category_id: 'foo'))
      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/base_test.rb
workarea-core-3.5.26 test/models/workarea/insights/base_test.rb
workarea-core-3.4.45 test/models/workarea/insights/base_test.rb
workarea-core-3.5.25 test/models/workarea/insights/base_test.rb
workarea-core-3.5.23 test/models/workarea/insights/base_test.rb
workarea-core-3.4.44 test/models/workarea/insights/base_test.rb
workarea-core-3.5.22 test/models/workarea/insights/base_test.rb
workarea-core-3.4.43 test/models/workarea/insights/base_test.rb
workarea-core-3.5.21 test/models/workarea/insights/base_test.rb
workarea-core-3.4.42 test/models/workarea/insights/base_test.rb
workarea-core-3.5.20 test/models/workarea/insights/base_test.rb
workarea-core-3.4.41 test/models/workarea/insights/base_test.rb
workarea-core-3.5.19 test/models/workarea/insights/base_test.rb
workarea-core-3.4.40 test/models/workarea/insights/base_test.rb
workarea-core-3.5.18 test/models/workarea/insights/base_test.rb
workarea-core-3.4.39 test/models/workarea/insights/base_test.rb
workarea-core-3.5.17 test/models/workarea/insights/base_test.rb
workarea-core-3.4.38 test/models/workarea/insights/base_test.rb
workarea-core-3.5.16 test/models/workarea/insights/base_test.rb
workarea-core-3.4.37 test/models/workarea/insights/base_test.rb