uservoice-ruby 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -62,7 +62,7 @@ begin
62
62
  client = UserVoice::Client.new(USERVOICE_SUBDOMAIN, API_KEY, API_SECRET)
63
63
 
64
64
  # Get users of a subdomain (requires trusted client, but no user)
65
- users = client.get("/api/v1/users.json?per_page=3")['users']
65
+ users = client.get_collection("/api/v1/users")
66
66
  users.each do |user|
67
67
  puts "User: \"#{user['name']}\", Profile URL: #{user['url']}"
68
68
  end
@@ -80,7 +80,7 @@ begin
80
80
 
81
81
  # Example request #2: Create a new private forum limited to only example.com email domain.
82
82
  forum = owner_access_token.post("/api/v1/forums.json", :forum => {
83
- :name => 'Example.com Private Feedback',
83
+ :name => 'Ruby Client Private Feedback',
84
84
  :private => true,
85
85
  :allow_by_email_domain => true,
86
86
  :allowed_email_domains => [{:domain => 'example.com'}]
@@ -1,6 +1,6 @@
1
1
  module UserVoice
2
2
  class Collection
3
- PER_PAGE = 500
3
+ PER_PAGE = 100
4
4
 
5
5
  def initialize(client, query, opts={})
6
6
  @client = client
@@ -1,3 +1,3 @@
1
1
  module Uservoice
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
@@ -20,6 +20,38 @@ describe UserVoice::Client do
20
20
  end.should raise_error(UserVoice::Unauthorized)
21
21
  end
22
22
 
23
+ it 'normal user_should be able to send message and send another ticket_message' do
24
+ pending 'Slow test disabled'
25
+ additional_comment = 'This is my latest comment on the issue'
26
+ user = subject.login_as('somebodythere@example.com')
27
+ owner = subject.login_as_owner
28
+
29
+ @ticket = user.post('/api/v1/tickets', :ticket => {
30
+ :subject => 'A new ticket has arrived in your console',
31
+ :message => 'My msg'
32
+ })['ticket']
33
+ p @ticket
34
+
35
+ p 'waiting spam review'
36
+ Kernel.sleep(3);
37
+ p 'posting response!'
38
+ p owner.post("/api/v1/tickets/#{@ticket['id']}/ticket_messages", :ticket_message => {
39
+ :text => 'Thanks for information!'
40
+ })
41
+
42
+ p 'sleeping 3s'
43
+ Kernel.sleep(3);
44
+ p 'posting followup'
45
+
46
+ subject.get("/api/v1/tickets/#{@ticket['id']}")['ticket']['state'].should == 'closed'
47
+
48
+ p user.post("/api/v1/tickets/#{@ticket['id']}/ticket_messages", :ticket_message => {
49
+ :text => additional_comment
50
+ })
51
+ subject.get("/api/v1/tickets/#{@ticket['id']}")['ticket']['state'].should == 'open'
52
+ subject.get("/api/v1/tickets/#{@ticket['id']}")['ticket']['messages'].first['body'].should == additional_comment
53
+ end
54
+
23
55
  it "should be able to get access token as owner" do
24
56
  subject.login_as_owner do |owner|
25
57
  owner.get("/api/v1/users/current.json")['user']['roles']['owner'].should == true
@@ -173,6 +205,11 @@ describe UserVoice::Client do
173
205
  my_token.get("/api/v1/users/current.json")
174
206
  }.should raise_error(UserVoice::NotFound)
175
207
  end
208
+ it 'should throw 404 if user not found' do
209
+ lambda {
210
+ subject.login_as_owner.get("/api/v1/users/2345871235")
211
+ }.should raise_error(UserVoice::NotFound)
212
+ end
176
213
 
177
214
  it "should/be able to delete random user and login as him after that" do
178
215
  somebody = subject.login_as('somebodythere@example.com')
@@ -192,7 +229,7 @@ describe UserVoice::Client do
192
229
 
193
230
  # this recreates somebody
194
231
  somebody = subject.login_as('somebodythere@example.com')
195
- somebody.get("/api/v1/users/current.json")['user']['id'].should_not == regular_user['id']
232
+ somebody.get("/api/v1/users/current.json")['user']['id'].should == regular_user['id']
196
233
  end
197
234
 
198
235
  it "should raise error with invalid email parameter" do
@@ -78,8 +78,8 @@ describe UserVoice::Collection do
78
78
  end
79
79
  end
80
80
 
81
- context 'having a list with 1501 elements' do
82
- ELEMENTS = 1501 # 4 pages, one record in the last page
81
+ context 'having a list with 301 elements' do
82
+ ELEMENTS = 301 # 4 pages, one record in the last page
83
83
 
84
84
  before do
85
85
  @client = mock()
@@ -120,9 +120,9 @@ describe UserVoice::Collection do
120
120
  end
121
121
 
122
122
  it 'should the size defined by limit' do
123
- collection = UserVoice::Collection.new(@client, '/api/v1/suggestions', :limit => 1337)
124
- collection.size.should == 1337
125
- collection.last['id'].should == 1337
123
+ collection = UserVoice::Collection.new(@client, '/api/v1/suggestions', :limit => 137)
124
+ collection.size.should == 137
125
+ collection.last['id'].should == 137
126
126
  end
127
127
 
128
128
  it 'should get last element and array size with two api calls' do
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.8
4
+ version: 0.0.9
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-12 00:00:00.000000000 Z
12
+ date: 2012-10-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec