contentstack 0.0.3 → 0.3.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.
data/spec/query_spec.rb CHANGED
@@ -54,7 +54,7 @@ describe Contentstack::Query do
54
54
  it "should get data using `include_count` method" do
55
55
  data = category_query.include_count.fetch
56
56
  expect(data.count).not_to be nil
57
- expect(data.count.class).to be Integer
57
+ expect(data.count).to eq 5
58
58
  end
59
59
 
60
60
  it "should get data using `only` method with string parameter" do
@@ -147,6 +147,11 @@ describe Contentstack::Query do
147
147
  expect(data.first.fields[:_owner]).not_to be nil
148
148
  end
149
149
 
150
+ it "should get data using `include_owner` method" do
151
+ data = product_query.include_fallback.fetch
152
+ expect(data.first.fields[:locale]).not_to be nil
153
+ end
154
+
150
155
  it "should get data using `include_draft` method" do
151
156
  data = category_query.include_draft.fetch
152
157
  expect(data.length).to eq 5
data/spec/spec_helper.rb CHANGED
@@ -107,10 +107,22 @@ RSpec.configure do |config|
107
107
  =end
108
108
 
109
109
  config.before(:each) do
110
- stub_request(:get, /cdn.contentstack.io\/v3\/content_types/).
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/).
111
115
  with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
112
116
  to_return(:status => 200, :body => File.read(File.dirname(__FILE__) + '/fixtures/content_types.json'), :headers => {})
113
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
+
114
126
  stub_request(:get, /cdn.contentstack.io\/v3\/assets/).
115
127
  with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
116
128
  to_return(:status => 200, :body => File.read(File.dirname(__FILE__) + '/fixtures/asset_collection.json'), :headers => {})
@@ -138,9 +150,14 @@ RSpec.configure do |config|
138
150
  stub_request(:get, /cdn.contentstack.io\/v3\/content_types\/category\/entries\/blt05056a2f5e0ebf76/).
139
151
  with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
140
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
+
141
158
  end
142
159
 
143
- def create_client(access_token = ENV['ACCESS_TOKEN'], api_key = ENV['API_KEY'], environment = ENV['STACK_ENV'])
144
- Contentstack::Client.new(access_token, api_key, environment)
160
+ def create_client(delivery_token = ENV['DELIVERY_TOKEN'], api_key = ENV['API_KEY'], environment = ENV['ENVIRONMENT'], options = {})
161
+ Contentstack::Client.new(api_key, delivery_token, environment, options)
145
162
  end
146
163
  end
data/spec/sync_spec.rb ADDED
@@ -0,0 +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
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.0.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Contentstack
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-02 00:00:00.000000000 Z
11
+ date: 2021-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -75,37 +75,16 @@ extra_rdoc_files: []
75
75
  files:
76
76
  - ".gitignore"
77
77
  - ".yardopts"
78
+ - CHANGELOG.md
78
79
  - CODE_OF_CONDUCT.md
80
+ - Gemfile
81
+ - Gemfile.lock
79
82
  - LICENSE.txt
80
83
  - README.md
81
84
  - contentstack.gemspec
82
85
  - coverage/.last_run.json
83
86
  - coverage/.resultset.json
84
87
  - coverage/.resultset.json.lock
85
- - coverage/assets/0.10.2/application.css
86
- - coverage/assets/0.10.2/application.js
87
- - coverage/assets/0.10.2/colorbox/border.png
88
- - coverage/assets/0.10.2/colorbox/controls.png
89
- - coverage/assets/0.10.2/colorbox/loading.gif
90
- - coverage/assets/0.10.2/colorbox/loading_background.png
91
- - coverage/assets/0.10.2/favicon_green.png
92
- - coverage/assets/0.10.2/favicon_red.png
93
- - coverage/assets/0.10.2/favicon_yellow.png
94
- - coverage/assets/0.10.2/loading.gif
95
- - coverage/assets/0.10.2/magnify.png
96
- - coverage/assets/0.10.2/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png
97
- - coverage/assets/0.10.2/smoothness/images/ui-bg_flat_75_ffffff_40x100.png
98
- - coverage/assets/0.10.2/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png
99
- - coverage/assets/0.10.2/smoothness/images/ui-bg_glass_65_ffffff_1x400.png
100
- - coverage/assets/0.10.2/smoothness/images/ui-bg_glass_75_dadada_1x400.png
101
- - coverage/assets/0.10.2/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png
102
- - coverage/assets/0.10.2/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png
103
- - coverage/assets/0.10.2/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png
104
- - coverage/assets/0.10.2/smoothness/images/ui-icons_222222_256x240.png
105
- - coverage/assets/0.10.2/smoothness/images/ui-icons_2e83ff_256x240.png
106
- - coverage/assets/0.10.2/smoothness/images/ui-icons_454545_256x240.png
107
- - coverage/assets/0.10.2/smoothness/images/ui-icons_888888_256x240.png
108
- - coverage/assets/0.10.2/smoothness/images/ui-icons_cd0a0a_256x240.png
109
88
  - coverage/index.html
110
89
  - lib/contentstack.rb
111
90
  - lib/contentstack/api.rb
@@ -117,6 +96,8 @@ files:
117
96
  - lib/contentstack/entry_collection.rb
118
97
  - lib/contentstack/error.rb
119
98
  - lib/contentstack/query.rb
99
+ - lib/contentstack/region.rb
100
+ - lib/contentstack/sync_result.rb
120
101
  - lib/contentstack/version.rb
121
102
  - lib/util.rb
122
103
  - rakefile.rb
@@ -128,15 +109,18 @@ files:
128
109
  - spec/entry_spec.rb
129
110
  - spec/fixtures/asset.json
130
111
  - spec/fixtures/asset_collection.json
112
+ - spec/fixtures/category_content_type.json
131
113
  - spec/fixtures/category_entry.json
132
114
  - spec/fixtures/category_entry_collection.json
133
115
  - spec/fixtures/category_entry_collection_without_count.json
134
116
  - spec/fixtures/content_types.json
135
117
  - spec/fixtures/product_entry.json
136
118
  - spec/fixtures/product_entry_collection.json
119
+ - spec/fixtures/sync_init.json
137
120
  - spec/query_spec.rb
138
121
  - spec/spec_helper.rb
139
- homepage: https://github.com/builtio-contentstack/contentstack-ruby
122
+ - spec/sync_spec.rb
123
+ homepage: https://github.com/contentstack/contentstack-ruby
140
124
  licenses:
141
125
  - MIT
142
126
  metadata: {}
@@ -155,8 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
155
139
  - !ruby/object:Gem::Version
156
140
  version: '0'
157
141
  requirements: []
158
- rubyforge_project:
159
- rubygems_version: 2.6.12
142
+ rubygems_version: 3.0.3
160
143
  signing_key:
161
144
  specification_version: 4
162
145
  summary: Contentstack Ruby client for the Content Delivery API