Skip to content
Closed
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### 2.3.0 (Next)

* [#89]https://github.com/dblock/strava-ruby-client/pull/89: Fix for time parsing in club events - [@tobiaszwaszak](https://github.com/tobiaszwaszak).
Copy link
Owner

@dblock dblock May 31, 2025

Choose a reason for hiding this comment

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

Suggested change
* [#89]https://github.com/dblock/strava-ruby-client/pull/89: Fix for time parsing in club events - [@tobiaszwaszak](https://github.com/tobiaszwaszak).
* [#89](https://github.com/dblock/strava-ruby-client/pull/89): Fix `nil` time parsing in club events - [@tobiaszwaszak](https://github.com/tobiaszwaszak).

* [#87](https://github.com/dblock/strava-ruby-client/pull/87): Prepares v2.3.0 by improving the event specs - [@simonneutert](https://github.com/simonneutert).
* [#86](https://github.com/dblock/strava-ruby-client/pull/86): Add description to club event model - [@tobiaszwaszak](https://github.com/tobiaszwaszak).
* Your contribution here.
Expand Down
2 changes: 1 addition & 1 deletion lib/strava/models/club_event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ClubEvent < Strava::Models::Response
property 'club', transform_with: ->(c) { Strava::Models::Club.new(c) }
property 'organizing_athlete', transform_with: ->(oa) { Strava::Models::Athlete.new(oa) }
property 'activity_type'
property 'created_at', transform_with: ->(v) { Time.parse(v) }
property 'created_at', transform_with: ->(v) { Time.parse(v) if v['created_at'] }
Copy link
Owner

Choose a reason for hiding this comment

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

This can't be right because v is the time, not v['created_at']. Add a test when the club activity has a created_at time and that test should pass.

property 'route_id'
property 'route', transform_with: ->(r) { Strava::Models::Route.new(r) }
property 'women_only'
Expand Down
24 changes: 24 additions & 0 deletions spec/strava/api/client/endpoints/clubs/club_events_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,28 @@
expect(event.upcoming_occurrences.first).to eq(Time.new(2018, 6, 23, 8, 30, 0, '+00:00'))
expect(event).to be_a Strava::Models::ClubEvent
end

context 'when created_at is invalid' do
let(:invalid_event_json) do
{
'id' => 123,
'resource_state' => 2,
'title' => 'Invalid Event',
'club_id' => 456,
'organizing_athlete' => { 'id' => 789, 'firstname' => 'John', 'lastname' => 'Doe' },
'activity_type' => 'Ride',
'created_at' => nil,
'route_id' => nil,
'route' => nil
}
end

it 'returns club events without created_at value' do
event = Strava::Models::ClubEvent.new(invalid_event_json)
expect(event.created_at).to be_nil
expect(event.strava_url).to eq 'https://www.strava.com/clubs/456/group_events/123'
expect(event.organizing_athlete).to be_a Strava::Models::Athlete
expect(event.route).to be_nil
end
end
end
Loading