diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2018-02-28 22:35:22 +0300 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2018-02-28 22:35:22 +0300 |
commit | e0401df1214397626e65e58166988fe62715d372 (patch) | |
tree | 087d8ca4a1611aa50a8ac98e66f7d1657ff1f90f /spec/requests/api/v3 | |
parent | 2b7b60728426c10ef1188a1073d3630805773a35 (diff) | |
parent | 11c67e7c2f992299ff5918ce67995b73d1e0be6d (diff) |
Merge commit '11c67e7c2f992299ff5918ce67995b73d1e0be6d' into object-storage-ee-to-ce-backport
Diffstat (limited to 'spec/requests/api/v3')
-rw-r--r-- | spec/requests/api/v3/award_emoji_spec.rb | 14 | ||||
-rw-r--r-- | spec/requests/api/v3/boards_spec.rb | 25 | ||||
-rw-r--r-- | spec/requests/api/v3/branches_spec.rb | 10 | ||||
-rw-r--r-- | spec/requests/api/v3/broadcast_messages_spec.rb | 6 | ||||
-rw-r--r-- | spec/requests/api/v3/builds_spec.rb | 14 | ||||
-rw-r--r-- | spec/requests/api/v3/issues_spec.rb | 19 | ||||
-rw-r--r-- | spec/requests/api/v3/merge_requests_spec.rb | 40 | ||||
-rw-r--r-- | spec/requests/api/v3/projects_spec.rb | 1 |
8 files changed, 63 insertions, 66 deletions
diff --git a/spec/requests/api/v3/award_emoji_spec.rb b/spec/requests/api/v3/award_emoji_spec.rb index 681e8e04295..36d793f505d 100644 --- a/spec/requests/api/v3/award_emoji_spec.rb +++ b/spec/requests/api/v3/award_emoji_spec.rb @@ -1,13 +1,13 @@ require 'spec_helper' describe API::V3::AwardEmoji do - let(:user) { create(:user) } - let!(:project) { create(:project) } - let(:issue) { create(:issue, project: project) } - let!(: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) } - let!(:note) { create(:note, project: project, noteable: issue) } + 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) } before { project.team << [user, :master] } diff --git a/spec/requests/api/v3/boards_spec.rb b/spec/requests/api/v3/boards_spec.rb index b86aab2ec70..ea2627142bf 100644 --- a/spec/requests/api/v3/boards_spec.rb +++ b/spec/requests/api/v3/boards_spec.rb @@ -1,28 +1,28 @@ require 'spec_helper' describe API::V3::Boards do - let(:user) { create(:user) } - let(:guest) { create(:user) } - let(:non_member) { create(:user) } - let!(:project) { create(:project, :public, creator_id: user.id, namespace: user.namespace ) } + set(:user) { create(:user) } + set(:guest) { create(:user) } + set(:non_member) { create(:user) } + set(:project) { create(:project, :public, creator_id: user.id, namespace: user.namespace ) } - let!(:dev_label) do + set(:dev_label) do create(:label, title: 'Development', color: '#FFAABB', project: project) end - let!(:test_label) do + set(:test_label) do create(:label, title: 'Testing', color: '#FFAACC', project: project) end - let!(:dev_list) do + set(:dev_list) do create(:list, label: dev_label, position: 1) end - let!(:test_list) do + set(:test_list) do create(:list, label: test_label, position: 2) end - let!(:board) do + set(:board) do create(:board, project: project, lists: [dev_list, test_list]) end @@ -98,8 +98,11 @@ describe API::V3::Boards do end context "when the user is project owner" do - let(:owner) { create(:user) } - let(:project) { create(:project, namespace: owner.namespace) } + set(:owner) { create(:user) } + + before do + project.update(namespace: owner.namespace) + end it "deletes the list if an admin requests it" do delete v3_api("#{base_url}/#{dev_list.id}", owner) diff --git a/spec/requests/api/v3/branches_spec.rb b/spec/requests/api/v3/branches_spec.rb index c88f7788697..9cd11a67712 100644 --- a/spec/requests/api/v3/branches_spec.rb +++ b/spec/requests/api/v3/branches_spec.rb @@ -2,11 +2,11 @@ require 'spec_helper' require 'mime/types' describe API::V3::Branches do - let(:user) { create(:user) } - let(:user2) { create(:user) } - let!(:project) { create(:project, :repository, creator: user) } - let!(:master) { create(:project_member, :master, user: user, project: project) } - let!(:guest) { create(:project_member, :guest, user: user2, project: project) } + set(:user) { create(:user) } + set(:user2) { create(:user) } + set(:project) { create(:project, :repository, creator: user) } + set(:master) { create(:project_member, :master, user: user, project: project) } + set(:guest) { create(:project_member, :guest, user: user2, project: project) } let!(:branch_name) { 'feature' } let!(:branch_sha) { '0b4bc9a49b562e85de7cc9e834518ea6828729b9' } let!(:branch_with_dot) { CreateBranchService.new(project, user).execute("with.1.2.3", "master") } diff --git a/spec/requests/api/v3/broadcast_messages_spec.rb b/spec/requests/api/v3/broadcast_messages_spec.rb index 948cd78c177..d04b1c72004 100644 --- a/spec/requests/api/v3/broadcast_messages_spec.rb +++ b/spec/requests/api/v3/broadcast_messages_spec.rb @@ -1,11 +1,11 @@ require 'spec_helper' describe API::V3::BroadcastMessages do - let(:user) { create(:user) } - let(:admin) { create(:admin) } + set(:user) { create(:user) } + set(:admin) { create(:admin) } describe 'DELETE /broadcast_messages/:id' do - let!(:message) { create(:broadcast_message) } + set(:message) { create(:broadcast_message) } it 'returns a 401 for anonymous users' do delete v3_api("/broadcast_messages/#{message.id}"), diff --git a/spec/requests/api/v3/builds_spec.rb b/spec/requests/api/v3/builds_spec.rb index 37710aedbb1..3546b5b85c1 100644 --- a/spec/requests/api/v3/builds_spec.rb +++ b/spec/requests/api/v3/builds_spec.rb @@ -1,14 +1,14 @@ require 'spec_helper' describe API::V3::Builds do - let(:user) { create(:user) } + set(:user) { create(:user) } let(:api_user) { user } - let!(:project) { create(:project, :repository, creator: user, public_builds: false) } - let!(:developer) { create(:project_member, :developer, user: user, project: project) } - let(:reporter) { create(:project_member, :reporter, project: project) } - let(:guest) { create(:project_member, :guest, project: project) } - let(:pipeline) { create(:ci_empty_pipeline, project: project, sha: project.commit.id, ref: project.default_branch) } - let(:build) { create(:ci_build, pipeline: pipeline) } + set(:project) { create(:project, :repository, creator: user, public_builds: false) } + set(:developer) { create(:project_member, :developer, user: user, project: project) } + set(:reporter) { create(:project_member, :reporter, project: project) } + set(:guest) { create(:project_member, :guest, project: project) } + set(:pipeline) { create(:ci_empty_pipeline, project: project, sha: project.commit.id, ref: project.default_branch) } + let!(:build) { create(:ci_build, pipeline: pipeline) } describe 'GET /projects/:id/builds ' do let(:query) { '' } diff --git a/spec/requests/api/v3/issues_spec.rb b/spec/requests/api/v3/issues_spec.rb index 9a0e6647ebf..86768d7397a 100644 --- a/spec/requests/api/v3/issues_spec.rb +++ b/spec/requests/api/v3/issues_spec.rb @@ -1,13 +1,13 @@ require 'spec_helper' describe API::V3::Issues, :mailer do - let(:user) { create(:user) } - let(:user2) { create(:user) } - let(:non_member) { create(:user) } - let(:guest) { create(:user) } - let(:author) { create(:author) } - let(:assignee) { create(:assignee) } - let(:admin) { create(:user, :admin) } + set(:user) { create(:user) } + set(:user2) { create(:user) } + set(:non_member) { create(:user) } + set(:guest) { create(:user) } + set(:author) { create(:author) } + set(:assignee) { create(:assignee) } + set(:admin) { create(:user, :admin) } let!(:project) { create(:project, :public, creator_id: user.id, namespace: user.namespace ) } let!(:closed_issue) do create :closed_issue, @@ -822,7 +822,8 @@ describe API::V3::Issues, :mailer do end context 'resolving issues in a merge request' do - let(:discussion) { create(:diff_note_on_merge_request).to_discussion } + set(:diff_note_on_merge_request) { create(:diff_note_on_merge_request) } + let(:discussion) { diff_note_on_merge_request.to_discussion } let(:merge_request) { discussion.noteable } let(:project) { merge_request.source_project } before do @@ -1169,7 +1170,7 @@ describe API::V3::Issues, :mailer do end context "when the user is project owner" do - let(:owner) { create(:user) } + set(:owner) { create(:user) } let(:project) { create(:project, namespace: owner.namespace) } it "deletes the issue if an admin requests it" do diff --git a/spec/requests/api/v3/merge_requests_spec.rb b/spec/requests/api/v3/merge_requests_spec.rb index 86f38dd4ec1..df73c731c96 100644 --- a/spec/requests/api/v3/merge_requests_spec.rb +++ b/spec/requests/api/v3/merge_requests_spec.rb @@ -1,6 +1,8 @@ require "spec_helper" describe API::MergeRequests do + include ProjectForksHelper + let(:base_time) { Time.now } let(:user) { create(:user) } let(:admin) { create(:user, :admin) } @@ -312,17 +314,17 @@ describe API::MergeRequests do context 'forked projects' do let!(:user2) { create(:user) } - let!(:fork_project) { create(:project, forked_from_project: project, namespace: user2.namespace, creator_id: user2.id) } + let!(:forked_project) { fork_project(project, user2) } let!(:unrelated_project) { create(:project, namespace: create(:user).namespace, creator_id: user2.id) } before do - fork_project.add_reporter(user2) + forked_project.add_reporter(user2) allow_any_instance_of(MergeRequest).to receive(:write_ref) end it "returns merge_request" do - post v3_api("/projects/#{fork_project.id}/merge_requests", user2), + post v3_api("/projects/#{forked_project.id}/merge_requests", user2), title: 'Test merge_request', source_branch: "feature_conflict", target_branch: "master", author: user2, target_project_id: project.id, description: 'Test description for Test merge_request' expect(response).to have_gitlab_http_status(201) @@ -331,10 +333,10 @@ describe API::MergeRequests do end it "does not return 422 when source_branch equals target_branch" do - expect(project.id).not_to eq(fork_project.id) - expect(fork_project.forked?).to be_truthy - expect(fork_project.forked_from_project).to eq(project) - post v3_api("/projects/#{fork_project.id}/merge_requests", user2), + expect(project.id).not_to eq(forked_project.id) + expect(forked_project.forked?).to be_truthy + expect(forked_project.forked_from_project).to eq(project) + post v3_api("/projects/#{forked_project.id}/merge_requests", user2), title: 'Test merge_request', source_branch: "master", target_branch: "master", author: user2, target_project_id: project.id expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq('Test merge_request') @@ -343,7 +345,7 @@ describe API::MergeRequests do it "returns 422 when target project has disabled merge requests" do project.project_feature.update(merge_requests_access_level: 0) - post v3_api("/projects/#{fork_project.id}/merge_requests", user2), + post v3_api("/projects/#{forked_project.id}/merge_requests", user2), title: 'Test', target_branch: "master", source_branch: 'markdown', @@ -354,36 +356,26 @@ describe API::MergeRequests do end it "returns 400 when source_branch is missing" do - post v3_api("/projects/#{fork_project.id}/merge_requests", user2), + post v3_api("/projects/#{forked_project.id}/merge_requests", user2), title: 'Test merge_request', target_branch: "master", author: user2, target_project_id: project.id expect(response).to have_gitlab_http_status(400) end it "returns 400 when target_branch is missing" do - post v3_api("/projects/#{fork_project.id}/merge_requests", user2), + post v3_api("/projects/#{forked_project.id}/merge_requests", user2), title: 'Test merge_request', target_branch: "master", author: user2, target_project_id: project.id expect(response).to have_gitlab_http_status(400) end it "returns 400 when title is missing" do - post v3_api("/projects/#{fork_project.id}/merge_requests", user2), + post v3_api("/projects/#{forked_project.id}/merge_requests", user2), target_branch: 'master', source_branch: 'markdown', author: user2, target_project_id: project.id expect(response).to have_gitlab_http_status(400) end context 'when target_branch is specified' do - it 'returns 422 if not a forked project' do - post v3_api("/projects/#{project.id}/merge_requests", user), - title: 'Test merge_request', - target_branch: 'master', - source_branch: 'markdown', - author: user, - target_project_id: fork_project.id - expect(response).to have_gitlab_http_status(422) - end - it 'returns 422 if targeting a different fork' do - post v3_api("/projects/#{fork_project.id}/merge_requests", user2), + post v3_api("/projects/#{forked_project.id}/merge_requests", user2), title: 'Test merge_request', target_branch: 'master', source_branch: 'markdown', @@ -394,8 +386,8 @@ describe API::MergeRequests do end it "returns 201 when target_branch is specified and for the same project" do - post v3_api("/projects/#{fork_project.id}/merge_requests", user2), - title: 'Test merge_request', target_branch: 'master', source_branch: 'markdown', author: user2, target_project_id: fork_project.id + post v3_api("/projects/#{forked_project.id}/merge_requests", user2), + title: 'Test merge_request', target_branch: 'master', source_branch: 'markdown', author: user2, target_project_id: forked_project.id expect(response).to have_gitlab_http_status(201) end end diff --git a/spec/requests/api/v3/projects_spec.rb b/spec/requests/api/v3/projects_spec.rb index cae2c3118da..e5282c3311f 100644 --- a/spec/requests/api/v3/projects_spec.rb +++ b/spec/requests/api/v3/projects_spec.rb @@ -89,6 +89,7 @@ describe API::V3::Projects do path path_with_namespace star_count forks_count created_at last_activity_at + avatar_url ) get v3_api('/projects?simple=true', user) |