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
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-01 18:07:45 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-01 18:07:45 +0300
commit1219a9dce91f4edbc135dfc08299b4122b4825a8 (patch)
treee7d12a55d75a2d56e60d9527bef3724e3578866d /spec/support
parent1a0d6dbdc2ac3047f4953a359ef27ba6e26074ae (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/support')
-rw-r--r--spec/support/database_cleaner.rb4
-rw-r--r--spec/support/non_existing_records_helper.rb12
-rw-r--r--spec/support/shared_contexts/finders/issues_finder_shared_contexts.rb11
-rw-r--r--spec/support/shared_examples/finders/snippet_visibility_shared_examples.rb5
-rw-r--r--spec/support/shared_examples/lib/gitlab/import_export/project_tree_restorer_shared_examples.rb5
-rw-r--r--spec/support/shared_examples/models/mentionable_shared_examples.rb6
-rw-r--r--spec/support/shared_examples/requests/api/discussions_shared_examples.rb8
-rw-r--r--spec/support/shared_examples/requests/api/issuable_participants_examples.rb2
-rw-r--r--spec/support/shared_examples/requests/api/milestones_shared_examples.rb8
-rw-r--r--spec/support/shared_examples/requests/api/notes_shared_examples.rb8
-rw-r--r--spec/support/shared_examples/requests/api/resolvable_discussions_shared_examples.rb2
-rw-r--r--spec/support/shared_examples/requests/api/resource_label_events_api_shared_examples.rb4
12 files changed, 34 insertions, 41 deletions
diff --git a/spec/support/database_cleaner.rb b/spec/support/database_cleaner.rb
index aaf408f6143..f6339d7343c 100644
--- a/spec/support/database_cleaner.rb
+++ b/spec/support/database_cleaner.rb
@@ -11,10 +11,6 @@ RSpec.configure do |config|
DatabaseCleaner.clean_with(:truncation)
end
- config.append_after(:context) do
- delete_from_all_tables!
- end
-
config.append_after(:context, :migration) do
delete_from_all_tables!
diff --git a/spec/support/non_existing_records_helper.rb b/spec/support/non_existing_records_helper.rb
new file mode 100644
index 00000000000..1d4368c8ddf
--- /dev/null
+++ b/spec/support/non_existing_records_helper.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+module NonExistingRecordsHelpers
+ # Max value for PG `serial` type: https://www.postgresql.org/docs/12/datatype-numeric.html
+ ACTIVE_MODEL_INTEGER_MAX = 2147483647
+
+ def non_existing_record_id
+ ACTIVE_MODEL_INTEGER_MAX
+ end
+ alias_method :non_existing_record_iid, :non_existing_record_id
+ alias_method :non_existing_record_access_level, :non_existing_record_id
+end
diff --git a/spec/support/shared_contexts/finders/issues_finder_shared_contexts.rb b/spec/support/shared_contexts/finders/issues_finder_shared_contexts.rb
index fc62ae5a13f..9ffde54c84a 100644
--- a/spec/support/shared_contexts/finders/issues_finder_shared_contexts.rb
+++ b/spec/support/shared_contexts/finders/issues_finder_shared_contexts.rb
@@ -28,19 +28,10 @@ RSpec.shared_context 'IssuesFinder#execute context' do
let(:params) { {} }
let(:issues) { described_class.new(search_user, params.reverse_merge(scope: scope, state: 'opened')).execute }
- before(:context) do
+ before_all do
project1.add_maintainer(user)
project2.add_developer(user)
project2.add_developer(user2)
project3.add_developer(user)
-
- issue1
- issue2
- issue3
- issue4
-
- award_emoji1
- award_emoji2
- award_emoji3
end
end
diff --git a/spec/support/shared_examples/finders/snippet_visibility_shared_examples.rb b/spec/support/shared_examples/finders/snippet_visibility_shared_examples.rb
index 5bd2da03f3f..c802038c9da 100644
--- a/spec/support/shared_examples/finders/snippet_visibility_shared_examples.rb
+++ b/spec/support/shared_examples/finders/snippet_visibility_shared_examples.rb
@@ -3,11 +3,6 @@
RSpec.shared_examples 'snippet visibility' do
using RSpec::Parameterized::TableSyntax
- # Make sure no snippets exist prior to running the test matrix
- before(:context) do
- DatabaseCleaner.clean_with(:truncation)
- end
-
let_it_be(:author) { create(:user) }
let_it_be(:member) { create(:user) }
let_it_be(:external) { create(:user, :external) }
diff --git a/spec/support/shared_examples/lib/gitlab/import_export/project_tree_restorer_shared_examples.rb b/spec/support/shared_examples/lib/gitlab/import_export/project_tree_restorer_shared_examples.rb
index 0e43f686327..5f9316c1cde 100644
--- a/spec/support/shared_examples/lib/gitlab/import_export/project_tree_restorer_shared_examples.rb
+++ b/spec/support/shared_examples/lib/gitlab/import_export/project_tree_restorer_shared_examples.rb
@@ -38,10 +38,9 @@ RSpec.shared_examples 'restores project successfully' do |**results|
expect(project.external_pull_requests.size).to eq(results.fetch(:external_pull_requests, 0))
end
- # This test is quarantined because the use of magic number 999 causes failure on CI
- it 'does not set params that are excluded from import_export settings', quarantine: 'https://gitlab.com/gitlab-org/gitlab/issues/207932#note_293724442' do
+ it 'does not set params that are excluded from import_export settings' do
expect(project.import_type).to be_nil
- expect(project.creator_id).not_to eq 999
+ expect(project.creator_id).not_to eq non_existing_record_id
end
it 'records exact number of import failures' do
diff --git a/spec/support/shared_examples/models/mentionable_shared_examples.rb b/spec/support/shared_examples/models/mentionable_shared_examples.rb
index b6b131338cc..ba6aa4e1d89 100644
--- a/spec/support/shared_examples/models/mentionable_shared_examples.rb
+++ b/spec/support/shared_examples/models/mentionable_shared_examples.rb
@@ -287,9 +287,9 @@ RSpec.shared_examples 'load mentions from DB' do |mentionable_type|
before do
user_mention = note.send(:model_user_mention)
mention_ids = {
- mentioned_users_ids: user_mention.mentioned_users_ids.to_a << User.maximum(:id).to_i.succ,
- mentioned_projects_ids: user_mention.mentioned_projects_ids.to_a << Project.maximum(:id).to_i.succ,
- mentioned_groups_ids: user_mention.mentioned_groups_ids.to_a << Group.maximum(:id).to_i.succ
+ mentioned_users_ids: user_mention.mentioned_users_ids.to_a << non_existing_record_id,
+ mentioned_projects_ids: user_mention.mentioned_projects_ids.to_a << non_existing_record_id,
+ mentioned_groups_ids: user_mention.mentioned_groups_ids.to_a << non_existing_record_id
}
user_mention.update(mention_ids)
end
diff --git a/spec/support/shared_examples/requests/api/discussions_shared_examples.rb b/spec/support/shared_examples/requests/api/discussions_shared_examples.rb
index 939ea405724..6315c10b0c4 100644
--- a/spec/support/shared_examples/requests/api/discussions_shared_examples.rb
+++ b/spec/support/shared_examples/requests/api/discussions_shared_examples.rb
@@ -66,7 +66,7 @@ RSpec.shared_examples 'discussions API' do |parent_type, noteable_type, id_name,
end
it "returns a 404 error when noteable id not found" do
- get api("/#{parent_type}/#{parent.id}/#{noteable_type}/12345/discussions", user)
+ get api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{non_existing_record_iid}/discussions", user)
expect(response).to have_gitlab_http_status(:not_found)
end
@@ -90,7 +90,7 @@ RSpec.shared_examples 'discussions API' do |parent_type, noteable_type, id_name,
end
it "returns a 404 error if discussion not found" do
- get api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions/12345", user)
+ get api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions/#{non_existing_record_id}", user)
expect(response).to have_gitlab_http_status(:not_found)
end
@@ -248,7 +248,7 @@ RSpec.shared_examples 'discussions API' do |parent_type, noteable_type, id_name,
it 'returns a 404 error when note id not found' do
put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\
- "discussions/#{note.discussion_id}/notes/12345", user),
+ "discussions/#{note.discussion_id}/notes/#{non_existing_record_id}", user),
params: { body: 'Hello!' }
expect(response).to have_gitlab_http_status(:not_found)
@@ -276,7 +276,7 @@ RSpec.shared_examples 'discussions API' do |parent_type, noteable_type, id_name,
it 'returns a 404 error when note id not found' do
delete api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\
- "discussions/#{note.discussion_id}/notes/12345", user)
+ "discussions/#{note.discussion_id}/notes/#{non_existing_record_id}", user)
expect(response).to have_gitlab_http_status(:not_found)
end
diff --git a/spec/support/shared_examples/requests/api/issuable_participants_examples.rb b/spec/support/shared_examples/requests/api/issuable_participants_examples.rb
index e442b988349..673d7741017 100644
--- a/spec/support/shared_examples/requests/api/issuable_participants_examples.rb
+++ b/spec/support/shared_examples/requests/api/issuable_participants_examples.rb
@@ -18,7 +18,7 @@ RSpec.shared_examples 'issuable participants endpoint' do
end
it 'returns a 404 when iid does not exist' do
- get api("/projects/#{project.id}/#{area}/999/participants", user)
+ get api("/projects/#{project.id}/#{area}/#{non_existing_record_iid}/participants", user)
expect(response).to have_gitlab_http_status(:not_found)
end
diff --git a/spec/support/shared_examples/requests/api/milestones_shared_examples.rb b/spec/support/shared_examples/requests/api/milestones_shared_examples.rb
index 3afb26bc869..77b49b7caef 100644
--- a/spec/support/shared_examples/requests/api/milestones_shared_examples.rb
+++ b/spec/support/shared_examples/requests/api/milestones_shared_examples.rb
@@ -56,7 +56,7 @@ RSpec.shared_examples 'group and project milestones' do |route_definition|
end
it 'does not return any milestone if none found' do
- get api(route, user), params: { iids: [Milestone.maximum(:iid).succ] }
+ get api(route, user), params: { iids: [non_existing_record_iid] }
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to be_an Array
@@ -120,7 +120,7 @@ RSpec.shared_examples 'group and project milestones' do |route_definition|
end
it 'returns a 404 error if milestone id not found' do
- get api("#{route}/1234", user)
+ get api("#{route}/#{non_existing_record_id}", user)
expect(response).to have_gitlab_http_status(:not_found)
end
@@ -183,7 +183,7 @@ RSpec.shared_examples 'group and project milestones' do |route_definition|
end
it 'returns a 404 error if milestone id not found' do
- put api("#{route}/1234", user), params: { title: 'updated title' }
+ put api("#{route}/#{non_existing_record_id}", user), params: { title: 'updated title' }
expect(response).to have_gitlab_http_status(:not_found)
end
@@ -367,7 +367,7 @@ RSpec.shared_examples 'group and project milestones' do |route_definition|
end
it 'returns a 404 error if milestone id not found' do
- not_found_route = "#{route}/1234/merge_requests"
+ not_found_route = "#{route}/#{non_existing_record_id}/merge_requests"
get api(not_found_route, user)
diff --git a/spec/support/shared_examples/requests/api/notes_shared_examples.rb b/spec/support/shared_examples/requests/api/notes_shared_examples.rb
index 61ac9acb154..60ed61269df 100644
--- a/spec/support/shared_examples/requests/api/notes_shared_examples.rb
+++ b/spec/support/shared_examples/requests/api/notes_shared_examples.rb
@@ -97,7 +97,7 @@ RSpec.shared_examples 'noteable API' do |parent_type, noteable_type, id_name|
end
it "returns a 404 error when noteable id not found" do
- get api("/#{parent_type}/#{parent.id}/#{noteable_type}/12345/notes", user)
+ get api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{non_existing_record_id}/notes", user)
expect(response).to have_gitlab_http_status(:not_found)
end
@@ -120,7 +120,7 @@ RSpec.shared_examples 'noteable API' do |parent_type, noteable_type, id_name|
end
it "returns a 404 error if note not found" do
- get api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes/12345", user)
+ get api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes/#{non_existing_record_id}", user)
expect(response).to have_gitlab_http_status(:not_found)
end
@@ -274,7 +274,7 @@ RSpec.shared_examples 'noteable API' do |parent_type, noteable_type, id_name|
end
it 'returns a 404 error when note id not found' do
- put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes/12345", user),
+ put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes/#{non_existing_record_id}", user),
params: { body: 'Hello!' }
expect(response).to have_gitlab_http_status(:not_found)
@@ -301,7 +301,7 @@ RSpec.shared_examples 'noteable API' do |parent_type, noteable_type, id_name|
end
it 'returns a 404 error when note id not found' do
- delete api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes/12345", user)
+ delete api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes/#{non_existing_record_id}", user)
expect(response).to have_gitlab_http_status(:not_found)
end
diff --git a/spec/support/shared_examples/requests/api/resolvable_discussions_shared_examples.rb b/spec/support/shared_examples/requests/api/resolvable_discussions_shared_examples.rb
index 8d2a3f13d8e..5748e873fd4 100644
--- a/spec/support/shared_examples/requests/api/resolvable_discussions_shared_examples.rb
+++ b/spec/support/shared_examples/requests/api/resolvable_discussions_shared_examples.rb
@@ -66,7 +66,7 @@ RSpec.shared_examples 'resolvable discussions API' do |parent_type, noteable_typ
it 'returns a 404 error when note id not found' do
put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\
- "discussions/#{note.discussion_id}/notes/12345", user),
+ "discussions/#{note.discussion_id}/notes/#{non_existing_record_id}", user),
params: { body: 'Hello!' }
expect(response).to have_gitlab_http_status(:not_found)
diff --git a/spec/support/shared_examples/requests/api/resource_label_events_api_shared_examples.rb b/spec/support/shared_examples/requests/api/resource_label_events_api_shared_examples.rb
index 520c3ea8e47..f49f944f38d 100644
--- a/spec/support/shared_examples/requests/api/resource_label_events_api_shared_examples.rb
+++ b/spec/support/shared_examples/requests/api/resource_label_events_api_shared_examples.rb
@@ -15,7 +15,7 @@ RSpec.shared_examples 'resource_label_events API' do |parent_type, eventable_typ
end
it "returns a 404 error when eventable id not found" do
- get api("/#{parent_type}/#{parent.id}/#{eventable_type}/12345/resource_label_events", user)
+ get api("/#{parent_type}/#{parent.id}/#{eventable_type}/#{non_existing_record_id}/resource_label_events", user)
expect(response).to have_gitlab_http_status(:not_found)
end
@@ -74,7 +74,7 @@ RSpec.shared_examples 'resource_label_events API' do |parent_type, eventable_typ
end
it "returns a 404 error if resource label event not found" do
- get api("/#{parent_type}/#{parent.id}/#{eventable_type}/#{eventable[id_name]}/resource_label_events/12345", user)
+ get api("/#{parent_type}/#{parent.id}/#{eventable_type}/#{eventable[id_name]}/resource_label_events/#{non_existing_record_id}", user)
expect(response).to have_gitlab_http_status(:not_found)
end