contentful_bootstrap 3.10.0 → 3.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.rubocop.yml +9 -5
- data/.rubocop_todo.yml +34 -76
- data/CHANGELOG.md +7 -0
- data/Guardfile +20 -4
- data/README.md +6 -6
- data/bin/contentful_bootstrap +46 -42
- data/contentful_bootstrap.gemspec +6 -3
- data/lib/contentful/bootstrap/command_runner.rb +3 -1
- data/lib/contentful/bootstrap/commands/base.rb +15 -15
- data/lib/contentful/bootstrap/commands/create_space.rb +5 -6
- data/lib/contentful/bootstrap/commands/generate_json.rb +13 -2
- data/lib/contentful/bootstrap/commands/generate_token.rb +6 -6
- data/lib/contentful/bootstrap/commands/update_space.rb +2 -2
- data/lib/contentful/bootstrap/generator.rb +5 -4
- data/lib/contentful/bootstrap/support.rb +1 -1
- data/lib/contentful/bootstrap/templates/base.rb +22 -25
- data/lib/contentful/bootstrap/templates/json_template.rb +49 -56
- data/lib/contentful/bootstrap/templates/links/base.rb +1 -1
- data/lib/contentful/bootstrap/token.rb +1 -1
- data/lib/contentful/bootstrap/version.rb +1 -1
- data/spec/contentful/bootstrap/command_runner_spec.rb +2 -2
- data/spec/contentful/bootstrap/commands/base_spec.rb +3 -15
- data/spec/contentful/bootstrap/commands/create_space_spec.rb +2 -2
- data/spec/contentful/bootstrap/commands/generate_json_spec.rb +1 -1
- data/spec/contentful/bootstrap/commands/generate_token_spec.rb +1 -1
- data/spec/contentful/bootstrap/commands/update_space_spec.rb +36 -8
- data/spec/contentful/bootstrap/generator_spec.rb +17 -2
- data/spec/contentful/bootstrap/templates/base_spec.rb +10 -8
- data/spec/contentful/bootstrap/templates/blog_spec.rb +9 -1
- data/spec/contentful/bootstrap/templates/catalogue_spec.rb +9 -1
- data/spec/contentful/bootstrap/templates/gallery_spec.rb +9 -1
- data/spec/contentful/bootstrap/templates/json_template_spec.rb +17 -9
- data/spec/fixtures/json_fixtures/environment_template.json +47 -0
- data/spec/fixtures/vcr_fixtures/asset_no_transform.yml +119 -4
- data/spec/fixtures/vcr_fixtures/check_created_space.yml +1 -1
- data/spec/fixtures/vcr_fixtures/check_original_staging_environment_status.yml +201 -0
- data/spec/fixtures/vcr_fixtures/check_staging_environment_status.yml +81 -0
- data/spec/fixtures/vcr_fixtures/check_update_space_localized.yml +2 -2
- data/spec/fixtures/vcr_fixtures/check_update_space_with_draft_content.yml +4 -4
- data/spec/fixtures/vcr_fixtures/create_space_with_blog_template.yml +153 -38
- data/spec/fixtures/vcr_fixtures/create_space_with_catalogue_template.yml +196 -81
- data/spec/fixtures/vcr_fixtures/create_space_with_gallery_template.yml +165 -50
- data/spec/fixtures/vcr_fixtures/generate_json.yml +5 -5
- data/spec/fixtures/vcr_fixtures/generate_json_content_types_only.yml +1 -1
- data/spec/fixtures/vcr_fixtures/generate_json_environments.yml +447 -0
- data/spec/fixtures/vcr_fixtures/generate_json_multi_ct.yml +5 -5
- data/spec/fixtures/vcr_fixtures/generate_json_preview.yml +5 -5
- data/spec/fixtures/vcr_fixtures/generate_json_single_ct.yml +5 -5
- data/spec/fixtures/vcr_fixtures/issue_22.yml +142 -27
- data/spec/fixtures/vcr_fixtures/no_ids.yml +126 -11
- data/spec/fixtures/vcr_fixtures/update_existing_asset.yml +130 -15
- data/spec/fixtures/vcr_fixtures/update_space_localized.yml +134 -19
- data/spec/fixtures/vcr_fixtures/update_with_environment.yml +2531 -0
- metadata +55 -17
@@ -66,7 +66,7 @@ module Contentful
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def config_file
|
69
|
-
@
|
69
|
+
@config_file ||= ::File.exist?(filename) ? IniFile.load(filename) : IniFile.new(filename: filename)
|
70
70
|
end
|
71
71
|
end
|
72
72
|
end
|
@@ -101,7 +101,7 @@ describe Contentful::Bootstrap::CommandRunner do
|
|
101
101
|
allow_any_instance_of(Contentful::Bootstrap::Commands::GenerateJson).to receive(:run)
|
102
102
|
|
103
103
|
expect(Contentful::Bootstrap::Commands::GenerateJson).to receive(:new).with(
|
104
|
-
'foo', 'bar', nil, false, false, false, []
|
104
|
+
'foo', 'bar', 'master', nil, false, false, false, []
|
105
105
|
).and_call_original
|
106
106
|
|
107
107
|
subject.generate_json('foo', access_token: 'bar')
|
@@ -111,7 +111,7 @@ describe Contentful::Bootstrap::CommandRunner do
|
|
111
111
|
allow_any_instance_of(Contentful::Bootstrap::Commands::GenerateJson).to receive(:run)
|
112
112
|
|
113
113
|
expect(Contentful::Bootstrap::Commands::GenerateJson).to receive(:new).with(
|
114
|
-
'foo', 'bar', 'baz', true, false, false, []
|
114
|
+
'foo', 'bar', 'master', 'baz', true, false, false, []
|
115
115
|
).and_call_original
|
116
116
|
|
117
117
|
subject.generate_json('foo', access_token: 'bar', filename: 'baz', content_types_only: true)
|
@@ -27,22 +27,10 @@ describe Contentful::Bootstrap::Commands::Base do
|
|
27
27
|
described_class.new(token, 'foo', trigger_oauth: false, quiet: true)
|
28
28
|
end
|
29
29
|
end
|
30
|
-
|
31
|
-
describe 'management_client_init' do
|
32
|
-
it 'runs management_client_init when trigger_oauth is true' do
|
33
|
-
expect_any_instance_of(described_class).to receive(:management_client_init)
|
34
|
-
described_class.new(token, 'foo', quiet: true)
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'doesnt run management_client_init when trigger_oauth is false' do
|
38
|
-
expect_any_instance_of(described_class).not_to receive(:management_client_init)
|
39
|
-
described_class.new(token, 'foo', trigger_oauth: false, quiet: true)
|
40
|
-
end
|
41
|
-
end
|
42
30
|
end
|
43
31
|
|
44
32
|
describe 'instance methods' do
|
45
|
-
it '#
|
33
|
+
it '#client' do
|
46
34
|
allow_any_instance_of(described_class).to receive(:configuration)
|
47
35
|
expect(Contentful::Management::Client).to receive(:new).with(
|
48
36
|
token.read,
|
@@ -57,7 +45,7 @@ describe Contentful::Bootstrap::Commands::Base do
|
|
57
45
|
|
58
46
|
describe '#configuration' do
|
59
47
|
before do
|
60
|
-
allow_any_instance_of(subject.class).to receive(:
|
48
|
+
allow_any_instance_of(subject.class).to receive(:client)
|
61
49
|
end
|
62
50
|
|
63
51
|
it 'passes if token is found' do
|
@@ -80,7 +68,7 @@ describe Contentful::Bootstrap::Commands::Base do
|
|
80
68
|
end
|
81
69
|
|
82
70
|
it '#token_server' do
|
83
|
-
allow_any_instance_of(described_class).to receive(:
|
71
|
+
allow_any_instance_of(described_class).to receive(:client)
|
84
72
|
|
85
73
|
expect(Contentful::Bootstrap::Support).to receive(:gets) { "y" }
|
86
74
|
expect_any_instance_of(Contentful::Bootstrap::Server).to receive(:start) {}
|
@@ -136,7 +136,7 @@ describe Contentful::Bootstrap::Commands::CreateSpace do
|
|
136
136
|
end
|
137
137
|
|
138
138
|
context 'with no_publish set to true' do
|
139
|
-
subject { described_class.new token, 'foo', json_template: 'bar', trigger_oauth: false, quiet: true, no_publish: true }
|
139
|
+
subject { described_class.new token, 'foo', environment: 'master', json_template: 'bar', trigger_oauth: false, quiet: true, no_publish: true }
|
140
140
|
|
141
141
|
it 'calls JsonTemplate with no_publish' do
|
142
142
|
allow(Contentful::Bootstrap::Support).to receive(:gets).and_return('y')
|
@@ -148,7 +148,7 @@ describe Contentful::Bootstrap::Commands::CreateSpace do
|
|
148
148
|
expect(subject).to receive(:fetch_space) { space_double }
|
149
149
|
expect(mock_template).to receive(:run)
|
150
150
|
|
151
|
-
expect(::Contentful::Bootstrap::Templates::JsonTemplate).to receive(:new).with(space_double, 'bar', false, true, true, false, true) { mock_template }
|
151
|
+
expect(::Contentful::Bootstrap::Templates::JsonTemplate).to receive(:new).with(space_double, 'bar', 'master', false, true, true, false, true) { mock_template }
|
152
152
|
|
153
153
|
subject.run
|
154
154
|
end
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe Contentful::Bootstrap::Commands::UpdateSpace do
|
4
4
|
let(:path) { File.expand_path(File.join('spec', 'fixtures', 'ini_fixtures', 'contentfulrc.ini')) }
|
5
5
|
let(:token) { Contentful::Bootstrap::Token.new path }
|
6
|
-
subject { described_class.new token, 'foo', json_template: 'bar', mark_processed: false, trigger_oauth: false, quiet: true }
|
6
|
+
subject { described_class.new token, 'foo', environment: 'master', json_template: 'bar', mark_processed: false, trigger_oauth: false, quiet: true }
|
7
7
|
let(:space_double) { SpaceDouble.new }
|
8
8
|
|
9
9
|
before do
|
@@ -42,7 +42,7 @@ describe Contentful::Bootstrap::Commands::UpdateSpace do
|
|
42
42
|
describe 'runs JSON Template without already processed elements' do
|
43
43
|
[true, false].each do |mark_processed|
|
44
44
|
context "mark_processed is #{mark_processed}" do
|
45
|
-
subject { described_class.new token, 'foo', json_template: 'bar', mark_processed: mark_processed, trigger_oauth: false, quiet: true}
|
45
|
+
subject { described_class.new token, 'foo', environment: 'master', json_template: 'bar', mark_processed: mark_processed, trigger_oauth: false, quiet: true}
|
46
46
|
|
47
47
|
it "calls JsonTemplate with mark_processed as #{mark_processed}" do
|
48
48
|
allow(::File).to receive(:exist?) { true }
|
@@ -52,7 +52,7 @@ describe Contentful::Bootstrap::Commands::UpdateSpace do
|
|
52
52
|
expect(subject).to receive(:fetch_space) { space_double }
|
53
53
|
expect(mock_template).to receive(:run)
|
54
54
|
|
55
|
-
expect(::Contentful::Bootstrap::Templates::JsonTemplate).to receive(:new).with(space_double, 'bar', mark_processed, true, true, false, false) { mock_template }
|
55
|
+
expect(::Contentful::Bootstrap::Templates::JsonTemplate).to receive(:new).with(space_double, 'bar', 'master', mark_processed, true, true, false, false) { mock_template }
|
56
56
|
|
57
57
|
subject.run
|
58
58
|
end
|
@@ -71,14 +71,14 @@ describe Contentful::Bootstrap::Commands::UpdateSpace do
|
|
71
71
|
expect(subject).to receive(:fetch_space) { space_double }
|
72
72
|
expect(mock_template).to receive(:run)
|
73
73
|
|
74
|
-
expect(::Contentful::Bootstrap::Templates::JsonTemplate).to receive(:new).with(space_double, 'bar', false, true, true, true, false) { mock_template }
|
74
|
+
expect(::Contentful::Bootstrap::Templates::JsonTemplate).to receive(:new).with(space_double, 'bar', 'master', false, true, true, true, false) { mock_template }
|
75
75
|
|
76
76
|
subject.run
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
80
|
context 'with no_publish set to true' do
|
81
|
-
subject { described_class.new token, 'foo', json_template: 'bar', trigger_oauth: false, skip_content_types: true, quiet: true, no_publish: true }
|
81
|
+
subject { described_class.new token, 'foo', environment: 'master', json_template: 'bar', trigger_oauth: false, skip_content_types: true, quiet: true, no_publish: true }
|
82
82
|
|
83
83
|
it 'calls JsonTemplate with no_publish' do
|
84
84
|
allow(::File).to receive(:exist?) { true }
|
@@ -88,7 +88,7 @@ describe Contentful::Bootstrap::Commands::UpdateSpace do
|
|
88
88
|
expect(subject).to receive(:fetch_space) { space_double }
|
89
89
|
expect(mock_template).to receive(:run)
|
90
90
|
|
91
|
-
expect(::Contentful::Bootstrap::Templates::JsonTemplate).to receive(:new).with(space_double, 'bar', false, true, true, true, true) { mock_template }
|
91
|
+
expect(::Contentful::Bootstrap::Templates::JsonTemplate).to receive(:new).with(space_double, 'bar', 'master', false, true, true, true, true) { mock_template }
|
92
92
|
|
93
93
|
subject.run
|
94
94
|
end
|
@@ -106,7 +106,7 @@ describe Contentful::Bootstrap::Commands::UpdateSpace do
|
|
106
106
|
it 'can update localized spaces' do
|
107
107
|
vcr('update_space_localized') {
|
108
108
|
json_path = File.expand_path(File.join('spec', 'fixtures', 'json_fixtures', 'update_space_localized.json'))
|
109
|
-
subject = described_class.new(token, 'vsy1ouf6jdcq', locale: 'es-AR', json_template: json_path, mark_processed: false, trigger_oauth: false, quiet: true)
|
109
|
+
subject = described_class.new(token, 'vsy1ouf6jdcq', environment: 'master', locale: 'es-AR', json_template: json_path, mark_processed: false, trigger_oauth: false, quiet: true)
|
110
110
|
|
111
111
|
subject.run
|
112
112
|
}
|
@@ -128,7 +128,7 @@ describe Contentful::Bootstrap::Commands::UpdateSpace do
|
|
128
128
|
it 'can update an existing asset and keep it as draft' do
|
129
129
|
vcr('update_existing_asset') {
|
130
130
|
json_path = File.expand_path(File.join('spec', 'fixtures', 'json_fixtures', 'assets_draft.json'))
|
131
|
-
subject = described_class.new(token, 'f3abi4dqvrhg', json_template: json_path, no_publish: true, trigger_oauth: false, quiet: true)
|
131
|
+
subject = described_class.new(token, 'f3abi4dqvrhg', environment: 'master', json_template: json_path, no_publish: true, trigger_oauth: false, quiet: true)
|
132
132
|
|
133
133
|
subject.run
|
134
134
|
}
|
@@ -157,5 +157,33 @@ describe Contentful::Bootstrap::Commands::UpdateSpace do
|
|
157
157
|
expect(delivery_cat.title).to eq 'Foo'
|
158
158
|
}
|
159
159
|
end
|
160
|
+
|
161
|
+
it 'can update a specific environment different than master' do
|
162
|
+
delivery_client = nil
|
163
|
+
vcr('check_original_staging_environment_status') {
|
164
|
+
delivery_client = Contentful::Client.new(
|
165
|
+
space: '9utsm1g0t7f5',
|
166
|
+
access_token: 'a67d4d9011f6d6c1dfe4169d838114d3d3849ab6df6fb1d322cf3ee91690fae4',
|
167
|
+
environment: 'staging',
|
168
|
+
dynamic_entries: :auto,
|
169
|
+
raise_errors: true
|
170
|
+
)
|
171
|
+
|
172
|
+
expect(delivery_client.entries.size).to eq 1
|
173
|
+
}
|
174
|
+
|
175
|
+
vcr('update_with_environment') {
|
176
|
+
json_path = File.expand_path(File.join('spec', 'fixtures', 'json_fixtures', 'environment_template.json'))
|
177
|
+
subject = described_class.new(token, '9utsm1g0t7f5', environment: 'staging', json_template: json_path, trigger_oauth: false, quiet: true)
|
178
|
+
|
179
|
+
subject.run
|
180
|
+
}
|
181
|
+
|
182
|
+
vcr('check_staging_environment_status') {
|
183
|
+
entries = delivery_client.entries
|
184
|
+
expect(entries.size).to eq 2
|
185
|
+
expect(entries.items.detect { |i| i.id == 'foo_update' }.name).to eq 'Test updated'
|
186
|
+
}
|
187
|
+
end
|
160
188
|
end
|
161
189
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Contentful::Bootstrap::Generator do
|
4
|
-
subject {
|
4
|
+
subject { described_class.new('wl1z0pal05vy', '48d7db7d4cd9d09df573c251d456f4acc72141b92f36e57f8684b36cf5cfff6e', 'master', false, false, []) }
|
5
5
|
|
6
6
|
describe 'user agent headers' do
|
7
7
|
it 'client has proper integration data' do
|
@@ -19,7 +19,7 @@ describe Contentful::Bootstrap::Generator do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
context 'with content_types_only set to true' do
|
22
|
-
subject {
|
22
|
+
subject { described_class.new('wl1z0pal05vy', '48d7db7d4cd9d09df573c251d456f4acc72141b92f36e57f8684b36cf5cfff6e', 'master', true, false, []) }
|
23
23
|
|
24
24
|
it 'can generate a JSON template for a given space with only Content Types' do
|
25
25
|
vcr('generate_json_content_types_only') {
|
@@ -30,4 +30,19 @@ describe Contentful::Bootstrap::Generator do
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
33
|
+
|
34
|
+
describe 'integration' do
|
35
|
+
subject { described_class.new('9utsm1g0t7f5', 'a67d4d9011f6d6c1dfe4169d838114d3d3849ab6df6fb1d322cf3ee91690fae4', 'staging', false, false, []) }
|
36
|
+
it 'can generate templates from an environment' do
|
37
|
+
vcr('generate_json_environments') {
|
38
|
+
unparsed_json = subject.generate_json
|
39
|
+
json = JSON.load(unparsed_json)
|
40
|
+
|
41
|
+
json_fixture('environment_template') { |fixture|
|
42
|
+
expect(json).to eq fixture
|
43
|
+
}
|
44
|
+
expect(json['entries']['foo'].size).to eq 2
|
45
|
+
}
|
46
|
+
end
|
47
|
+
end
|
33
48
|
end
|
@@ -2,7 +2,15 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Contentful::Bootstrap::Templates::Base do
|
4
4
|
let(:space) { Contentful::Management::Space.new }
|
5
|
-
subject { described_class.new(space, true) }
|
5
|
+
subject { described_class.new(space, 'master', true) }
|
6
|
+
|
7
|
+
before :each do
|
8
|
+
environment_proxy = Object.new
|
9
|
+
allow(space).to receive(:environments) { environment_proxy }
|
10
|
+
|
11
|
+
environment = Object.new
|
12
|
+
allow(environment_proxy).to receive(:find) { environment }
|
13
|
+
end
|
6
14
|
|
7
15
|
describe 'instance methods' do
|
8
16
|
it '#content_types' do
|
@@ -33,7 +41,7 @@ describe Contentful::Bootstrap::Templates::Base do
|
|
33
41
|
end
|
34
42
|
|
35
43
|
context 'with skip_content_types set to true' do
|
36
|
-
subject { described_class.new(space, true, true) }
|
44
|
+
subject { described_class.new(space, 'master', true, true) }
|
37
45
|
|
38
46
|
it 'doesnt call create_content_type if skip_content_types is sent' do
|
39
47
|
expect(subject).to receive(:create_entries)
|
@@ -45,10 +53,4 @@ describe Contentful::Bootstrap::Templates::Base do
|
|
45
53
|
end
|
46
54
|
end
|
47
55
|
end
|
48
|
-
|
49
|
-
describe 'attributes' do
|
50
|
-
it ':space' do
|
51
|
-
expect(subject.space).to eq space
|
52
|
-
end
|
53
|
-
end
|
54
56
|
end
|
@@ -2,7 +2,15 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Contentful::Bootstrap::Templates::Blog do
|
4
4
|
let(:space) { Contentful::Management::Space.new }
|
5
|
-
subject {
|
5
|
+
subject { described_class.new(space, 'master') }
|
6
|
+
|
7
|
+
before :each do
|
8
|
+
environment_proxy = Object.new
|
9
|
+
allow(space).to receive(:environments) { environment_proxy }
|
10
|
+
|
11
|
+
environment = Object.new
|
12
|
+
allow(environment_proxy).to receive(:find) { environment }
|
13
|
+
end
|
6
14
|
|
7
15
|
describe 'content types' do
|
8
16
|
it 'has Post content type' do
|
@@ -2,7 +2,15 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Contentful::Bootstrap::Templates::Catalogue do
|
4
4
|
let(:space) { Contentful::Management::Space.new }
|
5
|
-
subject {
|
5
|
+
subject { described_class.new(space, 'master') }
|
6
|
+
|
7
|
+
before :each do
|
8
|
+
environment_proxy = Object.new
|
9
|
+
allow(space).to receive(:environments) { environment_proxy }
|
10
|
+
|
11
|
+
environment = Object.new
|
12
|
+
allow(environment_proxy).to receive(:find) { environment }
|
13
|
+
end
|
6
14
|
|
7
15
|
describe 'content types' do
|
8
16
|
it 'has Brand content type' do
|
@@ -2,7 +2,15 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Contentful::Bootstrap::Templates::Gallery do
|
4
4
|
let(:space) { Contentful::Management::Space.new }
|
5
|
-
subject {
|
5
|
+
subject { described_class.new(space) }
|
6
|
+
|
7
|
+
before :each do
|
8
|
+
environment_proxy = Object.new
|
9
|
+
allow(space).to receive(:environments) { environment_proxy }
|
10
|
+
|
11
|
+
environment = Object.new
|
12
|
+
allow(environment_proxy).to receive(:find) { environment }
|
13
|
+
end
|
6
14
|
|
7
15
|
describe 'content types' do
|
8
16
|
it 'has Author content type' do
|
@@ -3,7 +3,15 @@ require 'spec_helper'
|
|
3
3
|
describe Contentful::Bootstrap::Templates::JsonTemplate do
|
4
4
|
let(:space) { Contentful::Management::Space.new }
|
5
5
|
let(:path) { json_path('simple') }
|
6
|
-
subject { described_class.new space, path, false, true, true }
|
6
|
+
subject { described_class.new space, path, 'master', false, true, true }
|
7
|
+
|
8
|
+
before :each do
|
9
|
+
environment_proxy = Object.new
|
10
|
+
allow(space).to receive(:environments) { environment_proxy }
|
11
|
+
|
12
|
+
environment = Object.new
|
13
|
+
allow(environment_proxy).to receive(:find) { environment }
|
14
|
+
end
|
7
15
|
|
8
16
|
before do
|
9
17
|
allow(::File).to receive(:write)
|
@@ -35,7 +43,7 @@ describe Contentful::Bootstrap::Templates::JsonTemplate do
|
|
35
43
|
end
|
36
44
|
|
37
45
|
it 'uses display_field if not' do
|
38
|
-
subject = described_class.new(space, File.expand_path(File.join('spec', 'fixtures', 'json_fixtures', 'display_field.json')), false, true, true)
|
46
|
+
subject = described_class.new(space, File.expand_path(File.join('spec', 'fixtures', 'json_fixtures', 'display_field.json')), 'master', false, true, true)
|
39
47
|
|
40
48
|
expect(subject.content_types.first['displayField']).to eq 'name'
|
41
49
|
end
|
@@ -127,7 +135,7 @@ describe Contentful::Bootstrap::Templates::JsonTemplate do
|
|
127
135
|
expect(json['contentTypes'].size).to eq(2)
|
128
136
|
expect(json['contentTypes'].last['id']).to eq('dog')
|
129
137
|
|
130
|
-
subject = described_class.new(space, processed_path, false, false)
|
138
|
+
subject = described_class.new(space, processed_path, 'master', false, false)
|
131
139
|
|
132
140
|
expect(subject.content_types.size).to eq(1)
|
133
141
|
expect(subject.content_types.first['id']).to eq('cat')
|
@@ -139,7 +147,7 @@ describe Contentful::Bootstrap::Templates::JsonTemplate do
|
|
139
147
|
expect(json['assets'].size).to eq(2)
|
140
148
|
expect(json['assets'].last['id']).to eq('dog_asset')
|
141
149
|
|
142
|
-
subject = described_class.new(space, processed_path, false, false)
|
150
|
+
subject = described_class.new(space, processed_path, 'master', false, false)
|
143
151
|
|
144
152
|
expect(subject.assets.size).to eq(1)
|
145
153
|
expect(subject.assets.first['id']).to eq('cat_asset')
|
@@ -151,7 +159,7 @@ describe Contentful::Bootstrap::Templates::JsonTemplate do
|
|
151
159
|
expect(json['entries']['dog'].size).to eq(1)
|
152
160
|
expect(json['entries']['dog'].first['sys']['id']).to eq('doge')
|
153
161
|
|
154
|
-
subject = described_class.new(space, processed_path, false, false)
|
162
|
+
subject = described_class.new(space, processed_path, 'master', false, false)
|
155
163
|
|
156
164
|
expect(subject.entries['dog'].size).to eq(0)
|
157
165
|
}
|
@@ -160,7 +168,7 @@ describe Contentful::Bootstrap::Templates::JsonTemplate do
|
|
160
168
|
|
161
169
|
describe 'mark processed' do
|
162
170
|
it 'does not write file after run if not mark_processed' do
|
163
|
-
subject = described_class.new(space, path, false, false)
|
171
|
+
subject = described_class.new(space, path, 'master', false, false)
|
164
172
|
['content_types', 'assets', 'entries'].each do |n|
|
165
173
|
allow(subject).to receive("create_#{n}".to_sym)
|
166
174
|
end
|
@@ -172,7 +180,7 @@ describe Contentful::Bootstrap::Templates::JsonTemplate do
|
|
172
180
|
end
|
173
181
|
|
174
182
|
it 'writes file after run if mark_processed' do
|
175
|
-
subject = described_class.new(space, path, true, false)
|
183
|
+
subject = described_class.new(space, path, 'master', true, false)
|
176
184
|
['content_types', 'assets', 'entries'].each do |n|
|
177
185
|
allow(subject).to receive("create_#{n}".to_sym)
|
178
186
|
end
|
@@ -229,7 +237,7 @@ describe Contentful::Bootstrap::Templates::JsonTemplate do
|
|
229
237
|
|
230
238
|
describe 'skip_content_types' do
|
231
239
|
context 'with skip_content_types set to true' do
|
232
|
-
subject { described_class.new(space, path, false, false, true, true) }
|
240
|
+
subject { described_class.new(space, path, 'master', false, false, true, true) }
|
233
241
|
|
234
242
|
it 'skips content type creation' do
|
235
243
|
['assets', 'entries'].each do |n|
|
@@ -245,7 +253,7 @@ describe Contentful::Bootstrap::Templates::JsonTemplate do
|
|
245
253
|
end
|
246
254
|
|
247
255
|
context 'with skip_content_types set to false' do
|
248
|
-
subject { described_class.new(space, path, false, false, true, false) }
|
256
|
+
subject { described_class.new(space, path, 'master', false, false, true, false) }
|
249
257
|
|
250
258
|
it 'doesnt skip content type creation' do
|
251
259
|
['assets', 'entries', 'content_types'].each do |n|
|
@@ -0,0 +1,47 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"contentTypes": [
|
4
|
+
{
|
5
|
+
"id": "foo",
|
6
|
+
"name": "Foo",
|
7
|
+
"displayField": "name",
|
8
|
+
"fields": [
|
9
|
+
{
|
10
|
+
"id": "name",
|
11
|
+
"name": "Name",
|
12
|
+
"type": "Symbol"
|
13
|
+
},
|
14
|
+
{
|
15
|
+
"id": "content",
|
16
|
+
"name": "Content",
|
17
|
+
"type": "Text"
|
18
|
+
}
|
19
|
+
]
|
20
|
+
}
|
21
|
+
],
|
22
|
+
"assets": [
|
23
|
+
|
24
|
+
],
|
25
|
+
"entries": {
|
26
|
+
"foo": [
|
27
|
+
{
|
28
|
+
"sys": {
|
29
|
+
"id": "6yVdruR4GsKO2iKOqQS2CS"
|
30
|
+
},
|
31
|
+
"fields": {
|
32
|
+
"name": "Test",
|
33
|
+
"content": "Some content"
|
34
|
+
}
|
35
|
+
},
|
36
|
+
{
|
37
|
+
"sys": {
|
38
|
+
"id": "foo_update"
|
39
|
+
},
|
40
|
+
"fields": {
|
41
|
+
"name": "Test updated",
|
42
|
+
"content": "Some content"
|
43
|
+
}
|
44
|
+
}
|
45
|
+
]
|
46
|
+
}
|
47
|
+
}
|