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
0
Merge Requests
0
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
Léo-Paul Géneau
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
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
4 deletions
+34
-4
spec/lib/gitlab/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
...
@@ -22,12 +22,14 @@ describe Gitlab::ContributionsCalendar do
end
end
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_week
)
{
today
-
7
.
days
}
let
(
:last_year
)
{
today
-
1
.
year
}
let
(
:last_year
)
{
today
-
1
.
year
}
before
do
before
do
travel_to
to
day
travel_to
Time
.
now
.
utc
.
end_of_
day
end
end
after
do
after
do
...
@@ -38,7 +40,7 @@ describe Gitlab::ContributionsCalendar do
...
@@ -38,7 +40,7 @@ describe Gitlab::ContributionsCalendar do
described_class
.
new
(
contributor
,
current_user
)
described_class
.
new
(
contributor
,
current_user
)
end
end
def
create_event
(
project
,
day
)
def
create_event
(
project
,
day
,
hour
=
0
)
@targets
||=
{}
@targets
||=
{}
@targets
[
project
]
||=
create
(
:issue
,
project:
project
,
author:
contributor
)
@targets
[
project
]
||=
create
(
:issue
,
project:
project
,
author:
contributor
)
...
@@ -47,7 +49,7 @@ describe Gitlab::ContributionsCalendar do
...
@@ -47,7 +49,7 @@ describe Gitlab::ContributionsCalendar do
action:
Event
::
CREATED
,
action:
Event
::
CREATED
,
target:
@targets
[
project
],
target:
@targets
[
project
],
author:
contributor
,
author:
contributor
,
created_at:
day
created_at:
DateTime
.
new
(
day
.
year
,
day
.
month
,
day
.
day
,
hour
)
)
)
end
end
...
@@ -68,6 +70,34 @@ describe Gitlab::ContributionsCalendar do
...
@@ -68,6 +70,34 @@ describe Gitlab::ContributionsCalendar do
expect
(
calendar
(
user
).
activity_dates
[
today
]).
to
eq
(
0
)
expect
(
calendar
(
user
).
activity_dates
[
today
]).
to
eq
(
0
)
expect
(
calendar
(
contributor
).
activity_dates
[
today
]).
to
eq
(
2
)
expect
(
calendar
(
contributor
).
activity_dates
[
today
]).
to
eq
(
2
)
end
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
end
describe
'#events_by_date'
do
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