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
dd785467
Commit
dd785467
authored
Nov 08, 2017
by
Alexis Reigel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
project#group_runner_enabled -> project_settings
parent
a2a7ad29
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
30 additions
and
19 deletions
+30
-19
app/controllers/projects/runners_controller.rb
app/controllers/projects/runners_controller.rb
+1
-1
app/models/project.rb
app/models/project.rb
+5
-0
db/migrate/20170925142221_add_group_runners_enabled_to_projects.rb
...e/20170925142221_add_group_runners_enabled_to_projects.rb
+0
-16
db/migrate/20171030155459_create_project_settings.rb
db/migrate/20171030155459_create_project_settings.rb
+2
-0
db/schema.rb
db/schema.rb
+2
-1
spec/factories/projects.rb
spec/factories/projects.rb
+8
-1
spec/models/project_spec.rb
spec/models/project_spec.rb
+12
-0
No files found.
app/controllers/projects/runners_controller.rb
View file @
dd785467
...
@@ -53,7 +53,7 @@ class Projects::RunnersController < Projects::ApplicationController
...
@@ -53,7 +53,7 @@ class Projects::RunnersController < Projects::ApplicationController
end
end
def
toggle_group_runners
def
toggle_group_runners
project
.
toggle!
(
:group_runners_enabled
)
project
.
toggle
_settings
!
(
:group_runners_enabled
)
redirect_to
project_settings_ci_cd_path
(
@project
)
redirect_to
project_settings_ci_cd_path
(
@project
)
end
end
...
...
app/models/project.rb
View file @
dd785467
...
@@ -249,6 +249,7 @@ class Project < ActiveRecord::Base
...
@@ -249,6 +249,7 @@ class Project < ActiveRecord::Base
delegate
:members
,
to: :team
,
prefix:
true
delegate
:members
,
to: :team
,
prefix:
true
delegate
:add_user
,
:add_users
,
to: :team
delegate
:add_user
,
:add_users
,
to: :team
delegate
:add_guest
,
:add_reporter
,
:add_developer
,
:add_master
,
:add_role
,
to: :team
delegate
:add_guest
,
:add_reporter
,
:add_developer
,
:add_master
,
:add_role
,
to: :team
delegate
:group_runners_enabled
,
:group_runners_enabled
=
,
:group_runners_enabled?
,
to: :settings
# Validations
# Validations
validates
:creator
,
presence:
true
,
on: :create
validates
:creator
,
presence:
true
,
on: :create
...
@@ -1893,6 +1894,10 @@ class Project < ActiveRecord::Base
...
@@ -1893,6 +1894,10 @@ class Project < ActiveRecord::Base
[]
[]
end
end
def
toggle_settings!
(
settings_attribute
)
settings
.
toggle!
(
settings_attribute
)
end
private
private
def
storage
def
storage
...
...
db/migrate/20170925142221_add_group_runners_enabled_to_projects.rb
deleted
100644 → 0
View file @
a2a7ad29
class
AddGroupRunnersEnabledToProjects
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
disable_ddl_transaction!
def
up
add_column_with_default
:projects
,
:group_runners_enabled
,
:boolean
,
default:
true
add_concurrent_index
:projects
,
:group_runners_enabled
end
def
down
remove_column
:projects
,
:group_runners_enabled
end
end
db/migrate/20171030155459_create_project_settings.rb
View file @
dd785467
...
@@ -7,6 +7,8 @@ class CreateProjectSettings < ActiveRecord::Migration
...
@@ -7,6 +7,8 @@ class CreateProjectSettings < ActiveRecord::Migration
def
change
def
change
create_table
:project_settings
do
|
t
|
create_table
:project_settings
do
|
t
|
t
.
references
:project
,
index:
true
,
foreign_key:
{
on_delete: :cascade
}
t
.
references
:project
,
index:
true
,
foreign_key:
{
on_delete: :cascade
}
t
.
boolean
:group_runners_enabled
,
default:
true
,
index:
true
end
end
end
end
end
end
db/schema.rb
View file @
dd785467
...
@@ -1506,8 +1506,10 @@ ActiveRecord::Schema.define(version: 20180418053107) do
...
@@ -1506,8 +1506,10 @@ ActiveRecord::Schema.define(version: 20180418053107) do
create_table
"project_settings"
,
force: :cascade
do
|
t
|
create_table
"project_settings"
,
force: :cascade
do
|
t
|
t
.
integer
"project_id"
t
.
integer
"project_id"
t
.
boolean
"group_runners_enabled"
,
default:
true
end
end
add_index
"project_settings"
,
[
"group_runners_enabled"
],
name:
"index_project_settings_on_group_runners_enabled"
,
using: :btree
add_index
"project_settings"
,
[
"project_id"
],
name:
"index_project_settings_on_project_id"
,
using: :btree
add_index
"project_settings"
,
[
"project_id"
],
name:
"index_project_settings_on_project_id"
,
using: :btree
create_table
"project_statistics"
,
force: :cascade
do
|
t
|
create_table
"project_statistics"
,
force: :cascade
do
|
t
|
...
@@ -1581,7 +1583,6 @@ ActiveRecord::Schema.define(version: 20180418053107) do
...
@@ -1581,7 +1583,6 @@ ActiveRecord::Schema.define(version: 20180418053107) do
add_index
"projects"
,
[
"created_at"
],
name:
"index_projects_on_created_at"
,
using: :btree
add_index
"projects"
,
[
"created_at"
],
name:
"index_projects_on_created_at"
,
using: :btree
add_index
"projects"
,
[
"creator_id"
],
name:
"index_projects_on_creator_id"
,
using: :btree
add_index
"projects"
,
[
"creator_id"
],
name:
"index_projects_on_creator_id"
,
using: :btree
add_index
"projects"
,
[
"description"
],
name:
"index_projects_on_description_trigram"
,
using: :gin
,
opclasses:
{
"description"
=>
"gin_trgm_ops"
}
add_index
"projects"
,
[
"description"
],
name:
"index_projects_on_description_trigram"
,
using: :gin
,
opclasses:
{
"description"
=>
"gin_trgm_ops"
}
add_index
"projects"
,
[
"group_runners_enabled"
],
name:
"index_projects_on_group_runners_enabled"
,
using: :btree
add_index
"projects"
,
[
"id"
],
name:
"index_projects_on_id_partial_for_visibility"
,
unique:
true
,
where:
"(visibility_level = ANY (ARRAY[10, 20]))"
,
using: :btree
add_index
"projects"
,
[
"id"
],
name:
"index_projects_on_id_partial_for_visibility"
,
unique:
true
,
where:
"(visibility_level = ANY (ARRAY[10, 20]))"
,
using: :btree
add_index
"projects"
,
[
"last_activity_at"
],
name:
"index_projects_on_last_activity_at"
,
using: :btree
add_index
"projects"
,
[
"last_activity_at"
],
name:
"index_projects_on_last_activity_at"
,
using: :btree
add_index
"projects"
,
[
"last_repository_check_failed"
],
name:
"index_projects_on_last_repository_check_failed"
,
using: :btree
add_index
"projects"
,
[
"last_repository_check_failed"
],
name:
"index_projects_on_last_repository_check_failed"
,
using: :btree
...
...
spec/factories/projects.rb
View file @
dd785467
...
@@ -15,14 +15,18 @@ FactoryBot.define do
...
@@ -15,14 +15,18 @@ FactoryBot.define do
namespace
namespace
creator
{
group
?
create
(
:user
)
:
namespace
&
.
owner
}
creator
{
group
?
create
(
:user
)
:
namespace
&
.
owner
}
# Nest Project Feature attributes
transient
do
transient
do
# Nest Project Feature attributes
wiki_access_level
ProjectFeature
::
ENABLED
wiki_access_level
ProjectFeature
::
ENABLED
builds_access_level
ProjectFeature
::
ENABLED
builds_access_level
ProjectFeature
::
ENABLED
snippets_access_level
ProjectFeature
::
ENABLED
snippets_access_level
ProjectFeature
::
ENABLED
issues_access_level
ProjectFeature
::
ENABLED
issues_access_level
ProjectFeature
::
ENABLED
merge_requests_access_level
ProjectFeature
::
ENABLED
merge_requests_access_level
ProjectFeature
::
ENABLED
repository_access_level
ProjectFeature
::
ENABLED
repository_access_level
ProjectFeature
::
ENABLED
# we can't assign the delegated `#settings` attributes directly, as the
# `#settings` relation needs to be created first
group_runners_enabled
nil
end
end
after
(
:create
)
do
|
project
,
evaluator
|
after
(
:create
)
do
|
project
,
evaluator
|
...
@@ -47,6 +51,9 @@ FactoryBot.define do
...
@@ -47,6 +51,9 @@ FactoryBot.define do
end
end
project
.
group
&
.
refresh_members_authorized_projects
project
.
group
&
.
refresh_members_authorized_projects
# assign the delegated `#settings` attributes after create
project
.
reload
.
group_runners_enabled
=
evaluator
.
group_runners_enabled
unless
evaluator
.
group_runners_enabled
.
nil?
end
end
trait
:public
do
trait
:public
do
...
...
spec/models/project_spec.rb
View file @
dd785467
...
@@ -3640,4 +3640,16 @@ describe Project do
...
@@ -3640,4 +3640,16 @@ describe Project do
it
{
is_expected
.
not_to
be_valid
}
it
{
is_expected
.
not_to
be_valid
}
end
end
end
end
describe
'#toggle_settings!'
do
it
'toggles the value on #settings'
do
project
=
create
:project
,
group_runners_enabled:
false
expect
(
project
.
group_runners_enabled
).
to
be
false
project
.
toggle_settings!
(
:group_runners_enabled
)
expect
(
project
.
group_runners_enabled
).
to
be
true
end
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