yammer-client 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. data.tar.gz.sig +0 -0
  2. data/.travis.yml +1 -0
  3. data/CHANGELOG.md +22 -0
  4. data/Gemfile +1 -1
  5. data/Gemfile.lock +3 -4
  6. data/README.md +11 -10
  7. data/file.txt +1 -0
  8. data/lib/yammer.rb +7 -11
  9. data/lib/yammer/api.rb +2 -1
  10. data/lib/yammer/api/autocomplete.rb +1 -1
  11. data/lib/yammer/api/group.rb +5 -5
  12. data/lib/yammer/api/group_membership.rb +2 -2
  13. data/lib/yammer/api/message.rb +13 -13
  14. data/lib/yammer/api/network.rb +1 -1
  15. data/lib/yammer/api/notification.rb +1 -1
  16. data/lib/yammer/api/pending_attachment.rb +48 -0
  17. data/lib/yammer/api/search.rb +1 -1
  18. data/lib/yammer/api/topic.rb +1 -1
  19. data/lib/yammer/api/user.rb +17 -17
  20. data/lib/yammer/api_handler.rb +15 -0
  21. data/lib/yammer/{response.rb → api_response.rb} +6 -6
  22. data/lib/yammer/base.rb +19 -11
  23. data/lib/yammer/client.rb +27 -42
  24. data/lib/yammer/configurable.rb +14 -8
  25. data/lib/yammer/group.rb +1 -1
  26. data/lib/yammer/group_membership.rb +1 -1
  27. data/lib/yammer/http_adapter.rb +74 -0
  28. data/lib/yammer/message.rb +1 -1
  29. data/lib/yammer/thread.rb +1 -1
  30. data/lib/yammer/user.rb +6 -6
  31. data/lib/yammer/version.rb +1 -1
  32. data/spec/api/autocomplete_spec.rb +1 -2
  33. data/spec/api/group_membership_spec.rb +1 -2
  34. data/spec/api/group_spec.rb +1 -2
  35. data/spec/api/message_spec.rb +1 -2
  36. data/spec/api/network_spec.rb +1 -2
  37. data/spec/api/notification_spec.rb +3 -4
  38. data/spec/api/pending_attachment_spec.rb +37 -0
  39. data/spec/api/search_spec.rb +1 -2
  40. data/spec/api/thread_spec.rb +1 -2
  41. data/spec/api/topic_spec.rb +1 -2
  42. data/spec/api/user_spec.rb +15 -2
  43. data/spec/{response_spec.rb → api_response.rb} +9 -8
  44. data/spec/client_spec.rb +203 -66
  45. data/spec/fixtures/users_followed.json +1 -0
  46. data/spec/fixtures/users_following.json +1 -0
  47. data/spec/http_adapter_spec.rb +90 -0
  48. data/spec/mocks/attachment.txt +1 -0
  49. data/spec/model/base_spec.rb +26 -5
  50. data/spec/model/group_membership_spec.rb +11 -0
  51. data/spec/model/group_spec.rb +10 -0
  52. data/spec/model/message_spec.rb +10 -0
  53. data/spec/model/thread_spec.rb +6 -0
  54. data/spec/model/user_spec.rb +53 -0
  55. data/spec/spec_helper.rb +8 -0
  56. data/yammer.gemspec +3 -1
  57. metadata +35 -10
  58. metadata.gz.sig +0 -0
  59. data/lib/yammer/http_connection.rb +0 -184
  60. data/lib/yammer/model.rb +0 -6
  61. data/spec/connection_spec.rb +0 -306
@@ -0,0 +1 @@
1
+ {"users":[{"activated_at":"2012/02/22 21:21:39 +0000","url":"https://www.staging.yammer.com/api/v1/users/9","web_url":"https://www.staging.yammer.com/salmonellaville.com/users/jim","full_name":"Jimmy","type":"user","state":"active","mugshot_url_template":"https://mug0.staging.assets-yammer.com/mugshot/images/{width}x{height}/HsmbxsFhqsq05tb-VBfxkv937-hN3CWL","job_title":"Grumbler","stats":{"following":69,"updates":353,"followers":76},"mugshot_url":"https://mug0.staging.assets-yammer.com/mugshot/images/48x48/HsmbxsFhqsq05tb-VBfxkv937-hN3CWL","id":9,"name":"jim"}],"more_available":false,"meta":{"followed_user_ids":[9]}}
@@ -0,0 +1 @@
1
+ {"users":[{"activated_at":"2012/02/22 21:21:39 +0000","url":"https://www.staging.yammer.com/api/v1/users/7","web_url":"https://www.staging.yammer.com/salmonellaville.com/users/jim","full_name":"Jimmy","type":"user","state":"active","mugshot_url_template":"https://mug0.staging.assets-yammer.com/mugshot/images/{width}x{height}/HsmbxsFhqsq05tb-VBfxkv937-hN3CWL","job_title":"Bumbler","stats":{"following":69,"updates":353,"followers":76},"mugshot_url":"https://mug0.staging.assets-yammer.com/mugshot/images/48x48/HsmbxsFhqsq05tb-VBfxkv937-hN3CWL","id":7,"name":"jim"}],"more_available":false,"meta":{"followed_user_ids":[7]}}
@@ -0,0 +1,90 @@
1
+ require File.expand_path('../spec_helper', __FILE__)
2
+ require 'yammer/http_adapter'
3
+
4
+ describe Yammer::HttpAdapter do
5
+
6
+ before :all do
7
+ Yammer.configure do |conf|
8
+ conf.access_token = 'TolNOFka9Uls2DxahNi78A'
9
+ end
10
+ end
11
+
12
+ context "initialization" do
13
+ context "with user options" do
14
+
15
+ before do
16
+ @options = {
17
+ :verify_ssl => false,
18
+ :max_redirects => 2
19
+ }
20
+ end
21
+
22
+ subject { @conn = Yammer::HttpAdapter.new('https://www.example.com', @options) }
23
+
24
+ it "overrides default options" do
25
+ expect(subject.instance_variable_get(:"@connection_options")).to eq @options
26
+ end
27
+ end
28
+
29
+ context "with invalid url" do
30
+ it "should raise argument error" do
31
+ expect { Yammer::HttpAdapter.new('www.example.com') }.to raise_error(ArgumentError)
32
+ end
33
+ end
34
+ end
35
+
36
+ context "with no options" do
37
+
38
+ subject { @conn = Yammer::HttpAdapter.new('https://www.yammer.com') }
39
+
40
+ describe "#scheme" do
41
+ it "returns the http scheme" do
42
+ expect(subject.scheme).to eq 'https'
43
+ end
44
+ end
45
+
46
+ describe "#host" do
47
+ it "returns the host server" do
48
+ expect(subject.host).to eq 'www.yammer.com'
49
+ end
50
+ end
51
+
52
+ describe "site_url" do
53
+ it "returns site_url" do
54
+ expect(subject.site_url).to eq 'https://www.yammer.com'
55
+ end
56
+ end
57
+
58
+ describe "site_url=" do
59
+ it "sets new site_url on client" do
60
+ subject.site_url = 'https://www.elpmaxe.com'
61
+ expect(subject.site_url).to eq 'https://www.elpmaxe.com'
62
+ end
63
+ end
64
+
65
+ describe "connection_options=" do
66
+ it "sets new connection_options" do
67
+ subject.connection_options = { :max_redirects => 6 }
68
+ expect(subject.connection_options).to eq({ :max_redirects => 6 })
69
+ end
70
+
71
+ it "should raise error" do
72
+ expect { subject.connection_options = '' }.to raise_error(ArgumentError)
73
+ end
74
+ end
75
+
76
+ describe "#absolute_url" do
77
+ context "with no parameters" do
78
+ it "returns a uri without path" do
79
+ expect(subject.send(:absolute_url)).to eq "https://www.yammer.com"
80
+ end
81
+ end
82
+
83
+ context "with parameters" do
84
+ it "returns a uri with path" do
85
+ expect(subject.send(:absolute_url, '/oauth/v2/authorize')).to eq "https://www.yammer.com/oauth/v2/authorize"
86
+ end
87
+ end
88
+ end
89
+ end
90
+ end
@@ -0,0 +1 @@
1
+ will code for food and money
@@ -1,6 +1,7 @@
1
1
  require File.expand_path('../../spec_helper', __FILE__)
2
2
 
3
3
  describe Yammer::Base do
4
+
4
5
  class DummyModel < Yammer::Base
5
6
  attr_accessor_deffered :first_name, :last_name
6
7
  end
@@ -11,6 +12,16 @@ describe Yammer::Base do
11
12
  end
12
13
  end
13
14
 
15
+ before :all do
16
+ Yammer.configure do |conf|
17
+ conf.access_token = 'TolNOFka9Uls2DxahNi78A'
18
+ end
19
+ end
20
+
21
+ after :all do
22
+ Yammer.reset!
23
+ end
24
+
14
25
  context 'new user object with id' do
15
26
 
16
27
  subject { DummyModel.new(:id => 42) }
@@ -23,8 +34,8 @@ describe Yammer::Base do
23
34
 
24
35
  describe "#id=" do
25
36
  it 'sets id' do
26
- # subject.send(:id, 2)
27
- # expect(subject.id).to eq 2
37
+ subject.send(:"id=", 2)
38
+ expect(subject.id).to eq 2
28
39
  end
29
40
  end
30
41
 
@@ -108,6 +119,7 @@ describe Yammer::Base do
108
119
  end
109
120
 
110
121
  describe "#save" do
122
+
111
123
  context 'unmodified model' do
112
124
  it 'does nothing' do
113
125
  expect(subject.save).to eq subject
@@ -118,10 +130,13 @@ describe Yammer::Base do
118
130
  subject { DummyModel.new(:id => 42, :first_name => 'jim', :last_name => 'peters') }
119
131
 
120
132
  it 'should update model' do
121
- Yammer.should_receive(:update_dummy_model).with(42, hash_including(
133
+ api_handler = double("ApiHandler")
134
+ api_handler.should_receive(:update_dummy_model).with(42, hash_including(
122
135
  :first_name =>'john',
123
136
  :last_name => 'smith')
124
137
  ).and_return(double('Response', :success? => true, :created? => true, :body => {:id => 2}))
138
+
139
+ subject.stub(:api_handler).and_return(api_handler)
125
140
  subject.first_name = 'john'
126
141
  subject.last_name = 'smith'
127
142
  subject.save
@@ -132,9 +147,12 @@ describe Yammer::Base do
132
147
  subject { DummyModel.new(:first_name => 'jim', :last_name => 'peters') }
133
148
 
134
149
  it 'should do nothing' do
135
- Yammer.should_receive(:create_dummy_model).with(
150
+ api_handler = double("ApiHandler")
151
+ api_handler.should_receive(:create_dummy_model).with(
136
152
  hash_including(:first_name =>'jim', :last_name => 'peters')
137
153
  ).and_return(double('Response', :success? => true, :created? => true, :body => {:id => '2'}))
154
+
155
+ subject.stub(:api_handler).and_return(api_handler)
138
156
  subject.save
139
157
  end
140
158
  end
@@ -143,10 +161,13 @@ describe Yammer::Base do
143
161
  subject { DummyModel.new(:first_name => 'jim', :last_name => 'peters') }
144
162
 
145
163
  it 'should create model' do
146
- Yammer.should_receive(:create_dummy_model).with({
164
+ api_handler = double("ApiHandler")
165
+ api_handler.should_receive(:create_dummy_model).with({
147
166
  :first_name =>'john',
148
167
  :last_name => 'peters'
149
168
  }).and_return(double('Response', :success? => true, :created? => true, :body => {:id => 2}))
169
+
170
+ subject.stub(:api_handler).and_return(api_handler)
150
171
  subject.first_name = 'john'
151
172
  subject.save
152
173
  end
@@ -1,6 +1,17 @@
1
1
  require File.expand_path('../../spec_helper', __FILE__)
2
2
 
3
3
  describe Yammer::GroupMembership do
4
+
5
+ before :all do
6
+ Yammer.configure do |conf|
7
+ conf.access_token = 'TolNOFka9Uls2DxahNi78A'
8
+ end
9
+ end
10
+
11
+ after :all do
12
+ Yammer.reset!
13
+ end
14
+
4
15
  context 'class methods' do
5
16
 
6
17
  subject { Yammer::GroupMembership }
@@ -3,6 +3,16 @@ require File.expand_path('../../spec_helper', __FILE__)
3
3
  describe Yammer::Group do
4
4
  context 'class methods' do
5
5
 
6
+ before :all do
7
+ Yammer.configure do |conf|
8
+ conf.access_token = 'TolNOFka9Uls2DxahNi78A'
9
+ end
10
+ end
11
+
12
+ after :all do
13
+ Yammer.reset!
14
+ end
15
+
6
16
  subject { Yammer::Group }
7
17
 
8
18
  describe '#create' do
@@ -2,6 +2,16 @@ require File.expand_path('../../spec_helper', __FILE__)
2
2
 
3
3
  describe Yammer::Message do
4
4
 
5
+ before :all do
6
+ Yammer.configure do |conf|
7
+ conf.access_token = 'TolNOFka9Uls2DxahNi78A'
8
+ end
9
+ end
10
+
11
+ after :all do
12
+ Yammer.reset!
13
+ end
14
+
5
15
  context 'class methods' do
6
16
 
7
17
  subject { Yammer::Message }
@@ -8,6 +8,12 @@ describe Yammer::Thread do
8
8
  end
9
9
  end
10
10
 
11
+ after :all do
12
+ Yammer.reset!
13
+ end
14
+
15
+ subject { Yammer::GroupMembership }
16
+
11
17
  context 'existing public thread' do
12
18
  subject { Yammer::Thread.new(MultiJson.load(fixture("public_thread.json"), :symbolize_keys => true)) }
13
19
 
@@ -8,6 +8,10 @@ describe Yammer::User do
8
8
  end
9
9
  end
10
10
 
11
+ after :all do
12
+ Yammer.reset!
13
+ end
14
+
11
15
  context 'class methods' do
12
16
 
13
17
  subject { Yammer::User }
@@ -30,6 +34,23 @@ describe Yammer::User do
30
34
  subject.create('hacker@yammer-inc.com')
31
35
  end
32
36
  end
37
+
38
+ describe '#current_user' do
39
+ it "should fetch authenticated user's data" do
40
+ stub_request(:get, "https://www.yammer.com/api/v1/users/current").with(
41
+ :headers => {
42
+ 'Accept' => 'application/json',
43
+ 'Authorization' => "Bearer #{Yammer.access_token}",
44
+ 'User-Agent' => "Yammer Ruby Gem #{Yammer::Version}"
45
+ }
46
+ ).to_return(
47
+ :status => 200,
48
+ :body => fixture('user.json'),
49
+ :headers => {}
50
+ )
51
+ subject.current
52
+ end
53
+ end
33
54
  end
34
55
 
35
56
  context 'new user object with id' do
@@ -110,6 +131,38 @@ describe Yammer::User do
110
131
  end
111
132
  end
112
133
 
134
+ describe "#followers" do
135
+ it 'returns users following user' do
136
+ stub_request(:get, "https://www.yammer.com/api/v1/users/following/2").
137
+ with(:headers => {
138
+ 'Accept'=>'application/json',
139
+ 'Authorization'=>"Bearer #{Yammer.access_token}",
140
+ 'User-Agent'=>"Yammer Ruby Gem #{Yammer::Version}"
141
+ }).to_return(
142
+ :status => 200,
143
+ :body => fixture('users_following.json'),
144
+ :headers => {}
145
+ )
146
+ subject.followers
147
+ end
148
+ end
149
+
150
+ describe "#following" do
151
+ it 'returns users followed by user' do
152
+ stub_request(:get, "https://www.yammer.com/api/v1/users/followed_by/2").
153
+ with(:headers => {
154
+ 'Accept'=>'application/json',
155
+ 'Authorization'=>"Bearer #{Yammer.access_token}",
156
+ 'User-Agent'=>"Yammer Ruby Gem #{Yammer::Version}"
157
+ }).to_return(
158
+ :status => 200,
159
+ :body => fixture('users_followed.json'),
160
+ :headers => {}
161
+ )
162
+ subject.following
163
+ end
164
+ end
165
+
113
166
  describe "#delete" do
114
167
  it 'deletes user' do
115
168
  stub_request(:delete, "https://www.yammer.com/api/v1/users/2").
data/spec/spec_helper.rb CHANGED
@@ -41,6 +41,14 @@ def fixture_path
41
41
  File.expand_path("../fixtures", __FILE__)
42
42
  end
43
43
 
44
+ def mock_path
45
+ File.expand_path("../mocks", __FILE__)
46
+ end
47
+
44
48
  def fixture(file)
45
49
  File.new("#{fixture_path}/#{file}")
46
50
  end
51
+
52
+ def upload(file)
53
+ File.new("#{mock_path}/#{file}")
54
+ end
data/yammer.gemspec CHANGED
@@ -5,7 +5,8 @@ require 'yammer/version'
5
5
  Gem::Specification.new do |s|
6
6
  s.name = 'yammer-client'
7
7
  s.version = Yammer::Version
8
- s.date = %q{2013-04-09}
8
+
9
+ s.date = %q{2013-04-22}
9
10
  s.summary = "Yammer API Client - beta"
10
11
  s.description = "A Ruby wrapper for accessing Yammer's REST API"
11
12
  s.authors = ["Kevin Mutyaba"]
@@ -24,6 +25,7 @@ Gem::Specification.new do |s|
24
25
  s.add_dependency 'oj', '~> 2.0.10'
25
26
  s.add_dependency 'multi_json', '~> 1.3'
26
27
  s.add_dependency 'oauth2-client', '~> 1.1.2'
28
+ s.add_dependency 'rest-client', '~> 1.6.7'
27
29
  s.add_dependency 'addressable', '~> 2.3.3'
28
30
 
29
31
  s.add_development_dependency 'rake'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yammer-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -38,7 +38,7 @@ cert_chain:
38
38
  OGZyVURBOQpqNmZBVGcvNGZxcGdJTFBWcUZJR1pPTUpERmNKeS9vZWh3d3hM
39
39
  dTVYTXg4OFdGRDlqVDF2Umo3N0Q3aVBMYlhkCnJmR3MvcUNKS2dpZlhkLzFh
40
40
  bTVobEFINWpYVT0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=
41
- date: 2013-04-09 00:00:00.000000000 Z
41
+ date: 2013-04-22 00:00:00.000000000 Z
42
42
  dependencies:
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: oj
@@ -88,6 +88,22 @@ dependencies:
88
88
  - - ~>
89
89
  - !ruby/object:Gem::Version
90
90
  version: 1.1.2
91
+ - !ruby/object:Gem::Dependency
92
+ name: rest-client
93
+ requirement: !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ~>
97
+ - !ruby/object:Gem::Version
98
+ version: 1.6.7
99
+ type: :runtime
100
+ prerelease: false
101
+ version_requirements: !ruby/object:Gem::Requirement
102
+ none: false
103
+ requirements:
104
+ - - ~>
105
+ - !ruby/object:Gem::Version
106
+ version: 1.6.7
91
107
  - !ruby/object:Gem::Dependency
92
108
  name: addressable
93
109
  requirement: !ruby/object:Gem::Requirement
@@ -184,6 +200,7 @@ files:
184
200
  - README.md
185
201
  - Rakefile
186
202
  - certs/tiabas-public.pem
203
+ - file.txt
187
204
  - lib/yammer.rb
188
205
  - lib/yammer/api.rb
189
206
  - lib/yammer/api/autocomplete.rb
@@ -192,22 +209,23 @@ files:
192
209
  - lib/yammer/api/message.rb
193
210
  - lib/yammer/api/network.rb
194
211
  - lib/yammer/api/notification.rb
212
+ - lib/yammer/api/pending_attachment.rb
195
213
  - lib/yammer/api/search.rb
196
214
  - lib/yammer/api/thread.rb
197
215
  - lib/yammer/api/topic.rb
198
216
  - lib/yammer/api/user.rb
217
+ - lib/yammer/api_handler.rb
218
+ - lib/yammer/api_response.rb
199
219
  - lib/yammer/base.rb
200
220
  - lib/yammer/client.rb
201
221
  - lib/yammer/configurable.rb
202
222
  - lib/yammer/error.rb
203
223
  - lib/yammer/group.rb
204
224
  - lib/yammer/group_membership.rb
205
- - lib/yammer/http_connection.rb
225
+ - lib/yammer/http_adapter.rb
206
226
  - lib/yammer/identity_map.rb
207
227
  - lib/yammer/message.rb
208
228
  - lib/yammer/message_body.rb
209
- - lib/yammer/model.rb
210
- - lib/yammer/response.rb
211
229
  - lib/yammer/thread.rb
212
230
  - lib/yammer/user.rb
213
231
  - lib/yammer/version.rb
@@ -217,12 +235,13 @@ files:
217
235
  - spec/api/message_spec.rb
218
236
  - spec/api/network_spec.rb
219
237
  - spec/api/notification_spec.rb
238
+ - spec/api/pending_attachment_spec.rb
220
239
  - spec/api/search_spec.rb
221
240
  - spec/api/thread_spec.rb
222
241
  - spec/api/topic_spec.rb
223
242
  - spec/api/user_spec.rb
243
+ - spec/api_response.rb
224
244
  - spec/client_spec.rb
225
- - spec/connection_spec.rb
226
245
  - spec/error_spec.rb
227
246
  - spec/fixtures/group.json
228
247
  - spec/fixtures/message.json
@@ -231,14 +250,17 @@ files:
231
250
  - spec/fixtures/private_thread.json
232
251
  - spec/fixtures/public_thread.json
233
252
  - spec/fixtures/user.json
253
+ - spec/fixtures/users_followed.json
254
+ - spec/fixtures/users_following.json
255
+ - spec/http_adapter_spec.rb
234
256
  - spec/identity_map_spec.rb
257
+ - spec/mocks/attachment.txt
235
258
  - spec/model/base_spec.rb
236
259
  - spec/model/group_membership_spec.rb
237
260
  - spec/model/group_spec.rb
238
261
  - spec/model/message_spec.rb
239
262
  - spec/model/thread_spec.rb
240
263
  - spec/model/user_spec.rb
241
- - spec/response_spec.rb
242
264
  - spec/spec_helper.rb
243
265
  - yammer.gemspec
244
266
  homepage: http://tiabas.github.io/yammer-client
@@ -274,12 +296,13 @@ test_files:
274
296
  - spec/api/message_spec.rb
275
297
  - spec/api/network_spec.rb
276
298
  - spec/api/notification_spec.rb
299
+ - spec/api/pending_attachment_spec.rb
277
300
  - spec/api/search_spec.rb
278
301
  - spec/api/thread_spec.rb
279
302
  - spec/api/topic_spec.rb
280
303
  - spec/api/user_spec.rb
304
+ - spec/api_response.rb
281
305
  - spec/client_spec.rb
282
- - spec/connection_spec.rb
283
306
  - spec/error_spec.rb
284
307
  - spec/fixtures/group.json
285
308
  - spec/fixtures/message.json
@@ -288,13 +311,15 @@ test_files:
288
311
  - spec/fixtures/private_thread.json
289
312
  - spec/fixtures/public_thread.json
290
313
  - spec/fixtures/user.json
314
+ - spec/fixtures/users_followed.json
315
+ - spec/fixtures/users_following.json
316
+ - spec/http_adapter_spec.rb
291
317
  - spec/identity_map_spec.rb
318
+ - spec/mocks/attachment.txt
292
319
  - spec/model/base_spec.rb
293
320
  - spec/model/group_membership_spec.rb
294
321
  - spec/model/group_spec.rb
295
322
  - spec/model/message_spec.rb
296
323
  - spec/model/thread_spec.rb
297
324
  - spec/model/user_spec.rb
298
- - spec/response_spec.rb
299
325
  - spec/spec_helper.rb
300
- has_rdoc: