Permalink
Browse files

Fix bug when deleting emails for the authenticated user.

  • Loading branch information...
1 parent fc6d3be commit 96574d5025c64a17cf820960a458165f2ac64212 @piotrmurach committed May 20, 2012
Showing with 7 additions and 8 deletions.
  1. +3 −2 lib/github_api/users/emails.rb
  2. +0 −1 spec/github/request/jsonize_spec.rb
  3. +4 −5 spec/github/users/emails_spec.rb
@@ -1,4 +1,5 @@
# encoding: utf-8
+require 'cgi'
module Github
class Users::Emails < API
@@ -30,7 +31,7 @@ def list(params={})
def add(*args)
params = _extract_parameters(args)
_normalize_params_keys(params)
- params['data'] = [args].flatten if args
+ params['data'] = args if args
post_request("/user/emails", params)
end
alias :<< :add
@@ -47,7 +48,7 @@ def add(*args)
def delete(*args)
params = _extract_parameters(args)
_normalize_params_keys(params)
- params['data'] = [args].flatten
+ params['data'] = args if args
delete_request("/user/emails", params)
end
@@ -85,5 +85,4 @@ def result_type() result[:request_headers]['Content-Type'] end
end
end
-
end # Github::Request::Jsonize
@@ -88,22 +88,21 @@
before do
stub_delete("/user/emails").
- with(:query => { :access_token => "#{OAUTH_TOKEN}", :data => email}).
- to_return(:body => fixture('users/emails.json'),
- :status => 200,
+ with(:query => { :access_token => "#{OAUTH_TOKEN}"}).
+ to_return(:body => fixture('users/emails.json'), :status => 204,
:headers => {:content_type => "application/json; charset=utf-8"})
end
it 'extracts request parameters and email data' do
github.users.emails.should_receive(:delete_request).
- with("/user/emails", { "per_page" => 21, "page" => 1, "data" => [email] })
+ with("/user/emails", { "per_page" => 21, "page" => 1, 'data' => [email] })
github.users.emails.delete email, params
end
it 'submits request successfully' do
github.users.emails.delete email
a_delete("/user/emails").
- with(:query => { :access_token => "#{OAUTH_TOKEN}", :data => email } ).
+ with(:query => { :access_token => "#{OAUTH_TOKEN}" } ).
should have_been_made
end
end # delete

0 comments on commit 96574d5

Please sign in to comment.