pageflow-support 13.0.0.beta6 → 13.0.0.beta7

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: b49a8322d424c94312154698aef0637c062d86af8d812b36791daa0749348aef
4
- data.tar.gz: 3bdf4417c75df1671599d7608513b934c0e4a2c6bdb42024e496e70b11f67690
3
+ metadata.gz: 63d9a73a001f922496a2eda12bee4b8ea1b75a8914821f32ee2b89a7798d2206
4
+ data.tar.gz: e363ff87b846199f7a8e2eb4199916266021370405d76b8a866042b0bb321585
5
5
  SHA512:
6
- metadata.gz: c0bb5aabcace4cc306c14c8477d064bff4199d3f43d03e329fbe3f7e6dae988cd1a7d8f039fb7ddd5dc4e6cf2bdb240eaa8af0f05d8c2ab7008ffa6d4b71832d
7
- data.tar.gz: 27d809d38f309699edd02ccbcb678d3073ecb43829f9ca4134bd81ab8998cd396ab7adb56e9100cd8093922f0d862c85c0b15664c9a8bb0b71a666c428f8c69b
6
+ metadata.gz: 7af7609a6f6729b49dc23353a1d28b49302ed245ef7bfbe74d09a52e620b03d1af4a4de61a78685bcec73620bdc640d5567a0032c26e15b0188c3c94078babe5
7
+ data.tar.gz: fe9e865351dab7a67f3747671dfbe9942c941640bf234d98b5637d662e07bf5369c4c1b2c791f00ffe51fe49f4caf3cf5c7c1aa301fbc2c697a10915e4c9ec4e
@@ -1,7 +1,28 @@
1
1
  class CreateTestHostedFile < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :test_hosted_files do |t|
4
- Pageflow::HostedFile.columns(t)
4
+ t.belongs_to(:entry, index: true)
5
+ t.belongs_to(:uploader, index: true)
6
+
7
+ t.integer(:parent_file_id)
8
+ t.string(:parent_file_model_type)
9
+
10
+ t.string(:state)
11
+ t.string(:rights)
12
+
13
+ t.string(:attachment_on_filesystem_file_name)
14
+ t.string(:attachment_on_filesystem_content_type)
15
+ t.integer(:attachment_on_filesystem_file_size, limit: 8)
16
+ t.datetime(:attachment_on_filesystem_updated_at)
17
+
18
+ t.string(:attachment_on_s3_file_name)
19
+ t.string(:attachment_on_s3_content_type)
20
+ t.integer(:attachment_on_s3_file_size, limit: 8)
21
+ t.datetime(:attachment_on_s3_updated_at)
22
+
23
+ t.timestamps
24
+
25
+ t.string :custom
5
26
  end
6
27
  end
7
28
  end
@@ -0,0 +1,53 @@
1
+ module Pageflow
2
+ # This helper allows to register a custom configure block that shall
3
+ # be executed in the context of a test. This is required when testing
4
+ # functionality that calls `Pageflow.config_for`, which builds up a
5
+ # new configuration object. Simply calling `Pageflow.configure` from
6
+ # inside a test does not work since there is no easy way to tear it
7
+ # down after the test.
8
+ #
9
+ # @since edge
10
+ module GlobalConfigApiTestHelper
11
+ mattr_accessor :custom_configure_block
12
+
13
+ # Call as part of test setup to add fixture configuration. Can be
14
+ # thought of as a test specific `Pageflow.configure`. Can only be
15
+ # used once per spec (including `before` blocks etc.)
16
+ #
17
+ # @example
18
+ #
19
+ # it 'works when the page type is registered'
20
+ # pageflow_configure do |config|
21
+ # config.page_types.register(Some.page_type)
22
+ # end
23
+ #
24
+ # # ...
25
+ # end
26
+ def pageflow_configure(&block)
27
+ GlobalConfigApiTestHelper.custom_configure_block = block
28
+ Pageflow.configure!
29
+ end
30
+
31
+ # Call from plugin test suite to make the `pageflow_configure`
32
+ # helper available and RSpec hooks to apply configuration changes.
33
+ def self.setup
34
+ return if @setup
35
+ @setup = true
36
+
37
+ RSpec.configure do |config|
38
+ config.include(GlobalConfigApiTestHelper)
39
+
40
+ config.before(:suite) do
41
+ Pageflow.configure do |pageflow_config|
42
+ GlobalConfigApiTestHelper.custom_configure_block&.call(pageflow_config)
43
+ end
44
+ end
45
+
46
+ config.before do
47
+ GlobalConfigApiTestHelper.custom_configure_block = nil
48
+ Pageflow.configure!
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,76 @@
1
+ require 'pageflow/global_config_api_test_helper'
2
+ require 'pageflow/test_page_type'
3
+
4
+ module Pageflow
5
+ # Shared examples providing integration level specs for Pageflow
6
+ # components commonly defined by plugins.
7
+ #
8
+ # @since edge
9
+ module Lint
10
+ # Ensure file type json partials render correctly.
11
+ #
12
+ # @param name [String] File type name to use in spec descriptions
13
+ # @param create_file_type [#call] Proc creating the file type to test
14
+ # @param create_file [#call] Proc creating a fixture file of the
15
+ # file type
16
+ #
17
+ # @example
18
+ #
19
+ # require 'spec_helper'
20
+ # require 'pageflow/lint'
21
+ #
22
+ # module SomePlugin
23
+ # Pageflow::Lint.file_type('some file type',
24
+ # create_file_type: -> { SomePlugin.file_type },
25
+ # create_file: -> { create(:some_file) })
26
+ # 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)
69
+
70
+ expect(result).to be_a(Hash)
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,12 @@
1
+ require 'pageflow/page_type'
2
+
3
+ module Pageflow
4
+ class TestPageType < PageType
5
+ attr_reader :name, :file_types
6
+
7
+ def initialize(name:, file_types: [])
8
+ @name = name
9
+ @file_types = file_types
10
+ end
11
+ end
12
+ 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.0.0.beta6
4
+ version: 13.0.0.beta7
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: 2018-10-18 00:00:00.000000000 Z
11
+ date: 2018-10-23 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.0.0.beta6
19
+ version: 13.0.0.beta7
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.0.0.beta6
26
+ version: 13.0.0.beta7
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: mysql2
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -187,8 +187,11 @@ files:
187
187
  - pageflow/dummy/templates/database.yml
188
188
  - pageflow/dummy/templates/test_theme.scss
189
189
  - pageflow/dummy/templates/test_theme_preview.png
190
+ - pageflow/global_config_api_test_helper.rb
191
+ - pageflow/lint.rb
190
192
  - pageflow/rails_version.rb
191
193
  - pageflow/support.rb
194
+ - pageflow/test_page_type.rb
192
195
  homepage: https://pageflow.io
193
196
  licenses: []
194
197
  metadata: {}