Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def execute(caller, name, data, filter = nil)
"Forwarding '#{@name}' action #{name} call to the Rpc agent on #{url}."
)

@client.call_rpc(url, caller: caller, method: :post, payload: params)
@client.call_rpc(url, caller: caller, method: :post, payload: params, symbolize_keys: true)
end

def get_form(caller, name, data = nil, filter = nil, metas = nil)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,30 @@ module ForestAdminDatasourceRpc
)
end
end

it 'asks the RPC client to symbolize response keys so ActionResult.parse sees :type' do
collection.execute(caller, 'my_action', {})

expect(rpc_client).to have_received(:call_rpc) do |_url, options|
expect(options[:symbolize_keys]).to be(true)
end
end

it 'returns the action result as-is so :type and other keys reach ActionResult.parse' do
success_result = {
type: 'Success',
message: 'ok',
invalidated: ['books'],
html: nil,
response_headers: {}
}
allow(rpc_client).to receive(:call_rpc).and_return(success_result)

result = collection.execute(caller, 'my_action', {})

expect(result).to eq(success_result)
expect(result[:type]).to eq('Success')
end
end

context 'when call get_form' do
Expand Down
Loading