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
bc510c29
Commit
bc510c29
authored
Feb 14, 2017
by
Tiago Botelho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adds test suite for feature
parent
d4273e2b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
70 additions
and
7 deletions
+70
-7
app/helpers/mirror_helper.rb
app/helpers/mirror_helper.rb
+1
-1
app/views/projects/mirrors/show.html.haml
app/views/projects/mirrors/show.html.haml
+2
-2
lib/gitlab/mirror.rb
lib/gitlab/mirror.rb
+3
-3
spec/features/projects/mirror_spec.rb
spec/features/projects/mirror_spec.rb
+40
-1
spec/models/application_setting_spec.rb
spec/models/application_setting_spec.rb
+24
-0
No files found.
app/helpers/mirror_helper.rb
View file @
bc510c29
...
...
@@ -7,7 +7,7 @@ module MirrorHelper
def
mirror_sync_time_options
Gitlab
::
Mirror
.
sync_time_options
.
select
do
|
key
,
value
|
value
<
current_application_settings
.
minimum_mirror_sync_time
value
>=
current_application_settings
.
minimum_mirror_sync_time
end
end
end
app/views/projects/mirrors/show.html.haml
View file @
bc510c29
...
...
@@ -47,7 +47,7 @@
=
render
"shared/mirror_trigger_builds_setting"
,
f:
f
.form-group
=
f
.
label
:sync_time
,
"Synchronization time"
,
class:
"label-light append-bottom-0"
=
f
.
select
:sync_time
,
options_for_select
(
mirror_sync_time_options
,
@project
.
sync_time
),
{},
class:
'form-control'
=
f
.
select
:sync_time
,
options_for_select
(
mirror_sync_time_options
,
@project
.
sync_time
),
{},
class:
'form-control
project-mirror-sync-time
'
.col-sm-12
%hr
.col-lg-3
...
...
@@ -82,7 +82,7 @@
=
render
"instructions"
.form-group
=
rm_form
.
label
:sync_time
,
"Synchronization time"
,
class:
"label-light append-bottom-0"
=
rm_form
.
select
:sync_time
,
options_for_select
(
mirror_sync_time_options
,
@remote_mirror
.
sync_time
),
{},
class:
'form-control'
=
rm_form
.
select
:sync_time
,
options_for_select
(
mirror_sync_time_options
,
@remote_mirror
.
sync_time
),
{},
class:
'form-control
remote-mirror-sync-time
'
.col-sm-12.text-center
%hr
=
f
.
submit
'Save changes'
,
class:
'btn btn-create'
,
name:
'update_remote_mirror'
lib/gitlab/mirror.rb
View file @
bc510c29
...
...
@@ -34,9 +34,9 @@ module Gitlab
update_all_mirrors_worker_job
=
Sidekiq
::
Cron
::
Job
.
find
(
"update_all_mirrors_worker"
)
update_all_remote_mirrors_worker_job
=
Sidekiq
::
Cron
::
Job
.
find
(
"update_all_remote_mirrors_worker"
)
if
update_all_mirrors_worker
&&
update_all_remote_mirrors_worker
update_all_mirrors_worker
.
destroy
update_all_remote_mirrors_worker
.
destroy
if
update_all_mirrors_worker
_job
&&
update_all_remote_mirrors_worker_job
update_all_mirrors_worker
_job
.
destroy
update_all_remote_mirrors_worker
_job
.
destroy
end
Sidekiq
::
Cron
::
Job
.
create
(
...
...
spec/features/projects/mirror_spec.rb
View file @
bc510c29
...
...
@@ -8,15 +8,54 @@ feature 'Project mirror', feature: true do
before
do
project
.
team
<<
[
user
,
:master
]
login_as
user
visit
namespace_project_mirror_path
(
project
.
namespace
,
project
)
end
describe
'pressing "Update now"'
do
before
{
visit
namespace_project_mirror_path
(
project
.
namespace
,
project
)
}
it
'returns with the project updating (job enqueued)'
do
Sidekiq
::
Testing
.
fake!
{
click_link
(
'Update Now'
)
}
expect
(
page
).
to
have_content
(
'Updating'
)
end
end
describe
'synchronization times'
do
describe
'daily minimum mirror sync_time'
do
before
do
stub_application_setting
(
minimum_mirror_sync_time:
Gitlab
::
Mirror
::
DAILY
)
visit
namespace_project_mirror_path
(
project
.
namespace
,
project
)
end
it
'shows the correct selector options'
do
expect
(
page
).
to
have_selector
(
'.project-mirror-sync-time > option'
,
count:
1
)
expect
(
page
).
to
have_selector
(
'.remote-mirror-sync-time > option'
,
count:
1
)
end
end
describe
'hourly minimum mirror sync_time'
do
before
do
stub_application_setting
(
minimum_mirror_sync_time:
Gitlab
::
Mirror
::
HOURLY
)
visit
namespace_project_mirror_path
(
project
.
namespace
,
project
)
end
it
'shows the correct selector options'
do
expect
(
page
).
to
have_selector
(
'.project-mirror-sync-time > option'
,
count:
2
)
expect
(
page
).
to
have_selector
(
'.remote-mirror-sync-time > option'
,
count:
2
)
end
end
describe
'fifteen minimum mirror sync_time'
do
before
do
stub_application_setting
(
minimum_mirror_sync_time:
Gitlab
::
Mirror
::
FIFTEEN
)
visit
namespace_project_mirror_path
(
project
.
namespace
,
project
)
end
it
'shows the correct selector options'
do
expect
(
page
).
to
have_selector
(
'.project-mirror-sync-time > option'
,
count:
3
)
expect
(
page
).
to
have_selector
(
'.remote-mirror-sync-time > option'
,
count:
3
)
end
end
end
end
end
spec/models/application_setting_spec.rb
View file @
bc510c29
...
...
@@ -20,6 +20,12 @@ describe ApplicationSetting, models: true do
it
{
is_expected
.
to
allow_value
(
https
).
for
(
:after_sign_out_path
)
}
it
{
is_expected
.
not_to
allow_value
(
ftp
).
for
(
:after_sign_out_path
)
}
it
{
is_expected
.
to
allow_value
(
Gitlab
::
Mirror
::
FIFTEEN
).
for
(
:minimum_mirror_sync_time
)
}
it
{
is_expected
.
to
allow_value
(
Gitlab
::
Mirror
::
HOURLY
).
for
(
:minimum_mirror_sync_time
)
}
it
{
is_expected
.
to
allow_value
(
Gitlab
::
Mirror
::
DAILY
).
for
(
:minimum_mirror_sync_time
)
}
it
{
is_expected
.
not_to
allow_value
(
nil
).
for
(
:minimum_mirror_sync_time
)
}
it
{
is_expected
.
not_to
allow_value
(
61
).
for
(
:minimum_mirror_sync_time
)
}
describe
'disabled_oauth_sign_in_sources validations'
do
before
do
allow
(
Devise
).
to
receive
(
:omniauth_providers
).
and_return
([
:github
])
...
...
@@ -41,6 +47,24 @@ describe ApplicationSetting, models: true do
subject
{
setting
}
end
context
"update minimum_mirror_cron_jobs"
do
let
(
:daily_cron
)
{
Gitlab
::
Mirror
::
SYNC_TIME_TO_CRON
[
Gitlab
::
Mirror
::
DAILY
]
}
let
(
:hourly_cron
)
{
Gitlab
::
Mirror
::
SYNC_TIME_TO_CRON
[
Gitlab
::
Mirror
::
HOURLY
]
}
before
do
Gitlab
::
Mirror
.
configure_cron_jobs!
allow_any_instance_of
(
Gitlab
::
CurrentSettings
).
to
receive
(
:current_application_settings
).
and_return
(
setting
)
end
it
"changes update_all_mirrors_worker cron"
do
expect
{
setting
.
update_attributes
(
minimum_mirror_sync_time:
Gitlab
::
Mirror
::
DAILY
)
}.
to
change
{
Sidekiq
::
Cron
::
Job
.
find
(
"update_all_mirrors_worker"
).
cron
}.
from
(
hourly_cron
).
to
(
daily_cron
)
end
it
"changes update_all_remote_mirrors_worker cron"
do
expect
{
setting
.
update_attributes
(
minimum_mirror_sync_time:
Gitlab
::
Mirror
::
DAILY
)
}.
to
change
{
Sidekiq
::
Cron
::
Job
.
find
(
"update_all_remote_mirrors_worker"
).
cron
}.
from
(
hourly_cron
).
to
(
daily_cron
)
end
end
# Upgraded databases will have this sort of content
context
'repository_storages is a String, not an Array'
do
before
{
setting
.
__send__
(
:raw_write_attribute
,
:repository_storages
,
'default'
)
}
...
...
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