blob: 1dd9c05ce81914f08cb96868c6354075be582581 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
require 'spec_helper'
describe API::API do
include ApiHelpers
let(:project) { FactoryGirl.create(:project) }
let(:gitlab_url) { GitlabCi.config.gitlab_server.url }
let(:private_token) { Network.new.authenticate(access_token: "some_token")["private_token"] }
let(:options) {
{
private_token: private_token,
url: gitlab_url
}
}
before {
stub_gitlab_calls
}
describe "POST /forks" do
let(:project_info) {
{
project_id: project.gitlab_id,
project_token: project.token,
data: {
id: 2,
name_with_namespace: "Gitlab.org / Underscore",
path_with_namespace: "gitlab-org/underscore",
default_branch: "master",
ssh_url_to_repo: "git@example.com:gitlab-org/underscore"
}
}
}
context "with valid info" do
before do
options.merge!(project_info)
end
it "should create a project with valid data" do
post api("/forks"), options
response.status.should eq 201
json_response['name'].should eq "Gitlab.org / Underscore"
end
end
context "with invalid project info" do
before do
options.merge!({})
end
it "should error with invalid data" do
post api("/forks"), options
response.status.should eq 400
end
end
end
end
|