contentful-management 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +24 -19
- data/lib/contentful/management/client.rb +11 -1
- data/lib/contentful/management/dynamic_entry.rb +7 -3
- data/lib/contentful/management/entry.rb +1 -1
- data/lib/contentful/management/resource/refresher.rb +1 -1
- data/lib/contentful/management/response.rb +12 -1
- data/lib/contentful/management/version.rb +1 -1
- data/spec/fixtures/vcr_cassettes/asset/reload_with_fields.yml +235 -0
- data/spec/fixtures/vcr_cassettes/content_type/entry/create_only_with_localized_fields.yml +217 -0
- data/spec/fixtures/vcr_cassettes/content_type/entry/create_to_single_locale_only_with_localized_fields.yml +216 -0
- data/spec/fixtures/vcr_cassettes/content_type/entry/update_only_with_localized_fields.yml +574 -0
- data/spec/lib/contentful/management/asset_spec.rb +14 -0
- data/spec/lib/contentful/management/content_type_spec.rb +42 -0
- metadata +12 -4
@@ -361,6 +361,20 @@ module Contentful
|
|
361
361
|
update_asset = asset.update(title: 'Updated name')
|
362
362
|
expect(update_asset).to be_kind_of Contentful::Management::Asset
|
363
363
|
expect(update_asset.title).to eq 'Updated name'
|
364
|
+
|
365
|
+
end
|
366
|
+
end
|
367
|
+
|
368
|
+
it 'updates fields collection when reloaded' do
|
369
|
+
vcr('asset/reload_with_fields') do
|
370
|
+
asset = Contentful::Management::Asset.find(space_id, '8R4vbQXKbCkcSu26Wy2U0')
|
371
|
+
valid_fields = asset.instance_variable_get(:@fields)
|
372
|
+
asset.instance_variable_set(:@fields, 'changed')
|
373
|
+
asset.reload
|
374
|
+
reloaded_fields = asset.instance_variable_get(:@fields)
|
375
|
+
expect(reloaded_fields['en-US']['description']).to eq valid_fields['en-US']['description']
|
376
|
+
expect(reloaded_fields['en-US']['title']).to eq valid_fields['en-US']['title']
|
377
|
+
expect(reloaded_fields['en-US']['file']).to eq valid_fields['en-US']['file']
|
364
378
|
end
|
365
379
|
end
|
366
380
|
end
|
@@ -239,6 +239,18 @@ module Contentful
|
|
239
239
|
expect(content_type.fields.size).to eq 1
|
240
240
|
end
|
241
241
|
end
|
242
|
+
|
243
|
+
it 'update with multiple locales' do
|
244
|
+
vcr('content_type/entry/update_only_with_localized_fields') do
|
245
|
+
space = Contentful::Management::Space.find('v2umtz8ths9v')
|
246
|
+
entry = space.entries.find('2dEkgsQRnSW2QuW4AMaa86')
|
247
|
+
entry.name_with_locales = {'en-US' => 'Contentful EN up', 'de-DE' => 'Contentful DE up', 'pl-PL' => 'Contentful PL up'}
|
248
|
+
entry.description_with_locales = {'en-US' => 'Description EN up', 'de-DE' => 'Description DE up', 'pl-PL' => 'Description PL up'}
|
249
|
+
entry.save
|
250
|
+
expect(entry).to be_kind_of Contentful::Management::Entry
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
242
254
|
end
|
243
255
|
|
244
256
|
describe '#save' do
|
@@ -461,6 +473,36 @@ module Contentful
|
|
461
473
|
expect(entry.blog_name).to eq 'Contentful en'
|
462
474
|
end
|
463
475
|
end
|
476
|
+
|
477
|
+
context 'only to unlocalized fields' do
|
478
|
+
it 'return entry with valid parameters' do
|
479
|
+
vcr('content_type/entry/create_only_with_localized_fields') do
|
480
|
+
content_type = subject.find('v2umtz8ths9v', 'category_content_type')
|
481
|
+
entry = content_type.entries.new
|
482
|
+
entry.name_with_locales = {'en-US' => 'Contentful EN', 'de-DE' => 'Contentful DE', 'pl-PL' => 'Contentful PL'}
|
483
|
+
entry.description_with_locales = {'en-US' => 'Description EN', 'de-DE' => 'Description DE', 'pl-PL' => 'Description PL'}
|
484
|
+
entry.save
|
485
|
+
expect(entry).to be_kind_of Contentful::Management::Entry
|
486
|
+
end
|
487
|
+
end
|
488
|
+
end
|
489
|
+
end
|
490
|
+
context 'to single locale' do
|
491
|
+
context 'only to unlocalized fields' do
|
492
|
+
it 'return entry with valid parameters' do
|
493
|
+
vcr('content_type/entry/create_to_single_locale_only_with_localized_fields') do
|
494
|
+
content_type = subject.find('v2umtz8ths9v', 'category_content_type')
|
495
|
+
entry = content_type.entries.new
|
496
|
+
entry.name = 'Some testing EN name'
|
497
|
+
entry.description= ' some testing EN description '
|
498
|
+
entry.locale = 'de-DE'
|
499
|
+
entry.name = 'Some testing DE name'
|
500
|
+
entry.description= ' some testing DE description'
|
501
|
+
entry.save
|
502
|
+
expect(entry).to be_kind_of Contentful::Management::Entry
|
503
|
+
end
|
504
|
+
end
|
505
|
+
end
|
464
506
|
end
|
465
507
|
end
|
466
508
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: contentful-management
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2014-
|
14
|
+
date: 2014-09-04 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: http
|
@@ -262,6 +262,7 @@ files:
|
|
262
262
|
- spec/fixtures/vcr_cassettes/asset/published_false.yml
|
263
263
|
- spec/fixtures/vcr_cassettes/asset/published_true.yml
|
264
264
|
- spec/fixtures/vcr_cassettes/asset/reload.yml
|
265
|
+
- spec/fixtures/vcr_cassettes/asset/reload_with_fields.yml
|
265
266
|
- spec/fixtures/vcr_cassettes/asset/save_update.yml
|
266
267
|
- spec/fixtures/vcr_cassettes/asset/set_locale.yml
|
267
268
|
- spec/fixtures/vcr_cassettes/asset/unarchive.yml
|
@@ -297,10 +298,13 @@ files:
|
|
297
298
|
- spec/fixtures/vcr_cassettes/content_type/destroy_activated.yml
|
298
299
|
- spec/fixtures/vcr_cassettes/content_type/entry/all.yml
|
299
300
|
- spec/fixtures/vcr_cassettes/content_type/entry/create.yml
|
301
|
+
- spec/fixtures/vcr_cassettes/content_type/entry/create_only_with_localized_fields.yml
|
302
|
+
- spec/fixtures/vcr_cassettes/content_type/entry/create_to_single_locale_only_with_localized_fields.yml
|
300
303
|
- spec/fixtures/vcr_cassettes/content_type/entry/create_with_camel_case_id_to_multiple_locales.yml
|
301
304
|
- spec/fixtures/vcr_cassettes/content_type/entry/create_with_entries.yml
|
302
305
|
- spec/fixtures/vcr_cassettes/content_type/entry/create_with_entries_for_multiple_locales.yml
|
303
306
|
- spec/fixtures/vcr_cassettes/content_type/entry/create_with_multiple_locales.yml
|
307
|
+
- spec/fixtures/vcr_cassettes/content_type/entry/update_only_with_localized_fields.yml
|
304
308
|
- spec/fixtures/vcr_cassettes/content_type/fields/add.yml
|
305
309
|
- spec/fixtures/vcr_cassettes/content_type/fields/create.yml
|
306
310
|
- spec/fixtures/vcr_cassettes/content_type/fields/create_array_with_params.yml
|
@@ -440,7 +444,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
440
444
|
version: '0'
|
441
445
|
segments:
|
442
446
|
- 0
|
443
|
-
hash:
|
447
|
+
hash: -2896588542136824987
|
444
448
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
445
449
|
none: false
|
446
450
|
requirements:
|
@@ -449,7 +453,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
449
453
|
version: '0'
|
450
454
|
segments:
|
451
455
|
- 0
|
452
|
-
hash:
|
456
|
+
hash: -2896588542136824987
|
453
457
|
requirements: []
|
454
458
|
rubyforge_project:
|
455
459
|
rubygems_version: 1.8.23
|
@@ -480,6 +484,7 @@ test_files:
|
|
480
484
|
- spec/fixtures/vcr_cassettes/asset/published_false.yml
|
481
485
|
- spec/fixtures/vcr_cassettes/asset/published_true.yml
|
482
486
|
- spec/fixtures/vcr_cassettes/asset/reload.yml
|
487
|
+
- spec/fixtures/vcr_cassettes/asset/reload_with_fields.yml
|
483
488
|
- spec/fixtures/vcr_cassettes/asset/save_update.yml
|
484
489
|
- spec/fixtures/vcr_cassettes/asset/set_locale.yml
|
485
490
|
- spec/fixtures/vcr_cassettes/asset/unarchive.yml
|
@@ -515,10 +520,13 @@ test_files:
|
|
515
520
|
- spec/fixtures/vcr_cassettes/content_type/destroy_activated.yml
|
516
521
|
- spec/fixtures/vcr_cassettes/content_type/entry/all.yml
|
517
522
|
- spec/fixtures/vcr_cassettes/content_type/entry/create.yml
|
523
|
+
- spec/fixtures/vcr_cassettes/content_type/entry/create_only_with_localized_fields.yml
|
524
|
+
- spec/fixtures/vcr_cassettes/content_type/entry/create_to_single_locale_only_with_localized_fields.yml
|
518
525
|
- spec/fixtures/vcr_cassettes/content_type/entry/create_with_camel_case_id_to_multiple_locales.yml
|
519
526
|
- spec/fixtures/vcr_cassettes/content_type/entry/create_with_entries.yml
|
520
527
|
- spec/fixtures/vcr_cassettes/content_type/entry/create_with_entries_for_multiple_locales.yml
|
521
528
|
- spec/fixtures/vcr_cassettes/content_type/entry/create_with_multiple_locales.yml
|
529
|
+
- spec/fixtures/vcr_cassettes/content_type/entry/update_only_with_localized_fields.yml
|
522
530
|
- spec/fixtures/vcr_cassettes/content_type/fields/add.yml
|
523
531
|
- spec/fixtures/vcr_cassettes/content_type/fields/create.yml
|
524
532
|
- spec/fixtures/vcr_cassettes/content_type/fields/create_array_with_params.yml
|