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.4.27 test/queries/workarea/search/date_filter_test.rb
workarea-core-3.5.4 test/queries/workarea/search/date_filter_test.rb
workarea-core-3.4.26 test/queries/workarea/search/date_filter_test.rb
workarea-core-3.5.3 test/queries/workarea/search/date_filter_test.rb
workarea-core-3.4.25 test/queries/workarea/search/date_filter_test.rb
workarea-core-3.5.2 test/queries/workarea/search/date_filter_test.rb
workarea-core-3.4.24 test/queries/workarea/search/date_filter_test.rb
workarea-core-3.5.1 test/queries/workarea/search/date_filter_test.rb
workarea-core-3.4.23 test/queries/workarea/search/date_filter_test.rb
workarea-core-3.4.22 test/queries/workarea/search/date_filter_test.rb
workarea-core-3.5.0 test/queries/workarea/search/date_filter_test.rb
workarea-core-3.4.21 test/queries/workarea/search/date_filter_test.rb
workarea-core-3.5.0.beta.1 test/queries/workarea/search/date_filter_test.rb
workarea-core-3.4.20 test/queries/workarea/search/date_filter_test.rb
workarea-core-3.4.19 test/queries/workarea/search/date_filter_test.rb
workarea-core-3.4.18 test/queries/workarea/search/date_filter_test.rb
workarea-core-3.4.17 test/queries/workarea/search/date_filter_test.rb
workarea-core-3.4.16 test/queries/workarea/search/date_filter_test.rb
workarea-core-3.4.15 test/queries/workarea/search/date_filter_test.rb
workarea-core-3.4.14 test/queries/workarea/search/date_filter_test.rb