locomotivecms_coal 1.6.0 → 1.8.0.alpha1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -1
  3. data/README.md +3 -3
  4. data/lib/locomotive/coal/resources/concerns/request.rb +1 -1
  5. data/lib/locomotive/coal/version.rb +1 -1
  6. metadata +20 -123
  7. data/.gitignore +0 -4
  8. data/.rspec +0 -2
  9. data/.travis.yml +0 -8
  10. data/Gemfile +0 -21
  11. data/Gemfile.lock +0 -125
  12. data/Rakefile +0 -21
  13. data/locomotivecms_coal.gemspec +0 -27
  14. data/spec/fixtures/assets/locomotive.png +0 -0
  15. data/spec/fixtures/assets/rails.png +0 -0
  16. data/spec/fixtures/coal_cassettes/accounts.yml +0 -214
  17. data/spec/fixtures/coal_cassettes/client.yml +0 -479
  18. data/spec/fixtures/coal_cassettes/content_assets.yml +0 -270
  19. data/spec/fixtures/coal_cassettes/content_entries.yml +0 -2189
  20. data/spec/fixtures/coal_cassettes/content_types.yml +0 -726
  21. data/spec/fixtures/coal_cassettes/current_site.yml +0 -166
  22. data/spec/fixtures/coal_cassettes/memberships.yml +0 -270
  23. data/spec/fixtures/coal_cassettes/my_account.yml +0 -260
  24. data/spec/fixtures/coal_cassettes/pages.yml +0 -333
  25. data/spec/fixtures/coal_cassettes/sections.yml +0 -267
  26. data/spec/fixtures/coal_cassettes/sites.yml +0 -212
  27. data/spec/fixtures/coal_cassettes/snippets.yml +0 -269
  28. data/spec/fixtures/coal_cassettes/theme_assets.yml +0 -270
  29. data/spec/fixtures/coal_cassettes/token.yml +0 -103
  30. data/spec/fixtures/coal_cassettes/translations.yml +0 -267
  31. data/spec/fixtures/coal_cassettes/version.yml +0 -103
  32. data/spec/integration/client_spec.rb +0 -67
  33. data/spec/integration/resources/accounts_spec.rb +0 -38
  34. data/spec/integration/resources/content_assets_spec.rb +0 -42
  35. data/spec/integration/resources/content_entries_spec.rb +0 -97
  36. data/spec/integration/resources/content_types_spec.rb +0 -44
  37. data/spec/integration/resources/current_site_spec.rb +0 -22
  38. data/spec/integration/resources/engine_version_spec.rb +0 -17
  39. data/spec/integration/resources/memberships_spec.rb +0 -39
  40. data/spec/integration/resources/my_account_spec.rb +0 -34
  41. data/spec/integration/resources/pages_spec.rb +0 -43
  42. data/spec/integration/resources/sections_spec.rb +0 -46
  43. data/spec/integration/resources/sites_spec.rb +0 -43
  44. data/spec/integration/resources/snippets_spec.rb +0 -38
  45. data/spec/integration/resources/theme_assets_spec.rb +0 -43
  46. data/spec/integration/resources/token_spec.rb +0 -38
  47. data/spec/integration/resources/translations_spec.rb +0 -38
  48. data/spec/spec_helper.rb +0 -28
  49. data/spec/support/api_settings.rb +0 -10
  50. data/spec/support/assets.rb +0 -4
  51. data/spec/support/default_resources.rb +0 -7
  52. data/spec/support/pry.rb +0 -4
  53. data/spec/support/vcr.rb +0 -10
  54. data/spec/unit/client_spec.rb +0 -52
  55. data/spec/unit/client_v2_spec.rb +0 -22
  56. data/spec/unit/error_spec.rb +0 -36
  57. data/spec/unit/paginated_resources_spec.rb +0 -50
  58. data/spec/unit/resource_spec.rb +0 -29
@@ -1,103 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: post
5
- uri: http://localhost:3000/locomotive/api/v3/tokens.json
6
- body:
7
- encoding: UTF-8
8
- string: email=admin%40locomotivecms.com&password=locomotive
9
- headers:
10
- User-Agent:
11
- - Faraday v0.15.4
12
- Accept:
13
- - application/json
14
- Accept-Encoding:
15
- - gzip,deflate
16
- Date:
17
- - Sun, 17 Nov 2019 16:39:24 GMT
18
- Content-Type:
19
- - application/x-www-form-urlencoded
20
- response:
21
- status:
22
- code: 201
23
- message: Created
24
- headers:
25
- Content-Type:
26
- - application/json
27
- Content-Length:
28
- - '32'
29
- Connection:
30
- - keep-alive
31
- Status:
32
- - 201 Created
33
- Cache-Control:
34
- - max-age=0, private, must-revalidate
35
- Etag:
36
- - W/"410e3d6fde24f39257a7cc619b61baa7"
37
- X-Runtime:
38
- - '0.004813'
39
- X-Request-Id:
40
- - 4dbdd6ff-8e32-494e-a364-3c8f05ed4619
41
- Date:
42
- - Sun, 17 Nov 2019 16:39:24 GMT
43
- X-Powered-By:
44
- - Phusion Passenger 6.0.4
45
- Server:
46
- - nginx/1.17.3 + Phusion Passenger 6.0.4
47
- body:
48
- encoding: UTF-8
49
- string: '{"token":"bzwAyFQzcchf_hgDQhz3"}'
50
- http_version:
51
- recorded_at: Sun, 17 Nov 2019 16:39:24 GMT
52
- - request:
53
- method: get
54
- uri: http://localhost:3000/locomotive/sample/api/v3/version.json?auth_token=bzwAyFQzcchf_hgDQhz3&email=admin@locomotivecms.com&token=bzwAyFQzcchf_hgDQhz3
55
- body:
56
- encoding: UTF-8
57
- string: ''
58
- headers:
59
- User-Agent:
60
- - Faraday v0.15.4
61
- Accept:
62
- - application/json
63
- Accept-Encoding:
64
- - gzip,deflate
65
- Date:
66
- - Sun, 17 Nov 2019 16:39:24 GMT
67
- X-Locomotive-Account-Email:
68
- - admin@locomotivecms.com
69
- X-Locomotive-Account-Token:
70
- - bzwAyFQzcchf_hgDQhz3
71
- response:
72
- status:
73
- code: 200
74
- message: OK
75
- headers:
76
- Content-Type:
77
- - application/json
78
- Content-Length:
79
- - '22'
80
- Connection:
81
- - keep-alive
82
- Status:
83
- - 200 OK
84
- Cache-Control:
85
- - max-age=0, private, must-revalidate
86
- Etag:
87
- - W/"f981a5a7069dbbda33875006acb1b026"
88
- X-Runtime:
89
- - '0.006873'
90
- X-Request-Id:
91
- - 5a103059-2a24-401f-94ca-49c2e1c657a9
92
- Date:
93
- - Sun, 17 Nov 2019 16:39:24 GMT
94
- X-Powered-By:
95
- - Phusion Passenger 6.0.4
96
- Server:
97
- - nginx/1.17.3 + Phusion Passenger 6.0.4
98
- body:
99
- encoding: UTF-8
100
- string: '{"engine":"4.0.0.rc0"}'
101
- http_version:
102
- recorded_at: Sun, 17 Nov 2019 16:39:24 GMT
103
- recorded_with: VCR 4.0.0
@@ -1,67 +0,0 @@
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) { TEST_API_URI.dup }
9
- let(:credentials) { TEST_API_CREDENTIALS.dup }
10
- let(:options) { {} }
11
- let(:client) { described_class.new(uri, credentials, options) }
12
-
13
- describe '#my_token' do
14
- subject { client.token }
15
- it { is_expected.not_to eq nil }
16
- end
17
-
18
- describe '#my_account' do
19
- subject { client.my_account.get.name }
20
- it { is_expected.not_to eq nil }
21
- end
22
-
23
- describe '#engine_version' do
24
- subject { client.engine_version }
25
- it { is_expected.to match(/\A\d\..+/) }
26
- end
27
-
28
- describe '#version' do
29
- subject { client.version }
30
- it { is_expected.to match(/\A\d\..+/) }
31
- end
32
-
33
- describe '#sites' do
34
- subject { client.sites.all.first }
35
- it { is_expected.not_to eq nil }
36
- end
37
-
38
- context 'scoped by a site' do
39
-
40
- let(:options) { { handle: 'sample' } }
41
-
42
- describe '#snippets' do
43
- subject { client.snippets.all }
44
- it { is_expected.to eq [] }
45
- end
46
-
47
- describe '#translations' do
48
- subject { client.translations.all }
49
- it { is_expected.to eq [] }
50
- end
51
-
52
- describe '#theme_assets' do
53
- subject { client.theme_assets.all }
54
- it { is_expected.to eq [] }
55
- end
56
-
57
- end
58
-
59
- describe '#scope_by' do
60
- let(:uri) { 'http://www.example.com:3000/locomotive/api/v3' }
61
- let(:site) { client.sites.all.first }
62
- subject { client.scope_by(site) }
63
- it { is_expected.to eq client }
64
- it { expect(subject.options[:handle]).to eq 'www' }
65
- end
66
-
67
- end
@@ -1,38 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Locomotive::Coal::Resources::Accounts, order: :defined do
4
-
5
- before { VCR.insert_cassette 'accounts', record: :new_episodes }
6
- after { VCR.eject_cassette }
7
-
8
- let(:uri) { TEST_API_V3_URI }
9
- let(:credentials) { { email: TEST_API_EMAIL, token: api_token } }
10
- let(:accounts) { described_class.new(uri, credentials) }
11
-
12
- describe '#all' do
13
-
14
- subject { accounts.all }
15
- it { expect(subject.size).to be > 0 }
16
-
17
- describe 'first account' do
18
- subject { accounts.all }
19
- it { expect(subject.to_a.map { |a| a.name }).to include('New Admin', 'John Doe') }
20
- end
21
- end
22
-
23
- describe '#create' do
24
- subject { create_account }
25
- it { expect(subject._id).not_to eq nil }
26
- end
27
-
28
- describe '#destroy' do
29
- let(:new_account) { accounts.all.find { |a| a.email == 'jane@doe.net' } || create_account }
30
- subject { accounts.destroy(new_account._id) }
31
- it { expect(subject._id).not_to eq nil }
32
- end
33
-
34
- def create_account
35
- accounts.create(name: 'Jane', email: 'jane@doe.net', password: 'easyone', password_confirmation: 'easyone')
36
- end
37
-
38
- end
@@ -1,42 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Locomotive::Coal::Resources::ContentAssets, order: :defined do
4
-
5
- before { VCR.insert_cassette 'content_assets', record: :new_episodes }
6
- after { VCR.eject_cassette }
7
-
8
- let(:uri) { TEST_SITE_API_V3_URI }
9
- let(:credentials) { { email: TEST_API_EMAIL, token: api_token } }
10
- let(:content_assets) { described_class.new(uri, credentials) }
11
-
12
- describe '#all' do
13
- subject { content_assets.all }
14
- it { expect(subject).not_to eq nil }
15
- end
16
-
17
- describe '#create' do
18
- subject { create_content_asset }
19
- it { expect(subject._id).not_to eq nil }
20
- end
21
-
22
- describe '#update' do
23
- let(:content_asset) { single_content_asset || create_content_asset }
24
- subject { content_assets.update(content_asset._id, source: asset_io('locomotive.png')) }
25
- it { expect(subject.url).to match /locomotive.png$/ }
26
- end
27
-
28
- describe '#destroy' do
29
- let(:content_asset) { single_content_asset || create_content_asset }
30
- subject { content_assets.destroy(content_asset._id) }
31
- it { expect(subject._id).not_to eq nil }
32
- end
33
-
34
- def create_content_asset
35
- content_assets.create(source: asset_io('rails.png'))
36
- end
37
-
38
- def single_content_asset
39
- content_assets.all.detect { |a| a.url =~ /rails.png$/ }
40
- end
41
-
42
- end
@@ -1,97 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Locomotive::Coal::Resources::ContentEntries, order: :defined do
4
-
5
- before(:all) do
6
- VCR.insert_cassette 'content_entries', record: :new_episodes, match_requests_on: [:method, :query, :body]
7
- @content_type = build_content_types.create(name: 'Article', slug: 'articles', fields: [{ label: 'Title', name: 'title', type: 'string', localized: true }])
8
- end
9
-
10
- after(:all) do
11
- build_content_types.destroy(@content_type._id)
12
- VCR.eject_cassette
13
- end
14
-
15
- let(:uri) { TEST_SITE_API_V3_URI }
16
- let(:credentials) { { email: TEST_API_EMAIL, token: api_token } }
17
- let(:content_type) { @content_type }
18
- let(:entries) { described_class.new(uri, credentials, content_type) }
19
-
20
- describe '#all' do
21
-
22
- let(:query) { {} }
23
- let(:options) { {} }
24
-
25
- subject { entries.all(query, options) }
26
-
27
- before { entries.create(title: 'Hello world'); entries.create(title: 'Lorem ipsum') }
28
- after { ['hello-world', 'lorem-ipsum'].each { |slug| entries.destroy(slug) } }
29
-
30
- it 'returns a paginated list of entries' do
31
- expect(subject.size).to be >= 2
32
- expect(subject._total_pages).to eq 1
33
- expect(subject._total_entries).to be >= 2
34
- end
35
-
36
- it 'returns a list of entries without params' do
37
- subject { entries.all }
38
- expect(subject.size).to be >= 2
39
- expect(subject._total_pages).to eq 1
40
- expect(subject._total_entries).to be >= 2
41
- end
42
-
43
- describe 'pagination' do
44
-
45
- let(:options) { { page: 2, per_page: 1 } }
46
-
47
- it 'returns the second page of entries' do
48
- expect(subject.size).to eq 1
49
- expect(subject._total_pages).to be >= 2
50
- expect(subject._total_entries).to be >= 2
51
- end
52
-
53
- end
54
-
55
- describe 'filter' do
56
-
57
- let(:query) { { _visible: true, title: 'Hello world' } }
58
-
59
- it { expect(subject.size).to eq 1 }
60
-
61
- end
62
-
63
- end
64
-
65
- describe '#each' do
66
-
67
- subject { [].tap { |list| entries.each { |e| list << e } } }
68
-
69
- before { entries.create(title: 'Hello world'); entries.create(title: 'Lorem ipsum') }
70
- after { ['hello-world', 'lorem-ipsum'].each { |slug| entries.destroy(slug) } }
71
-
72
- it { expect(subject.size).to eq 2 }
73
-
74
- end
75
-
76
- describe '#update' do
77
-
78
- let(:entry) { entries.create(title: 'Random title') }
79
- subject { entries.update(entry._slug, { title: 'Random title!' }) }
80
-
81
- it { expect(subject.title).to eq 'Random title!' }
82
-
83
- describe 'with a localized content entry' do
84
-
85
- subject { entries.update(entry._id, { title: 'Titre au hasard' }, :fr) }
86
-
87
- it { expect(subject.title).to eq 'Titre au hasard' }
88
-
89
- end
90
-
91
- end
92
-
93
- def build_content_types
94
- Locomotive::Coal::Resources::ContentTypes.new(TEST_SITE_API_V3_URI, { email: TEST_API_EMAIL, token: api_token })
95
- end
96
-
97
- end
@@ -1,44 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Locomotive::Coal::Resources::ContentTypes, order: :defined do
4
-
5
- before(:all) { VCR.insert_cassette 'content_types', record: :new_episodes, match_requests_on: [:method, :query, :body] }
6
- after(:all) { VCR.eject_cassette }
7
-
8
- let(:uri) { TEST_SITE_API_V3_URI }
9
- let(:credentials) { { email: TEST_API_EMAIL, token: api_token } }
10
- let(:content_types) { described_class.new(uri, credentials) }
11
-
12
- describe '#all' do
13
- subject { content_types.all }
14
- it { expect(subject).not_to eq nil }
15
- end
16
-
17
- describe '#create' do
18
- subject { create_content_type }
19
- it { expect(subject._id).not_to eq nil }
20
- end
21
-
22
- describe '#update' do
23
- let(:content_type) { content_types.all.detect { |s| s.slug == 'projects' } || create_content_type }
24
- subject { content_types.update(content_type._id, name: 'Our projects') }
25
- it { expect(subject.name).to eq 'Our projects' }
26
- end
27
-
28
- describe '#destroy' do
29
- let(:content_type) { content_types.all.detect { |s| s.slug == 'projects' } || create_content_type }
30
- subject { content_types.destroy(content_type._id) }
31
- it { expect(subject._id).not_to eq nil }
32
- end
33
-
34
- describe '#by_slug' do
35
- before { content_types.all.detect { |s| s.slug == 'projects' } || create_content_type }
36
- subject { content_types.by_slug(:projects) }
37
- it { expect(subject).not_to eq nil }
38
- end
39
-
40
- def create_content_type
41
- content_types.create(name: 'Projects', slug: 'projects', fields: [{ label: 'Name', name: 'name', type: 'string' }])
42
- end
43
-
44
- end
@@ -1,22 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Locomotive::Coal::Resources::CurrentSite do
4
-
5
- before { VCR.insert_cassette 'current_site', record: :new_episodes, match_requests_on: [:method, :query, :body] }
6
- after { VCR.eject_cassette }
7
-
8
- let(:uri) { TEST_SITE_API_V3_URI }
9
- let(:credentials) { { email: TEST_API_EMAIL, token: api_token } }
10
- let(:resource) { described_class.new(uri, credentials) }
11
-
12
- describe '#get' do
13
- subject { resource.get }
14
- it { expect(subject.name).not_to eq nil }
15
- end
16
-
17
- describe '#update' do
18
- subject { resource.update(name: 'John Doe') }
19
- it { expect(subject._id).not_to eq nil }
20
- end
21
-
22
- end
@@ -1,17 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Locomotive::Coal::Resources::EngineVersion do
4
-
5
- before { VCR.insert_cassette 'version' }
6
- after { VCR.eject_cassette }
7
-
8
- let(:uri) { TEST_SITE_API_V3_URI }
9
- let(:credentials) { { email: TEST_API_EMAIL, token: api_token } }
10
- let(:engine_version) { described_class.new(uri, credentials) }
11
-
12
- describe '#version' do
13
- subject { engine_version.version }
14
- it { is_expected.to match(/\A\d\..+/) }
15
- end
16
-
17
- end
@@ -1,39 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Locomotive::Coal::Resources::Memberships, order: :defined do
4
-
5
- before { VCR.insert_cassette 'memberships', record: :new_episodes }
6
- after { VCR.eject_cassette }
7
-
8
- let(:uri) { TEST_SITE_API_V3_URI }
9
- let(:credentials) { { email: TEST_API_EMAIL, token: api_token } }
10
- let(:memberships) { described_class.new(uri, credentials) }
11
- let(:new_account_email) { 'new_admin@locomotivecms.com' }
12
-
13
- describe '#all' do
14
- subject { memberships.all }
15
- it { expect(subject).not_to eq nil }
16
- end
17
-
18
- describe '#create' do
19
- subject { create_membership }
20
- it { expect(subject._id).not_to eq nil }
21
- end
22
-
23
- describe '#update' do
24
- let(:membership) { memberships.all.detect { |s| s.email == new_account_email } || create_membership }
25
- subject { memberships.update(membership._id, role: 'author') }
26
- it { expect(subject.role).to eq 'author' }
27
- end
28
-
29
- describe '#destroy' do
30
- let(:membership) { memberships.all.detect { |s| s.email == new_account_email } || create_membership }
31
- subject { memberships.destroy(membership._id) }
32
- it { expect(subject._id).to_not eq nil }
33
- end
34
-
35
- def create_membership
36
- memberships.create(role: 'Admin', account_email: new_account_email)
37
- end
38
-
39
- end
@@ -1,34 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Locomotive::Coal::Resources::MyAccount do
4
-
5
- before { VCR.insert_cassette 'my_account', record: :new_episodes, match_requests_on: [:method, :query, :body] }
6
- after { VCR.eject_cassette }
7
-
8
- let(:uri) { TEST_API_V3_URI }
9
- let(:credentials) { { email: TEST_API_EMAIL, token: api_token } }
10
- let(:resource) { described_class.new(uri, credentials) }
11
-
12
- describe '#get' do
13
- subject { resource.get }
14
- it { expect(subject.name).not_to eq nil }
15
- end
16
-
17
- describe '#create' do
18
- let(:credentials) { nil }
19
- let(:attributes) { { name: 'Jack Doe', email: 'jack@doe.net', password: 'easyone', password_confirmation: 'easyone' } }
20
- subject { resource.create(attributes) }
21
- it { expect(subject._id).not_to eq nil }
22
-
23
- describe 'missing attributes' do
24
- let(:attributes) { { name: 'Wrong account' } }
25
- it { expect { subject }.to raise_error(Locomotive::Coal::InvalidResourceError, 'Resource invalid: email is missing, password is missing') }
26
- end
27
- end
28
-
29
- describe '#update' do
30
- subject { resource.update(name: 'John Doe') }
31
- it { expect(subject._id).not_to eq nil }
32
- end
33
-
34
- end
@@ -1,43 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Locomotive::Coal::Resources::Pages, order: :defined do
4
-
5
- before { VCR.insert_cassette 'pages', record: :new_episodes }
6
- after { VCR.eject_cassette }
7
-
8
- let(:uri) { TEST_SITE_API_V3_URI }
9
- let(:credentials) { { email: TEST_API_EMAIL, token: api_token } }
10
- let(:pages) { described_class.new(uri, credentials) }
11
-
12
- describe '#all' do
13
- subject { pages.all(:en) }
14
- it { expect(subject).not_to eq nil }
15
- end
16
-
17
- describe '#fullpaths' do
18
- subject { pages.fullpaths(:en) }
19
- it { expect(subject).not_to eq nil }
20
- end
21
-
22
- describe '#create' do
23
- subject { create_page }
24
- it { expect(subject._id).not_to eq nil }
25
- end
26
-
27
- describe '#update' do
28
- let(:page) { pages.all(:en).detect { |s| s.fullpath == 'about-us' } || create_page }
29
- subject { pages.update(page._id, { template: 'Locomotive rocks. period' }, :en) }
30
- it { expect(subject.template).to eq 'Locomotive rocks. period' }
31
- end
32
-
33
- describe '#destroy' do
34
- let(:page) { pages.all(:en).detect { |s| s.fullpath == 'about-us' } || create_page }
35
- subject { pages.destroy(page._id) }
36
- it { expect(subject._id).not_to eq nil }
37
- end
38
-
39
- def create_page
40
- pages.create(title: 'About us', slug: 'about-us', parent: 'index', template: 'Locomotive rocks!')
41
- end
42
-
43
- end
@@ -1,46 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Locomotive::Coal::Resources::Sections, order: :defined do
4
-
5
- before { VCR.insert_cassette 'sections', record: :new_episodes }
6
- after { VCR.eject_cassette }
7
-
8
- let(:uri) { TEST_SITE_API_V3_URI }
9
- let(:credentials) { { email: TEST_API_EMAIL, token: api_token } }
10
- let(:sections) { described_class.new(uri, credentials) }
11
-
12
- describe '#all' do
13
- subject { sections.all }
14
- it { expect(subject).not_to eq nil }
15
- end
16
-
17
- describe '#create' do
18
- subject { create_section }
19
- it { expect(subject._id).not_to eq nil }
20
- end
21
-
22
- describe '#update' do
23
- let(:section) { sections.all.detect { |s| s.slug == 'sidebar' } || create_section }
24
- subject { sections.update(section._id, template: 'Locomotive rocks. period') }
25
- it { expect(subject.template).to eq 'Locomotive rocks. period' }
26
- end
27
-
28
- describe '#destroy' do
29
- let(:section) { sections.all.detect { |s| s.slug == 'sidebar' } || create_section }
30
- subject { sections.destroy(section._id) }
31
- it { expect(subject._id).not_to eq nil }
32
- end
33
-
34
- def create_section
35
- sections.create(name: 'Sidebar', slug: 'sidebar', template: 'Locomotive rocks!', definition: {
36
- name: 'sidebar',
37
- settings: [
38
- {
39
- id: 'title',
40
- type: 'text'
41
- }
42
- ]
43
- })
44
- end
45
-
46
- end
@@ -1,43 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Locomotive::Coal::Resources::Sites, order: :defined do
4
-
5
- before { VCR.insert_cassette 'sites', record: :new_episodes }
6
- after { VCR.eject_cassette }
7
-
8
- let(:uri) { TEST_API_V3_URI }
9
- let(:credentials) { { email: TEST_API_EMAIL, token: api_token } }
10
- let(:sites) { described_class.new(uri, credentials) }
11
-
12
- describe '#all' do
13
-
14
- subject { sites.all }
15
- it { expect(subject.size).to be > 0 }
16
-
17
- describe 'first site' do
18
- subject { sites.all.first }
19
- it { expect(subject.name).not_to eq nil }
20
- end
21
- end
22
-
23
- describe '#create' do
24
- subject { create_site }
25
- it { expect(subject._id).not_to eq nil }
26
- end
27
-
28
- describe '#by_handle' do
29
- subject { sites.by_handle('sample') }
30
- it { expect(subject._id).not_to eq nil }
31
- end
32
-
33
- describe '#destroy' do
34
- let(:new_site) { sites.by_handle('acme') || create_site }
35
- subject { sites.destroy(new_site._id) }
36
- it { expect(subject._id).not_to eq nil }
37
- end
38
-
39
- def create_site
40
- sites.create(name: 'Acme', handle: 'acme', locales: ['en'])
41
- end
42
-
43
- end
@@ -1,38 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Locomotive::Coal::Resources::Snippets, order: :defined do
4
-
5
- before { VCR.insert_cassette 'snippets', record: :new_episodes }
6
- after { VCR.eject_cassette }
7
-
8
- let(:uri) { TEST_SITE_API_V3_URI }
9
- let(:credentials) { { email: TEST_API_EMAIL, token: api_token } }
10
- let(:snippets) { described_class.new(uri, credentials) }
11
-
12
- describe '#all' do
13
- subject { snippets.all }
14
- it { expect(subject).not_to eq nil }
15
- end
16
-
17
- describe '#create' do
18
- subject { create_snippet }
19
- it { expect(subject._id).not_to eq nil }
20
- end
21
-
22
- describe '#update' do
23
- let(:snippet) { snippets.all.detect { |s| s.slug == 'footer' } || create_snippet }
24
- subject { snippets.update(snippet._id, template: 'Locomotive rocks. period') }
25
- it { expect(subject.template).to eq 'Locomotive rocks. period' }
26
- end
27
-
28
- describe '#destroy' do
29
- let(:snippet) { snippets.all.detect { |s| s.slug == 'footer' } || create_snippet }
30
- subject { snippets.destroy(snippet._id) }
31
- it { expect(subject._id).not_to eq nil }
32
- end
33
-
34
- def create_snippet
35
- snippets.create(name: 'Footer', slug: 'footer', template: 'Locomotive rocks!')
36
- end
37
-
38
- end