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 ac283bc
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 27 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
10 changes: 10 additions & 0 deletions app/furniture/content_block/content_blocks_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class ContentBlock
class ContentBlocksController < ApplicationController
expose :content_block, scope: -> { policy_scope(ContentBlock, policy_scope_class: ContentBlockPolicy::Scope) }, model: ContentBlock,
build: ->(params, scope) { scope.new(params.merge(slottable: slottable)) }

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/views/rooms/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<%- end %>


<%= link_to "Add Text Block", room.location(:new, child: :text_block), class: "button"%>
<%= link_to "Add Content Block", room.location(:new, child: :text_block), class: "button"%>
<%- end %>
<%- end %>
<div class="mt-3 gap-y-3">
Expand Down
4 changes: 3 additions & 1 deletion db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,7 @@
journal = FactoryBot.create(:journal, room: journal_section)
FactoryBot.create_list(:journal_entry, 7, :with_keywords, :published, journal:)

_content_block_section = FactoryBot.create(:room, space:, name: "Content Block-o-Clock",
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 ac283bc

Please sign in to comment.