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
c6afe660
Commit
c6afe660
authored
May 25, 2020
by
John Cai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ApplicationSetting ui changes for repository_storages_weighted
parent
3793df51
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
84 additions
and
9 deletions
+84
-9
app/views/admin/application_settings/_repository_storage.html.haml
.../admin/application_settings/_repository_storage.html.haml
+3
-3
changelogs/unreleased/jc-ui-repository-storages-weighted.yml
changelogs/unreleased/jc-ui-repository-storages-weighted.yml
+5
-0
db/post_migrate/20200526000407_seed_repository_storages_weighted.rb
...grate/20200526000407_seed_repository_storages_weighted.rb
+23
-0
db/structure.sql
db/structure.sql
+1
-0
spec/features/admin/admin_settings_spec.rb
spec/features/admin/admin_settings_spec.rb
+13
-0
spec/migrations/seed_repository_storages_weighted_spec.rb
spec/migrations/seed_repository_storages_weighted_spec.rb
+31
-0
spec/views/admin/application_settings/_repository_storage.html.haml_spec.rb
...pplication_settings/_repository_storage.html.haml_spec.rb
+8
-6
No files found.
app/views/admin/application_settings/_repository_storage.html.haml
View file @
c6afe660
...
...
@@ -18,9 +18,9 @@
=
_
(
'Select the configured storage available for new repositories to be placed on.'
)
=
link_to
icon
(
'question-circle'
),
help_page_path
(
'administration/repository_storage_paths'
)
.form-check
=
f
.
collection_check_boxes
:repository_storages
,
Gitlab
.
config
.
repositories
.
storages
,
:first
,
:first
,
include_hidden:
false
do
|
b
|
=
b
.
check_box
class:
'form-check
-input'
=
b
.
label
class:
'label-bold form-check-label'
-
@application_setting
.
repository_storages_weighted
.
each_key
do
|
storage
|
=
f
.
text_field
"repository_storages_weighted_
#{
storage
}
"
.
to_sym
,
class:
'form-text
-input'
=
f
.
label
storage
,
storage
,
class:
'label-bold form-check-label'
%br
=
f
.
submit
_
(
'Save changes'
),
class:
"btn btn-success qa-save-changes-button"
changelogs/unreleased/jc-ui-repository-storages-weighted.yml
0 → 100644
View file @
c6afe660
---
title
:
Add ApplicationSetting ui changes for repository_storages_weighted
merge_request
:
33096
author
:
type
:
added
db/post_migrate/20200526000407_seed_repository_storages_weighted.rb
0 → 100644
View file @
c6afe660
# frozen_string_literal: true
class
SeedRepositoryStoragesWeighted
<
ActiveRecord
::
Migration
[
6.0
]
class
ApplicationSetting
<
ActiveRecord
::
Base
serialize
:repository_storages
self
.
table_name
=
'application_settings'
end
def
up
ApplicationSetting
.
all
.
each
do
|
settings
|
storages
=
Gitlab
.
config
.
repositories
.
storages
.
keys
.
collect
do
|
storage
|
weight
=
settings
.
repository_storages
.
include?
(
storage
)
?
100
:
0
[
storage
,
weight
]
end
settings
.
repository_storages_weighted
=
Hash
[
storages
]
settings
.
save!
end
end
def
down
end
end
db/structure.sql
View file @
c6afe660
...
...
@@ -13955,6 +13955,7 @@ COPY "schema_migrations" (version) FROM STDIN;
20200521022725
20200525114553
20200525121014
20200526000407
20200526120714
20200526164946
20200526164947
...
...
spec/features/admin/admin_settings_spec.rb
View file @
c6afe660
...
...
@@ -277,6 +277,19 @@ describe 'Admin updates settings', :clean_gitlab_redis_shared_state, :do_not_moc
end
end
context
'Repository page'
do
it
'Change Repository storage settings'
do
visit
repository_admin_application_settings_path
page
.
within
(
'.as-repository-storage'
)
do
fill_in
'application_setting_repository_storages_weighted_default'
,
with:
50
click_button
'Save changes'
end
expect
(
current_settings
.
repository_storages_weighted_default
).
to
be
50
end
end
context
'Reporting page'
do
it
'Change Spam settings'
do
visit
reporting_admin_application_settings_path
...
...
spec/migrations/seed_repository_storages_weighted_spec.rb
0 → 100644
View file @
c6afe660
# frozen_string_literal: true
require
'spec_helper'
require
Rails
.
root
.
join
(
'db'
,
'post_migrate'
,
'20200526000407_seed_repository_storages_weighted.rb'
)
describe
SeedRepositoryStoragesWeighted
do
let
(
:storages
)
{
{
"foo"
=>
{},
"baz"
=>
{}
}
}
let
(
:application_settings
)
do
table
(
:application_settings
).
tap
do
|
klass
|
klass
.
class_eval
do
serialize
:repository_storages
end
end
end
before
do
allow
(
Gitlab
.
config
.
repositories
).
to
receive
(
:storages
).
and_return
(
storages
)
end
let
(
:application_setting
)
{
application_settings
.
create
}
let
(
:repository_storages
)
{
[
"foo"
]
}
it
'correctly schedules background migrations'
do
application_setting
.
repository_storages
=
repository_storages
application_setting
.
save!
migrate!
expect
(
application_settings
.
find
(
application_setting
.
id
).
repository_storages_weighted
).
to
eq
({
"foo"
=>
100
,
"baz"
=>
0
})
end
end
spec/views/admin/application_settings/_repository_storage.html.haml_spec.rb
View file @
c6afe660
...
...
@@ -3,24 +3,26 @@
require
'spec_helper'
describe
'admin/application_settings/_repository_storage.html.haml'
do
let
(
:app_settings
)
{
build
(
:application_setting
)
}
let
(
:
storages
)
do
let
(
:app_settings
)
{
create
(
:application_setting
)
}
let
(
:
repository_storages_weighted
)
do
{
"mepmep"
=>
{
"path"
=>
"/tmp"
}
,
"foobar"
=>
{
"path"
=>
"/tmp"
}
"mepmep"
=>
100
,
"foobar"
=>
50
}
end
before
do
allow
(
app_settings
).
to
receive
(
:repository_storages_weighted
).
and_return
(
repository_storages_weighted
)
allow
(
app_settings
).
to
receive
(
:repository_storages_weighted_mepmep
).
and_return
(
100
)
allow
(
app_settings
).
to
receive
(
:repository_storages_weighted_foobar
).
and_return
(
50
)
assign
(
:application_setting
,
app_settings
)
stub_storage_settings
(
storages
)
end
context
'when multiple storages are available'
do
it
'lists them all'
do
render
storages
.
keys
.
each
do
|
storage_name
|
repository_storages_weighted
.
each
do
|
storage_name
,
storage_weight
|
expect
(
rendered
).
to
have_content
(
storage_name
)
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