locomotivecms_coal 1.0.0.pre.alpha

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +1 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +8 -0
  5. data/Gemfile +23 -0
  6. data/Gemfile.lock +104 -0
  7. data/LICENSE +20 -0
  8. data/README.md +92 -0
  9. data/Rakefile +24 -0
  10. data/lib/locomotive/coal/client.rb +53 -0
  11. data/lib/locomotive/coal/error.rb +27 -0
  12. data/lib/locomotive/coal/paginated_resources.rb +20 -0
  13. data/lib/locomotive/coal/request.rb +63 -0
  14. data/lib/locomotive/coal/resource.rb +21 -0
  15. data/lib/locomotive/coal/resources/content_entries.rb +35 -0
  16. data/lib/locomotive/coal/resources/contents.rb +25 -0
  17. data/lib/locomotive/coal/resources/my_account.rb +15 -0
  18. data/lib/locomotive/coal/resources/sites.rb +31 -0
  19. data/lib/locomotive/coal/resources/token.rb +15 -0
  20. data/lib/locomotive/coal/version.rb +8 -0
  21. data/lib/locomotive/coal.rb +16 -0
  22. data/locomotivecms_coal.gemspec +26 -0
  23. data/spec/fixtures/coal_cassettes/client.yml +144 -0
  24. data/spec/fixtures/coal_cassettes/content_entries.yml +386 -0
  25. data/spec/fixtures/coal_cassettes/contents.yml +120 -0
  26. data/spec/fixtures/coal_cassettes/my_account.yml +97 -0
  27. data/spec/fixtures/coal_cassettes/sites.yml +204 -0
  28. data/spec/fixtures/coal_cassettes/token.yml +99 -0
  29. data/spec/integration/client_spec.rb +33 -0
  30. data/spec/integration/resources/content_entries_spec.rb +52 -0
  31. data/spec/integration/resources/contents_spec.rb +22 -0
  32. data/spec/integration/resources/my_account_spec.rb +17 -0
  33. data/spec/integration/resources/sites_spec.rb +43 -0
  34. data/spec/integration/resources/token_spec.rb +38 -0
  35. data/spec/spec_helper.rb +46 -0
  36. data/spec/support/api_settings.rb +6 -0
  37. data/spec/support/default_resources.rb +7 -0
  38. data/spec/support/pry.rb +4 -0
  39. data/spec/unit/client_spec.rb +25 -0
  40. data/spec/unit/paginated_resources_spec.rb +50 -0
  41. data/spec/unit/resource_spec.rb +18 -0
  42. metadata +159 -0
@@ -0,0 +1,120 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://sample.lvh.me:4000/locomotive/api/tokens.json
6
+ body:
7
+ encoding: US-ASCII
8
+ string: email=john%40doe.net&password=easyone
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ Accept-Encoding:
13
+ - gzip
14
+ User-Agent:
15
+ - unirest-ruby/1.1
16
+ Content-Length:
17
+ - '37'
18
+ Content-Type:
19
+ - application/x-www-form-urlencoded
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Date:
26
+ - Thu, 26 Mar 2015 12:13:40 GMT
27
+ Status:
28
+ - 200 OK
29
+ Connection:
30
+ - close
31
+ Location:
32
+ - http://sample.lvh.me:4000/locomotive/
33
+ Content-Type:
34
+ - application/json; charset=utf-8
35
+ X-Ua-Compatible:
36
+ - IE=Edge
37
+ Etag:
38
+ - '"557f8d72cf11ab5399621eddec942c29"'
39
+ Cache-Control:
40
+ - max-age=0, private, must-revalidate
41
+ Set-Cookie:
42
+ - _locomotive_session=KiLaEKykMgXNNfD6itS7bVfmjss; domain=.sample.lvh.me; path=/;
43
+ HttpOnly
44
+ X-Request-Id:
45
+ - 8a693be630caf70d8a7ecfbebc0b4c9e
46
+ X-Runtime:
47
+ - '0.023604'
48
+ body:
49
+ encoding: UTF-8
50
+ string: '{"token":"9GLRWwc2MGTCF7SHiZSg"}'
51
+ http_version:
52
+ recorded_at: Thu, 26 Mar 2015 12:13:40 GMT
53
+ - request:
54
+ method: get
55
+ uri: http://sample.lvh.me:4000/locomotive/api/content_types.json?auth_token=9GLRWwc2MGTCF7SHiZSg
56
+ body:
57
+ encoding: US-ASCII
58
+ string: ''
59
+ headers:
60
+ Accept:
61
+ - application/json
62
+ Accept-Encoding:
63
+ - gzip
64
+ User-Agent:
65
+ - unirest-ruby/1.1
66
+ response:
67
+ status:
68
+ code: 200
69
+ message: OK
70
+ headers:
71
+ Date:
72
+ - Thu, 26 Mar 2015 12:13:40 GMT
73
+ Status:
74
+ - 200 OK
75
+ Connection:
76
+ - close
77
+ Content-Type:
78
+ - application/json; charset=utf-8
79
+ X-Ua-Compatible:
80
+ - IE=Edge
81
+ Etag:
82
+ - '"7dbb8592219d2f208083b29864ef8522"'
83
+ Cache-Control:
84
+ - max-age=0, private, must-revalidate
85
+ Set-Cookie:
86
+ - _locomotive_session=F8r7t2KiM9Y_08jfTgR3-2_uWeg; domain=.sample.lvh.me; path=/;
87
+ HttpOnly
88
+ X-Request-Id:
89
+ - c5995e9d19527d56c352a1894b74baf7
90
+ X-Runtime:
91
+ - '0.069300'
92
+ body:
93
+ encoding: UTF-8
94
+ string: '[{"id":"54eb4b662475804b2b00000a","_id":"54eb4b662475804b2b00000a","created_at":"2015-02-23T15:46:46Z","updated_at":"2015-02-23T15:46:47Z","name":"Bands","slug":"bands","entries_custom_fields":[{"id":"54eb4b662475804b2b00000b","_id":"54eb4b662475804b2b00000b","name":"name","label":"Name","type":"string","required":true,"localized":false,"unique":false,"hint":"Name
95
+ of the band","position":0},{"id":"54eb4b662475804b2b00000c","_id":"54eb4b662475804b2b00000c","name":"leader","label":"Fullname
96
+ of the leader","type":"string","required":false,"localized":false,"unique":false,"position":1},{"id":"54eb4b662475804b2b00000d","_id":"54eb4b662475804b2b00000d","name":"kind","label":"Music
97
+ kind (grunge, rock, pop, country)","type":"select","required":false,"localized":false,"unique":false,"position":2,"select_options":[{"_id":"54eb4b662475804b2b00000f","name":"grunge","position":0,"id":"54eb4b662475804b2b00000f"},{"_id":"54eb4b662475804b2b000010","name":"rock","position":1,"id":"54eb4b662475804b2b000010"},{"_id":"54eb4b662475804b2b000011","name":"country","position":2,"id":"54eb4b662475804b2b000011"}],"raw_select_options":[{"id":"54eb4b662475804b2b00000f","name":{"en":"grunge"},"position":2},{"id":"54eb4b662475804b2b000010","name":{"en":"rock"},"position":2},{"id":"54eb4b662475804b2b000011","name":{"en":"country"},"position":2}]},{"id":"54eb4b662475804b2b00002d","_id":"54eb4b662475804b2b00002d","name":"songs","label":"Songs","type":"has_many","required":false,"localized":false,"unique":false,"position":3,"class_name":"Locomotive::ContentEntry54eb4b662475804b2b00001e","inverse_of":"band","ui_enabled":true,"class_slug":"songs"},{"id":"54eb4b662475804b2b00000e","_id":"54eb4b662475804b2b00000e","name":"featured","label":"Featured","type":"boolean","required":false,"localized":false,"unique":false,"position":4}],"description":"List
98
+ of bands","label_field_name":"name","order_by":"54eb4b662475804b2b00000b","order_direction":"asc","order_by_field_name":"name","public_submission_enabled":false,"public_submission_account_emails":[]},{"id":"54eb4bb52475804b2b000037","_id":"54eb4bb52475804b2b000037","created_at":"2015-02-23T15:48:05Z","updated_at":"2015-02-23T15:48:05Z","name":"Events","slug":"events","entries_custom_fields":[{"id":"54eb4bb52475804b2b000038","_id":"54eb4bb52475804b2b000038","name":"place","label":"Place","type":"string","required":true,"localized":false,"unique":false,"hint":"Name
99
+ of the place","position":0},{"id":"54eb4bb52475804b2b000039","_id":"54eb4bb52475804b2b000039","name":"date","label":"Date","type":"date","required":false,"localized":false,"unique":false,"hint":"Date
100
+ of the event","position":1},{"id":"54eb4bb52475804b2b00003a","_id":"54eb4bb52475804b2b00003a","name":"city","label":"City
101
+ of the event","type":"string","required":false,"localized":false,"unique":false,"position":2},{"id":"54eb4bb52475804b2b00003b","_id":"54eb4bb52475804b2b00003b","name":"state","label":"State
102
+ of the event","type":"string","required":false,"localized":false,"unique":false,"position":3},{"id":"54eb4bb52475804b2b00003c","_id":"54eb4bb52475804b2b00003c","name":"notes","label":"Notes","type":"text","required":false,"localized":false,"unique":false,"position":4,"text_formatting":""},{"id":"54eb4bb52475804b2b00003d","_id":"54eb4bb52475804b2b00003d","name":"tags","label":"List
103
+ of tags","type":"tags","required":false,"localized":false,"unique":false,"position":5},{"id":"54eb4bb52475804b2b00003e","_id":"54eb4bb52475804b2b00003e","name":"price","label":"Price
104
+ of the event","type":"float","required":false,"localized":false,"unique":false,"position":6}],"description":"List
105
+ of upcoming events","label_field_name":"place","order_by":"created_at","order_direction":"asc","order_by_field_name":"created_at","public_submission_enabled":false,"public_submission_account_emails":[]},{"id":"54eb4b662475804b2b00001a","_id":"54eb4b662475804b2b00001a","created_at":"2015-02-23T15:46:46Z","updated_at":"2015-02-23T15:46:46Z","name":"Messages","slug":"messages","entries_custom_fields":[{"id":"54eb4b662475804b2b00001b","_id":"54eb4b662475804b2b00001b","name":"name","label":"Name","type":"string","required":true,"localized":false,"unique":false,"hint":"Full
106
+ name","position":0},{"id":"54eb4b662475804b2b00001c","_id":"54eb4b662475804b2b00001c","name":"email","label":"Email","type":"string","required":true,"localized":false,"unique":false,"hint":"Email","position":1},{"id":"54eb4b662475804b2b00001d","_id":"54eb4b662475804b2b00001d","name":"message","label":"Message","type":"text","required":true,"localized":false,"unique":false,"hint":"Customer
107
+ message","position":2,"text_formatting":""}],"description":"Messages posted
108
+ by new potential customers","label_field_name":"name","order_by":"created_at","order_direction":"asc","order_by_field_name":"created_at","public_submission_enabled":true,"public_submission_account_emails":[]},{"id":"54eb4b662475804b2b00001e","_id":"54eb4b662475804b2b00001e","created_at":"2015-02-23T15:46:46Z","updated_at":"2015-02-23T15:46:47Z","name":"Songs","slug":"songs","entries_custom_fields":[{"id":"54eb4b662475804b2b00001f","_id":"54eb4b662475804b2b00001f","name":"title","label":"Title","type":"string","required":true,"localized":false,"unique":false,"hint":"Title
109
+ of your song","position":0},{"id":"54eb4b672475804b2b00002e","_id":"54eb4b672475804b2b00002e","name":"band","label":"Band","type":"belongs_to","required":false,"localized":false,"unique":false,"position":1,"class_name":"Locomotive::ContentEntry54eb4b662475804b2b00000a","ui_enabled":true,"class_slug":"bands"},{"id":"54eb4b662475804b2b000020","_id":"54eb4b662475804b2b000020","name":"cover","label":"Cover","type":"file","required":true,"localized":false,"unique":false,"position":2},{"id":"54eb4b662475804b2b000021","_id":"54eb4b662475804b2b000021","name":"short_description","label":"Short
110
+ description","type":"text","required":false,"localized":false,"unique":false,"position":3,"text_formatting":"html"},{"id":"54eb4b662475804b2b000022","_id":"54eb4b662475804b2b000022","name":"audio_url","label":"Audio
111
+ url","type":"string","required":false,"localized":false,"unique":false,"hint":"Url
112
+ to a service like Blip for instance","position":4},{"id":"54eb4b662475804b2b000023","_id":"54eb4b662475804b2b000023","name":"duration","label":"Duration","type":"string","required":false,"localized":false,"unique":false,"hint":"format
113
+ like: mm:ss","position":5}],"label_field_name":"title","order_by":"_position","order_direction":"asc","order_by_field_name":"_position","public_submission_enabled":false,"public_submission_account_emails":[]},{"id":"54eb4b662475804b2b000024","_id":"54eb4b662475804b2b000024","created_at":"2015-02-23T15:46:46Z","updated_at":"2015-02-23T15:46:46Z","name":"Updates","slug":"updates","entries_custom_fields":[{"id":"54eb4b662475804b2b000025","_id":"54eb4b662475804b2b000025","name":"title","label":"Title","type":"string","required":true,"localized":true,"unique":false,"hint":"Not
114
+ displayed in the website","position":0},{"id":"54eb4b662475804b2b000026","_id":"54eb4b662475804b2b000026","name":"text","label":"Text","type":"text","required":false,"localized":true,"unique":false,"hint":"Text
115
+ displayed in the home page","position":1,"text_formatting":"html"},{"id":"54eb4b662475804b2b000027","_id":"54eb4b662475804b2b000027","name":"category","label":"Category","type":"select","required":false,"localized":true,"unique":false,"hint":"Pick
116
+ a category","position":2,"select_options":[{"_id":"54eb4b662475804b2b000029","name":"General","position":0,"id":"54eb4b662475804b2b000029"},{"_id":"54eb4b662475804b2b00002a","name":"Gigs","position":1,"id":"54eb4b662475804b2b00002a"},{"_id":"54eb4b662475804b2b00002b","name":"Bands","position":2,"id":"54eb4b662475804b2b00002b"},{"_id":"54eb4b662475804b2b00002c","name":"Albums","position":3,"id":"54eb4b662475804b2b00002c"}],"raw_select_options":[{"id":"54eb4b662475804b2b000029","name":{"en":"General","fr":"G\u00e9n\u00e9ral"},"position":2},{"id":"54eb4b662475804b2b00002a","name":{"en":"Gigs","fr":"Concerts"},"position":2},{"id":"54eb4b662475804b2b00002b","name":{"en":"Bands","fr":"Groupes"},"position":2},{"id":"54eb4b662475804b2b00002c","name":{"en":"Albums"},"position":2}]},{"id":"54eb4b662475804b2b000028","_id":"54eb4b662475804b2b000028","name":"date","label":"Date","type":"date","required":false,"localized":false,"unique":false,"hint":"Date
117
+ of the update","position":3}],"description":"List of updates","label_field_name":"title","order_by":"54eb4b662475804b2b000028","order_direction":"asc","order_by_field_name":"date","public_submission_enabled":false,"public_submission_account_emails":[]}]'
118
+ http_version:
119
+ recorded_at: Thu, 26 Mar 2015 12:13:40 GMT
120
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,97 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://sample.lvh.me:4000/locomotive/api/tokens.json
6
+ body:
7
+ encoding: US-ASCII
8
+ string: email=john%40doe.net&password=easyone
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ Accept-Encoding:
13
+ - gzip
14
+ User-Agent:
15
+ - unirest-ruby/1.1
16
+ Content-Length:
17
+ - '37'
18
+ Content-Type:
19
+ - application/x-www-form-urlencoded
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Date:
26
+ - Thu, 26 Mar 2015 12:13:39 GMT
27
+ Status:
28
+ - 200 OK
29
+ Connection:
30
+ - close
31
+ Location:
32
+ - http://sample.lvh.me:4000/locomotive/
33
+ Content-Type:
34
+ - application/json; charset=utf-8
35
+ X-Ua-Compatible:
36
+ - IE=Edge
37
+ Etag:
38
+ - '"557f8d72cf11ab5399621eddec942c29"'
39
+ Cache-Control:
40
+ - max-age=0, private, must-revalidate
41
+ Set-Cookie:
42
+ - _locomotive_session=zUUHIKNc-a1-wegiBJYzxJOIcRE; domain=.sample.lvh.me; path=/;
43
+ HttpOnly
44
+ X-Request-Id:
45
+ - 061a5e57ccbb534f01f7042ad71bf80b
46
+ X-Runtime:
47
+ - '0.030627'
48
+ body:
49
+ encoding: UTF-8
50
+ string: '{"token":"9GLRWwc2MGTCF7SHiZSg"}'
51
+ http_version:
52
+ recorded_at: Thu, 26 Mar 2015 12:13:39 GMT
53
+ - request:
54
+ method: get
55
+ uri: http://sample.lvh.me:4000/locomotive/api/my_account.json?auth_token=9GLRWwc2MGTCF7SHiZSg
56
+ body:
57
+ encoding: US-ASCII
58
+ string: ''
59
+ headers:
60
+ Accept:
61
+ - application/json
62
+ Accept-Encoding:
63
+ - gzip
64
+ User-Agent:
65
+ - unirest-ruby/1.1
66
+ response:
67
+ status:
68
+ code: 200
69
+ message: OK
70
+ headers:
71
+ Date:
72
+ - Thu, 26 Mar 2015 12:13:40 GMT
73
+ Status:
74
+ - 200 OK
75
+ Connection:
76
+ - close
77
+ Content-Type:
78
+ - application/json; charset=utf-8
79
+ X-Ua-Compatible:
80
+ - IE=Edge
81
+ Etag:
82
+ - '"5286c0fcb45b4f01085a8ad3b0271bca"'
83
+ Cache-Control:
84
+ - max-age=0, private, must-revalidate
85
+ Set-Cookie:
86
+ - _locomotive_session=foIjGgvG1z2IMoxADAVRxAVoqnI; domain=.sample.lvh.me; path=/;
87
+ HttpOnly
88
+ X-Request-Id:
89
+ - e1a73f86678857cf095ff20bf64bb298
90
+ X-Runtime:
91
+ - '0.031958'
92
+ body:
93
+ encoding: UTF-8
94
+ string: '{"id":"54eb49b22475804b2b000001","_id":"54eb49b22475804b2b000001","created_at":"2015-02-23T15:39:30Z","updated_at":"2015-03-26T12:13:39Z","name":"John","email":"john@doe.net","locale":"en","encrypted_password":"fc2fa5bc736ba0f4ab04c4e427660f7a4fd7a360","password_salt":"ccEcFveptwhvSoRoExkX","api_key":"a9ac1e08c2c22c1b6f3da6db77a70cac4a615bd7","admin":true}'
95
+ http_version:
96
+ recorded_at: Thu, 26 Mar 2015 12:13:40 GMT
97
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,204 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://sample.lvh.me:4000/locomotive/api/tokens.json
6
+ body:
7
+ encoding: US-ASCII
8
+ string: email=john%40doe.net&password=easyone
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ Accept-Encoding:
13
+ - gzip
14
+ User-Agent:
15
+ - unirest-ruby/1.1
16
+ Content-Length:
17
+ - '37'
18
+ Content-Type:
19
+ - application/x-www-form-urlencoded
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Date:
26
+ - Thu, 26 Mar 2015 12:13:39 GMT
27
+ Status:
28
+ - 200 OK
29
+ Connection:
30
+ - close
31
+ Location:
32
+ - http://sample.lvh.me:4000/locomotive/
33
+ Content-Type:
34
+ - application/json; charset=utf-8
35
+ X-Ua-Compatible:
36
+ - IE=Edge
37
+ Etag:
38
+ - '"557f8d72cf11ab5399621eddec942c29"'
39
+ Cache-Control:
40
+ - max-age=0, private, must-revalidate
41
+ Set-Cookie:
42
+ - _locomotive_session=VquoZyFjWuRKNtfa4Qz8Ow1atCk; domain=.sample.lvh.me; path=/;
43
+ HttpOnly
44
+ X-Request-Id:
45
+ - adbf7f3b2ff1d55b0ab474625d878ddc
46
+ X-Runtime:
47
+ - '0.030411'
48
+ body:
49
+ encoding: UTF-8
50
+ string: '{"token":"9GLRWwc2MGTCF7SHiZSg"}'
51
+ http_version:
52
+ recorded_at: Thu, 26 Mar 2015 12:13:39 GMT
53
+ - request:
54
+ method: get
55
+ uri: http://sample.lvh.me:4000/locomotive/api/sites.json?auth_token=9GLRWwc2MGTCF7SHiZSg
56
+ body:
57
+ encoding: US-ASCII
58
+ string: ''
59
+ headers:
60
+ Accept:
61
+ - application/json
62
+ Accept-Encoding:
63
+ - gzip
64
+ User-Agent:
65
+ - unirest-ruby/1.1
66
+ response:
67
+ status:
68
+ code: 200
69
+ message: OK
70
+ headers:
71
+ Date:
72
+ - Thu, 26 Mar 2015 12:13:39 GMT
73
+ Status:
74
+ - 200 OK
75
+ Connection:
76
+ - close
77
+ Content-Type:
78
+ - application/json; charset=utf-8
79
+ X-Ua-Compatible:
80
+ - IE=Edge
81
+ Etag:
82
+ - '"81f71ce948be7560bc720c4e05d4c8d8"'
83
+ Cache-Control:
84
+ - max-age=0, private, must-revalidate
85
+ Set-Cookie:
86
+ - _locomotive_session=E_E0wjZoHg6guMeaGEFc_IYQ0Q8; domain=.sample.lvh.me; path=/;
87
+ HttpOnly
88
+ X-Request-Id:
89
+ - e972f9729360fa3c30e593df4b3daca0
90
+ X-Runtime:
91
+ - '0.052358'
92
+ body:
93
+ encoding: UTF-8
94
+ string: '[{"id":"54eb49c12475804b2b000002","_id":"54eb49c12475804b2b000002","created_at":"2015-02-23T15:39:45Z","updated_at":"2015-02-23T15:46:46Z","name":"Sample
95
+ website","locales":["en","fr","nb"],"timezone":"UTC","subdomain":"sample","domains":["example.org","sample.example.com","sample.lvh.me"],"domains_without_subdomain":["example.org","sample.example.com"],"domain_name":"lvh.me","memberships":[{"id":"54eb49c12475804b2b000003","_id":"54eb49c12475804b2b000003","role":"admin","role_name":"Administrator","can_update":false,"grant_admin":true,"account_id":"54eb49b22475804b2b000001","name":"John","email":"john@doe.net"}],"seo_title":"A
96
+ simple LocomotiveCMS website","meta_keywords":"some meta keywords","meta_description":"some
97
+ meta description"}]'
98
+ http_version:
99
+ recorded_at: Thu, 26 Mar 2015 12:13:39 GMT
100
+ - request:
101
+ method: post
102
+ uri: http://sample.lvh.me:4000/locomotive/api/sites.json
103
+ body:
104
+ encoding: US-ASCII
105
+ string: site[name]=Acme&site[subdomain]=acme&site[locales][]=en&auth_token=9GLRWwc2MGTCF7SHiZSg
106
+ headers:
107
+ Accept:
108
+ - application/json
109
+ Accept-Encoding:
110
+ - gzip
111
+ User-Agent:
112
+ - unirest-ruby/1.1
113
+ Content-Length:
114
+ - '87'
115
+ Content-Type:
116
+ - application/x-www-form-urlencoded
117
+ response:
118
+ status:
119
+ code: 200
120
+ message: OK
121
+ headers:
122
+ Date:
123
+ - Thu, 26 Mar 2015 12:13:39 GMT
124
+ Status:
125
+ - 200 OK
126
+ Connection:
127
+ - close
128
+ Location:
129
+ - http://sample.lvh.me:4000/locomotive/sites/5513f7f3c36511aa6a000001
130
+ Content-Type:
131
+ - application/json; charset=utf-8
132
+ X-Ua-Compatible:
133
+ - IE=Edge
134
+ Etag:
135
+ - '"586b513cca532ff623cbcba87ab3f8ef"'
136
+ Cache-Control:
137
+ - max-age=0, private, must-revalidate
138
+ Set-Cookie:
139
+ - _locomotive_session=j7Fc1aPj5ncc_5vthK1b94dOF3M; domain=.sample.lvh.me; path=/;
140
+ HttpOnly
141
+ X-Request-Id:
142
+ - 09b96eabaf1c19e21637ad5623b2c751
143
+ X-Runtime:
144
+ - '0.136287'
145
+ body:
146
+ encoding: UTF-8
147
+ string: '{"id":"5513f7f3c36511aa6a000001","_id":"5513f7f3c36511aa6a000001","created_at":"2015-03-26T12:13:39Z","updated_at":"2015-03-26T12:13:39Z","name":"Acme","locales":["en"],"timezone":"UTC","subdomain":"acme","domains":["acme.lvh.me"],"domains_without_subdomain":[],"domain_name":"lvh.me","memberships":[{"id":"5513f7f3c36511aa6a000002","_id":"5513f7f3c36511aa6a000002","role":"admin","role_name":"Administrator","can_update":false,"grant_admin":true,"account_id":"54eb49b22475804b2b000001","name":"John","email":"john@doe.net"}]}'
148
+ http_version:
149
+ recorded_at: Thu, 26 Mar 2015 12:13:39 GMT
150
+ - request:
151
+ method: delete
152
+ uri: http://sample.lvh.me:4000/locomotive/api/sites/5513f7f3c36511aa6a000001.json
153
+ body:
154
+ encoding: US-ASCII
155
+ string: auth_token=9GLRWwc2MGTCF7SHiZSg
156
+ headers:
157
+ Accept:
158
+ - application/json
159
+ Accept-Encoding:
160
+ - gzip
161
+ User-Agent:
162
+ - unirest-ruby/1.1
163
+ Content-Length:
164
+ - '31'
165
+ Content-Type:
166
+ - application/x-www-form-urlencoded
167
+ response:
168
+ status:
169
+ code: 200
170
+ message: OK
171
+ headers:
172
+ Date:
173
+ - Thu, 26 Mar 2015 12:13:39 GMT
174
+ Status:
175
+ - 200 OK
176
+ Connection:
177
+ - close
178
+ X-Message:
179
+ - '"Site%20was%20successfully%20destroyed."'
180
+ X-Message-Type:
181
+ - notice
182
+ Location:
183
+ - http://sample.lvh.me:4000/locomotive/sites
184
+ Content-Type:
185
+ - application/json; charset=utf-8
186
+ X-Ua-Compatible:
187
+ - IE=Edge
188
+ Etag:
189
+ - '"27caa7b4e34cff2c964ef6a71e74238e"'
190
+ Cache-Control:
191
+ - max-age=0, private, must-revalidate
192
+ Set-Cookie:
193
+ - _locomotive_session=nC_FJh22VAjBWzBkUYv1KxMkBYw; domain=.sample.lvh.me; path=/;
194
+ HttpOnly
195
+ X-Request-Id:
196
+ - 02fc4cae8563ecd906e7e1135e4de00f
197
+ X-Runtime:
198
+ - '0.126953'
199
+ body:
200
+ encoding: UTF-8
201
+ string: '{"id":null,"_id":null,"created_at":"2015-03-26T12:13:39Z","updated_at":"2015-03-26T12:13:39Z","name":"Acme","locales":["en"],"timezone":"UTC","subdomain":"acme","domains":["acme.lvh.me"],"domains_without_subdomain":[],"domain_name":"lvh.me","memberships":[{"id":"5513f7f3c36511aa6a000002","_id":"5513f7f3c36511aa6a000002","role":"admin","role_name":"Administrator","can_update":false,"grant_admin":true,"account_id":"54eb49b22475804b2b000001","name":"John","email":"john@doe.net"}]}'
202
+ http_version:
203
+ recorded_at: Thu, 26 Mar 2015 12:13:39 GMT
204
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,99 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://sample.lvh.me:4000/locomotive/api/tokens.json
6
+ body:
7
+ encoding: US-ASCII
8
+ string: email=john%40doe.net&api_key=a9ac1e08c2c22c1b6f3da6db77a70cac4a615bd7
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ Accept-Encoding:
13
+ - gzip
14
+ User-Agent:
15
+ - unirest-ruby/1.1
16
+ Content-Length:
17
+ - '69'
18
+ Content-Type:
19
+ - application/x-www-form-urlencoded
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Date:
26
+ - Thu, 26 Mar 2015 12:13:40 GMT
27
+ Status:
28
+ - 200 OK
29
+ Connection:
30
+ - close
31
+ Location:
32
+ - http://sample.lvh.me:4000/locomotive/
33
+ Content-Type:
34
+ - application/json; charset=utf-8
35
+ X-Ua-Compatible:
36
+ - IE=Edge
37
+ Etag:
38
+ - '"557f8d72cf11ab5399621eddec942c29"'
39
+ Cache-Control:
40
+ - max-age=0, private, must-revalidate
41
+ Set-Cookie:
42
+ - _locomotive_session=ZfTEg0ye8LoQiqsY_foUHZgeq-Y; domain=.sample.lvh.me; path=/;
43
+ HttpOnly
44
+ X-Request-Id:
45
+ - aa8e451806483825688c95a101e8c297
46
+ X-Runtime:
47
+ - '0.025094'
48
+ body:
49
+ encoding: UTF-8
50
+ string: '{"token":"9GLRWwc2MGTCF7SHiZSg"}'
51
+ http_version:
52
+ recorded_at: Thu, 26 Mar 2015 12:13:40 GMT
53
+ - request:
54
+ method: post
55
+ uri: http://www.example.com:4000/tokens.json
56
+ body:
57
+ encoding: US-ASCII
58
+ string: email=john%40doe.net&password=easyone
59
+ headers:
60
+ Accept:
61
+ - application/json
62
+ Accept-Encoding:
63
+ - gzip
64
+ User-Agent:
65
+ - unirest-ruby/1.1
66
+ Content-Length:
67
+ - '37'
68
+ Content-Type:
69
+ - application/x-www-form-urlencoded
70
+ response:
71
+ status:
72
+ code: 404
73
+ message: Not Found
74
+ headers:
75
+ Date:
76
+ - Thu, 26 Mar 2015 12:13:40 GMT
77
+ Status:
78
+ - 404 Not Found
79
+ Connection:
80
+ - close
81
+ Content-Type:
82
+ - application/json; charset=utf-8
83
+ X-Ua-Compatible:
84
+ - IE=Edge
85
+ Cache-Control:
86
+ - no-cache
87
+ Set-Cookie:
88
+ - _locomotive_session=Bo_23Fg-epuS-CvNzKWRcQkKkFY; domain=.example.com; path=/;
89
+ HttpOnly
90
+ X-Request-Id:
91
+ - 5b9886b71e43a1a2691b92681b4101d5
92
+ X-Runtime:
93
+ - '0.046065'
94
+ body:
95
+ encoding: UTF-8
96
+ string: '{"error":"No site found"}'
97
+ http_version:
98
+ recorded_at: Thu, 26 Mar 2015 12:13:40 GMT
99
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ describe Locomotive::Coal::Client do
4
+
5
+ before { VCR.insert_cassette 'client', record: :new_episodes }
6
+ after { VCR.eject_cassette }
7
+
8
+ let(:uri) { 'http://sample.lvh.me:4000/locomotive/api' }
9
+ let(:credentials) { { email: 'john@doe.net', password: 'easyone' } }
10
+ let(:client) { described_class.new(uri, credentials) }
11
+
12
+ describe '#my_token' do
13
+ subject { client.token }
14
+ it { is_expected.not_to eq nil }
15
+ end
16
+
17
+ describe '#my_account' do
18
+ subject { client.my_account.get.name }
19
+ it { is_expected.not_to eq nil }
20
+ end
21
+
22
+ describe '#sites' do
23
+ subject { client.sites.all.first }
24
+ it { is_expected.not_to eq nil }
25
+ end
26
+
27
+ describe '#scope_by' do
28
+ let(:site) { client.sites.all.first }
29
+ subject { client.scope_by(site) }
30
+ it { is_expected.to eq client }
31
+ end
32
+
33
+ end
@@ -0,0 +1,52 @@
1
+ require 'spec_helper'
2
+
3
+ describe Locomotive::Coal::Resources::ContentEntries do
4
+
5
+ before { VCR.insert_cassette 'content_entries', record: :new_episodes }
6
+ after { VCR.eject_cassette }
7
+
8
+ let(:uri) { TEST_API_URI }
9
+ let(:token) { api_token }
10
+ let(:content_type) { Locomotive::Coal::Resources::Contents.new(uri, token).by_slug(:bands) }
11
+ let(:entries) { described_class.new(uri, token, content_type) }
12
+
13
+ describe '#all' do
14
+
15
+ let(:query) { {} }
16
+ let(:options) { {} }
17
+
18
+ subject { entries.all(query, options) }
19
+
20
+ it { expect(subject.size).not_to eq 0 }
21
+ it { expect(subject._total_pages).not_to eq 0 }
22
+ it { expect(subject._total_entries).not_to eq 0 }
23
+
24
+ describe 'pagination' do
25
+
26
+ let(:options) { { page: 2, per_page: 2 } }
27
+
28
+ it { expect(subject.size).not_to eq 0 }
29
+ it { expect(subject._total_pages).to be > 1 }
30
+ it { expect(subject._total_entries).to be > 1 }
31
+
32
+ end
33
+
34
+ describe 'filter' do
35
+
36
+ let(:query) { { _visible: true, name: 'Pearl Jam' } }
37
+
38
+ it { expect(subject.size).to eq 1 }
39
+
40
+ end
41
+ end
42
+
43
+ describe '#update' do
44
+
45
+ let(:entry) { entries.all.first }
46
+ subject { entries.update(entry._id, { name: 'Pearl Jam' }) }
47
+
48
+ it { expect(subject._id).to eq entry._id }
49
+
50
+ end
51
+
52
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe Locomotive::Coal::Resources::Contents do
4
+
5
+ before { VCR.insert_cassette 'contents', record: :new_episodes }
6
+ after { VCR.eject_cassette }
7
+
8
+ let(:uri) { TEST_API_URI }
9
+ let(:token) { api_token }
10
+ let(:contents) { described_class.new(uri, token) }
11
+
12
+ describe '#by_slug' do
13
+ subject { contents.by_slug(:bands) }
14
+ it { expect(subject).not_to eq nil }
15
+ end
16
+
17
+ describe '#method_missing' do
18
+ subject { contents.bands }
19
+ it { expect(subject).not_to eq nil }
20
+ end
21
+
22
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe Locomotive::Coal::Resources::MyAccount do
4
+
5
+ before { VCR.insert_cassette 'my_account', record: :new_episodes }
6
+ after { VCR.eject_cassette }
7
+
8
+ let(:uri) { TEST_API_URI }
9
+ let(:token) { api_token }
10
+ let(:my_account) { described_class.new(uri, token) }
11
+
12
+ describe '#get' do
13
+ subject { my_account.get }
14
+ it { expect(subject.name).not_to eq nil }
15
+ end
16
+
17
+ end