diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 04:45:44 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 04:45:44 +0300 |
commit | 85dc423f7090da0a52c73eb66faf22ddb20efff9 (patch) | |
tree | 9160f299afd8c80c038f08e1545be119f5e3f1e1 /spec/models/product_analytics_event_spec.rb | |
parent | 15c2c8c66dbe422588e5411eee7e68f1fa440bb8 (diff) |
Add latest changes from gitlab-org/gitlab@13-4-stable-ee
Diffstat (limited to 'spec/models/product_analytics_event_spec.rb')
-rw-r--r-- | spec/models/product_analytics_event_spec.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/models/product_analytics_event_spec.rb b/spec/models/product_analytics_event_spec.rb index afdb5b690f8..286729b8398 100644 --- a/spec/models/product_analytics_event_spec.rb +++ b/spec/models/product_analytics_event_spec.rb @@ -35,4 +35,29 @@ RSpec.describe ProductAnalyticsEvent, type: :model do 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 + + describe '.by_category_and_action' do + let_it_be(:event) { create(:product_analytics_event, se_category: 'catA', se_action: 'actA') } + + before do + create(:product_analytics_event, se_category: 'catA', se_action: 'actB') + create(:product_analytics_event, se_category: 'catB', se_action: 'actA') + end + + it { expect(described_class.by_category_and_action('catA', 'actA')).to match_array([event]) } + end + + describe '.count_collector_tstamp_by_day' do + let_it_be(:time_now) { Time.zone.now } + let_it_be(:time_ago) { Time.zone.now - 5.days } + + let_it_be(:events) do + create_list(:product_analytics_event, 3, collector_tstamp: time_now) + + create_list(:product_analytics_event, 2, collector_tstamp: time_ago) + end + + subject { described_class.count_collector_tstamp_by_day(7.days) } + + it { is_expected.to eq({ time_now.beginning_of_day => 3, time_ago.beginning_of_day => 2 }) } + end end |