spiffy_stores_api 4.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.document +5 -0
- data/.gitignore +10 -0
- data/.travis.yml +14 -0
- data/CHANGELOG +3 -0
- data/Gemfile +5 -0
- data/Gemfile_ar40 +5 -0
- data/Gemfile_ar41 +5 -0
- data/Gemfile_ar50 +5 -0
- data/Gemfile_ar_master +5 -0
- data/README.md +200 -0
- data/Rakefile +39 -0
- data/lib/active_resource/base_ext.rb +21 -0
- data/lib/active_resource/connection_ext.rb +10 -0
- data/lib/active_resource/detailed_log_subscriber.rb +19 -0
- data/lib/active_resource/disable_prefix_check.rb +36 -0
- data/lib/active_resource/json_errors.rb +31 -0
- data/lib/active_resource/to_query.rb +10 -0
- data/lib/spiffy_stores_api.rb +29 -0
- data/lib/spiffy_stores_api/connection.rb +33 -0
- data/lib/spiffy_stores_api/countable.rb +14 -0
- data/lib/spiffy_stores_api/json_format.rb +18 -0
- data/lib/spiffy_stores_api/limits.rb +86 -0
- data/lib/spiffy_stores_api/metafields.rb +19 -0
- data/lib/spiffy_stores_api/resources.rb +2 -0
- data/lib/spiffy_stores_api/resources/address.rb +4 -0
- data/lib/spiffy_stores_api/resources/article.rb +20 -0
- data/lib/spiffy_stores_api/resources/base.rb +86 -0
- data/lib/spiffy_stores_api/resources/blog.rb +9 -0
- data/lib/spiffy_stores_api/resources/collect.rb +5 -0
- data/lib/spiffy_stores_api/resources/country.rb +4 -0
- data/lib/spiffy_stores_api/resources/customer.rb +24 -0
- data/lib/spiffy_stores_api/resources/image.rb +16 -0
- data/lib/spiffy_stores_api/resources/metafield.rb +12 -0
- data/lib/spiffy_stores_api/resources/order.rb +23 -0
- data/lib/spiffy_stores_api/resources/page.rb +5 -0
- data/lib/spiffy_stores_api/resources/product.rb +32 -0
- data/lib/spiffy_stores_api/resources/province.rb +5 -0
- data/lib/spiffy_stores_api/resources/script_tag.rb +4 -0
- data/lib/spiffy_stores_api/resources/standard_collection.rb +18 -0
- data/lib/spiffy_stores_api/resources/store.rb +18 -0
- data/lib/spiffy_stores_api/resources/super_collection.rb +14 -0
- data/lib/spiffy_stores_api/resources/variant.rb +8 -0
- data/lib/spiffy_stores_api/resources/webhook.rb +4 -0
- data/lib/spiffy_stores_api/session.rb +145 -0
- data/lib/spiffy_stores_api/version.rb +3 -0
- data/spiffy_stores_api.gemspec +34 -0
- data/test/active_resource/json_errors_test.rb +19 -0
- data/test/article_test.rb +73 -0
- data/test/base_test.rb +112 -0
- data/test/blog_test.rb +8 -0
- data/test/collect_test.rb +9 -0
- data/test/countable_test.rb +13 -0
- data/test/customer_test.rb +50 -0
- data/test/fixtures/article.json +15 -0
- data/test/fixtures/articles.json +39 -0
- data/test/fixtures/asset.json +9 -0
- data/test/fixtures/assets.json +136 -0
- data/test/fixtures/authors.json +1 -0
- data/test/fixtures/blog.json +12 -0
- data/test/fixtures/blogs.json +13 -0
- data/test/fixtures/collect.json +10 -0
- data/test/fixtures/custom_collection.json +17 -0
- data/test/fixtures/customers.json +64 -0
- data/test/fixtures/customers_search.json +66 -0
- data/test/fixtures/image.json +10 -0
- data/test/fixtures/images.json +20 -0
- data/test/fixtures/metafield.json +13 -0
- data/test/fixtures/metafields.json +26 -0
- data/test/fixtures/o_auth_revoke.json +5 -0
- data/test/fixtures/order.json +297 -0
- data/test/fixtures/orders.json +299 -0
- data/test/fixtures/product.json +116 -0
- data/test/fixtures/redirect.json +7 -0
- data/test/fixtures/script_tag.json +10 -0
- data/test/fixtures/script_tags.json +18 -0
- data/test/fixtures/smart_collection.json +21 -0
- data/test/fixtures/store.json +35 -0
- data/test/fixtures/tags.json +1 -0
- data/test/fixtures/transaction.json +29 -0
- data/test/fixtures/variant.json +23 -0
- data/test/fixtures/variants.json +88 -0
- data/test/fixtures/webhook.json +10 -0
- data/test/fixtures/webhooks.json +18 -0
- data/test/metafield_test.rb +46 -0
- data/test/store_test.rb +58 -0
- data/test/test_helper.rb +90 -0
- metadata +219 -0
@@ -0,0 +1,116 @@
|
|
1
|
+
{
|
2
|
+
"product": {
|
3
|
+
"product_type": "Cult Products",
|
4
|
+
"handle": "ipod-nano",
|
5
|
+
"created_at": "2011-10-20T14:05:13-04:00",
|
6
|
+
"body_html": "<p>It's the small iPod with one very big idea: Video. Now the world's most popular music player, available in 4GB and 8GB models, lets you enjoy TV shows, movies, video podcasts, and more. The larger, brighter display means amazing picture quality. In six eye-catching colors, iPod nano is stunning all around. And with models starting at just $149, little speaks volumes.</p>",
|
7
|
+
"title": "IPod Nano - 8GB",
|
8
|
+
"template_suffix": null,
|
9
|
+
"updated_at": "2011-10-20T14:05:13-04:00",
|
10
|
+
"id": 632910392,
|
11
|
+
"tags": "Emotive, Flash Memory, MP3, Music",
|
12
|
+
"images": [
|
13
|
+
{
|
14
|
+
"position": 1,
|
15
|
+
"created_at": "2011-10-20T14:05:13-04:00",
|
16
|
+
"product_id": 632910392,
|
17
|
+
"updated_at": "2011-10-20T14:05:13-04:00",
|
18
|
+
"src": "http://static.spiffyserver.com/s/files/1/6909/3384/products/ipod-nano.png?0",
|
19
|
+
"id": 850703190
|
20
|
+
}
|
21
|
+
],
|
22
|
+
"variants": [
|
23
|
+
{
|
24
|
+
"position": 1,
|
25
|
+
"price": "199.00",
|
26
|
+
"product_id": 632910392,
|
27
|
+
"created_at": "2011-10-20T14:05:13-04:00",
|
28
|
+
"requires_shipping": true,
|
29
|
+
"title": "Pink",
|
30
|
+
"inventory_quantity": 10,
|
31
|
+
"compare_at_price": null,
|
32
|
+
"inventory_policy": "continue",
|
33
|
+
"updated_at": "2011-10-20T14:05:13-04:00",
|
34
|
+
"inventory_management": "spiffy",
|
35
|
+
"id": 808950810,
|
36
|
+
"taxable": true,
|
37
|
+
"grams": 200,
|
38
|
+
"sku": "IPOD2008PINK",
|
39
|
+
"option1": "Pink",
|
40
|
+
"fulfillment_service": "manual",
|
41
|
+
"option2": null,
|
42
|
+
"option3": null
|
43
|
+
},
|
44
|
+
{
|
45
|
+
"position": 2,
|
46
|
+
"price": "199.00",
|
47
|
+
"product_id": 632910392,
|
48
|
+
"created_at": "2011-10-20T14:05:13-04:00",
|
49
|
+
"requires_shipping": true,
|
50
|
+
"title": "Red",
|
51
|
+
"inventory_quantity": 20,
|
52
|
+
"compare_at_price": null,
|
53
|
+
"inventory_policy": "continue",
|
54
|
+
"updated_at": "2011-10-20T14:05:13-04:00",
|
55
|
+
"inventory_management": "spiffy",
|
56
|
+
"id": 49148385,
|
57
|
+
"taxable": true,
|
58
|
+
"grams": 200,
|
59
|
+
"sku": "IPOD2008RED",
|
60
|
+
"option1": "Red",
|
61
|
+
"fulfillment_service": "manual",
|
62
|
+
"option2": null,
|
63
|
+
"option3": null
|
64
|
+
},
|
65
|
+
{
|
66
|
+
"position": 3,
|
67
|
+
"price": "199.00",
|
68
|
+
"product_id": 632910392,
|
69
|
+
"created_at": "2011-10-20T14:05:13-04:00",
|
70
|
+
"requires_shipping": true,
|
71
|
+
"title": "Green",
|
72
|
+
"inventory_quantity": 30,
|
73
|
+
"compare_at_price": null,
|
74
|
+
"inventory_policy": "continue",
|
75
|
+
"updated_at": "2011-10-20T14:05:13-04:00",
|
76
|
+
"inventory_management": "spiffy",
|
77
|
+
"id": 39072856,
|
78
|
+
"taxable": true,
|
79
|
+
"grams": 200,
|
80
|
+
"sku": "IPOD2008GREEN",
|
81
|
+
"option1": "Green",
|
82
|
+
"fulfillment_service": "manual",
|
83
|
+
"option2": null,
|
84
|
+
"option3": null
|
85
|
+
},
|
86
|
+
{
|
87
|
+
"position": 4,
|
88
|
+
"price": "199.00",
|
89
|
+
"product_id": 632910392,
|
90
|
+
"created_at": "2011-10-20T14:05:13-04:00",
|
91
|
+
"requires_shipping": true,
|
92
|
+
"title": "Black",
|
93
|
+
"inventory_quantity": 40,
|
94
|
+
"compare_at_price": null,
|
95
|
+
"inventory_policy": "continue",
|
96
|
+
"updated_at": "2011-10-20T14:05:13-04:00",
|
97
|
+
"inventory_management": "spiffy",
|
98
|
+
"id": 457924702,
|
99
|
+
"taxable": true,
|
100
|
+
"grams": 200,
|
101
|
+
"sku": "IPOD2008BLACK",
|
102
|
+
"option1": "Black",
|
103
|
+
"fulfillment_service": "manual",
|
104
|
+
"option2": null,
|
105
|
+
"option3": null
|
106
|
+
}
|
107
|
+
],
|
108
|
+
"vendor": "Apple",
|
109
|
+
"published_at": "2007-12-31T19:00:00-05:00",
|
110
|
+
"options": [
|
111
|
+
{
|
112
|
+
"name": "Title"
|
113
|
+
}
|
114
|
+
]
|
115
|
+
}
|
116
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
{
|
2
|
+
"script_tags": [
|
3
|
+
{
|
4
|
+
"created_at": "2014-03-07T16:14:54-05:00",
|
5
|
+
"event": "onload",
|
6
|
+
"id": 421379493,
|
7
|
+
"src": "http://js-aplenty.com/bar.js",
|
8
|
+
"updated_at": "2014-03-07T16:14:54-05:00"
|
9
|
+
},
|
10
|
+
{
|
11
|
+
"created_at": "2014-03-07T16:14:54-05:00",
|
12
|
+
"event": "onload",
|
13
|
+
"id": 596726825,
|
14
|
+
"src": "http://js-aplenty.com/foo.js",
|
15
|
+
"updated_at": "2014-03-07T16:14:54-05:00"
|
16
|
+
}
|
17
|
+
]
|
18
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
{
|
2
|
+
"smart_collection": {
|
3
|
+
"id": 1063001432,
|
4
|
+
"handle": "macbooks",
|
5
|
+
"title": "Macbooks",
|
6
|
+
"updated_at": "2016-03-17T16:57:03-04:00",
|
7
|
+
"body_html": null,
|
8
|
+
"published_at": null,
|
9
|
+
"sort_order": "alpha-asc",
|
10
|
+
"template_suffix": null,
|
11
|
+
"published_scope": "global",
|
12
|
+
"disjunctive": false,
|
13
|
+
"rules": [
|
14
|
+
{
|
15
|
+
"column": "title",
|
16
|
+
"relation": "starts_with",
|
17
|
+
"condition": "mac"
|
18
|
+
}
|
19
|
+
]
|
20
|
+
}
|
21
|
+
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
{
|
2
|
+
"store": {
|
3
|
+
"id": 690933842,
|
4
|
+
"name": "Apple Computers",
|
5
|
+
"domain": "shop.apple.com",
|
6
|
+
"spiffystores_domain": "apple.spiffystores.com",
|
7
|
+
"store_owner": "Steve Jobs",
|
8
|
+
"email": "steve@apple.com",
|
9
|
+
"customer_email": "sales@apple.com",
|
10
|
+
"address1": "1 Infinite Loop",
|
11
|
+
"city": "Cupertino",
|
12
|
+
"region": "California",
|
13
|
+
"region_code": "CA",
|
14
|
+
"country": "United States of America",
|
15
|
+
"country_code": "US",
|
16
|
+
"postal_code": "95014",
|
17
|
+
"phone": "61293607375",
|
18
|
+
"mobile": "61412123456",
|
19
|
+
"currency": "USD",
|
20
|
+
"money_format": "${{amount}}",
|
21
|
+
"money_with_currency_format": "${{amount}} USD",
|
22
|
+
"password_enabled": false,
|
23
|
+
"tax_shipping": true,
|
24
|
+
"tax_export_shipping": false,
|
25
|
+
"taxes_included": true,
|
26
|
+
"tax_rate": 0.1,
|
27
|
+
"timezone": "America/Los Angeles",
|
28
|
+
"unit_system":"imperial",
|
29
|
+
"tax_number": "123456789",
|
30
|
+
"instalments": false,
|
31
|
+
"plan_name": "Enterprise",
|
32
|
+
"created_at": "2015-05-08T16:02:51.611-08:00",
|
33
|
+
"force_ssl": true
|
34
|
+
}
|
35
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"tags": ["consequuntur", "cupiditate", "repellendus"]}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
{
|
2
|
+
"transaction": {
|
3
|
+
"amount": "409.94",
|
4
|
+
"authorization": "authorization-key",
|
5
|
+
"created_at": "2005-08-01T11:57:11-04:00",
|
6
|
+
"gateway": "bogus",
|
7
|
+
"id": 389404469,
|
8
|
+
"kind": "authorization",
|
9
|
+
"location_id": null,
|
10
|
+
"message": null,
|
11
|
+
"order_id": 450789469,
|
12
|
+
"parent_id": null,
|
13
|
+
"status": "success",
|
14
|
+
"test": false,
|
15
|
+
"user_id": null,
|
16
|
+
"device_id": null,
|
17
|
+
"receipt": {
|
18
|
+
"testcase": true,
|
19
|
+
"authorization": "123456"
|
20
|
+
},
|
21
|
+
"payment_details": {
|
22
|
+
"avs_result_code": null,
|
23
|
+
"credit_card_bin": null,
|
24
|
+
"cvv_result_code": null,
|
25
|
+
"credit_card_number": "XXXX-XXXX-XXXX-4242",
|
26
|
+
"credit_card_company": "Visa"
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
{
|
2
|
+
"variant": {
|
3
|
+
"price": "199.00",
|
4
|
+
"position": 1,
|
5
|
+
"created_at": "2011-10-20T14:05:13-04:00",
|
6
|
+
"title": "Pink",
|
7
|
+
"requires_shipping": true,
|
8
|
+
"updated_at": "2011-10-20T14:05:13-04:00",
|
9
|
+
"inventory_policy": "continue",
|
10
|
+
"compare_at_price": null,
|
11
|
+
"inventory_quantity": 10,
|
12
|
+
"inventory_management": "spiffy",
|
13
|
+
"taxable": true,
|
14
|
+
"id": 808950810,
|
15
|
+
"grams": 200,
|
16
|
+
"sku": "IPOD2008PINK",
|
17
|
+
"option1": "Pink",
|
18
|
+
"option2": null,
|
19
|
+
"fulfillment_service": "manual",
|
20
|
+
"option3": null,
|
21
|
+
"product_id": 632910392
|
22
|
+
}
|
23
|
+
}
|
@@ -0,0 +1,88 @@
|
|
1
|
+
{
|
2
|
+
"variants": [
|
3
|
+
{
|
4
|
+
"price": "199.00",
|
5
|
+
"position": 1,
|
6
|
+
"created_at": "2011-10-20T14:05:13-04:00",
|
7
|
+
"title": "Pink",
|
8
|
+
"requires_shipping": true,
|
9
|
+
"updated_at": "2011-10-20T14:05:13-04:00",
|
10
|
+
"inventory_policy": "continue",
|
11
|
+
"compare_at_price": null,
|
12
|
+
"inventory_quantity": 10,
|
13
|
+
"inventory_management": "spiffy",
|
14
|
+
"taxable": true,
|
15
|
+
"id": 808950810,
|
16
|
+
"grams": 200,
|
17
|
+
"sku": "IPOD2008PINK",
|
18
|
+
"option1": "Pink",
|
19
|
+
"option2": null,
|
20
|
+
"fulfillment_service": "manual",
|
21
|
+
"option3": null,
|
22
|
+
"product_id": 632910392
|
23
|
+
},
|
24
|
+
{
|
25
|
+
"price": "199.00",
|
26
|
+
"position": 2,
|
27
|
+
"created_at": "2011-10-20T14:05:13-04:00",
|
28
|
+
"title": "Red",
|
29
|
+
"requires_shipping": true,
|
30
|
+
"updated_at": "2011-10-20T14:05:13-04:00",
|
31
|
+
"inventory_policy": "continue",
|
32
|
+
"compare_at_price": null,
|
33
|
+
"inventory_quantity": 20,
|
34
|
+
"inventory_management": "spiffy",
|
35
|
+
"taxable": true,
|
36
|
+
"id": 49148385,
|
37
|
+
"grams": 200,
|
38
|
+
"sku": "IPOD2008RED",
|
39
|
+
"option1": "Red",
|
40
|
+
"option2": null,
|
41
|
+
"fulfillment_service": "manual",
|
42
|
+
"option3": null,
|
43
|
+
"product_id": 632910392
|
44
|
+
},
|
45
|
+
{
|
46
|
+
"price": "199.00",
|
47
|
+
"position": 3,
|
48
|
+
"created_at": "2011-10-20T14:05:13-04:00",
|
49
|
+
"title": "Green",
|
50
|
+
"requires_shipping": true,
|
51
|
+
"updated_at": "2011-10-20T14:05:13-04:00",
|
52
|
+
"inventory_policy": "continue",
|
53
|
+
"compare_at_price": null,
|
54
|
+
"inventory_quantity": 30,
|
55
|
+
"inventory_management": "spiffy",
|
56
|
+
"taxable": true,
|
57
|
+
"id": 39072856,
|
58
|
+
"grams": 200,
|
59
|
+
"sku": "IPOD2008GREEN",
|
60
|
+
"option1": "Green",
|
61
|
+
"option2": null,
|
62
|
+
"fulfillment_service": "manual",
|
63
|
+
"option3": null,
|
64
|
+
"product_id": 632910392
|
65
|
+
},
|
66
|
+
{
|
67
|
+
"price": "199.00",
|
68
|
+
"position": 4,
|
69
|
+
"created_at": "2011-10-20T14:05:13-04:00",
|
70
|
+
"title": "Black",
|
71
|
+
"requires_shipping": true,
|
72
|
+
"updated_at": "2011-10-20T14:05:13-04:00",
|
73
|
+
"inventory_policy": "continue",
|
74
|
+
"compare_at_price": null,
|
75
|
+
"inventory_quantity": 40,
|
76
|
+
"inventory_management": "spiffy",
|
77
|
+
"taxable": true,
|
78
|
+
"id": 457924702,
|
79
|
+
"grams": 200,
|
80
|
+
"sku": "IPOD2008BLACK",
|
81
|
+
"option1": "Black",
|
82
|
+
"option2": null,
|
83
|
+
"fulfillment_service": "manual",
|
84
|
+
"option3": null,
|
85
|
+
"product_id": 632910392
|
86
|
+
}
|
87
|
+
]
|
88
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
{
|
2
|
+
"webhooks":[{
|
3
|
+
"address":"http://www.yoloship.it/webhook",
|
4
|
+
"created_at":"2014-02-11T12:13:55-05:00",
|
5
|
+
"format":"json",
|
6
|
+
"id":123456,
|
7
|
+
"topic":"orders/create",
|
8
|
+
"updated_at":"2014-02-11T12:13:55-05:00"
|
9
|
+
},
|
10
|
+
{
|
11
|
+
"address":"http://www.yoloship.it/webhook",
|
12
|
+
"created_at":"2014-02-11T12:13:55-05:00",
|
13
|
+
"format":"json",
|
14
|
+
"id":123456,
|
15
|
+
"topic":"orders/create",
|
16
|
+
"updated_at":"2014-02-11T12:13:55-05:00"
|
17
|
+
}]
|
18
|
+
}
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class MetafieldTest < Test::Unit::TestCase
|
4
|
+
def test_get_metafields
|
5
|
+
fake "metafields", :method => :get, :body => load_fixture('metafields')
|
6
|
+
metafields = SpiffyStoresAPI::Metafield.find(:all)
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_get_metafield
|
10
|
+
fake "metafields/721389482", :method => :get, :body => load_fixture('metafield')
|
11
|
+
assert SpiffyStoresAPI::Metafield.find(721389482)
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_get_metafield_of_a_blog
|
15
|
+
fake "blogs/1008414260/metafields/721389482", :method => :get, :body => load_fixture('metafield')
|
16
|
+
metafield = SpiffyStoresAPI::Metafield.find(721389482, :params => {:resource => "blogs", :resource_id => 1008414260})
|
17
|
+
assert_equal 1008414260, metafield.prefix_options[:resource_id]
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_create_metafield_for_a_blog
|
21
|
+
fake "blogs/1008414260", :method => :get, :body => load_fixture('blog')
|
22
|
+
fake "blogs/1008414260/metafields", :method => :post, :status => 201, :body => load_fixture('metafield')
|
23
|
+
|
24
|
+
blog = SpiffyStoresAPI::Blog.find(1008414260)
|
25
|
+
metafield = blog.add_metafield(SpiffyStoresAPI::Metafield.new(:namespace => "summaries", :key => "First Summary", :value => "Make commerce better", :value_type => "string"))
|
26
|
+
|
27
|
+
assert_equal ActiveSupport::JSON.decode('{"metafield":{"namespace":"summaries","key":"First Summary","value":"Make commerce better","value_type":"string"}}'), ActiveSupport::JSON.decode(FakeWeb.last_request.body)
|
28
|
+
assert !metafield.new_record?
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_update_metafield
|
32
|
+
fake "metafields/721389482", :method => :get, :body => load_fixture('metafield')
|
33
|
+
fake "metafields/721389482", :method => :put, :status => 200, :body => load_fixture('metafield')
|
34
|
+
metafield = SpiffyStoresAPI::Metafield.find(721389482)
|
35
|
+
metafield.namespace = "teaser"
|
36
|
+
assert metafield.save
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_delete_metafield
|
40
|
+
fake "metafields/721389482", :method => :get, :body => load_fixture('metafield')
|
41
|
+
fake "metafields/721389482", :method => :delete, :body => 'destroyed'
|
42
|
+
metafield = SpiffyStoresAPI::Metafield.find(721389482)
|
43
|
+
assert metafield.destroy
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
data/test/store_test.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class StoreTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
super
|
6
|
+
fake "store"
|
7
|
+
@store = SpiffyStoresAPI::Store.current
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_current_should_return_current_store
|
11
|
+
assert @store.is_a?(SpiffyStoresAPI::Store)
|
12
|
+
assert_equal "Apple Computers", @store.name
|
13
|
+
assert_equal "apple.spiffystores.com", @store.spiffystores_domain
|
14
|
+
assert_equal 690933842, @store.id
|
15
|
+
assert_equal "2015-05-08T16:02:51.611-08:00", @store.created_at
|
16
|
+
assert_equal true, @store.tax_shipping
|
17
|
+
assert_equal false, @store.tax_export_shipping
|
18
|
+
assert_equal true, @store.force_ssl
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_current_with_options_should_return_current_store
|
22
|
+
fake "store.json?fields=name%2Cspiffystores_domain", :extension => false, :method => :get, :status => 201, :body => load_fixture('store')
|
23
|
+
|
24
|
+
@store = SpiffyStoresAPI::Store.current(params: { fields: 'name,spiffystores_domain' })
|
25
|
+
assert @store.is_a?(SpiffyStoresAPI::Store)
|
26
|
+
assert_equal "Apple Computers", @store.name
|
27
|
+
assert_equal "apple.spiffystores.com", @store.spiffystores_domain
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_get_metafields_for_store
|
31
|
+
fake "metafields"
|
32
|
+
|
33
|
+
metafields = @store.metafields
|
34
|
+
|
35
|
+
assert_equal 2, metafields.length
|
36
|
+
assert metafields.all?{|m| m.is_a?(SpiffyStoresAPI::Metafield)}
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_add_metafield
|
40
|
+
fake "metafields", :method => :post, :status => 201, :body =>load_fixture('metafield')
|
41
|
+
|
42
|
+
field = @store.add_metafield(SpiffyStoresAPI::Metafield.new(:namespace => "contact", :key => "email", :value => "123@example.com", :value_type => "string"))
|
43
|
+
assert_equal ActiveSupport::JSON.decode('{"metafield":{"namespace":"contact","key":"email","value":"123@example.com","value_type":"string"}}'), ActiveSupport::JSON.decode(FakeWeb.last_request.body)
|
44
|
+
assert !field.new_record?
|
45
|
+
assert_equal "contact", field.namespace
|
46
|
+
assert_equal "email", field.key
|
47
|
+
assert_equal "123@example.com", field.value
|
48
|
+
end
|
49
|
+
|
50
|
+
# def test_events
|
51
|
+
# fake "events"
|
52
|
+
#
|
53
|
+
# events = @store.events
|
54
|
+
#
|
55
|
+
# assert_equal 3, events.length
|
56
|
+
# assert events.all?{|m| m.is_a?(SpiffyStoresAPI::Event)}
|
57
|
+
# end
|
58
|
+
end
|