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
f7112776
Commit
f7112776
authored
Aug 14, 2017
by
Robert Speicher
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'ee-32004-use-timecop-safe-mode' into 'master'
[EE] Enable Timecop safe mode See merge request !2664
parents
0a365bda
f9aaeee6
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
69 additions
and
113 deletions
+69
-113
spec/ee/spec/features/boards/sidebar_spec.rb
spec/ee/spec/features/boards/sidebar_spec.rb
+4
-5
spec/features/boards/sidebar_spec.rb
spec/features/boards/sidebar_spec.rb
+5
-7
spec/features/groups/milestone_spec.rb
spec/features/groups/milestone_spec.rb
+4
-6
spec/lib/gitlab/background_migration/update_authorized_keys_file_since_spec.rb
...round_migration/update_authorized_keys_file_since_spec.rb
+6
-14
spec/lib/gitlab/git/storage/circuit_breaker_spec.rb
spec/lib/gitlab/git/storage/circuit_breaker_spec.rb
+1
-5
spec/lib/gitlab/metrics/requests_rack_middleware_spec.rb
spec/lib/gitlab/metrics/requests_rack_middleware_spec.rb
+6
-12
spec/migrations/update_authorized_keys_file_spec.rb
spec/migrations/update_authorized_keys_file_spec.rb
+7
-11
spec/models/burndown_spec.rb
spec/models/burndown_spec.rb
+18
-18
spec/models/issue_spec.rb
spec/models/issue_spec.rb
+3
-7
spec/models/remote_mirror_spec.rb
spec/models/remote_mirror_spec.rb
+6
-11
spec/requests/api/internal_spec.rb
spec/requests/api/internal_spec.rb
+4
-5
spec/serializers/analytics_build_entity_spec.rb
spec/serializers/analytics_build_entity_spec.rb
+2
-6
spec/spec_helper.rb
spec/spec_helper.rb
+1
-0
spec/workers/repository_update_remote_mirror_worker_spec.rb
spec/workers/repository_update_remote_mirror_worker_spec.rb
+2
-6
No files found.
spec/ee/spec/features/boards/sidebar_spec.rb
View file @
f7112776
...
...
@@ -13,8 +13,11 @@ describe 'Issue Boards', :js do
let!
(
:list
)
{
create
(
:list
,
board:
board
,
label:
development
,
position:
0
)
}
let
(
:card
)
{
find
(
'.board:nth-child(2)'
).
first
(
'.card'
)
}
around
do
|
example
|
Timecop
.
freeze
{
example
.
run
}
end
before
do
Timecop
.
freeze
stub_licensed_features
(
multiple_issue_assignees:
true
)
project
.
team
<<
[
user
,
:master
]
...
...
@@ -26,10 +29,6 @@ describe 'Issue Boards', :js do
wait_for_requests
end
after
do
Timecop
.
return
end
context
'assignee'
do
it
'updates the issues assignee'
do
click_card
(
card
)
...
...
spec/features/boards/sidebar_spec.rb
View file @
f7112776
...
...
@@ -15,11 +15,13 @@ describe 'Issue Boards', js: true do
let!
(
:list
)
{
create
(
:list
,
board:
board
,
label:
development
,
position:
0
)
}
let
(
:card
)
{
find
(
'.board:nth-child(2)'
).
first
(
'.card'
)
}
around
do
|
example
|
Timecop
.
freeze
{
example
.
run
}
end
before
do
Timecop
.
freeze
stub_licensed_features
(
multiple_issue_assignees:
false
)
project
.
team
<<
[
user
,
:master
]
project
.
add_master
(
user
)
sign_in
(
user
)
...
...
@@ -27,10 +29,6 @@ describe 'Issue Boards', js: true do
wait_for_requests
end
after
do
Timecop
.
return
end
it
'shows sidebar when clicking issue'
do
click_card
(
card
)
...
...
spec/features/groups/milestone_spec.rb
View file @
f7112776
...
...
@@ -5,14 +5,12 @@ feature 'Group milestones', :js do
let!
(
:project
)
{
create
(
:project_empty_repo
,
group:
group
)
}
let
(
:user
)
{
create
(
:group_member
,
:master
,
user:
create
(
:user
),
group:
group
).
user
}
before
do
Timecop
.
freeze
sign_in
(
user
)
around
do
|
example
|
Timecop
.
freeze
{
example
.
run
}
end
after
do
Timecop
.
return
before
do
sign_in
(
user
)
end
context
'create a milestone'
do
...
...
spec/lib/gitlab/background_migration/update_authorized_keys_file_since_spec.rb
View file @
f7112776
...
...
@@ -8,16 +8,12 @@ describe Gitlab::BackgroundMigration::UpdateAuthorizedKeysFileSince do
subject
{
background_migration
.
perform
(
cutoff_datetime
)
}
context
'when an SSH key was created after the cutoff datetime'
do
before
do
Timecop
.
freeze
end
after
do
Timecop
.
return
end
around
do
|
example
|
Timecop
.
travel
(
1
.
day
.
from_now
)
{
example
.
run
}
end
context
'when an SSH key was created after the cutoff datetime'
do
before
do
Timecop
.
travel
1
.
day
.
from_now
@key
=
create
(
:key
)
end
...
...
@@ -38,16 +34,12 @@ describe Gitlab::BackgroundMigration::UpdateAuthorizedKeysFileSince do
subject
{
background_migration
.
add_keys_since
(
cutoff_datetime
)
}
before
do
Timecop
.
freeze
end
after
do
Timecop
.
return
around
do
|
example
|
Timecop
.
travel
(
1
.
day
.
from_now
)
{
example
.
run
}
end
context
'when an SSH key was created after the cutoff datetime'
do
before
do
Timecop
.
travel
1
.
day
.
from_now
@key
=
create
(
:key
)
create
(
:key
)
# other key
end
...
...
spec/lib/gitlab/git/storage/circuit_breaker_spec.rb
View file @
f7112776
...
...
@@ -175,11 +175,7 @@ describe Gitlab::Git::Storage::CircuitBreaker, clean_gitlab_redis_shared_state:
describe
'#track_storage_inaccessible'
do
around
do
|
example
|
Timecop
.
freeze
example
.
run
Timecop
.
return
Timecop
.
freeze
{
example
.
run
}
end
it
'records the failure time in redis'
do
...
...
spec/lib/gitlab/metrics/requests_rack_middleware_spec.rb
View file @
f7112776
...
...
@@ -4,10 +4,6 @@ describe Gitlab::Metrics::RequestsRackMiddleware do
let
(
:app
)
{
double
(
'app'
)
}
subject
{
described_class
.
new
(
app
)
}
around
do
|
example
|
Timecop
.
freeze
{
example
.
run
}
end
describe
'#call'
do
let
(
:status
)
{
100
}
let
(
:env
)
{
{
'REQUEST_METHOD'
=>
'GET'
}
}
...
...
@@ -28,16 +24,14 @@ describe Gitlab::Metrics::RequestsRackMiddleware do
subject
.
call
(
env
)
end
it
'measures execution time'
do
execution_time
=
10
allow
(
app
).
to
receive
(
:call
)
do
|*
args
|
Timecop
.
freeze
(
execution_time
.
seconds
)
[
200
,
nil
,
nil
]
end
RSpec
::
Matchers
.
define
:a_positive_execution_time
do
match
{
|
actual
|
actual
>
0
}
end
expect
(
described_class
).
to
receive_message_chain
(
:http_request_duration_seconds
,
:observe
).
with
({
status:
200
,
method:
'get'
},
execution_time
)
it
'measures execution time'
do
expect
(
described_class
).
to
receive_message_chain
(
:http_request_duration_seconds
,
:observe
).
with
({
status:
200
,
method:
'get'
},
a_positive_execution_time
)
subject
.
call
(
env
)
Timecop
.
scale
(
3600
)
{
subject
.
call
(
env
)
}
end
end
...
...
spec/migrations/update_authorized_keys_file_spec.rb
View file @
f7112776
...
...
@@ -21,20 +21,16 @@ describe UpdateAuthorizedKeysFile, :migration do
end
context
'there are keys created before and after the cutoff datetime'
do
before
do
Timecop
.
freeze
end
after
do
Timecop
.
return
end
before
do
@cutoff_datetime
=
UpdateAuthorizedKeysFile
::
DATETIME_9_3_0_RELEASED
@keys
=
[]
Timecop
.
travel
(
@cutoff_datetime
-
1
.
day
)
2
.
times
{
@keys
<<
create
(
:key
)
}
# 2 keys before cutoff
Timecop
.
travel
(
@cutoff_datetime
+
1
.
day
)
2
.
times
{
@keys
<<
create
(
:key
)
}
# 2 keys after cutoff
Timecop
.
travel
(
@cutoff_datetime
-
1
.
day
)
do
2
.
times
{
@keys
<<
create
(
:key
)
}
# 2 keys before cutoff
end
Timecop
.
travel
(
@cutoff_datetime
+
1
.
day
)
do
2
.
times
{
@keys
<<
create
(
:key
)
}
# 2 keys after cutoff
end
end
it
'adds the keys created after the cutoff datetime to the authorized_keys file'
do
...
...
spec/models/burndown_spec.rb
View file @
f7112776
...
...
@@ -18,15 +18,17 @@ describe Burndown do
}
end
around
do
|
example
|
Timecop
.
travel
(
due_date
)
do
example
.
run
end
end
before
do
project
.
add_master
(
user
)
build_sample
end
after
do
Timecop
.
return
end
subject
{
described_class
.
new
(
milestone
).
to_json
}
it
"generates an array with date, issue count and weight"
do
...
...
@@ -52,9 +54,9 @@ describe Burndown do
end
it
"it counts until today if milestone due date > Date.today"
do
Timecop
.
travel
(
milestone
.
due_date
-
1
.
day
)
e
xpect
(
JSON
.
parse
(
subject
).
last
[
0
]).
to
eq
(
Time
.
now
.
strftime
(
"%Y-%m-%d"
))
Timecop
.
travel
(
milestone
.
due_date
-
1
.
day
)
do
expect
(
JSON
.
parse
(
subject
).
last
[
0
]).
to
eq
(
Time
.
now
.
strftime
(
"%Y-%m-%d"
))
e
nd
end
it
"sets attribute accurate to true"
do
...
...
@@ -104,19 +106,17 @@ describe Burndown do
next
if
day
.
even?
count
=
day
*
4
Timecop
.
travel
(
date
)
Timecop
.
travel
(
date
)
do
# Create issues
issues
=
create_list
(
:issue
,
count
,
issue_params
)
# Create issues
issues
=
create_list
(
:issue
,
count
,
issue_params
)
# Close issues
closed
=
issues
.
slice
(
0
..
count
/
2
)
closed
.
each
(
&
:close
)
# Close issues
closed
=
issues
.
slice
(
0
..
count
/
2
)
closed
.
each
(
&
:close
)
# Reopen issues
closed
.
slice
(
0
..
count
/
4
).
each
(
&
:reopen
)
# Reopen issues
closed
.
slice
(
0
..
count
/
4
).
each
(
&
:reopen
)
end
end
Timecop
.
travel
(
due_date
)
end
end
spec/models/issue_spec.rb
View file @
f7112776
...
...
@@ -57,18 +57,14 @@ describe Issue do
end
describe
'#closed_at'
do
after
do
Timecop
.
return
end
let!
(
:now
)
{
Timecop
.
freeze
(
Time
.
now
)
}
it
'sets closed_at to Time.now when issue is closed'
do
issue
=
create
(
:issue
,
state:
'opened'
)
expect
(
issue
.
closed_at
).
to
be_nil
issue
.
close
expect
(
issue
.
closed_at
).
to
eq
(
now
)
expect
(
issue
.
closed_at
).
to
be_present
end
end
...
...
spec/models/remote_mirror_spec.rb
View file @
f7112776
...
...
@@ -88,12 +88,8 @@ describe RemoteMirror do
context
'#sync'
do
let
(
:remote_mirror
)
{
create
(
:project
,
:repository
,
:remote_mirror
).
remote_mirrors
.
first
}
before
do
Timecop
.
freeze
(
Time
.
now
)
end
after
do
Timecop
.
return
around
do
|
example
|
Timecop
.
freeze
{
example
.
run
}
end
context
'repository mirrors not licensed'
do
...
...
@@ -145,13 +141,12 @@ describe RemoteMirror do
let
(
:remote_mirror
)
{
create
(
:project
,
:repository
,
:remote_mirror
).
remote_mirrors
.
first
}
let
(
:timestamp
)
{
Time
.
now
-
5
.
minutes
}
before
do
Timecop
.
freeze
(
Time
.
now
)
remote_mirror
.
update_attributes
(
last_update_started_at:
Time
.
now
)
around
do
|
example
|
Timecop
.
freeze
{
example
.
run
}
end
after
do
Timecop
.
return
before
do
remote_mirror
.
update_attributes
(
last_update_started_at:
Time
.
now
)
end
context
'when remote mirror does not have status failed'
do
...
...
spec/requests/api/internal_spec.rb
View file @
f7112776
...
...
@@ -229,13 +229,12 @@ describe API::Internal do
describe
"POST /internal/allowed"
,
:clean_gitlab_redis_shared_state
do
context
"access granted"
do
before
do
project
.
team
<<
[
user
,
:developer
]
Timecop
.
freeze
around
do
|
example
|
Timecop
.
freeze
{
example
.
run
}
end
after
do
Timecop
.
return
before
do
project
.
team
<<
[
user
,
:developer
]
end
context
'with env passed as a JSON'
do
...
...
spec/serializers/analytics_build_entity_spec.rb
View file @
f7112776
...
...
@@ -13,12 +13,8 @@ describe AnalyticsBuildEntity do
subject
{
entity
.
as_json
}
before
do
Timecop
.
freeze
end
after
do
Timecop
.
return
around
do
|
example
|
Timecop
.
freeze
{
example
.
run
}
end
it
'contains the URL'
do
...
...
spec/spec_helper.rb
View file @
f7112776
...
...
@@ -83,6 +83,7 @@ RSpec.configure do |config|
end
config
.
before
(
:suite
)
do
Timecop
.
safe_mode
=
true
TestEnv
.
init
end
...
...
spec/workers/repository_update_remote_mirror_worker_spec.rb
View file @
f7112776
...
...
@@ -6,12 +6,8 @@ describe RepositoryUpdateRemoteMirrorWorker do
let
(
:remote_mirror
)
{
create
(
:project
,
:repository
,
:remote_mirror
).
remote_mirrors
.
first
}
let
(
:scheduled_time
)
{
Time
.
now
-
5
.
minutes
}
before
do
Timecop
.
freeze
(
Time
.
now
)
end
after
do
Timecop
.
return
around
do
|
example
|
Timecop
.
freeze
(
Time
.
now
)
{
example
.
run
}
end
describe
'#perform'
do
...
...
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