Sha256: c030ca0b060680f938e0b46965145a7a037de8946cca5203182855b225331648

Contents?: true

Size: 1.67 KB

Versions: 27

Compression:

Stored size: 1.67 KB

Contents

require 'test_helper'

module Workarea
  class Segment
    module Rules
      class LastOrderTest < TestCase
        def test_qualifies?
          freeze_time
          metrics = Metrics::User.create!(id: 'bcrouse@workarea.com')

          visit = create_visit(email: 'bcrouse@workarea.com')
          refute(LastOrder.new.qualifies?(visit))

          visit = create_visit(email: 'bcrouse@workarea.com')
          refute(LastOrder.new(days: 7).qualifies?(visit))

          metrics.update_attributes!(last_order_at: 8.days.ago)
          visit = create_visit(email: 'bcrouse@workarea.com')
          refute(LastOrder.new(days: 7, within: true).qualifies?(visit))

          metrics.update_attributes!(last_order_at: 7.days.ago)
          visit = create_visit(email: 'bcrouse@workarea.com')
          assert(LastOrder.new(days: 7, within: true).qualifies?(visit))

          metrics.update_attributes!(last_order_at: 6.days.ago)
          visit = create_visit(email: 'bcrouse@workarea.com')
          assert(LastOrder.new(days: 7, within: true).qualifies?(visit))

          metrics.update_attributes!(last_order_at: 8.days.ago)
          visit = create_visit(email: 'bcrouse@workarea.com')
          assert(LastOrder.new(days: 7, within: false).qualifies?(visit))

          metrics.update_attributes!(last_order_at: 7.days.ago)
          visit = create_visit(email: 'bcrouse@workarea.com')
          refute(LastOrder.new(days: 7, within: false).qualifies?(visit))

          metrics.update_attributes!(last_order_at: 6.days.ago)
          visit = create_visit(email: 'bcrouse@workarea.com')
          refute(LastOrder.new(days: 7, within: false).qualifies?(visit))
        end
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
workarea-core-3.5.27 test/models/workarea/segment/rules/last_order_test.rb
workarea-core-3.5.26 test/models/workarea/segment/rules/last_order_test.rb
workarea-core-3.5.25 test/models/workarea/segment/rules/last_order_test.rb
workarea-core-3.5.23 test/models/workarea/segment/rules/last_order_test.rb
workarea-core-3.5.22 test/models/workarea/segment/rules/last_order_test.rb
workarea-core-3.5.21 test/models/workarea/segment/rules/last_order_test.rb
workarea-core-3.5.20 test/models/workarea/segment/rules/last_order_test.rb
workarea-core-3.5.19 test/models/workarea/segment/rules/last_order_test.rb
workarea-core-3.5.18 test/models/workarea/segment/rules/last_order_test.rb
workarea-core-3.5.17 test/models/workarea/segment/rules/last_order_test.rb
workarea-core-3.5.16 test/models/workarea/segment/rules/last_order_test.rb
workarea-core-3.5.15 test/models/workarea/segment/rules/last_order_test.rb
workarea-core-3.5.14 test/models/workarea/segment/rules/last_order_test.rb
workarea-core-3.5.13 test/models/workarea/segment/rules/last_order_test.rb
workarea-core-3.5.12 test/models/workarea/segment/rules/last_order_test.rb
workarea-core-3.5.11 test/models/workarea/segment/rules/last_order_test.rb
workarea-core-3.5.10 test/models/workarea/segment/rules/last_order_test.rb
workarea-core-3.5.9 test/models/workarea/segment/rules/last_order_test.rb
workarea-core-3.5.8 test/models/workarea/segment/rules/last_order_test.rb
workarea-core-3.5.7 test/models/workarea/segment/rules/last_order_test.rb