Открыть боковую панель
GitLab.org
Gitlab
Коммиты
7f198733
Не подтверждена
Коммит
7f198733
создал
Фев 16, 2023
по автору
Maxime Orefice
Просмотр файлов
Replace default_value_for with attribute
владелец
f8a95c8d
Изменения
4
Скрыть пробелы
Построчно
Рядом
app/models/project.rb
Просмотр файла @
7f198733
...
...
@@ -100,12 +100,12 @@ class Project < ApplicationRecord
attribute
:remove_source_branch_after_merge
,
default:
true
attribute
:autoclose_referenced_issues
,
default:
true
attribute
:ci_config_path
,
default:
->
{
Gitlab
::
CurrentSettings
.
default_ci_config_path
}
default_value_for
:iss
ues_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
:snippets_enabled
,
gitlab_config_features
.
snippets
attribute
:issues_enabled
,
default:
->
{
gitlab_config_features
.
issues
}
attribute
:merge_req
ues
ts
_enabled
,
default:
->
{
gitlab_config_features
.
merge_requests
}
attribute
:builds_enabled
,
default:
->
{
gitlab_config_features
.
builds
}
attribute
:wiki_enabled
,
default:
->
{
gitlab_config_features
.
wiki
}
attribute
:snippets_enabled
,
default:
->
{
gitlab_config_features
.
snippets
}
after_initialize
:set_legacy_default_value
add_authentication_token_field
:runners_token
,
encrypted:
->
{
Feature
.
enabled?
(
:projects_tokens_optional_encryption
)
?
:optional
:
:required
},
...
...
@@ -3121,6 +3121,14 @@ def suggested_reviewers_available?
private
def
set_legacy_default_value
self
.
issues_enabled
=
gitlab_config_features
.
issues
self
.
merge_requests_enabled
=
gitlab_config_features
.
merge_requests
self
.
builds_enabled
=
gitlab_config_features
.
builds
self
.
wiki_enabled
=
gitlab_config_features
.
wiki
self
.
snippets_enabled
=
gitlab_config_features
.
snippets
end
# overridden in EE
def
project_group_links_with_preload
project_group_links
...
...
ee/app/models/ee/project.rb
Просмотр файла @
7f198733
...
...
@@ -281,7 +281,7 @@ def requirements_enabled=(value)
end
end
default_value_for
:requirements_enabled
,
true
attribute
:requirements_enabled
,
default:
true
accepts_nested_attributes_for
:status_page_setting
,
update_only:
true
,
allow_destroy:
true
accepts_nested_attributes_for
:compliance_framework_setting
,
update_only:
true
,
allow_destroy:
true
...
...
ee/spec/models/ee/project_spec.rb
Просмотр файла @
7f198733
...
...
@@ -10,6 +10,12 @@
let
(
:project
)
{
create
(
:project
)
}
describe
'default values'
do
subject
{
build
(
:project
)
}
specify
{
expect
(
subject
.
requirements_enabled
).
to
eq
(
true
)
}
end
describe
'associations'
do
it
{
is_expected
.
to
delegate_method
(
:shared_runners_seconds
).
to
(
:statistics
)
}
...
...
spec/models/project_spec.rb
Просмотр файла @
7f198733
...
...
@@ -172,6 +172,16 @@
it
{
is_expected
.
to
have_one
(
:pages_metadatum
)
}
it
{
is_expected
.
to
have_many
(
:pages_deployments
)
}
describe
'default values'
do
subject
{
build
(
:project
)
}
specify
{
expect
(
subject
.
issues_enabled
).
to
eq
(
true
)
}
specify
{
expect
(
subject
.
merge_requests_enabled
).
to
eq
(
true
)
}
specify
{
expect
(
subject
.
builds_enabled
).
to
eq
(
true
)
}
specify
{
expect
(
subject
.
wiki_enabled
).
to
eq
(
true
)
}
specify
{
expect
(
subject
.
snippets_enabled
).
to
eq
(
true
)
}
end
it_behaves_like
'model with repository'
do
let_it_be
(
:container
)
{
create
(
:project
,
:repository
,
path:
'somewhere'
)
}
let
(
:stubbed_container
)
{
build_stubbed
(
:project
)
}
...
...
Редактирование
Предварительный просмотр
Поддерживает Markdown
0%
Попробовать снова
или
прикрепить новый файл
.
Отмена
You are about to add
0
people
to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Отмена
Пожалуйста,
зарегистрируйтесь
или
войдите
чтобы прокомментировать