Sha256: b7e443b45b2e6f2b9c4e035f14f220d1d47173b525154a947e4c6ef973d25b08

Contents?: true

Size: 1.31 KB

Versions: 34

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::User.update_aggregations!
        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

34 entries across 34 versions & 1 rubygems

Version Path
workarea-core-3.4.45 test/models/workarea/insights/customers_at_risk_test.rb
workarea-core-3.4.44 test/models/workarea/insights/customers_at_risk_test.rb
workarea-core-3.4.43 test/models/workarea/insights/customers_at_risk_test.rb
workarea-core-3.4.42 test/models/workarea/insights/customers_at_risk_test.rb
workarea-core-3.4.41 test/models/workarea/insights/customers_at_risk_test.rb
workarea-core-3.4.40 test/models/workarea/insights/customers_at_risk_test.rb
workarea-core-3.4.39 test/models/workarea/insights/customers_at_risk_test.rb
workarea-core-3.4.38 test/models/workarea/insights/customers_at_risk_test.rb
workarea-core-3.4.37 test/models/workarea/insights/customers_at_risk_test.rb
workarea-core-3.4.36 test/models/workarea/insights/customers_at_risk_test.rb
workarea-core-3.4.35 test/models/workarea/insights/customers_at_risk_test.rb
workarea-core-3.4.34 test/models/workarea/insights/customers_at_risk_test.rb
workarea-core-3.4.33 test/models/workarea/insights/customers_at_risk_test.rb
workarea-core-3.4.32 test/models/workarea/insights/customers_at_risk_test.rb
workarea-core-3.4.31 test/models/workarea/insights/customers_at_risk_test.rb
workarea-core-3.4.30 test/models/workarea/insights/customers_at_risk_test.rb
workarea-core-3.4.29 test/models/workarea/insights/customers_at_risk_test.rb
workarea-core-3.4.28 test/models/workarea/insights/customers_at_risk_test.rb
workarea-core-3.4.27 test/models/workarea/insights/customers_at_risk_test.rb
workarea-core-3.4.26 test/models/workarea/insights/customers_at_risk_test.rb