Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
a0c1a12d
Commit
a0c1a12d
authored
Sep 16, 2015
by
Valery Sizov
Committed by
Kamil Trzcinski
Sep 18, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove API calls from CE to CI
parent
bdfe6b96
Changes
22
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
31 additions
and
297 deletions
+31
-297
CHANGELOG
CHANGELOG
+1
-0
app/controllers/ci/projects_controller.rb
app/controllers/ci/projects_controller.rb
+1
-11
app/models/ci/project.rb
app/models/ci/project.rb
+0
-15
app/models/project_services/gitlab_ci_service.rb
app/models/project_services/gitlab_ci_service.rb
+14
-33
app/services/ci/create_project_service.rb
app/services/ci/create_project_service.rb
+2
-7
app/services/projects/fork_service.rb
app/services/projects/fork_service.rb
+1
-1
app/workers/fork_registration_worker.rb
app/workers/fork_registration_worker.rb
+0
-12
config/routes.rb
config/routes.rb
+0
-1
doc/ci/api/README.md
doc/ci/api/README.md
+0
-1
doc/ci/api/forks.md
doc/ci/api/forks.md
+0
-23
features/steps/project/services.rb
features/steps/project/services.rb
+1
-3
lib/ci/api/api.rb
lib/ci/api/api.rb
+0
-1
lib/ci/api/forks.rb
lib/ci/api/forks.rb
+0
-37
spec/controllers/ci/projects_controller_spec.rb
spec/controllers/ci/projects_controller_spec.rb
+0
-43
spec/lib/gitlab/backend/grack_auth_spec.rb
spec/lib/gitlab/backend/grack_auth_spec.rb
+0
-1
spec/models/project_services/gitlab_ci_service_spec.rb
spec/models/project_services/gitlab_ci_service_spec.rb
+4
-33
spec/requests/api/projects_spec.rb
spec/requests/api/projects_spec.rb
+1
-1
spec/requests/api/services_spec.rb
spec/requests/api/services_spec.rb
+2
-2
spec/requests/ci/api/forks_spec.rb
spec/requests/ci/api/forks_spec.rb
+0
-59
spec/services/ci/create_project_service_spec.rb
spec/services/ci/create_project_service_spec.rb
+2
-2
spec/services/projects/fork_service_spec.rb
spec/services/projects/fork_service_spec.rb
+2
-1
spec/workers/fork_registration_worker_spec.rb
spec/workers/fork_registration_worker_spec.rb
+0
-10
No files found.
CHANGELOG
View file @
a0c1a12d
...
@@ -55,6 +55,7 @@ v 8.0.0 (unreleased)
...
@@ -55,6 +55,7 @@ v 8.0.0 (unreleased)
- Webhook for issue now contains repository field (Jungkook Park)
- Webhook for issue now contains repository field (Jungkook Park)
- Add ability to add custom text to the help page (Jeroen van Baarsen)
- Add ability to add custom text to the help page (Jeroen van Baarsen)
- Add pg_schema to backup config
- Add pg_schema to backup config
- Removed API calls from CE to CI
v 7.14.3
v 7.14.3
- No changes
- No changes
...
...
app/controllers/ci/projects_controller.rb
View file @
a0c1a12d
...
@@ -55,7 +55,7 @@ module Ci
...
@@ -55,7 +55,7 @@ module Ci
return
redirect_to
ci_root_path
,
alert:
'You have to have at least master role to enable CI for this project'
return
redirect_to
ci_root_path
,
alert:
'You have to have at least master role to enable CI for this project'
end
end
@project
=
Ci
::
CreateProjectService
.
new
.
execute
(
current_user
,
project_data
,
ci_project_url
(
":project_id"
)
)
@project
=
Ci
::
CreateProjectService
.
new
.
execute
(
current_user
,
project_data
)
if
@project
.
persisted?
if
@project
.
persisted?
redirect_to
ci_project_path
(
@project
,
show_guide:
true
),
notice:
'Project was successfully created.'
redirect_to
ci_project_path
(
@project
,
show_guide:
true
),
notice:
'Project was successfully created.'
...
@@ -86,16 +86,6 @@ module Ci
...
@@ -86,16 +86,6 @@ module Ci
redirect_to
ci_projects_url
redirect_to
ci_projects_url
end
end
def
build
@commit
=
Ci
::
CreateCommitService
.
new
.
execute
(
@project
,
params
.
dup
)
if
@commit
&&
@commit
.
valid?
head
201
else
head
400
end
end
# Project status badge
# Project status badge
# Image with build status for sha or ref
# Image with build status for sha or ref
def
badge
def
badge
...
...
app/models/ci/project.rb
View file @
a0c1a12d
...
@@ -92,21 +92,6 @@ module Ci
...
@@ -92,21 +92,6 @@ module Ci
project
project
end
end
# TODO: remove
def
from_gitlab
(
user
,
scope
=
:owned
,
options
)
opts
=
user
.
authenticate_options
opts
.
merge!
options
raise
'Implement me of fix'
#projects = Ci::Network.new.projects(opts.compact, scope)
if
projects
projects
.
map
{
|
pr
|
OpenStruct
.
new
(
pr
)
}
else
[]
end
end
def
already_added?
(
project
)
def
already_added?
(
project
)
where
(
gitlab_id:
project
.
id
).
any?
where
(
gitlab_id:
project
.
id
).
any?
end
end
...
...
app/models/project_services/gitlab_ci_service.rb
View file @
a0c1a12d
...
@@ -19,22 +19,12 @@
...
@@ -19,22 +19,12 @@
#
#
class
GitlabCiService
<
CiService
class
GitlabCiService
<
CiService
API_PREFIX
=
"api/v1"
prop_accessor
:token
prop_accessor
:project_url
,
:token
,
:enable_ssl_verification
validates
:project_url
,
presence:
true
,
format:
{
with:
/\A
#{
URI
.
regexp
(
%w(http https)
)
}
\z/
,
message:
"should be a valid url"
},
if: :activated?
validates
:token
,
presence:
true
,
format:
{
with:
/\A([A-Za-z0-9]+)\z/
},
if: :activated?
after_save
:compose_service_hook
,
if: :activated?
after_save
:compose_service_hook
,
if: :activated?
def
compose_service_hook
def
compose_service_hook
hook
=
service_hook
||
build_service_hook
hook
=
service_hook
||
build_service_hook
hook
.
url
=
[
project_url
,
"/build"
,
"?token=
#{
token
}
"
].
join
(
""
)
hook
.
enable_ssl_verification
=
enable_ssl_verification
hook
.
save
hook
.
save
end
end
...
@@ -55,7 +45,8 @@ class GitlabCiService < CiService
...
@@ -55,7 +45,8 @@ class GitlabCiService < CiService
end
end
end
end
service_hook
.
execute
(
data
)
ci_project
=
Ci
::
Project
.
find_by
(
gitlab_id:
project
.
id
)
Ci
::
CreateCommitService
.
new
.
execute
(
ci_project
,
data
)
end
end
def
get_ci_commit
(
sha
,
ref
)
def
get_ci_commit
(
sha
,
ref
)
...
@@ -68,24 +59,22 @@ class GitlabCiService < CiService
...
@@ -68,24 +59,22 @@ class GitlabCiService < CiService
:error
:error
end
end
def
fork_registration
(
new_project
,
private_token
)
def
fork_registration
(
new_project
,
current_user
)
params
=
{
params
=
OpenStruct
.
new
(
{
id:
new_project
.
id
,
id:
new_project
.
id
,
name_with_namespace:
new_project
.
name_with_namespace
,
name_with_namespace:
new_project
.
name_with_namespace
,
path_with_namespace:
new_project
.
path_with_namespace
,
path_with_namespace:
new_project
.
path_with_namespace
,
web_url:
new_project
.
web_url
,
web_url:
new_project
.
web_url
,
default_branch:
new_project
.
default_branch
,
default_branch:
new_project
.
default_branch
,
ssh_url_to_repo:
new_project
.
ssh_url_to_repo
ssh_url_to_repo:
new_project
.
ssh_url_to_repo
}
})
HTTParty
.
post
(
ci_project
=
Ci
::
Project
.
find_by!
(
gitlab_id:
project
.
id
)
fork_registration_path
,
body:
{
Ci
::
CreateProjectService
.
new
.
execute
(
project_id:
project
.
id
,
current_user
,
project_token:
token
,
params
,
private_token:
private_token
,
ci_project
data:
params
},
verify:
false
)
)
end
end
...
@@ -112,11 +101,7 @@ class GitlabCiService < CiService
...
@@ -112,11 +101,7 @@ class GitlabCiService < CiService
end
end
def
fields
def
fields
[
[]
{
type:
'text'
,
name:
'token'
,
placeholder:
'GitLab CI project specific token'
},
{
type:
'text'
,
name:
'project_url'
,
placeholder:
'http://ci.gitlabhq.com/projects/3'
},
{
type:
'checkbox'
,
name:
'enable_ssl_verification'
,
title:
"Enable SSL verification"
}
]
end
end
private
private
...
@@ -125,10 +110,6 @@ class GitlabCiService < CiService
...
@@ -125,10 +110,6 @@ class GitlabCiService < CiService
repository
.
blob_at
(
sha
,
'.gitlab-ci.yml'
)
repository
.
blob_at
(
sha
,
'.gitlab-ci.yml'
)
end
end
def
fork_registration_path
project_url
.
sub
(
/projects\/\d*/
,
"
#{
API_PREFIX
}
/forks"
)
end
def
repository
def
repository
project
.
repository
project
.
repository
end
end
...
...
app/services/ci/create_project_service.rb
View file @
a0c1a12d
...
@@ -2,20 +2,15 @@ module Ci
...
@@ -2,20 +2,15 @@ module Ci
class
CreateProjectService
class
CreateProjectService
include
Gitlab
::
Application
.
routes
.
url_helpers
include
Gitlab
::
Application
.
routes
.
url_helpers
def
execute
(
current_user
,
params
,
project_route
,
forked_project
=
nil
)
def
execute
(
current_user
,
params
,
forked_project
=
nil
)
@project
=
Ci
::
Project
.
parse
(
params
)
@project
=
Ci
::
Project
.
parse
(
params
)
Ci
::
Project
.
transaction
do
Ci
::
Project
.
transaction
do
@project
.
save!
@project
.
save!
data
=
{
token:
@project
.
token
,
project_url:
project_route
.
gsub
(
":project_id"
,
@project
.
id
.
to_s
),
}
gl_project
=
::
Project
.
find
(
@project
.
gitlab_id
)
gl_project
=
::
Project
.
find
(
@project
.
gitlab_id
)
gl_project
.
build_missing_services
gl_project
.
build_missing_services
gl_project
.
gitlab_ci_service
.
update_attributes
(
data
.
merge
(
active:
true
)
)
gl_project
.
gitlab_ci_service
.
update_attributes
(
active:
true
,
token:
@project
.
token
)
end
end
if
forked_project
if
forked_project
...
...
app/services/projects/fork_service.rb
View file @
a0c1a12d
...
@@ -18,7 +18,7 @@ module Projects
...
@@ -18,7 +18,7 @@ module Projects
if
new_project
.
persisted?
if
new_project
.
persisted?
if
@project
.
gitlab_ci?
if
@project
.
gitlab_ci?
ForkRegistrationWorker
.
perform_async
(
@project
.
id
,
new_project
.
id
,
@current_user
.
private_token
)
@project
.
gitlab_ci_service
.
fork_registration
(
new_project
,
@current_user
)
end
end
end
end
...
...
app/workers/fork_registration_worker.rb
deleted
100644 → 0
View file @
bdfe6b96
class
ForkRegistrationWorker
include
Sidekiq
::
Worker
sidekiq_options
queue: :default
def
perform
(
from_project_id
,
to_project_id
,
private_token
)
from_project
=
Project
.
find
(
from_project_id
)
to_project
=
Project
.
find
(
to_project_id
)
from_project
.
gitlab_ci_service
.
fork_registration
(
to_project
,
private_token
)
end
end
config/routes.rb
View file @
a0c1a12d
...
@@ -18,7 +18,6 @@ Gitlab::Application.routes.draw do
...
@@ -18,7 +18,6 @@ Gitlab::Application.routes.draw do
member
do
member
do
get
:status
,
to:
'projects#badge'
get
:status
,
to:
'projects#badge'
get
:integration
get
:integration
post
:build
post
:toggle_shared_runners
post
:toggle_shared_runners
get
:dumped_yaml
get
:dumped_yaml
end
end
...
...
doc/ci/api/README.md
View file @
a0c1a12d
...
@@ -6,7 +6,6 @@
...
@@ -6,7 +6,6 @@
-
[
Runners
](
runners.md
)
-
[
Runners
](
runners.md
)
-
[
Commits
](
commits.md
)
-
[
Commits
](
commits.md
)
-
[
Builds
](
builds.md
)
-
[
Builds
](
builds.md
)
-
[
Forks
](
forks.md
)
## Authentication
## Authentication
...
...
doc/ci/api/forks.md
deleted
100644 → 0
View file @
bdfe6b96
# Forks API
This API is intended to aid in the setup and configuration of
forked projects on Gitlab CI.
__Authentication is done by GitLab user token & GitLab project token__
## Forks
### Create fork for project
```
POST /ci/forks
```
Parameters:
project_id (required) - The ID of a project
project_token (requires) - Project token
private_token(required) - User private token
data (required) - GitLab project data (name_with_namespace, web_url, default_branch, ssh_url_to_repo)
features/steps/project/services.rb
View file @
a0c1a12d
...
@@ -26,13 +26,11 @@ class Spinach::Features::ProjectServices < Spinach::FeatureSteps
...
@@ -26,13 +26,11 @@ class Spinach::Features::ProjectServices < Spinach::FeatureSteps
step
'I fill gitlab-ci settings'
do
step
'I fill gitlab-ci settings'
do
check
'Active'
check
'Active'
fill_in
'Project url'
,
with:
'http://ci.gitlab.org/projects/3'
fill_in
'Token'
,
with:
'verySecret'
click_button
'Save'
click_button
'Save'
end
end
step
'I should see service settings saved'
do
step
'I should see service settings saved'
do
expect
(
find_field
(
'
Project url'
).
value
).
to
eq
'http://ci.gitlab.org/projects/3
'
expect
(
find_field
(
'
Active'
).
value
).
to
eq
'1
'
end
end
step
'I click hipchat service link'
do
step
'I click hipchat service link'
do
...
...
lib/ci/api/api.rb
View file @
a0c1a12d
...
@@ -36,7 +36,6 @@ module Ci
...
@@ -36,7 +36,6 @@ module Ci
mount
Commits
mount
Commits
mount
Runners
mount
Runners
mount
Projects
mount
Projects
mount
Forks
mount
Triggers
mount
Triggers
end
end
end
end
...
...
lib/ci/api/forks.rb
deleted
100644 → 0
View file @
bdfe6b96
module
Ci
module
API
class
Forks
<
Grape
::
API
resource
:forks
do
# Create a fork
#
# Parameters:
# project_id (required) - The ID of a project
# project_token (requires) - Project token
# private_token(required) - User private token
# data (required) - GitLab project data (name_with_namespace, web_url, default_branch, ssh_url_to_repo)
#
#
# Example Request:
# POST /forks
post
do
required_attributes!
[
:project_id
,
:data
,
:project_token
,
:private_token
]
project
=
Ci
::
Project
.
find_by!
(
gitlab_id:
params
[
:project_id
])
authenticate_project_token!
(
project
)
fork
=
Ci
::
CreateProjectService
.
new
.
execute
(
current_user
,
params
[
:data
],
Ci
::
RoutesHelper
.
ci_project_url
(
":project_id"
),
project
)
if
fork
present
fork
,
with:
Entities
::
Project
else
not_found!
end
end
end
end
end
end
spec/controllers/ci/projects_controller_spec.rb
View file @
a0c1a12d
...
@@ -5,49 +5,6 @@ describe Ci::ProjectsController do
...
@@ -5,49 +5,6 @@ describe Ci::ProjectsController do
@project
=
FactoryGirl
.
create
:ci_project
@project
=
FactoryGirl
.
create
:ci_project
end
end
describe
"POST #build"
do
it
'should respond 200 if params is ok'
do
post
:build
,
{
id:
@project
.
id
,
ref:
'master'
,
before:
'2aa371379db71ac89ae20843fcff3b3477cf1a1d'
,
after:
'1c8a9df454ef68c22c2a33cca8232bb50849e5c5'
,
token:
@project
.
token
,
ci_yaml_file:
gitlab_ci_yaml
,
commits:
[
{
message:
"Message"
}
]
}
expect
(
response
).
to
be_success
expect
(
response
.
code
).
to
eq
(
'201'
)
end
it
'should respond 400 if push about removed branch'
do
post
:build
,
{
id:
@project
.
id
,
ref:
'master'
,
before:
'2aa371379db71ac89ae20843fcff3b3477cf1a1d'
,
after:
'0000000000000000000000000000000000000000'
,
token:
@project
.
token
,
ci_yaml_file:
gitlab_ci_yaml
}
expect
(
response
).
not_to
be_success
expect
(
response
.
code
).
to
eq
(
'400'
)
end
it
'should respond 400 if some params missed'
do
post
:build
,
id:
@project
.
id
,
token:
@project
.
token
,
ci_yaml_file:
gitlab_ci_yaml
expect
(
response
).
not_to
be_success
expect
(
response
.
code
).
to
eq
(
'400'
)
end
it
'should respond 403 if token is wrong'
do
post
:build
,
id:
@project
.
id
,
token:
'invalid-token'
expect
(
response
).
not_to
be_success
expect
(
response
.
code
).
to
eq
(
'403'
)
end
end
describe
"POST /projects"
do
describe
"POST /projects"
do
let
(
:project_dump
)
{
OpenStruct
.
new
({
id:
@project
.
gitlab_id
})
}
let
(
:project_dump
)
{
OpenStruct
.
new
({
id:
@project
.
gitlab_id
})
}
...
...
spec/lib/gitlab/backend/grack_auth_spec.rb
View file @
a0c1a12d
...
@@ -180,7 +180,6 @@ describe Grack::Auth do
...
@@ -180,7 +180,6 @@ describe Grack::Auth do
gitlab_ci_service
=
project
.
build_gitlab_ci_service
gitlab_ci_service
=
project
.
build_gitlab_ci_service
gitlab_ci_service
.
active
=
true
gitlab_ci_service
.
active
=
true
gitlab_ci_service
.
token
=
token
gitlab_ci_service
.
token
=
token
gitlab_ci_service
.
project_url
=
"http://google.com"
gitlab_ci_service
.
save
gitlab_ci_service
.
save
env
[
"HTTP_AUTHORIZATION"
]
=
ActionController
::
HttpAuthentication
::
Basic
.
encode_credentials
(
"gitlab-ci-token"
,
token
)
env
[
"HTTP_AUTHORIZATION"
]
=
ActionController
::
HttpAuthentication
::
Basic
.
encode_credentials
(
"gitlab-ci-token"
,
token
)
...
...
spec/models/project_services/gitlab_ci_service_spec.rb
View file @
a0c1a12d
...
@@ -26,33 +26,6 @@ describe GitlabCiService do
...
@@ -26,33 +26,6 @@ describe GitlabCiService do
it
{
is_expected
.
to
have_one
(
:service_hook
)
}
it
{
is_expected
.
to
have_one
(
:service_hook
)
}
end
end
describe
'validations'
do
context
'active'
do
before
{
allow
(
subject
).
to
receive
(
:activated?
).
and_return
(
true
)
}
it
{
is_expected
.
to
validate_presence_of
(
:token
)
}
it
{
is_expected
.
to
validate_presence_of
(
:project_url
)
}
it
{
is_expected
.
to
allow_value
(
'ewf9843kdnfdfs89234n'
).
for
(
:token
)
}
it
{
is_expected
.
to
allow_value
(
'http://ci.example.com/project/1'
).
for
(
:project_url
)
}
it
{
is_expected
.
not_to
allow_value
(
'token with spaces'
).
for
(
:token
)
}
it
{
is_expected
.
not_to
allow_value
(
'token/with%spaces'
).
for
(
:token
)
}
it
{
is_expected
.
not_to
allow_value
(
'this is not url'
).
for
(
:project_url
)
}
it
{
is_expected
.
not_to
allow_value
(
'http//noturl'
).
for
(
:project_url
)
}
it
{
is_expected
.
not_to
allow_value
(
'ftp://ci.example.com/projects/3'
).
for
(
:project_url
)
}
end
context
'inactive'
do
before
{
allow
(
subject
).
to
receive
(
:activated?
).
and_return
(
false
)
}
it
{
is_expected
.
not_to
validate_presence_of
(
:token
)
}
it
{
is_expected
.
not_to
validate_presence_of
(
:project_url
)
}
it
{
is_expected
.
to
allow_value
(
'ewf9843kdnfdfs89234n'
).
for
(
:token
)
}
it
{
is_expected
.
to
allow_value
(
'http://ci.example.com/project/1'
).
for
(
:project_url
)
}
it
{
is_expected
.
to
allow_value
(
'token with spaces'
).
for
(
:token
)
}
it
{
is_expected
.
to
allow_value
(
'ftp://ci.example.com/projects/3'
).
for
(
:project_url
)
}
end
end
describe
'commits methods'
do
describe
'commits methods'
do
before
do
before
do
@ci_project
=
create
(
:ci_project
)
@ci_project
=
create
(
:ci_project
)
...
@@ -77,8 +50,6 @@ describe GitlabCiService do
...
@@ -77,8 +50,6 @@ describe GitlabCiService do
it
"calls ci_yaml_file"
do
it
"calls ci_yaml_file"
do
service_hook
=
double
service_hook
=
double
expect
(
service_hook
).
to
receive
(
:execute
)
expect
(
@service
).
to
receive
(
:service_hook
).
and_return
(
service_hook
)
expect
(
@service
).
to
receive
(
:ci_yaml_file
).
with
(
push_sample_data
[
:checkout_sha
])
expect
(
@service
).
to
receive
(
:ci_yaml_file
).
with
(
push_sample_data
[
:checkout_sha
])
@service
.
execute
(
push_sample_data
)
@service
.
execute
(
push_sample_data
)
...
@@ -88,7 +59,7 @@ describe GitlabCiService do
...
@@ -88,7 +59,7 @@ describe GitlabCiService do
describe
"Fork registration"
do
describe
"Fork registration"
do
before
do
before
do
@old_project
=
create
(
:
empty_project
)
@old_project
=
create
(
:
ci_project
).
gl_project
@project
=
create
(
:empty_project
)
@project
=
create
(
:empty_project
)
@user
=
create
(
:user
)
@user
=
create
(
:user
)
...
@@ -101,9 +72,9 @@ describe GitlabCiService do
...
@@ -101,9 +72,9 @@ describe GitlabCiService do
)
)
end
end
it
"
performs http reuquest to ci
"
do
it
"
creates fork on CI
"
do
stub_request
(
:post
,
"http://ci.gitlab.org/api/v1/forks"
)
expect_any_instance_of
(
Ci
::
CreateProjectService
).
to
receive
(
:execute
)
@service
.
fork_registration
(
@project
,
@user
.
private_token
)
@service
.
fork_registration
(
@project
,
@user
)
end
end
end
end
end
end
spec/requests/api/projects_spec.rb
View file @
a0c1a12d
...
@@ -89,7 +89,7 @@ describe API::API, api: true do
...
@@ -89,7 +89,7 @@ describe API::API, api: true do
it
'returns projects in the correct order when ci_enabled_first parameter is passed'
do
it
'returns projects in the correct order when ci_enabled_first parameter is passed'
do
[
project
,
project2
,
project3
].
each
{
|
project
|
project
.
build_missing_services
}
[
project
,
project2
,
project3
].
each
{
|
project
|
project
.
build_missing_services
}
project2
.
gitlab_ci_service
.
update
(
active:
true
,
token:
"token"
,
project_url:
"http://ci.example.com/projects/1"
)
project2
.
gitlab_ci_service
.
update
(
active:
true
,
token:
"token"
)
get
api
(
'/projects'
,
user
),
{
ci_enabled_first:
'true'
}
get
api
(
'/projects'
,
user
),
{
ci_enabled_first:
'true'
}
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
...
...
spec/requests/api/services_spec.rb
View file @
a0c1a12d
...
@@ -17,9 +17,9 @@ describe API::API, api: true do
...
@@ -17,9 +17,9 @@ describe API::API, api: true do
it
"should return if required fields missing"
do
it
"should return if required fields missing"
do
attrs
=
service_attrs
attrs
=
service_attrs
required_attributes
=
service_attrs_list
.
select
do
|
attr
|
required_attributes
=
service_attrs_list
.
select
do
|
attr
|
service_klass
.
validators_on
(
attr
).
any?
do
|
v
|
service_klass
.
validators_on
(
attr
).
any?
do
|
v
|
v
.
class
==
ActiveRecord
::
Validations
::
PresenceValidator
v
.
class
==
ActiveRecord
::
Validations
::
PresenceValidator
end
end
end
end
...
...
spec/requests/ci/api/forks_spec.rb
deleted
100644 → 0
View file @
bdfe6b96
require
'spec_helper'
describe
Ci
::
API
::
API
do
include
ApiHelpers
let
(
:project
)
{
FactoryGirl
.
create
(
:ci_project
)
}
let
(
:private_token
)
{
create
(
:user
).
private_token
}
let
(
:options
)
do
{
private_token:
private_token
,
url:
GitlabCi
.
config
.
gitlab_ci
.
url
}
end
before
do
stub_gitlab_calls
end
describe
"POST /forks"
do
let
(
:project_info
)
do
{
project_id:
project
.
gitlab_id
,
project_token:
project
.
token
,
data:
{
id:
create
(
:empty_project
).
id
,
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"
}
}
end
context
"with valid info"
do
before
do
options
.
merge!
(
project_info
)
end
it
"should create a project with valid data"
do
post
ci_api
(
"/forks"
),
options
expect
(
response
.
status
).
to
eq
(
201
)
expect
(
json_response
[
'name'
]).
to
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
ci_api
(
"/forks"
),
options
expect
(
response
.
status
).
to
eq
(
400
)
end
end
end
end
spec/services/ci/create_project_service_spec.rb
View file @
a0c1a12d
...
@@ -7,7 +7,7 @@ describe Ci::CreateProjectService do
...
@@ -7,7 +7,7 @@ describe Ci::CreateProjectService do
describe
:execute
do
describe
:execute
do
context
'valid params'
do
context
'valid params'
do
subject
{
service
.
execute
(
current_user
,
project
,
'http://localhost/projects/:project_id'
)
}
subject
{
service
.
execute
(
current_user
,
project
)
}
it
{
is_expected
.
to
be_kind_of
(
Ci
::
Project
)
}
it
{
is_expected
.
to
be_kind_of
(
Ci
::
Project
)
}
it
{
is_expected
.
to
be_persisted
}
it
{
is_expected
.
to
be_persisted
}
...
@@ -24,7 +24,7 @@ describe Ci::CreateProjectService do
...
@@ -24,7 +24,7 @@ describe Ci::CreateProjectService do
FactoryGirl
.
create
(
:ci_project
,
shared_runners_enabled:
true
,
public:
true
,
allow_git_fetch:
true
)
FactoryGirl
.
create
(
:ci_project
,
shared_runners_enabled:
true
,
public:
true
,
allow_git_fetch:
true
)
end
end
subject
{
service
.
execute
(
current_user
,
project
,
'http://localhost/projects/:project_id'
,
ci_origin_project
)
}
subject
{
service
.
execute
(
current_user
,
project
,
ci_origin_project
)
}
it
"uses project as a template for settings and jobs"
do
it
"uses project as a template for settings and jobs"
do
expect
(
subject
.
shared_runners_enabled
).
to
be_truthy
expect
(
subject
.
shared_runners_enabled
).
to
be_truthy
...
...
spec/services/projects/fork_service_spec.rb
View file @
a0c1a12d
...
@@ -44,10 +44,11 @@ describe Projects::ForkService do
...
@@ -44,10 +44,11 @@ describe Projects::ForkService do
context
'GitLab CI is enabled'
do
context
'GitLab CI is enabled'
do
it
"calls fork registrator for CI"
do
it
"calls fork registrator for CI"
do
create
(
:ci_project
,
gl_project:
@from_project
)
@from_project
.
build_missing_services
@from_project
.
build_missing_services
@from_project
.
gitlab_ci_service
.
update_attributes
(
active:
true
)
@from_project
.
gitlab_ci_service
.
update_attributes
(
active:
true
)
expect
(
ForkRegistrationWorker
).
to
receive
(
:perform_async
)
expect
_any_instance_of
(
Ci
::
CreateProjectService
).
to
receive
(
:execute
)
fork_project
(
@from_project
,
@to_user
)
fork_project
(
@from_project
,
@to_user
)
end
end
...
...
spec/workers/fork_registration_worker_spec.rb
deleted
100644 → 0
View file @
bdfe6b96
require
'spec_helper'
describe
ForkRegistrationWorker
do
context
"as a resque worker"
do
it
"reponds to #perform"
do
expect
(
ForkRegistrationWorker
.
new
).
to
respond_to
(
:perform
)
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment