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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
37fe73c3
Commit
37fe73c3
authored
Nov 15, 2015
by
Robert Speicher
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'ce/master' into ce-to-ee
parents
6afca450
aec9f211
Changes
82
Hide whitespace changes
Inline
Side-by-side
Showing
82 changed files
with
562 additions
and
279 deletions
+562
-279
app/assets/stylesheets/framework/header.scss
app/assets/stylesheets/framework/header.scss
+4
-0
app/controllers/admin/application_controller.rb
app/controllers/admin/application_controller.rb
+6
-0
app/controllers/admin/impersonation_controller.rb
app/controllers/admin/impersonation_controller.rb
+32
-0
app/controllers/admin/users_controller.rb
app/controllers/admin/users_controller.rb
+0
-6
app/controllers/projects/application_controller.rb
app/controllers/projects/application_controller.rb
+1
-1
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+26
-5
app/helpers/projects_helper.rb
app/helpers/projects_helper.rb
+1
-1
app/models/application_setting.rb
app/models/application_setting.rb
+4
-0
app/models/ci/application_setting.rb
app/models/ci/application_setting.rb
+1
-1
app/models/ci/build.rb
app/models/ci/build.rb
+11
-3
app/models/ci/commit.rb
app/models/ci/commit.rb
+13
-12
app/models/ci/event.rb
app/models/ci/event.rb
+1
-1
app/models/ci/project.rb
app/models/ci/project.rb
+2
-26
app/models/ci/runner.rb
app/models/ci/runner.rb
+1
-1
app/models/ci/runner_project.rb
app/models/ci/runner_project.rb
+1
-1
app/models/ci/service.rb
app/models/ci/service.rb
+1
-1
app/models/ci/trigger.rb
app/models/ci/trigger.rb
+1
-1
app/models/ci/trigger_request.rb
app/models/ci/trigger_request.rb
+1
-1
app/models/ci/variable.rb
app/models/ci/variable.rb
+1
-1
app/models/ci/web_hook.rb
app/models/ci/web_hook.rb
+1
-1
app/models/commit_status.rb
app/models/commit_status.rb
+33
-0
app/models/generic_commit_status.rb
app/models/generic_commit_status.rb
+33
-0
app/models/group.rb
app/models/group.rb
+1
-0
app/models/hooks/project_hook.rb
app/models/hooks/project_hook.rb
+13
-12
app/models/hooks/service_hook.rb
app/models/hooks/service_hook.rb
+13
-12
app/models/hooks/system_hook.rb
app/models/hooks/system_hook.rb
+13
-12
app/models/hooks/web_hook.rb
app/models/hooks/web_hook.rb
+13
-12
app/models/label.rb
app/models/label.rb
+1
-0
app/models/merge_request.rb
app/models/merge_request.rb
+1
-0
app/models/namespace.rb
app/models/namespace.rb
+1
-0
app/models/project.rb
app/models/project.rb
+17
-6
app/models/project_services/ci/hip_chat_service.rb
app/models/project_services/ci/hip_chat_service.rb
+1
-1
app/models/project_services/ci/mail_service.rb
app/models/project_services/ci/mail_service.rb
+1
-1
app/models/project_services/ci/slack_service.rb
app/models/project_services/ci/slack_service.rb
+1
-1
app/models/release.rb
app/models/release.rb
+12
-0
app/models/user.rb
app/models/user.rb
+1
-0
app/services/git_push_service.rb
app/services/git_push_service.rb
+1
-1
app/services/projects/fork_service.rb
app/services/projects/fork_service.rb
+1
-1
app/views/admin/users/_head.html.haml
app/views/admin/users/_head.html.haml
+1
-1
app/views/layouts/header/_default.html.haml
app/views/layouts/header/_default.html.haml
+4
-0
app/views/layouts/nav/_project_settings.html.haml
app/views/layouts/nav/_project_settings.html.haml
+1
-1
app/views/projects/edit.html.haml
app/views/projects/edit.html.haml
+10
-1
app/views/projects/graphs/_head.html.haml
app/views/projects/graphs/_head.html.haml
+1
-1
config/gitlab.yml.example
config/gitlab.yml.example
+1
-0
config/initializers/1_settings.rb
config/initializers/1_settings.rb
+1
-0
config/routes.rb
config/routes.rb
+3
-1
doc/api/projects.md
doc/api/projects.md
+6
-0
lib/api/entities.rb
lib/api/entities.rb
+1
-1
lib/api/projects.rb
lib/api/projects.rb
+6
-0
spec/controllers/admin/users_controller_spec.rb
spec/controllers/admin/users_controller_spec.rb
+0
-15
spec/factories/ci/projects.rb
spec/factories/ci/projects.rb
+8
-4
spec/factories/labels.rb
spec/factories/labels.rb
+1
-0
spec/factories/merge_requests.rb
spec/factories/merge_requests.rb
+1
-0
spec/factories/releases.rb
spec/factories/releases.rb
+12
-0
spec/features/admin/admin_users_spec.rb
spec/features/admin/admin_users_spec.rb
+38
-12
spec/models/application_setting_spec.rb
spec/models/application_setting_spec.rb
+4
-0
spec/models/ci/commit_spec.rb
spec/models/ci/commit_spec.rb
+13
-12
spec/models/ci/project_spec.rb
spec/models/ci/project_spec.rb
+4
-16
spec/models/ci/runner_project_spec.rb
spec/models/ci/runner_project_spec.rb
+1
-1
spec/models/ci/runner_spec.rb
spec/models/ci/runner_spec.rb
+1
-1
spec/models/ci/service_spec.rb
spec/models/ci/service_spec.rb
+1
-1
spec/models/ci/trigger_spec.rb
spec/models/ci/trigger_spec.rb
+12
-0
spec/models/ci/variable_spec.rb
spec/models/ci/variable_spec.rb
+1
-1
spec/models/ci/web_hook_spec.rb
spec/models/ci/web_hook_spec.rb
+1
-1
spec/models/commit_status_spec.rb
spec/models/commit_status_spec.rb
+33
-0
spec/models/generic_commit_status_spec.rb
spec/models/generic_commit_status_spec.rb
+33
-0
spec/models/group_spec.rb
spec/models/group_spec.rb
+1
-0
spec/models/label_spec.rb
spec/models/label_spec.rb
+1
-0
spec/models/merge_request_spec.rb
spec/models/merge_request_spec.rb
+1
-0
spec/models/namespace_spec.rb
spec/models/namespace_spec.rb
+1
-0
spec/models/project_spec.rb
spec/models/project_spec.rb
+6
-3
spec/models/release_spec.rb
spec/models/release_spec.rb
+12
-0
spec/models/user_spec.rb
spec/models/user_spec.rb
+2
-0
spec/requests/api/projects_spec.rb
spec/requests/api/projects_spec.rb
+5
-2
spec/requests/api/services_spec.rb
spec/requests/api/services_spec.rb
+1
-0
spec/requests/ci/api/builds_spec.rb
spec/requests/ci/api/builds_spec.rb
+5
-8
spec/requests/ci/api/commits_spec.rb
spec/requests/ci/api/commits_spec.rb
+1
-1
spec/requests/ci/api/projects_spec.rb
spec/requests/ci/api/projects_spec.rb
+36
-70
spec/requests/ci/api/triggers_spec.rb
spec/requests/ci/api/triggers_spec.rb
+1
-1
spec/services/ci/create_trigger_request_service_spec.rb
spec/services/ci/create_trigger_request_service_spec.rb
+1
-1
spec/services/projects/create_service_spec.rb
spec/services/projects/create_service_spec.rb
+22
-0
spec/services/projects/fork_service_spec.rb
spec/services/projects/fork_service_spec.rb
+1
-1
No files found.
app/assets/stylesheets/framework/header.scss
View file @
37fe73c3
...
...
@@ -118,6 +118,10 @@ header {
}
}
}
.impersonation
i
{
color
:
$red-normal
;
}
}
@mixin
collapsed-header
{
...
...
app/controllers/admin/application_controller.rb
View file @
37fe73c3
...
...
@@ -8,4 +8,10 @@ class Admin::ApplicationController < ApplicationController
def
authenticate_admin!
return
render_404
unless
current_user
.
is_admin?
end
def
authorize_impersonator!
if
session
[
:impersonator_id
]
User
.
find_by!
(
username:
session
[
:impersonator_id
]).
admin?
end
end
end
app/controllers/admin/impersonation_controller.rb
0 → 100644
View file @
37fe73c3
class
Admin::ImpersonationController
<
Admin
::
ApplicationController
skip_before_action
:authenticate_admin!
,
only: :destroy
before_action
:user
before_action
:authorize_impersonator!
def
create
session
[
:impersonator_id
]
=
current_user
.
username
session
[
:impersonator_return_to
]
=
request
.
env
[
'HTTP_REFERER'
]
warden
.
set_user
(
user
,
scope:
'user'
)
flash
[
:alert
]
=
"You are impersonating
#{
user
.
username
}
."
redirect_to
root_path
end
def
destroy
redirect
=
session
[
:impersonator_return_to
]
warden
.
set_user
(
user
,
scope:
'user'
)
session
[
:impersonator_return_to
]
=
nil
session
[
:impersonator_id
]
=
nil
redirect_to
redirect
||
root_path
end
def
user
@user
||=
User
.
find_by!
(
username:
params
[
:id
]
||
session
[
:impersonator_id
])
end
end
app/controllers/admin/users_controller.rb
View file @
37fe73c3
...
...
@@ -63,12 +63,6 @@ class Admin::UsersController < Admin::ApplicationController
end
end
def
login_as
sign_in
(
user
)
flash
[
:alert
]
=
"Logged in as
#{
user
.
username
}
"
redirect_to
root_path
end
def
disable_two_factor
user
.
disable_two_factor!
redirect_to
admin_user_path
(
user
),
...
...
app/controllers/projects/application_controller.rb
View file @
37fe73c3
...
...
@@ -29,7 +29,7 @@ class Projects::ApplicationController < ApplicationController
private
def
ci_enabled
return
render_404
unless
@project
.
gitlab_ci
?
return
render_404
unless
@project
.
builds_enabled
?
end
def
ci_project
...
...
app/controllers/projects_controller.rb
View file @
37fe73c3
...
...
@@ -211,11 +211,32 @@ class ProjectsController < ApplicationController
def
project_params
params
.
require
(
:project
).
permit
(
:name
,
:path
,
:description
,
:issues_tracker
,
:tag_list
,
:issues_enabled
,
:merge_requests_enabled
,
:snippets_enabled
,
:issues_tracker_id
,
:default_branch
,
:wiki_enabled
,
:issues_template
,
:merge_requests_template
,
:visibility_level
,
:merge_requests_rebase_enabled
,
:import_url
,
:last_activity_at
,
:namespace_id
,
:avatar
,
:approvals_before_merge
,
:approver_ids
,
:reset_approvals_on_push
,
:merge_requests_ff_only_enabled
:avatar
,
:builds_enabled
,
:default_branch
,
:description
,
:import_url
,
:issues_enabled
,
:issues_tracker
,
:issues_tracker_id
,
:last_activity_at
,
:merge_requests_enabled
,
:name
,
:namespace_id
,
:path
,
:snippets_enabled
,
:tag_list
,
:visibility_level
,
:wiki_enabled
,
# EE-only
:approvals_before_merge
,
:approver_ids
,
:issues_template
,
:merge_requests_ff_only_enabled
,
:merge_requests_rebase_enabled
,
:merge_requests_template
,
:reset_approvals_on_push
)
end
...
...
app/helpers/projects_helper.rb
View file @
37fe73c3
...
...
@@ -117,7 +117,7 @@ module ProjectsHelper
nav_tabs
<<
:merge_requests
end
if
project
.
gitlab_ci
?
&&
can?
(
current_user
,
:read_build
,
project
)
if
project
.
builds_enabled
?
&&
can?
(
current_user
,
:read_build
,
project
)
nav_tabs
<<
:builds
end
...
...
app/models/application_setting.rb
View file @
37fe73c3
...
...
@@ -24,6 +24,10 @@
# after_sign_out_path :string(255)
# session_expire_delay :integer default(10080), not null
# import_sources :text
# help_page_text :text
# admin_notification_email :string(255)
# shared_runners_enabled :boolean default(TRUE), not null
# max_artifacts_size :integer default(100), not null
#
class
ApplicationSetting
<
ActiveRecord
::
Base
...
...
app/models/ci/application_setting.rb
View file @
37fe73c3
# == Schema Information
#
# Table name: application_settings
# Table name:
ci_
application_settings
#
# id :integer not null, primary key
# all_broken_builds :boolean
...
...
app/models/ci/build.rb
View file @
37fe73c3
# == Schema Information
#
# Table name: builds
# Table name:
ci_
builds
#
# id :integer not null, primary key
# project_id :integer
...
...
@@ -11,16 +11,24 @@
# updated_at :datetime
# started_at :datetime
# runner_id :integer
# commit_id :integer
# coverage :float
# commit_id :integer
# commands :text
# job_id :integer
# name :string(255)
# deploy :boolean default(FALSE)
# options :text
# allow_failure :boolean default(FALSE), not null
# stage :string(255)
# deploy :boolean default(FALSE)
# trigger_request_id :integer
# stage_idx :integer
# tag :boolean
# ref :string(255)
# user_id :integer
# type :string(255)
# target_url :string(255)
# description :string(255)
# artifacts_file :text
#
module
Ci
...
...
app/models/ci/commit.rb
View file @
37fe73c3
# == Schema Information
#
# Table name: commits
# Table name: c
i_c
ommits
#
# id :integer not null, primary key
# project_id :integer
# ref :string(255)
# sha :string(255)
# before_sha :string(255)
# push_data :text
# created_at :datetime
# updated_at :datetime
# tag :boolean default(FALSE)
# yaml_errors :text
# committed_at :datetime
# id :integer not null, primary key
# project_id :integer
# ref :string(255)
# sha :string(255)
# before_sha :string(255)
# push_data :text
# created_at :datetime
# updated_at :datetime
# tag :boolean default(FALSE)
# yaml_errors :text
# committed_at :datetime
# gl_project_id :integer
#
module
Ci
...
...
app/models/ci/event.rb
View file @
37fe73c3
# == Schema Information
#
# Table name: events
# Table name:
ci_
events
#
# id :integer not null, primary key
# project_id :integer
...
...
app/models/ci/project.rb
View file @
37fe73c3
# == Schema Information
#
# Table name: projects
# Table name:
ci_
projects
#
# id :integer not null, primary key
# name :string(255)
not null
# name :string(255)
# timeout :integer default(3600), not null
# created_at :datetime
# updated_at :datetime
...
...
@@ -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
}
"
).
...
...
app/models/ci/runner.rb
View file @
37fe73c3
# == Schema Information
#
# Table name: runners
# Table name:
ci_
runners
#
# id :integer not null, primary key
# token :string(255)
...
...
app/models/ci/runner_project.rb
View file @
37fe73c3
# == Schema Information
#
# Table name: runner_projects
# Table name:
ci_
runner_projects
#
# id :integer not null, primary key
# runner_id :integer not null
...
...
app/models/ci/service.rb
View file @
37fe73c3
# == Schema Information
#
# Table name: services
# Table name:
ci_
services
#
# id :integer not null, primary key
# type :string(255)
...
...
app/models/ci/trigger.rb
View file @
37fe73c3
# == Schema Information
#
# Table name: triggers
# Table name:
ci_
triggers
#
# id :integer not null, primary key
# token :string(255)
...
...
app/models/ci/trigger_request.rb
View file @
37fe73c3
# == Schema Information
#
# Table name: trigger_requests
# Table name:
ci_
trigger_requests
#
# id :integer not null, primary key
# trigger_id :integer not null
...
...
app/models/ci/variable.rb
View file @
37fe73c3
# == Schema Information
#
# Table name: variables
# Table name:
ci_
variables
#
# id :integer not null, primary key
# project_id :integer not null
...
...
app/models/ci/web_hook.rb
View file @
37fe73c3
# == Schema Information
#
# Table name: web_hooks
# Table name:
ci_
web_hooks
#
# id :integer not null, primary key
# url :string(255) not null
...
...
app/models/commit_status.rb
View file @
37fe73c3
# == Schema Information
#
# Table name: ci_builds
#
# id :integer not null, primary key
# project_id :integer
# status :string(255)
# finished_at :datetime
# trace :text
# created_at :datetime
# updated_at :datetime
# started_at :datetime
# runner_id :integer
# coverage :float
# commit_id :integer
# commands :text
# job_id :integer
# name :string(255)
# deploy :boolean default(FALSE)
# options :text
# allow_failure :boolean default(FALSE), not null
# stage :string(255)
# trigger_request_id :integer
# stage_idx :integer
# tag :boolean
# ref :string(255)
# user_id :integer
# type :string(255)
# target_url :string(255)
# description :string(255)
# artifacts_file :text
#
class
CommitStatus
<
ActiveRecord
::
Base
self
.
table_name
=
'ci_builds'
...
...
app/models/generic_commit_status.rb
View file @
37fe73c3
# == Schema Information
#
# Table name: ci_builds
#
# id :integer not null, primary key
# project_id :integer
# status :string(255)
# finished_at :datetime
# trace :text
# created_at :datetime
# updated_at :datetime
# started_at :datetime
# runner_id :integer
# coverage :float
# commit_id :integer
# commands :text
# job_id :integer
# name :string(255)
# deploy :boolean default(FALSE)
# options :text
# allow_failure :boolean default(FALSE), not null
# stage :string(255)
# trigger_request_id :integer
# stage_idx :integer
# tag :boolean
# ref :string(255)
# user_id :integer
# type :string(255)
# target_url :string(255)
# description :string(255)
# artifacts_file :text
#
class
GenericCommitStatus
<
CommitStatus
before_validation
:set_default_values
...
...
app/models/group.rb
View file @
37fe73c3
...
...
@@ -11,6 +11,7 @@
# type :string(255)
# description :string(255) default(""), not null
# avatar :string(255)
# public :boolean default(FALSE)
#
require
'carrierwave/orm/activerecord'
...
...
app/models/hooks/project_hook.rb
View file @
37fe73c3
...
...
@@ -2,18 +2,19 @@
#
# Table name: web_hooks
#
# id :integer not null, primary key
# url :string(255)
# project_id :integer
# created_at :datetime
# updated_at :datetime
# type :string(255) default("ProjectHook")
# service_id :integer
# push_events :boolean default(TRUE), not null
# issues_events :boolean default(FALSE), not null
# merge_requests_events :boolean default(FALSE), not null
# tag_push_events :boolean default(FALSE)
# note_events :boolean default(FALSE), not null
# id :integer not null, primary key
# url :string(255)
# project_id :integer
# created_at :datetime
# updated_at :datetime
# type :string(255) default("ProjectHook")
# service_id :integer
# push_events :boolean default(TRUE), not null
# issues_events :boolean default(FALSE), not null
# merge_requests_events :boolean default(FALSE), not null
# tag_push_events :boolean default(FALSE)
# note_events :boolean default(FALSE), not null
# enable_ssl_verification :boolean default(TRUE)
#
class
ProjectHook
<
WebHook
...
...
app/models/hooks/service_hook.rb
View file @
37fe73c3
...
...
@@ -2,18 +2,19 @@
#
# Table name: web_hooks
#
# id :integer not null, primary key
# url :string(255)
# project_id :integer
# created_at :datetime
# updated_at :datetime
# type :string(255) default("ProjectHook")
# service_id :integer
# push_events :boolean default(TRUE), not null
# issues_events :boolean default(FALSE), not null
# merge_requests_events :boolean default(FALSE), not null
# tag_push_events :boolean default(FALSE)
# note_events :boolean default(FALSE), not null
# id :integer not null, primary key
# url :string(255)
# project_id :integer
# created_at :datetime
# updated_at :datetime
# type :string(255) default("ProjectHook")
# service_id :integer
# push_events :boolean default(TRUE), not null
# issues_events :boolean default(FALSE), not null
# merge_requests_events :boolean default(FALSE), not null
# tag_push_events :boolean default(FALSE)
# note_events :boolean default(FALSE), not null
# enable_ssl_verification :boolean default(TRUE)
#
class
ServiceHook
<
WebHook
...
...
app/models/hooks/system_hook.rb
View file @
37fe73c3
...
...
@@ -2,18 +2,19 @@
#
# Table name: web_hooks
#
# id :integer not null, primary key
# url :string(255)
# project_id :integer
# created_at :datetime
# updated_at :datetime
# type :string(255) default("ProjectHook")
# service_id :integer
# push_events :boolean default(TRUE), not null
# issues_events :boolean default(FALSE), not null
# merge_requests_events :boolean default(FALSE), not null
# tag_push_events :boolean default(FALSE)
# note_events :boolean default(FALSE), not null
# id :integer not null, primary key
# url :string(255)
# project_id :integer
# created_at :datetime
# updated_at :datetime
# type :string(255) default("ProjectHook")
# service_id :integer
# push_events :boolean default(TRUE), not null
# issues_events :boolean default(FALSE), not null
# merge_requests_events :boolean default(FALSE), not null
# tag_push_events :boolean default(FALSE)
# note_events :boolean default(FALSE), not null
# enable_ssl_verification :boolean default(TRUE)
#
class
SystemHook
<
WebHook
...
...
app/models/hooks/web_hook.rb
View file @
37fe73c3
...
...
@@ -2,18 +2,19 @@
#
# Table name: web_hooks
#
# id :integer not null, primary key
# url :string(255)
# project_id :integer
# created_at :datetime
# updated_at :datetime
# type :string(255) default("ProjectHook")
# service_id :integer
# push_events :boolean default(TRUE), not null
# issues_events :boolean default(FALSE), not null
# merge_requests_events :boolean default(FALSE), not null
# tag_push_events :boolean default(FALSE)
# note_events :boolean default(FALSE), not null
# id :integer not null, primary key
# url :string(255)
# project_id :integer
# created_at :datetime
# updated_at :datetime
# type :string(255) default("ProjectHook")
# service_id :integer
# push_events :boolean default(TRUE), not null
# issues_events :boolean default(FALSE), not null
# merge_requests_events :boolean default(FALSE), not null
# tag_push_events :boolean default(FALSE)
# note_events :boolean default(FALSE), not null
# enable_ssl_verification :boolean default(TRUE)
#
class
WebHook
<
ActiveRecord
::
Base
...
...
app/models/label.rb
View file @
37fe73c3
...
...
@@ -8,6 +8,7 @@
# project_id :integer
# created_at :datetime
# updated_at :datetime
# template :boolean default(FALSE)
#
class
Label
<
ActiveRecord
::
Base
...
...
app/models/merge_request.rb
View file @
37fe73c3
...
...
@@ -20,6 +20,7 @@
# position :integer default(0)
# locked_at :datetime
# updated_by_id :integer
# merge_error :string(255)
#
require
Rails
.
root
.
join
(
"app/models/commit"
)
...
...
app/models/namespace.rb
View file @
37fe73c3
...
...
@@ -11,6 +11,7 @@
# type :string(255)
# description :string(255) default(""), not null
# avatar :string(255)
# public :boolean default(FALSE)
#
class
Namespace
<
ActiveRecord
::
Base
...
...
app/models/project.rb
View file @
37fe73c3
...
...
@@ -52,6 +52,7 @@ class Project < ActiveRecord::Base
default_value_for
:visibility_level
,
gitlab_config_features
.
visibility_level
default_value_for
:issues_enabled
,
gitlab_config_features
.
issues
default_value_for
:merge_requests_enabled
,
gitlab_config_features
.
merge_requests
default_value_for
:builds_enabled
,
gitlab_config_features
.
builds
default_value_for
:wiki_enabled
,
gitlab_config_features
.
wiki
default_value_for
:wall_enabled
,
false
default_value_for
:snippets_enabled
,
gitlab_config_features
.
snippets
...
...
@@ -464,10 +465,6 @@ class Project < ActiveRecord::Base
list
.
find
{
|
service
|
service
.
to_param
==
name
}
end
def
gitlab_ci?
gitlab_ci_service
&&
gitlab_ci_service
.
active
&&
gitlab_ci_project
.
present?
end
def
ci_services
services
.
select
{
|
service
|
service
.
category
==
:ci
}
end
...
...
@@ -828,9 +825,23 @@ class Project < ActiveRecord::Base
)
end
def
enable_ci
# TODO: this should be migrated to Project table,
# the same as issues_enabled
def
builds_enabled
gitlab_ci_service
&&
gitlab_ci_service
.
active
end
def
builds_enabled?
builds_enabled
end
def
builds_enabled
=
(
value
)
service
=
gitlab_ci_service
||
create_gitlab_ci_service
service
.
active
=
tr
ue
service
.
active
=
val
ue
service
.
save
end
def
enable_ci
self
.
builds_enabled
=
true
end
end
app/models/project_services/ci/hip_chat_service.rb
View file @
37fe73c3
# == Schema Information
#
# Table name: services
# Table name:
ci_
services
#
# id :integer not null, primary key
# type :string(255)
...
...
app/models/project_services/ci/mail_service.rb
View file @
37fe73c3
# == Schema Information
#
# Table name: services
# Table name:
ci_
services
#
# id :integer not null, primary key
# type :string(255)
...
...
app/models/project_services/ci/slack_service.rb
View file @
37fe73c3
# == Schema Information
#
# Table name: services
# Table name:
ci_
services
#
# id :integer not null, primary key
# type :string(255)
...
...
app/models/release.rb
View file @
37fe73c3
# == Schema Information
#
# Table name: releases
#
# id :integer not null, primary key
# tag :string(255)
# description :text
# project_id :integer
# created_at :datetime
# updated_at :datetime
#
class
Release
<
ActiveRecord
::
Base
belongs_to
:project
...
...
app/models/user.rb
View file @
37fe73c3
...
...
@@ -54,6 +54,7 @@
# public_email :string(255) default(""), not null
# dashboard :integer default(0)
# project_view :integer default(0)
# consumed_timestep :integer
# layout :integer default(0)
#
...
...
app/services/git_push_service.rb
View file @
37fe73c3
...
...
@@ -60,7 +60,7 @@ class GitPushService
# If CI was disabled but .gitlab-ci.yml file was pushed
# we enable CI automatically
if
!
project
.
gitlab_ci
?
&&
gitlab_ci_yaml?
(
newrev
)
if
!
project
.
builds_enabled
?
&&
gitlab_ci_yaml?
(
newrev
)
project
.
enable_ci
end
...
...
app/services/projects/fork_service.rb
View file @
37fe73c3
...
...
@@ -17,7 +17,7 @@ module Projects
new_project
=
CreateService
.
new
(
current_user
,
new_params
).
execute
if
new_project
.
persisted?
if
@project
.
gitlab_ci
?
if
@project
.
builds_enabled
?
new_project
.
enable_ci
settings
=
@project
.
gitlab_ci_project
.
attributes
.
select
do
|
attr_name
,
value
|
...
...
app/views/admin/users/_head.html.haml
View file @
37fe73c3
...
...
@@ -7,7 +7,7 @@
.pull-right
-
unless
@user
==
current_user
=
link_to
'
Log in as this user'
,
login_as
_admin_user_path
(
@user
),
method: :post
,
class:
"btn btn-grouped btn-info"
=
link_to
'
Impersonate'
,
impersonate
_admin_user_path
(
@user
),
method: :post
,
class:
"btn btn-grouped btn-info"
=
link_to
edit_admin_user_path
(
@user
),
class:
"btn btn-grouped"
do
%i
.fa.fa-pencil-square-o
Edit
...
...
app/views/layouts/header/_default.html.haml
View file @
37fe73c3
...
...
@@ -13,6 +13,10 @@
%li
.visible-sm.visible-xs
=
link_to
search_path
,
title:
'Search'
,
data:
{
toggle:
'tooltip'
,
placement:
'bottom'
}
do
=
icon
(
'search'
)
-
if
session
[
:impersonator_id
]
%li
.impersonation
=
link_to
stop_impersonation_admin_users_path
,
method: :delete
,
title:
'Stop impersonation'
,
data:
{
toggle:
'tooltip'
,
placement:
'bottom'
}
do
=
icon
(
'user-secret fw'
)
-
if
current_user
.
is_admin?
%li
=
link_to
admin_root_path
,
title:
'Admin area'
,
data:
{
toggle:
'tooltip'
,
placement:
'bottom'
}
do
...
...
app/views/layouts/nav/_project_settings.html.haml
View file @
37fe73c3
...
...
@@ -50,7 +50,7 @@
%span
Audit Events
-
if
@project
.
gitlab_ci
?
-
if
@project
.
builds_enabled
?
=
nav_link
(
controller: :runners
)
do
=
link_to
namespace_project_runners_path
(
@project
.
namespace
,
@project
),
title:
'Runners'
,
data:
{
placement:
'right'
}
do
=
icon
(
'cog fw'
)
...
...
app/views/projects/edit.html.haml
View file @
37fe73c3
...
...
@@ -57,7 +57,16 @@
=
f
.
check_box
:merge_requests_enabled
%strong
Merge Requests
%br
%span
.descr
Submit changes to be merged upstream.
%span
.descr
Submit changes to be merged upstream
.form-group
.col-sm-offset-2.col-sm-10
.checkbox
=
f
.
label
:builds_enabled
do
=
f
.
check_box
:builds_enabled
%strong
Builds
%br
%span
.descr
Test and deploy your changes before merge
.form-group
.col-sm-offset-2.col-sm-10
...
...
app/views/projects/graphs/_head.html.haml
View file @
37fe73c3
...
...
@@ -3,7 +3,7 @@
=
link_to
'Contributors'
,
namespace_project_graph_path
=
nav_link
(
action: :commits
)
do
=
link_to
'Commits'
,
commits_namespace_project_graph_path
-
if
@project
.
gitlab_ci
?
-
if
@project
.
builds_enabled
?
=
nav_link
(
action: :ci
)
do
=
link_to
ci_namespace_project_graph_path
do
Continuous Integration
config/gitlab.yml.example
View file @
37fe73c3
...
...
@@ -84,6 +84,7 @@ production: &base
merge_requests: true
wiki: true
snippets: false
builds: true
## Webhook settings
# Number of seconds to wait for HTTP response after sending webhook HTTP POST request (default: 10)
...
...
config/initializers/1_settings.rb
View file @
37fe73c3
...
...
@@ -199,6 +199,7 @@ Settings.gitlab.default_projects_features['issues'] = true if Settings.g
Settings
.
gitlab
.
default_projects_features
[
'merge_requests'
]
=
true
if
Settings
.
gitlab
.
default_projects_features
[
'merge_requests'
].
nil?
Settings
.
gitlab
.
default_projects_features
[
'wiki'
]
=
true
if
Settings
.
gitlab
.
default_projects_features
[
'wiki'
].
nil?
Settings
.
gitlab
.
default_projects_features
[
'snippets'
]
=
false
if
Settings
.
gitlab
.
default_projects_features
[
'snippets'
].
nil?
Settings
.
gitlab
.
default_projects_features
[
'builds'
]
=
true
if
Settings
.
gitlab
.
default_projects_features
[
'builds'
].
nil?
Settings
.
gitlab
.
default_projects_features
[
'visibility_level'
]
=
Settings
.
send
(
:verify_constant
,
Gitlab
::
VisibilityLevel
,
Settings
.
gitlab
.
default_projects_features
[
'visibility_level'
],
Gitlab
::
VisibilityLevel
::
PRIVATE
)
Settings
.
gitlab
[
'repository_downloads_path'
]
=
File
.
join
(
Settings
.
shared
[
'path'
],
'cache/archive'
)
if
Settings
.
gitlab
[
'repository_downloads_path'
].
nil?
Settings
.
gitlab
[
'restricted_signup_domains'
]
||=
[]
...
...
config/routes.rb
View file @
37fe73c3
...
...
@@ -227,6 +227,8 @@ Gitlab::Application.routes.draw do
resources
:keys
,
only:
[
:show
,
:destroy
]
resources
:identities
,
only:
[
:index
,
:edit
,
:update
,
:destroy
]
delete
'stop_impersonation'
=>
'impersonation#destroy'
,
on: :collection
member
do
get
:projects
get
:keys
...
...
@@ -236,7 +238,7 @@ Gitlab::Application.routes.draw do
put
:unblock
put
:unlock
put
:confirm
post
:login_as
post
'impersonate'
=>
'impersonation#create'
patch
:disable_two_factor
delete
'remove/:email_id'
,
action:
'remove_email'
,
as:
'remove_email'
end
...
...
doc/api/projects.md
View file @
37fe73c3
...
...
@@ -60,6 +60,7 @@ Parameters:
"path_with_namespace"
:
"diaspora/diaspora-client"
,
"issues_enabled"
:
true
,
"merge_requests_enabled"
:
true
,
"builds_enabled"
:
true
,
"wiki_enabled"
:
true
,
"snippets_enabled"
:
false
,
"created_at"
:
"2013-09-30T13: 46: 02Z"
,
...
...
@@ -101,6 +102,7 @@ Parameters:
"path_with_namespace"
:
"brightbox/puppet"
,
"issues_enabled"
:
true
,
"merge_requests_enabled"
:
true
,
"builds_enabled"
:
true
,
"wiki_enabled"
:
true
,
"snippets_enabled"
:
false
,
"created_at"
:
"2013-09-30T13:46:02Z"
,
...
...
@@ -191,6 +193,7 @@ Parameters:
"path_with_namespace"
:
"diaspora/diaspora-project-site"
,
"issues_enabled"
:
true
,
"merge_requests_enabled"
:
true
,
"builds_enabled"
:
true
,
"wiki_enabled"
:
true
,
"snippets_enabled"
:
false
,
"created_at"
:
"2013-09-30T13: 46: 02Z"
,
...
...
@@ -312,6 +315,7 @@ Parameters:
-
`description`
(optional) - short project description
-
`issues_enabled`
(optional)
-
`merge_requests_enabled`
(optional)
-
`builds_enabled`
(optional)
-
`wiki_enabled`
(optional)
-
`snippets_enabled`
(optional)
-
`public`
(optional) - if
`true`
same as setting visibility_level = 20
...
...
@@ -334,6 +338,7 @@ Parameters:
-
`default_branch`
(optional) - 'master' by default
-
`issues_enabled`
(optional)
-
`merge_requests_enabled`
(optional)
-
`builds_enabled`
(optional)
-
`wiki_enabled`
(optional)
-
`snippets_enabled`
(optional)
-
`public`
(optional) - if
`true`
same as setting visibility_level = 20
...
...
@@ -357,6 +362,7 @@ Parameters:
-
`default_branch`
(optional)
-
`issues_enabled`
(optional)
-
`merge_requests_enabled`
(optional)
-
`builds_enabled`
(optional)
-
`wiki_enabled`
(optional)
-
`snippets_enabled`
(optional)
-
`public`
(optional) - if
`true`
same as setting visibility_level = 20
...
...
lib/api/entities.rb
View file @
37fe73c3
...
...
@@ -67,7 +67,7 @@ module API
expose
:owner
,
using:
Entities
::
UserBasic
,
unless:
->
(
project
,
options
)
{
project
.
group
}
expose
:name
,
:name_with_namespace
expose
:path
,
:path_with_namespace
expose
:issues_enabled
,
:merge_requests_enabled
,
:wiki_enabled
,
:snippets_enabled
,
:created_at
,
:last_activity_at
expose
:issues_enabled
,
:merge_requests_enabled
,
:wiki_enabled
,
:
builds_enabled
,
:
snippets_enabled
,
:created_at
,
:last_activity_at
expose
:creator_id
expose
:namespace
expose
:forked_from_project
,
using:
Entities
::
ForkedFromProject
,
if:
lambda
{
|
project
,
options
|
project
.
forked?
}
...
...
lib/api/projects.rb
View file @
37fe73c3
...
...
@@ -75,6 +75,7 @@ module API
# description (optional) - short project description
# issues_enabled (optional)
# merge_requests_enabled (optional)
# builds_enabled (optional)
# wiki_enabled (optional)
# snippets_enabled (optional)
# namespace_id (optional) - defaults to user namespace
...
...
@@ -90,6 +91,7 @@ module API
:description
,
:issues_enabled
,
:merge_requests_enabled
,
:builds_enabled
,
:wiki_enabled
,
:snippets_enabled
,
:namespace_id
,
...
...
@@ -117,6 +119,7 @@ module API
# default_branch (optional) - 'master' by default
# issues_enabled (optional)
# merge_requests_enabled (optional)
# builds_enabled (optional)
# wiki_enabled (optional)
# snippets_enabled (optional)
# public (optional) - if true same as setting visibility_level = 20
...
...
@@ -132,6 +135,7 @@ module API
:default_branch
,
:issues_enabled
,
:merge_requests_enabled
,
:builds_enabled
,
:wiki_enabled
,
:snippets_enabled
,
:public
,
...
...
@@ -172,6 +176,7 @@ module API
# description (optional) - short project description
# issues_enabled (optional)
# merge_requests_enabled (optional)
# builds_enabled (optional)
# wiki_enabled (optional)
# snippets_enabled (optional)
# public (optional) - if true same as setting visibility_level = 20
...
...
@@ -185,6 +190,7 @@ module API
:default_branch
,
:issues_enabled
,
:merge_requests_enabled
,
:builds_enabled
,
:wiki_enabled
,
:snippets_enabled
,
:public
,
...
...
spec/controllers/admin/users_controller_spec.rb
View file @
37fe73c3
...
...
@@ -7,21 +7,6 @@ describe Admin::UsersController do
sign_in
(
admin
)
end
describe
'POST login_as'
do
let
(
:user
)
{
create
(
:user
)
}
it
'logs admin as another user'
do
expect
(
warden
.
authenticate
(
scope: :user
)).
not_to
eq
(
user
)
post
:login_as
,
id:
user
.
username
expect
(
warden
.
authenticate
(
scope: :user
)).
to
eq
(
user
)
end
it
'redirects user to homepage'
do
post
:login_as
,
id:
user
.
username
expect
(
response
).
to
redirect_to
(
root_path
)
end
end
describe
'DELETE #user with projects'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
,
namespace:
user
.
namespace
)
}
...
...
spec/factories/ci/projects.rb
View file @
37fe73c3
...
...
@@ -31,16 +31,20 @@ FactoryGirl.define do
factory
:ci_project_without_token
,
class:
Ci
::
Project
do
default_ref
'master'
gl_project
factory: :empty_project
shared_runners_enabled
false
factory
:ci_project
do
token
'iPWx6WM4lhHNedGfBpPJNP'
end
factory
:ci_public_project
do
public
true
initialize_with
do
# TODO:
# this is required, because builds_enabled is initialized when Project is created
# and this create gitlab_ci_project if builds is set to true
# here we take created gitlab_ci_project and update it's attributes
ci_project
=
create
(
:empty_project
).
ensure_gitlab_ci_project
ci_project
.
update_attributes
(
attributes
)
ci_project
end
end
end
spec/factories/labels.rb
View file @
37fe73c3
...
...
@@ -8,6 +8,7 @@
# project_id :integer
# created_at :datetime
# updated_at :datetime
# template :boolean default(FALSE)
#
# Read about factories at https://github.com/thoughtbot/factory_girl
...
...
spec/factories/merge_requests.rb
View file @
37fe73c3
...
...
@@ -20,6 +20,7 @@
# position :integer default(0)
# locked_at :datetime
# updated_by_id :integer
# merge_error :string(255)
#
FactoryGirl
.
define
do
...
...
spec/factories/releases.rb
View file @
37fe73c3
# == Schema Information
#
# Table name: releases
#
# id :integer not null, primary key
# tag :string(255)
# description :text
# project_id :integer
# created_at :datetime
# updated_at :datetime
#
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl
.
define
do
...
...
spec/features/admin/admin_users_spec.rb
View file @
37fe73c3
...
...
@@ -111,24 +111,50 @@ describe "Admin::Users", feature: true do
expect
(
page
).
to
have_content
(
@user
.
name
)
end
describe
'
Login as another user
'
do
it
'should show login button for other users and check that it works'
do
another_user
=
create
(
:user
)
describe
'
Impersonation
'
do
let
(
:another_user
)
{
create
(
:user
)
}
before
{
visit
admin_user_path
(
another_user
)
}
visit
admin_user_path
(
another_user
)
click_link
'Log in as this user'
context
'before impersonating'
do
it
'shows impersonate button for other users'
do
expect
(
page
).
to
have_content
(
'Impersonate'
)
end
expect
(
page
).
to
have_content
(
"Logged in as
#{
another_user
.
username
}
"
)
it
'should not show impersonate button for admin itself'
do
visit
admin_user_path
(
@user
)
page
.
within
'.sidebar-user .username'
do
expect
(
page
).
to
have_content
(
another_user
.
username
)
expect
(
page
).
not_to
have_content
(
'Impersonate'
)
end
end
it
'should not show login button for admin itself'
do
visit
admin_user_path
(
@user
)
expect
(
page
).
not_to
have_content
(
'Log in as this user'
)
context
'when impersonating'
do
before
{
click_link
'Impersonate'
}
it
'logs in as the user when impersonate is clicked'
do
page
.
within
'.sidebar-user .username'
do
expect
(
page
).
to
have_content
(
another_user
.
username
)
end
end
it
'sees impersonation log out icon'
do
icon
=
first
(
'.fa.fa-user-secret'
)
expect
(
icon
).
to_not
eql
nil
end
it
'can log out of impersonated user back to original user'
do
find
(
:css
,
'li.impersonation a'
).
click
page
.
within
'.sidebar-user .username'
do
expect
(
page
).
to
have_content
(
@user
.
username
)
end
end
it
'is redirected back to the impersonated users page in the admin after stopping'
do
find
(
:css
,
'li.impersonation a'
).
click
expect
(
current_path
).
to
eql
"/admin/users/
#{
another_user
.
username
}
"
end
end
end
...
...
spec/models/application_setting_spec.rb
View file @
37fe73c3
...
...
@@ -23,6 +23,10 @@
# after_sign_out_path :string(255)
# session_expire_delay :integer default(10080), not null
# import_sources :text
# help_page_text :text
# admin_notification_email :string(255)
# shared_runners_enabled :boolean default(TRUE), not null
# max_artifacts_size :integer default(100), not null
#
require
'spec_helper'
...
...
spec/models/ci/commit_spec.rb
View file @
37fe73c3
# == Schema Information
#
# Table name: commits
# Table name: c
i_c
ommits
#
# id :integer not null, primary key
# project_id :integer
# ref :string(255)
# sha :string(255)
# before_sha :string(255)
# push_data :text
# created_at :datetime
# updated_at :datetime
# tag :boolean default(FALSE)
# yaml_errors :text
# committed_at :datetime
# id :integer not null, primary key
# project_id :integer
# ref :string(255)
# sha :string(255)
# before_sha :string(255)
# push_data :text
# created_at :datetime
# updated_at :datetime
# tag :boolean default(FALSE)
# yaml_errors :text
# committed_at :datetime
# gl_project_id :integer
#
require
'spec_helper'
...
...
spec/models/ci/project_spec.rb
View file @
37fe73c3
# == Schema Information
#
# Table name: projects
# Table name:
ci_
projects
#
# id :integer not null, primary key
# name :string(255)
not null
# name :string(255)
# timeout :integer default(3600), not null
# created_at :datetime
# updated_at :datetime
...
...
@@ -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/models/ci/runner_project_spec.rb
View file @
37fe73c3
# == Schema Information
#
# Table name: runner_projects
# Table name:
ci_
runner_projects
#
# id :integer not null, primary key
# runner_id :integer not null
...
...
spec/models/ci/runner_spec.rb
View file @
37fe73c3
# == Schema Information
#
# Table name: runners
# Table name:
ci_
runners
#
# id :integer not null, primary key
# token :string(255)
...
...
spec/models/ci/service_spec.rb
View file @
37fe73c3
# == Schema Information
#
# Table name: services
# Table name:
ci_
services
#
# id :integer not null, primary key
# type :string(255)
...
...
spec/models/ci/trigger_spec.rb
View file @
37fe73c3
# == Schema Information
#
# Table name: ci_triggers
#
# id :integer not null, primary key
# token :string(255)
# project_id :integer not null
# deleted_at :datetime
# created_at :datetime
# updated_at :datetime
#
require
'spec_helper'
describe
Ci
::
Trigger
do
...
...
spec/models/ci/variable_spec.rb
View file @
37fe73c3
# == Schema Information
#
# Table name: variables
# Table name:
ci_
variables
#
# id :integer not null, primary key
# project_id :integer not null
...
...
spec/models/ci/web_hook_spec.rb
View file @
37fe73c3
# == Schema Information
#
# Table name: web_hooks
# Table name:
ci_
web_hooks
#
# id :integer not null, primary key
# url :string(255) not null
...
...
spec/models/commit_status_spec.rb
View file @
37fe73c3
# == Schema Information
#
# Table name: ci_builds
#
# id :integer not null, primary key
# project_id :integer
# status :string(255)
# finished_at :datetime
# trace :text
# created_at :datetime
# updated_at :datetime
# started_at :datetime
# runner_id :integer
# coverage :float
# commit_id :integer
# commands :text
# job_id :integer
# name :string(255)
# deploy :boolean default(FALSE)
# options :text
# allow_failure :boolean default(FALSE), not null
# stage :string(255)
# trigger_request_id :integer
# stage_idx :integer
# tag :boolean
# ref :string(255)
# user_id :integer
# type :string(255)
# target_url :string(255)
# description :string(255)
# artifacts_file :text
#
require
'spec_helper'
describe
CommitStatus
do
...
...
spec/models/generic_commit_status_spec.rb
View file @
37fe73c3
# == Schema Information
#
# Table name: ci_builds
#
# id :integer not null, primary key
# project_id :integer
# status :string(255)
# finished_at :datetime
# trace :text
# created_at :datetime
# updated_at :datetime
# started_at :datetime
# runner_id :integer
# coverage :float
# commit_id :integer
# commands :text
# job_id :integer
# name :string(255)
# deploy :boolean default(FALSE)
# options :text
# allow_failure :boolean default(FALSE), not null
# stage :string(255)
# trigger_request_id :integer
# stage_idx :integer
# tag :boolean
# ref :string(255)
# user_id :integer
# type :string(255)
# target_url :string(255)
# description :string(255)
# artifacts_file :text
#
require
'spec_helper'
describe
GenericCommitStatus
do
...
...
spec/models/group_spec.rb
View file @
37fe73c3
...
...
@@ -11,6 +11,7 @@
# type :string(255)
# description :string(255) default(""), not null
# avatar :string(255)
# public :boolean default(FALSE)
#
require
'spec_helper'
...
...
spec/models/label_spec.rb
View file @
37fe73c3
...
...
@@ -8,6 +8,7 @@
# project_id :integer
# created_at :datetime
# updated_at :datetime
# template :boolean default(FALSE)
#
require
'spec_helper'
...
...
spec/models/merge_request_spec.rb
View file @
37fe73c3
...
...
@@ -20,6 +20,7 @@
# position :integer default(0)
# locked_at :datetime
# updated_by_id :integer
# merge_error :string(255)
#
require
'spec_helper'
...
...
spec/models/namespace_spec.rb
View file @
37fe73c3
...
...
@@ -11,6 +11,7 @@
# type :string(255)
# description :string(255) default(""), not null
# avatar :string(255)
# public :boolean default(FALSE)
#
require
'spec_helper'
...
...
spec/models/project_spec.rb
View file @
37fe73c3
...
...
@@ -445,12 +445,15 @@ describe Project do
it
{
expect
(
project
.
ci_commit
(
commit
.
sha
)).
to
eq
(
commit
)
}
end
describe
:
enable_ci
do
describe
:
builds_enabled
do
let
(
:project
)
{
create
:project
}
before
{
project
.
enable_ci
}
before
{
project
.
builds_enabled
=
true
}
it
{
expect
(
project
.
gitlab_ci?
).
to
be_truthy
}
subject
{
project
.
builds_enabled
}
it
{
is_expected
.
to
eq
(
project
.
gitlab_ci_service
.
active
)
}
it
{
expect
(
project
.
builds_enabled?
).
to
be_truthy
}
it
{
expect
(
project
.
gitlab_ci_project
).
to
be_a
(
Ci
::
Project
)
}
end
...
...
spec/models/release_spec.rb
View file @
37fe73c3
# == Schema Information
#
# Table name: releases
#
# id :integer not null, primary key
# tag :string(255)
# description :text
# project_id :integer
# created_at :datetime
# updated_at :datetime
#
require
'rails_helper'
RSpec
.
describe
Release
,
type: :model
do
...
...
spec/models/user_spec.rb
View file @
37fe73c3
...
...
@@ -54,6 +54,8 @@
# public_email :string(255) default(""), not null
# dashboard :integer default(0)
# project_view :integer default(0)
# consumed_timestep :integer
# layout :integer default(0)
#
require
'spec_helper'
...
...
spec/requests/api/projects_spec.rb
View file @
37fe73c3
...
...
@@ -88,8 +88,11 @@ describe API::API, api: true do
end
it
'returns projects in the correct order when ci_enabled_first parameter is passed'
do
[
project
,
project2
,
project3
].
each
{
|
project
|
project
.
build_missing_services
}
project2
.
gitlab_ci_service
.
update
(
active:
true
)
[
project
,
project2
,
project3
].
each
do
|
project
|
project
.
builds_enabled
=
false
project
.
build_missing_services
end
project2
.
builds_enabled
=
true
get
api
(
'/projects'
,
user
),
{
ci_enabled_first:
'true'
}
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
).
to
be_an
Array
...
...
spec/requests/api/services_spec.rb
View file @
37fe73c3
...
...
@@ -46,6 +46,7 @@ describe API::API, api: true do
delete
api
(
"/projects/
#{
project
.
id
}
/services/
#{
dashed_service
}
"
,
user
)
expect
(
response
.
status
).
to
eq
(
200
)
project
.
send
(
service_method
).
reload
expect
(
project
.
send
(
service_method
).
activated?
).
to
be_falsey
end
end
...
...
spec/requests/ci/api/builds_spec.rb
View file @
37fe73c3
...
...
@@ -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
...
...
@@ -160,15 +160,13 @@ describe Ci::API::API do
end
it
"using token as parameter"
do
settings
=
Gitlab
::
CurrentSettings
::
current_application_settings
settings
.
update_attributes
(
max_artifacts_size:
0
)
stub_application_setting
(
max_artifacts_size:
0
)
post
authorize_url
,
{
token:
build
.
project
.
token
,
filesize:
100
},
headers
expect
(
response
.
status
).
to
eq
(
413
)
end
it
"using token as header"
do
settings
=
Gitlab
::
CurrentSettings
::
current_application_settings
settings
.
update_attributes
(
max_artifacts_size:
0
)
stub_application_setting
(
max_artifacts_size:
0
)
post
authorize_url
,
{
filesize:
100
},
headers_with_token
expect
(
response
.
status
).
to
eq
(
413
)
end
...
...
@@ -220,8 +218,7 @@ describe Ci::API::API do
end
it
do
settings
=
Gitlab
::
CurrentSettings
::
current_application_settings
settings
.
update_attributes
(
max_artifacts_size:
0
)
stub_application_setting
(
max_artifacts_size:
0
)
upload_artifacts
(
file_upload
,
headers_with_token
)
expect
(
response
.
status
).
to
eq
(
413
)
end
...
...
spec/requests/ci/api/commits_spec.rb
View file @
37fe73c3
...
...
@@ -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 @
37fe73c3
...
...
@@ -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 @
37fe73c3
...
...
@@ -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 @
37fe73c3
...
...
@@ -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
...
...
spec/services/projects/create_service_spec.rb
View file @
37fe73c3
...
...
@@ -70,6 +70,28 @@ describe Projects::CreateService do
end
end
context
'builds_enabled global setting'
do
let
(
:project
)
{
create_project
(
@user
,
@opts
)
}
subject
{
project
.
builds_enabled?
}
context
'global builds_enabled false does not enable CI by default'
do
before
do
@opts
.
merge!
(
builds_enabled:
false
)
end
it
{
is_expected
.
to
be_falsey
}
end
context
'global builds_enabled true does enable CI by default'
do
before
do
@opts
.
merge!
(
builds_enabled:
true
)
end
it
{
is_expected
.
to
be_truthy
}
end
end
context
'restricted visibility level'
do
before
do
stub_application_setting
(
restricted_visibility_levels:
[
Gitlab
::
VisibilityLevel
::
PUBLIC
])
...
...
spec/services/projects/fork_service_spec.rb
View file @
37fe73c3
...
...
@@ -46,7 +46,7 @@ describe Projects::ForkService do
it
"fork and enable CI for fork"
do
@from_project
.
enable_ci
@to_project
=
fork_project
(
@from_project
,
@to_user
)
expect
(
@to_project
.
gitlab_ci
?
).
to
be_truthy
expect
(
@to_project
.
builds_enabled
?
).
to
be_truthy
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