From e8d2c2579383897a1dd7f9debd359abe8ae8373d Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Tue, 20 Jul 2021 09:55:51 +0000 Subject: Add latest changes from gitlab-org/gitlab@14-1-stable-ee --- spec/lib/gitlab/import_export/all_models.yml | 47 ++++++++++++---------- .../import_export/import_test_coverage_spec.rb | 4 +- .../import_export/project/object_builder_spec.rb | 26 ++++++++++++ .../import_export/project/tree_restorer_spec.rb | 21 ++++++++++ .../gitlab/import_export/safe_model_attributes.yml | 5 +++ spec/lib/gitlab/import_export/shared_spec.rb | 4 +- .../import_export/snippet_repo_restorer_spec.rb | 2 +- 7 files changed, 83 insertions(+), 26 deletions(-) (limited to 'spec/lib/gitlab/import_export') diff --git a/spec/lib/gitlab/import_export/all_models.yml b/spec/lib/gitlab/import_export/all_models.yml index 87a10b52b22..78805cea66a 100644 --- a/spec/lib/gitlab/import_export/all_models.yml +++ b/spec/lib/gitlab/import_export/all_models.yml @@ -54,6 +54,8 @@ issues: - namespace - note_authors - issue_email_participants +- test_reports +- requirement events: - author - project @@ -196,6 +198,8 @@ merge_request_diff: - merge_request_diff_files merge_request_diff_commits: - merge_request_diff +- commit_author +- committer merge_request_diff_detail: - merge_request_diff merge_request_diff_files: @@ -367,34 +371,34 @@ project: - discord_integration - drone_ci_integration - emails_on_push_integration -- pipelines_email_service -- mattermost_slash_commands_service -- slack_slash_commands_service +- pipelines_email_integration +- mattermost_slash_commands_integration +- slack_slash_commands_integration - irker_integration -- packagist_service -- pivotaltracker_service -- prometheus_service +- packagist_integration +- pivotaltracker_integration +- prometheus_integration - flowdock_integration - assembla_integration - asana_integration -- slack_service -- microsoft_teams_service -- mattermost_service +- slack_integration +- microsoft_teams_integration +- mattermost_integration - hangouts_chat_integration -- unify_circuit_service +- unify_circuit_integration - buildkite_integration - bamboo_integration -- teamcity_service -- pushover_service -- jira_service -- redmine_service -- youtrack_service +- teamcity_integration +- pushover_integration +- jira_integration +- redmine_integration +- youtrack_integration - custom_issue_tracker_integration - bugzilla_integration - ewm_integration - external_wiki_integration -- mock_ci_service -- mock_monitoring_service +- mock_ci_integration +- mock_monitoring_integration - forked_to_members - forked_from_project - forks @@ -480,12 +484,12 @@ project: - kubernetes_namespaces - error_tracking_setting - metrics_setting -- gitlab_slack_application_service -- github_service +- gitlab_slack_application_integration +- github_integration - protected_environments - mirror_user - push_rule -- jenkins_service +- jenkins_integration - index_status - feature_usage - approval_rules @@ -557,7 +561,7 @@ project: - alert_management_alerts - repository_storage_moves - freeze_periods -- webex_teams_service +- webex_teams_integration - build_report_results - vulnerability_statistic - vulnerability_historical_statistics @@ -574,6 +578,7 @@ project: - merge_request_metrics - security_orchestration_policy_configuration - timelogs +- error_tracking_errors award_emoji: - awardable - user diff --git a/spec/lib/gitlab/import_export/import_test_coverage_spec.rb b/spec/lib/gitlab/import_export/import_test_coverage_spec.rb index 7a9e7d8afba..9c6d2708607 100644 --- a/spec/lib/gitlab/import_export/import_test_coverage_spec.rb +++ b/spec/lib/gitlab/import_export/import_test_coverage_spec.rb @@ -109,14 +109,14 @@ RSpec.describe 'Test coverage of the Project Import' do def failure_message(not_tested_relations) <<~MSG - These relations seem to be added recenty and + These relations seem to be added recently and they expected to be covered in our Import specs: #{not_tested_relations}. To do that, expand one of the files listed in `project_json_fixtures` (or expand the list if you consider adding a new fixture file). After that, add a new spec into - `spec/lib/gitlab/import_export/project_tree_restorer_spec.rb` + `spec/lib/gitlab/import_export/project/tree_restorer_spec.rb` to check that the relation is being imported correctly. In case the spec breaks the master or there is a sense of urgency, diff --git a/spec/lib/gitlab/import_export/project/object_builder_spec.rb b/spec/lib/gitlab/import_export/project/object_builder_spec.rb index 20d882c82be..4c9f9f7c690 100644 --- a/spec/lib/gitlab/import_export/project/object_builder_spec.rb +++ b/spec/lib/gitlab/import_export/project/object_builder_spec.rb @@ -150,4 +150,30 @@ RSpec.describe Gitlab::ImportExport::Project::ObjectBuilder do expect(merge_request.persisted?).to be true end end + + context 'merge request diff commit users' do + it 'finds the existing user' do + user = MergeRequest::DiffCommitUser + .find_or_create('Alice', 'alice@example.com') + + found = described_class.build( + MergeRequest::DiffCommitUser, + 'name' => 'Alice', + 'email' => 'alice@example.com' + ) + + expect(found).to eq(user) + end + + it 'creates a new user' do + found = described_class.build( + MergeRequest::DiffCommitUser, + 'name' => 'Alice', + 'email' => 'alice@example.com' + ) + + expect(found.name).to eq('Alice') + expect(found.email).to eq('alice@example.com') + end + end end 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 1b5fba85020..82f465c4f9e 100644 --- a/spec/lib/gitlab/import_export/project/tree_restorer_spec.rb +++ b/spec/lib/gitlab/import_export/project/tree_restorer_spec.rb @@ -224,6 +224,27 @@ RSpec.describe Gitlab::ImportExport::Project::TreeRestorer do expect(MergeRequestDiffCommit.count).to eq(77) end + it 'assigns committer and author details to all diff commits' do + MergeRequestDiffCommit.all.each do |commit| + expect(commit.commit_author_id).not_to be_nil + expect(commit.committer_id).not_to be_nil + end + end + + it 'assigns the correct commit users to different diff commits' do + commit1 = MergeRequestDiffCommit + .find_by(sha: '0b4bc9a49b562e85de7cc9e834518ea6828729b9') + + commit2 = MergeRequestDiffCommit + .find_by(sha: 'a4e5dfebf42e34596526acb8611bc7ed80e4eb3f') + + expect(commit1.commit_author.name).to eq('Dmitriy Zaporozhets') + expect(commit1.commit_author.email).to eq('dmitriy.zaporozhets@gmail.com') + + expect(commit2.commit_author.name).to eq('James Lopez') + expect(commit2.commit_author.email).to eq('james@jameslopez.es') + end + it 'has the correct data for merge request latest_merge_request_diff' do MergeRequest.find_each do |merge_request| expect(merge_request.latest_merge_request_diff_id).to eq(merge_request.merge_request_diffs.maximum(:id)) diff --git a/spec/lib/gitlab/import_export/safe_model_attributes.yml b/spec/lib/gitlab/import_export/safe_model_attributes.yml index 2173bee6b4b..77d126e012e 100644 --- a/spec/lib/gitlab/import_export/safe_model_attributes.yml +++ b/spec/lib/gitlab/import_export/safe_model_attributes.yml @@ -235,6 +235,10 @@ MergeRequestDiffCommit: - committer_email - message - trailers +MergeRequest::DiffCommitUser: +- id +- name +- email MergeRequestDiffFile: - merge_request_diff_id - relative_order @@ -645,6 +649,7 @@ Timelog: - spent_at - created_at - updated_at +- summary ProjectAutoDevops: - id - enabled diff --git a/spec/lib/gitlab/import_export/shared_spec.rb b/spec/lib/gitlab/import_export/shared_spec.rb index feeb88397eb..1945156ca59 100644 --- a/spec/lib/gitlab/import_export/shared_spec.rb +++ b/spec/lib/gitlab/import_export/shared_spec.rb @@ -26,7 +26,7 @@ RSpec.describe Gitlab::ImportExport::Shared do describe '#export_path' do it 'uses a random hash relative to project path' do - expect(subject.export_path).to match(/#{base_path}\h{32}\/\h{32}/) + expect(subject.export_path).to match(%r{#{base_path}\h{32}/\h{32}}) end it 'memoizes the path' do @@ -44,7 +44,7 @@ RSpec.describe Gitlab::ImportExport::Shared do subject = described_class.new(group) base_path = %(/tmp/gitlab_exports/@groups/) - expect(subject.base_path).to match(/#{base_path}\h{2}\/\h{2}\/\h{64}/) + expect(subject.base_path).to match(%r{#{base_path}\h{2}/\h{2}/\h{64}}) end end end diff --git a/spec/lib/gitlab/import_export/snippet_repo_restorer_spec.rb b/spec/lib/gitlab/import_export/snippet_repo_restorer_spec.rb index fe934cadedd..c1661cf02b6 100644 --- a/spec/lib/gitlab/import_export/snippet_repo_restorer_spec.rb +++ b/spec/lib/gitlab/import_export/snippet_repo_restorer_spec.rb @@ -29,7 +29,7 @@ RSpec.describe Gitlab::ImportExport::SnippetRepoRestorer do expect(restorer.restore).to be_truthy end.to change { SnippetRepository.count }.by(1) - blob = snippet.repository.blob_at('HEAD', snippet.file_name) + blob = snippet.repository.blob_at(snippet.default_branch, snippet.file_name) expect(blob).not_to be_nil expect(blob.data).to eq(snippet.content) end -- cgit v1.2.3