Sha256: 2005428c45599d5b76ff8f564e96f87d3e6b1a1925a922b0c9b5bad1cdc2971f

Contents?: true

Size: 844 Bytes

Versions: 2

Compression:

Stored size: 844 Bytes

Contents

feature 'Recurring reports' do
  scenario 'Sending report every 24 hours' do
    when_the_customer_service_desk_wishes_to_receive_a_report_every_24_hours
    then_once_a_report_has_been_sent_another_should_be_scheduled
  end

  def when_the_customer_service_desk_wishes_to_receive_a_report_every_24_hours
    OrderReporting.mailer_class = double(latest_orders: nil)
    OrderReporting.scheduler = OrderReporting::DelayedJobScheduler.new

    OrderReporting.define_report :latest_orders do |config|
      config.send_every = 24.hours
      config.query = OrderReporting::LatestOrdersQuery.new
    end
  end

  def then_once_a_report_has_been_sent_another_should_be_scheduled
    first_job = Delayed::Job.first
    first_job.update!(run_at: Time.now)
    Delayed::Worker.new.work_off
    expect(first_job).to_not eq(Delayed::Job.first)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spree_order_reporting-0.0.2 spec/features/recurring_reports_spec.rb
spree_order_reporting-0.0.1 spec/features/recurring_reports_spec.rb