Sha256: 464c0cec3c988175c7e6e02ab02f24da4f3d254bef301e66a957d368125b854c

Contents?: true

Size: 1.31 KB

Versions: 28

Compression:

Stored size: 1.31 KB

Contents

require 'test_helper'

module Workarea
  module Insights
    class CustomersAtRiskTest < TestCase
      def test_results
        Metrics::User.save_order(email: 'bcrouse0@workarea.com', revenue: 1.to_m, at: 60.days.ago)
        Metrics::User.save_order(email: 'bcrouse1@workarea.com', revenue: 1.to_m, at: 1.day.ago)
        Metrics::User.save_order(email: 'bcrouse2@workarea.com', revenue: 10.to_m, at: 2.days.ago)
        Metrics::User.save_order(email: 'bcrouse2@workarea.com', revenue: 10.to_m, at: 3.days.ago)
        Metrics::User.save_order(email: 'bcrouse3@workarea.com', revenue: 20.to_m, at: 2.days.ago)
        Metrics::User.save_order(email: 'bcrouse3@workarea.com', revenue: 20.to_m, at: 3.days.ago)
        Metrics::User.save_order(email: 'bcrouse3@workarea.com', revenue: 20.to_m, at: 4.days.ago)
        Metrics::User.save_order(email: 'bcrouse4@workarea.com', revenue: 30.to_m, at: 6.months.ago)
        Metrics::User.save_order(email: 'bcrouse4@workarea.com', revenue: 30.to_m, at: 6.months.ago)

        Metrics::UpdateUserAggregations.update!
        CustomersAtRisk.generate_monthly!
        assert_equal(1, CustomersAtRisk.count)
        at_risk = CustomersAtRisk.first
        assert_equal(1, at_risk.results.length)
        assert_equal('bcrouse4@workarea.com', at_risk.results.first['_id'])
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

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