pageflow-support 13.5.0 → 13.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5bcd9468297749bb25a96fb57e665e7c8c8150a66fa93899d168e910745a8576
4
- data.tar.gz: ef1c49e58888f9c989f969f594baef5b6337487e8fc9765b709595df33bd4b19
3
+ metadata.gz: 1e237e3c395bafa9b407240566bbdd43148b54a9fc2f7e0fbe285d8a80d839ed
4
+ data.tar.gz: 18c04c9fa9b0ac8f7b82f33fb5aad83d96d1a0ac54b1d1e32734290e1eb3e5c1
5
5
  SHA512:
6
- metadata.gz: 76f6dec7705867509a53393b38b673fc65981456e94819740775b0e2d4c171b85823d310ddedb20152460b35215a7ff424661f0baa8fa79d446a6b8d062749d2
7
- data.tar.gz: ecb20b6e47deed0f321a3c53aa795385656cf4361430fa9e466e13404038245dcdb0f44dfa83661282c12041ad9680f34f136469ef2c6829ad5131d7281eac28
6
+ metadata.gz: 81b3ab9faa2059cc990de500197deaba30fb0bee3b8688af26050684a236ccebc8b86ce997fed06daeb2fe217c3bc6018cc84c4f1e0b1bed86982a33aeb9abe4
7
+ data.tar.gz: 150194efb591b54ffe3a32b6688a3d153d1d7c4e999046776b5fd4b8aaeaf82e1f4247f1deb8c3a76c389a32b98049a36ba8d3b580d459998b00d31872d52bea
@@ -0,0 +1,58 @@
1
+ require 'pageflow/global_config_api_test_helper'
2
+ require 'pageflow/test_page_type'
3
+
4
+ module Pageflow
5
+ module Lint
6
+ # @api private
7
+ module FileType
8
+ def self.lint(name, create_file_type:, create_file:)
9
+ GlobalConfigApiTestHelper.setup
10
+
11
+ RSpec.describe "file type #{name}", type: :helper do
12
+ let(:file_type, &create_file_type)
13
+
14
+ let(:file, &create_file)
15
+
16
+ before do
17
+ pageflow_configure do |config|
18
+ page_type = TestPageType.new(name: :test,
19
+ file_types: [file_type])
20
+ config.page_types.clear
21
+ config.page_types.register(page_type)
22
+ end
23
+ end
24
+
25
+ it 'renders seed json without error' do
26
+ expect {
27
+ helper.extend(FilesHelper)
28
+ helper.render(partial: 'pageflow/files/file',
29
+ formats: [:json],
30
+ locals: {
31
+ file: UsedFile.new(file, FileUsage.new),
32
+ file_type: file_type
33
+ })
34
+ }.not_to raise_error
35
+ end
36
+
37
+ it 'renders editor json without error' do
38
+ helper.extend(FilesHelper)
39
+ helper.render(partial: 'pageflow/editor/files/file',
40
+ formats: [:json],
41
+ locals: {
42
+ file: UsedFile.new(file, FileUsage.new),
43
+ file_type: file_type
44
+ })
45
+ end
46
+
47
+ it 'provides css_background_image_urls that returns hash if present' do
48
+ if file_type.css_background_image_urls
49
+ result = file_type.css_background_image_urls.call(file)
50
+
51
+ expect(result).to be_a(Hash)
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,51 @@
1
+ require 'pageflow/render_page_test_helper'
2
+
3
+ module Pageflow
4
+ module Lint
5
+ # @api private
6
+ module PageType
7
+ def self.lint(page_type)
8
+ GlobalConfigApiTestHelper.setup
9
+
10
+ RSpec.describe "page type #{page_type.name}", type: :helper do
11
+ include RenderPageTestHelper
12
+
13
+ before do
14
+ pageflow_configure do |config|
15
+ config.page_types.register(page_type)
16
+ end
17
+ end
18
+
19
+ it 'renderer page template without error' do
20
+ expect {
21
+ render_page(page_type)
22
+ }.not_to raise_error
23
+ end
24
+
25
+ it 'renders json seed template without error' do
26
+ helper.extend(PageTypesHelper)
27
+
28
+ expect {
29
+ JbuilderTemplate.encode(helper) do |json|
30
+ helper.page_type_json_seed(json, page_type)
31
+ end
32
+ }.not_to raise_error
33
+ end
34
+
35
+ it 'defines all required translations' do
36
+ expect(page_type.translation_key).to have_translation
37
+ expect(page_type.description_translation_key).to have_translation
38
+ expect(page_type.category_translation_key).to have_translation
39
+ expect(page_type.help_entry_translation_key).to have_translation
40
+ end
41
+
42
+ matcher :have_translation do
43
+ match do |key|
44
+ I18n.t(key, exception_handler: ->(*) { false })
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
data/pageflow/lint.rb CHANGED
@@ -1,6 +1,9 @@
1
1
  require 'pageflow/global_config_api_test_helper'
2
2
  require 'pageflow/test_page_type'
3
3
 
4
+ require 'pageflow/lint/file_type'
5
+ require 'pageflow/lint/page_type'
6
+
4
7
  module Pageflow
5
8
  # Shared examples providing integration level specs for Pageflow
6
9
  # components commonly defined by plugins.
@@ -24,53 +27,26 @@ module Pageflow
24
27
  # create_file_type: -> { SomePlugin.file_type },
25
28
  # create_file: -> { create(:some_file) })
26
29
  # end
27
- def self.file_type(name, create_file_type:, create_file:)
28
- GlobalConfigApiTestHelper.setup
29
-
30
- RSpec.describe "file type #{name}", type: :helper do
31
- let(:file_type, &create_file_type)
32
-
33
- let(:file, &create_file)
34
-
35
- before do
36
- pageflow_configure do |config|
37
- page_type = TestPageType.new(name: :test,
38
- file_types: [file_type])
39
- config.page_types.clear
40
- config.page_types.register(page_type)
41
- end
42
- end
43
-
44
- it 'renders seed json without error' do
45
- expect {
46
- helper.extend(FilesHelper)
47
- helper.render(partial: 'pageflow/files/file',
48
- formats: [:json],
49
- locals: {
50
- file: UsedFile.new(file, FileUsage.new),
51
- file_type: file_type
52
- })
53
- }.not_to raise_error
54
- end
55
-
56
- it 'renders editor json without error' do
57
- helper.extend(FilesHelper)
58
- helper.render(partial: 'pageflow/editor/files/file',
59
- formats: [:json],
60
- locals: {
61
- file: UsedFile.new(file, FileUsage.new),
62
- file_type: file_type
63
- })
64
- end
65
-
66
- it 'provides css_background_image_urls that returns hash if present' do
67
- if file_type.css_background_image_urls
68
- result = file_type.css_background_image_urls.call(file)
30
+ def self.file_type(*args)
31
+ Lint::FileType.lint(*args)
32
+ end
69
33
 
70
- expect(result).to be_a(Hash)
71
- end
72
- end
73
- end
34
+ # Contract specs for page types
35
+ #
36
+ # @param page_type [PageType] Page type to run specs for
37
+ #
38
+ # @since 13.6
39
+ #
40
+ # @example
41
+ #
42
+ # require 'spec_helper'
43
+ # require 'pageflow/lint'
44
+ #
45
+ # module SomePlugin
46
+ # Pageflow::Lint.page_type(SomePLugin.page_type)
47
+ # end
48
+ def self.page_type(*args)
49
+ Lint::PageType.lint(*args)
74
50
  end
75
51
  end
76
52
  end
@@ -0,0 +1,25 @@
1
+ require 'pageflow/global_config_api_test_helper'
2
+ require 'factory_bot_rails'
3
+
4
+ module Pageflow
5
+ module RenderPageTestHelper
6
+ def render_page(page_type, configuration = {})
7
+ page = FactoryBot.create(:page, template: page_type.name, configuration: configuration)
8
+ revision = page.chapter.storyline.revision
9
+ entry = PublishedEntry.new(revision.entry, revision)
10
+
11
+ helper.extend(InfoBoxHelper)
12
+ helper.extend(BackgroundImageHelper)
13
+ helper.extend(EntryJsonSeedHelper)
14
+ helper.extend(PageBackgroundAssetHelper)
15
+ helper.extend(PagesHelper)
16
+ helper.extend(VideoFilesHelper)
17
+
18
+ page_type.view_helpers.each do |page_type_helper|
19
+ helper.extend(page_type_helper)
20
+ end
21
+
22
+ helper.render_page_template(page, entry: entry)
23
+ end
24
+ end
25
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pageflow-support
3
3
  version: !ruby/object:Gem::Version
4
- version: 13.5.0
4
+ version: 13.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Codevise Solutions Ltd
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-05 00:00:00.000000000 Z
11
+ date: 2019-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pageflow
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 13.5.0
19
+ version: 13.6.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 13.5.0
26
+ version: 13.6.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: mysql2
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -53,7 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.7.0
55
55
  - !ruby/object:Gem::Dependency
56
- name: factory_bot
56
+ name: factory_bot_rails
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
@@ -189,7 +189,10 @@ files:
189
189
  - pageflow/dummy/templates/test_theme_preview.png
190
190
  - pageflow/global_config_api_test_helper.rb
191
191
  - pageflow/lint.rb
192
+ - pageflow/lint/file_type.rb
193
+ - pageflow/lint/page_type.rb
192
194
  - pageflow/rails_version.rb
195
+ - pageflow/render_page_test_helper.rb
193
196
  - pageflow/support.rb
194
197
  - pageflow/test_page_type.rb
195
198
  homepage: https://pageflow.io