Commit 496c247d authored by Rémy Coutable's avatar Rémy Coutable

Use non_existing_record_id/non_existing_record_iid in ee/spec/

This makes the strategy to get a non-existing-record-id consistent
accross the specs.
Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent bac450f2
...@@ -28,7 +28,7 @@ describe Boards::IssuesController do ...@@ -28,7 +28,7 @@ describe Boards::IssuesController do
context 'with invalid board id' do context 'with invalid board id' do
it 'returns a not found 404 response' do it 'returns a not found 404 response' do
list_issues user: user, board: 999, list: list2 list_issues user: user, board: non_existing_record_id, list: list2
expect(response).to have_gitlab_http_status(:not_found) expect(response).to have_gitlab_http_status(:not_found)
end end
...@@ -109,7 +109,7 @@ describe Boards::IssuesController do ...@@ -109,7 +109,7 @@ describe Boards::IssuesController do
context 'with invalid list id' do context 'with invalid list id' do
it 'returns a not found 404 response' do it 'returns a not found 404 response' do
list_issues user: user, board: board, list: 999 list_issues user: user, board: board, list: non_existing_record_id
expect(response).to have_gitlab_http_status(:not_found) expect(response).to have_gitlab_http_status(:not_found)
end end
...@@ -226,7 +226,7 @@ describe Boards::IssuesController do ...@@ -226,7 +226,7 @@ describe Boards::IssuesController do
context 'with invalid board id' do context 'with invalid board id' do
it 'returns a not found 404 response' do it 'returns a not found 404 response' do
create_issue user: user, board: 999, list: list1, title: 'New issue' create_issue user: user, board: non_existing_record_id, list: list1, title: 'New issue'
expect(response).to have_gitlab_http_status(:not_found) expect(response).to have_gitlab_http_status(:not_found)
end end
...@@ -234,7 +234,7 @@ describe Boards::IssuesController do ...@@ -234,7 +234,7 @@ describe Boards::IssuesController do
context 'with invalid list id' do context 'with invalid list id' do
it 'returns a not found 404 response' do it 'returns a not found 404 response' do
create_issue user: user, board: board, list: 999, title: 'New issue' create_issue user: user, board: board, list: non_existing_record_id, title: 'New issue'
expect(response).to have_gitlab_http_status(:not_found) expect(response).to have_gitlab_http_status(:not_found)
end end
...@@ -286,13 +286,13 @@ describe Boards::IssuesController do ...@@ -286,13 +286,13 @@ describe Boards::IssuesController do
end end
it 'returns a not found 404 response for invalid board id' do it 'returns a not found 404 response for invalid board id' do
move user: user, board: 999, issue: issue, from_list_id: list1.id, to_list_id: list2.id move user: user, board: non_existing_record_id, issue: issue, from_list_id: list1.id, to_list_id: list2.id
expect(response).to have_gitlab_http_status(:not_found) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'returns a not found 404 response for invalid issue id' do it 'returns a not found 404 response for invalid issue id' do
move user: user, board: board, issue: double(id: 999), from_list_id: list1.id, to_list_id: list2.id move user: user, board: board, issue: double(id: non_existing_record_id), from_list_id: list1.id, to_list_id: list2.id
expect(response).to have_gitlab_http_status(:not_found) expect(response).to have_gitlab_http_status(:not_found)
end end
......
...@@ -489,7 +489,7 @@ describe Boards::ListsController do ...@@ -489,7 +489,7 @@ describe Boards::ListsController do
context 'with invalid list id' do context 'with invalid list id' do
it 'returns a not found 404 response' do it 'returns a not found 404 response' do
move user: user, board: board, list: 999, position: 1 move user: user, board: board, list: non_existing_record_id, position: 1
expect(response).to have_gitlab_http_status(:not_found) expect(response).to have_gitlab_http_status(:not_found)
end end
...@@ -533,7 +533,7 @@ describe Boards::ListsController do ...@@ -533,7 +533,7 @@ describe Boards::ListsController do
context 'with invalid list id' do context 'with invalid list id' do
it 'returns a not found 404 response' do it 'returns a not found 404 response' do
remove_board_list user: user, board: board, list: 999 remove_board_list user: user, board: board, list: non_existing_record_id
expect(response).to have_gitlab_http_status(:not_found) expect(response).to have_gitlab_http_status(:not_found)
end end
......
...@@ -125,7 +125,7 @@ describe Projects::JobsController do ...@@ -125,7 +125,7 @@ describe Projects::JobsController do
end end
context 'and invalid id' do context 'and invalid id' do
let(:extra_params) { { id: 1234 } } let(:extra_params) { { id: non_existing_record_id } }
it 'returns 404' do it 'returns 404' do
make_request make_request
......
...@@ -206,7 +206,7 @@ describe Groups::EpicIssuesController do ...@@ -206,7 +206,7 @@ describe Groups::EpicIssuesController do
end end
context 'when user does not have permissions to admin the epic' do context 'when user does not have permissions to admin the epic' do
it 'returns status 404' do it 'returns status 403' do
subject subject
expect(response).to have_gitlab_http_status(:forbidden) expect(response).to have_gitlab_http_status(:forbidden)
...@@ -233,9 +233,11 @@ describe Groups::EpicIssuesController do ...@@ -233,9 +233,11 @@ describe Groups::EpicIssuesController do
context 'when the epic_issue record does not exists' do context 'when the epic_issue record does not exists' do
it 'returns status 404' do it 'returns status 404' do
delete :destroy, params: { group_id: group, epic_id: epic.to_param, id: 9999 } group.add_developer(user)
expect(response).to have_gitlab_http_status(:forbidden) delete :destroy, params: { group_id: group, epic_id: epic.to_param, id: non_existing_record_id }
expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
......
...@@ -155,7 +155,7 @@ describe Oauth::GeoAuthController, :geo do ...@@ -155,7 +155,7 @@ describe Oauth::GeoAuthController, :geo do
before do before do
allow_any_instance_of(Gitlab::Geo::Oauth::Session).to receive(:get_token).and_return('token') allow_any_instance_of(Gitlab::Geo::Oauth::Session).to receive(:get_token).and_return('token')
allow_any_instance_of(Gitlab::Geo::Oauth::Session).to receive(:authenticate).and_return(id: 999999) allow_any_instance_of(Gitlab::Geo::Oauth::Session).to receive(:authenticate).and_return(id: non_existing_record_id)
end end
it 'handles non-existent local user error' do it 'handles non-existent local user error' do
......
...@@ -170,7 +170,7 @@ describe Projects::BoardsController do ...@@ -170,7 +170,7 @@ describe Projects::BoardsController do
context 'with invalid board id' do context 'with invalid board id' do
it 'returns a not found 404 response' do it 'returns a not found 404 response' do
update_board 999, name: nil update_board non_existing_record_id, name: nil
expect(response).to have_gitlab_http_status(:not_found) expect(response).to have_gitlab_http_status(:not_found)
end end
...@@ -219,7 +219,7 @@ describe Projects::BoardsController do ...@@ -219,7 +219,7 @@ describe Projects::BoardsController do
context 'with invalid board id' do context 'with invalid board id' do
it 'returns a not found 404 response' do it 'returns a not found 404 response' do
remove_board board: 999 remove_board board: non_existing_record_id
expect(response).to have_gitlab_http_status(:not_found) expect(response).to have_gitlab_http_status(:not_found)
end end
......
...@@ -268,7 +268,7 @@ describe SubscriptionsController do ...@@ -268,7 +268,7 @@ describe SubscriptionsController do
context 'when selecting a non existing group' do context 'when selecting a non existing group' do
let(:params) do let(:params) do
{ {
selected_group: 999, selected_group: non_existing_record_id,
customer: { country: 'NL' }, customer: { country: 'NL' },
subscription: { plan_id: 'x', quantity: 1 } subscription: { plan_id: 'x', quantity: 1 }
} }
......
...@@ -57,7 +57,7 @@ describe 'PackageFiles' do ...@@ -57,7 +57,7 @@ describe 'PackageFiles' do
end end
it 'gives 404 when no package file exist' do it 'gives 404 when no package file exist' do
visit download_project_package_file_path(project, '9999') visit download_project_package_file_path(project, non_existing_record_id)
expect(status_code).to eq(404) expect(status_code).to eq(404)
end end
......
...@@ -289,12 +289,12 @@ describe Geo::JobArtifactRegistryFinder, :geo_fdw do ...@@ -289,12 +289,12 @@ describe Geo::JobArtifactRegistryFinder, :geo_fdw do
context 'unused tracked IDs' do context 'unused tracked IDs' do
context 'with an orphaned registry' do context 'with an orphaned registry' do
let!(:orphaned) { create(:geo_job_artifact_registry, artifact_id: 1234567) } let!(:orphaned) { create(:geo_job_artifact_registry, artifact_id: non_existing_record_id) }
it 'includes tracked IDs that do not exist in the model table' do it 'includes tracked IDs that do not exist in the model table' do
_, unused_tracked_ids = subject.find_registry_differences(1234567..1234567) _, unused_tracked_ids = subject.find_registry_differences(non_existing_record_id..non_existing_record_id)
expect(unused_tracked_ids).to match_array([1234567]) expect(unused_tracked_ids).to match_array([non_existing_record_id])
end end
it 'excludes IDs outside the ID range' do it 'excludes IDs outside the ID range' do
......
...@@ -340,14 +340,14 @@ describe Geo::LfsObjectRegistryFinder, :geo_fdw do ...@@ -340,14 +340,14 @@ describe Geo::LfsObjectRegistryFinder, :geo_fdw do
context 'unused tracked IDs' do context 'unused tracked IDs' do
context 'with an orphaned registry' do context 'with an orphaned registry' do
let!(:orphaned) { create(:geo_lfs_object_registry, lfs_object_id: 1234567) } let!(:orphaned) { create(:geo_lfs_object_registry, lfs_object_id: non_existing_record_id) }
it 'includes tracked IDs that do not exist in the model table' do it 'includes tracked IDs that do not exist in the model table' do
range = 1234567..1234567 range = non_existing_record_id..non_existing_record_id
_, unused_tracked_ids = subject.find_registry_differences(range) _, unused_tracked_ids = subject.find_registry_differences(range)
expect(unused_tracked_ids).to match_array([1234567]) expect(unused_tracked_ids).to match_array([non_existing_record_id])
end end
it 'excludes IDs outside the ID range' do it 'excludes IDs outside the ID range' do
......
...@@ -65,8 +65,8 @@ describe Banzai::Filter::EpicReferenceFilter do ...@@ -65,8 +65,8 @@ describe Banzai::Filter::EpicReferenceFilter do
expect(link.attr('data-original')).to eq(reference) expect(link.attr('data-original')).to eq(reference)
end end
it 'ignores invalid epic IDs' do it 'ignores invalid epic IIDs' do
text = "Check &9999" text = "Check &#{non_existing_record_iid}"
expect(doc(text).to_s).to eq(ERB::Util.html_escape_once(text)) expect(doc(text).to_s).to eq(ERB::Util.html_escape_once(text))
end end
...@@ -100,8 +100,8 @@ describe Banzai::Filter::EpicReferenceFilter do ...@@ -100,8 +100,8 @@ describe Banzai::Filter::EpicReferenceFilter do
expect(doc.css('a').first.attr('class')).to eq('gfm gfm-epic has-tooltip') expect(doc.css('a').first.attr('class')).to eq('gfm gfm-epic has-tooltip')
end end
it 'ignores invalid epic IDs' do it 'ignores invalid epic IIDs' do
text = "Check &amp;9999" text = "Check &amp;#{non_existing_record_iid}"
expect(doc(text).to_s).to eq(ERB::Util.html_escape_once(text)) expect(doc(text).to_s).to eq(ERB::Util.html_escape_once(text))
end end
......
...@@ -67,7 +67,7 @@ describe Banzai::ReferenceParser::EpicParser do ...@@ -67,7 +67,7 @@ describe Banzai::ReferenceParser::EpicParser do
context 'when epic with given ID does not exist' do context 'when epic with given ID does not exist' do
it 'returns an empty Array' do it 'returns an empty Array' do
expect(subject.referenced_by([link(9999)])).to be_empty expect(subject.referenced_by([link(non_existing_record_id)])).to be_empty
end end
end end
end end
......
...@@ -70,7 +70,7 @@ describe EE::Gitlab::Checks::PushRules::CommitCheck do ...@@ -70,7 +70,7 @@ describe EE::Gitlab::Checks::PushRules::CommitCheck do
context 'with private commit email' do context 'with private commit email' do
it 'returns error if private commit email was not associated to a user' do it 'returns error if private commit email was not associated to a user' do
user_email = "#{User.maximum(:id).next}-foo@#{::Gitlab::CurrentSettings.current_application_settings.commit_email_hostname}" user_email = "#{non_existing_record_id}-foo@#{::Gitlab::CurrentSettings.current_application_settings.commit_email_hostname}"
allow_any_instance_of(Commit).to receive(:author_email).and_return(user_email) allow_any_instance_of(Commit).to receive(:author_email).and_return(user_email)
...@@ -185,7 +185,7 @@ describe EE::Gitlab::Checks::PushRules::CommitCheck do ...@@ -185,7 +185,7 @@ describe EE::Gitlab::Checks::PushRules::CommitCheck do
end end
it 'raises an error when using an unknown private commit email' do it 'raises an error when using an unknown private commit email' do
user_email = "#{User.maximum(:id).next}-foobar@users.noreply.gitlab.com" user_email = "#{non_existing_record_id}-foobar@users.noreply.gitlab.com"
allow_any_instance_of(Commit).to receive(:committer_email).and_return(user_email) allow_any_instance_of(Commit).to receive(:committer_email).and_return(user_email)
......
...@@ -75,7 +75,7 @@ describe Gitlab::BackgroundMigration::UserMentions::CreateResourceUserMention do ...@@ -75,7 +75,7 @@ describe Gitlab::BackgroundMigration::UserMentions::CreateResourceUserMention do
# this not does not have actual mentions # this not does not have actual mentions
let!(:note4) { notes.create!(noteable_id: epic.id, noteable_type: 'Epic', author_id: author.id, note: 'note3 for an email@somesite.com and some other rando @ ref' ) } let!(:note4) { notes.create!(noteable_id: epic.id, noteable_type: 'Epic', author_id: author.id, note: 'note3 for an email@somesite.com and some other rando @ ref' ) }
# this not points to an innexistent noteable record in desigs table # this not points to an innexistent noteable record in desigs table
let!(:note5) { notes.create!(noteable_id: epics.maximum(:id) + 10, noteable_type: 'Epic', author_id: author.id, note: description_mentions, project_id: project.id) } let!(:note5) { notes.create!(noteable_id: non_existing_record_id, noteable_type: 'Epic', author_id: author.id, note: description_mentions, project_id: project.id) }
it_behaves_like 'resource notes mentions migration', MigrateEpicNotesMentionsToDb, Epic it_behaves_like 'resource notes mentions migration', MigrateEpicNotesMentionsToDb, Epic
end end
...@@ -96,7 +96,7 @@ describe Gitlab::BackgroundMigration::UserMentions::CreateResourceUserMention do ...@@ -96,7 +96,7 @@ describe Gitlab::BackgroundMigration::UserMentions::CreateResourceUserMention do
# this not does not have actual mentions # this not does not have actual mentions
let!(:note4) { notes.create!(noteable_id: design.id, noteable_type: 'DesignManagement::Design', project_id: project.id, author_id: author.id, note: 'note3 for an email@somesite.com and some other rando @ ref' ) } let!(:note4) { notes.create!(noteable_id: design.id, noteable_type: 'DesignManagement::Design', project_id: project.id, author_id: author.id, note: 'note3 for an email@somesite.com and some other rando @ ref' ) }
# this not points to an innexistent noteable record in desigs table # this not points to an innexistent noteable record in desigs table
let!(:note5) { notes.create!(noteable_id: designs.maximum(:id) + 10, noteable_type: 'DesignManagement::Design', project_id: project.id, author_id: author.id, note: description_mentions) } let!(:note5) { notes.create!(noteable_id: non_existing_record_id, noteable_type: 'DesignManagement::Design', project_id: project.id, author_id: author.id, note: description_mentions) }
let(:user_mentions) { design_user_mentions } let(:user_mentions) { design_user_mentions }
let(:resource) { design } let(:resource) { design }
......
...@@ -75,7 +75,7 @@ describe Gitlab::Geo::GitPushHttp, :geo, :use_clean_rails_memory_store_caching d ...@@ -75,7 +75,7 @@ describe Gitlab::Geo::GitPushHttp, :geo, :use_clean_rails_memory_store_caching d
context 'when the GeoNode does not exist' do context 'when the GeoNode does not exist' do
it 'returns nil' do it 'returns nil' do
Rails.cache.write(cache_key, 9999998, expires_in: described_class::EXPIRES_IN) Rails.cache.write(cache_key, non_existing_record_id, expires_in: described_class::EXPIRES_IN)
expect(subject.fetch_referrer_node).to be_nil expect(subject.fetch_referrer_node).to be_nil
end end
......
...@@ -120,6 +120,6 @@ describe Gitlab::ImportExport::Group::RelationFactory do ...@@ -120,6 +120,6 @@ describe Gitlab::ImportExport::Group::RelationFactory do
end end
def random_id def random_id
rand(1000..10000) rand(10_000..100_000)
end end
end end
...@@ -19,7 +19,7 @@ describe Gitlab::ReferenceExtractor do ...@@ -19,7 +19,7 @@ describe Gitlab::ReferenceExtractor do
@e1 = create(:epic, group: group) @e1 = create(:epic, group: group)
@e2 = create(:epic, group: create(:group, :private)) @e2 = create(:epic, group: create(:group, :private))
text = "#{@e0.to_reference(group, full: true)}, &999, #{@e1.to_reference(group, full: true)}, #{@e2.to_reference(group, full: true)}" text = "#{@e0.to_reference(group, full: true)}, &#{non_existing_record_iid}, #{@e1.to_reference(group, full: true)}, #{@e2.to_reference(group, full: true)}"
subject.analyze(text, { group: group }) subject.analyze(text, { group: group })
......
...@@ -25,7 +25,7 @@ describe MigrateDesignNotesMentionsToDb, :sidekiq do ...@@ -25,7 +25,7 @@ describe MigrateDesignNotesMentionsToDb, :sidekiq do
let!(:resource4) { notes.create!(note: 'note3 for @root to check', noteable_id: design.id, noteable_type: 'DesignManagement::Design') } let!(:resource4) { notes.create!(note: 'note3 for @root to check', noteable_id: design.id, noteable_type: 'DesignManagement::Design') }
let!(:user_mention) { design_user_mentions.create!(design_id: design.id, note_id: resource4.id, mentioned_users_ids: [1]) } let!(:user_mention) { design_user_mentions.create!(design_id: design.id, note_id: resource4.id, mentioned_users_ids: [1]) }
# this note points to an innexistent noteable record # this note points to an innexistent noteable record
let!(:resource5) { notes.create!(note: 'note3 for @root to check', noteable_id: designs.maximum(:id) + 10, noteable_type: 'DesignManagement::Design') } let!(:resource5) { notes.create!(note: 'note3 for @root to check', noteable_id: non_existing_record_id, noteable_type: 'DesignManagement::Design') }
before do before do
stub_const("#{described_class.name}::BATCH_SIZE", 1) stub_const("#{described_class.name}::BATCH_SIZE", 1)
......
...@@ -24,7 +24,7 @@ describe MigrateEpicNotesMentionsToDb, :migration do ...@@ -24,7 +24,7 @@ describe MigrateEpicNotesMentionsToDb, :migration do
let!(:resource4) { notes.create!(note: 'note3 for @root to check', noteable_id: epic.id, noteable_type: 'Epic') } let!(:resource4) { notes.create!(note: 'note3 for @root to check', noteable_id: epic.id, noteable_type: 'Epic') }
let!(:user_mention) { epic_user_mentions.create!(epic_id: epic.id, note_id: resource4.id, mentioned_users_ids: [1]) } let!(:user_mention) { epic_user_mentions.create!(epic_id: epic.id, note_id: resource4.id, mentioned_users_ids: [1]) }
# this note points to an inexistent noteable record # this note points to an inexistent noteable record
let!(:resource5) { notes.create!(note: 'note3 for @root to check', noteable_id: epics.maximum(:id) + 10, noteable_type: 'Epic') } let!(:resource5) { notes.create!(note: 'note3 for @root to check', noteable_id: non_existing_record_id, noteable_type: 'Epic') }
it_behaves_like 'schedules resource mentions migration', Epic, true it_behaves_like 'schedules resource mentions migration', Epic, true
end end
...@@ -49,7 +49,7 @@ RSpec.describe AuditEvent, type: :model do ...@@ -49,7 +49,7 @@ RSpec.describe AuditEvent, type: :model do
end end
context 'when user does not exists anymore' do context 'when user does not exists anymore' do
subject(:event) { described_class.new(author_id: 99999) } subject(:event) { described_class.new(author_id: non_existing_record_id) }
context 'when details contains author_name' do context 'when details contains author_name' do
it 'returns author_name' do it 'returns author_name' do
...@@ -89,7 +89,7 @@ RSpec.describe AuditEvent, type: :model do ...@@ -89,7 +89,7 @@ RSpec.describe AuditEvent, type: :model do
end end
context 'when entity does not exist' do context 'when entity does not exist' do
subject(:event) { described_class.new(entity_id: 99999, entity_type: 'User') } subject(:event) { described_class.new(entity_id: non_existing_record_id, entity_type: 'User') }
it 'returns nil' do it 'returns nil' do
expect(event.entity).to be_blank expect(event.entity).to be_blank
......
...@@ -13,7 +13,7 @@ describe API::GeoNodes, :request_store, :geo_fdw, :prometheus, api: true do ...@@ -13,7 +13,7 @@ describe API::GeoNodes, :request_store, :geo_fdw, :prometheus, api: true do
let!(:primary) { create(:geo_node, :primary) } let!(:primary) { create(:geo_node, :primary) }
let!(:secondary) { create(:geo_node) } let!(:secondary) { create(:geo_node) }
let!(:secondary_status) { create(:geo_node_status, :healthy, geo_node: secondary) } let!(:secondary_status) { create(:geo_node_status, :healthy, geo_node: secondary) }
let(:unexisting_node_id) { GeoNode.maximum(:id).to_i.succ } let(:unexisting_node_id) { non_existing_record_id }
let(:group_to_sync) { create(:group) } let(:group_to_sync) { create(:group) }
describe 'POST /geo_nodes' do describe 'POST /geo_nodes' do
......
...@@ -248,8 +248,7 @@ describe API::Groups do ...@@ -248,8 +248,7 @@ describe API::Groups do
end end
it 'returns 404 for a non existing group' do it 'returns 404 for a non existing group' do
non_existent_group_id = Group.maximum(:id).to_i + 1 ldap_sync(non_existing_record_id, user, :disable!)
ldap_sync(non_existent_group_id, user, :disable!)
expect(response).to have_gitlab_http_status(:not_found) expect(response).to have_gitlab_http_status(:not_found)
end end
......
...@@ -65,7 +65,7 @@ describe API::IssueLinks do ...@@ -65,7 +65,7 @@ describe API::IssueLinks do
target_project = create(:project, :public) target_project = create(:project, :public)
post api("/projects/#{project.id}/issues/#{issue.iid}/links", user), post api("/projects/#{project.id}/issues/#{issue.iid}/links", user),
params: { target_project_id: target_project.id, target_issue_iid: 999 } params: { target_project_id: target_project.id, target_issue_iid: non_existing_record_iid }
expect(response).to have_gitlab_http_status(:not_found) expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 Not found') expect(json_response['message']).to eq('404 Not found')
...@@ -170,7 +170,7 @@ describe API::IssueLinks do ...@@ -170,7 +170,7 @@ describe API::IssueLinks do
context 'issue link not found' do context 'issue link not found' do
it 'returns 404' do it 'returns 404' do
delete api("/projects/#{project.id}/issues/#{issue.iid}/links/999", user) delete api("/projects/#{project.id}/issues/#{issue.iid}/links/#{non_existing_record_id}", user)
expect(response).to have_gitlab_http_status(:not_found) expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 Not found') expect(json_response['message']).to eq('404 Not found')
......
...@@ -107,7 +107,7 @@ describe API::ManagedLicenses do ...@@ -107,7 +107,7 @@ describe API::ManagedLicenses do
end end
it 'responds with 404 Not Found if requesting non-existing managed license' do it 'responds with 404 Not Found if requesting non-existing managed license' do
get api("/projects/#{project.id}/managed_licenses/1234512345", dev_user) get api("/projects/#{project.id}/managed_licenses/#{non_existing_record_id}", dev_user)
expect(response).to have_gitlab_http_status(:not_found) expect(response).to have_gitlab_http_status(:not_found)
end end
...@@ -232,7 +232,7 @@ describe API::ManagedLicenses do ...@@ -232,7 +232,7 @@ describe API::ManagedLicenses do
end end
it 'responds with 404 Not Found if requesting non-existing managed license' do it 'responds with 404 Not Found if requesting non-existing managed license' do
patch api("/projects/#{project.id}/managed_licenses/1234512345", maintainer_user) patch api("/projects/#{project.id}/managed_licenses/#{non_existing_record_id}", maintainer_user)
expect(response).to have_gitlab_http_status(:not_found) expect(response).to have_gitlab_http_status(:not_found)
end end
...@@ -275,7 +275,7 @@ describe API::ManagedLicenses do ...@@ -275,7 +275,7 @@ describe API::ManagedLicenses do
it 'responds with 404 Not Found if requesting non-existing managed license' do it 'responds with 404 Not Found if requesting non-existing managed license' do
expect do expect do
delete api("/projects/#{project.id}/managed_licenses/1234512345", maintainer_user) delete api("/projects/#{project.id}/managed_licenses/#{non_existing_record_id}", maintainer_user)
expect(response).to have_gitlab_http_status(:not_found) expect(response).to have_gitlab_http_status(:not_found)
end.not_to change {project.software_license_policies.count} end.not_to change {project.software_license_policies.count}
......
...@@ -145,7 +145,7 @@ describe API::Namespaces do ...@@ -145,7 +145,7 @@ describe API::Namespaces do
context 'when namespace not found' do context 'when namespace not found' do
it 'returns 404' do it 'returns 404' do
put api("/namespaces/12345", admin), params: { plan: 'silver' } put api("/namespaces/#{non_existing_record_id}", admin), params: { plan: 'silver' }
expect(response).to have_gitlab_http_status(:not_found) expect(response).to have_gitlab_http_status(:not_found)
expect(json_response).to eq('message' => '404 Namespace Not Found') expect(json_response).to eq('message' => '404 Namespace Not Found')
......
...@@ -138,7 +138,9 @@ describe API::Todos do ...@@ -138,7 +138,9 @@ describe API::Todos do
end end
it 'returns 404 if the epic is not found' do it 'returns 404 if the epic is not found' do
post api("/groups/#{group.id}/epics/9999/todo", user) group.add_developer(user)
post api("/groups/#{group.id}/epics/#{non_existing_record_iid}/todo", user)
expect(response).to have_gitlab_http_status(:forbidden) expect(response).to have_gitlab_http_status(:forbidden)
end end
......
...@@ -67,7 +67,7 @@ describe Projects::IssueLinksController do ...@@ -67,7 +67,7 @@ describe Projects::IssueLinksController do
context 'when failing service result' do context 'when failing service result' do
let(:user_role) { :developer } let(:user_role) { :developer }
let(:issuable_references) { ['#999'] } let(:issuable_references) { ["##{non_existing_record_iid}"] }
it 'returns failure JSON' do it 'returns failure JSON' do
post namespace_project_issue_links_path(issue_links_params(issuable_references: issuable_references)) post namespace_project_issue_links_path(issue_links_params(issuable_references: issuable_references))
......
...@@ -32,7 +32,7 @@ describe IssueLinks::CreateService do ...@@ -32,7 +32,7 @@ describe IssueLinks::CreateService do
context 'when Issue not found' do context 'when Issue not found' do
let(:params) do let(:params) do
{ issuable_references: ['#999'] } { issuable_references: ["##{non_existing_record_iid}"] }
end end
it 'returns error' do it 'returns error' do
......
...@@ -874,7 +874,7 @@ describe QuickActions::InterpretService do ...@@ -874,7 +874,7 @@ describe QuickActions::InterpretService do
context 'relate a non-existing issue' do context 'relate a non-existing issue' do
let(:issues_related) { [] } let(:issues_related) { [] }
let(:content) { "/relate imaginary#1234" } let(:content) { "/relate imaginary##{non_existing_record_iid}" }
it_behaves_like 'relate command' it_behaves_like 'relate command'
end end
......
...@@ -127,7 +127,7 @@ describe Geo::FileDownloadDispatchWorker, :geo, :geo_fdw, :use_sql_query_cache_f ...@@ -127,7 +127,7 @@ describe Geo::FileDownloadDispatchWorker, :geo, :geo_fdw, :use_sql_query_cache_f
end end
context 'with a failed file' do context 'with a failed file' do
let(:failed_registry) { create(:geo_upload_registry, :avatar, :failed, file_id: 999) } let(:failed_registry) { create(:geo_upload_registry, :avatar, :failed, file_id: non_existing_record_id) }
it 'does not stall backfill' do it 'does not stall backfill' do
unsynced_registry = create(:geo_upload_registry, :avatar, :with_file, :never_synced) unsynced_registry = create(:geo_upload_registry, :avatar, :with_file, :never_synced)
...@@ -147,7 +147,7 @@ describe Geo::FileDownloadDispatchWorker, :geo, :geo_fdw, :use_sql_query_cache_f ...@@ -147,7 +147,7 @@ describe Geo::FileDownloadDispatchWorker, :geo, :geo_fdw, :use_sql_query_cache_f
end end
it 'does not retry failed files when retry_at is tomorrow' do it 'does not retry failed files when retry_at is tomorrow' do
failed_registry = create(:geo_upload_registry, :avatar, :failed, file_id: 999, retry_at: Date.tomorrow) failed_registry = create(:geo_upload_registry, :avatar, :failed, file_id: non_existing_record_id, retry_at: Date.tomorrow)
expect(Geo::FileDownloadWorker).not_to receive(:perform_async).with('avatar', failed_registry.file_id) expect(Geo::FileDownloadWorker).not_to receive(:perform_async).with('avatar', failed_registry.file_id)
...@@ -155,7 +155,7 @@ describe Geo::FileDownloadDispatchWorker, :geo, :geo_fdw, :use_sql_query_cache_f ...@@ -155,7 +155,7 @@ describe Geo::FileDownloadDispatchWorker, :geo, :geo_fdw, :use_sql_query_cache_f
end end
it 'retries failed files when retry_at is in the past' do it 'retries failed files when retry_at is in the past' do
failed_registry = create(:geo_upload_registry, :avatar, :failed, file_id: 999, retry_at: Date.yesterday) failed_registry = create(:geo_upload_registry, :avatar, :failed, file_id: non_existing_record_id, retry_at: Date.yesterday)
expect(Geo::FileDownloadWorker).to receive(:perform_async).with('avatar', failed_registry.file_id) expect(Geo::FileDownloadWorker).to receive(:perform_async).with('avatar', failed_registry.file_id)
...@@ -234,7 +234,7 @@ describe Geo::FileDownloadDispatchWorker, :geo, :geo_fdw, :use_sql_query_cache_f ...@@ -234,7 +234,7 @@ describe Geo::FileDownloadDispatchWorker, :geo, :geo_fdw, :use_sql_query_cache_f
end end
context 'with a failed file' do context 'with a failed file' do
let(:failed_registry) { create(:geo_upload_registry, :avatar, :failed, file_id: 999) } let(:failed_registry) { create(:geo_upload_registry, :avatar, :failed, file_id: non_existing_record_id) }
it 'does not stall backfill' do it 'does not stall backfill' do
unsynced = create(:upload) unsynced = create(:upload)
...@@ -254,7 +254,7 @@ describe Geo::FileDownloadDispatchWorker, :geo, :geo_fdw, :use_sql_query_cache_f ...@@ -254,7 +254,7 @@ describe Geo::FileDownloadDispatchWorker, :geo, :geo_fdw, :use_sql_query_cache_f
end end
it 'does not retry failed files when retry_at is tomorrow' do it 'does not retry failed files when retry_at is tomorrow' do
failed_registry = create(:geo_upload_registry, :avatar, :failed, file_id: 999, retry_at: Date.tomorrow) failed_registry = create(:geo_upload_registry, :avatar, :failed, file_id: non_existing_record_id, retry_at: Date.tomorrow)
expect(Geo::FileDownloadWorker).not_to receive(:perform_async).with('avatar', failed_registry.file_id) expect(Geo::FileDownloadWorker).not_to receive(:perform_async).with('avatar', failed_registry.file_id)
...@@ -262,7 +262,7 @@ describe Geo::FileDownloadDispatchWorker, :geo, :geo_fdw, :use_sql_query_cache_f ...@@ -262,7 +262,7 @@ describe Geo::FileDownloadDispatchWorker, :geo, :geo_fdw, :use_sql_query_cache_f
end end
it 'retries failed files when retry_at is in the past' do it 'retries failed files when retry_at is in the past' do
failed_registry = create(:geo_upload_registry, :avatar, :failed, file_id: 999, retry_at: Date.yesterday) failed_registry = create(:geo_upload_registry, :avatar, :failed, file_id: non_existing_record_id, retry_at: Date.yesterday)
expect(Geo::FileDownloadWorker).to receive(:perform_async).with('avatar', failed_registry.file_id) expect(Geo::FileDownloadWorker).to receive(:perform_async).with('avatar', failed_registry.file_id)
......
...@@ -25,9 +25,9 @@ RSpec.describe Geo::ProjectSyncWorker do ...@@ -25,9 +25,9 @@ RSpec.describe Geo::ProjectSyncWorker do
context 'when project could not be found' do context 'when project could not be found' do
it 'logs an error and returns' do it 'logs an error and returns' do
expect(subject).to receive(:log_error).with("Couldn't find project, skipping syncing", project_id: 999) expect(subject).to receive(:log_error).with("Couldn't find project, skipping syncing", project_id: non_existing_record_id)
expect { subject.perform(999) }.not_to raise_error expect { subject.perform(non_existing_record_id) }.not_to raise_error
end end
end end
......
...@@ -53,7 +53,7 @@ describe JiraConnect::SyncBranchWorker do ...@@ -53,7 +53,7 @@ describe JiraConnect::SyncBranchWorker do
end end
context 'when project no longer exists' do context 'when project no longer exists' do
let(:project_id) { Project.maximum(:id).to_i + 1 } let(:project_id) { non_existing_record_id }
it 'does not call JiraConnect::SyncService' do it 'does not call JiraConnect::SyncService' do
expect(JiraConnect::SyncService).not_to receive(:new) expect(JiraConnect::SyncService).not_to receive(:new)
......
...@@ -18,7 +18,7 @@ describe JiraConnect::SyncMergeRequestWorker do ...@@ -18,7 +18,7 @@ describe JiraConnect::SyncMergeRequestWorker do
end end
context 'when MR no longer exists' do context 'when MR no longer exists' do
let(:merge_request_id) { MergeRequest.maximum(:id).to_i + 1 } let(:merge_request_id) { non_existing_record_id }
it 'does not call JiraConnect::SyncService' do it 'does not call JiraConnect::SyncService' do
expect(JiraConnect::SyncService).not_to receive(:new) expect(JiraConnect::SyncService).not_to receive(:new)
......
...@@ -60,7 +60,7 @@ describe IncidentManagement::ProcessPrometheusAlertWorker do ...@@ -60,7 +60,7 @@ describe IncidentManagement::ProcessPrometheusAlertWorker do
end end
context 'when project could not be found' do context 'when project could not be found' do
let(:non_existing_project_id) { (Project.maximum(:id) || 0) + 1 } let(:non_existing_project_id) { non_existing_record_id }
it 'does not create an issue' do it 'does not create an issue' do
expect { subject.perform(non_existing_project_id, alert_params) } expect { subject.perform(non_existing_project_id, alert_params) }
...@@ -75,7 +75,7 @@ describe IncidentManagement::ProcessPrometheusAlertWorker do ...@@ -75,7 +75,7 @@ describe IncidentManagement::ProcessPrometheusAlertWorker do
context 'when event could not be found' do context 'when event could not be found' do
before do before do
alert_params[:labels][:gitlab_alert_id] = (PrometheusAlertEvent.maximum(:id) || 0) + 1 alert_params[:labels][:gitlab_alert_id] = non_existing_record_id
end end
it 'does not create an issue' do it 'does not create an issue' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment