diff options
author | Robert Schilling <rschilling@student.tugraz.at> | 2016-04-07 14:07:17 +0200 |
---|---|---|
committer | Robert Schilling <rschilling@student.tugraz.at> | 2016-04-13 11:23:42 +0200 |
commit | 482f67edb46423d4fc567e061d6546d8dfafc7bb (patch) | |
tree | 1f6d81b239da8373b319e9b35b866f9921d60519 /spec/requests/api/issues_spec.rb | |
parent | 8ea6c6d80c0942e0f2caee3caa0cd7503e51d45d (diff) | |
download | gitlab-ce-482f67edb46423d4fc567e061d6546d8dfafc7bb.tar.gz |
API: Ability to move an issue
Diffstat (limited to 'spec/requests/api/issues_spec.rb')
-rw-r--r-- | spec/requests/api/issues_spec.rb | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/spec/requests/api/issues_spec.rb b/spec/requests/api/issues_spec.rb index 822d3ad3017..db4ee46975a 100644 --- a/spec/requests/api/issues_spec.rb +++ b/spec/requests/api/issues_spec.rb @@ -7,7 +7,7 @@ describe API::API, api: true do let(:author) { create(:author) } let(:assignee) { create(:assignee) } let(:admin) { create(:user, :admin) } - let!(:project) { create(:project, :public, namespace: user.namespace ) } + let!(:project) { create(:project, :public, creator_id: user.id, namespace: user.namespace ) } let!(:closed_issue) do create :closed_issue, author: user, @@ -501,4 +501,55 @@ describe API::API, api: true do end end end + + describe '/projects/:id/issues/:issue_id/move' do + let!(:target_project) { create(:project, path: 'project2', creator_id: user.id, namespace: user.namespace ) } + let!(:target_project2) { create(:project, creator_id: non_member.id, namespace: non_member.namespace ) } + + it 'moves an issue' do + post api("/projects/#{project.id}/issues/#{issue.id}/move", user), + new_project_id: target_project.id + + expect(response.status).to eq(201) + expect(json_response['project_id']).to eq(target_project.id) + end + + it 'returns an error if target and source project are the same' do + post api("/projects/#{project.id}/issues/#{issue.id}/move", user), + new_project_id: project.id + + expect(response.status).to eq(400) + expect(json_response['message']).to eq('Cannot move issue to project it originates from!') + end + + it "returns an error if I don't have the permission" do + post api("/projects/#{project.id}/issues/#{issue.id}/move", user), + new_project_id: target_project2.id + + expect(response.status).to eq(400) + expect(json_response['message']).to eq('Cannot move issue due to insufficient permissions!') + end + + it 'moves the issue to another namespace if I am admin' do + post api("/projects/#{project.id}/issues/#{issue.id}/move", admin), + new_project_id: target_project2.id + + expect(response.status).to eq(201) + expect(json_response['project_id']).to eq(target_project2.id) + end + + it 'returns 404 if the source issue is not found' do + post api("/projects/#{project.id}/issues/123/move", user), + new_project_id: target_project.id + + expect(response.status).to eq(404) + end + + it 'returns 404 if the target project is not found' do + post api("/projects/1234/issues/#{issue.id}/move", user), + new_project_id: target_project.id + + expect(response.status).to eq(404) + end + end end |