Skip to content

Commit 7c6dcbe

Browse files
committed
Add missing .length on gsub matcher
1 parent 15b5cfb commit 7c6dcbe

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/fcm.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def get_instance_id_info(iid_token, options = {})
162162
end
163163

164164
def send_to_topic(topic, options = {})
165-
if topic.gsub(TOPIC_REGEX, '').zero?
165+
if topic.gsub(TOPIC_REGEX, '').length.zero?
166166
body = { 'message': { 'topic': topic }.merge(options) }
167167

168168
for_uri(BASE_URI_V1) do |connection|

spec/fcm_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,15 @@
207207
)
208208
stub_fcm_send_to_topic_request.should have_been_made.times(1)
209209
end
210+
211+
context "when topic is invalid" do
212+
let(:topic) { '/topics/news$' }
213+
214+
it 'should raise error' do
215+
client.send_to_topic(topic, options)
216+
stub_fcm_send_to_topic_request.should_not have_been_requested
217+
end
218+
end
210219
end
211220

212221
describe "#send_to_topic_condition" do

0 commit comments

Comments
 (0)