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.4.4 spec/roqua/core_ext/active_interaction/date_time_as_unix_extension_spec.rb
roqua-support-0.4.3 spec/roqua/core_ext/active_interaction/date_time_as_unix_extension_spec.rb
roqua-support-0.4.2 spec/roqua/core_ext/active_interaction/date_time_as_unix_extension_spec.rb
roqua-support-0.4.1 spec/roqua/core_ext/active_interaction/date_time_as_unix_extension_spec.rb
roqua-support-0.4.0 spec/roqua/core_ext/active_interaction/date_time_as_unix_extension_spec.rb
roqua-support-0.3.5 spec/roqua/core_ext/active_interaction/date_time_as_unix_extension_spec.rb
roqua-support-0.3.4 spec/roqua/core_ext/active_interaction/date_time_as_unix_extension_spec.rb
roqua-support-0.3.3 spec/roqua/core_ext/active_interaction/date_time_as_unix_extension_spec.rb
roqua-support-0.3.2 spec/roqua/core_ext/active_interaction/date_time_as_unix_extension_spec.rb
roqua-support-0.3.1 spec/roqua/core_ext/active_interaction/date_time_as_unix_extension_spec.rb
roqua-support-0.3.0 spec/roqua/core_ext/active_interaction/date_time_as_unix_extension_spec.rb
roqua-support-0.1.34 spec/roqua/core_ext/active_interaction/date_time_as_unix_extension_spec.rb
roqua-support-0.1.33 spec/roqua/core_ext/active_interaction/date_time_as_unix_extension_spec.rb
roqua-support-0.1.32 spec/roqua/core_ext/active_interaction/date_time_as_unix_extension_spec.rb
roqua-support-0.1.31 spec/roqua/core_ext/active_interaction/date_time_as_unix_extension_spec.rb
roqua-support-0.1.30 spec/roqua/core_ext/active_interaction/date_time_as_unix_extension_spec.rb
roqua-support-0.1.29 spec/roqua/core_ext/active_interaction/date_time_as_unix_extension_spec.rb
roqua-support-0.1.28 spec/roqua/core_ext/active_interaction/date_time_as_unix_extension_spec.rb
roqua-support-0.1.27 spec/roqua/core_ext/active_interaction/date_time_as_unix_extension_spec.rb
roqua-support-0.1.26 spec/roqua/core_ext/active_interaction/date_time_as_unix_extension_spec.rb