contentful-management 0.7.3 → 0.8.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.
@@ -720,6 +720,30 @@ module Contentful
720
720
  end
721
721
  end
722
722
  end
723
+
724
+ describe 'issues' do
725
+ it 'content types should be valid on creation - #79' do
726
+ vcr('content_type/issue_79') {
727
+ space = Contentful::Management::Space.find('ngtgiva4wofg')
728
+
729
+ field = Contentful::Management::Field.new
730
+ field.id = 'name'
731
+ field.name = 'name'
732
+ field.type = 'Symbol'
733
+
734
+ content_type = space.content_types.new
735
+ content_type.id = 'isssue_79_ct'
736
+ content_type.name = 'Issue 79 CT'
737
+ content_type.fields = [field]
738
+ content_type.display_field = 'name'
739
+
740
+ content_type.save
741
+ content_type.activate
742
+
743
+ expect(content_type.sys[:version] > 0).to be_truthy
744
+ }
745
+ end
746
+ end
723
747
  end
724
748
  end
725
749
  end
@@ -736,6 +736,229 @@ module Contentful
736
736
  expect(entry_with_all_locales.non_localized_with_locales).to match({"de-DE" => "foobar", "en-US" => nil, "es" => nil})
737
737
  }
738
738
  end
739
+
740
+ it 'can save with multiple locales assigned - #73' do
741
+ vcr('entry/issue_73') {
742
+ begin
743
+ client.configuration[:default_locale] = 'en-GB'
744
+ content_type = Contentful::Management::ContentType.find('u2viwgfeal0o', 'someType')
745
+ new_entry = content_type.entries.create(id: 'hello-world')
746
+
747
+ new_entry.name = 'Hello World!'
748
+ new_entry.locale = 'en-GB'
749
+ new_entry.value_with_locales = {'en-GB'=>'hello world', 'es-ES'=>'hola mundo'}
750
+
751
+ res = new_entry.save
752
+
753
+ expect(res.respond_to?(:error)).to be_falsey
754
+ expect(res.is_a?(Contentful::Management::DynamicEntry)).to be_truthy
755
+ expect(res.value_with_locales).to match('en-GB' => 'hello world', 'es-ES' => 'hola mundo')
756
+ ensure
757
+ new_entry.destroy
758
+ end
759
+ }
760
+ end
761
+
762
+ describe 'it can properly assign, save and publish - #61' do
763
+ describe 'on an entry created through the api' do
764
+ describe 'before refetch' do
765
+ it 'on an already populated field' do
766
+ vcr('entry/issue_61.1') {
767
+ begin
768
+ client.configuration[:default_locale] = 'en-GB'
769
+ content_type = Contentful::Management::ContentType.find('u2viwgfeal0o', 'someType')
770
+ new_entry = content_type.entries.create(id: 'issue61_1', value: 'hello')
771
+
772
+ expect(new_entry.value).to eq 'hello'
773
+
774
+ new_entry.value = 'goodbye'
775
+
776
+ new_entry.save
777
+ new_entry.publish
778
+
779
+ expected_entry = Contentful::Management::Entry.find('u2viwgfeal0o', new_entry.id)
780
+
781
+ expect(expected_entry.value).to eq 'goodbye'
782
+ ensure
783
+ new_entry.destroy
784
+ end
785
+ }
786
+ end
787
+
788
+ it 'on a previously empty field' do
789
+ vcr('entry/issue_61.2') {
790
+ begin
791
+ client.configuration[:default_locale] = 'en-GB'
792
+ content_type = Contentful::Management::ContentType.find('u2viwgfeal0o', 'someType')
793
+ new_entry = content_type.entries.create(id: 'issue61_2')
794
+
795
+ new_entry.value = 'goodbye'
796
+
797
+ new_entry.save
798
+ new_entry.publish
799
+
800
+ expect(new_entry.value).to eq 'goodbye'
801
+
802
+ expected_entry = Contentful::Management::Entry.find('u2viwgfeal0o', new_entry.id)
803
+
804
+ expect(expected_entry.value).to eq 'goodbye'
805
+ ensure
806
+ new_entry.destroy
807
+ end
808
+ }
809
+ end
810
+ end
811
+
812
+ describe 'after refetch' do
813
+ it 'on an already populated field' do
814
+ vcr('entry/issue_61.3') {
815
+ begin
816
+ client.configuration[:default_locale] = 'en-GB'
817
+ content_type = Contentful::Management::ContentType.find('u2viwgfeal0o', 'someType')
818
+ new_entry = content_type.entries.create(id: 'issue61_3', value: 'hello')
819
+
820
+ expect(new_entry.value).to eq 'hello'
821
+
822
+ expected_entry = Contentful::Management::Entry.find('u2viwgfeal0o', new_entry.id)
823
+
824
+ expected_entry.value = 'goodbye'
825
+
826
+ expected_entry.save
827
+ expected_entry.publish
828
+
829
+ expect(expected_entry.value).to eq 'goodbye'
830
+ ensure
831
+ new_entry.destroy
832
+ end
833
+ }
834
+ end
835
+
836
+ it 'on a previously empty field' do
837
+ vcr('entry/issue_61.4') {
838
+ begin
839
+ client.configuration[:default_locale] = 'en-GB'
840
+ content_type = Contentful::Management::ContentType.find('u2viwgfeal0o', 'someType')
841
+ new_entry = content_type.entries.create(id: 'issue61_4')
842
+
843
+ expected_entry = Contentful::Management::Entry.find('u2viwgfeal0o', new_entry.id)
844
+
845
+ expected_entry.value = 'goodbye'
846
+
847
+ expected_entry.save
848
+ expected_entry.publish
849
+
850
+ expect(expected_entry.value).to eq 'goodbye'
851
+ ensure
852
+ new_entry.destroy
853
+ end
854
+ }
855
+ end
856
+ end
857
+ end
858
+
859
+ describe 'on an entry created through the ui' do
860
+ describe 'with dynamic_entries' do
861
+ let!(:client) { vcr('entry/issue_61_spaces') { Client.new(token, dynamic_entries: ['u2viwgfeal0o']) } }
862
+ it 'on an already populated field' do
863
+ vcr('entry/issue_61.5') {
864
+ begin
865
+ client.configuration[:default_locale] = 'en-GB'
866
+
867
+ expected_entry = Contentful::Management::Entry.find('u2viwgfeal0o', 'fIpsfQSOd22IsqMQCiG0K')
868
+
869
+ expect(expected_entry.value).to eq 'hello'
870
+
871
+ expected_entry.value = 'goodbye'
872
+
873
+ expected_entry.save
874
+ expected_entry.publish
875
+
876
+ expect(expected_entry.value).to eq 'goodbye'
877
+ ensure
878
+ expected_entry.value = 'hello'
879
+
880
+ expected_entry.save
881
+ expected_entry.publish
882
+ end
883
+ }
884
+ end
885
+
886
+ it 'on a previously empty field' do
887
+ vcr('entry/issue_61.6') {
888
+ begin
889
+ client.configuration[:default_locale] = 'en-GB'
890
+
891
+ expected_entry = Contentful::Management::Entry.find('u2viwgfeal0o', '2GmtCwDBcIu4giMgQGIIcq')
892
+
893
+ expect(expected_entry.value).to eq nil
894
+
895
+ expected_entry.value = 'goodbye'
896
+
897
+ expected_entry.save
898
+ expected_entry.publish
899
+
900
+ expect(expected_entry.value).to eq 'goodbye'
901
+ ensure
902
+ expected_entry.value = nil
903
+
904
+ expected_entry.save
905
+ expected_entry.publish
906
+ end
907
+ }
908
+ end
909
+ end
910
+ end
911
+
912
+ describe 'without dynamic entries' do
913
+ it 'on an already populated field' do
914
+ vcr('entry/issue_61.7') {
915
+ begin
916
+ client.configuration[:default_locale] = 'en-GB'
917
+
918
+ expected_entry = Contentful::Management::Entry.find('u2viwgfeal0o', 'fIpsfQSOd22IsqMQCiG0K')
919
+
920
+ expect(expected_entry.value).to eq 'hello'
921
+
922
+ expected_entry.value = 'goodbye'
923
+
924
+ expected_entry.save
925
+ expected_entry.publish
926
+
927
+ expect(expected_entry.value).to eq 'goodbye'
928
+ ensure
929
+ expected_entry.value = 'hello'
930
+
931
+ expected_entry.save
932
+ expected_entry.publish
933
+ end
934
+ }
935
+ end
936
+
937
+ it 'on a previously empty field' do
938
+ vcr('entry/issue_61.8') {
939
+ begin
940
+ client.configuration[:default_locale] = 'en-GB'
941
+
942
+ expected_entry = Contentful::Management::Entry.find('u2viwgfeal0o', '2GmtCwDBcIu4giMgQGIIcq')
943
+
944
+ expect(expected_entry.value).to eq nil
945
+
946
+ expected_entry.value = 'goodbye'
947
+
948
+ expected_entry.save
949
+ expected_entry.publish
950
+
951
+ expect(expected_entry.value).to eq 'goodbye'
952
+ ensure
953
+ expected_entry.value = nil
954
+
955
+ expected_entry.save
956
+ expected_entry.publish
957
+ end
958
+ }
959
+ end
960
+ end
961
+ end
739
962
  end
740
963
  end
741
964
  end
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.7.3
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Protas
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-11-26 00:00:00.000000000 Z
13
+ date: 2016-01-22 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: http
@@ -181,6 +181,7 @@ files:
181
181
  - ".travis.yml"
182
182
  - CHANGELOG.md
183
183
  - Gemfile
184
+ - Guardfile
184
185
  - LICENSE.txt
185
186
  - README.md
186
187
  - RELEASE.md
@@ -210,6 +211,7 @@ files:
210
211
  - lib/contentful/management/resource/array_like.rb
211
212
  - lib/contentful/management/resource/asset_fields.rb
212
213
  - lib/contentful/management/resource/entry_fields.rb
214
+ - lib/contentful/management/resource/field_aware.rb
213
215
  - lib/contentful/management/resource/fields.rb
214
216
  - lib/contentful/management/resource/refresher.rb
215
217
  - lib/contentful/management/resource/system_properties.rb
@@ -301,6 +303,7 @@ files:
301
303
  - spec/fixtures/vcr_cassettes/content_type/fields/update_field.yml
302
304
  - spec/fixtures/vcr_cassettes/content_type/find.yml
303
305
  - spec/fixtures/vcr_cassettes/content_type/find_not_found.yml
306
+ - spec/fixtures/vcr_cassettes/content_type/issue_79.yml
304
307
  - spec/fixtures/vcr_cassettes/content_type/reload.yml
305
308
  - spec/fixtures/vcr_cassettes/content_type/save_new.yml
306
309
  - spec/fixtures/vcr_cassettes/content_type/save_updated.yml
@@ -343,7 +346,17 @@ files:
343
346
  - spec/fixtures/vcr_cassettes/entry/find-with-null-symbols.yml
344
347
  - spec/fixtures/vcr_cassettes/entry/find.yml
345
348
  - spec/fixtures/vcr_cassettes/entry/find_not_found.yml
349
+ - spec/fixtures/vcr_cassettes/entry/issue_61_1.yml
350
+ - spec/fixtures/vcr_cassettes/entry/issue_61_2.yml
351
+ - spec/fixtures/vcr_cassettes/entry/issue_61_3.yml
352
+ - spec/fixtures/vcr_cassettes/entry/issue_61_4.yml
353
+ - spec/fixtures/vcr_cassettes/entry/issue_61_5.yml
354
+ - spec/fixtures/vcr_cassettes/entry/issue_61_6.yml
355
+ - spec/fixtures/vcr_cassettes/entry/issue_61_7.yml
356
+ - spec/fixtures/vcr_cassettes/entry/issue_61_8.yml
357
+ - spec/fixtures/vcr_cassettes/entry/issue_61_spaces.yml
346
358
  - spec/fixtures/vcr_cassettes/entry/issue_70.yml
359
+ - spec/fixtures/vcr_cassettes/entry/issue_73.yml
347
360
  - spec/fixtures/vcr_cassettes/entry/limited_entries.yml
348
361
  - spec/fixtures/vcr_cassettes/entry/locales/fallback_to_default_locale.yml
349
362
  - spec/fixtures/vcr_cassettes/entry/locales/retrieve_localized.yml
@@ -464,7 +477,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
464
477
  version: '0'
465
478
  requirements: []
466
479
  rubyforge_project:
467
- rubygems_version: 2.4.5.1
480
+ rubygems_version: 2.5.0
468
481
  signing_key:
469
482
  specification_version: 4
470
483
  summary: contentful management api
@@ -544,6 +557,7 @@ test_files:
544
557
  - spec/fixtures/vcr_cassettes/content_type/fields/update_field.yml
545
558
  - spec/fixtures/vcr_cassettes/content_type/find.yml
546
559
  - spec/fixtures/vcr_cassettes/content_type/find_not_found.yml
560
+ - spec/fixtures/vcr_cassettes/content_type/issue_79.yml
547
561
  - spec/fixtures/vcr_cassettes/content_type/reload.yml
548
562
  - spec/fixtures/vcr_cassettes/content_type/save_new.yml
549
563
  - spec/fixtures/vcr_cassettes/content_type/save_updated.yml
@@ -586,7 +600,17 @@ test_files:
586
600
  - spec/fixtures/vcr_cassettes/entry/find-with-null-symbols.yml
587
601
  - spec/fixtures/vcr_cassettes/entry/find.yml
588
602
  - spec/fixtures/vcr_cassettes/entry/find_not_found.yml
603
+ - spec/fixtures/vcr_cassettes/entry/issue_61_1.yml
604
+ - spec/fixtures/vcr_cassettes/entry/issue_61_2.yml
605
+ - spec/fixtures/vcr_cassettes/entry/issue_61_3.yml
606
+ - spec/fixtures/vcr_cassettes/entry/issue_61_4.yml
607
+ - spec/fixtures/vcr_cassettes/entry/issue_61_5.yml
608
+ - spec/fixtures/vcr_cassettes/entry/issue_61_6.yml
609
+ - spec/fixtures/vcr_cassettes/entry/issue_61_7.yml
610
+ - spec/fixtures/vcr_cassettes/entry/issue_61_8.yml
611
+ - spec/fixtures/vcr_cassettes/entry/issue_61_spaces.yml
589
612
  - spec/fixtures/vcr_cassettes/entry/issue_70.yml
613
+ - spec/fixtures/vcr_cassettes/entry/issue_73.yml
590
614
  - spec/fixtures/vcr_cassettes/entry/limited_entries.yml
591
615
  - spec/fixtures/vcr_cassettes/entry/locales/fallback_to_default_locale.yml
592
616
  - spec/fixtures/vcr_cassettes/entry/locales/retrieve_localized.yml