From 5f6a10eb984c0398cccaef728e56b300cbe4acfd Mon Sep 17 00:00:00 2001 From: Zee Spencer <50284+zspencer@users.noreply.github.com> Date: Wed, 17 Apr 2024 17:27:18 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9=20Rename=20to=20`Content=20Block`?= =?UTF-8?q?=20because=20that=20sounds=20better=20to=20me?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/furniture/{text_block.rb => content_block.rb} | 2 +- app/furniture/content_block/content_block_policy.rb | 11 +++++++++++ .../content_block/content_blocks_controller.rb | 9 +++++++++ app/furniture/text_block/text_block_policy.rb | 11 ----------- app/furniture/text_block/text_blocks_controller.rb | 10 ---------- app/lib/space_routes.rb | 2 +- app/views/rooms/edit.html.erb | 4 ++-- db/migrate/20240328004901_create_content_blocks.rb | 7 +++++++ db/migrate/20240328004901_create_text_blocks.rb | 7 ------- db/seeds.rb | 2 ++ spec/system/slots_system_spec.rb | 6 +++--- 11 files changed, 36 insertions(+), 35 deletions(-) rename app/furniture/{text_block.rb => content_block.rb} (70%) create mode 100644 app/furniture/content_block/content_block_policy.rb create mode 100644 app/furniture/content_block/content_blocks_controller.rb delete mode 100644 app/furniture/text_block/text_block_policy.rb delete mode 100644 app/furniture/text_block/text_blocks_controller.rb create mode 100644 db/migrate/20240328004901_create_content_blocks.rb delete mode 100644 db/migrate/20240328004901_create_text_blocks.rb diff --git a/app/furniture/text_block.rb b/app/furniture/content_block.rb similarity index 70% rename from app/furniture/text_block.rb rename to app/furniture/content_block.rb index a9e401089..91e6c7bfb 100644 --- a/app/furniture/text_block.rb +++ b/app/furniture/content_block.rb @@ -1,4 +1,4 @@ -class TextBlock < ApplicationRecord +class ContentBlock < ApplicationRecord belongs_to :slot has_one :section, through: :slot has_one :space, through: :section diff --git a/app/furniture/content_block/content_block_policy.rb b/app/furniture/content_block/content_block_policy.rb new file mode 100644 index 000000000..0f6adfe77 --- /dev/null +++ b/app/furniture/content_block/content_block_policy.rb @@ -0,0 +1,11 @@ +class ContentBlock + class ContentBlockPolicy < ApplicationPolicy + alias_method :content_block, :object + def create? + current_person.member_of?(content_block.space) + end + + class Scope < ApplicationScope + end + end +end diff --git a/app/furniture/content_block/content_blocks_controller.rb b/app/furniture/content_block/content_blocks_controller.rb new file mode 100644 index 000000000..b6ff520a7 --- /dev/null +++ b/app/furniture/content_block/content_blocks_controller.rb @@ -0,0 +1,9 @@ +class ContentBlock + class ContentBlocksController < ApplicationController + expose :content_block, scope: -> { policy_scope(ContentBlock, policy_scope_class: ContentBlockPolicy::Scope) }, model: ContentBlock + + def new + authorize(content_block, policy_class: ContentBlockPolicy) + end + end +end diff --git a/app/furniture/text_block/text_block_policy.rb b/app/furniture/text_block/text_block_policy.rb deleted file mode 100644 index a64cb484e..000000000 --- a/app/furniture/text_block/text_block_policy.rb +++ /dev/null @@ -1,11 +0,0 @@ -class TextBlock - class TextBlockPolicy < ApplicationPolicy - alias_method :text_block, :object - def create? - current_person.member_of?(text_block.space) - end - - class Scope < ApplicationScope - end - end -end diff --git a/app/furniture/text_block/text_blocks_controller.rb b/app/furniture/text_block/text_blocks_controller.rb deleted file mode 100644 index 787439338..000000000 --- a/app/furniture/text_block/text_blocks_controller.rb +++ /dev/null @@ -1,10 +0,0 @@ -class TextBlock - class TextBlocksController < ApplicationController - expose :text_block, scope: -> { policy_scope(TextBlock, policy_scope_class: TextBlockPolicy::Scope) }, model: TextBlock, - build: ->(params, scope) { scope.new(params.merge(slottable: slottable)) } - - def new - authorize(text_block, policy_class: TextBlockPolicy) - end - end -end diff --git a/app/lib/space_routes.rb b/app/lib/space_routes.rb index fe5e2a88d..3b68fe6ff 100644 --- a/app/lib/space_routes.rb +++ b/app/lib/space_routes.rb @@ -9,7 +9,7 @@ def self.append_routes(router) Furniture.append_routes(router) router.resources :furnitures, only: %i[create edit update destroy] router.resource :hero_image, controller: "room/hero_images" - router.resources :text_block, controller: "text_block/text_blocks" + router.resources :content_block, controller: "content_block/content_blocks" end router.resources :utilities diff --git a/app/views/rooms/edit.html.erb b/app/views/rooms/edit.html.erb index 226eda64a..63f9f6ef8 100644 --- a/app/views/rooms/edit.html.erb +++ b/app/views/rooms/edit.html.erb @@ -18,10 +18,10 @@