contentstack 0.6.0 → 0.6.2

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.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/codeql-analysis.yml +68 -68
  3. data/.github/workflows/jira.yml +28 -0
  4. data/.github/workflows/release-gem.yml +31 -0
  5. data/.github/workflows/sast-scan.yml +10 -10
  6. data/.github/workflows/sca-scan.yml +15 -13
  7. data/.github/workflows/secrets-scan.yml +10 -10
  8. data/.gitignore +11 -11
  9. data/.yardopts +6 -6
  10. data/CHANGELOG.md +108 -78
  11. data/CODEOWNERS +1 -1
  12. data/CODE_OF_CONDUCT.md +73 -73
  13. data/Gemfile +2 -2
  14. data/Gemfile.lock +28 -23
  15. data/LICENSE.txt +21 -21
  16. data/README.md +197 -197
  17. data/SECURITY.md +27 -27
  18. data/contentstack.gemspec +29 -29
  19. data/lib/contentstack/api.rb +191 -188
  20. data/lib/contentstack/asset.rb +68 -68
  21. data/lib/contentstack/asset_collection.rb +27 -27
  22. data/lib/contentstack/client.rb +91 -91
  23. data/lib/contentstack/content_type.rb +53 -53
  24. data/lib/contentstack/entry.rb +221 -221
  25. data/lib/contentstack/entry_collection.rb +44 -44
  26. data/lib/contentstack/error.rb +6 -6
  27. data/lib/contentstack/query.rb +653 -653
  28. data/lib/contentstack/region.rb +5 -5
  29. data/lib/contentstack/sync_result.rb +29 -29
  30. data/lib/contentstack/version.rb +2 -2
  31. data/lib/contentstack.rb +31 -31
  32. data/lib/util.rb +110 -110
  33. data/rakefile.rb +3 -3
  34. data/spec/asset_collection_spec.rb +15 -15
  35. data/spec/asset_spec.rb +47 -47
  36. data/spec/content_type_spec.rb +80 -80
  37. data/spec/contentstack_spec.rb +38 -38
  38. data/spec/entry_collection_spec.rb +41 -41
  39. data/spec/entry_spec.rb +101 -101
  40. data/spec/fixtures/asset.json +1 -1
  41. data/spec/fixtures/asset_collection.json +1 -1
  42. data/spec/fixtures/category_content_type.json +1 -1
  43. data/spec/fixtures/category_entry.json +1 -1
  44. data/spec/fixtures/category_entry_collection.json +1 -1
  45. data/spec/fixtures/category_entry_collection_without_count.json +1 -1
  46. data/spec/fixtures/content_types.json +1 -1
  47. data/spec/fixtures/product_entry.json +1 -1
  48. data/spec/fixtures/product_entry_collection.json +1 -1
  49. data/spec/fixtures/sync_init.json +2974 -2974
  50. data/spec/query_spec.rb +205 -205
  51. data/spec/spec_helper.rb +180 -180
  52. data/spec/sync_spec.rb +26 -26
  53. metadata +9 -7
data/spec/spec_helper.rb CHANGED
@@ -1,181 +1,181 @@
1
- # This file was generated by the `rspec --init` command. Conventionally, all
2
- # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
- # The generated `.rspec` file contains `--require spec_helper` which will cause
4
- # this file to always be loaded, without a need to explicitly require it in any
5
- # files.
6
- #
7
- # Given that it is always loaded, you are encouraged to keep this file as
8
- # light-weight as possible. Requiring heavyweight dependencies from this file
9
- # will add to the boot time of your test suite on EVERY test run, even for an
10
- # individual file that may not need all of that loaded. Instead, consider making
11
- # a separate helper file that requires the additional dependencies and performs
12
- # the additional setup, and require it from the spec files that actually need
13
- # it.
14
- #
15
- # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
16
- require 'webmock/rspec'
17
- WebMock.disable_net_connect!(allow_localhost: true)
18
-
19
- require 'simplecov'
20
- SimpleCov.start
21
-
22
- require 'contentstack'
23
-
24
- RSpec.configure do |config|
25
- # rspec-expectations config goes here. You can use an alternate
26
- # assertion/expectation library such as wrong or the stdlib/minitest
27
- # assertions if you prefer.
28
- config.expect_with :rspec do |expectations|
29
- # This option will default to `true` in RSpec 4. It makes the `description`
30
- # and `failure_message` of custom matchers include text for helper methods
31
- # defined using `chain`, e.g.:
32
- # be_bigger_than(2).and_smaller_than(4).description
33
- # # => "be bigger than 2 and smaller than 4"
34
- # ...rather than:
35
- # # => "be bigger than 2"
36
- expectations.include_chain_clauses_in_custom_matcher_descriptions = true
37
- end
38
-
39
- # rspec-mocks config goes here. You can use an alternate test double
40
- # library (such as bogus or mocha) by changing the `mock_with` option here.
41
- config.mock_with :rspec do |mocks|
42
- # Prevents you from mocking or stubbing a method that does not exist on
43
- # a real object. This is generally recommended, and will default to
44
- # `true` in RSpec 4.
45
- mocks.verify_partial_doubles = true
46
- end
47
-
48
- # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
49
- # have no way to turn it off -- the option exists only for backwards
50
- # compatibility in RSpec 3). It causes shared context metadata to be
51
- # inherited by the metadata hash of host groups and examples, rather than
52
- # triggering implicit auto-inclusion in groups with matching metadata.
53
- config.shared_context_metadata_behavior = :apply_to_host_groups
54
-
55
- # The settings below are suggested to provide a good initial experience
56
- # with RSpec, but feel free to customize to your heart's content.
57
- =begin
58
- # This allows you to limit a spec run to individual examples or groups
59
- # you care about by tagging them with `:focus` metadata. When nothing
60
- # is tagged with `:focus`, all examples get run. RSpec also provides
61
- # aliases for `it`, `describe`, and `context` that include `:focus`
62
- # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
63
- config.filter_run_when_matching :focus
64
-
65
- # Allows RSpec to persist some state between runs in order to support
66
- # the `--only-failures` and `--next-failure` CLI options. We recommend
67
- # you configure your source control system to ignore this file.
68
- config.example_status_persistence_file_path = "spec/examples.txt"
69
-
70
- # Limits the available syntax to the non-monkey patched syntax that is
71
- # recommended. For more details, see:
72
- # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
73
- # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
74
- # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
75
- config.disable_monkey_patching!
76
-
77
- # This setting enables warnings. It's recommended, but in some cases may
78
- # be too noisy due to issues in dependencies.
79
- config.warnings = true
80
-
81
- # Many RSpec users commonly either run the entire suite or an individual
82
- # file, and it's useful to allow more verbose output when running an
83
- # individual spec file.
84
- if config.files_to_run.one?
85
- # Use the documentation formatter for detailed output,
86
- # unless a formatter has already been configured
87
- # (e.g. via a command-line flag).
88
- config.default_formatter = "doc"
89
- end
90
-
91
- # Print the 10 slowest examples and example groups at the
92
- # end of the spec run, to help surface which specs are running
93
- # particularly slow.
94
- config.profile_examples = 10
95
-
96
- # Run specs in random order to surface order dependencies. If you find an
97
- # order dependency and want to debug it, you can fix the order by providing
98
- # the seed, which is printed after each run.
99
- # --seed 1234
100
- config.order = :random
101
-
102
- # Seed global randomization in this process using the `--seed` CLI option.
103
- # Setting this allows you to use `--seed` to deterministically reproduce
104
- # test failures related to randomization by passing the same `--seed` value
105
- # as the one that triggered the failure.
106
- Kernel.srand config.seed
107
- =end
108
-
109
- config.before(:each) do
110
- stub_request(:get, /custom-cdn.contentstack.com\/v3\/content_types/).
111
- with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
112
- to_return(:status => 200, :body => File.read(File.dirname(__FILE__) + '/fixtures/content_types.json'), :headers => {})
113
-
114
- stub_request(:get, /eu-cdn.contentstack.com\/v3\/content_types/).
115
- with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
116
- to_return(:status => 200, :body => File.read(File.dirname(__FILE__) + '/fixtures/content_types.json'), :headers => {})
117
-
118
- stub_request(:get, /cdn.contentstack.io\/v3\/content_types/).
119
- with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
120
- to_return(:status => 200, :body => File.read(File.dirname(__FILE__) + '/fixtures/content_types.json'), :headers => {})
121
-
122
- stub_request(:get, /cdn.contentstack.io\/v3\/content_types\/category/).
123
- with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
124
- to_return(:status => 200, :body => File.read(File.dirname(__FILE__) + '/fixtures/category_content_type.json'), :headers => {})
125
-
126
- stub_request(:get, /cdn.contentstack.io\/v3\/assets/).
127
- with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
128
- to_return(:status => 200, :body => File.read(File.dirname(__FILE__) + '/fixtures/asset_collection.json'), :headers => {})
129
-
130
- stub_request(:get, /cdn.contentstack.io\/v3\/assets\/image_1/).
131
- with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
132
- to_return(:status => 200, :body => File.read(File.dirname(__FILE__) + '/fixtures/asset.json'), :headers => {})
133
-
134
- stub_request(:get, /cdn.contentstack.io\/v3\/content_types\/product\/entries/).
135
- with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
136
- to_return(:status => 200, :body => File.read(File.dirname(__FILE__) + '/fixtures/product_entry_collection.json'), :headers => {})
137
-
138
- stub_request(:get, /cdn.contentstack.io\/v3\/content_types\/product\/entries\/uid/).
139
- with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
140
- to_return(:status => 200, :body => File.read(File.dirname(__FILE__) + '/fixtures/product_entry.json'), :headers => {})
141
-
142
- stub_request(:get, /cdn.contentstack.io\/v3\/content_types\/category\/entries/).
143
- with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
144
- to_return(:status => 200, :body => File.read(File.dirname(__FILE__) + '/fixtures/category_entry_collection_without_count.json'), :headers => {})
145
-
146
- stub_request(:get, /cdn.contentstack.io\/v3\/content_types\/category\/entries.*include_count=true/).
147
- with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
148
- to_return(:status => 200, :body => File.read(File.dirname(__FILE__) + '/fixtures/category_entry_collection.json'), :headers => {})
149
-
150
- stub_request(:get, /cdn.contentstack.io\/v3\/content_types\/category\/entries\/uid/).
151
- with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
152
- to_return(:status => 200, :body => File.read(File.dirname(__FILE__) + '/fixtures/category_entry.json'), :headers => {})
153
-
154
- stub_request(:get, /cdn.contentstack.io\/v3\/stacks\/sync/).
155
- with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
156
- to_return(:status => 200, :body => File.read(File.dirname(__FILE__) + '/fixtures/sync_init.json'), :headers => {})
157
-
158
- stub_request(:get, /preview.contentstack.io\/v3\/content_types\/category\/entries/).
159
- with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
160
- to_return(:status => 200, :body => File.read(File.dirname(__FILE__) + '/fixtures/category_entry_collection_without_count.json'), :headers => {})
161
-
162
- stub_request(:get, /preview.contentstack.io\/v3\/content_types\/category\/entries\/uid/).
163
- with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
164
- to_return(:status => 200, :body => File.read(File.dirname(__FILE__) + '/fixtures/category_entry.json'), :headers => {})
165
- end
166
-
167
- def create_client(delivery_token = ENV['DELIVERY_TOKEN'], api_key = ENV['API_KEY'], environment = ENV['ENVIRONMENT'], options = {})
168
- Contentstack::Client.new(api_key, delivery_token, environment, options)
169
- end
170
-
171
- def create_preview_client(delivery_token = ENV['DELIVERY_TOKEN'], api_key = ENV['API_KEY'], environment = ENV['ENVIRONMENT'], options = {live_preview: {host: 'https://preview.contentstack.io', enable: true, management_token: 'auth'}})
172
- Contentstack::Client.new(api_key, delivery_token, environment, options)
173
- end
174
-
175
- def render(content, entry)
176
- Contentstack::render_content(content, ContentstackUtils::Model::Options.new(entry))
177
- end
178
- def json_to_html(content, entry)
179
- Contentstack::json_to_html(content, ContentstackUtils::Model::Options.new(entry))
180
- end
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
4
+ # this file to always be loaded, without a need to explicitly require it in any
5
+ # files.
6
+ #
7
+ # Given that it is always loaded, you are encouraged to keep this file as
8
+ # light-weight as possible. Requiring heavyweight dependencies from this file
9
+ # will add to the boot time of your test suite on EVERY test run, even for an
10
+ # individual file that may not need all of that loaded. Instead, consider making
11
+ # a separate helper file that requires the additional dependencies and performs
12
+ # the additional setup, and require it from the spec files that actually need
13
+ # it.
14
+ #
15
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
16
+ require 'webmock/rspec'
17
+ WebMock.disable_net_connect!(allow_localhost: true)
18
+
19
+ require 'simplecov'
20
+ SimpleCov.start
21
+
22
+ require 'contentstack'
23
+
24
+ RSpec.configure do |config|
25
+ # rspec-expectations config goes here. You can use an alternate
26
+ # assertion/expectation library such as wrong or the stdlib/minitest
27
+ # assertions if you prefer.
28
+ config.expect_with :rspec do |expectations|
29
+ # This option will default to `true` in RSpec 4. It makes the `description`
30
+ # and `failure_message` of custom matchers include text for helper methods
31
+ # defined using `chain`, e.g.:
32
+ # be_bigger_than(2).and_smaller_than(4).description
33
+ # # => "be bigger than 2 and smaller than 4"
34
+ # ...rather than:
35
+ # # => "be bigger than 2"
36
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
37
+ end
38
+
39
+ # rspec-mocks config goes here. You can use an alternate test double
40
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
41
+ config.mock_with :rspec do |mocks|
42
+ # Prevents you from mocking or stubbing a method that does not exist on
43
+ # a real object. This is generally recommended, and will default to
44
+ # `true` in RSpec 4.
45
+ mocks.verify_partial_doubles = true
46
+ end
47
+
48
+ # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
49
+ # have no way to turn it off -- the option exists only for backwards
50
+ # compatibility in RSpec 3). It causes shared context metadata to be
51
+ # inherited by the metadata hash of host groups and examples, rather than
52
+ # triggering implicit auto-inclusion in groups with matching metadata.
53
+ config.shared_context_metadata_behavior = :apply_to_host_groups
54
+
55
+ # The settings below are suggested to provide a good initial experience
56
+ # with RSpec, but feel free to customize to your heart's content.
57
+ =begin
58
+ # This allows you to limit a spec run to individual examples or groups
59
+ # you care about by tagging them with `:focus` metadata. When nothing
60
+ # is tagged with `:focus`, all examples get run. RSpec also provides
61
+ # aliases for `it`, `describe`, and `context` that include `:focus`
62
+ # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
63
+ config.filter_run_when_matching :focus
64
+
65
+ # Allows RSpec to persist some state between runs in order to support
66
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
67
+ # you configure your source control system to ignore this file.
68
+ config.example_status_persistence_file_path = "spec/examples.txt"
69
+
70
+ # Limits the available syntax to the non-monkey patched syntax that is
71
+ # recommended. For more details, see:
72
+ # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
73
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
74
+ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
75
+ config.disable_monkey_patching!
76
+
77
+ # This setting enables warnings. It's recommended, but in some cases may
78
+ # be too noisy due to issues in dependencies.
79
+ config.warnings = true
80
+
81
+ # Many RSpec users commonly either run the entire suite or an individual
82
+ # file, and it's useful to allow more verbose output when running an
83
+ # individual spec file.
84
+ if config.files_to_run.one?
85
+ # Use the documentation formatter for detailed output,
86
+ # unless a formatter has already been configured
87
+ # (e.g. via a command-line flag).
88
+ config.default_formatter = "doc"
89
+ end
90
+
91
+ # Print the 10 slowest examples and example groups at the
92
+ # end of the spec run, to help surface which specs are running
93
+ # particularly slow.
94
+ config.profile_examples = 10
95
+
96
+ # Run specs in random order to surface order dependencies. If you find an
97
+ # order dependency and want to debug it, you can fix the order by providing
98
+ # the seed, which is printed after each run.
99
+ # --seed 1234
100
+ config.order = :random
101
+
102
+ # Seed global randomization in this process using the `--seed` CLI option.
103
+ # Setting this allows you to use `--seed` to deterministically reproduce
104
+ # test failures related to randomization by passing the same `--seed` value
105
+ # as the one that triggered the failure.
106
+ Kernel.srand config.seed
107
+ =end
108
+
109
+ config.before(:each) do
110
+ stub_request(:get, /custom-cdn.contentstack.com\/v3\/content_types/).
111
+ with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
112
+ to_return(:status => 200, :body => File.read(File.dirname(__FILE__) + '/fixtures/content_types.json'), :headers => {})
113
+
114
+ stub_request(:get, /eu-cdn.contentstack.com\/v3\/content_types/).
115
+ with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
116
+ to_return(:status => 200, :body => File.read(File.dirname(__FILE__) + '/fixtures/content_types.json'), :headers => {})
117
+
118
+ stub_request(:get, /cdn.contentstack.io\/v3\/content_types/).
119
+ with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
120
+ to_return(:status => 200, :body => File.read(File.dirname(__FILE__) + '/fixtures/content_types.json'), :headers => {})
121
+
122
+ stub_request(:get, /cdn.contentstack.io\/v3\/content_types\/category/).
123
+ with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
124
+ to_return(:status => 200, :body => File.read(File.dirname(__FILE__) + '/fixtures/category_content_type.json'), :headers => {})
125
+
126
+ stub_request(:get, /cdn.contentstack.io\/v3\/assets/).
127
+ with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
128
+ to_return(:status => 200, :body => File.read(File.dirname(__FILE__) + '/fixtures/asset_collection.json'), :headers => {})
129
+
130
+ stub_request(:get, /cdn.contentstack.io\/v3\/assets\/image_1/).
131
+ with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
132
+ to_return(:status => 200, :body => File.read(File.dirname(__FILE__) + '/fixtures/asset.json'), :headers => {})
133
+
134
+ stub_request(:get, /cdn.contentstack.io\/v3\/content_types\/product\/entries/).
135
+ with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
136
+ to_return(:status => 200, :body => File.read(File.dirname(__FILE__) + '/fixtures/product_entry_collection.json'), :headers => {})
137
+
138
+ stub_request(:get, /cdn.contentstack.io\/v3\/content_types\/product\/entries\/uid/).
139
+ with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
140
+ to_return(:status => 200, :body => File.read(File.dirname(__FILE__) + '/fixtures/product_entry.json'), :headers => {})
141
+
142
+ stub_request(:get, /cdn.contentstack.io\/v3\/content_types\/category\/entries/).
143
+ with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
144
+ to_return(:status => 200, :body => File.read(File.dirname(__FILE__) + '/fixtures/category_entry_collection_without_count.json'), :headers => {})
145
+
146
+ stub_request(:get, /cdn.contentstack.io\/v3\/content_types\/category\/entries.*include_count=true/).
147
+ with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
148
+ to_return(:status => 200, :body => File.read(File.dirname(__FILE__) + '/fixtures/category_entry_collection.json'), :headers => {})
149
+
150
+ stub_request(:get, /cdn.contentstack.io\/v3\/content_types\/category\/entries\/uid/).
151
+ with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
152
+ to_return(:status => 200, :body => File.read(File.dirname(__FILE__) + '/fixtures/category_entry.json'), :headers => {})
153
+
154
+ stub_request(:get, /cdn.contentstack.io\/v3\/stacks\/sync/).
155
+ with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
156
+ to_return(:status => 200, :body => File.read(File.dirname(__FILE__) + '/fixtures/sync_init.json'), :headers => {})
157
+
158
+ stub_request(:get, /preview.contentstack.io\/v3\/content_types\/category\/entries/).
159
+ with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
160
+ to_return(:status => 200, :body => File.read(File.dirname(__FILE__) + '/fixtures/category_entry_collection_without_count.json'), :headers => {})
161
+
162
+ stub_request(:get, /preview.contentstack.io\/v3\/content_types\/category\/entries\/uid/).
163
+ with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
164
+ to_return(:status => 200, :body => File.read(File.dirname(__FILE__) + '/fixtures/category_entry.json'), :headers => {})
165
+ end
166
+
167
+ def create_client(delivery_token = ENV['DELIVERY_TOKEN'], api_key = ENV['API_KEY'], environment = ENV['ENVIRONMENT'], options = {})
168
+ Contentstack::Client.new(api_key, delivery_token, environment, options)
169
+ end
170
+
171
+ def create_preview_client(delivery_token = ENV['DELIVERY_TOKEN'], api_key = ENV['API_KEY'], environment = ENV['ENVIRONMENT'], options = {live_preview: {host: 'https://preview.contentstack.io', enable: true, management_token: 'auth'}})
172
+ Contentstack::Client.new(api_key, delivery_token, environment, options)
173
+ end
174
+
175
+ def render(content, entry)
176
+ Contentstack::render_content(content, ContentstackUtils::Model::Options.new(entry))
177
+ end
178
+ def json_to_html(content, entry)
179
+ Contentstack::json_to_html(content, ContentstackUtils::Model::Options.new(entry))
180
+ end
181
181
  end
data/spec/sync_spec.rb CHANGED
@@ -1,27 +1,27 @@
1
- require 'spec_helper'
2
- require_relative '../lib/contentstack.rb'
3
- pagination_token = "token"
4
- describe Contentstack::SyncResult do
5
- let(:client) { create_client }
6
-
7
- it "initial sync for Stack" do
8
- @result = client.sync({init: true})
9
- expect(@result.items.length).to be 100
10
- expect(@result.skip).to be 0
11
- expect(@result.limit).to be 100
12
- expect(@result.total_count).to be 123
13
- expect(@result.pagination_token).not_to be nil
14
- expect(@result.sync_token).to be nil
15
- pagination_token = @result.pagination_token
16
- end
17
-
18
- it "next paginated sync for Stack" do
19
- @result = client.sync({pagination_token: pagination_token})
20
- expect(@result.items.length).to be 100
21
- expect(@result.skip).to be 0
22
- expect(@result.limit).to be 100
23
- expect(@result.total_count).to be 123
24
- expect(@result.pagination_token).not_to be nil
25
- expect(@result.sync_token).to be nil
26
- end
1
+ require 'spec_helper'
2
+ require_relative '../lib/contentstack.rb'
3
+ pagination_token = "token"
4
+ describe Contentstack::SyncResult do
5
+ let(:client) { create_client }
6
+
7
+ it "initial sync for Stack" do
8
+ @result = client.sync({init: true})
9
+ expect(@result.items.length).to be 100
10
+ expect(@result.skip).to be 0
11
+ expect(@result.limit).to be 100
12
+ expect(@result.total_count).to be 123
13
+ expect(@result.pagination_token).not_to be nil
14
+ expect(@result.sync_token).to be nil
15
+ pagination_token = @result.pagination_token
16
+ end
17
+
18
+ it "next paginated sync for Stack" do
19
+ @result = client.sync({pagination_token: pagination_token})
20
+ expect(@result.items.length).to be 100
21
+ expect(@result.skip).to be 0
22
+ expect(@result.limit).to be 100
23
+ expect(@result.total_count).to be 123
24
+ expect(@result.pagination_token).not_to be nil
25
+ expect(@result.sync_token).to be nil
26
+ end
27
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: contentstack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Contentstack
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-17 00:00:00.000000000 Z
11
+ date: 2023-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '3.2'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '6.2'
22
+ version: 7.0.4
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: '3.2'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '6.2'
32
+ version: 7.0.4
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: contentstack_utils
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -39,7 +39,7 @@ dependencies:
39
39
  version: '1.0'
40
40
  - - ">="
41
41
  - !ruby/object:Gem::Version
42
- version: 1.0.1
42
+ version: 1.1.1
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
@@ -49,7 +49,7 @@ dependencies:
49
49
  version: '1.0'
50
50
  - - ">="
51
51
  - !ruby/object:Gem::Version
52
- version: 1.0.1
52
+ version: 1.1.1
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: rspec
55
55
  requirement: !ruby/object:Gem::Requirement
@@ -114,6 +114,8 @@ extensions: []
114
114
  extra_rdoc_files: []
115
115
  files:
116
116
  - ".github/workflows/codeql-analysis.yml"
117
+ - ".github/workflows/jira.yml"
118
+ - ".github/workflows/release-gem.yml"
117
119
  - ".github/workflows/sast-scan.yml"
118
120
  - ".github/workflows/sca-scan.yml"
119
121
  - ".github/workflows/secrets-scan.yml"
@@ -182,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
182
184
  - !ruby/object:Gem::Version
183
185
  version: '0'
184
186
  requirements: []
185
- rubygems_version: 3.1.6
187
+ rubygems_version: 3.0.3.1
186
188
  signing_key:
187
189
  specification_version: 4
188
190
  summary: Contentstack Ruby client for the Content Delivery API