Sha256: 5c2f7972d853c89f1a2c58b719991483766dfe87e8bc360289c0ec0b147f0d8d

Contents?: true

Size: 782 Bytes

Versions: 4

Compression:

Stored size: 782 Bytes

Contents

# frozen_string_literal: true

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
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
timely-0.9.0 spec/extensions_spec.rb
timely-0.8.0 spec/extensions_spec.rb
timely-0.7.0 spec/extensions_spec.rb
timely-0.6.0 spec/extensions_spec.rb