Sha256: cc5d327167abb025daa1effbf2bf2c9671830a61e3544f4f7b3042fb853de0ef

Contents?: true

Size: 1.35 KB

Versions: 34

Compression:

Stored size: 1.35 KB

Contents

require 'active_interaction'
require 'active_support/all'
require 'roqua/core_ext/active_interaction/filters/date_time_as_unix_extension'

class DateTimeFilterOperation < ActiveInteraction::Base
  date_time :date_time, default: nil

  def execute
    date_time
  end
end

describe RoquaDateTimeAsUnixFilterExtension do
  let(:time) { Time.now.change(:usec => 0) }

  it 'unix integer time translates correctly to datetime' do
    expect(DateTimeFilterOperation.run! date_time: time.to_i).to eq time
  end

  it 'unix integer time as string translates correctly to datetime' do
    expect(DateTimeFilterOperation.run! date_time: time.to_i.to_s).to eq time
  end

  it 'transations and empty string to nil' do
    expect(DateTimeFilterOperation.run! date_time: '').to eq nil
  end
end

class TimeFilterOperation < ActiveInteraction::Base
  time :time, default: nil

  def execute
    time
  end
end

describe RoquaDateTimeAsUnixFilterExtension do
  let(:time) { Time.now.change(:usec => 0) }

  it 'unix integer time translates correctly to time' do
    expect(TimeFilterOperation.run! time: time.to_i).to eq time
  end

  it 'unix integer time as string translates correctly to datetime' do
    expect(TimeFilterOperation.run! time: time.to_i.to_s).to eq time
  end

  it 'transations and empty string to nil' do
    expect(TimeFilterOperation.run! time: '').to eq nil
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
roqua-support-0.1.25 spec/roqua/core_ext/active_interaction/date_time_as_unix_extension_spec.rb
roqua-support-0.1.24 spec/roqua/core_ext/active_interaction/date_time_as_unix_extension_spec.rb
roqua-support-0.1.23 spec/roqua/core_ext/active_interaction/date_time_as_unix_extension_spec.rb
roqua-support-0.1.22 spec/roqua/core_ext/active_interaction/date_time_as_unix_extension_spec.rb
roqua-support-0.1.21 spec/roqua/core_ext/active_interaction/date_time_as_unix_extension_spec.rb
roqua-support-0.1.20 spec/roqua/core_ext/active_interaction/date_time_as_unix_extension_spec.rb
roqua-support-0.1.19 spec/roqua/core_ext/active_interaction/date_time_as_unix_extension_spec.rb
roqua-support-0.1.18 spec/roqua/core_ext/active_interaction/date_time_as_unix_extension_spec.rb
roqua-support-0.1.17 spec/roqua/core_ext/active_interaction/date_time_as_unix_extension_spec.rb
roqua-support-0.1.16 spec/roqua/core_ext/active_interaction/date_time_as_unix_extension_spec.rb
roqua-support-0.1.15 spec/roqua/core_ext/active_interaction/date_time_as_unix_extension_spec.rb
roqua-support-0.1.14 spec/roqua/core_ext/active_interaction/date_time_as_unix_extension_spec.rb
roqua-support-0.1.13 spec/roqua/core_ext/active_interaction/date_time_as_unix_extension_spec.rb
roqua-support-0.1.12 spec/roqua/core_ext/active_interaction/date_time_as_unix_extension_spec.rb