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.6 test/models/workarea/insights/customers_at_risk_test.rb
workarea-core-3.5.5 test/models/workarea/insights/customers_at_risk_test.rb
workarea-core-3.5.4 test/models/workarea/insights/customers_at_risk_test.rb
workarea-core-3.5.3 test/models/workarea/insights/customers_at_risk_test.rb
workarea-core-3.5.2 test/models/workarea/insights/customers_at_risk_test.rb
workarea-core-3.5.1 test/models/workarea/insights/customers_at_risk_test.rb
workarea-core-3.5.0 test/models/workarea/insights/customers_at_risk_test.rb
workarea-core-3.5.0.beta.1 test/models/workarea/insights/customers_at_risk_test.rb