Skip to content
Merged
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 lib/active_resource/custom_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def delete(method_name, options = {})

private
def custom_method_element_url(method_name, options = {})
"#{self.class.prefix(prefix_options)}#{self.class.collection_name}/#{id}/#{method_name}#{self.class.format_extension}#{self.class.__send__(:query_string, options)}"
"#{self.class.prefix(prefix_options)}#{self.class.collection_name}/#{URI.encode_www_form_component(id.to_s)}/#{method_name}#{self.class.format_extension}#{self.class.__send__(:query_string, options)}"
end

def custom_method_new_element_url(method_name, options = {})
Expand Down
11 changes: 11 additions & 0 deletions test/cases/base/custom_methods_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,15 @@ def test_paths_without_format
ensure
ActiveResource::Base.include_format_in_path = true
end

def test_custom_element_method_identifier_encoding
luis = { person: { id: "luís", name: "Luís" } }.to_json

ActiveResource::HttpMock.respond_to do |mock|
mock.get "/people/lu%C3%ADs.json", {}, luis
mock.put "/people/lu%C3%ADs/deactivate.json", {}, luis, 204
end

assert_equal ActiveResource::Response.new(luis, 204), Person.find("luís").put(:deactivate)
end
end