summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab')
-rw-r--r--spec/lib/gitlab/background_migration/user_mentions/create_resource_user_mention_spec.rb10
-rw-r--r--spec/lib/gitlab/cycle_analytics/code_event_fetcher_spec.rb1
-rw-r--r--spec/lib/gitlab/cycle_analytics/code_stage_spec.rb1
-rw-r--r--spec/lib/gitlab/cycle_analytics/issue_event_fetcher_spec.rb1
-rw-r--r--spec/lib/gitlab/cycle_analytics/issue_stage_spec.rb1
-rw-r--r--spec/lib/gitlab/cycle_analytics/plan_event_fetcher_spec.rb1
-rw-r--r--spec/lib/gitlab/cycle_analytics/plan_stage_spec.rb1
-rw-r--r--spec/lib/gitlab/cycle_analytics/production_event_fetcher_spec.rb1
-rw-r--r--spec/lib/gitlab/cycle_analytics/production_stage_spec.rb1
-rw-r--r--spec/lib/gitlab/cycle_analytics/review_event_fetcher_spec.rb1
-rw-r--r--spec/lib/gitlab/cycle_analytics/review_stage_spec.rb1
-rw-r--r--spec/lib/gitlab/cycle_analytics/shared_event_spec.rb16
-rw-r--r--spec/lib/gitlab/cycle_analytics/shared_stage_spec.rb74
-rw-r--r--spec/lib/gitlab/cycle_analytics/staging_event_fetcher_spec.rb1
-rw-r--r--spec/lib/gitlab/cycle_analytics/staging_stage_spec.rb1
-rw-r--r--spec/lib/gitlab/cycle_analytics/test_event_fetcher_spec.rb1
-rw-r--r--spec/lib/gitlab/cycle_analytics/test_stage_spec.rb1
-rw-r--r--spec/lib/gitlab/import_export/all_models.yml2
18 files changed, 8 insertions, 108 deletions
diff --git a/spec/lib/gitlab/background_migration/user_mentions/create_resource_user_mention_spec.rb b/spec/lib/gitlab/background_migration/user_mentions/create_resource_user_mention_spec.rb
index a273dcf9e5c..ff8b9dd1005 100644
--- a/spec/lib/gitlab/background_migration/user_mentions/create_resource_user_mention_spec.rb
+++ b/spec/lib/gitlab/background_migration/user_mentions/create_resource_user_mention_spec.rb
@@ -12,6 +12,7 @@ describe Gitlab::BackgroundMigration::UserMentions::CreateResourceUserMention, s
let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) }
let(:notes) { table(:notes) }
+ let(:routes) { table(:routes) }
let(:author) { users.create!(email: 'author@example.com', notification_email: 'author@example.com', name: 'author', username: 'author', projects_limit: 10, state: 'active') }
let(:member) { users.create!(email: 'member@example.com', notification_email: 'member@example.com', name: 'member', username: 'member', projects_limit: 10, state: 'active') }
@@ -32,13 +33,14 @@ describe Gitlab::BackgroundMigration::UserMentions::CreateResourceUserMention, s
before do
# build personal namespaces and routes for users
- mentioned_users.each { |u| u.becomes(User).save! }
+ mentioned_users.each do |u|
+ namespace = namespaces.create!(path: u.username, name: u.name, runners_token: "my-token-u#{u.id}", owner_id: u.id, type: nil)
+ routes.create!(path: namespace.path, source_type: 'Namespace', source_id: namespace.id)
+ end
# build namespaces and routes for groups
mentioned_groups.each do |gr|
- gr.name += '-org'
- gr.path += '-org'
- gr.becomes(Namespace).save!
+ routes.create!(path: gr.path, source_type: 'Namespace', source_id: gr.id)
end
end
diff --git a/spec/lib/gitlab/cycle_analytics/code_event_fetcher_spec.rb b/spec/lib/gitlab/cycle_analytics/code_event_fetcher_spec.rb
index b521ad0c6ea..326a41a3af7 100644
--- a/spec/lib/gitlab/cycle_analytics/code_event_fetcher_spec.rb
+++ b/spec/lib/gitlab/cycle_analytics/code_event_fetcher_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
require 'spec_helper'
-require 'lib/gitlab/cycle_analytics/shared_event_spec'
describe Gitlab::CycleAnalytics::CodeEventFetcher do
let(:stage_name) { :code }
diff --git a/spec/lib/gitlab/cycle_analytics/code_stage_spec.rb b/spec/lib/gitlab/cycle_analytics/code_stage_spec.rb
index aa12bc21d22..9a4193b09f5 100644
--- a/spec/lib/gitlab/cycle_analytics/code_stage_spec.rb
+++ b/spec/lib/gitlab/cycle_analytics/code_stage_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
require 'spec_helper'
-require 'lib/gitlab/cycle_analytics/shared_stage_spec'
describe Gitlab::CycleAnalytics::CodeStage do
let(:stage_name) { :code }
diff --git a/spec/lib/gitlab/cycle_analytics/issue_event_fetcher_spec.rb b/spec/lib/gitlab/cycle_analytics/issue_event_fetcher_spec.rb
index afb7b6a13b0..a72e2952782 100644
--- a/spec/lib/gitlab/cycle_analytics/issue_event_fetcher_spec.rb
+++ b/spec/lib/gitlab/cycle_analytics/issue_event_fetcher_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
require 'spec_helper'
-require 'lib/gitlab/cycle_analytics/shared_event_spec'
describe Gitlab::CycleAnalytics::IssueEventFetcher do
let(:stage_name) { :issue }
diff --git a/spec/lib/gitlab/cycle_analytics/issue_stage_spec.rb b/spec/lib/gitlab/cycle_analytics/issue_stage_spec.rb
index 497db88d850..021d31bf160 100644
--- a/spec/lib/gitlab/cycle_analytics/issue_stage_spec.rb
+++ b/spec/lib/gitlab/cycle_analytics/issue_stage_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
require 'spec_helper'
-require 'lib/gitlab/cycle_analytics/shared_stage_spec'
describe Gitlab::CycleAnalytics::IssueStage do
let(:stage_name) { :issue }
diff --git a/spec/lib/gitlab/cycle_analytics/plan_event_fetcher_spec.rb b/spec/lib/gitlab/cycle_analytics/plan_event_fetcher_spec.rb
index 17786cd02c6..587f185b970 100644
--- a/spec/lib/gitlab/cycle_analytics/plan_event_fetcher_spec.rb
+++ b/spec/lib/gitlab/cycle_analytics/plan_event_fetcher_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
require 'spec_helper'
-require 'lib/gitlab/cycle_analytics/shared_event_spec'
describe Gitlab::CycleAnalytics::PlanEventFetcher do
let(:stage_name) { :plan }
diff --git a/spec/lib/gitlab/cycle_analytics/plan_stage_spec.rb b/spec/lib/gitlab/cycle_analytics/plan_stage_spec.rb
index 01a46f5ba65..e391fa6b999 100644
--- a/spec/lib/gitlab/cycle_analytics/plan_stage_spec.rb
+++ b/spec/lib/gitlab/cycle_analytics/plan_stage_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
require 'spec_helper'
-require 'lib/gitlab/cycle_analytics/shared_stage_spec'
describe Gitlab::CycleAnalytics::PlanStage do
let(:stage_name) { :plan }
diff --git a/spec/lib/gitlab/cycle_analytics/production_event_fetcher_spec.rb b/spec/lib/gitlab/cycle_analytics/production_event_fetcher_spec.rb
index 3ecfad49acd..aeca72e8c91 100644
--- a/spec/lib/gitlab/cycle_analytics/production_event_fetcher_spec.rb
+++ b/spec/lib/gitlab/cycle_analytics/production_event_fetcher_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
require 'spec_helper'
-require 'lib/gitlab/cycle_analytics/shared_event_spec'
describe Gitlab::CycleAnalytics::ProductionEventFetcher do
let(:stage_name) { :production }
diff --git a/spec/lib/gitlab/cycle_analytics/production_stage_spec.rb b/spec/lib/gitlab/cycle_analytics/production_stage_spec.rb
index eceea474988..aeeae291e2e 100644
--- a/spec/lib/gitlab/cycle_analytics/production_stage_spec.rb
+++ b/spec/lib/gitlab/cycle_analytics/production_stage_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
require 'spec_helper'
-require 'lib/gitlab/cycle_analytics/shared_stage_spec'
describe Gitlab::CycleAnalytics::ProductionStage do
let(:stage_name) { 'Total' }
diff --git a/spec/lib/gitlab/cycle_analytics/review_event_fetcher_spec.rb b/spec/lib/gitlab/cycle_analytics/review_event_fetcher_spec.rb
index 2c2169be58c..3eb62b45e6f 100644
--- a/spec/lib/gitlab/cycle_analytics/review_event_fetcher_spec.rb
+++ b/spec/lib/gitlab/cycle_analytics/review_event_fetcher_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
require 'spec_helper'
-require 'lib/gitlab/cycle_analytics/shared_event_spec'
describe Gitlab::CycleAnalytics::ReviewEventFetcher do
let(:stage_name) { :review }
diff --git a/spec/lib/gitlab/cycle_analytics/review_stage_spec.rb b/spec/lib/gitlab/cycle_analytics/review_stage_spec.rb
index 0f36a8c5c36..14100ee6f73 100644
--- a/spec/lib/gitlab/cycle_analytics/review_stage_spec.rb
+++ b/spec/lib/gitlab/cycle_analytics/review_stage_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
require 'spec_helper'
-require 'lib/gitlab/cycle_analytics/shared_stage_spec'
describe Gitlab::CycleAnalytics::ReviewStage do
let(:stage_name) { :review }
diff --git a/spec/lib/gitlab/cycle_analytics/shared_event_spec.rb b/spec/lib/gitlab/cycle_analytics/shared_event_spec.rb
deleted file mode 100644
index c053af010b3..00000000000
--- a/spec/lib/gitlab/cycle_analytics/shared_event_spec.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-shared_examples 'default query config' do
- let(:project) { create(:project) }
- let(:event) { described_class.new(stage: stage_name, options: { from: 1.day.ago, project: project }) }
-
- it 'has the stage attribute' do
- expect(event.stage).not_to be_nil
- end
-
- it 'has the projection attributes' do
- expect(event.projections).not_to be_nil
- end
-end
diff --git a/spec/lib/gitlab/cycle_analytics/shared_stage_spec.rb b/spec/lib/gitlab/cycle_analytics/shared_stage_spec.rb
deleted file mode 100644
index 9c16fb6f6dc..00000000000
--- a/spec/lib/gitlab/cycle_analytics/shared_stage_spec.rb
+++ /dev/null
@@ -1,74 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-shared_examples 'base stage' do
- ISSUES_MEDIAN = 30.minutes.to_i
-
- let(:stage) { described_class.new(options: { project: double }) }
-
- before do
- allow(stage).to receive(:project_median).and_return(1.12)
- allow_next_instance_of(Gitlab::CycleAnalytics::BaseEventFetcher) do |instance|
- allow(instance).to receive(:event_result).and_return({})
- end
- end
-
- it 'has the median data value' do
- expect(stage.as_json[:value]).not_to be_nil
- end
-
- it 'has the median data stage' do
- expect(stage.as_json[:title]).not_to be_nil
- end
-
- it 'has the median data description' do
- expect(stage.as_json[:description]).not_to be_nil
- end
-
- it 'has the title' do
- expect(stage.title).to eq(stage_name.to_s.capitalize)
- end
-
- it 'has the events' do
- expect(stage.events).not_to be_nil
- end
-end
-
-shared_examples 'calculate #median with date range' do
- context 'when valid date range is given' do
- before do
- stage_options[:from] = 5.days.ago
- stage_options[:to] = 5.days.from_now
- end
-
- it { expect(stage.project_median).to eq(ISSUES_MEDIAN) }
- end
-
- context 'when records are out of the date range' do
- before do
- stage_options[:from] = 2.years.ago
- stage_options[:to] = 1.year.ago
- end
-
- it { expect(stage.project_median).to eq(nil) }
- end
-end
-
-shared_examples 'Gitlab::Analytics::CycleAnalytics::DataCollector backend examples' do
- let(:stage_params) { Gitlab::Analytics::CycleAnalytics::DefaultStages.send("params_for_#{stage_name}_stage").merge(project: project) }
- let(:stage) { Analytics::CycleAnalytics::ProjectStage.new(stage_params) }
- let(:data_collector) { Gitlab::Analytics::CycleAnalytics::DataCollector.new(stage: stage, params: { from: stage_options[:from], current_user: project.creator }) }
- let(:attribute_to_verify) { :title }
-
- context 'provides the same results as the old implementation' do
- it 'for the median' do
- expect(data_collector.median.seconds).to eq(ISSUES_MEDIAN)
- end
-
- it 'for the list of event records' do
- records = data_collector.records_fetcher.serialized_records
- expect(records.map { |event| event[attribute_to_verify] }).to eq(expected_ordered_attribute_values)
- end
- end
-end
diff --git a/spec/lib/gitlab/cycle_analytics/staging_event_fetcher_spec.rb b/spec/lib/gitlab/cycle_analytics/staging_event_fetcher_spec.rb
index 016d2e8da5b..525f1608a70 100644
--- a/spec/lib/gitlab/cycle_analytics/staging_event_fetcher_spec.rb
+++ b/spec/lib/gitlab/cycle_analytics/staging_event_fetcher_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
require 'spec_helper'
-require 'lib/gitlab/cycle_analytics/shared_event_spec'
describe Gitlab::CycleAnalytics::StagingEventFetcher do
let(:stage_name) { :staging }
diff --git a/spec/lib/gitlab/cycle_analytics/staging_stage_spec.rb b/spec/lib/gitlab/cycle_analytics/staging_stage_spec.rb
index 306b08a60e1..930892edd31 100644
--- a/spec/lib/gitlab/cycle_analytics/staging_stage_spec.rb
+++ b/spec/lib/gitlab/cycle_analytics/staging_stage_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
require 'spec_helper'
-require 'lib/gitlab/cycle_analytics/shared_stage_spec'
describe Gitlab::CycleAnalytics::StagingStage do
let(:stage_name) { :staging }
diff --git a/spec/lib/gitlab/cycle_analytics/test_event_fetcher_spec.rb b/spec/lib/gitlab/cycle_analytics/test_event_fetcher_spec.rb
index be7c0e9dd59..d550f083600 100644
--- a/spec/lib/gitlab/cycle_analytics/test_event_fetcher_spec.rb
+++ b/spec/lib/gitlab/cycle_analytics/test_event_fetcher_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
require 'spec_helper'
-require 'lib/gitlab/cycle_analytics/shared_event_spec'
describe Gitlab::CycleAnalytics::TestEventFetcher do
let(:stage_name) { :test }
diff --git a/spec/lib/gitlab/cycle_analytics/test_stage_spec.rb b/spec/lib/gitlab/cycle_analytics/test_stage_spec.rb
index e347f36dfce..56e90520e72 100644
--- a/spec/lib/gitlab/cycle_analytics/test_stage_spec.rb
+++ b/spec/lib/gitlab/cycle_analytics/test_stage_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
require 'spec_helper'
-require 'lib/gitlab/cycle_analytics/shared_stage_spec'
describe Gitlab::CycleAnalytics::TestStage do
let(:stage_name) { :test }
diff --git a/spec/lib/gitlab/import_export/all_models.yml b/spec/lib/gitlab/import_export/all_models.yml
index 37b3e4a4a22..eb28e730499 100644
--- a/spec/lib/gitlab/import_export/all_models.yml
+++ b/spec/lib/gitlab/import_export/all_models.yml
@@ -208,6 +208,7 @@ ci_pipelines:
- vulnerability_findings
- pipeline_config
- security_scans
+- daily_report_results
pipeline_variables:
- pipeline
stages:
@@ -470,6 +471,7 @@ project:
- status_page_setting
- requirements
- export_jobs
+- daily_report_results
award_emoji:
- awardable
- user