Sha256: ec896008a30051e14b2c7977344f5091a8a6dda9bb18b4ce49d0d7ce05042ae6

Contents?: true

Size: 890 Bytes

Versions: 135

Compression:

Stored size: 890 Bytes

Contents

module ForestLiana
  class OperatorDateIntervalParserTest < ActiveSupport::TestCase
    test 'OPERATOR_AFTER_X_HOURS_AGO and OPERATOR_BEFORE_X_HOURS_AGO should not take timezone into account' do
      # Setting a big timezone (GMT+10) on purpose, the timezone should not be applied on the result date
      operatorDateIntervalParser = OperatorDateIntervalParser.new('Australia/Sydney')

      result = operatorDateIntervalParser.get_date_filter(OperatorDateIntervalParser::OPERATOR_AFTER_X_HOURS_AGO, 2)
      hourComputed = result.split('> ')[1].tr('\'', '').to_datetime.hour
      assert hourComputed == Time.now.utc.hour - 2

      result = operatorDateIntervalParser.get_date_filter(OperatorDateIntervalParser::OPERATOR_BEFORE_X_HOURS_AGO, 2)
      hourComputed = result.split('< ')[1].tr('\'', '').to_datetime.hour
      assert hourComputed == Time.now.utc.hour - 2
    end
  end
end

Version data entries

135 entries across 135 versions & 1 rubygems

Version Path
forest_liana-9.1.9 test/services/forest_liana/operator_date_interval_parser_test.rb
forest_liana-9.1.8 test/services/forest_liana/operator_date_interval_parser_test.rb
forest_liana-9.1.7 test/services/forest_liana/operator_date_interval_parser_test.rb
forest_liana-9.1.6 test/services/forest_liana/operator_date_interval_parser_test.rb
forest_liana-9.1.5 test/services/forest_liana/operator_date_interval_parser_test.rb
forest_liana-9.1.4 test/services/forest_liana/operator_date_interval_parser_test.rb
forest_liana-9.1.3 test/services/forest_liana/operator_date_interval_parser_test.rb
forest_liana-9.1.2 test/services/forest_liana/operator_date_interval_parser_test.rb
forest_liana-9.1.1 test/services/forest_liana/operator_date_interval_parser_test.rb
forest_liana-9.1.0 test/services/forest_liana/operator_date_interval_parser_test.rb
forest_liana-8.2.0 test/services/forest_liana/operator_date_interval_parser_test.rb
forest_liana-9.0.0 test/services/forest_liana/operator_date_interval_parser_test.rb
forest_liana-9.0.0.beta.1 test/services/forest_liana/operator_date_interval_parser_test.rb
forest_liana-8.1.0 test/services/forest_liana/operator_date_interval_parser_test.rb
forest_liana-8.0.17 test/services/forest_liana/operator_date_interval_parser_test.rb
forest_liana-7.8.2 test/services/forest_liana/operator_date_interval_parser_test.rb
forest_liana-8.0.16 test/services/forest_liana/operator_date_interval_parser_test.rb
forest_liana-8.0.15 test/services/forest_liana/operator_date_interval_parser_test.rb
forest_liana-8.0.14 test/services/forest_liana/operator_date_interval_parser_test.rb
forest_liana-8.0.13 test/services/forest_liana/operator_date_interval_parser_test.rb