alchemy_cms 7.0.0.pre.a → 7.0.0.pre.c

Sign up to get free protection for your applications and to get access to all the features.
Files changed (237) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/brakeman-analysis.yml +2 -2
  3. data/.github/workflows/lint.yml +37 -0
  4. data/.github/workflows/{ci.yml → test.yml} +8 -8
  5. data/.gitignore +0 -5
  6. data/.hound.yml +2 -3
  7. data/.rubocop.yml +4 -350
  8. data/.standard.yml +3 -0
  9. data/CHANGELOG.md +33 -0
  10. data/Gemfile +3 -2
  11. data/README.md +10 -12
  12. data/Rakefile +0 -19
  13. data/alchemy_cms.gemspec +4 -2
  14. data/app/assets/config/alchemy_manifest.js +1 -0
  15. data/app/assets/javascripts/alchemy/admin.js +0 -2
  16. data/app/assets/javascripts/alchemy/alchemy.dirty.js.coffee +1 -1
  17. data/app/assets/javascripts/alchemy/alchemy.initializer.js.coffee +5 -12
  18. data/app/assets/javascripts/alchemy/alchemy.link_dialog.js.coffee +6 -1
  19. data/app/assets/stylesheets/alchemy/base.scss +2 -2
  20. data/app/components/alchemy/ingredients/audio_view.rb +37 -0
  21. data/app/components/alchemy/ingredients/base_view.rb +38 -0
  22. data/app/components/alchemy/ingredients/boolean_view.rb +13 -0
  23. data/app/components/alchemy/ingredients/datetime_view.rb +22 -0
  24. data/app/components/alchemy/ingredients/file_view.rb +40 -0
  25. data/app/components/alchemy/ingredients/headline_view.rb +20 -0
  26. data/app/components/alchemy/ingredients/html_view.rb +9 -0
  27. data/app/components/alchemy/ingredients/link_view.rb +25 -0
  28. data/app/components/alchemy/ingredients/node_view.rb +11 -0
  29. data/app/components/alchemy/ingredients/page_view.rb +15 -0
  30. data/app/components/alchemy/ingredients/picture_view.rb +108 -0
  31. data/app/components/alchemy/ingredients/richtext_view.rb +22 -0
  32. data/app/components/alchemy/ingredients/select_view.rb +6 -0
  33. data/app/components/alchemy/ingredients/text_view.rb +41 -0
  34. data/app/components/alchemy/ingredients/video_view.rb +39 -0
  35. data/app/controllers/alchemy/admin/attachments_controller.rb +3 -3
  36. data/app/controllers/alchemy/admin/base_controller.rb +7 -7
  37. data/app/controllers/alchemy/admin/clipboard_controller.rb +2 -2
  38. data/app/controllers/alchemy/admin/elements_controller.rb +26 -11
  39. data/app/controllers/alchemy/admin/languages_controller.rb +1 -1
  40. data/app/controllers/alchemy/admin/nodes_controller.rb +2 -2
  41. data/app/controllers/alchemy/admin/pages_controller.rb +10 -10
  42. data/app/controllers/alchemy/admin/pictures_controller.rb +14 -14
  43. data/app/controllers/alchemy/admin/resources_controller.rb +27 -28
  44. data/app/controllers/alchemy/admin/styleguide_controller.rb +1 -0
  45. data/app/controllers/alchemy/admin/tags_controller.rb +11 -11
  46. data/app/controllers/alchemy/api/base_controller.rb +2 -2
  47. data/app/controllers/alchemy/api/elements_controller.rb +11 -11
  48. data/app/controllers/alchemy/api/ingredients_controller.rb +1 -1
  49. data/app/controllers/alchemy/api/nodes_controller.rb +1 -1
  50. data/app/controllers/alchemy/api/pages_controller.rb +11 -11
  51. data/app/controllers/alchemy/attachments_controller.rb +3 -3
  52. data/app/controllers/alchemy/base_controller.rb +1 -8
  53. data/app/controllers/alchemy/messages_controller.rb +9 -9
  54. data/app/controllers/alchemy/pages_controller.rb +8 -19
  55. data/app/controllers/concerns/alchemy/admin/archive_overlay.rb +1 -0
  56. data/app/controllers/concerns/alchemy/admin/uploader_responses.rb +5 -7
  57. data/app/controllers/concerns/alchemy/legacy_page_redirects.rb +5 -5
  58. data/app/decorators/alchemy/element_editor.rb +4 -4
  59. data/app/decorators/alchemy/ingredient_editor.rb +6 -6
  60. data/app/helpers/alchemy/admin/attachments_helper.rb +1 -1
  61. data/app/helpers/alchemy/admin/base_helper.rb +21 -22
  62. data/app/helpers/alchemy/admin/elements_helper.rb +1 -1
  63. data/app/helpers/alchemy/admin/form_helper.rb +1 -1
  64. data/app/helpers/alchemy/admin/navigation_helper.rb +7 -7
  65. data/app/helpers/alchemy/admin/pages_helper.rb +2 -2
  66. data/app/helpers/alchemy/admin/tags_helper.rb +3 -3
  67. data/app/helpers/alchemy/base_helper.rb +2 -2
  68. data/app/helpers/alchemy/elements_block_helper.rb +9 -7
  69. data/app/helpers/alchemy/elements_helper.rb +12 -12
  70. data/app/helpers/alchemy/pages_helper.rb +11 -11
  71. data/app/helpers/alchemy/url_helper.rb +1 -1
  72. data/{package/src → app/javascript/alchemy_admin}/datepicker.js +1 -0
  73. data/{package/src → app/javascript/alchemy_admin}/node_tree.js +2 -2
  74. data/{package/src → app/javascript/alchemy_admin}/page_publication_fields.js +1 -1
  75. data/{package/src → app/javascript/alchemy_admin}/page_sorter.js +1 -1
  76. data/{package/src → app/javascript/alchemy_admin}/picture_editors.js +2 -2
  77. data/{package/src → app/javascript/alchemy_admin}/sitemap.js +4 -4
  78. data/app/javascript/alchemy_admin/tinymce.js +142 -0
  79. data/app/javascript/alchemy_admin.js +34 -0
  80. data/app/mailers/alchemy/messages_mailer.rb +1 -1
  81. data/app/models/alchemy/attachment.rb +6 -6
  82. data/app/models/alchemy/base_record.rb +1 -0
  83. data/app/models/alchemy/eager_loading.rb +6 -6
  84. data/app/models/alchemy/element/definitions.rb +1 -1
  85. data/app/models/alchemy/element/element_ingredients.rb +3 -3
  86. data/app/models/alchemy/element.rb +2 -2
  87. data/app/models/alchemy/elements_repository.rb +1 -1
  88. data/app/models/alchemy/image_cropper_settings.rb +2 -2
  89. data/app/models/alchemy/ingredient.rb +14 -12
  90. data/app/models/alchemy/ingredient_validator.rb +1 -1
  91. data/app/models/alchemy/ingredients/datetime.rb +1 -1
  92. data/app/models/alchemy/ingredients/file.rb +5 -5
  93. data/app/models/alchemy/ingredients/headline.rb +4 -4
  94. data/app/models/alchemy/ingredients/picture.rb +27 -9
  95. data/app/models/alchemy/ingredients/richtext.rb +15 -12
  96. data/app/models/alchemy/ingredients/text.rb +6 -6
  97. data/app/models/alchemy/language/code.rb +1 -1
  98. data/app/models/alchemy/language.rb +4 -4
  99. data/app/models/alchemy/legacy_page_url.rb +1 -1
  100. data/app/models/alchemy/node.rb +2 -2
  101. data/app/models/alchemy/page/page_elements.rb +14 -14
  102. data/app/models/alchemy/page/page_naming.rb +4 -4
  103. data/app/models/alchemy/page/page_natures.rb +1 -1
  104. data/app/models/alchemy/page/page_scopes.rb +5 -5
  105. data/app/models/alchemy/page.rb +11 -11
  106. data/app/models/alchemy/picture/calculations.rb +2 -2
  107. data/app/models/alchemy/picture/transformations.rb +2 -2
  108. data/app/models/alchemy/picture/url.rb +4 -4
  109. data/app/models/alchemy/picture.rb +11 -10
  110. data/app/models/alchemy/picture_thumb/create.rb +1 -1
  111. data/app/models/alchemy/picture_thumb.rb +1 -1
  112. data/app/models/alchemy/picture_variant.rb +2 -3
  113. data/app/models/alchemy/tag.rb +8 -0
  114. data/app/models/concerns/alchemy/picture_thumbnails.rb +6 -6
  115. data/app/serializers/alchemy/base_serializer.rb +1 -1
  116. data/app/serializers/alchemy/page_tree_serializer.rb +7 -7
  117. data/app/services/alchemy/duplicate_element.rb +3 -3
  118. data/app/services/alchemy/tag_validations.rb +1 -1
  119. data/app/views/alchemy/_menubar.html.erb +1 -1
  120. data/app/views/alchemy/admin/attachments/_replace_button.html.erb +1 -1
  121. data/app/views/alchemy/admin/attachments/destroy.js.erb +1 -1
  122. data/app/views/alchemy/admin/elements/_element.html.erb +3 -0
  123. data/app/views/alchemy/admin/nodes/index.html.erb +4 -2
  124. data/app/views/alchemy/admin/pages/_page_layout_filter.html.erb +1 -1
  125. data/app/views/alchemy/admin/pages/edit.html.erb +3 -7
  126. data/app/views/alchemy/admin/pages/index.html.erb +1 -1
  127. data/app/views/alchemy/admin/pages/update.js.erb +12 -6
  128. data/app/views/alchemy/admin/pictures/_infos.html.erb +1 -1
  129. data/app/views/alchemy/admin/resources/_filter_bar.html.erb +1 -1
  130. data/app/views/alchemy/admin/styleguide/index.html.erb +1 -1
  131. data/app/views/alchemy/admin/uploader/_button.html.erb +1 -1
  132. data/app/views/alchemy/base/permission_denied.js.erb +1 -1
  133. data/app/views/alchemy/base/redirect.js.erb +1 -1
  134. data/app/views/alchemy/ingredients/_audio_view.html.erb +1 -14
  135. data/app/views/alchemy/ingredients/_boolean_view.html.erb +1 -1
  136. data/app/views/alchemy/ingredients/_datetime_view.html.erb +3 -9
  137. data/app/views/alchemy/ingredients/_file_view.html.erb +3 -16
  138. data/app/views/alchemy/ingredients/_headline_view.html.erb +4 -10
  139. data/app/views/alchemy/ingredients/_html_view.html.erb +1 -1
  140. data/app/views/alchemy/ingredients/_link_view.html.erb +4 -9
  141. data/app/views/alchemy/ingredients/_node_view.html.erb +1 -1
  142. data/app/views/alchemy/ingredients/_page_view.html.erb +1 -4
  143. data/app/views/alchemy/ingredients/_picture_view.html.erb +4 -5
  144. data/app/views/alchemy/ingredients/_richtext_editor.html.erb +11 -2
  145. data/app/views/alchemy/ingredients/_richtext_view.html.erb +3 -3
  146. data/app/views/alchemy/ingredients/_select_view.html.erb +1 -1
  147. data/app/views/alchemy/ingredients/_text_view.html.erb +3 -19
  148. data/app/views/alchemy/ingredients/_video_view.html.erb +3 -18
  149. data/app/views/alchemy/ingredients/shared/_link_tools.html.erb +1 -0
  150. data/app/views/alchemy/ingredients/shared/_picture_tools.html.erb +1 -0
  151. data/app/views/layouts/alchemy/admin.html.erb +9 -15
  152. data/bin/importmap +4 -0
  153. data/bin/setup +28 -0
  154. data/bin/start +17 -0
  155. data/config/brakeman.ignore +0 -46
  156. data/config/importmap.rb +8 -0
  157. data/config/initializers/assets.rb +1 -0
  158. data/config/initializers/dragonfly.rb +1 -0
  159. data/config/initializers/mime_types.rb +1 -0
  160. data/config/initializers/mini_profiler.rb +1 -0
  161. data/config/initializers/simple_form.rb +3 -2
  162. data/config/locales/alchemy.en.yml +1 -1
  163. data/config/routes.rb +21 -20
  164. data/config/spring.rb +1 -0
  165. data/db/migrate/20230121212637_alchemy_six_point_one.rb +8 -8
  166. data/db/migrate/20230505132743_add_indexes_to_alchemy_pictures.rb +6 -0
  167. data/lib/alchemy/admin/locale.rb +3 -3
  168. data/lib/alchemy/admin/preview_url.rb +2 -2
  169. data/lib/alchemy/auth_accessors.rb +1 -1
  170. data/lib/alchemy/config.rb +1 -1
  171. data/lib/alchemy/controller_actions.rb +4 -4
  172. data/lib/alchemy/deprecation.rb +1 -0
  173. data/lib/alchemy/dragonfly/processors/thumbnail.rb +1 -1
  174. data/lib/alchemy/element_definition.rb +2 -2
  175. data/lib/alchemy/engine.rb +16 -1
  176. data/lib/alchemy/filetypes.rb +7 -7
  177. data/lib/alchemy/forms/builder.rb +4 -4
  178. data/lib/alchemy/i18n.rb +6 -4
  179. data/lib/alchemy/install/tasks.rb +2 -1
  180. data/lib/alchemy/name_conversions.rb +1 -1
  181. data/lib/alchemy/page_layout.rb +1 -1
  182. data/lib/alchemy/permissions.rb +5 -4
  183. data/lib/alchemy/resource.rb +10 -10
  184. data/lib/alchemy/resources_helper.rb +7 -7
  185. data/lib/alchemy/routing_constraints.rb +2 -2
  186. data/lib/alchemy/seeder.rb +12 -5
  187. data/lib/alchemy/shell.rb +2 -1
  188. data/lib/alchemy/taggable.rb +3 -2
  189. data/lib/alchemy/tasks/tidy.rb +1 -0
  190. data/lib/alchemy/test_support/capybara_helpers.rb +1 -1
  191. data/lib/alchemy/test_support/config_stubbing.rb +1 -0
  192. data/lib/alchemy/test_support/factories/element_factory.rb +4 -0
  193. data/lib/alchemy/test_support/factories/page_factory.rb +2 -2
  194. data/lib/alchemy/test_support/having_crop_action_examples.rb +9 -9
  195. data/lib/alchemy/test_support/having_picture_thumbnails_examples.rb +33 -33
  196. data/lib/alchemy/test_support/integration_helpers.rb +4 -3
  197. data/lib/alchemy/test_support/shared_contexts.rb +2 -1
  198. data/lib/alchemy/test_support/shared_dom_ids_examples.rb +9 -9
  199. data/lib/alchemy/test_support/shared_ingredient_examples.rb +12 -6
  200. data/lib/alchemy/test_support/shared_uploader_examples.rb +1 -0
  201. data/lib/alchemy/tinymce.rb +3 -26
  202. data/lib/alchemy/upgrader/seven_point_zero.rb +13 -23
  203. data/lib/alchemy/upgrader.rb +1 -11
  204. data/lib/alchemy/version.rb +1 -1
  205. data/lib/alchemy.rb +5 -0
  206. data/lib/alchemy_cms.rb +3 -1
  207. data/lib/generators/alchemy/base.rb +3 -2
  208. data/lib/generators/alchemy/elements/elements_generator.rb +2 -1
  209. data/lib/generators/alchemy/ingredient/ingredient_generator.rb +1 -0
  210. data/lib/generators/alchemy/install/files/application.html.erb +2 -2
  211. data/lib/generators/alchemy/install/install_generator.rb +2 -25
  212. data/lib/generators/alchemy/module/module_generator.rb +1 -0
  213. data/lib/generators/alchemy/page_layouts/page_layouts_generator.rb +1 -0
  214. data/lib/generators/alchemy/site_layouts/site_layouts_generator.rb +1 -0
  215. data/lib/generators/alchemy/views/views_generator.rb +2 -1
  216. data/lib/tasks/alchemy/thumbnails.rake +5 -5
  217. data/lib/tasks/alchemy/tidy.rake +1 -0
  218. data/lib/tasks/alchemy/upgrade.rake +10 -15
  219. data/package.json +6 -26
  220. metadata +80 -31
  221. data/app/assets/javascripts/alchemy/alchemy.tinymce.js.coffee +0 -93
  222. data/app/presenters/alchemy/picture_view.rb +0 -88
  223. data/app/views/alchemy/admin/pages/_tinymce_custom_config.html.erb +0 -10
  224. data/package/admin.js +0 -32
  225. data/package/dist/admin.js +0 -16
  226. data/package/dist/admin.js.map +0 -7
  227. data/package/src/__tests__/i18n.spec.js +0 -93
  228. data/package/src/utils/__tests__/ajax.spec.js +0 -168
  229. data/package/src/utils/__tests__/events.spec.js +0 -38
  230. /data/{package/src → app/javascript/alchemy_admin}/file_editors.js +0 -0
  231. /data/{package/src → app/javascript/alchemy_admin}/i18n.js +0 -0
  232. /data/{package/src → app/javascript/alchemy_admin}/image_cropper.js +0 -0
  233. /data/{package/src → app/javascript/alchemy_admin}/image_loader.js +0 -0
  234. /data/{package/src → app/javascript/alchemy_admin}/ingredient_anchor_link.js +0 -0
  235. /data/{package/src → app/javascript/alchemy_admin}/translations.js +0 -0
  236. /data/{package/src → app/javascript/alchemy_admin}/utils/ajax.js +0 -0
  237. /data/{package/src → app/javascript/alchemy_admin}/utils/events.js +0 -0
@@ -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, { language: language })
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.load_file(page_seeds_file)
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.create!(draft.merge(attributes))
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!
@@ -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.merge!(match: :all)
32
+ args[:match] = :all
32
33
  end
33
34
 
34
35
  if names.any?
35
- args.merge!(names: names)
36
+ args[:names] = names
36
37
  end
37
38
 
38
39
  super(args)
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require "alchemy/shell"
3
4
 
4
5
  module Alchemy
@@ -20,7 +20,7 @@ module Alchemy
20
20
  within_entire_page do
21
21
  page.find(
22
22
  "div.select2-result-label",
23
- text: /#{Regexp.escape(value)}/i, match: :prefer_exact,
23
+ text: /#{Regexp.escape(value)}/i, match: :prefer_exact
24
24
  ).click
25
25
  end
26
26
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Alchemy
3
4
  module TestSupport
4
5
  # Allows you to stub the Alchemy configuration in your specs
@@ -25,6 +25,10 @@ FactoryBot.define do
25
25
  name { "slide" }
26
26
  end
27
27
 
28
+ trait :compact do
29
+ name { "slide" }
30
+ end
31
+
28
32
  trait :with_ingredients do
29
33
  autogenerate_ingredients { true }
30
34
  end
@@ -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: { id: 1 }
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: { id: 1, picture_id: picture.id } }
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
- { size: "300x250" }
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
- { fixed_ratio: "2" }
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
- { fixed_ratio: "0.5" }
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
- { fixed_ratio: false }
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
- { fixed_ratio: "123,45" }
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
- { size: "80x60" }
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) { { format: "gif" } }
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) { { crop: true } }
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
- { crop_from: "30x30", crop_size: "75x75" }
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) { { foo: "baz" } }
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) { { crop: true } }
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) { { crop: nil } }
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) { { size: "30x70" } }
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) { { crop: true } }
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
- { crop: true }
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
- { crop: false }
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
- { crop: true }
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
- { crop: false }
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
- { size: "300x250" }
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
- { fixed_ratio: "2" }
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
- { fixed_ratio: "0.5" }
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
- { fixed_ratio: false }
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
- { fixed_ratio: "123,45" }
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
- { size: "80x60" }
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) { { crop: true, size: size } }
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) { { crop: true } }
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
- user = build(:alchemy_dummy_user, user_or_role)
17
+ build(:alchemy_dummy_user, user_or_role)
17
18
  else
18
- user = user_or_role
19
+ user_or_role
19
20
  end
20
21
  allow_any_instance_of(ApplicationController).to receive(:current_user).and_return(user)
21
22
  end
@@ -1,9 +1,10 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  RSpec.shared_context "with invalid file" do
3
4
  let(:invalid_file) do
4
5
  fixture_file_upload(
5
6
  File.expand_path("../../../spec/fixtures/users.yml", __dir__),
6
- "text/x-yaml",
7
+ "text/x-yaml"
7
8
  )
8
9
  end
9
10
 
@@ -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
- { anchor: true }
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
- { anchor: "from_value" }
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
- { anchor: false }
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
- { anchor: true }
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
- { anchor: true }
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
- { anchor: "FixED VALUE" }
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({ linkable: true }.with_indifferent_access) }
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
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  RSpec.shared_examples_for "having a json uploader error message" do
3
4
  it "renders json response with error message" do
4
5
  subject