storyblok 3.0.0 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,23 +0,0 @@
1
- require_relative '../../lib/storyblok/request'
2
- require 'spec_helper'
3
-
4
- describe Storyblok::Request do
5
- subject { described_class.new(client, endpoint) }
6
-
7
- let(:client) { 'fake_client' }
8
- let(:endpoint) { 'some.url.com' }
9
- let(:query) { {my_key: 'my_value'} }
10
- let(:id) { 222 }
11
-
12
- context "#copy" do
13
- it "Returns a copy of StoryBlock:Request object initialized" do
14
- object_duplicated = subject.copy
15
- expect(subject.client).to eq(object_duplicated.client)
16
- expect(subject.endpoint).to eq(object_duplicated.endpoint)
17
- expect(subject.query).to eq(object_duplicated.query)
18
- expect(subject.id).to eq(object_duplicated.id)
19
- expect(subject.type).to eq(object_duplicated.type)
20
- expect(subject.object_id).not_to eq(object_duplicated.object_id)
21
- end
22
- end
23
- end
data/spec/spec_helper.rb DELETED
@@ -1,121 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # This file was generated by the `rspec --init` command. Conventionally, all
4
- # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
5
- # The generated `.rspec` file contains `--require spec_helper` which will cause
6
- # this file to always be loaded, without a need to explicitly require it in any
7
- # files.
8
- #
9
- # Given that it is always loaded, you are encouraged to keep this file as
10
- # light-weight as possible. Requiring heavyweight dependencies from this file
11
- # will add to the boot time of your test suite on EVERY test run, even for an
12
- # individual file that may not need all of that loaded. Instead, consider making
13
- # a separate helper file that requires the additional dependencies and performs
14
- # the additional setup, and require it from the spec files that actually need
15
- # it.
16
- #
17
-
18
- if ENV['COVERAGE']
19
- require 'simplecov'
20
- SimpleCov.start do
21
- add_filter "/spec/"
22
- end
23
- end
24
-
25
- require 'vcr'
26
- VCR.configure do |config|
27
- config.cassette_library_dir = "spec/fixtures/vcr_cassettes"
28
- config.configure_rspec_metadata!
29
- config.hook_into :webmock
30
- config.default_cassette_options = {
31
- :match_requests_on => [:method, VCR.request_matchers.uri_without_params(:cv, :cache_version)]
32
- }
33
- config.allow_http_connections_when_no_cassette = true
34
- end
35
-
36
- # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
37
- RSpec.configure do |config|
38
- # rspec-expectations config goes here. You can use an alternate
39
- # assertion/expectation library such as wrong or the stdlib/minitest
40
- # assertions if you prefer.
41
- config.expect_with :rspec do |expectations|
42
- # This option will default to `true` in RSpec 4. It makes the `description`
43
- # and `failure_message` of custom matchers include text for helper methods
44
- # defined using `chain`, e.g.:
45
- # be_bigger_than(2).and_smaller_than(4).description
46
- # # => "be bigger than 2 and smaller than 4"
47
- # ...rather than:
48
- # # => "be bigger than 2"
49
- expectations.include_chain_clauses_in_custom_matcher_descriptions = true
50
- end
51
-
52
- # rspec-mocks config goes here. You can use an alternate test double
53
- # library (such as bogus or mocha) by changing the `mock_with` option here.
54
- config.mock_with :rspec do |mocks|
55
- # Prevents you from mocking or stubbing a method that does not exist on
56
- # a real object. This is generally recommended, and will default to
57
- # `true` in RSpec 4.
58
- mocks.verify_partial_doubles = true
59
- end
60
-
61
- # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
62
- # have no way to turn it off -- the option exists only for backwards
63
- # compatibility in RSpec 3). It causes shared context metadata to be
64
- # inherited by the metadata hash of host groups and examples, rather than
65
- # triggering implicit auto-inclusion in groups with matching metadata.
66
- config.shared_context_metadata_behavior = :apply_to_host_groups
67
-
68
- # The settings below are suggested to provide a good initial experience
69
- # with RSpec, but feel free to customize to your heart's content.
70
- begin
71
- # This allows you to limit a spec run to individual examples or groups
72
- # you care about by tagging them with `:focus` metadata. When nothing
73
- # is tagged with `:focus`, all examples get run. RSpec also provides
74
- # aliases for `it`, `describe`, and `context` that include `:focus`
75
- # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
76
- config.filter_run_when_matching :focus
77
-
78
- # Allows RSpec to persist some state between runs in order to support
79
- # the `--only-failures` and `--next-failure` CLI options. We recommend
80
- # you configure your source control system to ignore this file.
81
- # config.example_status_persistence_file_path = "spec/examples.txt"
82
-
83
- # Limits the available syntax to the non-monkey patched syntax that is
84
- # recommended. For more details, see:
85
- # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
86
- # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
87
- # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
88
- # config.disable_monkey_patching!
89
-
90
- # This setting enables warnings. It's recommended, but in some cases may
91
- # be too noisy due to issues in dependencies.
92
- # config.warnings = true
93
-
94
- # Many RSpec users commonly either run the entire suite or an individual
95
- # file, and it's useful to allow more verbose output when running an
96
- # individual spec file.
97
- if config.files_to_run.one?
98
- # Use the documentation formatter for detailed output,
99
- # unless a formatter has already been configured
100
- # (e.g. via a command-line flag).
101
- config.default_formatter = "doc"
102
- end
103
-
104
- # Print the 10 slowest examples and example groups at the
105
- # end of the spec run, to help surface which specs are running
106
- # particularly slow.
107
- # config.profile_examples = 10
108
-
109
- # Run specs in random order to surface order dependencies. If you find an
110
- # order dependency and want to debug it, you can fix the order by providing
111
- # the seed, which is printed after each run.
112
- # --seed 1234
113
- # config.order = :random
114
-
115
- # Seed global randomization in this process using the `--seed` CLI option.
116
- # Setting this allows you to use `--seed` to deterministically reproduce
117
- # test failures related to randomization by passing the same `--seed` value
118
- # as the one that triggered the failure.
119
- # Kernel.srand config.seed
120
- end
121
- end
@@ -1,292 +0,0 @@
1
- require_relative '../../lib/storyblok/client'
2
- require_relative '../../lib/storyblok/cache/redis'
3
- require 'redis'
4
- require 'spec_helper'
5
-
6
- describe Storyblok::Client do
7
- subject { described_class.new(token: token, version: version) }
8
- let(:subject_v1) { described_class.new(api_version: 1, token: token, version: version) }
9
-
10
- context "V2" do
11
- context "When querying CDN Content" do
12
-
13
- context "With token defined" do
14
- let(:token) { '<SPACE_PUBLIC_TOKEN>' }
15
-
16
- context "When querying stories" do
17
-
18
- context "When querying the published version" do
19
- let(:version) { 'published' }
20
-
21
- context "when querying an existent story by slug" do
22
- it "returns a story", :vcr do
23
- expect(subject.story('simple_content')['data']).to eq({
24
- "story"=> {
25
- "name"=> "simple_content",
26
- "created_at"=> "2020-08-20T18:01:55.065Z",
27
- "published_at"=> "2021-11-11T20:16:01.847Z",
28
- "id"=> 18409805,
29
- "uuid"=> "fe520269-b092-482c-94c4-8028eb81af41",
30
- "content"=> {
31
- "_uid"=> "ae111a76-84b7-43cc-a6a0-77a70de1b6f4",
32
- "component"=> "SimpleTextContentType",
33
- "SimpleText"=> "Simple Content from a Simple Text PUBLISHED VERSION"
34
- },
35
- "slug"=> "simple_content",
36
- "full_slug"=> "simple_content",
37
- "sort_by_date"=> nil,
38
- "position"=> 0,
39
- "tag_list"=> [
40
- "tag_out_of_any_folder"
41
- ],
42
- "is_startpage"=> false,
43
- "parent_id"=> 0,
44
- "meta_data"=> nil,
45
- "group_id"=> "f905f0f0-569e-4036-bcef-1479e5088956",
46
- "first_published_at"=> "2020-08-20T18:03:33.000Z",
47
- "release_id"=> nil,
48
- "lang"=> "default",
49
- "path"=> nil,
50
- "alternates"=> [],
51
- "default_full_slug"=> nil,
52
- "translated_slugs"=> nil
53
- },
54
- "cv"=> 1637246408,
55
- "rels"=> [],
56
- "links"=> []
57
- })
58
- end
59
-
60
- context "using resolve_relations", :vcr do
61
- it "returns a story with relations resolved", :vcr do
62
- expect(subject.story('content-resolve-relations', resolve_relations: 'options-list.options')['data']).to eq(
63
- {
64
- "story"=>{
65
- "name"=>"content resolve relations",
66
- "created_at"=>"2021-11-16T19:45:13.233Z",
67
- "published_at"=>"2021-11-18T14:40:08.858Z",
68
- "id"=>85924760,
69
- "uuid"=>"8926c2a6-e0ac-4afd-9132-0f7016699c16",
70
- "content"=>{
71
- "_uid"=>"7e385817-6fcb-4860-b510-f9b2bc56c7e6",
72
- "body"=>[
73
- {
74
- "_uid"=>"eaf49c11-e254-4609-af43-6840e1d52115",
75
- "options"=>[
76
- {
77
- "name"=>"simple_content_1",
78
- "created_at"=>"2020-08-20T18:45:52.758Z",
79
- "published_at"=>"2021-11-16T20:46:31.256Z",
80
- "id"=>18409845,
81
- "uuid"=>"542e19cc-ff06-4f19-ae64-a725c89e3406",
82
- "content"=>{
83
- "_uid"=>"e8ac85a4-91eb-42c2-8a18-b6e709b67e9d",
84
- "component"=>"SimpleTextContentType",
85
- "SimpleText"=>"Simple Content Draft"
86
- },
87
- "slug"=>"simple_content_1",
88
- "full_slug"=>"my-folder-slug/simple_content_1",
89
- "sort_by_date"=> nil,
90
- "position"=>0,
91
- "tag_list"=>[],
92
- "is_startpage"=>false,
93
- "parent_id"=>18409844,
94
- "meta_data"=> nil,
95
- "group_id"=>"943ee7f6-b002-44c6-8e26-41b21b6792ea",
96
- "first_published_at"=>"2020-08-20T18:46:39.840Z",
97
- "release_id"=> nil,
98
- "lang"=>"default",
99
- "path"=> nil,
100
- "alternates"=>[],
101
- "default_full_slug"=> nil,
102
- "translated_slugs"=> nil
103
- }
104
- ],
105
- "component"=>"options-list"
106
- }
107
- ],
108
- "component"=>"page"
109
- },
110
- "slug"=>"content-resolve-relations",
111
- "full_slug"=>"content-resolve-relations",
112
- "sort_by_date"=> nil,
113
- "position"=>-100,
114
- "tag_list"=>[],
115
- "is_startpage"=>false,
116
- "parent_id"=>0,
117
- "meta_data"=> nil,
118
- "group_id"=>"5f656b63-f64a-4648-aed8-b9ac2ea069e5",
119
- "first_published_at"=>"2021-11-16T20:28:35.000Z",
120
- "release_id"=> nil,
121
- "lang"=>"default",
122
- "path"=> nil,
123
- "alternates"=>[],
124
- "default_full_slug"=> nil,
125
- "translated_slugs"=> nil
126
- },
127
- "cv"=>1637246408,
128
- "rels"=>[
129
- {
130
- "name"=>"simple_content_1",
131
- "created_at"=>"2020-08-20T18:45:52.758Z",
132
- "published_at"=>"2021-11-16T20:46:31.256Z",
133
- "id"=>18409845,
134
- "uuid"=>"542e19cc-ff06-4f19-ae64-a725c89e3406",
135
- "content"=>{
136
- "_uid"=>"e8ac85a4-91eb-42c2-8a18-b6e709b67e9d",
137
- "component"=>"SimpleTextContentType",
138
- "SimpleText"=>"Simple Content Draft"
139
- },
140
- "slug"=>"simple_content_1",
141
- "full_slug"=>"my-folder-slug/simple_content_1",
142
- "sort_by_date"=> nil,
143
- "position"=>0,
144
- "tag_list"=>[],
145
- "is_startpage"=>false,
146
- "parent_id"=>18409844,
147
- "meta_data"=> nil,
148
- "group_id"=>"943ee7f6-b002-44c6-8e26-41b21b6792ea",
149
- "first_published_at"=>"2020-08-20T18:46:39.840Z",
150
- "release_id"=> nil,
151
- "lang"=>"default",
152
- "path"=> nil,
153
- "alternates"=>[],
154
- "default_full_slug"=> nil,
155
- "translated_slugs"=> nil
156
- }
157
- ],
158
- "links"=>[]
159
- }
160
- )
161
- end
162
- end
163
-
164
- context "using resolve_links", :vcr do
165
- it "returns a story with links resolved" do
166
- expect(subject.story('content-resolve-links', resolve_links: 1)['data']).to eq({
167
- "story"=> {
168
- "name"=> "content resolve links",
169
- "created_at"=> "2021-11-18T17:43:08.695Z",
170
- "published_at"=> "2021-11-18T19:23:22.657Z",
171
- "id"=> 86436757,
172
- "uuid"=> "e93f2707-775c-41d4-8ad5-413975318d93",
173
- "content"=> {
174
- "_uid"=> "d8e13705-ddf8-4f4f-8432-d3baece5ec23",
175
- "body"=> [],
176
- "component"=> "page",
177
- "link_to_story"=> {
178
- "id"=> "fe520269-b092-482c-94c4-8028eb81af41",
179
- "url"=> "",
180
- "anchor"=> "",
181
- "linktype"=> "story",
182
- "fieldtype"=> "multilink",
183
- "cached_url"=> "simple_content",
184
- "story"=> {
185
- "name"=> "simple_content",
186
- "created_at"=> "2020-08-20T18:01:55.065Z",
187
- "published_at"=> "2021-11-11T20:16:01.847Z",
188
- "id"=> 18409805,
189
- "uuid"=> "fe520269-b092-482c-94c4-8028eb81af41",
190
- "content"=> {
191
- "_uid"=> "ae111a76-84b7-43cc-a6a0-77a70de1b6f4",
192
- "component"=> "SimpleTextContentType",
193
- "SimpleText"=> "Simple Content from a Simple Text PUBLISHED VERSION"
194
- },
195
- "slug"=> "simple_content",
196
- "full_slug"=> "simple_content",
197
- "sort_by_date"=> nil,
198
- "position"=> 0,
199
- "tag_list"=> [
200
- "tag_out_of_any_folder"
201
- ],
202
- "is_startpage"=> false,
203
- "parent_id"=> 0,
204
- "meta_data"=> nil,
205
- "group_id"=> "f905f0f0-569e-4036-bcef-1479e5088956",
206
- "first_published_at"=> "2020-08-20T18:03:33.000Z",
207
- "release_id"=> nil,
208
- "lang"=> "default",
209
- "path"=> nil,
210
- "alternates"=> [],
211
- "default_full_slug"=> nil,
212
- "translated_slugs"=> nil
213
- }
214
- },
215
- "link_to_story_2"=> {
216
- "id"=> "",
217
- "url"=> "",
218
- "linktype"=> "url",
219
- "fieldtype"=> "multilink",
220
- "cached_url"=> ""
221
- }
222
- },
223
- "slug"=> "content-resolve-links",
224
- "full_slug"=> "content-resolve-links",
225
- "sort_by_date"=> nil,
226
- "position"=> -110,
227
- "tag_list"=> [],
228
- "is_startpage"=> false,
229
- "parent_id"=> 0,
230
- "meta_data"=> nil,
231
- "group_id"=> "7f03b8db-6237-48b4-abd7-6bc8a0f459c8",
232
- "first_published_at"=> "2021-11-18T17:51:19.000Z",
233
- "release_id"=> nil,
234
- "lang"=> "default",
235
- "path"=> nil,
236
- "alternates"=> [],
237
- "default_full_slug"=> nil,
238
- "translated_slugs"=> nil
239
- },
240
- "cv"=> 1637263402,
241
- "rels"=> [],
242
- "links"=> [
243
- {
244
- "name"=> "simple_content",
245
- "created_at"=> "2020-08-20T18:01:55.065Z",
246
- "published_at"=> "2021-11-11T20:16:01.847Z",
247
- "id"=> 18409805,
248
- "uuid"=> "fe520269-b092-482c-94c4-8028eb81af41",
249
- "content"=> {
250
- "_uid"=> "ae111a76-84b7-43cc-a6a0-77a70de1b6f4",
251
- "component"=> "SimpleTextContentType",
252
- "SimpleText"=> "Simple Content from a Simple Text PUBLISHED VERSION"
253
- },
254
- "slug"=> "simple_content",
255
- "full_slug"=> "simple_content",
256
- "sort_by_date"=> nil,
257
- "position"=> 0,
258
- "tag_list"=> [
259
- "tag_out_of_any_folder"
260
- ],
261
- "is_startpage"=> false,
262
- "parent_id"=> 0,
263
- "meta_data"=> nil,
264
- "group_id"=> "f905f0f0-569e-4036-bcef-1479e5088956",
265
- "first_published_at"=> "2020-08-20T18:03:33.000Z",
266
- "release_id"=> nil,
267
- "lang"=> "default",
268
- "path"=> nil,
269
- "alternates"=> [],
270
- "default_full_slug"=> nil,
271
- "translated_slugs"=> nil
272
- }
273
- ]
274
- })
275
- end
276
- end
277
-
278
- context "comparing v2 and v1 to assure backward compatibility", :vcr do
279
- it "returns difference in translated_slug default value" do
280
- v2_content = subject.story("content-resolve-relations", resolve_relations: "options-list.options", cv: 1)["data"]["story"]
281
- v1_content = subject_v1.story("content-resolve-relations", resolve_relations: "options-list.options", cv: 1)["data"]["story"]
282
-
283
- expect(Hashdiff.diff(v2_content, v1_content)).to eq [["~", "content.body[0].options[0].translated_slugs", nil, []], ["~", "translated_slugs", nil, []]]
284
- end
285
- end
286
- end
287
- end
288
- end
289
- end
290
- end
291
- end
292
- end
data/storyblok.gemspec DELETED
@@ -1,27 +0,0 @@
1
- require File.expand_path('../lib/storyblok/version', __FILE__)
2
-
3
- Gem::Specification.new do |gem|
4
- gem.name = 'storyblok'
5
- gem.version = Storyblok::VERSION
6
- gem.summary = 'storyblok'
7
- gem.description = 'Ruby client for the https://www.storyblok.com management and content delivery API'
8
- gem.license = 'MIT'
9
- gem.authors = ['Storyblok (Alexander Feiglstorfer)']
10
- gem.email = 'it@storyblok.com'
11
- gem.homepage = 'https://github.com/storyblok/storyblok-ruby'
12
-
13
- gem.files = Dir['{**/}{.*,*}'].select { |path| File.file?(path) && !path.start_with?('pkg') && !path.end_with?('.gem') }
14
- gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
15
- gem.test_files = gem.files.grep(%r{^spec/})
16
- gem.require_paths = ['lib']
17
-
18
- gem.add_dependency 'rest-client', '>= 1.8.0', '< 3'
19
- gem.add_dependency 'storyblok-richtext-renderer', '>= 0.0.4', '< 1'
20
-
21
- gem.add_development_dependency 'bundler', '~> 1.5'
22
- gem.add_development_dependency 'hashdiff', '~> 1.0', '>= 1.0.1'
23
- gem.add_development_dependency 'rspec', '~> 3'
24
- gem.add_development_dependency 'webmock', '~> 0'
25
- gem.add_development_dependency 'vcr', '~> 0'
26
- gem.add_development_dependency 'simplecov', '< 0.18.0'
27
- end