BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
cf2d2cd3
Commit
cf2d2cd3
authored
Jul 31, 2017
by
Mike Greiling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add tests for proper timezone date grouping within ContributionsCalendar
parent
d1f5e81e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
4 deletions
+34
-4
contributions_calendar_spec.rb
spec/lib/gitlab/contributions_calendar_spec.rb
+34
-4
No files found.
spec/lib/gitlab/contributions_calendar_spec.rb
View file @
cf2d2cd3
...
...
@@ -22,12 +22,14 @@ describe Gitlab::ContributionsCalendar do
end
end
let
(
:today
)
{
Time
.
now
.
to_date
}
let
(
:today
)
{
Time
.
now
.
utc
.
to_date
}
let
(
:yesterday
)
{
today
-
1
.
day
}
let
(
:tomorrow
)
{
today
+
1
.
day
}
let
(
:last_week
)
{
today
-
7
.
days
}
let
(
:last_year
)
{
today
-
1
.
year
}
before
do
travel_to
to
day
travel_to
Time
.
now
.
utc
.
end_of_
day
end
after
do
...
...
@@ -38,7 +40,7 @@ describe Gitlab::ContributionsCalendar do
described_class
.
new
(
contributor
,
current_user
)
end
def
create_event
(
project
,
day
)
def
create_event
(
project
,
day
,
hour
=
0
)
@targets
||=
{}
@targets
[
project
]
||=
create
(
:issue
,
project:
project
,
author:
contributor
)
...
...
@@ -47,7 +49,7 @@ describe Gitlab::ContributionsCalendar do
action:
Event
::
CREATED
,
target:
@targets
[
project
],
author:
contributor
,
created_at:
day
created_at:
DateTime
.
new
(
day
.
year
,
day
.
month
,
day
.
day
,
hour
)
)
end
...
...
@@ -68,6 +70,34 @@ describe Gitlab::ContributionsCalendar do
expect
(
calendar
(
user
).
activity_dates
[
today
]).
to
eq
(
0
)
expect
(
calendar
(
contributor
).
activity_dates
[
today
]).
to
eq
(
2
)
end
context
"when events fall under different dates depending on the time zone"
do
before
do
create_event
(
public_project
,
today
,
1
)
create_event
(
public_project
,
today
,
4
)
create_event
(
public_project
,
today
,
10
)
create_event
(
public_project
,
today
,
16
)
create_event
(
public_project
,
today
,
23
)
end
it
"renders correct event counts within the UTC timezone"
do
Time
.
use_zone
(
'UTC'
)
do
expect
(
calendar
.
activity_dates
).
to
eq
(
today
=>
5
)
end
end
it
"renders correct event counts within the Sydney timezone"
do
Time
.
use_zone
(
'Sydney'
)
do
expect
(
calendar
.
activity_dates
).
to
eq
(
today
=>
3
,
tomorrow
=>
2
)
end
end
it
"renders correct event counts within the US Central timezone"
do
Time
.
use_zone
(
'Central Time (US & Canada)'
)
do
expect
(
calendar
.
activity_dates
).
to
eq
(
yesterday
=>
2
,
today
=>
3
)
end
end
end
end
describe
'#events_by_date'
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