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
2d5328ed
Commit
2d5328ed
authored
May 20, 2020
by
Sean Arnold
Committed by
Stan Hu
May 21, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More Time usages fixes for /models
Using cop to find offences
parent
2b467078
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
19 additions
and
19 deletions
+19
-19
app/models/pages_domain.rb
app/models/pages_domain.rb
+1
-1
ee/app/models/geo_node_status.rb
ee/app/models/geo_node_status.rb
+1
-1
ee/spec/models/geo_node_status_spec.rb
ee/spec/models/geo_node_status_spec.rb
+1
-1
spec/models/ci/pipeline_schedule_spec.rb
spec/models/ci/pipeline_schedule_spec.rb
+1
-1
spec/models/commit_status_spec.rb
spec/models/commit_status_spec.rb
+1
-1
spec/models/concerns/sortable_spec.rb
spec/models/concerns/sortable_spec.rb
+1
-1
spec/models/issue_spec.rb
spec/models/issue_spec.rb
+4
-4
spec/models/iteration_spec.rb
spec/models/iteration_spec.rb
+6
-6
spec/models/merge_request_diff_commit_spec.rb
spec/models/merge_request_diff_commit_spec.rb
+1
-1
spec/models/pages_domain_spec.rb
spec/models/pages_domain_spec.rb
+2
-2
No files found.
app/models/pages_domain.rb
View file @
2d5328ed
...
@@ -141,7 +141,7 @@ class PagesDomain < ApplicationRecord
...
@@ -141,7 +141,7 @@ class PagesDomain < ApplicationRecord
def
expired?
def
expired?
return
false
unless
x509
return
false
unless
x509
current
=
Time
.
new
current
=
Time
.
current
current
<
x509
.
not_before
||
x509
.
not_after
<
current
current
<
x509
.
not_before
||
x509
.
not_after
<
current
end
end
...
...
ee/app/models/geo_node_status.rb
View file @
2d5328ed
...
@@ -300,7 +300,7 @@ class GeoNodeStatus < ApplicationRecord
...
@@ -300,7 +300,7 @@ class GeoNodeStatus < ApplicationRecord
end
end
def
attribute_timestamp
=
(
attr
,
value
)
def
attribute_timestamp
=
(
attr
,
value
)
self
[
attr
]
=
Time
.
at
(
value
)
self
[
attr
]
=
Time
.
zone
.
at
(
value
)
end
end
def
self
.
percentage_methods
def
self
.
percentage_methods
...
...
ee/spec/models/geo_node_status_spec.rb
View file @
2d5328ed
...
@@ -1114,7 +1114,7 @@ describe GeoNodeStatus, :geo, :geo_fdw do
...
@@ -1114,7 +1114,7 @@ describe GeoNodeStatus, :geo, :geo_fdw do
expect
(
result
.
id
).
to
be_nil
expect
(
result
.
id
).
to
be_nil
expect
(
result
.
attachments_count
).
to
eq
(
status
.
attachments_count
)
expect
(
result
.
attachments_count
).
to
eq
(
status
.
attachments_count
)
expect
(
result
.
cursor_last_event_date
).
to
eq
(
Time
.
at
(
status
.
cursor_last_event_timestamp
))
expect
(
result
.
cursor_last_event_date
).
to
eq
(
Time
.
zone
.
at
(
status
.
cursor_last_event_timestamp
))
expect
(
result
.
storage_shards
.
count
).
to
eq
(
Settings
.
repositories
.
storages
.
count
)
expect
(
result
.
storage_shards
.
count
).
to
eq
(
Settings
.
repositories
.
storages
.
count
)
end
end
end
end
...
...
spec/models/ci/pipeline_schedule_spec.rb
View file @
2d5328ed
...
@@ -118,7 +118,7 @@ describe Ci::PipelineSchedule do
...
@@ -118,7 +118,7 @@ describe Ci::PipelineSchedule do
let
(
:pipeline_schedule
)
{
create
(
:ci_pipeline_schedule
,
:every_minute
)
}
let
(
:pipeline_schedule
)
{
create
(
:ci_pipeline_schedule
,
:every_minute
)
}
it
"updates next_run_at to the sidekiq worker's execution time"
do
it
"updates next_run_at to the sidekiq worker's execution time"
do
Timecop
.
freeze
(
Time
.
parse
(
"2019-06-01 12:18:00+0000"
))
do
Timecop
.
freeze
(
Time
.
zone
.
parse
(
"2019-06-01 12:18:00+0000"
))
do
expect
(
pipeline_schedule
.
next_run_at
).
to
eq
(
cron_worker_next_run_at
)
expect
(
pipeline_schedule
.
next_run_at
).
to
eq
(
cron_worker_next_run_at
)
end
end
end
end
...
...
spec/models/commit_status_spec.rb
View file @
2d5328ed
...
@@ -708,7 +708,7 @@ describe CommitStatus do
...
@@ -708,7 +708,7 @@ describe CommitStatus do
end
end
describe
'#enqueue'
do
describe
'#enqueue'
do
let!
(
:current_time
)
{
Time
.
new
(
2018
,
4
,
5
,
14
,
0
,
0
)
}
let!
(
:current_time
)
{
Time
.
zone
.
local
(
2018
,
4
,
5
,
14
,
0
,
0
)
}
before
do
before
do
allow
(
Time
).
to
receive
(
:now
).
and_return
(
current_time
)
allow
(
Time
).
to
receive
(
:now
).
and_return
(
current_time
)
...
...
spec/models/concerns/sortable_spec.rb
View file @
2d5328ed
...
@@ -91,7 +91,7 @@ describe Sortable do
...
@@ -91,7 +91,7 @@ describe Sortable do
Group
.
all
.
order_by
(
order
).
map
(
&
:name
)
Group
.
all
.
order_by
(
order
).
map
(
&
:name
)
end
end
let!
(
:ref_time
)
{
Time
.
parse
(
'2018-05-01 00:00:00'
)
}
let!
(
:ref_time
)
{
Time
.
zone
.
parse
(
'2018-05-01 00:00:00'
)
}
let!
(
:group1
)
{
create
(
:group
,
name:
'aa'
,
id:
1
,
created_at:
ref_time
-
15
.
seconds
,
updated_at:
ref_time
)
}
let!
(
:group1
)
{
create
(
:group
,
name:
'aa'
,
id:
1
,
created_at:
ref_time
-
15
.
seconds
,
updated_at:
ref_time
)
}
let!
(
:group2
)
{
create
(
:group
,
name:
'AAA'
,
id:
2
,
created_at:
ref_time
-
10
.
seconds
,
updated_at:
ref_time
-
5
.
seconds
)
}
let!
(
:group2
)
{
create
(
:group
,
name:
'AAA'
,
id:
2
,
created_at:
ref_time
-
10
.
seconds
,
updated_at:
ref_time
-
5
.
seconds
)
}
let!
(
:group3
)
{
create
(
:group
,
name:
'BB'
,
id:
3
,
created_at:
ref_time
-
5
.
seconds
,
updated_at:
ref_time
-
10
.
seconds
)
}
let!
(
:group3
)
{
create
(
:group
,
name:
'BB'
,
id:
3
,
created_at:
ref_time
-
5
.
seconds
,
updated_at:
ref_time
-
10
.
seconds
)
}
...
...
spec/models/issue_spec.rb
View file @
2d5328ed
...
@@ -994,7 +994,7 @@ describe Issue do
...
@@ -994,7 +994,7 @@ describe Issue do
it_behaves_like
'versioned description'
it_behaves_like
'versioned description'
describe
"#previous_updated_at"
do
describe
"#previous_updated_at"
do
let_it_be
(
:updated_at
)
{
Time
.
new
(
2012
,
01
,
06
)
}
let_it_be
(
:updated_at
)
{
Time
.
zone
.
local
(
2012
,
01
,
06
)
}
let_it_be
(
:issue
)
{
create
(
:issue
,
updated_at:
updated_at
)
}
let_it_be
(
:issue
)
{
create
(
:issue
,
updated_at:
updated_at
)
}
it
'returns updated_at value if updated_at did not change at all'
do
it
'returns updated_at value if updated_at did not change at all'
do
...
@@ -1010,15 +1010,15 @@ describe Issue do
...
@@ -1010,15 +1010,15 @@ describe Issue do
end
end
it
'returns updated_at value if previous updated_at value is not present'
do
it
'returns updated_at value if previous updated_at value is not present'
do
allow
(
issue
).
to
receive
(
:previous_changes
).
and_return
({
'updated_at'
=>
[
nil
,
Time
.
new
(
2013
,
02
,
06
)]
})
allow
(
issue
).
to
receive
(
:previous_changes
).
and_return
({
'updated_at'
=>
[
nil
,
Time
.
zone
.
local
(
2013
,
02
,
06
)]
})
expect
(
issue
.
previous_updated_at
).
to
eq
(
updated_at
)
expect
(
issue
.
previous_updated_at
).
to
eq
(
updated_at
)
end
end
it
'returns previous updated_at when present'
do
it
'returns previous updated_at when present'
do
allow
(
issue
).
to
receive
(
:previous_changes
).
and_return
({
'updated_at'
=>
[
Time
.
new
(
2013
,
02
,
06
),
Time
.
new
(
2013
,
03
,
06
)]
})
allow
(
issue
).
to
receive
(
:previous_changes
).
and_return
({
'updated_at'
=>
[
Time
.
zone
.
local
(
2013
,
02
,
06
),
Time
.
zone
.
local
(
2013
,
03
,
06
)]
})
expect
(
issue
.
previous_updated_at
).
to
eq
(
Time
.
new
(
2013
,
02
,
06
))
expect
(
issue
.
previous_updated_at
).
to
eq
(
Time
.
zone
.
local
(
2013
,
02
,
06
))
end
end
end
end
...
...
spec/models/iteration_spec.rb
View file @
2d5328ed
...
@@ -62,7 +62,7 @@ describe Iteration do
...
@@ -62,7 +62,7 @@ describe Iteration do
end
end
context
'when end_date is in range'
do
context
'when end_date is in range'
do
let
(
:start_date
)
{
Time
.
now
}
let
(
:start_date
)
{
Time
.
current
}
let
(
:due_date
)
{
6
.
days
.
from_now
}
let
(
:due_date
)
{
6
.
days
.
from_now
}
it
'is not valid'
do
it
'is not valid'
do
...
@@ -94,7 +94,7 @@ describe Iteration do
...
@@ -94,7 +94,7 @@ describe Iteration do
describe
'#future_date'
do
describe
'#future_date'
do
context
'when dates are in the future'
do
context
'when dates are in the future'
do
let
(
:start_date
)
{
Time
.
now
}
let
(
:start_date
)
{
Time
.
current
}
let
(
:due_date
)
{
1
.
week
.
from_now
}
let
(
:due_date
)
{
1
.
week
.
from_now
}
it
{
is_expected
.
to
be_valid
}
it
{
is_expected
.
to
be_valid
}
...
@@ -111,7 +111,7 @@ describe Iteration do
...
@@ -111,7 +111,7 @@ describe Iteration do
end
end
context
'when due_date is in the past'
do
context
'when due_date is in the past'
do
let
(
:start_date
)
{
Time
.
now
}
let
(
:start_date
)
{
Time
.
current
}
let
(
:due_date
)
{
1
.
week
.
ago
}
let
(
:due_date
)
{
1
.
week
.
ago
}
it
'is not valid'
do
it
'is not valid'
do
...
@@ -122,7 +122,7 @@ describe Iteration do
...
@@ -122,7 +122,7 @@ describe Iteration do
context
'when start_date is over 500 years in the future'
do
context
'when start_date is over 500 years in the future'
do
let
(
:start_date
)
{
501
.
years
.
from_now
}
let
(
:start_date
)
{
501
.
years
.
from_now
}
let
(
:due_date
)
{
Time
.
now
}
let
(
:due_date
)
{
Time
.
current
}
it
'is not valid'
do
it
'is not valid'
do
expect
(
subject
).
not_to
be_valid
expect
(
subject
).
not_to
be_valid
...
@@ -131,7 +131,7 @@ describe Iteration do
...
@@ -131,7 +131,7 @@ describe Iteration do
end
end
context
'when due_date is over 500 years in the future'
do
context
'when due_date is over 500 years in the future'
do
let
(
:start_date
)
{
Time
.
now
}
let
(
:start_date
)
{
Time
.
current
}
let
(
:due_date
)
{
501
.
years
.
from_now
}
let
(
:due_date
)
{
501
.
years
.
from_now
}
it
'is not valid'
do
it
'is not valid'
do
...
@@ -143,7 +143,7 @@ describe Iteration do
...
@@ -143,7 +143,7 @@ describe Iteration do
end
end
describe
'.within_timeframe'
do
describe
'.within_timeframe'
do
let_it_be
(
:now
)
{
Time
.
now
}
let_it_be
(
:now
)
{
Time
.
current
}
let_it_be
(
:project
)
{
create
(
:project
,
:empty_repo
)
}
let_it_be
(
:project
)
{
create
(
:project
,
:empty_repo
)
}
let_it_be
(
:iteration_1
)
{
create
(
:iteration
,
project:
project
,
start_date:
now
,
due_date:
1
.
day
.
from_now
)
}
let_it_be
(
:iteration_1
)
{
create
(
:iteration
,
project:
project
,
start_date:
now
,
due_date:
1
.
day
.
from_now
)
}
let_it_be
(
:iteration_2
)
{
create
(
:iteration
,
project:
project
,
start_date:
2
.
days
.
from_now
,
due_date:
3
.
days
.
from_now
)
}
let_it_be
(
:iteration_2
)
{
create
(
:iteration
,
project:
project
,
start_date:
2
.
days
.
from_now
,
due_date:
3
.
days
.
from_now
)
}
...
...
spec/models/merge_request_diff_commit_spec.rb
View file @
2d5328ed
...
@@ -73,7 +73,7 @@ describe MergeRequestDiffCommit do
...
@@ -73,7 +73,7 @@ describe MergeRequestDiffCommit do
# This commit's date is "Sun Aug 17 07:12:55 292278994 +0000"
# This commit's date is "Sun Aug 17 07:12:55 292278994 +0000"
[
project
.
commit
(
'ba3343bc4fa403a8dfbfcab7fc1a8c29ee34bd69'
)]
[
project
.
commit
(
'ba3343bc4fa403a8dfbfcab7fc1a8c29ee34bd69'
)]
end
end
let
(
:timestamp
)
{
Time
.
at
((
1
<<
31
)
-
1
)
}
let
(
:timestamp
)
{
Time
.
zone
.
at
((
1
<<
31
)
-
1
)
}
let
(
:rows
)
do
let
(
:rows
)
do
[{
[{
"message"
:
"Weird commit date
\n
"
,
"message"
:
"Weird commit date
\n
"
,
...
...
spec/models/pages_domain_spec.rb
View file @
2d5328ed
...
@@ -97,8 +97,8 @@ describe PagesDomain do
...
@@ -97,8 +97,8 @@ describe PagesDomain do
it
'saves validity time'
do
it
'saves validity time'
do
domain
.
save
domain
.
save
expect
(
domain
.
certificate_valid_not_before
).
to
be_like_time
(
Time
.
parse
(
"2020-03-16 14:20:34 UTC"
))
expect
(
domain
.
certificate_valid_not_before
).
to
be_like_time
(
Time
.
zone
.
parse
(
"2020-03-16 14:20:34 UTC"
))
expect
(
domain
.
certificate_valid_not_after
).
to
be_like_time
(
Time
.
parse
(
"2220-01-28 14:20:34 UTC"
))
expect
(
domain
.
certificate_valid_not_after
).
to
be_like_time
(
Time
.
zone
.
parse
(
"2220-01-28 14:20:34 UTC"
))
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