diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-17 18:09:01 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-17 18:09:01 +0300 |
commit | b304a72312465ed4c0a568ee6a6ea5e97f705c9b (patch) | |
tree | a2f25dbea26c81e88b169c55a6275e3969323e82 /spec/requests | |
parent | b84eeb256c4a780d902faee1f99ca9a711b3214a (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/requests')
38 files changed, 189 insertions, 196 deletions
diff --git a/spec/requests/api/access_requests_spec.rb b/spec/requests/api/access_requests_spec.rb index 3bfca00776f..17f4cde5b8c 100644 --- a/spec/requests/api/access_requests_spec.rb +++ b/spec/requests/api/access_requests_spec.rb @@ -3,12 +3,12 @@ require 'spec_helper' describe API::AccessRequests do - set(:maintainer) { create(:user) } - set(:developer) { create(:user) } - set(:access_requester) { create(:user) } - set(:stranger) { create(:user) } + let_it_be(:maintainer) { create(:user) } + let_it_be(:developer) { create(:user) } + let_it_be(:access_requester) { create(:user) } + let_it_be(:stranger) { create(:user) } - set(:project) do + let_it_be(:project) do create(:project, :public, creator_id: maintainer.id, namespace: maintainer.namespace) do |project| project.add_developer(developer) project.add_maintainer(maintainer) @@ -16,7 +16,7 @@ describe API::AccessRequests do end end - set(:group) do + let_it_be(:group) do create(:group, :public) do |group| group.add_developer(developer) group.add_owner(maintainer) diff --git a/spec/requests/api/award_emoji_spec.rb b/spec/requests/api/award_emoji_spec.rb index 19a34314bb8..4a830f2b449 100644 --- a/spec/requests/api/award_emoji_spec.rb +++ b/spec/requests/api/award_emoji_spec.rb @@ -3,14 +3,13 @@ require 'spec_helper' describe API::AwardEmoji do - set(:user) { create(:user) } - set(:project) { create(:project) } - set(:issue) { create(:issue, project: project) } - set(:award_emoji) { create(:award_emoji, awardable: issue, user: user) } - let!(:merge_request) { create(:merge_request, source_project: project, target_project: project) } - let!(:downvote) { create(:award_emoji, :downvote, awardable: merge_request, user: user) } - - set(:note) { create(:note, project: project, noteable: issue) } + let_it_be(:user) { create(:user) } + let_it_be(:project) { create(:project) } + let_it_be(:issue) { create(:issue, project: project) } + let_it_be(:award_emoji) { create(:award_emoji, awardable: issue, user: user) } + let_it_be(:note) { create(:note, project: project, noteable: issue) } + let!(:merge_request) { create(:merge_request, source_project: project, target_project: project) } + let!(:downvote) { create(:award_emoji, :downvote, awardable: merge_request, user: user) } before do project.add_maintainer(user) diff --git a/spec/requests/api/boards_spec.rb b/spec/requests/api/boards_spec.rb index 510ef9d7d0a..f53bfedb49a 100644 --- a/spec/requests/api/boards_spec.rb +++ b/spec/requests/api/boards_spec.rb @@ -3,35 +3,35 @@ require 'spec_helper' describe API::Boards do - set(:user) { create(:user) } - set(:non_member) { create(:user) } - set(:guest) { create(:user) } - set(:admin) { create(:user, :admin) } - set(:board_parent) { create(:project, :public, creator_id: user.id, namespace: user.namespace ) } + let_it_be(:user) { create(:user) } + let_it_be(:non_member) { create(:user) } + let_it_be(:guest) { create(:user) } + let_it_be(:admin) { create(:user, :admin) } + let_it_be(:board_parent, reload: true) { create(:project, :public, creator_id: user.id, namespace: user.namespace ) } - set(:dev_label) do + let_it_be(:dev_label) do create(:label, title: 'Development', color: '#FFAABB', project: board_parent) end - set(:test_label) do + let_it_be(:test_label) do create(:label, title: 'Testing', color: '#FFAACC', project: board_parent) end - set(:ux_label) do + let_it_be(:ux_label) do create(:label, title: 'UX', color: '#FF0000', project: board_parent) end - set(:dev_list) do + let_it_be(:dev_list) do create(:list, label: dev_label, position: 1) end - set(:test_list) do + let_it_be(:test_list) do create(:list, label: test_label, position: 2) end - set(:milestone) { create(:milestone, project: board_parent) } - set(:board_label) { create(:label, project: board_parent) } - set(:board) { create(:board, project: board_parent, lists: [dev_list, test_list]) } + let_it_be(:milestone) { create(:milestone, project: board_parent) } + let_it_be(:board_label) { create(:label, project: board_parent) } + let_it_be(:board) { create(:board, project: board_parent, lists: [dev_list, test_list]) } it_behaves_like 'group and project boards', "/projects/:id/boards" @@ -66,11 +66,11 @@ describe API::Boards do end describe "POST /groups/:id/boards/lists" do - set(:group) { create(:group) } - set(:board_parent) { create(:group, parent: group ) } + let_it_be(:group) { create(:group) } + let_it_be(:board_parent) { create(:group, parent: group ) } let(:url) { "/groups/#{board_parent.id}/boards/#{board.id}/lists" } - set(:board) { create(:board, group: board_parent) } + let_it_be(:board) { create(:board, group: board_parent) } it 'creates a new board list for ancestor group labels' do group.add_developer(user) diff --git a/spec/requests/api/branches_spec.rb b/spec/requests/api/branches_spec.rb index d4deb049ea7..046ec40f218 100644 --- a/spec/requests/api/branches_spec.rb +++ b/spec/requests/api/branches_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe API::Branches do - set(:user) { create(:user) } + let_it_be(:user) { create(:user) } let(:project) { create(:project, :repository, creator: user, path: 'my.project') } let(:guest) { create(:user).tap { |u| project.add_guest(u) } } let(:branch_name) { 'feature' } diff --git a/spec/requests/api/broadcast_messages_spec.rb b/spec/requests/api/broadcast_messages_spec.rb index 163479226e3..7d71b83e147 100644 --- a/spec/requests/api/broadcast_messages_spec.rb +++ b/spec/requests/api/broadcast_messages_spec.rb @@ -3,9 +3,9 @@ require 'spec_helper' describe API::BroadcastMessages do - set(:user) { create(:user) } - set(:admin) { create(:admin) } - set(:message) { create(:broadcast_message) } + let_it_be(:user) { create(:user) } + let_it_be(:admin) { create(:admin) } + let_it_be(:message) { create(:broadcast_message) } describe 'GET /broadcast_messages' do it 'returns an Array of BroadcastMessages' do diff --git a/spec/requests/api/features_spec.rb b/spec/requests/api/features_spec.rb index dfd14f89dbf..d7b0bf881a6 100644 --- a/spec/requests/api/features_spec.rb +++ b/spec/requests/api/features_spec.rb @@ -3,8 +3,8 @@ require 'spec_helper' describe API::Features do - set(:user) { create(:user) } - set(:admin) { create(:admin) } + let_it_be(:user) { create(:user) } + let_it_be(:admin) { create(:admin) } before do Flipper.unregister_groups diff --git a/spec/requests/api/graphql/current_user_query_spec.rb b/spec/requests/api/graphql/current_user_query_spec.rb index 9db638ea59e..2b38b8e98ab 100644 --- a/spec/requests/api/graphql/current_user_query_spec.rb +++ b/spec/requests/api/graphql/current_user_query_spec.rb @@ -16,7 +16,7 @@ describe 'getting project information' do end context 'when there is a current_user' do - set(:current_user) { create(:user) } + let_it_be(:current_user) { create(:user) } it_behaves_like 'a working graphql query' diff --git a/spec/requests/api/graphql/gitlab_schema_spec.rb b/spec/requests/api/graphql/gitlab_schema_spec.rb index e10f0732852..8d020cd3a4e 100644 --- a/spec/requests/api/graphql/gitlab_schema_spec.rb +++ b/spec/requests/api/graphql/gitlab_schema_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' describe 'GitlabSchema configurations' do include GraphqlHelpers - set(:project) { create(:project) } + let_it_be(:project) { create(:project) } shared_examples 'imposing query limits' do describe 'timeouts' do diff --git a/spec/requests/api/graphql/mutations/award_emojis/add_spec.rb b/spec/requests/api/graphql/mutations/award_emojis/add_spec.rb index b24981873c8..3fdeccc84f9 100644 --- a/spec/requests/api/graphql/mutations/award_emojis/add_spec.rb +++ b/spec/requests/api/graphql/mutations/award_emojis/add_spec.rb @@ -5,9 +5,9 @@ require 'spec_helper' describe 'Adding an AwardEmoji' do include GraphqlHelpers - set(:current_user) { create(:user) } - set(:project) { create(:project) } - set(:awardable) { create(:note, project: project) } + let_it_be(:current_user) { create(:user) } + let_it_be(:project) { create(:project) } + let_it_be(:awardable) { create(:note, project: project) } let(:emoji_name) { 'thumbsup' } let(:mutation) do variables = { diff --git a/spec/requests/api/graphql/mutations/award_emojis/toggle_spec.rb b/spec/requests/api/graphql/mutations/award_emojis/toggle_spec.rb index 5e2c0e668a5..bc796b34db4 100644 --- a/spec/requests/api/graphql/mutations/award_emojis/toggle_spec.rb +++ b/spec/requests/api/graphql/mutations/award_emojis/toggle_spec.rb @@ -5,9 +5,9 @@ require 'spec_helper' describe 'Toggling an AwardEmoji' do include GraphqlHelpers - set(:current_user) { create(:user) } - set(:project) { create(:project) } - set(:awardable) { create(:note, project: project) } + let_it_be(:current_user) { create(:user) } + let_it_be(:project, reload: true) { create(:project) } + let_it_be(:awardable) { create(:note, project: project) } let(:emoji_name) { 'thumbsup' } let(:mutation) do variables = { diff --git a/spec/requests/api/graphql/mutations/notes/create/diff_note_spec.rb b/spec/requests/api/graphql/mutations/notes/create/diff_note_spec.rb index b04fcb9aece..4c535434faa 100644 --- a/spec/requests/api/graphql/mutations/notes/create/diff_note_spec.rb +++ b/spec/requests/api/graphql/mutations/notes/create/diff_note_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' describe 'Adding a DiffNote' do include GraphqlHelpers - set(:current_user) { create(:user) } + let_it_be(:current_user) { create(:user) } let(:noteable) { create(:merge_request, source_project: project, target_project: project) } let(:project) { create(:project, :repository) } let(:diff_refs) { noteable.diff_refs } diff --git a/spec/requests/api/graphql/mutations/notes/create/image_diff_note_spec.rb b/spec/requests/api/graphql/mutations/notes/create/image_diff_note_spec.rb index 3ba6c689024..0bba3e79434 100644 --- a/spec/requests/api/graphql/mutations/notes/create/image_diff_note_spec.rb +++ b/spec/requests/api/graphql/mutations/notes/create/image_diff_note_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' describe 'Adding an image DiffNote' do include GraphqlHelpers - set(:current_user) { create(:user) } + let_it_be(:current_user) { create(:user) } let(:noteable) { create(:merge_request, source_project: project, target_project: project) } let(:project) { create(:project, :repository) } let(:diff_refs) { noteable.diff_refs } diff --git a/spec/requests/api/graphql/mutations/notes/create/note_spec.rb b/spec/requests/api/graphql/mutations/notes/create/note_spec.rb index 14aaa430ac9..9a78d44245e 100644 --- a/spec/requests/api/graphql/mutations/notes/create/note_spec.rb +++ b/spec/requests/api/graphql/mutations/notes/create/note_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' describe 'Adding a Note' do include GraphqlHelpers - set(:current_user) { create(:user) } + let_it_be(:current_user) { create(:user) } let(:noteable) { create(:merge_request, source_project: project, target_project: project) } let(:project) { create(:project) } let(:discussion) { nil } diff --git a/spec/requests/api/graphql/tasks/task_completion_status_spec.rb b/spec/requests/api/graphql/tasks/task_completion_status_spec.rb index 566d0fe636a..188bfa8b924 100644 --- a/spec/requests/api/graphql/tasks/task_completion_status_spec.rb +++ b/spec/requests/api/graphql/tasks/task_completion_status_spec.rb @@ -9,8 +9,8 @@ describe 'getting task completion status information' do DESCRIPTION_1_DONE = '- [x] task 1\n- [ ] task 2' DESCRIPTION_2_DONE = '- [x] task 1\n- [x] task 2' - set(:user1) { create(:user) } - set(:project) { create(:project, :repository, :public) } + let_it_be(:user1) { create(:user) } + let_it_be(:project) { create(:project, :repository, :public) } let(:fields) do <<~QUERY diff --git a/spec/requests/api/group_boards_spec.rb b/spec/requests/api/group_boards_spec.rb index 232ec9aca32..d2d10f357fe 100644 --- a/spec/requests/api/group_boards_spec.rb +++ b/spec/requests/api/group_boards_spec.rb @@ -3,42 +3,42 @@ require 'spec_helper' describe API::GroupBoards do - set(:user) { create(:user) } - set(:non_member) { create(:user) } - set(:guest) { create(:user) } - set(:admin) { create(:user, :admin) } - set(:board_parent) { create(:group, :public) } + let_it_be(:user) { create(:user) } + let_it_be(:non_member) { create(:user) } + let_it_be(:guest) { create(:user) } + let_it_be(:admin) { create(:user, :admin) } + let_it_be(:board_parent) { create(:group, :public) } before do board_parent.add_owner(user) end - set(:project) { create(:project, :public, namespace: board_parent ) } + let_it_be(:project) { create(:project, :public, namespace: board_parent ) } - set(:dev_label) do + let_it_be(:dev_label) do create(:group_label, title: 'Development', color: '#FFAABB', group: board_parent) end - set(:test_label) do + let_it_be(:test_label) do create(:group_label, title: 'Testing', color: '#FFAACC', group: board_parent) end - set(:ux_label) do + let_it_be(:ux_label) do create(:group_label, title: 'UX', color: '#FF0000', group: board_parent) end - set(:dev_list) do + let_it_be(:dev_list) do create(:list, label: dev_label, position: 1) end - set(:test_list) do + let_it_be(:test_list) do create(:list, label: test_label, position: 2) end - set(:milestone) { create(:milestone, group: board_parent) } - set(:board_label) { create(:group_label, group: board_parent) } + let_it_be(:milestone) { create(:milestone, group: board_parent) } + let_it_be(:board_label) { create(:group_label, group: board_parent) } - set(:board) { create(:board, group: board_parent, lists: [dev_list, test_list]) } + let_it_be(:board) { create(:board, group: board_parent, lists: [dev_list, test_list]) } it_behaves_like 'group and project boards', "/groups/:id/boards", false diff --git a/spec/requests/api/issues/get_group_issues_spec.rb b/spec/requests/api/issues/get_group_issues_spec.rb index f2a1b335589..59e89a7f452 100644 --- a/spec/requests/api/issues/get_group_issues_spec.rb +++ b/spec/requests/api/issues/get_group_issues_spec.rb @@ -3,18 +3,16 @@ require 'spec_helper' describe API::Issues do - set(:user) { create(:user) } - let(:user2) { create(:user) } - let(:non_member) { create(:user) } - set(:guest) { create(:user) } - set(:author) { create(:author) } - set(:assignee) { create(:assignee) } - let(:admin) { create(:user, :admin) } - - let(:issue_title) { 'foo' } - let(:issue_description) { 'closed' } - - let(:no_milestone_title) { 'None' } + let_it_be(:user) { create(:user) } + let(:user2) { create(:user) } + let(:non_member) { create(:user) } + let_it_be(:guest) { create(:user) } + let_it_be(:author) { create(:author) } + let_it_be(:assignee) { create(:assignee) } + let(:admin) { create(:user, :admin) } + let(:issue_title) { 'foo' } + let(:issue_description) { 'closed' } + let(:no_milestone_title) { 'None' } let(:any_milestone_title) { 'Any' } before do diff --git a/spec/requests/api/issues/get_project_issues_spec.rb b/spec/requests/api/issues/get_project_issues_spec.rb index e031cc9b0c6..edd4ae85729 100644 --- a/spec/requests/api/issues/get_project_issues_spec.rb +++ b/spec/requests/api/issues/get_project_issues_spec.rb @@ -3,18 +3,18 @@ require 'spec_helper' describe API::Issues do - set(:user) { create(:user) } - set(:project) { create(:project, :public, :repository, creator_id: user.id, namespace: user.namespace) } - set(:private_mrs_project) do + let_it_be(:user) { create(:user) } + let_it_be(:project, reload: true) { create(:project, :public, :repository, creator_id: user.id, namespace: user.namespace) } + let_it_be(:private_mrs_project) do create(:project, :public, :repository, creator_id: user.id, namespace: user.namespace, merge_requests_access_level: ProjectFeature::PRIVATE) end - let(:user2) { create(:user) } - let(:non_member) { create(:user) } - set(:guest) { create(:user) } - set(:author) { create(:author) } - set(:assignee) { create(:assignee) } - let(:admin) { create(:user, :admin) } + let(:user2) { create(:user) } + let(:non_member) { create(:user) } + let_it_be(:guest) { create(:user) } + let_it_be(:author) { create(:author) } + let_it_be(:assignee) { create(:assignee) } + let(:admin) { create(:user, :admin) } let(:issue_title) { 'foo' } let(:issue_description) { 'closed' } let!(:closed_issue) do @@ -48,12 +48,12 @@ describe API::Issues do title: issue_title, description: issue_description end - set(:label) do + let_it_be(:label) do create(:label, title: 'label', color: '#FFAABB', project: project) end let!(:label_link) { create(:label_link, label: label, target: issue) } let(:milestone) { create(:milestone, title: '1.0.0', project: project) } - set(:empty_milestone) do + let_it_be(:empty_milestone) do create(:milestone, title: '2.0.0', project: project) end let!(:note) { create(:note_on_issue, author: user, project: project, noteable: issue) } diff --git a/spec/requests/api/issues/issues_spec.rb b/spec/requests/api/issues/issues_spec.rb index 19422d4ca39..45754736a2c 100644 --- a/spec/requests/api/issues/issues_spec.rb +++ b/spec/requests/api/issues/issues_spec.rb @@ -3,18 +3,18 @@ require 'spec_helper' describe API::Issues do - set(:user) { create(:user) } - set(:project) { create(:project, :public, :repository, creator_id: user.id, namespace: user.namespace) } - set(:private_mrs_project) do + let_it_be(:user) { create(:user) } + let_it_be(:project, reload: true) { create(:project, :public, :repository, creator_id: user.id, namespace: user.namespace) } + let_it_be(:private_mrs_project) do create(:project, :public, :repository, creator_id: user.id, namespace: user.namespace, merge_requests_access_level: ProjectFeature::PRIVATE) end - let(:user2) { create(:user) } - let(:non_member) { create(:user) } - set(:guest) { create(:user) } - set(:author) { create(:author) } - set(:assignee) { create(:assignee) } - let(:admin) { create(:user, :admin) } + let(:user2) { create(:user) } + let(:non_member) { create(:user) } + let_it_be(:guest) { create(:user) } + let_it_be(:author) { create(:author) } + let_it_be(:assignee) { create(:assignee) } + let(:admin) { create(:user, :admin) } let(:issue_title) { 'foo' } let(:issue_description) { 'closed' } let!(:closed_issue) do @@ -48,12 +48,12 @@ describe API::Issues do title: issue_title, description: issue_description end - set(:label) do + let_it_be(:label) do create(:label, title: 'label', color: '#FFAABB', project: project) end let!(:label_link) { create(:label_link, label: label, target: issue) } let(:milestone) { create(:milestone, title: '1.0.0', project: project) } - set(:empty_milestone) do + let_it_be(:empty_milestone) do create(:milestone, title: '2.0.0', project: project) end let!(:note) { create(:note_on_issue, author: user, project: project, noteable: issue) } diff --git a/spec/requests/api/issues/post_projects_issues_spec.rb b/spec/requests/api/issues/post_projects_issues_spec.rb index 341d0e8ae6b..782eda875af 100644 --- a/spec/requests/api/issues/post_projects_issues_spec.rb +++ b/spec/requests/api/issues/post_projects_issues_spec.rb @@ -3,17 +3,17 @@ require 'spec_helper' describe API::Issues do - set(:user) { create(:user) } - set(:project) do + let_it_be(:user) { create(:user) } + let_it_be(:project, reload: true) do create(:project, :public, creator_id: user.id, namespace: user.namespace) end - let(:user2) { create(:user) } - let(:non_member) { create(:user) } - set(:guest) { create(:user) } - set(:author) { create(:author) } - set(:assignee) { create(:assignee) } - let(:admin) { create(:user, :admin) } + let(:user2) { create(:user) } + let(:non_member) { create(:user) } + let_it_be(:guest) { create(:user) } + let_it_be(:author) { create(:author) } + let_it_be(:assignee) { create(:assignee) } + let(:admin) { create(:user, :admin) } let(:issue_title) { 'foo' } let(:issue_description) { 'closed' } let!(:closed_issue) do @@ -47,12 +47,12 @@ describe API::Issues do title: issue_title, description: issue_description end - set(:label) do + let_it_be(:label) do create(:label, title: 'label', color: '#FFAABB', project: project) end let!(:label_link) { create(:label_link, label: label, target: issue) } let(:milestone) { create(:milestone, title: '1.0.0', project: project) } - set(:empty_milestone) do + let_it_be(:empty_milestone) do create(:milestone, title: '2.0.0', project: project) end let!(:note) { create(:note_on_issue, author: user, project: project, noteable: issue) } diff --git a/spec/requests/api/issues/put_projects_issues_spec.rb b/spec/requests/api/issues/put_projects_issues_spec.rb index 8e78aca59b2..709520b6bdf 100644 --- a/spec/requests/api/issues/put_projects_issues_spec.rb +++ b/spec/requests/api/issues/put_projects_issues_spec.rb @@ -3,17 +3,17 @@ require 'spec_helper' describe API::Issues do - set(:user) { create(:user) } - set(:project) do + let_it_be(:user) { create(:user) } + let_it_be(:project, reload: true) do create(:project, :public, creator_id: user.id, namespace: user.namespace) end - let(:user2) { create(:user) } - let(:non_member) { create(:user) } - set(:guest) { create(:user) } - set(:author) { create(:author) } - set(:assignee) { create(:assignee) } - let(:admin) { create(:user, :admin) } + let(:user2) { create(:user) } + let(:non_member) { create(:user) } + let_it_be(:guest) { create(:user) } + let_it_be(:author) { create(:author) } + let_it_be(:assignee) { create(:assignee) } + let(:admin) { create(:user, :admin) } let(:issue_title) { 'foo' } let(:issue_description) { 'closed' } let!(:closed_issue) do @@ -47,12 +47,12 @@ describe API::Issues do title: issue_title, description: issue_description end - set(:label) do + let_it_be(:label) do create(:label, title: 'label', color: '#FFAABB', project: project) end let!(:label_link) { create(:label_link, label: label, target: issue) } let(:milestone) { create(:milestone, title: '1.0.0', project: project) } - set(:empty_milestone) do + let_it_be(:empty_milestone) do create(:milestone, title: '2.0.0', project: project) end let!(:note) { create(:note_on_issue, author: user, project: project, noteable: issue) } diff --git a/spec/requests/api/jobs_spec.rb b/spec/requests/api/jobs_spec.rb index 1e1099ebcb6..652be20f1e4 100644 --- a/spec/requests/api/jobs_spec.rb +++ b/spec/requests/api/jobs_spec.rb @@ -31,11 +31,11 @@ describe API::Jobs do end end - set(:project) do + let_it_be(:project, reload: true) do create(:project, :repository, public_builds: false) end - set(:pipeline) do + let_it_be(:pipeline, reload: true) do create(:ci_empty_pipeline, project: project, sha: project.commit.id, ref: project.default_branch) diff --git a/spec/requests/api/markdown_spec.rb b/spec/requests/api/markdown_spec.rb index 99263f2fc1e..8a1e1b05c9a 100644 --- a/spec/requests/api/markdown_spec.rb +++ b/spec/requests/api/markdown_spec.rb @@ -52,8 +52,8 @@ describe API::Markdown do end context "when arguments are valid" do - set(:project) { create(:project) } - set(:issue) { create(:issue, project: project) } + let_it_be(:project) { create(:project) } + let_it_be(:issue) { create(:issue, project: project) } let(:text) { ":tada: Hello world! :100: #{issue.to_reference}" } context "when not using gfm" do diff --git a/spec/requests/api/merge_requests_spec.rb b/spec/requests/api/merge_requests_spec.rb index 58190beb38a..862afd11b86 100644 --- a/spec/requests/api/merge_requests_spec.rb +++ b/spec/requests/api/merge_requests_spec.rb @@ -6,9 +6,9 @@ describe API::MergeRequests do include ProjectForksHelper let(:base_time) { Time.now } - set(:user) { create(:user) } - set(:user2) { create(:user) } - set(:admin) { create(:user, :admin) } + let_it_be(:user) { create(:user) } + let_it_be(:user2) { create(:user) } + let_it_be(:admin) { create(:user, :admin) } let(:project) { create(:project, :public, :repository, creator: user, namespace: user.namespace, only_allow_merge_if_pipeline_succeeds: false) } let(:milestone) { create(:milestone, title: '1.0.0', project: project) } let(:milestone1) { create(:milestone, title: '0.9', project: project) } diff --git a/spec/requests/api/pages/internal_access_spec.rb b/spec/requests/api/pages/internal_access_spec.rb index 821a210a414..91139b987df 100644 --- a/spec/requests/api/pages/internal_access_spec.rb +++ b/spec/requests/api/pages/internal_access_spec.rb @@ -6,16 +6,15 @@ describe "Internal Project Pages Access" do using RSpec::Parameterized::TableSyntax include AccessMatchers - set(:group) { create(:group) } - set(:project) { create(:project, :internal, pages_access_level: ProjectFeature::ENABLED, namespace: group) } - - set(:admin) { create(:admin) } - set(:owner) { create(:user) } - set(:master) { create(:user) } - set(:developer) { create(:user) } - set(:reporter) { create(:user) } - set(:guest) { create(:user) } - set(:user) { create(:user) } + let_it_be(:group) { create(:group) } + let_it_be(:project, reload: true) { create(:project, :internal, pages_access_level: ProjectFeature::ENABLED, namespace: group) } + let_it_be(:admin) { create(:admin) } + let_it_be(:owner) { create(:user) } + let_it_be(:master) { create(:user) } + let_it_be(:developer) { create(:user) } + let_it_be(:reporter) { create(:user) } + let_it_be(:guest) { create(:user) } + let_it_be(:user) { create(:user) } before do allow(Gitlab.config.pages).to receive(:access_control).and_return(true) diff --git a/spec/requests/api/pages/private_access_spec.rb b/spec/requests/api/pages/private_access_spec.rb index ec84762b05a..7c592ccfd43 100644 --- a/spec/requests/api/pages/private_access_spec.rb +++ b/spec/requests/api/pages/private_access_spec.rb @@ -6,16 +6,15 @@ describe "Private Project Pages Access" do using RSpec::Parameterized::TableSyntax include AccessMatchers - set(:group) { create(:group) } - set(:project) { create(:project, :private, pages_access_level: ProjectFeature::ENABLED, namespace: group) } - - set(:admin) { create(:admin) } - set(:owner) { create(:user) } - set(:master) { create(:user) } - set(:developer) { create(:user) } - set(:reporter) { create(:user) } - set(:guest) { create(:user) } - set(:user) { create(:user) } + let_it_be(:group) { create(:group) } + let_it_be(:project, reload: true) { create(:project, :private, pages_access_level: ProjectFeature::ENABLED, namespace: group) } + let_it_be(:admin) { create(:admin) } + let_it_be(:owner) { create(:user) } + let_it_be(:master) { create(:user) } + let_it_be(:developer) { create(:user) } + let_it_be(:reporter) { create(:user) } + let_it_be(:guest) { create(:user) } + let_it_be(:user) { create(:user) } before do allow(Gitlab.config.pages).to receive(:access_control).and_return(true) diff --git a/spec/requests/api/pages/public_access_spec.rb b/spec/requests/api/pages/public_access_spec.rb index 67b8cfb8fbc..f2fe64434c6 100644 --- a/spec/requests/api/pages/public_access_spec.rb +++ b/spec/requests/api/pages/public_access_spec.rb @@ -6,16 +6,15 @@ describe "Public Project Pages Access" do using RSpec::Parameterized::TableSyntax include AccessMatchers - set(:group) { create(:group) } - set(:project) { create(:project, :public, pages_access_level: ProjectFeature::ENABLED, namespace: group) } - - set(:admin) { create(:admin) } - set(:owner) { create(:user) } - set(:master) { create(:user) } - set(:developer) { create(:user) } - set(:reporter) { create(:user) } - set(:guest) { create(:user) } - set(:user) { create(:user) } + let_it_be(:group) { create(:group) } + let_it_be(:project, reload: true) { create(:project, :public, pages_access_level: ProjectFeature::ENABLED, namespace: group) } + let_it_be(:admin) { create(:admin) } + let_it_be(:owner) { create(:user) } + let_it_be(:master) { create(:user) } + let_it_be(:developer) { create(:user) } + let_it_be(:reporter) { create(:user) } + let_it_be(:guest) { create(:user) } + let_it_be(:user) { create(:user) } before do allow(Gitlab.config.pages).to receive(:access_control).and_return(true) diff --git a/spec/requests/api/pipeline_schedules_spec.rb b/spec/requests/api/pipeline_schedules_spec.rb index 42fc97729bd..fdb9508ed08 100644 --- a/spec/requests/api/pipeline_schedules_spec.rb +++ b/spec/requests/api/pipeline_schedules_spec.rb @@ -3,9 +3,9 @@ require 'spec_helper' describe API::PipelineSchedules do - set(:developer) { create(:user) } - set(:user) { create(:user) } - set(:project) { create(:project, :repository, public_builds: false) } + let_it_be(:developer) { create(:user) } + let_it_be(:user) { create(:user) } + let_it_be(:project) { create(:project, :repository, public_builds: false) } before do project.add_developer(developer) @@ -375,7 +375,7 @@ describe API::PipelineSchedules do describe 'POST /projects/:id/pipeline_schedules/:pipeline_schedule_id/variables' do let(:params) { attributes_for(:ci_pipeline_schedule_variable) } - set(:pipeline_schedule) do + let_it_be(:pipeline_schedule) do create(:ci_pipeline_schedule, project: project, owner: developer) end @@ -432,7 +432,7 @@ describe API::PipelineSchedules do end describe 'PUT /projects/:id/pipeline_schedules/:pipeline_schedule_id/variables/:key' do - set(:pipeline_schedule) do + let_it_be(:pipeline_schedule) do create(:ci_pipeline_schedule, project: project, owner: developer) end @@ -472,7 +472,7 @@ describe API::PipelineSchedules do describe 'DELETE /projects/:id/pipeline_schedules/:pipeline_schedule_id/variables/:key' do let(:maintainer) { create(:user) } - set(:pipeline_schedule) do + let_it_be(:pipeline_schedule) do create(:ci_pipeline_schedule, project: project, owner: developer) end diff --git a/spec/requests/api/project_container_repositories_spec.rb b/spec/requests/api/project_container_repositories_spec.rb index 7cec0867b32..98b3416a2bc 100644 --- a/spec/requests/api/project_container_repositories_spec.rb +++ b/spec/requests/api/project_container_repositories_spec.rb @@ -5,12 +5,11 @@ require 'spec_helper' describe API::ProjectContainerRepositories do include ExclusiveLeaseHelpers - set(:project) { create(:project, :private) } - set(:maintainer) { create(:user) } - set(:developer) { create(:user) } - set(:reporter) { create(:user) } - set(:guest) { create(:user) } - + let_it_be(:project) { create(:project, :private) } + let_it_be(:maintainer) { create(:user) } + let_it_be(:developer) { create(:user) } + let_it_be(:reporter) { create(:user) } + let_it_be(:guest) { create(:user) } let(:root_repository) { create(:container_repository, :root, project: project) } let(:test_repository) { create(:container_repository, project: project) } diff --git a/spec/requests/api/project_export_spec.rb b/spec/requests/api/project_export_spec.rb index 37f2cc85a50..98214a8c471 100644 --- a/spec/requests/api/project_export_spec.rb +++ b/spec/requests/api/project_export_spec.rb @@ -3,13 +3,13 @@ require 'spec_helper' describe API::ProjectExport, :clean_gitlab_redis_cache do - set(:project) { create(:project) } - set(:project_none) { create(:project) } - set(:project_started) { create(:project) } + let_it_be(:project) { create(:project) } + let_it_be(:project_none) { create(:project) } + let_it_be(:project_started) { create(:project) } let(:project_finished) { create(:project, :with_export) } let(:project_after_export) { create(:project, :with_export) } - set(:user) { create(:user) } - set(:admin) { create(:admin) } + let_it_be(:user) { create(:user) } + let_it_be(:admin) { create(:admin) } let(:path) { "/projects/#{project.id}/export" } let(:path_none) { "/projects/#{project_none.id}/export" } diff --git a/spec/requests/api/project_snippets_spec.rb b/spec/requests/api/project_snippets_spec.rb index ccbfe040fca..2c6a13efc12 100644 --- a/spec/requests/api/project_snippets_spec.rb +++ b/spec/requests/api/project_snippets_spec.rb @@ -3,9 +3,9 @@ require 'spec_helper' describe API::ProjectSnippets do - set(:project) { create(:project, :public) } - set(:user) { create(:user) } - set(:admin) { create(:admin) } + let_it_be(:project) { create(:project, :public) } + let_it_be(:user) { create(:user) } + let_it_be(:admin) { create(:admin) } describe "GET /projects/:project_id/snippets/:id/user_agent_detail" do let(:snippet) { create(:project_snippet, :public, project: project) } diff --git a/spec/requests/api/resource_label_events_spec.rb b/spec/requests/api/resource_label_events_spec.rb index 8bac378787c..7619399458a 100644 --- a/spec/requests/api/resource_label_events_spec.rb +++ b/spec/requests/api/resource_label_events_spec.rb @@ -3,9 +3,9 @@ require 'spec_helper' describe API::ResourceLabelEvents do - set(:user) { create(:user) } - set(:project) { create(:project, :public, namespace: user.namespace) } - set(:label) { create(:label, project: project) } + let_it_be(:user) { create(:user) } + let_it_be(:project, reload: true) { create(:project, :public, namespace: user.namespace) } + let_it_be(:label) { create(:label, project: project) } before do project.add_developer(user) diff --git a/spec/requests/api/runners_spec.rb b/spec/requests/api/runners_spec.rb index 7bad30d107d..c54487a68fe 100644 --- a/spec/requests/api/runners_spec.rb +++ b/spec/requests/api/runners_spec.rb @@ -557,7 +557,7 @@ describe API::Runners do end describe 'GET /runners/:id/jobs' do - set(:job_1) { create(:ci_build) } + let_it_be(:job_1) { create(:ci_build) } let!(:job_2) { create(:ci_build, :running, runner: shared_runner, project: project) } let!(:job_3) { create(:ci_build, :failed, runner: shared_runner, project: project) } let!(:job_4) { create(:ci_build, :running, runner: project_runner, project: project) } diff --git a/spec/requests/api/search_spec.rb b/spec/requests/api/search_spec.rb index 24d7f1e313c..04794b2ba58 100644 --- a/spec/requests/api/search_spec.rb +++ b/spec/requests/api/search_spec.rb @@ -3,10 +3,10 @@ require 'spec_helper' describe API::Search do - set(:user) { create(:user) } - set(:group) { create(:group) } - set(:project) { create(:project, :wiki_repo, :public, name: 'awesome project', group: group) } - set(:repo_project) { create(:project, :public, :repository, group: group) } + let_it_be(:user) { create(:user) } + let_it_be(:group) { create(:group) } + let_it_be(:project, reload: true) { create(:project, :wiki_repo, :public, name: 'awesome project', group: group) } + let_it_be(:repo_project) { create(:project, :public, :repository, group: group) } shared_examples 'response is correct' do |schema:, size: 1| it { expect(response).to have_gitlab_http_status(200) } diff --git a/spec/requests/api/services_spec.rb b/spec/requests/api/services_spec.rb index 628d5533366..323164f26f0 100644 --- a/spec/requests/api/services_spec.rb +++ b/spec/requests/api/services_spec.rb @@ -3,10 +3,10 @@ require "spec_helper" describe API::Services do - set(:user) { create(:user) } - set(:user2) { create(:user) } + let_it_be(:user) { create(:user) } + let_it_be(:user2) { create(:user) } - set(:project) do + let_it_be(:project, reload: true) do create(:project, creator_id: user.id, namespace: user.namespace) end diff --git a/spec/requests/api/settings_spec.rb b/spec/requests/api/settings_spec.rb index af86ba86303..1a6bd4e6c0d 100644 --- a/spec/requests/api/settings_spec.rb +++ b/spec/requests/api/settings_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' describe API::Settings, 'Settings' do let(:user) { create(:user) } - set(:admin) { create(:admin) } + let_it_be(:admin) { create(:admin) } describe "GET /application/settings" do it "returns application settings" do diff --git a/spec/requests/api/snippets_spec.rb b/spec/requests/api/snippets_spec.rb index 1749ec89bc1..21565265b99 100644 --- a/spec/requests/api/snippets_spec.rb +++ b/spec/requests/api/snippets_spec.rb @@ -89,8 +89,8 @@ describe API::Snippets do end describe 'GET /snippets/:id/raw' do - set(:author) { create(:user) } - set(:snippet) { create(:personal_snippet, :private, author: author) } + let_it_be(:author) { create(:user) } + let_it_be(:snippet) { create(:personal_snippet, :private, author: author) } it 'requires authentication' do get api("/snippets/#{snippet.id}", nil) @@ -137,10 +137,10 @@ describe API::Snippets do end describe 'GET /snippets/:id' do - set(:admin) { create(:user, :admin) } - set(:author) { create(:user) } - set(:private_snippet) { create(:personal_snippet, :private, author: author) } - set(:internal_snippet) { create(:personal_snippet, :internal, author: author) } + let_it_be(:admin) { create(:user, :admin) } + let_it_be(:author) { create(:user) } + let_it_be(:private_snippet) { create(:personal_snippet, :private, author: author) } + let_it_be(:internal_snippet) { create(:personal_snippet, :internal, author: author) } it 'requires authentication' do get api("/snippets/#{private_snippet.id}", nil) diff --git a/spec/requests/api/task_completion_status_spec.rb b/spec/requests/api/task_completion_status_spec.rb index ee2531197b1..a2891e1d983 100644 --- a/spec/requests/api/task_completion_status_spec.rb +++ b/spec/requests/api/task_completion_status_spec.rb @@ -3,8 +3,8 @@ require 'spec_helper' describe 'task completion status response' do - set(:user) { create(:user) } - set(:project) do + let_it_be(:user) { create(:user) } + let_it_be(:project) do create(:project, :public, creator_id: user.id, namespace: user.namespace) end diff --git a/spec/requests/api/triggers_spec.rb b/spec/requests/api/triggers_spec.rb index d54d112cd9f..35e41f5ae52 100644 --- a/spec/requests/api/triggers_spec.rb +++ b/spec/requests/api/triggers_spec.rb @@ -3,8 +3,8 @@ require 'spec_helper' describe API::Triggers do - set(:user) { create(:user) } - set(:user2) { create(:user) } + let_it_be(:user) { create(:user) } + let_it_be(:user2) { create(:user) } let!(:trigger_token) { 'secure_token' } let!(:trigger_token_2) { 'secure_token_2' } |