BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
e53a56ac
Commit
e53a56ac
authored
Nov 12, 2015
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix broken tests
parent
6384c757
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
43 additions
and
113 deletions
+43
-113
project.rb
app/models/ci/project.rb
+0
-24
project_spec.rb
spec/models/ci/project_spec.rb
+2
-14
builds_spec.rb
spec/requests/ci/api/builds_spec.rb
+2
-2
commits_spec.rb
spec/requests/ci/api/commits_spec.rb
+1
-1
projects_spec.rb
spec/requests/ci/api/projects_spec.rb
+36
-70
triggers_spec.rb
spec/requests/ci/api/triggers_spec.rb
+1
-1
create_trigger_request_service_spec.rb
spec/services/ci/create_trigger_request_service_spec.rb
+1
-1
No files found.
app/models/ci/project.rb
View file @
e53a56ac
...
...
@@ -66,30 +66,6 @@ module Ci
class
<<
self
include
Ci
::
CurrentSettings
def
base_build_script
<<-
eos
git submodule update --init
ls -la
eos
end
def
parse
(
project
)
params
=
{
gitlab_id:
project
.
id
,
default_ref:
project
.
default_branch
||
'master'
,
email_add_pusher:
current_application_settings
.
add_pusher
,
email_only_broken_builds:
current_application_settings
.
all_broken_builds
,
}
project
=
Ci
::
Project
.
new
(
params
)
project
.
build_missing_services
project
end
def
already_added?
(
project
)
where
(
gitlab_id:
project
.
id
).
any?
end
def
unassigned
(
runner
)
joins
(
"LEFT JOIN
#{
Ci
::
RunnerProject
.
table_name
}
ON
#{
Ci
::
RunnerProject
.
table_name
}
.project_id =
#{
Ci
::
Project
.
table_name
}
.id "
\
"AND
#{
Ci
::
RunnerProject
.
table_name
}
.runner_id =
#{
runner
.
id
}
"
).
...
...
spec/models/ci/project_spec.rb
View file @
e53a56ac
...
...
@@ -28,8 +28,8 @@
require
'spec_helper'
describe
Ci
::
Project
do
let
(
:
gl_project
)
{
FactoryGirl
.
create
:empty
_project
}
let
(
:
project
)
{
FactoryGirl
.
create
:ci_project
,
gl_project:
gl_project
}
let
(
:
project
)
{
FactoryGirl
.
create
:ci
_project
}
let
(
:
gl_project
)
{
project
.
gl_project
}
subject
{
project
}
it
{
is_expected
.
to
have_many
(
:runner_projects
)
}
...
...
@@ -194,18 +194,6 @@ describe Ci::Project do
end
end
describe
'Project.parse'
do
let
(
:project
)
{
FactoryGirl
.
create
:project
}
subject
{
Ci
::
Project
.
parse
(
project
)
}
it
{
is_expected
.
to
be_valid
}
it
{
is_expected
.
to
be_kind_of
(
Ci
::
Project
)
}
it
{
expect
(
subject
.
name
).
to
eq
(
project
.
name_with_namespace
)
}
it
{
expect
(
subject
.
gitlab_id
).
to
eq
(
project
.
id
)
}
it
{
expect
(
subject
.
gitlab_url
).
to
eq
(
project
.
web_url
)
}
end
describe
:repo_url_with_auth
do
let
(
:project
)
{
FactoryGirl
.
create
:ci_project
}
subject
{
project
.
repo_url_with_auth
}
...
...
spec/requests/ci/api/builds_spec.rb
View file @
e53a56ac
...
...
@@ -5,7 +5,7 @@ describe Ci::API::API do
let
(
:runner
)
{
FactoryGirl
.
create
(
:ci_runner
,
tag_list:
[
"mysql"
,
"ruby"
])
}
let
(
:project
)
{
FactoryGirl
.
create
(
:ci_project
)
}
let
(
:gl_project
)
{
FactoryGirl
.
create
(
:empty_project
,
gitlab_ci_project:
project
)
}
let
(
:gl_project
)
{
project
.
gl_project
}
before
do
stub_ci_commit_to_return_yaml_file
...
...
@@ -14,7 +14,7 @@ describe Ci::API::API do
describe
"Builds API for runners"
do
let
(
:shared_runner
)
{
FactoryGirl
.
create
(
:ci_runner
,
token:
"SharedRunner"
)
}
let
(
:shared_project
)
{
FactoryGirl
.
create
(
:ci_project
,
name:
"SharedProject"
)
}
let
(
:shared_gl_project
)
{
FactoryGirl
.
create
(
:empty_project
,
gitlab_ci_project:
shared_project
)
}
let
(
:shared_gl_project
)
{
shared_project
.
gl_project
}
before
do
FactoryGirl
.
create
:ci_runner_project
,
project_id:
project
.
id
,
runner_id:
runner
.
id
...
...
spec/requests/ci/api/commits_spec.rb
View file @
e53a56ac
...
...
@@ -4,7 +4,7 @@ describe Ci::API::API, 'Commits' do
include
ApiHelpers
let
(
:project
)
{
FactoryGirl
.
create
(
:ci_project
)
}
let
(
:gl_project
)
{
FactoryGirl
.
create
(
:empty_project
,
gitlab_ci_project:
project
)
}
let
(
:gl_project
)
{
project
.
gl_project
}
let
(
:commit
)
{
FactoryGirl
.
create
(
:ci_commit
,
gl_project:
gl_project
)
}
let
(
:options
)
do
...
...
spec/requests/ci/api/projects_spec.rb
View file @
e53a56ac
...
...
@@ -41,8 +41,8 @@ describe Ci::API::API do
describe
"GET /projects/owned"
do
let!
(
:gl_project1
)
{
FactoryGirl
.
create
(
:empty_project
,
namespace:
user
.
namespace
)}
let!
(
:gl_project2
)
{
FactoryGirl
.
create
(
:empty_project
,
namespace:
user
.
namespace
)}
let!
(
:project1
)
{
FactoryGirl
.
create
(
:ci_project
,
gl_project:
gl_project1
)
}
let!
(
:project2
)
{
FactoryGirl
.
create
(
:ci_project
,
gl_project:
gl_project2
)
}
let!
(
:project1
)
{
gl_project1
.
ensure_gitlab_ci_project
}
let!
(
:project2
)
{
gl_project2
.
ensure_gitlab_ci_project
}
before
do
project1
.
gl_project
.
team
<<
[
user
,
:developer
]
...
...
@@ -180,87 +180,53 @@ describe Ci::API::API do
end
end
describe
"POST /projects"
do
let
(
:gl_project
)
{
FactoryGirl
.
create
:empty_project
}
let
(
:project_info
)
do
{
gitlab_id:
gl_project
.
id
}
end
let
(
:invalid_project_info
)
{
{}
}
describe
"POST /projects/:id/runners/:id"
do
let
(
:project
)
{
FactoryGirl
.
create
(
:ci_project
)
}
let
(
:runner
)
{
FactoryGirl
.
create
(
:ci_runner
)
}
context
"with valid project info
"
do
before
do
options
.
merge!
(
project_info
)
e
nd
it
"should add the project to the runner
"
do
project
.
gl_project
.
team
<<
[
user
,
:master
]
post
ci_api
(
"/projects/
#{
project
.
id
}
/runners/
#{
runner
.
id
}
"
),
options
e
xpect
(
response
.
status
).
to
eq
(
201
)
it
"should create a project with valid data"
do
post
ci_api
(
"/projects"
),
options
expect
(
response
.
status
).
to
eq
(
201
)
expect
(
json_response
[
'name'
]).
to
eq
(
gl_project
.
name_with_namespace
)
end
project
.
reload
expect
(
project
.
runners
.
first
.
id
).
to
eq
(
runner
.
id
)
end
context
"with invalid project info"
do
before
do
options
.
merge!
(
invalid_project_info
)
end
it
"should fail if it tries to link a non-existing project or runner"
do
post
ci_api
(
"/projects/
#{
project
.
id
}
/runners/non-existing"
),
options
expect
(
response
.
status
).
to
eq
(
404
)
it
"should error with invalid data"
do
post
ci_api
(
"/projects"
),
options
expect
(
response
.
status
).
to
eq
(
400
)
end
post
ci_api
(
"/projects/non-existing/runners/
#{
runner
.
id
}
"
),
options
expect
(
response
.
status
).
to
eq
(
404
)
end
describe
"POST /projects/:id/runners/:id"
do
let
(
:project
)
{
FactoryGirl
.
create
(
:ci_project
)
}
let
(
:runner
)
{
FactoryGirl
.
create
(
:ci_runner
)
}
it
"should add the project to the runner"
do
project
.
gl_project
.
team
<<
[
user
,
:master
]
post
ci_api
(
"/projects/
#{
project
.
id
}
/runners/
#{
runner
.
id
}
"
),
options
expect
(
response
.
status
).
to
eq
(
201
)
project
.
reload
expect
(
project
.
runners
.
first
.
id
).
to
eq
(
runner
.
id
)
end
it
"should fail if it tries to link a non-existing project or runner"
do
post
ci_api
(
"/projects/
#{
project
.
id
}
/runners/non-existing"
),
options
expect
(
response
.
status
).
to
eq
(
404
)
post
ci_api
(
"/projects/non-existing/runners/
#{
runner
.
id
}
"
),
options
expect
(
response
.
status
).
to
eq
(
404
)
end
it
"non-manager is not authorized"
do
allow_any_instance_of
(
User
).
to
receive
(
:can_manage_project?
).
and_return
(
false
)
post
ci_api
(
"/projects/
#{
project
.
id
}
/runners/
#{
runner
.
id
}
"
),
options
expect
(
response
.
status
).
to
eq
(
401
)
end
it
"non-manager is not authorized"
do
allow_any_instance_of
(
User
).
to
receive
(
:can_manage_project?
).
and_return
(
false
)
post
ci_api
(
"/projects/
#{
project
.
id
}
/runners/
#{
runner
.
id
}
"
),
options
expect
(
response
.
status
).
to
eq
(
401
)
end
end
describe
"DELETE /projects/:id/runners/:id"
do
let
(
:project
)
{
FactoryGirl
.
create
(
:ci_project
)
}
let
(
:runner
)
{
FactoryGirl
.
create
(
:ci_runner
)
}
describe
"DELETE /projects/:id/runners/:id"
do
let
(
:project
)
{
FactoryGirl
.
create
(
:ci_project
)
}
let
(
:runner
)
{
FactoryGirl
.
create
(
:ci_runner
)
}
it
"should remove the project from the runner"
do
project
.
gl_project
.
team
<<
[
user
,
:master
]
post
ci_api
(
"/projects/
#{
project
.
id
}
/runners/
#{
runner
.
id
}
"
),
options
it
"should remove the project from the runner"
do
project
.
gl_project
.
team
<<
[
user
,
:master
]
post
ci_api
(
"/projects/
#{
project
.
id
}
/runners/
#{
runner
.
id
}
"
),
options
expect
(
project
.
runners
).
to
be_present
delete
ci_api
(
"/projects/
#{
project
.
id
}
/runners/
#{
runner
.
id
}
"
),
options
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
project
.
runners
).
to
be_present
delete
ci_api
(
"/projects/
#{
project
.
id
}
/runners/
#{
runner
.
id
}
"
),
options
expect
(
response
.
status
).
to
eq
(
200
)
project
.
reload
expect
(
project
.
runners
).
to
be_empty
end
project
.
reload
expect
(
project
.
runners
).
to
be_empty
end
it
"non-manager is not authorized"
do
delete
ci_api
(
"/projects/
#{
project
.
id
}
/runners/
#{
runner
.
id
}
"
),
options
expect
(
response
.
status
).
to
eq
(
401
)
end
it
"non-manager is not authorized"
do
delete
ci_api
(
"/projects/
#{
project
.
id
}
/runners/
#{
runner
.
id
}
"
),
options
expect
(
response
.
status
).
to
eq
(
401
)
end
end
end
spec/requests/ci/api/triggers_spec.rb
View file @
e53a56ac
...
...
@@ -6,7 +6,7 @@ describe Ci::API::API do
describe
'POST /projects/:project_id/refs/:ref/trigger'
do
let!
(
:trigger_token
)
{
'secure token'
}
let!
(
:gl_project
)
{
FactoryGirl
.
create
(
:project
)
}
let!
(
:project
)
{
FactoryGirl
.
create
(
:ci_project
,
gl_project:
gl_project
)
}
let!
(
:project
)
{
gl_project
.
ensure_gitlab_ci_project
}
let!
(
:project2
)
{
FactoryGirl
.
create
(
:ci_project
)
}
let!
(
:trigger
)
{
FactoryGirl
.
create
(
:ci_trigger
,
project:
project
,
token:
trigger_token
)
}
let
(
:options
)
do
...
...
spec/services/ci/create_trigger_request_service_spec.rb
View file @
e53a56ac
...
...
@@ -3,7 +3,7 @@ require 'spec_helper'
describe
Ci
::
CreateTriggerRequestService
do
let
(
:service
)
{
Ci
::
CreateTriggerRequestService
.
new
}
let
(
:gl_project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:ci_project
,
gl_project:
gl_project
)
}
let
(
:project
)
{
gl_project
.
ensure_gitlab_ci_project
}
let
(
:trigger
)
{
create
(
:ci_trigger
,
project:
project
)
}
before
do
...
...
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