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
c6561fa7
Commit
c6561fa7
authored
Feb 25, 2021
by
Fabio Pitino
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure use of UTC timezone when counting CI Minutes
parent
01032275
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
8 deletions
+16
-8
ee/app/models/ci/minutes/namespace_monthly_usage.rb
ee/app/models/ci/minutes/namespace_monthly_usage.rb
+5
-1
ee/app/models/ci/minutes/project_monthly_usage.rb
ee/app/models/ci/minutes/project_monthly_usage.rb
+5
-1
ee/spec/models/ci/minutes/namespace_monthly_usage_spec.rb
ee/spec/models/ci/minutes/namespace_monthly_usage_spec.rb
+3
-3
ee/spec/models/ci/minutes/project_monthly_usage_spec.rb
ee/spec/models/ci/minutes/project_monthly_usage_spec.rb
+3
-3
No files found.
ee/app/models/ci/minutes/namespace_monthly_usage.rb
View file @
c6561fa7
...
...
@@ -9,7 +9,11 @@ module Ci
belongs_to
:namespace
scope
:current_month
,
->
{
where
(
date:
Time
.
current
.
utc
.
beginning_of_month
)
}
scope
:current_month
,
->
{
where
(
date:
beginning_of_month
)
}
def
self
.
beginning_of_month
(
time
=
Time
.
current
)
time
.
utc
.
beginning_of_month
end
# We should pretty much always use this method to access data for the current month
# since this will lazily create an entry if it doesn't exist.
...
...
ee/app/models/ci/minutes/project_monthly_usage.rb
View file @
c6561fa7
...
...
@@ -9,7 +9,11 @@ module Ci
belongs_to
:project
scope
:current_month
,
->
{
where
(
date:
Time
.
current
.
beginning_of_month
)
}
scope
:current_month
,
->
{
where
(
date:
beginning_of_month
)
}
def
self
.
beginning_of_month
(
time
=
Time
.
current
)
time
.
utc
.
beginning_of_month
end
# We should pretty much always use this method to access data for the current month
# since this will lazily create an entry if it doesn't exist.
...
...
ee/spec/models/ci/minutes/namespace_monthly_usage_spec.rb
View file @
c6561fa7
...
...
@@ -16,7 +16,7 @@ RSpec.describe Ci::Minutes::NamespaceMonthlyUsage do
end
it
'does not raise exception if unique index is not violated'
do
expect
{
create
(
:ci_namespace_monthly_usage
,
namespace:
namespace
,
date:
1
.
month
.
ago
.
utc
.
beginning_of_month
)
}
expect
{
create
(
:ci_namespace_monthly_usage
,
namespace:
namespace
,
date:
described_class
.
beginning_of_month
(
1
.
month
.
ago
)
)
}
.
to
change
{
described_class
.
count
}.
by
(
1
)
end
end
...
...
@@ -31,7 +31,7 @@ RSpec.describe Ci::Minutes::NamespaceMonthlyUsage do
expect
(
subject
.
amount_used
).
to
eq
(
0
)
expect
(
subject
.
namespace
).
to
eq
(
namespace
)
expect
(
subject
.
date
).
to
eq
(
Time
.
current
.
beginning_of_month
)
expect
(
subject
.
date
).
to
eq
(
described_class
.
beginning_of_month
)
end
end
end
...
...
@@ -42,7 +42,7 @@ RSpec.describe Ci::Minutes::NamespaceMonthlyUsage do
context
'when namespace usage exists for previous months'
do
before
do
create
(
:ci_namespace_monthly_usage
,
namespace:
namespace
,
date:
2
.
months
.
ago
.
utc
.
beginning_of_month
)
create
(
:ci_namespace_monthly_usage
,
namespace:
namespace
,
date:
described_class
.
beginning_of_month
(
2
.
months
.
ago
)
)
end
it_behaves_like
'creates usage record'
...
...
ee/spec/models/ci/minutes/project_monthly_usage_spec.rb
View file @
c6561fa7
...
...
@@ -16,7 +16,7 @@ RSpec.describe Ci::Minutes::ProjectMonthlyUsage do
end
it
'does not raise exception if unique index is not violated'
do
expect
{
create
(
:ci_project_monthly_usage
,
project:
project
,
date:
1
.
month
.
ago
.
utc
.
beginning_of_month
)
}
expect
{
create
(
:ci_project_monthly_usage
,
project:
project
,
date:
described_class
.
beginning_of_month
(
1
.
month
.
ago
)
)
}
.
to
change
{
described_class
.
count
}.
by
(
1
)
end
end
...
...
@@ -31,7 +31,7 @@ RSpec.describe Ci::Minutes::ProjectMonthlyUsage do
expect
(
subject
.
amount_used
).
to
eq
(
0
)
expect
(
subject
.
project
).
to
eq
(
project
)
expect
(
subject
.
date
).
to
eq
(
Time
.
current
.
beginning_of_month
)
expect
(
subject
.
date
).
to
eq
(
described_class
.
beginning_of_month
)
end
end
end
...
...
@@ -42,7 +42,7 @@ RSpec.describe Ci::Minutes::ProjectMonthlyUsage do
context
'when project usage exists for previous months'
do
before
do
create
(
:ci_project_monthly_usage
,
project:
project
,
date:
2
.
months
.
ago
.
utc
.
beginning_of_month
)
create
(
:ci_project_monthly_usage
,
project:
project
,
date:
described_class
.
beginning_of_month
(
2
.
months
.
ago
)
)
end
it_behaves_like
'creates usage record'
...
...
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