Commit cee68dec authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Fix api merge request specs

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent c227aa44
...@@ -47,32 +47,32 @@ describe API::API do ...@@ -47,32 +47,32 @@ describe API::API do
context 'between branches projects' do context 'between branches projects' do
it "should return merge_request" do it "should return merge_request" do
post api("/projects/#{project.id}/merge_requests", user), post api("/projects/#{project.id}/merge_requests", user),
title: 'Test merge_request', source_branch: "stable", target_branch: "master", author: user title: 'Test merge_request', source_branch: "stable", target_branch: "master", author: user
response.status.should == 201 response.status.should == 201
json_response['title'].should == 'Test merge_request' json_response['title'].should == 'Test merge_request'
end end
it "should return 422 when source_branch equals target_branch" do it "should return 422 when source_branch equals target_branch" do
post api("/projects/#{project.id}/merge_requests", user), post api("/projects/#{project.id}/merge_requests", user),
title: "Test merge_request", source_branch: "master", target_branch: "master", author: user title: "Test merge_request", source_branch: "master", target_branch: "master", author: user
response.status.should == 422 response.status.should == 422
end end
it "should return 400 when source_branch is missing" do it "should return 400 when source_branch is missing" do
post api("/projects/#{project.id}/merge_requests", user), post api("/projects/#{project.id}/merge_requests", user),
title: "Test merge_request", target_branch: "master", author: user title: "Test merge_request", target_branch: "master", author: user
response.status.should == 400 response.status.should == 400
end end
it "should return 400 when target_branch is missing" do it "should return 400 when target_branch is missing" do
post api("/projects/#{project.id}/merge_requests", user), post api("/projects/#{project.id}/merge_requests", user),
title: "Test merge_request", source_branch: "stable", author: user title: "Test merge_request", source_branch: "stable", author: user
response.status.should == 400 response.status.should == 400
end end
it "should return 400 when title is missing" do it "should return 400 when title is missing" do
post api("/projects/#{project.id}/merge_requests", user), post api("/projects/#{project.id}/merge_requests", user),
target_branch: 'master', source_branch: 'stable' target_branch: 'master', source_branch: 'stable'
response.status.should == 400 response.status.should == 400
end end
end end
...@@ -80,8 +80,8 @@ describe API::API do ...@@ -80,8 +80,8 @@ describe API::API do
context 'forked projects' do context 'forked projects' do
let!(:user2) {create(:user)} let!(:user2) {create(:user)}
let!(:forked_project_link) { build(:forked_project_link) } let!(:forked_project_link) { build(:forked_project_link) }
let!(:fork_project) { create(:source_project, forked_project_link: forked_project_link, namespace: user2.namespace, creator_id: user2.id) } let!(:fork_project) { create(:project, forked_project_link: forked_project_link, namespace: user2.namespace, creator_id: user2.id) }
let!(:unrelated_project) { create(:target_project, namespace: user2.namespace, creator_id: user2.id) } let!(:unrelated_project) { create(:project, namespace: create(:user).namespace, creator_id: user2.id) }
before :each do |each| before :each do |each|
fork_project.team << [user2, :reporters] fork_project.team << [user2, :reporters]
...@@ -92,7 +92,7 @@ describe API::API do ...@@ -92,7 +92,7 @@ describe API::API do
it "should return merge_request" do it "should return merge_request" do
post api("/projects/#{fork_project.id}/merge_requests", user2), post api("/projects/#{fork_project.id}/merge_requests", user2),
title: 'Test merge_request', source_branch: "stable", target_branch: "master", author: user2, target_project_id: project.id title: 'Test merge_request', source_branch: "stable", target_branch: "master", author: user2, target_project_id: project.id
response.status.should == 201 response.status.should == 201
json_response['title'].should == 'Test merge_request' json_response['title'].should == 'Test merge_request'
end end
...@@ -102,44 +102,44 @@ describe API::API do ...@@ -102,44 +102,44 @@ describe API::API do
fork_project.forked?.should be_true fork_project.forked?.should be_true
fork_project.forked_from_project.should == project fork_project.forked_from_project.should == project
post api("/projects/#{fork_project.id}/merge_requests", user2), post api("/projects/#{fork_project.id}/merge_requests", user2),
title: 'Test merge_request', source_branch: "master", target_branch: "master", author: user2, target_project_id: project.id title: 'Test merge_request', source_branch: "master", target_branch: "master", author: user2, target_project_id: project.id
response.status.should == 201 response.status.should == 201
json_response['title'].should == 'Test merge_request' json_response['title'].should == 'Test merge_request'
end end
it "should return 400 when source_branch is missing" do it "should return 400 when source_branch is missing" do
post api("/projects/#{fork_project.id}/merge_requests", user2), post api("/projects/#{fork_project.id}/merge_requests", user2),
title: 'Test merge_request', target_branch: "master", author: user2, target_project_id: project.id title: 'Test merge_request', target_branch: "master", author: user2, target_project_id: project.id
response.status.should == 400 response.status.should == 400
end end
it "should return 400 when target_branch is missing" do it "should return 400 when target_branch is missing" do
post api("/projects/#{fork_project.id}/merge_requests", user2), post api("/projects/#{fork_project.id}/merge_requests", user2),
title: 'Test merge_request', target_branch: "master", author: user2, target_project_id: project.id title: 'Test merge_request', target_branch: "master", author: user2, target_project_id: project.id
response.status.should == 400 response.status.should == 400
end end
it "should return 400 when title is missing" do it "should return 400 when title is missing" do
post api("/projects/#{fork_project.id}/merge_requests", user2), post api("/projects/#{fork_project.id}/merge_requests", user2),
target_branch: 'master', source_branch: 'stable', author: user2, target_project_id: project.id target_branch: 'master', source_branch: 'stable', author: user2, target_project_id: project.id
response.status.should == 400 response.status.should == 400
end end
it "should return 400 when target_branch is specified and not a forked project" do it "should return 400 when target_branch is specified and not a forked project" do
post api("/projects/#{project.id}/merge_requests", user), post api("/projects/#{project.id}/merge_requests", user),
title: 'Test merge_request', target_branch: 'master', source_branch: 'stable', author: user, target_project_id: fork_project.id title: 'Test merge_request', target_branch: 'master', source_branch: 'stable', author: user, target_project_id: fork_project.id
response.status.should == 400 response.status.should == 400
end end
it "should return 400 when target_branch is specified and for a different fork" do it "should return 400 when target_branch is specified and for a different fork" do
post api("/projects/#{fork_project.id}/merge_requests", user2), post api("/projects/#{fork_project.id}/merge_requests", user2),
title: 'Test merge_request', target_branch: 'master', source_branch: 'stable', author: user2, target_project_id: unrelated_project.id title: 'Test merge_request', target_branch: 'master', source_branch: 'stable', author: user2, target_project_id: unrelated_project.id
response.status.should == 400 response.status.should == 400
end end
it "should return 201 when target_branch is specified and for the same project" do it "should return 201 when target_branch is specified and for the same project" do
post api("/projects/#{fork_project.id}/merge_requests", user2), post api("/projects/#{fork_project.id}/merge_requests", user2),
title: 'Test merge_request', target_branch: 'master', source_branch: 'stable', author: user2, target_project_id: fork_project.id title: 'Test merge_request', target_branch: 'master', source_branch: 'stable', author: user2, target_project_id: fork_project.id
response.status.should == 201 response.status.should == 201
end end
end end
...@@ -170,7 +170,7 @@ describe API::API do ...@@ -170,7 +170,7 @@ describe API::API do
it "should return 422 when source_branch and target_branch are renamed the same" do it "should return 422 when source_branch and target_branch are renamed the same" do
put api("/projects/#{project.id}/merge_request/#{merge_request.id}", user), put api("/projects/#{project.id}/merge_request/#{merge_request.id}", user),
source_branch: "master", target_branch: "master" source_branch: "master", target_branch: "master"
response.status.should == 422 response.status.should == 422
end end
...@@ -198,5 +198,4 @@ describe API::API do ...@@ -198,5 +198,4 @@ describe API::API do
response.status.should == 404 response.status.should == 404
end end
end end
end end
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