Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/factories/error_tracking/detailed_error.rb1
-rw-r--r--spec/factories/sentry_issue.rb8
-rw-r--r--spec/fixtures/api/schemas/error_tracking/error_detailed.json2
-rw-r--r--spec/fixtures/lib/gitlab/import_export/complex/project.json7
-rw-r--r--spec/frontend/error_tracking/components/error_details_spec.js43
-rw-r--r--spec/lib/gitlab/ci/pipeline/seed/build_spec.rb2
-rw-r--r--spec/lib/gitlab/import_export/all_models.yml3
-rw-r--r--spec/lib/gitlab/import_export/project_tree_restorer_spec.rb10
-rw-r--r--spec/lib/gitlab/import_export/safe_model_attributes.yml4
-rw-r--r--spec/models/issue_spec.rb1
-rw-r--r--spec/models/sentry_issue_spec.rb17
-rw-r--r--spec/models/timelog_spec.rb26
-rw-r--r--spec/support/helpers/live_debugger.rb10
-rw-r--r--spec/support/matchers/graphql_matchers.rb6
14 files changed, 135 insertions, 5 deletions
diff --git a/spec/factories/error_tracking/detailed_error.rb b/spec/factories/error_tracking/detailed_error.rb
index 0fee329b808..f12c327d403 100644
--- a/spec/factories/error_tracking/detailed_error.rb
+++ b/spec/factories/error_tracking/detailed_error.rb
@@ -23,6 +23,7 @@ FactoryBot.define do
[Time.now.to_i, 10]
]
end
+ gitlab_issue { 'http://gitlab.example.com/issues/1' }
first_release_last_commit { '68c914da9' }
last_release_last_commit { '9ad419c86' }
first_release_short_version { 'abc123' }
diff --git a/spec/factories/sentry_issue.rb b/spec/factories/sentry_issue.rb
new file mode 100644
index 00000000000..c9886f1673a
--- /dev/null
+++ b/spec/factories/sentry_issue.rb
@@ -0,0 +1,8 @@
+# frozen_string_literal: true
+
+FactoryBot.define do
+ factory :sentry_issue, class: SentryIssue do
+ issue
+ sentry_issue_identifier { 1234567891 }
+ end
+end
diff --git a/spec/fixtures/api/schemas/error_tracking/error_detailed.json b/spec/fixtures/api/schemas/error_tracking/error_detailed.json
index 40d6773f0e6..2a1cd2c03e0 100644
--- a/spec/fixtures/api/schemas/error_tracking/error_detailed.json
+++ b/spec/fixtures/api/schemas/error_tracking/error_detailed.json
@@ -13,6 +13,7 @@
"short_id",
"status",
"frequency",
+ "gitlab_issue",
"first_release_last_commit",
"last_release_last_commit",
"first_release_short_version",
@@ -36,6 +37,7 @@
"short_id": { "type": "string"},
"status": { "type": "string"},
"frequency": { "type": "array"},
+ "gitlab_issue": { "type": ["string", "null"] },
"first_release_last_commit": { "type": ["string", "null"] },
"last_release_last_commit": { "type": ["string", "null"] },
"first_release_short_version": { "type": ["string", "null"] },
diff --git a/spec/fixtures/lib/gitlab/import_export/complex/project.json b/spec/fixtures/lib/gitlab/import_export/complex/project.json
index 8dc91b05f4d..acfd6a6924a 100644
--- a/spec/fixtures/lib/gitlab/import_export/complex/project.json
+++ b/spec/fixtures/lib/gitlab/import_export/complex/project.json
@@ -366,7 +366,12 @@
"type": "ProjectLabel"
}
}
- ]
+ ],
+ "sentry_issue": {
+ "id": 1,
+ "issue_id": 40,
+ "sentry_issue_identifier": 1234567891
+ }
},
{
"id": 39,
diff --git a/spec/frontend/error_tracking/components/error_details_spec.js b/spec/frontend/error_tracking/components/error_details_spec.js
index 72f3577c530..632ed373545 100644
--- a/spec/frontend/error_tracking/components/error_details_spec.js
+++ b/spec/frontend/error_tracking/components/error_details_spec.js
@@ -138,5 +138,48 @@ describe('ErrorDetails', () => {
submitSpy.mockRestore();
});
});
+
+ describe('GitLab issue link', () => {
+ const gitlabIssue = 'https://gitlab.example.com/issues/1';
+ const findGitLabLink = () => wrapper.find(`[href="${gitlabIssue}"]`);
+ const findCreateIssueButton = () => wrapper.find('[data-qa-selector="create_issue_button"]');
+
+ describe('is present', () => {
+ beforeEach(() => {
+ store.state.details.loading = false;
+ store.state.details.error = {
+ id: 1,
+ gitlab_issue: gitlabIssue,
+ };
+ mountComponent();
+ });
+
+ it('should display the issue link', () => {
+ expect(findGitLabLink().exists()).toBe(true);
+ });
+
+ it('should not display a create issue button', () => {
+ expect(findCreateIssueButton().exists()).toBe(false);
+ });
+ });
+
+ describe('is not present', () => {
+ beforeEach(() => {
+ store.state.details.loading = false;
+ store.state.details.error = {
+ id: 1,
+ gitlab_issue: null,
+ };
+ mountComponent();
+ });
+
+ it('should not display an issue link', () => {
+ expect(findGitLabLink().exists()).toBe(false);
+ });
+ it('should display the create issue button', () => {
+ expect(findCreateIssueButton().exists()).toBe(true);
+ });
+ });
+ });
});
});
diff --git a/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb b/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb
index 53dcb6359fe..2ae513aea1b 100644
--- a/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb
+++ b/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb
@@ -852,7 +852,7 @@ describe Gitlab::Ci::Pipeline::Seed::Build do
it "returns an error" do
expect(subject.errors).to contain_exactly(
- "rspec: one job can only need 5 others, but you have listed 6. See needs keyword documentation for more details")
+ "rspec: one job can only need 10 others, but you have listed 11. See needs keyword documentation for more details")
end
end
diff --git a/spec/lib/gitlab/import_export/all_models.yml b/spec/lib/gitlab/import_export/all_models.yml
index 24f0eb9a30c..ab17d9993f6 100644
--- a/spec/lib/gitlab/import_export/all_models.yml
+++ b/spec/lib/gitlab/import_export/all_models.yml
@@ -8,6 +8,7 @@ issues:
- milestone
- notes
- resource_label_events
+- sentry_issue
- label_links
- labels
- last_edited_by
@@ -548,4 +549,6 @@ versions: &version
- actions
zoom_meetings:
- issue
+sentry_issue:
+- issue
design_versions: *version
diff --git a/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb b/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
index 67614eb509d..f549216ccb0 100644
--- a/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
+++ b/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
@@ -234,6 +234,12 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do
expect(meetings.first.url).to eq('https://zoom.us/j/123456789')
end
+ it 'restores sentry issues' do
+ sentry_issue = @project.issues.first.sentry_issue
+
+ expect(sentry_issue.sentry_issue_identifier).to eq(1234567891)
+ end
+
context 'Merge requests' do
it 'always has the new project as a target' do
expect(MergeRequest.find_by_title('MR1').target_project).to eq(@project)
@@ -643,7 +649,9 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do
before do
setup_import_export_config('with_invalid_records')
- Labkit::Correlation::CorrelationId.use_id(correlation_id) { subject }
+ # Import is running from the rake task, `correlation_id` is not assigned
+ expect(Labkit::Correlation::CorrelationId).to receive(:new_id).and_return(correlation_id)
+ subject
end
context 'when failures occur because a relation fails to be processed' do
diff --git a/spec/lib/gitlab/import_export/safe_model_attributes.yml b/spec/lib/gitlab/import_export/safe_model_attributes.yml
index 05cae858450..fa6bf14bf64 100644
--- a/spec/lib/gitlab/import_export/safe_model_attributes.yml
+++ b/spec/lib/gitlab/import_export/safe_model_attributes.yml
@@ -689,6 +689,10 @@ ErrorTracking::ProjectErrorTrackingSetting:
- project_id
- project_name
- organization_name
+SentryIssue:
+- id
+- issue_id
+- sentry_issue_identifier
Suggestion:
- id
- note_id
diff --git a/spec/models/issue_spec.rb b/spec/models/issue_spec.rb
index 0f78cb4d9b1..4d115be9524 100644
--- a/spec/models/issue_spec.rb
+++ b/spec/models/issue_spec.rb
@@ -12,6 +12,7 @@ describe Issue do
it { is_expected.to belong_to(:duplicated_to).class_name('Issue') }
it { is_expected.to belong_to(:closed_by).class_name('User') }
it { is_expected.to have_many(:assignees) }
+ it { is_expected.to have_one(:sentry_issue) }
end
describe 'modules' do
diff --git a/spec/models/sentry_issue_spec.rb b/spec/models/sentry_issue_spec.rb
new file mode 100644
index 00000000000..b3f7d2628db
--- /dev/null
+++ b/spec/models/sentry_issue_spec.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe SentryIssue do
+ describe 'associations' do
+ it { is_expected.to belong_to(:issue) }
+ end
+
+ describe 'validations' do
+ let!(:sentry_issue) { create(:sentry_issue) }
+
+ it { is_expected.to validate_presence_of(:issue) }
+ it { is_expected.to validate_uniqueness_of(:issue) }
+ it { is_expected.to validate_presence_of(:sentry_issue_identifier) }
+ end
+end
diff --git a/spec/models/timelog_spec.rb b/spec/models/timelog_spec.rb
index 7321a458817..33c1afad59f 100644
--- a/spec/models/timelog_spec.rb
+++ b/spec/models/timelog_spec.rb
@@ -41,4 +41,30 @@ RSpec.describe Timelog do
expect(subject).to be_valid
end
end
+
+ describe 'scopes' do
+ describe 'for_issues_in_group' do
+ it 'return timelogs created for group issues' do
+ group = create(:group)
+ subgroup = create(:group, parent: group)
+
+ create(:timelog, issue: create(:issue, project: create(:project)))
+ timelog1 = create(:timelog, issue: create(:issue, project: create(:project, group: group)))
+ timelog2 = create(:timelog, issue: create(:issue, project: create(:project, group: subgroup)))
+
+ expect(described_class.for_issues_in_group(group)).to contain_exactly(timelog1, timelog2)
+ end
+ end
+
+ describe 'between_dates' do
+ it 'returns collection of timelogs within given dates' do
+ create(:timelog, spent_at: 65.days.ago)
+ timelog1 = create(:timelog, spent_at: 15.days.ago)
+ timelog2 = create(:timelog, spent_at: 5.days.ago)
+ timelogs = described_class.between_dates(20.days.ago, 1.day.ago)
+
+ expect(timelogs).to contain_exactly(timelog1, timelog2)
+ end
+ end
+ end
end
diff --git a/spec/support/helpers/live_debugger.rb b/spec/support/helpers/live_debugger.rb
index d6091035b59..cdb068760f4 100644
--- a/spec/support/helpers/live_debugger.rb
+++ b/spec/support/helpers/live_debugger.rb
@@ -6,11 +6,17 @@ module LiveDebugger
def live_debug
puts
puts "Current example is paused for live debugging."
- puts "Opening #{current_url} in your default browser..."
+
+ if ENV['CHROME_HEADLESS'] =~ /^(false|no|0)$/i
+ puts "Switch to the Chrome window that was automatically opened to run the test in order to view current page"
+ else
+ puts "Opening #{current_url} in your default browser..."
+ end
+
puts "The current user credentials are: #{@current_user.username} / #{@current_user.password}" if @current_user
puts "Press any key to resume the execution of the example!!"
- `open #{current_url}`
+ `open #{current_url}` if ENV['CHROME_HEADLESS'] !~ /^(false|no|0)$/i
loop until $stdin.getch
diff --git a/spec/support/matchers/graphql_matchers.rb b/spec/support/matchers/graphql_matchers.rb
index d735c10f698..ebba5d8a73c 100644
--- a/spec/support/matchers/graphql_matchers.rb
+++ b/spec/support/matchers/graphql_matchers.rb
@@ -64,6 +64,12 @@ RSpec::Matchers.define :have_graphql_type do |expected|
end
end
+RSpec::Matchers.define :have_non_null_graphql_type do |expected|
+ match do |field|
+ expect(field.type).to eq(!expected.to_graphql)
+ end
+end
+
RSpec::Matchers.define :have_graphql_resolver do |expected|
match do |field|
case expected