Sha256: df1fa7aeaf7adc73f34c2aea7764dd2edbf4d922fbff0b3f1da3fb087cc226d0

Contents?: true

Size: 1.47 KB

Versions: 62

Compression:

Stored size: 1.47 KB

Contents

require 'test_helper'

module Workarea
  module Search
    class DateFilterTest < TestCase
      def test_query_value
        search = AdminOrders.new(placed_at_greater_than: '2016-08-26')
        filter = DateFilter.new(search, 'placed_at', :gte)
        assert_equal(Time.zone.local(2016, 8, 26), filter.query_value)

        search = AdminOrders.new(
          placed_at_greater_than: '2016-08-26',
          placed_at_less_than: '2016-08-30'
        )
        filter = DateFilter.new(search, 'placed_at', :gte)
        assert_equal(Time.zone.local(2016, 8, 26), filter.query_value)
        filter = DateFilter.new(search, 'placed_at', :lt)
        assert_equal(Time.zone.local(2016, 8, 30).end_of_day, filter.query_value)

        search = AdminOrders.new(
          placed_at_greater_than: '2016-08-26',
          placed_at_less_than: '2016-08-26'
        )
        filter = DateFilter.new(search, 'placed_at', :gte)
        assert_equal(Time.zone.local(2016, 8, 26), filter.query_value)
        filter = DateFilter.new(search, 'placed_at', :lt)
        assert_equal(Time.zone.local(2016, 8, 26).end_of_day, filter.query_value)
      end

      def test_time_specified?
        search = AdminOrders.new(placed_at_greater_than: '2016-08-26')
        refute(DateFilter.new(search, 'placed_at', :gte).time_specified?)

        search = AdminOrders.new(placed_at_greater_than: '2019-03-06T14:00:00-05:00')
        assert(DateFilter.new(search, 'placed_at', :gte).time_specified?)
      end
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

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