diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-11 00:10:15 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-11 00:10:15 +0300 |
commit | e109a7799eb2c5598211c4cc1e0c83d5beb44018 (patch) | |
tree | d72aa61dbb5b04bb0f25232660591963bc1f03b8 /spec/migrations | |
parent | cba8ff64401258aa68eebd7603d4022884ed0a45 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/migrations')
32 files changed, 133 insertions, 133 deletions
diff --git a/spec/migrations/20190924152703_migrate_issue_trackers_data_spec.rb b/spec/migrations/20190924152703_migrate_issue_trackers_data_spec.rb index 11398685549..47f85df01ac 100644 --- a/spec/migrations/20190924152703_migrate_issue_trackers_data_spec.rb +++ b/spec/migrations/20190924152703_migrate_issue_trackers_data_spec.rb @@ -15,35 +15,35 @@ RSpec.describe MigrateIssueTrackersData do end let!(:jira_service) do - services.create(type: 'JiraService', properties: properties, category: 'issue_tracker') + services.create!(type: 'JiraService', properties: properties, category: 'issue_tracker') end let!(:jira_service_nil) do - services.create(type: 'JiraService', properties: nil, category: 'issue_tracker') + services.create!(type: 'JiraService', properties: nil, category: 'issue_tracker') end let!(:bugzilla_service) do - services.create(type: 'BugzillaService', properties: properties, category: 'issue_tracker') + services.create!(type: 'BugzillaService', properties: properties, category: 'issue_tracker') end let!(:youtrack_service) do - services.create(type: 'YoutrackService', properties: properties, category: 'issue_tracker') + services.create!(type: 'YoutrackService', properties: properties, category: 'issue_tracker') end let!(:youtrack_service_empty) do - services.create(type: 'YoutrackService', properties: '', category: 'issue_tracker') + services.create!(type: 'YoutrackService', properties: '', category: 'issue_tracker') end let!(:gitlab_service) do - services.create(type: 'GitlabIssueTrackerService', properties: properties, category: 'issue_tracker') + services.create!(type: 'GitlabIssueTrackerService', properties: properties, category: 'issue_tracker') end let!(:gitlab_service_empty) do - services.create(type: 'GitlabIssueTrackerService', properties: {}, category: 'issue_tracker') + services.create!(type: 'GitlabIssueTrackerService', properties: {}, category: 'issue_tracker') end let!(:other_service) do - services.create(type: 'OtherService', properties: properties, category: 'other_category') + services.create!(type: 'OtherService', properties: properties, category: 'other_category') end before do diff --git a/spec/migrations/20200122123016_backfill_project_settings_spec.rb b/spec/migrations/20200122123016_backfill_project_settings_spec.rb index 60c6206a83b..9ae492a36aa 100644 --- a/spec/migrations/20200122123016_backfill_project_settings_spec.rb +++ b/spec/migrations/20200122123016_backfill_project_settings_spec.rb @@ -5,16 +5,16 @@ require Rails.root.join('db', 'post_migrate', '20200122123016_backfill_project_s RSpec.describe BackfillProjectSettings, :sidekiq, schema: 20200114113341 do let(:projects) { table(:projects) } - let(:namespace) { table(:namespaces).create(name: 'user', path: 'user') } - let(:project) { projects.create(namespace_id: namespace.id) } + let(:namespace) { table(:namespaces).create!(name: 'user', path: 'user') } + let(:project) { projects.create!(namespace_id: namespace.id) } describe '#up' do before do stub_const("#{described_class}::BATCH_SIZE", 2) - projects.create(id: 1, namespace_id: namespace.id) - projects.create(id: 2, namespace_id: namespace.id) - projects.create(id: 3, namespace_id: namespace.id) + projects.create!(id: 1, namespace_id: namespace.id) + projects.create!(id: 2, namespace_id: namespace.id) + projects.create!(id: 3, namespace_id: namespace.id) end it 'schedules BackfillProjectSettings background jobs' do diff --git a/spec/migrations/20200123155929_remove_invalid_jira_data_spec.rb b/spec/migrations/20200123155929_remove_invalid_jira_data_spec.rb index e69a30752db..a6ef0b29461 100644 --- a/spec/migrations/20200123155929_remove_invalid_jira_data_spec.rb +++ b/spec/migrations/20200123155929_remove_invalid_jira_data_spec.rb @@ -7,7 +7,7 @@ RSpec.describe RemoveInvalidJiraData do let(:jira_tracker_data) { table(:jira_tracker_data) } let(:services) { table(:services) } - let(:service) { services.create(id: 1) } + let(:service) { services.create!(id: 1) } let(:data) do { service_id: service.id, @@ -22,49 +22,49 @@ RSpec.describe RemoveInvalidJiraData do } end - let!(:valid_data) { jira_tracker_data.create(data) } - let!(:empty_data) { jira_tracker_data.create(service_id: service.id) } + let!(:valid_data) { jira_tracker_data.create!(data) } + let!(:empty_data) { jira_tracker_data.create!(service_id: service.id) } let!(:invalid_api_url) do data[:encrypted_api_url_iv] = nil - jira_tracker_data.create(data) + jira_tracker_data.create!(data) end let!(:missing_api_url) do data[:encrypted_api_url] = '' data[:encrypted_api_url_iv] = nil - jira_tracker_data.create(data) + jira_tracker_data.create!(data) end let!(:invalid_url) do data[:encrypted_url_iv] = nil - jira_tracker_data.create(data) + jira_tracker_data.create!(data) end let!(:missing_url) do data[:encrypted_url] = '' - jira_tracker_data.create(data) + jira_tracker_data.create!(data) end let!(:invalid_username) do data[:encrypted_username_iv] = nil - jira_tracker_data.create(data) + jira_tracker_data.create!(data) end let!(:missing_username) do data[:encrypted_username] = nil data[:encrypted_username_iv] = nil - jira_tracker_data.create(data) + jira_tracker_data.create!(data) end let!(:invalid_password) do data[:encrypted_password_iv] = nil - jira_tracker_data.create(data) + jira_tracker_data.create!(data) end let!(:missing_password) do data[:encrypted_password] = nil data[:encrypted_username_iv] = nil - jira_tracker_data.create(data) + jira_tracker_data.create!(data) end it 'removes the invalid data' do diff --git a/spec/migrations/20200127090233_remove_invalid_issue_tracker_data_spec.rb b/spec/migrations/20200127090233_remove_invalid_issue_tracker_data_spec.rb index e7917cf5d72..9ddf188b15e 100644 --- a/spec/migrations/20200127090233_remove_invalid_issue_tracker_data_spec.rb +++ b/spec/migrations/20200127090233_remove_invalid_issue_tracker_data_spec.rb @@ -7,7 +7,7 @@ RSpec.describe RemoveInvalidIssueTrackerData do let(:issue_tracker_data) { table(:issue_tracker_data) } let(:services) { table(:services) } - let(:service) { services.create(id: 1) } + let(:service) { services.create!(id: 1) } let(:data) do { service_id: service.id, @@ -20,38 +20,38 @@ RSpec.describe RemoveInvalidIssueTrackerData do } end - let!(:valid_data) { issue_tracker_data.create(data) } - let!(:empty_data) { issue_tracker_data.create(service_id: service.id) } + let!(:valid_data) { issue_tracker_data.create!(data) } + let!(:empty_data) { issue_tracker_data.create!(service_id: service.id) } let!(:invalid_issues_url) do data[:encrypted_issues_url_iv] = nil - issue_tracker_data.create(data) + issue_tracker_data.create!(data) end let!(:missing_issues_url) do data[:encrypted_issues_url] = '' data[:encrypted_issues_url_iv] = nil - issue_tracker_data.create(data) + issue_tracker_data.create!(data) end let!(:invalid_new_isue_url) do data[:encrypted_new_issue_url_iv] = nil - issue_tracker_data.create(data) + issue_tracker_data.create!(data) end let!(:missing_new_issue_url) do data[:encrypted_new_issue_url] = '' - issue_tracker_data.create(data) + issue_tracker_data.create!(data) end let!(:invalid_project_url) do data[:encrypted_project_url_iv] = nil - issue_tracker_data.create(data) + issue_tracker_data.create!(data) end let!(:missing_project_url) do data[:encrypted_project_url] = nil data[:encrypted_project_url_iv] = nil - issue_tracker_data.create(data) + issue_tracker_data.create!(data) end it 'removes the invalid data' do diff --git a/spec/migrations/20200130145430_reschedule_migrate_issue_trackers_data_spec.rb b/spec/migrations/20200130145430_reschedule_migrate_issue_trackers_data_spec.rb index e140be476ab..9947718d11b 100644 --- a/spec/migrations/20200130145430_reschedule_migrate_issue_trackers_data_spec.rb +++ b/spec/migrations/20200130145430_reschedule_migrate_issue_trackers_data_spec.rb @@ -15,35 +15,35 @@ RSpec.describe RescheduleMigrateIssueTrackersData do end let!(:jira_service) do - services.create(id: 10, type: 'JiraService', properties: properties, category: 'issue_tracker') + services.create!(id: 10, type: 'JiraService', properties: properties, category: 'issue_tracker') end let!(:jira_service_nil) do - services.create(id: 11, type: 'JiraService', properties: nil, category: 'issue_tracker') + services.create!(id: 11, type: 'JiraService', properties: nil, category: 'issue_tracker') end let!(:bugzilla_service) do - services.create(id: 12, type: 'BugzillaService', properties: properties, category: 'issue_tracker') + services.create!(id: 12, type: 'BugzillaService', properties: properties, category: 'issue_tracker') end let!(:youtrack_service) do - services.create(id: 13, type: 'YoutrackService', properties: properties, category: 'issue_tracker') + services.create!(id: 13, type: 'YoutrackService', properties: properties, category: 'issue_tracker') end let!(:youtrack_service_empty) do - services.create(id: 14, type: 'YoutrackService', properties: '', category: 'issue_tracker') + services.create!(id: 14, type: 'YoutrackService', properties: '', category: 'issue_tracker') end let!(:gitlab_service) do - services.create(id: 15, type: 'GitlabIssueTrackerService', properties: properties, category: 'issue_tracker') + services.create!(id: 15, type: 'GitlabIssueTrackerService', properties: properties, category: 'issue_tracker') end let!(:gitlab_service_empty) do - services.create(id: 16, type: 'GitlabIssueTrackerService', properties: {}, category: 'issue_tracker') + services.create!(id: 16, type: 'GitlabIssueTrackerService', properties: {}, category: 'issue_tracker') end let!(:other_service) do - services.create(id: 17, type: 'OtherService', properties: properties, category: 'other_category') + services.create!(id: 17, type: 'OtherService', properties: properties, category: 'other_category') end before do @@ -69,7 +69,7 @@ RSpec.describe RescheduleMigrateIssueTrackersData do let(:jira_tracker_data) { table(:jira_tracker_data) } let!(:valid_issue_tracker_data) do - issue_tracker_data.create( + issue_tracker_data.create!( service_id: bugzilla_service.id, encrypted_issues_url: 'http://url.com', encrypted_issues_url_iv: 'somevalue' @@ -77,7 +77,7 @@ RSpec.describe RescheduleMigrateIssueTrackersData do end let!(:invalid_issue_tracker_data) do - issue_tracker_data.create( + issue_tracker_data.create!( service_id: bugzilla_service.id, encrypted_issues_url: 'http:url.com', encrypted_issues_url_iv: nil @@ -85,7 +85,7 @@ RSpec.describe RescheduleMigrateIssueTrackersData do end let!(:valid_jira_tracker_data) do - jira_tracker_data.create( + jira_tracker_data.create!( service_id: bugzilla_service.id, encrypted_url: 'http://url.com', encrypted_url_iv: 'somevalue' @@ -93,7 +93,7 @@ RSpec.describe RescheduleMigrateIssueTrackersData do end let!(:invalid_jira_tracker_data) do - jira_tracker_data.create( + jira_tracker_data.create!( service_id: bugzilla_service.id, encrypted_url: 'http://url.com', encrypted_url_iv: nil diff --git a/spec/migrations/20200313203550_remove_orphaned_chat_names_spec.rb b/spec/migrations/20200313203550_remove_orphaned_chat_names_spec.rb index d9ce62fe475..f16e7b483e9 100644 --- a/spec/migrations/20200313203550_remove_orphaned_chat_names_spec.rb +++ b/spec/migrations/20200313203550_remove_orphaned_chat_names_spec.rb @@ -9,9 +9,9 @@ RSpec.describe RemoveOrphanedChatNames, schema: 20200313202430 do let(:services) { table(:services) } let(:chat_names) { table(:chat_names) } - let(:namespace) { namespaces.create(name: 'foo', path: 'foo') } - let(:project) { projects.create(namespace_id: namespace.id) } - let(:service) { services.create(project_id: project.id, type: 'chat') } + let(:namespace) { namespaces.create!(name: 'foo', path: 'foo') } + let(:project) { projects.create!(namespace_id: namespace.id) } + let(:service) { services.create!(project_id: project.id, type: 'chat') } let(:chat_name) { chat_names.create!(service_id: service.id, team_id: 'TEAM', user_id: 12345, chat_id: 12345) } let(:orphaned_chat_name) { chat_names.create!(team_id: 'TEAM', service_id: 0, user_id: 12345, chat_id: 12345) } diff --git a/spec/migrations/20200406102120_backfill_deployment_clusters_from_deployments_spec.rb b/spec/migrations/20200406102120_backfill_deployment_clusters_from_deployments_spec.rb index c6b221b09a5..9950cc23889 100644 --- a/spec/migrations/20200406102120_backfill_deployment_clusters_from_deployments_spec.rb +++ b/spec/migrations/20200406102120_backfill_deployment_clusters_from_deployments_spec.rb @@ -8,10 +8,10 @@ RSpec.describe BackfillDeploymentClustersFromDeployments, :migration, :sidekiq, it 'schedules BackfillDeploymentClustersFromDeployments background jobs' do stub_const("#{described_class}::BATCH_SIZE", 2) - namespace = table(:namespaces).create(name: 'the-namespace', path: 'the-path') - project = table(:projects).create(name: 'the-project', namespace_id: namespace.id) - environment = table(:environments).create(name: 'the-environment', project_id: project.id, slug: 'slug') - cluster = table(:clusters).create(name: 'the-cluster') + namespace = table(:namespaces).create!(name: 'the-namespace', path: 'the-path') + project = table(:projects).create!(name: 'the-project', namespace_id: namespace.id) + environment = table(:environments).create!(name: 'the-environment', project_id: project.id, slug: 'slug') + cluster = table(:clusters).create!(name: 'the-cluster') deployment_data = { cluster_id: cluster.id, project_id: project.id, environment_id: environment.id, ref: 'abc', tag: false, sha: 'sha', status: 1 } @@ -44,7 +44,7 @@ RSpec.describe BackfillDeploymentClustersFromDeployments, :migration, :sidekiq, def create_deployment(**data) @iid ||= 0 @iid += 1 - table(:deployments).create(iid: @iid, **data) + table(:deployments).create!(iid: @iid, **data) end end end diff --git a/spec/migrations/20200526115436_dedup_mr_metrics_spec.rb b/spec/migrations/20200526115436_dedup_mr_metrics_spec.rb index f2698a0f352..9d3851ed5b0 100644 --- a/spec/migrations/20200526115436_dedup_mr_metrics_spec.rb +++ b/spec/migrations/20200526115436_dedup_mr_metrics_spec.rb @@ -10,19 +10,19 @@ RSpec.describe DedupMrMetrics, :migration, schema: 20200526013844 do let(:metrics) { table(:merge_request_metrics) } let(:merge_request_params) { { source_branch: 'x', target_branch: 'y', target_project_id: project.id } } - let!(:namespace) { namespaces.create(name: 'foo', path: 'foo') } + let!(:namespace) { namespaces.create!(name: 'foo', path: 'foo') } let!(:project) { projects.create!(namespace_id: namespace.id) } let!(:merge_request_1) { merge_requests.create!(merge_request_params) } let!(:merge_request_2) { merge_requests.create!(merge_request_params) } let!(:merge_request_3) { merge_requests.create!(merge_request_params) } - let!(:duplicated_metrics_1) { metrics.create(merge_request_id: merge_request_1.id, latest_build_started_at: 1.day.ago, first_deployed_to_production_at: 5.days.ago, updated_at: 2.months.ago) } - let!(:duplicated_metrics_2) { metrics.create(merge_request_id: merge_request_1.id, latest_build_started_at: Time.now, merged_at: Time.now, updated_at: 1.month.ago) } + let!(:duplicated_metrics_1) { metrics.create!(merge_request_id: merge_request_1.id, latest_build_started_at: 1.day.ago, first_deployed_to_production_at: 5.days.ago, updated_at: 2.months.ago) } + let!(:duplicated_metrics_2) { metrics.create!(merge_request_id: merge_request_1.id, latest_build_started_at: Time.now, merged_at: Time.now, updated_at: 1.month.ago) } - let!(:duplicated_metrics_3) { metrics.create(merge_request_id: merge_request_3.id, diff_size: 30, commits_count: 20, updated_at: 2.months.ago) } - let!(:duplicated_metrics_4) { metrics.create(merge_request_id: merge_request_3.id, added_lines: 5, commits_count: nil, updated_at: 1.month.ago) } + let!(:duplicated_metrics_3) { metrics.create!(merge_request_id: merge_request_3.id, diff_size: 30, commits_count: 20, updated_at: 2.months.ago) } + let!(:duplicated_metrics_4) { metrics.create!(merge_request_id: merge_request_3.id, added_lines: 5, commits_count: nil, updated_at: 1.month.ago) } - let!(:non_duplicated_metrics) { metrics.create(merge_request_id: merge_request_2.id, latest_build_started_at: 2.days.ago) } + let!(:non_duplicated_metrics) { metrics.create!(merge_request_id: merge_request_2.id, latest_build_started_at: 2.days.ago) } it 'deduplicates merge_request_metrics table' do expect { migrate! }.to change { metrics.count }.from(5).to(3) diff --git a/spec/migrations/add_deploy_token_type_to_deploy_tokens_spec.rb b/spec/migrations/add_deploy_token_type_to_deploy_tokens_spec.rb index f1fe27e72a1..b33320c922a 100644 --- a/spec/migrations/add_deploy_token_type_to_deploy_tokens_spec.rb +++ b/spec/migrations/add_deploy_token_type_to_deploy_tokens_spec.rb @@ -6,7 +6,7 @@ require Rails.root.join('db', 'migrate', '20200122161638_add_deploy_token_type_t RSpec.describe AddDeployTokenTypeToDeployTokens do let(:deploy_tokens) { table(:deploy_tokens) } let(:deploy_token) do - deploy_tokens.create(name: 'token_test', + deploy_tokens.create!(name: 'token_test', username: 'gitlab+deploy-token-1', token_encrypted: 'dr8rPXwM+Mbs2p3Bg1+gpnXqrnH/wu6vaHdcc7A3isPR67WB', read_repository: true, diff --git a/spec/migrations/add_incident_settings_to_all_existing_projects_spec.rb b/spec/migrations/add_incident_settings_to_all_existing_projects_spec.rb index dab42c0ffc3..a62fc43df02 100644 --- a/spec/migrations/add_incident_settings_to_all_existing_projects_spec.rb +++ b/spec/migrations/add_incident_settings_to_all_existing_projects_spec.rb @@ -38,7 +38,7 @@ RSpec.describe AddIncidentSettingsToAllExistingProjects, :migration do RSpec.shared_context 'with incident settings' do let(:existing_create_issue) { false } before do - project_incident_management_settings.create( + project_incident_management_settings.create!( project_id: project.id, create_issue: existing_create_issue ) diff --git a/spec/migrations/add_unique_constraint_to_approvals_user_id_and_merge_request_id_spec.rb b/spec/migrations/add_unique_constraint_to_approvals_user_id_and_merge_request_id_spec.rb index 6c04be5fc60..391bc59cdc0 100644 --- a/spec/migrations/add_unique_constraint_to_approvals_user_id_and_merge_request_id_spec.rb +++ b/spec/migrations/add_unique_constraint_to_approvals_user_id_and_merge_request_id_spec.rb @@ -12,15 +12,15 @@ RSpec.describe AddUniqueConstraintToApprovalsUserIdAndMergeRequestId do describe '#up' do before do - namespaces.create(id: 1, name: 'ns', path: 'ns') - projects.create(id: 1, namespace_id: 1) - merge_requests.create(id: 1, target_branch: 'master', source_branch: 'feature-1', target_project_id: 1) - merge_requests.create(id: 2, target_branch: 'master', source_branch: 'feature-2', target_project_id: 1) + namespaces.create!(id: 1, name: 'ns', path: 'ns') + projects.create!(id: 1, namespace_id: 1) + merge_requests.create!(id: 1, target_branch: 'master', source_branch: 'feature-1', target_project_id: 1) + merge_requests.create!(id: 2, target_branch: 'master', source_branch: 'feature-2', target_project_id: 1) end it 'deletes duplicate records and keeps the first one' do - first_approval = approvals.create(id: 1, merge_request_id: 1, user_id: 1) - approvals.create(id: 2, merge_request_id: 1, user_id: 1) + first_approval = approvals.create!(id: 1, merge_request_id: 1, user_id: 1) + approvals.create!(id: 2, merge_request_id: 1, user_id: 1) migration.up diff --git a/spec/migrations/backfill_and_add_not_null_constraint_to_released_at_column_on_releases_table_spec.rb b/spec/migrations/backfill_and_add_not_null_constraint_to_released_at_column_on_releases_table_spec.rb index 9d0ad5863c6..6c782af9a31 100644 --- a/spec/migrations/backfill_and_add_not_null_constraint_to_released_at_column_on_releases_table_spec.rb +++ b/spec/migrations/backfill_and_add_not_null_constraint_to_released_at_column_on_releases_table_spec.rb @@ -13,7 +13,7 @@ RSpec.describe BackfillAndAddNotNullConstraintToReleasedAtColumnOnReleasesTable it 'fills released_at with the value of created_at' do created_at_a = Time.zone.parse('2019-02-10T08:00:00Z') created_at_b = Time.zone.parse('2019-03-10T18:00:00Z') - namespace = namespaces.create(name: 'foo', path: 'foo') + namespace = namespaces.create!(name: 'foo', path: 'foo') project = projects.create!(namespace_id: namespace.id) release_a = releases.create!(project_id: project.id, created_at: created_at_a) release_b = releases.create!(project_id: project.id, created_at: created_at_b) diff --git a/spec/migrations/backfill_imported_snippet_repositories_spec.rb b/spec/migrations/backfill_imported_snippet_repositories_spec.rb index 998a691bf77..356551f176e 100644 --- a/spec/migrations/backfill_imported_snippet_repositories_spec.rb +++ b/spec/migrations/backfill_imported_snippet_repositories_spec.rb @@ -6,7 +6,7 @@ require Rails.root.join('db', 'post_migrate', '20200608072931_backfill_imported_ RSpec.describe BackfillImportedSnippetRepositories do let(:users) { table(:users) } let(:snippets) { table(:snippets) } - let(:user) { users.create(id: 1, email: 'user@example.com', projects_limit: 10, username: 'test', name: 'Test', state: 'active') } + let(:user) { users.create!(id: 1, email: 'user@example.com', projects_limit: 10, username: 'test', name: 'Test', state: 'active') } def create_snippet(id) params = { diff --git a/spec/migrations/backfill_releases_table_updated_at_and_add_not_null_constraints_to_timestamps_spec.rb b/spec/migrations/backfill_releases_table_updated_at_and_add_not_null_constraints_to_timestamps_spec.rb index 4c3517bc574..22c93d37816 100644 --- a/spec/migrations/backfill_releases_table_updated_at_and_add_not_null_constraints_to_timestamps_spec.rb +++ b/spec/migrations/backfill_releases_table_updated_at_and_add_not_null_constraints_to_timestamps_spec.rb @@ -13,7 +13,7 @@ RSpec.describe BackfillReleasesTableUpdatedAtAndAddNotNullConstraintsToTimestamp it 'fills null updated_at rows with the value of created_at' do created_at_a = Time.zone.parse('2014-03-11T04:30:00Z') created_at_b = Time.zone.parse('2019-09-10T12:00:00Z') - namespace = namespaces.create(name: 'foo', path: 'foo') + namespace = namespaces.create!(name: 'foo', path: 'foo') project = projects.create!(namespace_id: namespace.id) release_a = releases.create!(project_id: project.id, released_at: Time.zone.parse('2014-12-10T06:00:00Z'), @@ -36,7 +36,7 @@ RSpec.describe BackfillReleasesTableUpdatedAtAndAddNotNullConstraintsToTimestamp created_at_a = Time.zone.parse('2014-03-11T04:30:00Z') updated_at_a = Time.zone.parse('2015-01-16T10:00:00Z') created_at_b = Time.zone.parse('2019-09-10T12:00:00Z') - namespace = namespaces.create(name: 'foo', path: 'foo') + namespace = namespaces.create!(name: 'foo', path: 'foo') project = projects.create!(namespace_id: namespace.id) release_a = releases.create!(project_id: project.id, released_at: Time.zone.parse('2014-12-10T06:00:00Z'), diff --git a/spec/migrations/backfill_snippet_repositories_spec.rb b/spec/migrations/backfill_snippet_repositories_spec.rb index 6d417669ad6..b176b8d49ec 100644 --- a/spec/migrations/backfill_snippet_repositories_spec.rb +++ b/spec/migrations/backfill_snippet_repositories_spec.rb @@ -6,7 +6,7 @@ require Rails.root.join('db', 'post_migrate', '20200420094444_backfill_snippet_r RSpec.describe BackfillSnippetRepositories do let(:users) { table(:users) } let(:snippets) { table(:snippets) } - let(:user) { users.create(id: 1, email: 'user@example.com', projects_limit: 10, username: 'test', name: 'Test', state: 'active') } + let(:user) { users.create!(id: 1, email: 'user@example.com', projects_limit: 10, username: 'test', name: 'Test', state: 'active') } def create_snippet(id) params = { diff --git a/spec/migrations/encrypt_plaintext_attributes_on_application_settings_spec.rb b/spec/migrations/encrypt_plaintext_attributes_on_application_settings_spec.rb index ff5aa81b5b5..7cd3646d107 100644 --- a/spec/migrations/encrypt_plaintext_attributes_on_application_settings_spec.rb +++ b/spec/migrations/encrypt_plaintext_attributes_on_application_settings_spec.rb @@ -19,7 +19,7 @@ RSpec.describe EncryptPlaintextAttributesOnApplicationSettings do describe '#up' do it 'encrypts token and saves it' do - application_setting = application_settings.create + application_setting = application_settings.create! application_setting.update_columns( plaintext_attributes.each_with_object({}) do |plaintext_attribute, attributes| attributes[plaintext_attribute] = plaintext @@ -39,7 +39,7 @@ RSpec.describe EncryptPlaintextAttributesOnApplicationSettings do describe '#down' do it 'decrypts encrypted token and saves it' do - application_setting = application_settings.create( + application_setting = application_settings.create!( plaintext_attributes.each_with_object({}) do |plaintext_attribute, attributes| attributes[plaintext_attribute] = plaintext end diff --git a/spec/migrations/enqueue_reset_merge_status_second_run_spec.rb b/spec/migrations/enqueue_reset_merge_status_second_run_spec.rb index d4189326366..2bbc67c4db3 100644 --- a/spec/migrations/enqueue_reset_merge_status_second_run_spec.rb +++ b/spec/migrations/enqueue_reset_merge_status_second_run_spec.rb @@ -6,8 +6,8 @@ require Rails.root.join('db', 'post_migrate', '20190620112608_enqueue_reset_merg RSpec.describe EnqueueResetMergeStatusSecondRun do let(:namespaces) { table(:namespaces) } let(:projects) { table(:projects) } - let(:namespace) { namespaces.create(name: 'gitlab', path: 'gitlab-org') } - let(:project) { projects.create(namespace_id: namespace.id, name: 'foo') } + let(:namespace) { namespaces.create!(name: 'gitlab', path: 'gitlab-org') } + let(:project) { projects.create!(namespace_id: namespace.id, name: 'foo') } let(:merge_requests) { table(:merge_requests) } def create_merge_request(id, extra_params = {}) diff --git a/spec/migrations/enqueue_reset_merge_status_spec.rb b/spec/migrations/enqueue_reset_merge_status_spec.rb index c581293ddcd..0843bbacd5f 100644 --- a/spec/migrations/enqueue_reset_merge_status_spec.rb +++ b/spec/migrations/enqueue_reset_merge_status_spec.rb @@ -6,8 +6,8 @@ require Rails.root.join('db', 'post_migrate', '20190528180441_enqueue_reset_merg RSpec.describe EnqueueResetMergeStatus do let(:namespaces) { table(:namespaces) } let(:projects) { table(:projects) } - let(:namespace) { namespaces.create(name: 'gitlab', path: 'gitlab-org') } - let(:project) { projects.create(namespace_id: namespace.id, name: 'foo') } + let(:namespace) { namespaces.create!(name: 'gitlab', path: 'gitlab-org') } + let(:project) { projects.create!(namespace_id: namespace.id, name: 'foo') } let(:merge_requests) { table(:merge_requests) } def create_merge_request(id, extra_params = {}) diff --git a/spec/migrations/fill_file_store_lfs_objects_spec.rb b/spec/migrations/fill_file_store_lfs_objects_spec.rb index 2a610e5311b..23063cc9cd0 100644 --- a/spec/migrations/fill_file_store_lfs_objects_spec.rb +++ b/spec/migrations/fill_file_store_lfs_objects_spec.rb @@ -9,7 +9,7 @@ RSpec.describe FillFileStoreLfsObjects do context 'when file_store is nil' do it 'updates file_store to local' do - lfs_objects.create(oid: oid, size: 1062, file_store: nil) + lfs_objects.create!(oid: oid, size: 1062, file_store: nil) lfs_object = lfs_objects.find_by(oid: oid) expect { migrate! }.to change { lfs_object.reload.file_store }.from(nil).to(1) @@ -18,7 +18,7 @@ RSpec.describe FillFileStoreLfsObjects do context 'when file_store is set to local' do it 'does not update file_store' do - lfs_objects.create(oid: oid, size: 1062, file_store: 1) + lfs_objects.create!(oid: oid, size: 1062, file_store: 1) lfs_object = lfs_objects.find_by(oid: oid) expect { migrate! }.not_to change { lfs_object.reload.file_store } @@ -27,7 +27,7 @@ RSpec.describe FillFileStoreLfsObjects do context 'when file_store is set to object storage' do it 'does not update file_store' do - lfs_objects.create(oid: oid, size: 1062, file_store: 2) + lfs_objects.create!(oid: oid, size: 1062, file_store: 2) lfs_object = lfs_objects.find_by(oid: oid) expect { migrate! }.not_to change { lfs_object.reload.file_store } diff --git a/spec/migrations/fill_store_uploads_spec.rb b/spec/migrations/fill_store_uploads_spec.rb index 60eaf982c57..bcb5d45e1c0 100644 --- a/spec/migrations/fill_store_uploads_spec.rb +++ b/spec/migrations/fill_store_uploads_spec.rb @@ -9,7 +9,7 @@ RSpec.describe FillStoreUploads do context 'when store is nil' do it 'updates store to local' do - uploads.create(size: 100.kilobytes, + uploads.create!(size: 100.kilobytes, uploader: 'AvatarUploader', path: path, store: nil) @@ -22,7 +22,7 @@ RSpec.describe FillStoreUploads do context 'when store is set to local' do it 'does not update store' do - uploads.create(size: 100.kilobytes, + uploads.create!(size: 100.kilobytes, uploader: 'AvatarUploader', path: path, store: 1) @@ -35,7 +35,7 @@ RSpec.describe FillStoreUploads do context 'when store is set to object storage' do it 'does not update store' do - uploads.create(size: 100.kilobytes, + uploads.create!(size: 100.kilobytes, uploader: 'AvatarUploader', path: path, store: 2) diff --git a/spec/migrations/fix_null_type_labels_spec.rb b/spec/migrations/fix_null_type_labels_spec.rb index fadc2a5d29e..b3fc0e30687 100644 --- a/spec/migrations/fix_null_type_labels_spec.rb +++ b/spec/migrations/fix_null_type_labels_spec.rb @@ -10,14 +10,14 @@ RSpec.describe FixNullTypeLabels do let(:labels) { table(:labels) } before do - group = namespaces.create(name: 'labels-test-project', path: 'labels-test-project', type: 'Group') + group = namespaces.create!(name: 'labels-test-project', path: 'labels-test-project', type: 'Group') project = projects.create!(namespace_id: group.id, name: 'labels-test-group', path: 'labels-test-group') - @template_label = labels.create(title: 'template', template: true) - @project_label = labels.create(title: 'project label', project_id: project.id, type: 'ProjectLabel') - @group_label = labels.create(title: 'group_label', group_id: group.id, type: 'GroupLabel') - @broken_label_1 = labels.create(title: 'broken 1', project_id: project.id) - @broken_label_2 = labels.create(title: 'broken 2', project_id: project.id) + @template_label = labels.create!(title: 'template', template: true) + @project_label = labels.create!(title: 'project label', project_id: project.id, type: 'ProjectLabel') + @group_label = labels.create!(title: 'group_label', group_id: group.id, type: 'GroupLabel') + @broken_label_1 = labels.create!(title: 'broken 1', project_id: project.id) + @broken_label_2 = labels.create!(title: 'broken 2', project_id: project.id) end describe '#up' do diff --git a/spec/migrations/fix_pool_repository_source_project_id_spec.rb b/spec/migrations/fix_pool_repository_source_project_id_spec.rb index 67a75b893ef..3413cef3c8b 100644 --- a/spec/migrations/fix_pool_repository_source_project_id_spec.rb +++ b/spec/migrations/fix_pool_repository_source_project_id_spec.rb @@ -13,11 +13,11 @@ RSpec.describe FixPoolRepositorySourceProjectId do # gitaly is a project with a pool repository that has a source_project_id gitaly = projects.create!(name: 'gitaly', path: 'gitlab-org/gitaly', namespace_id: 1) - pool_repository = pool_repositories.create(shard_id: shard.id, source_project_id: gitaly.id) + pool_repository = pool_repositories.create!(shard_id: shard.id, source_project_id: gitaly.id) gitaly.update_column(:pool_repository_id, pool_repository.id) # gitlab is a project with a pool repository that's missing a source_project_id - pool_repository_without_source_project = pool_repositories.create(shard_id: shard.id, source_project_id: nil) + pool_repository_without_source_project = pool_repositories.create!(shard_id: shard.id, source_project_id: nil) gitlab = projects.create!(name: 'gitlab', path: 'gitlab-org/gitlab-ce', namespace_id: 1, pool_repository_id: pool_repository_without_source_project.id) projects.create!(name: 'gitlab-fork-1', path: 'my-org-1/gitlab-ce', namespace_id: 1, pool_repository_id: pool_repository_without_source_project.id) diff --git a/spec/migrations/fix_projects_without_project_feature_spec.rb b/spec/migrations/fix_projects_without_project_feature_spec.rb index 1ec67c07ba3..696c9e86384 100644 --- a/spec/migrations/fix_projects_without_project_feature_spec.rb +++ b/spec/migrations/fix_projects_without_project_feature_spec.rb @@ -4,13 +4,13 @@ require 'spec_helper' require Rails.root.join('db', 'post_migrate', '20200127111840_fix_projects_without_project_feature.rb') RSpec.describe FixProjectsWithoutProjectFeature do - let(:namespace) { table(:namespaces).create(name: 'gitlab', path: 'gitlab-org') } + let(:namespace) { table(:namespaces).create!(name: 'gitlab', path: 'gitlab-org') } let!(:projects) do [ - table(:projects).create(namespace_id: namespace.id, name: 'foo 1'), - table(:projects).create(namespace_id: namespace.id, name: 'foo 2'), - table(:projects).create(namespace_id: namespace.id, name: 'foo 3') + table(:projects).create!(namespace_id: namespace.id, name: 'foo 1'), + table(:projects).create!(namespace_id: namespace.id, name: 'foo 2'), + table(:projects).create!(namespace_id: namespace.id, name: 'foo 3') ] end diff --git a/spec/migrations/fix_projects_without_prometheus_services_spec.rb b/spec/migrations/fix_projects_without_prometheus_services_spec.rb index a4504ab6773..987350847ca 100644 --- a/spec/migrations/fix_projects_without_prometheus_services_spec.rb +++ b/spec/migrations/fix_projects_without_prometheus_services_spec.rb @@ -4,13 +4,13 @@ require 'spec_helper' require Rails.root.join('db', 'post_migrate', '20200220115023_fix_projects_without_prometheus_service.rb') RSpec.describe FixProjectsWithoutPrometheusService, :migration do - let(:namespace) { table(:namespaces).create(name: 'gitlab', path: 'gitlab-org') } + let(:namespace) { table(:namespaces).create!(name: 'gitlab', path: 'gitlab-org') } let!(:projects) do [ - table(:projects).create(namespace_id: namespace.id, name: 'foo 1'), - table(:projects).create(namespace_id: namespace.id, name: 'foo 2'), - table(:projects).create(namespace_id: namespace.id, name: 'foo 3') + table(:projects).create!(namespace_id: namespace.id, name: 'foo 1'), + table(:projects).create!(namespace_id: namespace.id, name: 'foo 2'), + table(:projects).create!(namespace_id: namespace.id, name: 'foo 3') ] end diff --git a/spec/migrations/fix_wrong_pages_access_level_spec.rb b/spec/migrations/fix_wrong_pages_access_level_spec.rb index 80787e0f115..310076f2e0a 100644 --- a/spec/migrations/fix_wrong_pages_access_level_spec.rb +++ b/spec/migrations/fix_wrong_pages_access_level_spec.rb @@ -17,7 +17,7 @@ RSpec.describe FixWrongPagesAccessLevel, :sidekiq_might_not_need_inline, schema: let(:features_table) { table(:project_features) } let(:subgroup) do - root_group = namespaces_table.create(path: "group", name: "group") + root_group = namespaces_table.create!(path: "group", name: "group") namespaces_table.create!(path: "subgroup", name: "group", parent_id: root_group.id) end diff --git a/spec/migrations/insert_project_hooks_plan_limits_spec.rb b/spec/migrations/insert_project_hooks_plan_limits_spec.rb index 09fae160a6f..f29d72168bc 100644 --- a/spec/migrations/insert_project_hooks_plan_limits_spec.rb +++ b/spec/migrations/insert_project_hooks_plan_limits_spec.rb @@ -9,11 +9,11 @@ RSpec.describe InsertProjectHooksPlanLimits do let(:plan_limits) { table(:plan_limits) } before do - plans.create(id: 34, name: 'free') - plans.create(id: 2, name: 'bronze') - plans.create(id: 3, name: 'silver') - plans.create(id: 4, name: 'gold') - plan_limits.create(plan_id: 34, ci_active_jobs: 5) + plans.create!(id: 34, name: 'free') + plans.create!(id: 2, name: 'bronze') + plans.create!(id: 3, name: 'silver') + plans.create!(id: 4, name: 'gold') + plan_limits.create!(plan_id: 34, ci_active_jobs: 5) end context 'when on Gitlab.com' do diff --git a/spec/migrations/migrate_auto_dev_ops_domain_to_cluster_domain_spec.rb b/spec/migrations/migrate_auto_dev_ops_domain_to_cluster_domain_spec.rb index d0abc777326..c7c846c7ef3 100644 --- a/spec/migrations/migrate_auto_dev_ops_domain_to_cluster_domain_spec.rb +++ b/spec/migrations/migrate_auto_dev_ops_domain_to_cluster_domain_spec.rb @@ -80,7 +80,7 @@ RSpec.describe MigrateAutoDevOpsDomainToClusterDomain do cluster_projects.each do |cluster_project| specific_domain = "#{cluster_project.id}-#{domain}" if domain - project_auto_devops_table.create( + project_auto_devops_table.create!( project_id: cluster_project.project_id, enabled: true, domain: specific_domain diff --git a/spec/migrations/move_limits_from_plans_spec.rb b/spec/migrations/move_limits_from_plans_spec.rb index a7a7d540ed3..c65fc439dd6 100644 --- a/spec/migrations/move_limits_from_plans_spec.rb +++ b/spec/migrations/move_limits_from_plans_spec.rb @@ -7,11 +7,11 @@ RSpec.describe MoveLimitsFromPlans do let(:plans) { table(:plans) } let(:plan_limits) { table(:plan_limits) } - let!(:gold_plan) { plans.create(name: 'gold', title: 'Gold', active_pipelines_limit: 20, pipeline_size_limit: 21, active_jobs_limit: 22) } - let!(:silver_plan) { plans.create(name: 'silver', title: 'Silver', active_pipelines_limit: 30, pipeline_size_limit: 31, active_jobs_limit: 32) } - let!(:bronze_plan) { plans.create(name: 'bronze', title: 'Bronze', active_pipelines_limit: 40, pipeline_size_limit: 41, active_jobs_limit: 42) } - let!(:free_plan) { plans.create(name: 'free', title: 'Free', active_pipelines_limit: 50, pipeline_size_limit: 51, active_jobs_limit: 52) } - let!(:other_plan) { plans.create(name: 'other', title: 'Other', active_pipelines_limit: nil, pipeline_size_limit: nil, active_jobs_limit: 0) } + let!(:gold_plan) { plans.create!(name: 'gold', title: 'Gold', active_pipelines_limit: 20, pipeline_size_limit: 21, active_jobs_limit: 22) } + let!(:silver_plan) { plans.create!(name: 'silver', title: 'Silver', active_pipelines_limit: 30, pipeline_size_limit: 31, active_jobs_limit: 32) } + let!(:bronze_plan) { plans.create!(name: 'bronze', title: 'Bronze', active_pipelines_limit: 40, pipeline_size_limit: 41, active_jobs_limit: 42) } + let!(:free_plan) { plans.create!(name: 'free', title: 'Free', active_pipelines_limit: 50, pipeline_size_limit: 51, active_jobs_limit: 52) } + let!(:other_plan) { plans.create!(name: 'other', title: 'Other', active_pipelines_limit: nil, pipeline_size_limit: nil, active_jobs_limit: 0) } describe 'migrate' do it 'populates plan_limits from all the records in plans' do diff --git a/spec/migrations/populate_project_statistics_packages_size_spec.rb b/spec/migrations/populate_project_statistics_packages_size_spec.rb index 9024406c614..6c838e83c56 100644 --- a/spec/migrations/populate_project_statistics_packages_size_spec.rb +++ b/spec/migrations/populate_project_statistics_packages_size_spec.rb @@ -16,7 +16,7 @@ RSpec.describe PopulateProjectStatisticsPackagesSize do let(:artifacts_size) { 4.terabytes } let(:storage_size) { repo_size + lfs_size + artifacts_size } - let(:namespace) { namespaces.create(name: 'foo', path: 'foo') } + let(:namespace) { namespaces.create!(name: 'foo', path: 'foo') } let(:package) { packages.create!(project_id: project.id, name: 'a package', package_type: 1) } let(:project) { projects.create!(namespace_id: namespace.id) } diff --git a/spec/migrations/schedule_link_lfs_objects_projects_spec.rb b/spec/migrations/schedule_link_lfs_objects_projects_spec.rb index 04ca18de91f..2384c5d5ce7 100644 --- a/spec/migrations/schedule_link_lfs_objects_projects_spec.rb +++ b/spec/migrations/schedule_link_lfs_objects_projects_spec.rb @@ -11,42 +11,42 @@ RSpec.describe ScheduleLinkLfsObjectsProjects, :migration, :sidekiq do let(:lfs_objects) { table(:lfs_objects) } let(:lfs_objects_projects) { table(:lfs_objects_projects) } - let(:namespace) { namespaces.create(name: 'GitLab', path: 'gitlab') } + let(:namespace) { namespaces.create!(name: 'GitLab', path: 'gitlab') } - let(:fork_network) { fork_networks.create(root_project_id: source_project.id) } - let(:another_fork_network) { fork_networks.create(root_project_id: another_source_project.id) } + let(:fork_network) { fork_networks.create!(root_project_id: source_project.id) } + let(:another_fork_network) { fork_networks.create!(root_project_id: another_source_project.id) } - let(:source_project) { projects.create(namespace_id: namespace.id) } - let(:another_source_project) { projects.create(namespace_id: namespace.id) } - let(:project) { projects.create(namespace_id: namespace.id) } - let(:another_project) { projects.create(namespace_id: namespace.id) } + let(:source_project) { projects.create!(namespace_id: namespace.id) } + let(:another_source_project) { projects.create!(namespace_id: namespace.id) } + let(:project) { projects.create!(namespace_id: namespace.id) } + let(:another_project) { projects.create!(namespace_id: namespace.id) } - let(:lfs_object) { lfs_objects.create(oid: 'abc123', size: 100) } - let(:another_lfs_object) { lfs_objects.create(oid: 'def456', size: 200) } + let(:lfs_object) { lfs_objects.create!(oid: 'abc123', size: 100) } + let(:another_lfs_object) { lfs_objects.create!(oid: 'def456', size: 200) } let!(:source_project_lop_1) do - lfs_objects_projects.create( + lfs_objects_projects.create!( lfs_object_id: lfs_object.id, project_id: source_project.id ) end let!(:source_project_lop_2) do - lfs_objects_projects.create( + lfs_objects_projects.create!( lfs_object_id: another_lfs_object.id, project_id: source_project.id ) end let!(:another_source_project_lop_1) do - lfs_objects_projects.create( + lfs_objects_projects.create!( lfs_object_id: lfs_object.id, project_id: another_source_project.id ) end let!(:another_source_project_lop_2) do - lfs_objects_projects.create( + lfs_objects_projects.create!( lfs_object_id: another_lfs_object.id, project_id: another_source_project.id ) @@ -56,10 +56,10 @@ RSpec.describe ScheduleLinkLfsObjectsProjects, :migration, :sidekiq do stub_const("#{described_class.name}::BATCH_SIZE", 2) # Create links between projects - fork_network_members.create(fork_network_id: fork_network.id, project_id: source_project.id, forked_from_project_id: nil) - fork_network_members.create(fork_network_id: fork_network.id, project_id: project.id, forked_from_project_id: source_project.id) - fork_network_members.create(fork_network_id: another_fork_network.id, project_id: another_source_project.id, forked_from_project_id: nil) - fork_network_members.create(fork_network_id: another_fork_network.id, project_id: another_project.id, forked_from_project_id: another_fork_network.root_project_id) + fork_network_members.create!(fork_network_id: fork_network.id, project_id: source_project.id, forked_from_project_id: nil) + fork_network_members.create!(fork_network_id: fork_network.id, project_id: project.id, forked_from_project_id: source_project.id) + fork_network_members.create!(fork_network_id: another_fork_network.id, project_id: another_source_project.id, forked_from_project_id: nil) + fork_network_members.create!(fork_network_id: another_fork_network.id, project_id: another_project.id, forked_from_project_id: another_fork_network.root_project_id) end it 'schedules background migration to link LFS objects' do diff --git a/spec/migrations/schedule_populate_merge_request_assignees_table_spec.rb b/spec/migrations/schedule_populate_merge_request_assignees_table_spec.rb index 93185b330c7..1f44df82ad0 100644 --- a/spec/migrations/schedule_populate_merge_request_assignees_table_spec.rb +++ b/spec/migrations/schedule_populate_merge_request_assignees_table_spec.rb @@ -6,8 +6,8 @@ require Rails.root.join('db', 'post_migrate', '20190322132835_schedule_populate_ RSpec.describe SchedulePopulateMergeRequestAssigneesTable do let(:namespaces) { table(:namespaces) } let(:projects) { table(:projects) } - let(:namespace) { namespaces.create(name: 'gitlab', path: 'gitlab-org') } - let(:project) { projects.create(namespace_id: namespace.id, name: 'foo') } + let(:namespace) { namespaces.create!(name: 'gitlab', path: 'gitlab-org') } + let(:project) { projects.create!(namespace_id: namespace.id, name: 'foo') } let(:merge_requests) { table(:merge_requests) } def create_merge_request(id) diff --git a/spec/migrations/seed_repository_storages_weighted_spec.rb b/spec/migrations/seed_repository_storages_weighted_spec.rb index fb077a3e345..d2fb1f7a014 100644 --- a/spec/migrations/seed_repository_storages_weighted_spec.rb +++ b/spec/migrations/seed_repository_storages_weighted_spec.rb @@ -17,7 +17,7 @@ RSpec.describe SeedRepositoryStoragesWeighted do allow(Gitlab.config.repositories).to receive(:storages).and_return(storages) end - let(:application_setting) { application_settings.create } + let(:application_setting) { application_settings.create! } let(:repository_storages) { ["foo"] } it 'correctly schedules background migrations' do |