croudia 1.0.5 → 1.0.6
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.
- checksums.yaml +4 -4
- data/lib/croudia/api/favorites.rb +17 -0
- data/lib/croudia/version.rb +1 -1
- data/spec/croudia/api/favorites_spec.rb +36 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8602e9464991c5cf32f2bb90c876ff49fc75bd14
|
4
|
+
data.tar.gz: 9885d3ac96bc597383d66cf0ea44e089b62754e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88d2d921cf8b1da8e1ab1337b56b67309775153c314098cc0982e2fcc2d2f055c17d25cf745eab6de6193e6dbd3b2d171ed49c9338cff1fee9201eb7f99ebc65
|
7
|
+
data.tar.gz: b82159c956cd035b9e0c0a20ba2f7f95efc17b560ec539276c0129de3c0ed2df0b55f8b603e6386d11467ade6a9f9caaa8cca12f82341d7b3295034cab2d5ed8
|
@@ -3,6 +3,23 @@ require 'croudia/status'
|
|
3
3
|
module Croudia
|
4
4
|
module API
|
5
5
|
module Favorites
|
6
|
+
# List of favorited statuses
|
7
|
+
#
|
8
|
+
# @param user [String]
|
9
|
+
# @param params [Hash]
|
10
|
+
# @return [Array<Croudia::Status>]
|
11
|
+
def favorites(user={}, params={})
|
12
|
+
resp = case user
|
13
|
+
when Hash
|
14
|
+
params.merge!(user)
|
15
|
+
get('/favorites.json', params)
|
16
|
+
else
|
17
|
+
get("/favorites/#{user}.json", params)
|
18
|
+
end
|
19
|
+
|
20
|
+
objects(Croudia::Status, resp)
|
21
|
+
end
|
22
|
+
|
6
23
|
# Favorite a status
|
7
24
|
#
|
8
25
|
# @param status_id [String, Integer, Croudia::Status]
|
data/lib/croudia/version.rb
CHANGED
@@ -5,6 +5,42 @@ describe Croudia::API::Favorites do
|
|
5
5
|
@client = Croudia::Client.new
|
6
6
|
end
|
7
7
|
|
8
|
+
describe '#favorites' do
|
9
|
+
context 'when user is not specified' do
|
10
|
+
before do
|
11
|
+
stub_get('/favorites.json').to_return(
|
12
|
+
body: fixture(:timeline),
|
13
|
+
headers: { content_type: 'application/json; charset=utf-8' }
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'requests the correct resource' do
|
18
|
+
@client.favorites
|
19
|
+
expect(a_get('/favorites.json')).to have_been_made
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'returns Array of Croudia::Status' do
|
23
|
+
subject = @client.favorites
|
24
|
+
expect(subject).to be_an Array
|
25
|
+
subject.each { |s| expect(s).to be_a Croudia::Status }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'when user is specified' do
|
30
|
+
before do
|
31
|
+
stub_get('/favorites/wktk.json').to_return(
|
32
|
+
body: fixture(:timeline),
|
33
|
+
headers: { content_type: 'application/json; charset=utf-8' }
|
34
|
+
)
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'requests the correct resource' do
|
38
|
+
@client.favorites('wktk')
|
39
|
+
expect(a_get('/favorites/wktk.json')).to have_been_made
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
8
44
|
describe '#favorite' do
|
9
45
|
before do
|
10
46
|
stub_post('/favorites/create/1234.json').to_return(
|