diff options
Diffstat (limited to 'spec/models/product_analytics_event_spec.rb')
-rw-r--r-- | spec/models/product_analytics_event_spec.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/spec/models/product_analytics_event_spec.rb b/spec/models/product_analytics_event_spec.rb index 6058df9fa13..afdb5b690f8 100644 --- a/spec/models/product_analytics_event_spec.rb +++ b/spec/models/product_analytics_event_spec.rb @@ -21,4 +21,18 @@ RSpec.describe ProductAnalyticsEvent, type: :model do it { expect(described_class.timerange(7.days)).to match_array([event_1, event_2]) } it { expect(described_class.timerange(30.days)).to match_array([event_1, event_2, event_3]) } end + + describe '.count_by_graph' do + let_it_be(:events) do + [ + create(:product_analytics_event, platform: 'web'), + create(:product_analytics_event, platform: 'web'), + create(:product_analytics_event, platform: 'app'), + create(:product_analytics_event, platform: 'mobile', collector_tstamp: Time.zone.now - 10.days) + ] + end + + it { expect(described_class.count_by_graph('platform', 7.days)).to eq({ 'app' => 1, 'web' => 2 }) } + it { expect(described_class.count_by_graph('platform', 30.days)).to eq({ 'app' => 1, 'mobile' => 1, 'web' => 2 }) } + end end |