Skip to content

Commit

Permalink
🧹 Rename to Content Block because that sounds better to me
Browse files Browse the repository at this point in the history
  • Loading branch information
zspencer committed Apr 18, 2024
1 parent 8c6ef8d commit 5f6a10e
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 35 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class TextBlock < ApplicationRecord
class ContentBlock < ApplicationRecord
belongs_to :slot
has_one :section, through: :slot
has_one :space, through: :section
Expand Down
11 changes: 11 additions & 0 deletions app/furniture/content_block/content_block_policy.rb
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions app/furniture/content_block/content_blocks_controller.rb
Original file line number Diff line number Diff line change
@@ -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
11 changes: 0 additions & 11 deletions app/furniture/text_block/text_block_policy.rb

This file was deleted.

10 changes: 0 additions & 10 deletions app/furniture/text_block/text_blocks_controller.rb

This file was deleted.

2 changes: 1 addition & 1 deletion app/lib/space_routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/views/rooms/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
<h2>Gizmos (but lighter)</h2>
<%- end %>


<%= link_to "Add Text Block", room.location(:new, child: :text_block), class: "button"%>
<%= link_to "Add Content Block", room.location(:new, child: :content_block), class: "button"%>
<%- end %>
<%- end %>

<div class="mt-3 gap-y-3">
<%= render CardComponent.new do %>
<h2>Gizmos</h2>
Expand Down
7 changes: 7 additions & 0 deletions db/migrate/20240328004901_create_content_blocks.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class CreateContentBlocks < ActiveRecord::Migration[7.1]
def change
create_table :content_blocks, id: :uuid do |t|
t.timestamps
end
end
end
7 changes: 0 additions & 7 deletions db/migrate/20240328004901_create_text_blocks.rb

This file was deleted.

2 changes: 2 additions & 0 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,5 @@

_content_block_section = FactoryBot.create(:room, space:, name: "Content Block-o-Clock",
description: "Content Blocks show static Words, Photos, or Videos!")

# FactoryBot.create(:content_block, in_section: content_block_section)
6 changes: 3 additions & 3 deletions spec/system/slots_system_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@
let(:space) { create(:space, :with_members) }
let(:section) { create(:room, space:) }

scenario "Adding a Text Block to a Slot" do
scenario "Adding a Content Block to a Slot" do
sign_in(space.members.first, space)
visit(polymorphic_path(section.location(:edit)))

click_link("Add Text Block")
click_link("Add Content Block")
expect(page).to have_current_path(polymorphic_path(section.location(:new, child: :text_block)))

fill_in_rich_text_area("Body", with: "Prepare yourself for AMAZING")
click_button("Create")

expect(section.slots.count).to eq(1)
expect(section.slots.first.slottable).to be_a(TextBlock)
expect(section.slots.first.slottable).to be_a(ContentBlock)
expect(sections.slots.first.slottable.body).to eq("Prepare yourself for AMAZING")
end
end

0 comments on commit 5f6a10e

Please sign in to comment.