Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
Admin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
osuny
Admin
Commits
504c1c11
Unverified
Commit
504c1c11
authored
1 year ago
by
Sébastien Gaya
Browse files
Options
Downloads
Patches
Plain Diff
fix and tests events
parent
dee54671
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/models/communication/website/agenda/event/with_cal.rb
+5
-2
5 additions, 2 deletions
app/models/communication/website/agenda/event/with_cal.rb
test/models/communication/website/agenda/event_test.rb
+98
-3
98 additions, 3 deletions
test/models/communication/website/agenda/event_test.rb
with
103 additions
and
5 deletions
app/models/communication/website/agenda/event/with_cal.rb
+
5
−
2
View file @
504c1c11
...
...
@@ -3,7 +3,7 @@ module Communication::Website::Agenda::Event::WithCal
def
cal
@cal
||=
AddToCalendar
::
URLs
.
new
(
start_datetime:
cal_from_time
,
start_datetime:
cal_from_time
,
end_datetime:
cal_to_time
,
timezone:
timezone
.
name
,
all_day:
cal_all_day
,
...
...
@@ -21,6 +21,9 @@ module Communication::Website::Agenda::Event::WithCal
end
def
cal_to_time
# Si all_day == true et qu'on ne transmet pas de date de fin, l'événement sera considéré comme un événement d'une journée
# On peut donc early return selon ces conditions
return
if
cal_all_day
&&
from_day
==
to_day
to_day
.
nil?
?
cal_to_time_with_no_end_day
:
cal_to_time_with_end_day
end
...
...
@@ -37,7 +40,7 @@ module Communication::Website::Agenda::Event::WithCal
def
cal_to_time_with_end_day
# Soit on a 1 heure de fin, et tout est simple
cal_end_time
=
to_hour
cal_end_time
=
to_hour
# Soit on n'en a pas, mais on a 1 heure de début, donc on ajoute 1 heure pour éviter les événements sans durée
cal_end_time
||=
from_hour
+
1
.
hour
if
from_hour
# Si rien n'a marché, on a nil
...
...
This diff is collapsed.
Click to expand it.
test/models/communication/website/agenda/event_test.rb
+
98
−
3
View file @
504c1c11
...
...
@@ -43,7 +43,102 @@
require
"test_helper"
class
Communication::Website::Agenda::EventTest
<
ActiveSupport
::
TestCase
# test "the truth" do
# assert true
# end
test
"valid cal file with specific dates and hours"
do
event
=
new_event
(
from_day:
Date
.
tomorrow
,
from_hour:
"09:00"
,
to_day:
Date
.
tomorrow
+
1
.
day
,
to_hour:
"19:00"
)
assert
(
event
.
valid?
)
assert_nothing_raised
{
event
.
cal
}
end
test
"valid cal file with specific hours on the same day"
do
event
=
new_event
(
from_day:
Date
.
tomorrow
,
from_hour:
"09:00"
,
to_day:
Date
.
tomorrow
,
to_hour:
"19:00"
)
assert
(
event
.
valid?
)
assert_nothing_raised
{
event
.
cal
}
end
test
"valid cal file with specific hours but no end date"
do
event
=
new_event
(
from_day:
Date
.
tomorrow
,
from_hour:
"09:00"
,
to_day:
nil
,
to_hour:
"19:00"
)
assert
(
event
.
valid?
)
assert_nothing_raised
{
event
.
cal
}
end
test
"valid cal file with specific dates but no end hour"
do
event
=
new_event
(
from_day:
Date
.
tomorrow
,
from_hour:
"09:00"
,
to_day:
Date
.
tomorrow
+
1
.
day
,
to_hour:
nil
)
assert
(
event
.
valid?
)
assert_nothing_raised
{
event
.
cal
}
end
test
"valid cal file on same day but no end hour"
do
event
=
new_event
(
from_day:
Date
.
tomorrow
,
from_hour:
"09:00"
,
to_day:
Date
.
tomorrow
,
to_hour:
nil
)
assert
(
event
.
valid?
)
assert_nothing_raised
{
event
.
cal
}
end
test
"valid cal file on same day but no hours"
do
event
=
new_event
(
from_day:
Date
.
tomorrow
,
from_hour:
nil
,
to_day:
Date
.
tomorrow
,
to_hour:
nil
)
assert
(
event
.
valid?
)
assert_nothing_raised
{
event
.
cal
}
end
test
"valid cal file with specific dates but no hours"
do
event
=
new_event
(
from_day:
Date
.
tomorrow
,
from_hour:
nil
,
to_day:
Date
.
tomorrow
+
1
.
day
,
to_hour:
nil
)
assert
(
event
.
valid?
)
assert_nothing_raised
{
event
.
cal
}
end
test
"valid cal file but no end"
do
event
=
new_event
(
from_day:
Date
.
tomorrow
,
from_hour:
"09:00"
,
to_day:
nil
,
to_hour:
nil
)
assert
(
event
.
valid?
)
assert_nothing_raised
{
event
.
cal
}
end
protected
def
new_event
(
**
options
)
website_with_github
.
agenda_events
.
new
(
title:
"An event"
,
university_id:
website_with_github
.
university_id
,
language_id:
website_with_github
.
default_language_id
,
**
options
)
end
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment