uservoice-ruby 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -43,7 +43,7 @@ sso_token = UserVoice.generate_sso_token(USERVOICE_SUBDOMAIN, SSO_KEY, {
43
43
  :guid => 1001,
44
44
  :display_name => "John Doe",
45
45
  :email => 'john.doe@example.com'
46
- })
46
+ }, 5*60) # the token will be valid for 5 minutes (5*60 seconds) by default
47
47
 
48
48
  # Now this URL will log John Doe in:
49
49
  puts "https://#{USERVOICE_SUBDOMAIN}.uservoice.com/?sso=#{sso_token}"
@@ -30,7 +30,7 @@ module UserVoice
30
30
 
31
31
  def login_with_verifier(oauth_verifier)
32
32
  raise Unauthorized.new('Call request token first') if @request_token.nil?
33
- token = @request_token.get_access_token(:oauth_verifier => oauth_verifier)
33
+ token = @request_token.get_access_token({:oauth_verifier => oauth_verifier}, {}, DEFAULT_HEADERS)
34
34
  Client.new(@consumer, :oauth_token => token.token, :oauth_token_secret => token.secret)
35
35
  end
36
36
 
@@ -52,7 +52,7 @@ module UserVoice
52
52
  end
53
53
 
54
54
  def request_token
55
- @request_token = @consumer.get_request_token(:oauth_callback => @callback)
55
+ @request_token = @consumer.get_request_token({:oauth_callback => @callback}, {}, DEFAULT_HEADERS)
56
56
  end
57
57
 
58
58
  def login_as_owner(&block)
@@ -10,7 +10,7 @@ require 'oauth'
10
10
 
11
11
  module UserVoice
12
12
  EMAIL_FORMAT = %r{^(\w[-+.\w!\#\$%&'\*\+\-/=\?\^_`\{\|\}~]*@([-\w]*\.)+[a-zA-Z]{2,9})$}
13
- DEFAULT_HEADERS = { 'Content-Type'=> 'application/json', 'Accept'=> 'application/json' }
13
+ DEFAULT_HEADERS = { 'Content-Type'=> 'application/json', 'Accept'=> 'application/json', 'API-Client' => "uservoice-ruby-#{UserVoice::VERSION}" }
14
14
 
15
15
  class APIError < RuntimeError
16
16
  end
@@ -1,3 +1,3 @@
1
- module Uservoice
2
- VERSION = "0.0.9"
1
+ module UserVoice
2
+ VERSION = "0.0.10"
3
3
  end
@@ -99,6 +99,20 @@ describe UserVoice::Client do
99
99
  user['email'].should == 'mailaddress@example.com'
100
100
  end
101
101
 
102
+ it "should update the email of the current user" do
103
+ user = subject.login_as('mailaddress@example.com') do |token|
104
+ token.put("/api/v1/users/0", :user => {
105
+ :email => 'mailaddress123@example.com'
106
+ })
107
+ token.get("/api/v1/users/current")['user']
108
+ end
109
+
110
+ user_with_new_email = subject.login_as('mailaddress123@example.com')
111
+ id = user_with_new_email.get("/api/v1/users/current")['user']['id']
112
+ id.should == user['id']
113
+ user_with_new_email.delete("/api/v1/users/#{id}")['user']
114
+ end
115
+
102
116
  it "should get current user with copied access token" do
103
117
  original_token = subject.login_as('mailaddress@example.com')
104
118
 
@@ -229,7 +243,7 @@ describe UserVoice::Client do
229
243
 
230
244
  # this recreates somebody
231
245
  somebody = subject.login_as('somebodythere@example.com')
232
- somebody.get("/api/v1/users/current.json")['user']['id'].should == regular_user['id']
246
+ somebody.get("/api/v1/users/current.json")['user']['email'].should == regular_user['email']
233
247
  end
234
248
 
235
249
  it "should raise error with invalid email parameter" do
@@ -4,7 +4,7 @@ require "uservoice/version"
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "uservoice-ruby"
7
- s.version = Uservoice::VERSION
7
+ s.version = UserVoice::VERSION
8
8
  s.authors = ["Raimo Tuisku"]
9
9
  s.email = ["dev@usevoice.com"]
10
10
  s.homepage = "http://developer.uservoice.com"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uservoice-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-25 00:00:00.000000000 Z
12
+ date: 2012-11-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec