meducation_sdk 2.1.2 → 2.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d7021247a0ac9c68f00f0453299c6e7c5c79a6e7
4
- data.tar.gz: 20a4e1b587813fe69acf735daec4d1c62df17608
3
+ metadata.gz: 7ee0e1febec5e14ae0d8ad9a1b6dbb5bcbef6274
4
+ data.tar.gz: e6ac2312b72eddf19599aa29e4cc4a26eead9f1a
5
5
  SHA512:
6
- metadata.gz: 19911c95efdc0fe6dbe01836d91d7dcad5441e5290bd08990155472e497f9959d2ccd52940b3102a71d5e0fdc79511856e0510cd6e63db5761a7a133c4141066
7
- data.tar.gz: 59cf16c0d638171bd94d2284394ec3eacdf01c97c0023d305a013313d8836a0614507f22cddbff6503378e10ea571e0303b5ba31080265381a7d16961cba9f96
6
+ metadata.gz: 898d808840d6cfae8f307e5995cea56ab5669c6f2bd7b9a9e627b982f66fbcbfdabda43d7949aa8cf3a8f8992f8d61b5b28ec0d822775edf75e2d7bdbb93fff1
7
+ data.tar.gz: 027ac89d2416db85b53ad058ffccbf04911acb9af5e5e94c0553b0a38594dd7ac7670d28aba29d185bd3acacf35973d671b4c66378d7c939516fd3656af196f2
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ # 2.1.3 / 2014-04-16
2
+ * [FEATURE] Added Ecommerce Product
3
+
1
4
  # 2.1.2 / 2014-04-16
2
5
  * [FEATURE] Added New Email Short Codes
3
6
 
@@ -43,6 +43,7 @@ RESOURCES = %w{
43
43
  community_membership
44
44
  contribution
45
45
  dashboard_item
46
+ ecommerce_product
46
47
  ecommerce_subscription
47
48
  external_resource
48
49
  group
@@ -0,0 +1,24 @@
1
+ module MeducationSDK
2
+ class EcommerceProduct < Resource
3
+ self.path = "/ecommerce_products"
4
+
5
+ def item
6
+ @item ||= sdk_class_for(item_type).find(item_id)
7
+ end
8
+
9
+ def collection
10
+ item.is_a?(Collection) ? item : (raise MeducationSDKError.new("Item is not a collection. It is a #{item.class.name}"))
11
+ end
12
+
13
+ end
14
+
15
+ class EcommerceProductMock < EcommerceProduct
16
+ extend Loquor::ResourceMock
17
+
18
+ self.attributes = {
19
+ id: 1,
20
+ item_type: 89,
21
+ item_id: 90
22
+ }
23
+ end
24
+ end
@@ -1,3 +1,3 @@
1
1
  module MeducationSDK
2
- VERSION = "2.1.2"
2
+ VERSION = "2.1.3"
3
3
  end
@@ -0,0 +1,43 @@
1
+ require_relative '../test_helper'
2
+ require_relative '../resource_test'
3
+
4
+ module MeducationSDK
5
+ class EcommerceProductTest < ResourceTest
6
+ test_resource(EcommerceProduct, '/ecommerce_products')
7
+
8
+ def setup
9
+ super
10
+ @collection = MeducationSDK::Collection.new({id: 1, slug: "funky_professor"})
11
+ end
12
+
13
+ def test_item_calls_sdk_when_known_type
14
+ product = EcommerceProduct.new(item_id: 3, item_type: "Collection")
15
+ MeducationSDK::Collection.expects(:find).with(3).returns(@collection)
16
+ assert_equal @collection, product.item
17
+ end
18
+
19
+ def test_item_raises_error_when_unknown_type
20
+ product = EcommerceProduct.new(item_id: 3, item_type: "UnknownType")
21
+ assert_raises NameError do
22
+ product.item
23
+ end
24
+ end
25
+
26
+ def test_collection_returns_when_item_a_collection
27
+ product = EcommerceProduct.new(item_id: 3, item_type: "Collection")
28
+ MeducationSDK::Collection.expects(:find).with(3).returns(@collection)
29
+ assert_equal @collection, product.collection
30
+ end
31
+
32
+ def test_collection_raises_error_when_item_not_a_collection
33
+ media_file = MeducationSDK::MediaFile.new({id: 1})
34
+ product = EcommerceProduct.new(item_id: 3, item_type: "MediaFile")
35
+ MeducationSDK::MediaFile.expects(:find).with(3).returns(media_file)
36
+ assert_raises MeducationSDKError do
37
+ product.collection
38
+ end
39
+ end
40
+
41
+ end
42
+ end
43
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: meducation_sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.2
4
+ version: 2.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Walker
@@ -156,6 +156,7 @@ files:
156
156
  - lib/meducation_sdk/resources/community_membership.rb
157
157
  - lib/meducation_sdk/resources/contribution.rb
158
158
  - lib/meducation_sdk/resources/dashboard_item.rb
159
+ - lib/meducation_sdk/resources/ecommerce_product.rb
159
160
  - lib/meducation_sdk/resources/ecommerce_subscription.rb
160
161
  - lib/meducation_sdk/resources/external_resource.rb
161
162
  - lib/meducation_sdk/resources/group.rb
@@ -221,6 +222,7 @@ files:
221
222
  - test/resources/community_test.rb
222
223
  - test/resources/contribution_test.rb
223
224
  - test/resources/dashboard_item_test.rb
225
+ - test/resources/ecommerce_product_test.rb
224
226
  - test/resources/ecommerce_subscription_test.rb
225
227
  - test/resources/external_resource_test.rb
226
228
  - test/resources/group_discussion_post_test.rb
@@ -310,6 +312,7 @@ test_files:
310
312
  - test/resources/community_test.rb
311
313
  - test/resources/contribution_test.rb
312
314
  - test/resources/dashboard_item_test.rb
315
+ - test/resources/ecommerce_product_test.rb
313
316
  - test/resources/ecommerce_subscription_test.rb
314
317
  - test/resources/external_resource_test.rb
315
318
  - test/resources/group_discussion_post_test.rb