Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include full address in ical event #1036

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/helpers/ical_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def icalendar(*events)
item.dtstart = event.date
item.dtend = event.end_date
item.url = event_url(event)
item.location = event.location.name if event.location
item.location = event.location.calendar_event_address if event.location
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To ensure that this feature will work in the future when the code base changes. Could you please add a test for this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need explicit tests for this or would the smoke testing in the events controller specs surfice, given that we already have the calendar event address test?

end
end
end.to_s
Expand Down
8 changes: 8 additions & 0 deletions app/models/location.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ def address
"#{street} #{house_number}, #{zip} #{city}"
end

def calendar_event_address
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To ensure that this feature will work in the future when the code base changes. Could you please add a test for this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if [street, house_number, zip, city].all?(&:present?)
address
else
name
end
end

def nice_url
URI.parse(url).host
end
Expand Down
10 changes: 10 additions & 0 deletions spec/models/location_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@
end
end

describe "#calendar_event_address" do
it "returns the full address if all fields are present" do
expect(@location.calendar_event_address).to eq(@location.address)
end

it "returns the location name if not all fields are present" do
expect(@virtual_location.calendar_event_address).to eq(@virtual_location.name)
end
end

describe '#geocoding' do
it 'geocodes once a location is saved' do
Location.all.find_each do |locn|
Expand Down