Sha256: 9018966da15a5eef7c7d430424cc8b044973867aecd158d2eeff62043f74890a

Contents?: true

Size: 1.06 KB

Versions: 9

Compression:

Stored size: 1.06 KB

Contents

require 'spec_helper'
require 'timely/rails/extensions'

describe Timely::Extensions do
  before do
    class TimelyExtensionsTestSeasonal < ActiveRecord::Base
      self.table_name = 'seasonals'
      acts_as_seasonal
    end
  end

  after { Object.send(:remove_const, 'TimelyExtensionsTestSeasonal') }

  it 'should cache boundary start' do
    season = Timely::Season.new
    season.date_groups.build(:start_date => Date.current, :end_date => Date.current + 2)
    season.date_groups.build(:start_date => Date.current - 1, :end_date => Date.current + 1)
    season.save!

    o = TimelyExtensionsTestSeasonal.new
    o.season = season
    o.save!
    expect(o.boundary_start).to eq Date.current - 1
    expect(o.boundary_end  ).to eq Date.current + 2

    expect(TimelyExtensionsTestSeasonal.season_on(Date.current + 3)).to be_empty
    expect(TimelyExtensionsTestSeasonal.season_on(Date.current + 2)).to eq [o]
    expect(TimelyExtensionsTestSeasonal.season_on(Date.current - 1)).to eq [o]
    expect(TimelyExtensionsTestSeasonal.season_on(Date.current - 2)).to be_empty

  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
timely-0.5.0 spec/extensions_spec.rb
timely-0.4.2 spec/extensions_spec.rb
timely-0.4.1 spec/extensions_spec.rb
timely-0.4.0 spec/extensions_spec.rb
timely-0.3.4 spec/extensions_spec.rb
timely-0.3.2 spec/extensions_spec.rb
timely-0.3.1 spec/extensions_spec.rb
timely-0.3.0 spec/extensions_spec.rb
timely-0.1.0 spec/extensions_spec.rb