yam 0.0.6 → 1.0.0
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.
- data.tar.gz.sig +0 -0
- data/.travis.yml +5 -0
- data/.yardopts +10 -0
- data/AUTHORS +1 -0
- data/CHANGELOG.md +7 -0
- data/CONTRIBUTING.md +0 -7
- data/Gemfile +27 -1
- data/README.md +190 -67
- data/Rakefile +9 -3
- data/certs/public.pem +20 -0
- data/lib/yammer.rb +47 -0
- data/lib/yammer/api.rb +29 -0
- data/lib/yammer/api/autocomplete.rb +39 -0
- data/lib/yammer/api/group.rb +92 -0
- data/lib/yammer/api/group_membership.rb +46 -0
- data/lib/yammer/api/invitation.rb +39 -0
- data/lib/yammer/api/like.rb +57 -0
- data/lib/yammer/api/message.rb +227 -0
- data/lib/yammer/api/network.rb +35 -0
- data/lib/yammer/api/notification.rb +32 -0
- data/lib/yammer/api/open_graph_object.rb +92 -0
- data/lib/yammer/api/pending_attachment.rb +64 -0
- data/lib/yammer/api/search.rb +42 -0
- data/lib/yammer/api/subscription.rb +32 -0
- data/lib/yammer/api/thread.rb +37 -0
- data/lib/yammer/api/topic.rb +37 -0
- data/lib/yammer/api/user.rb +168 -0
- data/lib/yammer/api_handler.rb +27 -0
- data/lib/yammer/api_response.rb +57 -0
- data/lib/yammer/base.rb +208 -0
- data/lib/yammer/client.rb +100 -0
- data/lib/yammer/configurable.rb +81 -0
- data/lib/yammer/error.rb +75 -0
- data/lib/yammer/group.rb +27 -0
- data/lib/yammer/group_membership.rb +25 -0
- data/lib/yammer/http_adapter.rb +100 -0
- data/lib/yammer/identity_map.rb +56 -0
- data/lib/yammer/message.rb +32 -0
- data/lib/yammer/message_body.rb +27 -0
- data/lib/yammer/pending_attachment.rb +19 -0
- data/lib/yammer/thread.rb +58 -0
- data/lib/yammer/user.rb +66 -0
- data/lib/yammer/version.rb +32 -0
- data/{lib/yam/configuration.rb → spec/api/autocomplete_spec.rb} +18 -23
- data/spec/api/group_membership_spec.rb +48 -0
- data/spec/api/group_spec.rb +76 -0
- data/spec/api/invitation_spec.rb +60 -0
- data/spec/api/like_spec.rb +46 -0
- data/spec/api/message_spec.rb +136 -0
- data/spec/api/network_spec.rb +41 -0
- data/{lib/yam/client.rb → spec/api/notification_spec.rb} +22 -4
- data/spec/api/open_graph_object_spec.rb +67 -0
- data/spec/api/pending_attachment_spec.rb +56 -0
- data/{lib/yam/constants.rb → spec/api/search_spec.rb} +21 -8
- data/spec/api/subscription_spec.rb +41 -0
- data/{lib/yam.rb → spec/api/thread_spec.rb} +19 -12
- data/{lib/yam/request.rb → spec/api/topic_spec.rb} +19 -15
- data/spec/api/user_spec.rb +108 -0
- data/spec/api_response.rb +86 -0
- data/spec/client_spec.rb +364 -0
- data/spec/error_spec.rb +88 -0
- data/spec/fixtures/group.json +1 -0
- data/spec/fixtures/message.json +1 -0
- data/spec/fixtures/messages_in_thread.json +1 -0
- data/spec/fixtures/portal_thread.json +1 -0
- data/spec/fixtures/private_thread.json +1 -0
- data/spec/fixtures/public_thread.json +1 -0
- data/spec/fixtures/user.json +1 -0
- data/spec/fixtures/users_followed.json +1 -0
- data/spec/fixtures/users_following.json +1 -0
- data/spec/http_adapter_spec.rb +109 -0
- data/spec/identity_map_spec.rb +127 -0
- data/spec/mocks/attachment.txt +1 -0
- data/spec/model/base_spec.rb +196 -0
- data/spec/model/group_membership_spec.rb +57 -0
- data/spec/model/group_spec.rb +73 -0
- data/spec/model/message_spec.rb +74 -0
- data/spec/model/thread_spec.rb +91 -0
- data/spec/model/user_spec.rb +222 -0
- data/spec/spec_helper.rb +39 -14
- data/yam.gemspec +50 -28
- metadata +270 -187
- metadata.gz.sig +0 -0
- data/lib/yam/api.rb +0 -53
- data/lib/yam/connection.rb +0 -57
- data/lib/yam/version.rb +0 -20
- data/spec/yam/client_spec.rb +0 -50
- data/spec/yam_spec.rb +0 -87
@@ -0,0 +1,41 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
# Copyright (c) Microsoft Corporation
|
4
|
+
# All rights reserved.
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
13
|
+
# ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY
|
14
|
+
# IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR
|
15
|
+
# PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
|
16
|
+
#
|
17
|
+
# See the Apache Version 2.0 License for specific language governing
|
18
|
+
# permissions and limitations under the License.
|
19
|
+
|
20
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
21
|
+
|
22
|
+
describe Yammer::Api::Network do
|
23
|
+
|
24
|
+
before :all do
|
25
|
+
@client = Yammer::Client.new(
|
26
|
+
:site_url => 'https://www.yammer.com',
|
27
|
+
:client_id => 'PRbTcg9qjgKsp4jjpm1pw',
|
28
|
+
:client_secret => 'Xn7kp7Ly0TCY4GtZWkmSsqGEPg10DmMADyjWkf2U',
|
29
|
+
:access_token => 'TolNOFka9Uls2DxahNi78A'
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
subject { @client }
|
34
|
+
|
35
|
+
describe '#networks_current' do
|
36
|
+
it 'should fetch network data' do
|
37
|
+
subject.should_receive(:get).with('/api/v1/networks/current', { :include_suspended => true })
|
38
|
+
subject.current_networks({ :include_suspended => true })
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
1
3
|
# Copyright (c) Microsoft Corporation
|
2
4
|
# All rights reserved.
|
3
5
|
#
|
@@ -15,9 +17,25 @@
|
|
15
17
|
# See the Apache Version 2.0 License for specific language governing
|
16
18
|
# permissions and limitations under the License.
|
17
19
|
|
18
|
-
require '
|
20
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
21
|
+
|
22
|
+
describe Yammer::Api::Notification do
|
23
|
+
|
24
|
+
before :all do
|
25
|
+
@client = Yammer::Client.new(
|
26
|
+
:site_url => 'https://www.yammer.com',
|
27
|
+
:client_id => 'PRbTcg9qjgKsp4jjpm1pw',
|
28
|
+
:client_secret => 'Xn7kp7Ly0TCY4GtZWkmSsqGEPg10DmMADyjWkf2U',
|
29
|
+
:access_token => 'TolNOFka9Uls2DxahNi78A'
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
subject { @client }
|
19
34
|
|
20
|
-
|
21
|
-
|
35
|
+
describe '#notifications' do
|
36
|
+
it "should fetch authenticated user's notifications" do
|
37
|
+
subject.should_receive(:get).with('/api/v1/streams/notifications')
|
38
|
+
subject.notifications
|
39
|
+
end
|
22
40
|
end
|
23
|
-
end
|
41
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
# Copyright (c) Microsoft Corporation
|
3
|
+
# All rights reserved.
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
12
|
+
# ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY
|
13
|
+
# IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR
|
14
|
+
# PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
|
15
|
+
#
|
16
|
+
# See the Apache Version 2.0 License for specific language governing
|
17
|
+
# permissions and limitations under the License.
|
18
|
+
|
19
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
20
|
+
|
21
|
+
describe Yammer::Api::Search do
|
22
|
+
|
23
|
+
before :all do
|
24
|
+
@client = Yammer::Client.new(
|
25
|
+
:site_url => 'https://www.yammer.com',
|
26
|
+
:client_id => 'PRbTcg9qjgKsp4jjpm1pw',
|
27
|
+
:client_secret => 'Xn7kp7Ly0TCY4GtZWkmSsqGEPg10DmMADyjWkf2U',
|
28
|
+
:access_token => 'TolNOFka9Uls2DxahNi78A'
|
29
|
+
)
|
30
|
+
end
|
31
|
+
|
32
|
+
subject { @client }
|
33
|
+
|
34
|
+
describe '#open graph object' do
|
35
|
+
|
36
|
+
it 'should create open graph object' do
|
37
|
+
ogo_url = 'http://www.example.com'
|
38
|
+
ogo_props = {
|
39
|
+
:site_name => 'Microsoft',
|
40
|
+
:image => 'https://example.com/global/images/test.jpg'
|
41
|
+
}
|
42
|
+
subject.should_receive(:post).with('/api/v1/open_graph_objects', {
|
43
|
+
:url=>"http://www.example.com",
|
44
|
+
:properites => {
|
45
|
+
:site_name => "Microsoft",
|
46
|
+
:image => "https://example.com/global/images/test.jpg"
|
47
|
+
}
|
48
|
+
})
|
49
|
+
subject.create_open_graph_object(ogo_url, ogo_props)
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should follow open graph object' do
|
53
|
+
subject.should_receive(:post).with('/api/v1/subscriptions', :target_id => 7, :target_type => 'OpenGraphObject')
|
54
|
+
subject.follow_open_graph_object(7)
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'should follow opnen graph object' do
|
58
|
+
subject.should_receive(:get).with('/api/v1/subscriptions/to_open_graph_object/5')
|
59
|
+
subject.is_following_open_graph_object?(5)
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'should fetch open graph objects in user activity stream' do
|
63
|
+
subject.should_receive(:get).with('/api/v1/streams/activities', :owner_type => 'open_graph_object', :owner_id => 4)
|
64
|
+
subject.get_activity_stream_open_graph_objects(4)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
# Copyright (c) Microsoft Corporation
|
4
|
+
# All rights reserved.
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
13
|
+
# ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY
|
14
|
+
# IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR
|
15
|
+
# PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
|
16
|
+
#
|
17
|
+
# See the Apache Version 2.0 License for specific language governing
|
18
|
+
# permissions and limitations under the License.
|
19
|
+
|
20
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
21
|
+
|
22
|
+
describe Yammer::Api::PendingAttachment do
|
23
|
+
|
24
|
+
before :all do
|
25
|
+
@client = Yammer::Client.new(
|
26
|
+
:site_url => 'https://www.yammer.com',
|
27
|
+
:client_id => 'PRbTcg9qjgKsp4jjpm1pw',
|
28
|
+
:client_secret => 'Xn7kp7Ly0TCY4GtZWkmSsqGEPg10DmMADyjWkf2U',
|
29
|
+
:access_token => 'TolNOFka9Uls2DxahNi78A'
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
subject { @client }
|
34
|
+
|
35
|
+
describe '#get_pending_attachment' do
|
36
|
+
it 'should fetch a pending attachment' do
|
37
|
+
subject.should_receive(:get).with('/api/v1/pending_attachments/2')
|
38
|
+
subject.get_pending_attachment(2)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#delete_pending_attachment' do
|
43
|
+
it 'should delete a pending attachment' do
|
44
|
+
subject.should_receive(:delete).with('/api/v1/pending_attachments/1')
|
45
|
+
subject.delete_pending_attachment(1)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe '#create_pending_attachment' do
|
50
|
+
it 'should create a pending attachment' do
|
51
|
+
attachment = upload('attachment.txt')
|
52
|
+
subject.should_receive(:post).with('/api/v1/pending_attachments', :attachment => attachment)
|
53
|
+
subject.create_pending_attachment(attachment)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
1
3
|
# Copyright (c) Microsoft Corporation
|
2
4
|
# All rights reserved.
|
3
5
|
#
|
@@ -14,15 +16,26 @@
|
|
14
16
|
#
|
15
17
|
# See the Apache Version 2.0 License for specific language governing
|
16
18
|
# permissions and limitations under the License.
|
17
|
-
#
|
18
|
-
module Yam
|
19
|
-
module Constants
|
20
|
-
extend self
|
21
19
|
|
22
|
-
|
20
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
21
|
+
|
22
|
+
describe Yammer::Api::Search do
|
23
|
+
|
24
|
+
before :all do
|
25
|
+
@client = Yammer::Client.new(
|
26
|
+
:site_url => 'https://www.yammer.com',
|
27
|
+
:client_id => 'PRbTcg9qjgKsp4jjpm1pw',
|
28
|
+
:client_secret => 'Xn7kp7Ly0TCY4GtZWkmSsqGEPg10DmMADyjWkf2U',
|
29
|
+
:access_token => 'TolNOFka9Uls2DxahNi78A'
|
30
|
+
)
|
31
|
+
end
|
23
32
|
|
24
|
-
|
33
|
+
subject { @client }
|
25
34
|
|
26
|
-
|
35
|
+
describe '#search' do
|
36
|
+
it 'should search for stuff' do
|
37
|
+
subject.should_receive(:get).with('/api/v1/search', { :search => 'tdd dojo' })
|
38
|
+
subject.search(:search => 'tdd dojo')
|
39
|
+
end
|
27
40
|
end
|
28
|
-
end
|
41
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
# Copyright (c) Microsoft Corporation
|
4
|
+
# All rights reserved.
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
13
|
+
# ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY
|
14
|
+
# IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR
|
15
|
+
# PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
|
16
|
+
#
|
17
|
+
# See the Apache Version 2.0 License for specific language governing
|
18
|
+
# permissions and limitations under the License.
|
19
|
+
|
20
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
21
|
+
|
22
|
+
describe Yammer::Api::Search do
|
23
|
+
|
24
|
+
before :all do
|
25
|
+
@client = Yammer::Client.new(
|
26
|
+
:site_url => 'https://www.yammer.com',
|
27
|
+
:client_id => 'PRbTcg9qjgKsp4jjpm1pw',
|
28
|
+
:client_secret => 'Xn7kp7Ly0TCY4GtZWkmSsqGEPg10DmMADyjWkf2U',
|
29
|
+
:access_token => 'TolNOFka9Uls2DxahNi78A'
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
subject { @client }
|
34
|
+
|
35
|
+
describe '#subscription' do
|
36
|
+
it 'should create new subscription' do
|
37
|
+
subject.should_receive(:post).with('/api/v1/subscriptions', :target_type =>'OpenGraphObject', :target_id => 1)
|
38
|
+
subject.create_subscription('OpenGraphObject', 1)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
1
3
|
# Copyright (c) Microsoft Corporation
|
2
4
|
# All rights reserved.
|
3
5
|
#
|
@@ -15,20 +17,25 @@
|
|
15
17
|
# See the Apache Version 2.0 License for specific language governing
|
16
18
|
# permissions and limitations under the License.
|
17
19
|
|
18
|
-
require '
|
19
|
-
|
20
|
-
|
20
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
21
|
+
|
22
|
+
describe Yammer::Api::Thread do
|
21
23
|
|
22
|
-
|
23
|
-
|
24
|
+
before :all do
|
25
|
+
@client = Yammer::Client.new(
|
26
|
+
:site_url => 'https://www.yammer.com',
|
27
|
+
:client_id => 'PRbTcg9qjgKsp4jjpm1pw',
|
28
|
+
:client_secret => 'Xn7kp7Ly0TCY4GtZWkmSsqGEPg10DmMADyjWkf2U',
|
29
|
+
:access_token => 'TolNOFka9Uls2DxahNi78A'
|
30
|
+
)
|
31
|
+
end
|
24
32
|
|
25
|
-
|
26
|
-
# Handler for the client instance
|
27
|
-
attr_accessor :api_client
|
33
|
+
subject { @client }
|
28
34
|
|
29
|
-
|
30
|
-
|
31
|
-
|
35
|
+
describe '#get_thread' do
|
36
|
+
it 'should fetch a thread' do
|
37
|
+
subject.should_receive(:get).with('/api/v1/threads/1', {})
|
38
|
+
subject.get_thread(1)
|
32
39
|
end
|
33
40
|
end
|
34
|
-
end
|
41
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
1
3
|
# Copyright (c) Microsoft Corporation
|
2
4
|
# All rights reserved.
|
3
5
|
#
|
@@ -15,23 +17,25 @@
|
|
15
17
|
# See the Apache Version 2.0 License for specific language governing
|
16
18
|
# permissions and limitations under the License.
|
17
19
|
|
18
|
-
|
19
|
-
module Yam
|
20
|
-
module Request
|
21
|
-
def get(path, params={}, options={})
|
22
|
-
request(:get, path, params, options)
|
23
|
-
end
|
20
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
24
21
|
|
25
|
-
|
26
|
-
|
27
|
-
|
22
|
+
describe Yammer::Api::Topic do
|
23
|
+
|
24
|
+
before :all do
|
25
|
+
@client = Yammer::Client.new(
|
26
|
+
:site_url => 'https://www.yammer.com',
|
27
|
+
:client_id => 'PRbTcg9qjgKsp4jjpm1pw',
|
28
|
+
:client_secret => 'Xn7kp7Ly0TCY4GtZWkmSsqGEPg10DmMADyjWkf2U',
|
29
|
+
:access_token => 'TolNOFka9Uls2DxahNi78A'
|
30
|
+
)
|
31
|
+
end
|
28
32
|
|
29
|
-
|
30
|
-
conn = connection(options)
|
31
|
-
path = (conn.path_prefix + path).gsub(/\/\//,'/') if conn.path_prefix != '/'
|
33
|
+
subject { @client }
|
32
34
|
|
33
|
-
|
34
|
-
|
35
|
+
describe '#topics' do
|
36
|
+
it 'should fetch topic' do
|
37
|
+
subject.should_receive(:get).with('/api/v1/topics/1',{ :is_followed_by => 2 })
|
38
|
+
subject.get_topic(1, :is_followed_by => 2)
|
35
39
|
end
|
36
40
|
end
|
37
|
-
end
|
41
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
# Copyright (c) Microsoft Corporation
|
4
|
+
# All rights reserved.
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
13
|
+
# ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY
|
14
|
+
# IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR
|
15
|
+
# PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
|
16
|
+
#
|
17
|
+
# See the Apache Version 2.0 License for specific language governing
|
18
|
+
# permissions and limitations under the License.
|
19
|
+
|
20
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
21
|
+
require 'ostruct'
|
22
|
+
|
23
|
+
describe Yammer::Api::User do
|
24
|
+
|
25
|
+
before :all do
|
26
|
+
@client = Yammer::Client.new(
|
27
|
+
:site_url => 'https://yammer.com',
|
28
|
+
:client_id => "PRbTcg9qjgKsp4jjpm1pw",
|
29
|
+
:client_secret => "Xn7kp7Ly0TCY4GtZWkmSsqGEPg10DmMADyjWkf2U",
|
30
|
+
:access_token => "TolNOFka9Uls2DxahNi78A"
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
subject { @client }
|
35
|
+
|
36
|
+
describe "users" do
|
37
|
+
it "makes an http request" do
|
38
|
+
@client.should_receive(:get).with('/api/v1/users', { :page => 1, :letter => 'm' })
|
39
|
+
@client.all_users({:page => 1, :letter => 'm'})
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "create_user" do
|
44
|
+
it "makes an http request" do
|
45
|
+
params = {:first_name => 'john', :last_name => 'doe', :email => 'jdoe@yammer-inc.com'}
|
46
|
+
@client.should_receive(:post).with('/api/v1/users', params)
|
47
|
+
@client.create_user(params)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "get_user" do
|
52
|
+
it "makes an http request" do
|
53
|
+
@client.should_receive(:get).with('/api/v1/users/1')
|
54
|
+
@client.get_user(1)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe "update_user" do
|
59
|
+
it "makes an http request" do
|
60
|
+
params = {:first_name => 'jane', :last_name => 'smith'}
|
61
|
+
@client.should_receive(:put).with('/api/v1/users/1', params)
|
62
|
+
@client.update_user(1, params)
|
63
|
+
end
|
64
|
+
|
65
|
+
context 'with id as a string' do
|
66
|
+
it 'updates user' do
|
67
|
+
params = {:first_name => 'jane', :last_name => 'smith'}
|
68
|
+
@client.should_receive(:put).with('/api/v1/users/current', params)
|
69
|
+
subject.update_user('current', params)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe "delete_user" do
|
75
|
+
it "makes an http request" do
|
76
|
+
@client.should_receive(:delete).with('/api/v1/users/1')
|
77
|
+
@client.delete_user(1)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe "user_by_email" do
|
82
|
+
it "makes an http request" do
|
83
|
+
@client.should_receive(:get).with('/api/v1/users/by_email', :email => 'bob@yammer-inc.com')
|
84
|
+
@client.get_user_by_email('bob@yammer-inc.com')
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe "current_user" do
|
89
|
+
it "makes an http request" do
|
90
|
+
@client.should_receive(:get).with('/api/v1/users/current')
|
91
|
+
@client.current_user
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
describe "users_following" do
|
96
|
+
it "makes an http request" do
|
97
|
+
@client.should_receive(:get).with('/api/v1/users/following/3')
|
98
|
+
@client.users_following(3)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
describe "users_followed_by" do
|
103
|
+
it "makes an http request" do
|
104
|
+
@client.should_receive(:get).with('/api/v1/users/followed_by/4')
|
105
|
+
@client.users_followed_by(4)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|