Skip to content

Commit 8c73c49

Browse files
author
Rafael Marinho
committed
minor fixes
1 parent a843cc0 commit 8c73c49

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

lib/stream-chat/client.rb

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -824,16 +824,13 @@ def get_active_live_locations(user_id)
824824
# @param [Float] longitude Optional longitude coordinate
825825
# @param [String] end_at Optional end time for the location sharing
826826
# @return [StreamChat::StreamResponse]
827-
sig { params(user_id: String, created_by_device_id: String, message_id: String, latitude: T.nilable(Float), longitude: T.nilable(Float), end_at: T.nilable(String)).returns(StreamChat::StreamResponse) }
828-
def update_location(user_id, created_by_device_id:, message_id:, latitude: nil, longitude: nil, end_at: nil)
827+
sig { params(user_id: String, created_by_device_id: String, message_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
828+
def update_location(user_id, created_by_device_id:, message_id:, **options)
829829
data = {
830830
created_by_device_id: created_by_device_id,
831831
message_id: message_id
832832
}
833-
data[:latitude] = latitude if latitude
834-
data[:longitude] = longitude if longitude
835-
data[:end_at] = end_at if end_at
836-
833+
data.merge!(options) if options
837834
put('users/location', data: data, params: { user_id: user_id })
838835
end
839836

spec/client_spec.rb

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,17 +1038,19 @@ def loop_times(times)
10381038
end
10391039

10401040
it 'can create and update a location' do
1041-
location = {
1041+
location = {
10421042
created_by_device_id: SecureRandom.uuid,
10431043
latitude: 40.7128,
10441044
longitude: -74.0060,
10451045
end_at: (Time.now + 3600).iso8601
10461046
}
10471047

1048-
response = @channel.send_message({
1049-
text: 'Location sharing message',
1050-
shared_location: location,
1051-
}, @location_test_user[:id])
1048+
response = @channel.send_message(
1049+
{
1050+
text: 'Location sharing message',
1051+
shared_location: location
1052+
}, @location_test_user[:id]
1053+
)
10521054

10531055
expect(response['message']).to include 'shared_location'
10541056
expect(response['message']['shared_location']['created_by_device_id']).to eq(location[:created_by_device_id])
@@ -1076,21 +1078,22 @@ def loop_times(times)
10761078
longitude = -74.0060
10771079
end_at = (Time.now + 3600).iso8601
10781080

1079-
response = @location_channel.send_message({
1080-
text: 'Location sharing message',
1081-
shared_location: {
1082-
created_by_device_id: device_id,
1083-
latitude: latitude,
1084-
longitude: longitude,
1085-
end_at: end_at
1086-
}
1087-
}, @location_test_user[:id])
1081+
response = @location_channel.send_message(
1082+
{
1083+
text: 'Location sharing message',
1084+
shared_location: {
1085+
created_by_device_id: device_id,
1086+
latitude: latitude,
1087+
longitude: longitude,
1088+
end_at: end_at
1089+
}
1090+
}, @location_test_user[:id]
1091+
)
10881092

10891093
response = @client.get_active_live_locations(@location_test_user[:id])
10901094
expect(response).to include 'active_live_locations'
10911095
expect(response['active_live_locations']).to be_an(Array)
10921096
expect(response['active_live_locations'].length).to be >= 1
1093-
10941097
location = response['active_live_locations'].find { |loc| loc['created_by_device_id'] == device_id }
10951098
expect(location).not_to be_nil
10961099
expect(location['latitude']).to eq(latitude)
@@ -1099,7 +1102,7 @@ def loop_times(times)
10991102
end
11001103

11011104
it 'should have active live locations on the channel' do
1102-
response = @channel.query()
1105+
response = @channel.query
11031106
expect(response).to include 'active_live_locations'
11041107
expect(response['active_live_locations'].length).to be >= 1
11051108
end

0 commit comments

Comments
 (0)