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
4 changes: 2 additions & 2 deletions lib/akismet/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -286,14 +286,14 @@ def invoke_comment_method(method_name, user_ip, user_agent, params = {})

for key in env.keys
if PARAM_TO_API_PARAM.value?(key.to_sym)
raise ArgumentError, "Environment variable '#{ key }' conflicts with built-in API parameter"
raise ArgumentError, "Environment variable #{ key.inspect } conflicts with built-in API parameter"
end
end

params = params.each_with_object({}) do |(name, value), api_params|
next if name == :env

api_name = PARAM_TO_API_PARAM[name] || raise(ArgumentError, "Invalid param: #{ name }")
api_name = PARAM_TO_API_PARAM[name.to_sym] || raise(ArgumentError, "Invalid param: #{ name.inspect }")
api_params[api_name] = value
end

Expand Down
7 changes: 7 additions & 0 deletions test/client_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,11 @@ def test_invalid_param_raises
@client.check 'ip', 'ua', invalid_param: 'invalid'
end
end

def test_params_can_be_symbols_or_keys
@client.check 'ip', 'ua', { author: 'Name' }
@client.check 'ip', 'ua', {'author' => 'Name'}
@client.check 'ip', 'ua', {env: { a: 1, b: 1 }}
@client.check 'ip', 'ua', {env: {'a' => 1, 'b' => 1}}
end
end