Skip to content

Commit

Permalink
rubocop linting
Browse files Browse the repository at this point in the history
  • Loading branch information
avonderluft committed Nov 18, 2024
1 parent b822894 commit 16c05ca
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 16 deletions.
2 changes: 1 addition & 1 deletion app/controllers/concerns/comfy/reorder_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module Comfy::ReorderAction
def reorder
resource_class = self.class.reorder_action_resource
(params.permit(order: [])[:order] || []).each_with_index do |id, index|
resource_class.where(id:).update_all(position: index)
resource_class.where(id: id).update_all(position: index)
end
if resource_class == ::Comfy::Cms::Page
Comfy::Cms::Page.all.each(&:save!)
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/comfy/admin/cms_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ module Comfy
module Admin
module CmsHelper
# Wrapper around Comfy::FormBuilder
def comfy_form_with(**options, &)
def comfy_form_with(**options, &block)
form_options = options.merge(builder: ComfortableMediaSurfer::FormBuilder)
form_options[:bootstrap] = { layout: :horizontal }
form_options[:local] = true
bootstrap_form_with(**form_options, &)
bootstrap_form_with(**form_options, &block)
end

def comfy_admin_partial(path, params = {})
Expand Down
2 changes: 1 addition & 1 deletion lib/comfortable_media_surfer/content/renderer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Error < StandardError; end
MAX_DEPTH = 100

# tags are in this format: {{ cms:tag_class params }}
TAG_REGEX = %r{\{\{\s*?cms:(?<class>\w+)(?<params>.*?)\}\}}.freeze
TAG_REGEX = %r{\{\{\s*?cms:(?<class>\w+)(?<params>.*?)\}\}}

class << self
# @return [Hash<String, Class<ComfortableMediaSurfer::Content::Tag>>]
Expand Down
2 changes: 1 addition & 1 deletion lib/comfortable_media_surfer/extensions/acts_as_tree.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def self_and_siblings
# BUG: https://github.com/rails/rails/issues/14369
# It's still a bug. Remove it to see failing test
def parent_id=(id)
self.parent = self.class.find_by(id:)
self.parent = self.class.find_by(id: id)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/comfortable_media_surfer/seeds/layout/importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def import_layout(path, parent)
attributes_yaml = content_hash.delete('attributes')
attrs = YAML.safe_load(attributes_yaml)

layout = site.layouts.where(identifier:).first_or_initialize
layout = site.layouts.where(identifier: identifier).first_or_initialize
layout.parent = parent

if fresh_seed?(layout, content_path)
Expand Down
10 changes: 4 additions & 6 deletions lib/comfortable_media_surfer/seeds/snippet/importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,20 @@ def import!
attributes_yaml = content_hash.delete('attributes')
attrs = YAML.safe_load(attributes_yaml)

snippet = site.snippets.where(identifier:).first_or_initialize
snippet = site.snippets.where(identifier: identifier).first_or_initialize

if fresh_seed?(snippet, path)
category_ids = category_names_to_ids(snippet, attrs.delete('categories'))

snippet.attributes = attrs.merge(
category_ids:,
category_ids: category_ids,
content: content_hash['content']
)

if snippet.save
message = "[CMS SEEDS] Imported Snippet \t #{snippet.identifier}"
ComfortableMediaSurfer.logger.info(message)
ComfortableMediaSurfer.logger.info("[CMS SEEDS] Imported Snippet \t #{snippet.identifier}")
else
message = "[CMS SEEDS] Failed to import Snippet \n#{snippet.errors.inspect}"
ComfortableMediaSurfer.logger.warn(message)
ComfortableMediaSurfer.logger.warn("[CMS SEEDS] Failed to import Snippet \n#{snippet.errors.inspect}")
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/generators/comfy/scaffold/scaffold_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ScaffoldGenerator < Rails::Generators::NamedBase

argument :model_args, type: :array, default: [], banner: 'attribute:type'

def initialize(*args, &)
def initialize(*args, &block)
super
@model_attrs = []
model_args.each do |arg|
Expand Down
6 changes: 3 additions & 3 deletions test/integration/render_cms_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def create_site_b
)
site.pages.create!(
label: 'default',
layout:,
layout: layout,
fragments_attributes: [{ identifier: 'content', content: 'SiteBContent' }]
)
end
Expand Down Expand Up @@ -215,7 +215,7 @@ def test_cms_layout_defaults

def test_cms_layout
content = '{{cms:text content}} {{cms:text content_b}} {{cms:text content_c}}'
comfy_cms_layouts(:default).update_columns(content:)
comfy_cms_layouts(:default).update_columns(content: content)
get '/render-layout?type=layout'
assert_response :success
assert_equal 'TestText TestPartial TestValue TestTemplate TestValue', response.body
Expand All @@ -235,7 +235,7 @@ def test_cms_layout_with_status

def test_cms_layout_with_action
content = '{{cms:text content}} {{cms:text content_b}} {{cms:text content_c}}'
comfy_cms_layouts(:default).update_columns(content:)
comfy_cms_layouts(:default).update_columns(content: content)
get '/render-layout?type=layout_with_action'
assert_response :success
assert_equal "Can render CMS layout and specify action\n ", response.body
Expand Down

0 comments on commit 16c05ca

Please sign in to comment.