alchemy_cms 7.0.0.pre.a → 7.0.0.pre.b
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/brakeman-analysis.yml +2 -2
- data/.github/workflows/ci.yml +7 -7
- data/.github/workflows/lint.yml +17 -0
- data/.hound.yml +2 -3
- data/.rubocop.yml +4 -350
- data/.standard.yml +3 -0
- data/CHANGELOG.md +29 -0
- data/Gemfile +3 -1
- data/README.md +7 -9
- data/Rakefile +1 -1
- data/alchemy_cms.gemspec +2 -1
- data/app/assets/javascripts/alchemy/admin.js +0 -1
- data/app/assets/javascripts/alchemy/alchemy.link_dialog.js.coffee +6 -1
- data/app/components/alchemy/ingredients/audio_view.rb +37 -0
- data/app/components/alchemy/ingredients/base_view.rb +38 -0
- data/app/components/alchemy/ingredients/boolean_view.rb +13 -0
- data/app/components/alchemy/ingredients/datetime_view.rb +22 -0
- data/app/components/alchemy/ingredients/file_view.rb +40 -0
- data/app/components/alchemy/ingredients/headline_view.rb +20 -0
- data/app/components/alchemy/ingredients/html_view.rb +9 -0
- data/app/components/alchemy/ingredients/link_view.rb +25 -0
- data/app/components/alchemy/ingredients/node_view.rb +11 -0
- data/app/components/alchemy/ingredients/page_view.rb +15 -0
- data/app/components/alchemy/ingredients/picture_view.rb +108 -0
- data/app/components/alchemy/ingredients/richtext_view.rb +22 -0
- data/app/components/alchemy/ingredients/select_view.rb +6 -0
- data/app/components/alchemy/ingredients/text_view.rb +41 -0
- data/app/components/alchemy/ingredients/video_view.rb +39 -0
- data/app/controllers/alchemy/admin/attachments_controller.rb +3 -3
- data/app/controllers/alchemy/admin/base_controller.rb +7 -7
- data/app/controllers/alchemy/admin/clipboard_controller.rb +2 -2
- data/app/controllers/alchemy/admin/elements_controller.rb +26 -11
- data/app/controllers/alchemy/admin/languages_controller.rb +1 -1
- data/app/controllers/alchemy/admin/nodes_controller.rb +2 -2
- data/app/controllers/alchemy/admin/pages_controller.rb +10 -10
- data/app/controllers/alchemy/admin/pictures_controller.rb +14 -14
- data/app/controllers/alchemy/admin/resources_controller.rb +27 -28
- data/app/controllers/alchemy/admin/styleguide_controller.rb +1 -0
- data/app/controllers/alchemy/admin/tags_controller.rb +11 -11
- data/app/controllers/alchemy/api/base_controller.rb +2 -2
- data/app/controllers/alchemy/api/elements_controller.rb +11 -11
- data/app/controllers/alchemy/api/ingredients_controller.rb +1 -1
- data/app/controllers/alchemy/api/nodes_controller.rb +1 -1
- data/app/controllers/alchemy/api/pages_controller.rb +11 -11
- data/app/controllers/alchemy/attachments_controller.rb +3 -3
- data/app/controllers/alchemy/base_controller.rb +1 -1
- data/app/controllers/alchemy/messages_controller.rb +9 -9
- data/app/controllers/alchemy/pages_controller.rb +8 -19
- data/app/controllers/concerns/alchemy/admin/archive_overlay.rb +1 -0
- data/app/controllers/concerns/alchemy/admin/uploader_responses.rb +5 -7
- data/app/controllers/concerns/alchemy/legacy_page_redirects.rb +5 -5
- data/app/decorators/alchemy/element_editor.rb +4 -4
- data/app/decorators/alchemy/ingredient_editor.rb +6 -6
- data/app/helpers/alchemy/admin/attachments_helper.rb +1 -1
- data/app/helpers/alchemy/admin/base_helper.rb +21 -22
- data/app/helpers/alchemy/admin/elements_helper.rb +1 -1
- data/app/helpers/alchemy/admin/form_helper.rb +1 -1
- data/app/helpers/alchemy/admin/navigation_helper.rb +7 -7
- data/app/helpers/alchemy/admin/pages_helper.rb +2 -2
- data/app/helpers/alchemy/admin/tags_helper.rb +3 -3
- data/app/helpers/alchemy/base_helper.rb +2 -2
- data/app/helpers/alchemy/elements_block_helper.rb +9 -7
- data/app/helpers/alchemy/elements_helper.rb +12 -12
- data/app/helpers/alchemy/pages_helper.rb +11 -11
- data/app/helpers/alchemy/url_helper.rb +1 -1
- data/app/mailers/alchemy/messages_mailer.rb +1 -1
- data/app/models/alchemy/attachment.rb +6 -6
- data/app/models/alchemy/base_record.rb +1 -0
- data/app/models/alchemy/eager_loading.rb +6 -6
- data/app/models/alchemy/element/definitions.rb +1 -1
- data/app/models/alchemy/element/element_ingredients.rb +3 -3
- data/app/models/alchemy/element.rb +2 -2
- data/app/models/alchemy/elements_repository.rb +1 -1
- data/app/models/alchemy/image_cropper_settings.rb +2 -2
- data/app/models/alchemy/ingredient.rb +14 -12
- data/app/models/alchemy/ingredient_validator.rb +1 -1
- data/app/models/alchemy/ingredients/datetime.rb +1 -1
- data/app/models/alchemy/ingredients/file.rb +5 -5
- data/app/models/alchemy/ingredients/headline.rb +4 -4
- data/app/models/alchemy/ingredients/picture.rb +27 -9
- data/app/models/alchemy/ingredients/richtext.rb +15 -12
- data/app/models/alchemy/ingredients/text.rb +6 -6
- data/app/models/alchemy/language/code.rb +1 -1
- data/app/models/alchemy/language.rb +4 -4
- data/app/models/alchemy/legacy_page_url.rb +1 -1
- data/app/models/alchemy/node.rb +2 -2
- data/app/models/alchemy/page/page_elements.rb +14 -14
- data/app/models/alchemy/page/page_naming.rb +4 -4
- data/app/models/alchemy/page/page_natures.rb +1 -1
- data/app/models/alchemy/page/page_scopes.rb +5 -5
- data/app/models/alchemy/page.rb +11 -11
- data/app/models/alchemy/picture/calculations.rb +2 -2
- data/app/models/alchemy/picture/transformations.rb +2 -2
- data/app/models/alchemy/picture/url.rb +4 -4
- data/app/models/alchemy/picture.rb +11 -10
- data/app/models/alchemy/picture_thumb/create.rb +1 -1
- data/app/models/alchemy/picture_thumb.rb +1 -1
- data/app/models/alchemy/picture_variant.rb +2 -3
- data/app/models/alchemy/tag.rb +8 -0
- data/app/models/concerns/alchemy/picture_thumbnails.rb +6 -6
- data/app/serializers/alchemy/base_serializer.rb +1 -1
- data/app/serializers/alchemy/page_tree_serializer.rb +7 -7
- data/app/services/alchemy/duplicate_element.rb +3 -3
- data/app/services/alchemy/tag_validations.rb +1 -1
- data/app/views/alchemy/admin/elements/_element.html.erb +3 -0
- data/app/views/alchemy/admin/pages/edit.html.erb +0 -3
- data/app/views/alchemy/admin/pages/update.js.erb +10 -4
- data/app/views/alchemy/admin/pictures/_infos.html.erb +1 -1
- data/app/views/alchemy/ingredients/_audio_view.html.erb +1 -14
- data/app/views/alchemy/ingredients/_boolean_view.html.erb +1 -1
- data/app/views/alchemy/ingredients/_datetime_view.html.erb +3 -9
- data/app/views/alchemy/ingredients/_file_view.html.erb +3 -16
- data/app/views/alchemy/ingredients/_headline_view.html.erb +4 -10
- data/app/views/alchemy/ingredients/_html_view.html.erb +1 -1
- data/app/views/alchemy/ingredients/_link_view.html.erb +4 -9
- data/app/views/alchemy/ingredients/_node_view.html.erb +1 -1
- data/app/views/alchemy/ingredients/_page_view.html.erb +1 -4
- data/app/views/alchemy/ingredients/_picture_view.html.erb +4 -5
- data/app/views/alchemy/ingredients/_richtext_editor.html.erb +11 -2
- data/app/views/alchemy/ingredients/_richtext_view.html.erb +3 -3
- data/app/views/alchemy/ingredients/_select_view.html.erb +1 -1
- data/app/views/alchemy/ingredients/_text_view.html.erb +3 -19
- data/app/views/alchemy/ingredients/_video_view.html.erb +3 -18
- data/app/views/alchemy/ingredients/shared/_link_tools.html.erb +1 -0
- data/app/views/alchemy/ingredients/shared/_picture_tools.html.erb +1 -0
- data/app/views/layouts/alchemy/admin.html.erb +7 -9
- data/bin/setup +37 -0
- data/bin/start +17 -0
- data/config/initializers/assets.rb +1 -0
- data/config/initializers/dragonfly.rb +1 -0
- data/config/initializers/mime_types.rb +1 -0
- data/config/initializers/mini_profiler.rb +1 -0
- data/config/initializers/simple_form.rb +3 -2
- data/config/locales/alchemy.en.yml +1 -1
- data/config/routes.rb +21 -20
- data/config/spring.rb +1 -0
- data/db/migrate/20230121212637_alchemy_six_point_one.rb +8 -8
- data/db/migrate/20230505132743_add_indexes_to_alchemy_pictures.rb +6 -0
- data/lib/alchemy/admin/locale.rb +3 -3
- data/lib/alchemy/admin/preview_url.rb +2 -2
- data/lib/alchemy/auth_accessors.rb +1 -1
- data/lib/alchemy/config.rb +1 -1
- data/lib/alchemy/controller_actions.rb +4 -4
- data/lib/alchemy/deprecation.rb +1 -0
- data/lib/alchemy/dragonfly/processors/thumbnail.rb +1 -1
- data/lib/alchemy/element_definition.rb +2 -2
- data/lib/alchemy/engine.rb +2 -1
- data/lib/alchemy/filetypes.rb +7 -7
- data/lib/alchemy/forms/builder.rb +4 -4
- data/lib/alchemy/i18n.rb +6 -4
- data/lib/alchemy/install/tasks.rb +2 -1
- data/lib/alchemy/name_conversions.rb +1 -1
- data/lib/alchemy/page_layout.rb +1 -1
- data/lib/alchemy/permissions.rb +5 -4
- data/lib/alchemy/resource.rb +10 -10
- data/lib/alchemy/resources_helper.rb +7 -7
- data/lib/alchemy/routing_constraints.rb +2 -2
- data/lib/alchemy/seeder.rb +12 -5
- data/lib/alchemy/shell.rb +2 -1
- data/lib/alchemy/taggable.rb +3 -2
- data/lib/alchemy/tasks/tidy.rb +1 -0
- data/lib/alchemy/test_support/capybara_helpers.rb +1 -1
- data/lib/alchemy/test_support/config_stubbing.rb +1 -0
- data/lib/alchemy/test_support/factories/element_factory.rb +4 -0
- data/lib/alchemy/test_support/factories/page_factory.rb +2 -2
- data/lib/alchemy/test_support/having_crop_action_examples.rb +9 -9
- data/lib/alchemy/test_support/having_picture_thumbnails_examples.rb +33 -33
- data/lib/alchemy/test_support/integration_helpers.rb +4 -3
- data/lib/alchemy/test_support/shared_contexts.rb +2 -1
- data/lib/alchemy/test_support/shared_dom_ids_examples.rb +9 -9
- data/lib/alchemy/test_support/shared_ingredient_examples.rb +12 -6
- data/lib/alchemy/test_support/shared_uploader_examples.rb +1 -0
- data/lib/alchemy/tinymce.rb +3 -26
- data/lib/alchemy/upgrader.rb +1 -0
- data/lib/alchemy/version.rb +1 -1
- data/lib/alchemy_cms.rb +1 -0
- data/lib/generators/alchemy/base.rb +3 -2
- data/lib/generators/alchemy/elements/elements_generator.rb +2 -1
- data/lib/generators/alchemy/ingredient/ingredient_generator.rb +1 -0
- data/lib/generators/alchemy/install/files/application.html.erb +1 -1
- data/lib/generators/alchemy/install/install_generator.rb +2 -1
- data/lib/generators/alchemy/module/module_generator.rb +1 -0
- data/lib/generators/alchemy/page_layouts/page_layouts_generator.rb +1 -0
- data/lib/generators/alchemy/site_layouts/site_layouts_generator.rb +1 -0
- data/lib/generators/alchemy/views/views_generator.rb +2 -1
- data/lib/tasks/alchemy/thumbnails.rake +5 -5
- data/lib/tasks/alchemy/tidy.rake +1 -0
- data/lib/tasks/alchemy/upgrade.rake +6 -5
- data/package/admin.js +2 -0
- data/package/dist/admin.js +3 -3
- data/package/dist/admin.js.map +4 -4
- data/package/src/datepicker.js +1 -0
- data/package/src/tinymce.js +142 -0
- data/package.json +2 -2
- metadata +39 -7
- data/app/assets/javascripts/alchemy/alchemy.tinymce.js.coffee +0 -93
- data/app/presenters/alchemy/picture_view.rb +0 -88
- data/app/views/alchemy/admin/pages/_tinymce_custom_config.html.erb +0 -10
data/lib/alchemy/seeder.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require "alchemy/shell"
|
3
4
|
|
4
5
|
module Alchemy
|
@@ -46,7 +47,7 @@ module Alchemy
|
|
46
47
|
contentpages.each do |page|
|
47
48
|
create_page(page, {
|
48
49
|
language: Alchemy::Language.default,
|
49
|
-
language_root: true
|
50
|
+
language_root: true
|
50
51
|
})
|
51
52
|
end
|
52
53
|
end
|
@@ -55,7 +56,7 @@ module Alchemy
|
|
55
56
|
desc "Seeding Alchemy layout pages from #{page_seeds_file}"
|
56
57
|
language = Alchemy::Language.default
|
57
58
|
layoutpages.each do |page|
|
58
|
-
create_page(page, {
|
59
|
+
create_page(page, {language: language})
|
59
60
|
end
|
60
61
|
end
|
61
62
|
|
@@ -82,7 +83,11 @@ module Alchemy
|
|
82
83
|
end
|
83
84
|
|
84
85
|
def page_yml
|
85
|
-
@_page_yml ||= YAML.
|
86
|
+
@_page_yml ||= YAML.safe_load(
|
87
|
+
page_seeds_file.read,
|
88
|
+
permitted_classes: [Date],
|
89
|
+
aliases: true
|
90
|
+
)
|
86
91
|
end
|
87
92
|
|
88
93
|
def contentpages
|
@@ -99,7 +104,9 @@ module Alchemy
|
|
99
104
|
|
100
105
|
def create_page(draft, attributes = {})
|
101
106
|
children = draft.delete("children") || []
|
102
|
-
page = Alchemy::Page.
|
107
|
+
page = Alchemy::Page.new(draft.merge(attributes))
|
108
|
+
page.versions.build
|
109
|
+
page.save!
|
103
110
|
log "Created page: #{page.name}"
|
104
111
|
children.each do |child|
|
105
112
|
create_page(child, parent: page, language: page.language)
|
@@ -119,7 +126,7 @@ module Alchemy
|
|
119
126
|
page_layout: default_language["page_layout"],
|
120
127
|
public: true,
|
121
128
|
default: true,
|
122
|
-
site: Alchemy::Site.default
|
129
|
+
site: Alchemy::Site.default
|
123
130
|
)
|
124
131
|
else
|
125
132
|
raise DefaultLanguageNotFoundError
|
data/lib/alchemy/shell.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require "thor/shell/color"
|
3
4
|
|
4
5
|
module Alchemy
|
@@ -10,7 +11,7 @@ module Alchemy
|
|
10
11
|
clear: Thor::Shell::Color::CLEAR,
|
11
12
|
green: Thor::Shell::Color::GREEN,
|
12
13
|
red: Thor::Shell::Color::RED,
|
13
|
-
yellow: Thor::Shell::Color::YELLOW
|
14
|
+
yellow: Thor::Shell::Color::YELLOW
|
14
15
|
}.freeze
|
15
16
|
|
16
17
|
def self.silence!
|
data/lib/alchemy/taggable.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Alchemy
|
3
4
|
# ActsAsTaggableOn to Gutentag interface compatibility module
|
4
5
|
# Include this module to add tagging support to your model.
|
@@ -28,11 +29,11 @@ module Alchemy
|
|
28
29
|
end
|
29
30
|
|
30
31
|
unless args[:match]
|
31
|
-
args
|
32
|
+
args[:match] = :all
|
32
33
|
end
|
33
34
|
|
34
35
|
if names.any?
|
35
|
-
args
|
36
|
+
args[:names] = names
|
36
37
|
end
|
37
38
|
|
38
39
|
super(args)
|
data/lib/alchemy/tasks/tidy.rb
CHANGED
@@ -36,7 +36,7 @@ FactoryBot.define do
|
|
36
36
|
after(:build) do |page, evaluator|
|
37
37
|
page.build_public_version(
|
38
38
|
public_on: evaluator.public_on,
|
39
|
-
public_until: evaluator.public_until
|
39
|
+
public_until: evaluator.public_until
|
40
40
|
)
|
41
41
|
end
|
42
42
|
after(:create) do |page|
|
@@ -46,7 +46,7 @@ FactoryBot.define do
|
|
46
46
|
:alchemy_element,
|
47
47
|
name: name,
|
48
48
|
page_version: page.public_version,
|
49
|
-
autogenerate_ingredients: true
|
49
|
+
autogenerate_ingredients: true
|
50
50
|
)
|
51
51
|
end
|
52
52
|
end
|
@@ -10,20 +10,20 @@ RSpec.shared_examples_for "having crop action" do |args|
|
|
10
10
|
|
11
11
|
context "with no picture assigned" do
|
12
12
|
it "renders error message" do
|
13
|
-
get :crop, params: {
|
13
|
+
get :crop, params: {id: 1}
|
14
14
|
expect(assigns(:no_image_notice)).to eq(Alchemy.t(:no_image_for_cropper_found))
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
18
|
context "with picture assigned" do
|
19
|
-
subject { get :crop, params: {
|
19
|
+
subject { get :crop, params: {id: 1, picture_id: picture.id} }
|
20
20
|
|
21
21
|
let(:default_mask) do
|
22
22
|
[
|
23
23
|
0,
|
24
24
|
0,
|
25
25
|
300,
|
26
|
-
250
|
26
|
+
250
|
27
27
|
]
|
28
28
|
end
|
29
29
|
|
@@ -43,7 +43,7 @@ RSpec.shared_examples_for "having crop action" do |args|
|
|
43
43
|
|
44
44
|
context "with sizes in settings" do
|
45
45
|
let(:settings) do
|
46
|
-
{
|
46
|
+
{size: "300x250"}
|
47
47
|
end
|
48
48
|
|
49
49
|
it "sets sizes to given values" do
|
@@ -78,7 +78,7 @@ RSpec.shared_examples_for "having crop action" do |args|
|
|
78
78
|
|
79
79
|
context "and aspect ratio set on the settings" do
|
80
80
|
let(:settings) do
|
81
|
-
{
|
81
|
+
{fixed_ratio: "2"}
|
82
82
|
end
|
83
83
|
|
84
84
|
it "does not infer the height from the image file preserving the aspect ratio" do
|
@@ -93,7 +93,7 @@ RSpec.shared_examples_for "having crop action" do |args|
|
|
93
93
|
context "when width or height is not fixed and an aspect ratio is given" do
|
94
94
|
context "and aspect ratio set on the settings" do
|
95
95
|
let(:settings) do
|
96
|
-
{
|
96
|
+
{fixed_ratio: "0.5"}
|
97
97
|
end
|
98
98
|
|
99
99
|
it "width is given, it infers the height from width and ratio" do
|
@@ -136,7 +136,7 @@ RSpec.shared_examples_for "having crop action" do |args|
|
|
136
136
|
|
137
137
|
context "with fixed_ratio set to false" do
|
138
138
|
let(:settings) do
|
139
|
-
{
|
139
|
+
{fixed_ratio: false}
|
140
140
|
end
|
141
141
|
|
142
142
|
it "sets ratio to false" do
|
@@ -147,7 +147,7 @@ RSpec.shared_examples_for "having crop action" do |args|
|
|
147
147
|
|
148
148
|
context "with fixed_ratio set to a non float string" do
|
149
149
|
let(:settings) do
|
150
|
-
{
|
150
|
+
{fixed_ratio: "123,45"}
|
151
151
|
end
|
152
152
|
|
153
153
|
it "raises error" do
|
@@ -157,7 +157,7 @@ RSpec.shared_examples_for "having crop action" do |args|
|
|
157
157
|
|
158
158
|
context "with no fixed_ratio set" do
|
159
159
|
let(:settings) do
|
160
|
-
{
|
160
|
+
{size: "80x60"}
|
161
161
|
end
|
162
162
|
|
163
163
|
it "sets a fixed ratio from sizes" do
|
@@ -38,7 +38,7 @@ RSpec.shared_examples_for "having picture thumbnails" do
|
|
38
38
|
end
|
39
39
|
|
40
40
|
context "with format in the options" do
|
41
|
-
let(:options) { {
|
41
|
+
let(:options) { {format: "gif"} }
|
42
42
|
|
43
43
|
it "takes this as format." do
|
44
44
|
expect(picture_url).to match(/\.gif/)
|
@@ -53,24 +53,24 @@ RSpec.shared_examples_for "having picture thumbnails" do
|
|
53
53
|
|
54
54
|
context "if cropping is enabled" do
|
55
55
|
before do
|
56
|
-
allow(record).to receive(:settings) { {
|
56
|
+
allow(record).to receive(:settings) { {crop: true} }
|
57
57
|
end
|
58
58
|
|
59
59
|
it "passes these crop values to the picture's url method." do
|
60
60
|
expect(picture).to receive(:url).with(
|
61
|
-
hash_including(crop_from: "10x10", crop_size: "200x200")
|
61
|
+
hash_including(crop_from: "10x10", crop_size: "200x200")
|
62
62
|
)
|
63
63
|
picture_url
|
64
64
|
end
|
65
65
|
|
66
66
|
context "but with crop values in the options" do
|
67
67
|
let(:options) do
|
68
|
-
{
|
68
|
+
{crop_from: "30x30", crop_size: "75x75"}
|
69
69
|
end
|
70
70
|
|
71
71
|
it "passes these crop values instead." do
|
72
72
|
expect(picture).to receive(:url).with(
|
73
|
-
hash_including(crop_from: "30x30", crop_size: "75x75")
|
73
|
+
hash_including(crop_from: "30x30", crop_size: "75x75")
|
74
74
|
)
|
75
75
|
picture_url
|
76
76
|
end
|
@@ -79,7 +79,7 @@ RSpec.shared_examples_for "having picture thumbnails" do
|
|
79
79
|
end
|
80
80
|
|
81
81
|
context "with other options" do
|
82
|
-
let(:options) { {
|
82
|
+
let(:options) { {foo: "baz"} }
|
83
83
|
|
84
84
|
context "and the image does not need to be processed" do
|
85
85
|
before do
|
@@ -129,7 +129,7 @@ RSpec.shared_examples_for "having picture thumbnails" do
|
|
129
129
|
|
130
130
|
context "with cropping enabled" do
|
131
131
|
before do
|
132
|
-
allow(record).to receive(:settings) { {
|
132
|
+
allow(record).to receive(:settings) { {crop: true} }
|
133
133
|
end
|
134
134
|
|
135
135
|
it "includes these crop values.", :aggregate_failures do
|
@@ -140,7 +140,7 @@ RSpec.shared_examples_for "having picture thumbnails" do
|
|
140
140
|
|
141
141
|
context "with cropping disabled" do
|
142
142
|
before do
|
143
|
-
allow(record).to receive(:settings) { {
|
143
|
+
allow(record).to receive(:settings) { {crop: nil} }
|
144
144
|
end
|
145
145
|
|
146
146
|
it "does not include these crop values.", :aggregate_failures do
|
@@ -165,7 +165,7 @@ RSpec.shared_examples_for "having picture thumbnails" do
|
|
165
165
|
|
166
166
|
context "having size setting" do
|
167
167
|
before do
|
168
|
-
allow(record).to receive(:settings) { {
|
168
|
+
allow(record).to receive(:settings) { {size: "30x70"} }
|
169
169
|
end
|
170
170
|
|
171
171
|
it "includes this size." do
|
@@ -175,7 +175,7 @@ RSpec.shared_examples_for "having picture thumbnails" do
|
|
175
175
|
|
176
176
|
context "having crop setting" do
|
177
177
|
before do
|
178
|
-
allow(record).to receive(:settings) { {
|
178
|
+
allow(record).to receive(:settings) { {crop: true} }
|
179
179
|
end
|
180
180
|
|
181
181
|
it "includes this setting" do
|
@@ -214,7 +214,7 @@ RSpec.shared_examples_for "having picture thumbnails" do
|
|
214
214
|
|
215
215
|
context "when crop is enabled in the settings" do
|
216
216
|
let(:settings) do
|
217
|
-
{
|
217
|
+
{crop: true}
|
218
218
|
end
|
219
219
|
|
220
220
|
context "and crop sizes are present" do
|
@@ -228,8 +228,8 @@ RSpec.shared_examples_for "having picture thumbnails" do
|
|
228
228
|
hash_including(
|
229
229
|
crop_from: "10x10",
|
230
230
|
crop_size: "200x200",
|
231
|
-
crop: true
|
232
|
-
)
|
231
|
+
crop: true
|
232
|
+
)
|
233
233
|
)
|
234
234
|
thumbnail_url
|
235
235
|
end
|
@@ -241,8 +241,8 @@ RSpec.shared_examples_for "having picture thumbnails" do
|
|
241
241
|
hash_including(
|
242
242
|
crop_from: nil,
|
243
243
|
crop_size: nil,
|
244
|
-
crop: true
|
245
|
-
)
|
244
|
+
crop: true
|
245
|
+
)
|
246
246
|
)
|
247
247
|
thumbnail_url
|
248
248
|
end
|
@@ -251,7 +251,7 @@ RSpec.shared_examples_for "having picture thumbnails" do
|
|
251
251
|
|
252
252
|
context "when cropping is disabled in the settings" do
|
253
253
|
let(:settings) do
|
254
|
-
{
|
254
|
+
{crop: false}
|
255
255
|
end
|
256
256
|
|
257
257
|
context "but crop sizes are present" do
|
@@ -265,8 +265,8 @@ RSpec.shared_examples_for "having picture thumbnails" do
|
|
265
265
|
hash_including(
|
266
266
|
crop_size: nil,
|
267
267
|
crop_from: nil,
|
268
|
-
crop: false
|
269
|
-
)
|
268
|
+
crop: false
|
269
|
+
)
|
270
270
|
)
|
271
271
|
thumbnail_url
|
272
272
|
end
|
@@ -316,7 +316,7 @@ RSpec.shared_examples_for "having picture thumbnails" do
|
|
316
316
|
|
317
317
|
context "when cropping is enabled in settings" do
|
318
318
|
let(:settings) do
|
319
|
-
{
|
319
|
+
{crop: true}
|
320
320
|
end
|
321
321
|
|
322
322
|
context "and crop values are present" do
|
@@ -330,7 +330,7 @@ RSpec.shared_examples_for "having picture thumbnails" do
|
|
330
330
|
hash_including(
|
331
331
|
crop_from: "10x10",
|
332
332
|
crop_size: "200x200",
|
333
|
-
crop: true
|
333
|
+
crop: true
|
334
334
|
)
|
335
335
|
)
|
336
336
|
end
|
@@ -342,7 +342,7 @@ RSpec.shared_examples_for "having picture thumbnails" do
|
|
342
342
|
hash_including(
|
343
343
|
crop_from: nil,
|
344
344
|
crop_size: nil,
|
345
|
-
crop: true
|
345
|
+
crop: true
|
346
346
|
)
|
347
347
|
)
|
348
348
|
end
|
@@ -351,7 +351,7 @@ RSpec.shared_examples_for "having picture thumbnails" do
|
|
351
351
|
|
352
352
|
context "when cropping is disabled in settings" do
|
353
353
|
let(:settings) do
|
354
|
-
{
|
354
|
+
{crop: false}
|
355
355
|
end
|
356
356
|
|
357
357
|
context "but crop values are present" do
|
@@ -365,7 +365,7 @@ RSpec.shared_examples_for "having picture thumbnails" do
|
|
365
365
|
hash_including(
|
366
366
|
crop_from: nil,
|
367
367
|
crop_size: nil,
|
368
|
-
crop: false
|
368
|
+
crop: false
|
369
369
|
)
|
370
370
|
)
|
371
371
|
end
|
@@ -382,7 +382,7 @@ RSpec.shared_examples_for "having picture thumbnails" do
|
|
382
382
|
crop_size: nil,
|
383
383
|
flatten: true,
|
384
384
|
format: "jpg",
|
385
|
-
size: "160x120"
|
385
|
+
size: "160x120"
|
386
386
|
)
|
387
387
|
end
|
388
388
|
end
|
@@ -405,7 +405,7 @@ RSpec.shared_examples_for "having picture thumbnails" do
|
|
405
405
|
0,
|
406
406
|
0,
|
407
407
|
300,
|
408
|
-
250
|
408
|
+
250
|
409
409
|
]
|
410
410
|
end
|
411
411
|
|
@@ -424,7 +424,7 @@ RSpec.shared_examples_for "having picture thumbnails" do
|
|
424
424
|
|
425
425
|
context "with sizes in settings" do
|
426
426
|
let(:settings) do
|
427
|
-
{
|
427
|
+
{size: "300x250"}
|
428
428
|
end
|
429
429
|
|
430
430
|
it "sets sizes to given values" do
|
@@ -453,7 +453,7 @@ RSpec.shared_examples_for "having picture thumbnails" do
|
|
453
453
|
|
454
454
|
context "and aspect ratio set" do
|
455
455
|
let(:settings) do
|
456
|
-
{
|
456
|
+
{fixed_ratio: "2"}
|
457
457
|
end
|
458
458
|
|
459
459
|
it "does not infer the height from the image file preserving the aspect ratio" do
|
@@ -466,7 +466,7 @@ RSpec.shared_examples_for "having picture thumbnails" do
|
|
466
466
|
context "when width or height is not fixed and an aspect ratio is given" do
|
467
467
|
context "and aspect ratio set" do
|
468
468
|
let(:settings) do
|
469
|
-
{
|
469
|
+
{fixed_ratio: "0.5"}
|
470
470
|
end
|
471
471
|
|
472
472
|
it "width is given, it infers the height from width and ratio" do
|
@@ -503,7 +503,7 @@ RSpec.shared_examples_for "having picture thumbnails" do
|
|
503
503
|
|
504
504
|
context "with fixed_ratio set to false" do
|
505
505
|
let(:settings) do
|
506
|
-
{
|
506
|
+
{fixed_ratio: false}
|
507
507
|
end
|
508
508
|
|
509
509
|
it "sets ratio to false" do
|
@@ -513,7 +513,7 @@ RSpec.shared_examples_for "having picture thumbnails" do
|
|
513
513
|
|
514
514
|
context "with fixed_ratio set to a non float string" do
|
515
515
|
let(:settings) do
|
516
|
-
{
|
516
|
+
{fixed_ratio: "123,45"}
|
517
517
|
end
|
518
518
|
|
519
519
|
it "raises an error" do
|
@@ -523,7 +523,7 @@ RSpec.shared_examples_for "having picture thumbnails" do
|
|
523
523
|
|
524
524
|
context "with no fixed_ratio set" do
|
525
525
|
let(:settings) do
|
526
|
-
{
|
526
|
+
{size: "80x60"}
|
527
527
|
end
|
528
528
|
|
529
529
|
it "sets a fixed ratio from sizes" do
|
@@ -532,7 +532,7 @@ RSpec.shared_examples_for "having picture thumbnails" do
|
|
532
532
|
end
|
533
533
|
|
534
534
|
context "with size set to different values" do
|
535
|
-
let(:settings) { {
|
535
|
+
let(:settings) { {crop: true, size: size} }
|
536
536
|
|
537
537
|
before do
|
538
538
|
picture.image_file_width = 200
|
@@ -623,7 +623,7 @@ RSpec.shared_examples_for "having picture thumbnails" do
|
|
623
623
|
|
624
624
|
context "with crop set to true" do
|
625
625
|
before do
|
626
|
-
allow(record).to receive(:settings) { {
|
626
|
+
allow(record).to receive(:settings) { {crop: true} }
|
627
627
|
end
|
628
628
|
|
629
629
|
context "if picture.image_file is nil" do
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Alchemy
|
3
4
|
module TestSupport
|
4
5
|
# Helpers for integration specs
|
@@ -11,11 +12,11 @@ module Alchemy
|
|
11
12
|
# Pass either a user object or a symbol in the format of ':as_admin'.
|
12
13
|
#
|
13
14
|
def authorize_user(user_or_role = nil)
|
14
|
-
case user_or_role
|
15
|
+
user = case user_or_role
|
15
16
|
when Symbol, String
|
16
|
-
|
17
|
+
build(:alchemy_dummy_user, user_or_role)
|
17
18
|
else
|
18
|
-
|
19
|
+
user_or_role
|
19
20
|
end
|
20
21
|
allow_any_instance_of(ApplicationController).to receive(:current_user).and_return(user)
|
21
22
|
end
|
@@ -6,7 +6,7 @@ RSpec.shared_examples_for "having dom ids" do
|
|
6
6
|
let(:ingredient) do
|
7
7
|
described_class.new(
|
8
8
|
element: element,
|
9
|
-
role: "headline"
|
9
|
+
role: "headline"
|
10
10
|
)
|
11
11
|
end
|
12
12
|
|
@@ -31,7 +31,7 @@ RSpec.shared_examples_for "having dom ids" do
|
|
31
31
|
|
32
32
|
context "with anchor setting set to true" do
|
33
33
|
let(:settings) do
|
34
|
-
{
|
34
|
+
{anchor: true}
|
35
35
|
end
|
36
36
|
|
37
37
|
it "parameterizes dom_id" do
|
@@ -42,7 +42,7 @@ RSpec.shared_examples_for "having dom ids" do
|
|
42
42
|
|
43
43
|
context "with anchor setting set to from_value" do
|
44
44
|
let(:settings) do
|
45
|
-
{
|
45
|
+
{anchor: "from_value"}
|
46
46
|
end
|
47
47
|
|
48
48
|
context "with a value present" do
|
@@ -50,7 +50,7 @@ RSpec.shared_examples_for "having dom ids" do
|
|
50
50
|
described_class.new(
|
51
51
|
element: element,
|
52
52
|
role: "headline",
|
53
|
-
value: "Hello World"
|
53
|
+
value: "Hello World"
|
54
54
|
)
|
55
55
|
end
|
56
56
|
|
@@ -64,7 +64,7 @@ RSpec.shared_examples_for "having dom ids" do
|
|
64
64
|
described_class.new(
|
65
65
|
element: element,
|
66
66
|
role: "headline",
|
67
|
-
value: ""
|
67
|
+
value: ""
|
68
68
|
)
|
69
69
|
end
|
70
70
|
|
@@ -77,7 +77,7 @@ RSpec.shared_examples_for "having dom ids" do
|
|
77
77
|
context "with anchor setting set to fixed value" do
|
78
78
|
context "that is false" do
|
79
79
|
let(:settings) do
|
80
|
-
{
|
80
|
+
{anchor: false}
|
81
81
|
end
|
82
82
|
|
83
83
|
it "sets no dom_id" do
|
@@ -87,7 +87,7 @@ RSpec.shared_examples_for "having dom ids" do
|
|
87
87
|
|
88
88
|
context "that is true" do
|
89
89
|
let(:settings) do
|
90
|
-
{
|
90
|
+
{anchor: true}
|
91
91
|
end
|
92
92
|
|
93
93
|
it "sets no dom_id" do
|
@@ -97,7 +97,7 @@ RSpec.shared_examples_for "having dom ids" do
|
|
97
97
|
|
98
98
|
context "that is from_value" do
|
99
99
|
let(:settings) do
|
100
|
-
{
|
100
|
+
{anchor: true}
|
101
101
|
end
|
102
102
|
|
103
103
|
it "sets no dom_id" do
|
@@ -107,7 +107,7 @@ RSpec.shared_examples_for "having dom ids" do
|
|
107
107
|
|
108
108
|
context "that is a non reserved value" do
|
109
109
|
let(:settings) do
|
110
|
-
{
|
110
|
+
{anchor: "FixED VALUE"}
|
111
111
|
end
|
112
112
|
|
113
113
|
it "sets the dom_id to fixed value" do
|
@@ -8,7 +8,7 @@ RSpec.shared_examples_for "an alchemy ingredient" do
|
|
8
8
|
subject(:ingredient) do
|
9
9
|
described_class.new(
|
10
10
|
element: element,
|
11
|
-
role: "headline"
|
11
|
+
role: "headline"
|
12
12
|
)
|
13
13
|
end
|
14
14
|
|
@@ -31,13 +31,13 @@ RSpec.shared_examples_for "an alchemy ingredient" do
|
|
31
31
|
expect(element).to receive(:ingredient_definition_for).at_least(:once) do
|
32
32
|
{
|
33
33
|
settings: {
|
34
|
-
linkable: true
|
35
|
-
}
|
34
|
+
linkable: true
|
35
|
+
}
|
36
36
|
}.with_indifferent_access
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
it { is_expected.to eq({
|
40
|
+
it { is_expected.to eq({linkable: true}.with_indifferent_access) }
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
@@ -57,8 +57,8 @@ RSpec.shared_examples_for "an alchemy ingredient" do
|
|
57
57
|
type: "Text",
|
58
58
|
default: "Hello World",
|
59
59
|
settings: {
|
60
|
-
linkable: true
|
61
|
-
}
|
60
|
+
linkable: true
|
61
|
+
}
|
62
62
|
}.with_indifferent_access
|
63
63
|
end
|
64
64
|
|
@@ -73,4 +73,10 @@ RSpec.shared_examples_for "an alchemy ingredient" do
|
|
73
73
|
end
|
74
74
|
end
|
75
75
|
end
|
76
|
+
|
77
|
+
describe "#as_view_component" do
|
78
|
+
subject { ingredient.as_view_component }
|
79
|
+
|
80
|
+
it { is_expected.to be_a("#{described_class}View".constantize) }
|
81
|
+
end
|
76
82
|
end
|