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/services/product_analytics | |
parent | 15c2c8c66dbe422588e5411eee7e68f1fa440bb8 (diff) |
Add latest changes from gitlab-org/gitlab@13-4-stable-ee
Diffstat (limited to 'spec/services/product_analytics')
-rw-r--r-- | spec/services/product_analytics/build_activity_graph_service_spec.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/services/product_analytics/build_activity_graph_service_spec.rb b/spec/services/product_analytics/build_activity_graph_service_spec.rb new file mode 100644 index 00000000000..e303656da34 --- /dev/null +++ b/spec/services/product_analytics/build_activity_graph_service_spec.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe ProductAnalytics::BuildActivityGraphService do + let_it_be(:project) { create(:project) } + let_it_be(:time_now) { Time.zone.now } + let_it_be(:time_ago) { Time.zone.now - 5.days } + + let_it_be(:events) do + [ + create(:product_analytics_event, project: project, collector_tstamp: time_now), + create(:product_analytics_event, project: project, collector_tstamp: time_now), + create(:product_analytics_event, project: project, collector_tstamp: time_now), + create(:product_analytics_event, project: project, collector_tstamp: time_ago), + create(:product_analytics_event, project: project, collector_tstamp: time_ago) + ] + end + + let(:params) { { timerange: 7 } } + + subject { described_class.new(project, params).execute } + + it 'returns a valid graph hash' do + expected_hash = { + id: 'collector_tstamp', + keys: [time_ago.to_date, time_now.to_date], + values: [2, 3] + } + + expect(subject).to eq(expected_hash) + end +end |