meducation_sdk 1.5.6 → 1.5.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/meducation_sdk/resources/author.rb +23 -0
- data/lib/meducation_sdk/resources/collection_topic.rb +8 -6
- data/lib/meducation_sdk/version.rb +1 -1
- data/lib/meducation_sdk.rb +1 -0
- data/test/resources/author_test.rb +15 -0
- data/test/resources/collection_topic_test.rb +15 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 59cdaa5f76cdde2eb332690eda73a06fc48f7679
|
4
|
+
data.tar.gz: 954e3a4ecf08267207ccea0751c0896d719bf8f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e5e383e3455c0109d8399762c5dcf73deedbfa7e234a0e18913c2caeb702fe5c2a0a116a2e40116ebc022bf55a8c946f35436b4ca3b378f40a5d22cc6beca6b
|
7
|
+
data.tar.gz: 6e468ec9dfe67820d6857ead5038651b2985024d5e2d9969030dd53ce00169bce7a101f40ebfca5413ba6c4c3f7317d84cf11c6c4f0d396c2048844c88059fc3
|
data/CHANGELOG.md
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
module MeducationSDK
|
2
|
+
|
3
|
+
class Author < Resource
|
4
|
+
self.path = "/authors"
|
5
|
+
|
6
|
+
def user
|
7
|
+
@user ||= User.find(user_id)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class AuthorMock < Author
|
12
|
+
extend Loquor::ResourceMock
|
13
|
+
|
14
|
+
self.attributes = {
|
15
|
+
id: 728,
|
16
|
+
user_id: 100,
|
17
|
+
name: 'Dr Buick',
|
18
|
+
occupation: "Doctor",
|
19
|
+
qualifications: "All of them"
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -4,14 +4,17 @@ module MeducationSDK
|
|
4
4
|
|
5
5
|
self.path = "/collection_topics"
|
6
6
|
|
7
|
-
def
|
8
|
-
@
|
7
|
+
def authors
|
8
|
+
@authors ||= Author.where(id: author_ids)
|
9
|
+
end
|
10
|
+
|
11
|
+
def users
|
12
|
+
@authors ||= User.where(id: authors.map(&:user_id))
|
9
13
|
end
|
10
14
|
|
11
15
|
def comments
|
12
16
|
@comments ||= Comment.where(id: comment_ids)
|
13
17
|
end
|
14
|
-
|
15
18
|
end
|
16
19
|
|
17
20
|
class CollectionTopicMock < CollectionTopic
|
@@ -26,9 +29,8 @@ module MeducationSDK
|
|
26
29
|
resource_ids: [3, 4, 5],
|
27
30
|
views_in_last_30_days: 1,
|
28
31
|
views_in_last_60_days: 2,
|
29
|
-
rating: 123
|
32
|
+
rating: 123,
|
33
|
+
author_ids: [7,12,54]
|
30
34
|
}
|
31
|
-
|
32
35
|
end
|
33
|
-
|
34
36
|
end
|
data/lib/meducation_sdk.rb
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require_relative '../resource_test'
|
3
|
+
|
4
|
+
module MeducationSDK
|
5
|
+
class AuthorTest < ResourceTest
|
6
|
+
test_resource(Author, '/authors')
|
7
|
+
|
8
|
+
def test_user_calls_sdk
|
9
|
+
author = Author.new(user_id: 20)
|
10
|
+
MeducationSDK::User.expects(:find).with(20)
|
11
|
+
author.user
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
@@ -10,6 +10,20 @@ module MeducationSDK
|
|
10
10
|
MeducationSDK::Comment.expects(:where).with(id: [7, 8, 9])
|
11
11
|
topic.comments
|
12
12
|
end
|
13
|
+
def test_authors_calls_spi
|
14
|
+
topic = CollectionTopic.new(author_ids: [7, 8, 9])
|
15
|
+
MeducationSDK::Author.expects(:where).with(id: [7, 8, 9])
|
16
|
+
topic.authors
|
17
|
+
end
|
18
|
+
def test_users_calls_spi
|
19
|
+
authors = [
|
20
|
+
Author.new(user_id: 8),
|
21
|
+
Author.new(user_id: 10)
|
22
|
+
]
|
23
|
+
topic = CollectionTopic.new(author_ids: [7, 8, 9])
|
24
|
+
MeducationSDK::Author.expects(:where).with(id: [7, 8, 9]).returns(authors)
|
25
|
+
MeducationSDK::User.expects(:where).with(id: [8, 10])
|
26
|
+
topic.users
|
27
|
+
end
|
13
28
|
end
|
14
29
|
end
|
15
|
-
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: meducation_sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Walker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -127,6 +127,7 @@ files:
|
|
127
127
|
- lib/meducation_sdk/configuration.rb
|
128
128
|
- lib/meducation_sdk/mocker.rb
|
129
129
|
- lib/meducation_sdk/resource.rb
|
130
|
+
- lib/meducation_sdk/resources/author.rb
|
130
131
|
- lib/meducation_sdk/resources/badges/answerer_badge.rb
|
131
132
|
- lib/meducation_sdk/resources/badges/badge.rb
|
132
133
|
- lib/meducation_sdk/resources/badges/befriender_badge.rb
|
@@ -181,6 +182,7 @@ files:
|
|
181
182
|
- test/configuration_test.rb
|
182
183
|
- test/mocker_test.rb
|
183
184
|
- test/resource_test.rb
|
185
|
+
- test/resources/author_test.rb
|
184
186
|
- test/resources/badges/answerer_badge_test.rb
|
185
187
|
- test/resources/badges/badge_test.rb
|
186
188
|
- test/resources/badges/befriender_badge_test.rb
|
@@ -259,6 +261,7 @@ test_files:
|
|
259
261
|
- test/configuration_test.rb
|
260
262
|
- test/mocker_test.rb
|
261
263
|
- test/resource_test.rb
|
264
|
+
- test/resources/author_test.rb
|
262
265
|
- test/resources/badges/answerer_badge_test.rb
|
263
266
|
- test/resources/badges/badge_test.rb
|
264
267
|
- test/resources/badges/befriender_badge_test.rb
|