Skip to content
This repository was archived by the owner on Jul 30, 2025. It is now read-only.

Commit bff59c0

Browse files
author
Idan Katz
committed
fix method_as_class to handle non alphanumeric
1 parent 7bd89ef commit bff59c0

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

lib/zendesk_api/client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def build_connection
179179
private
180180

181181
def method_as_class(method)
182-
klass_as_string = ZendeskAPI::Helpers.modulize_string(Inflection.singular(method.to_s))
182+
klass_as_string = ZendeskAPI::Helpers.modulize_string(Inflection.singular(method.to_s.gsub(/\W/, '')))
183183
ZendeskAPI::Association.class_from_namespace(klass_as_string)
184184
end
185185

spec/core/client_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ def build_connection
240240

241241
it "should not respond_to? invalid resources" do
242242
expect(subject.respond_to?(:nope)).to eq(false)
243+
expect(subject.respond_to?(:empty?)).to eq(false)
243244
end
244245

245246
it "delegates voice correctly" do

0 commit comments

Comments
 (0)