diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 3f878b97a..af6797505 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -41,11 +41,11 @@ RSpec/ExampleLength:
- 'spec/furniture/journal/entries_request_spec.rb'
- 'spec/furniture/markdown_text_block_spec.rb'
- 'spec/furniture/marketplace/products_controller_request_spec.rb'
- - 'spec/models/furniture_placement_spec.rb'
+ - 'spec/models/furniture_spec.rb'
- 'spec/models/membership_spec.rb'
- 'spec/models/room_spec.rb'
- 'spec/policies/room_policy_spec.rb'
- - 'spec/requests/furniture_placements_controller_request_spec.rb'
+ - 'spec/requests/furnitures_controller_request_spec.rb'
- 'spec/requests/rsvps_controller_request_spec.rb'
- 'spec/requests/spaces/invitations_request_spec.rb'
- 'spec/requests/spaces_controller_request_spec.rb'
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 99ca2e89e..5217be6d4 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -124,7 +124,7 @@ def pundit_user
end
def space_repository
- policy_scope(Space.includes(:rooms, entrance: [:furniture_placements]))
+ policy_scope(Space.includes(:rooms, entrance: [:furnitures]))
end
# Retrieves the room based upon the current_space and params
diff --git a/app/controllers/furniture_placements_controller.rb b/app/controllers/furniture_placements_controller.rb
deleted file mode 100644
index ac2936fbe..000000000
--- a/app/controllers/furniture_placements_controller.rb
+++ /dev/null
@@ -1,67 +0,0 @@
-class FurniturePlacementsController < ApplicationController
- def edit
- respond_to do |format|
- format.turbo_stream
- format.html
- end
- end
-
- def create
- respond_to do |format|
- if furniture_placement.save!
- format.html do
- redirect_to(
- [furniture_placement.room.space, furniture_placement.room],
- notice: t(".success", name: furniture_placement.furniture.model_name.human)
- )
- end
- format.turbo_stream
- end
- end
- end
-
- def update
- respond_to do |format|
- if furniture_placement.update!(furniture_placement_params)
- format.html do
- redirect_to(
- [:edit, furniture_placement.room.space, furniture_placement.room],
- notice: t(".success", name: furniture_placement.furniture.model_name.human)
- )
- end
- end
- end
- end
-
- def destroy
- furniture_placement.furniture.destroy!
- respond_to do |format|
- format.html do
- redirect_to(
- [furniture_placement.room.space, furniture_placement.room],
- notice: t(".success", name: furniture_placement.furniture.model_name.human.titleize)
- )
- end
-
- format.turbo_stream do
- render turbo_stream: turbo_stream.remove(furniture_placement)
- end
- end
- end
-
- helper_method def furniture_placement
- @furniture_placement ||= find_or_build.tap do |furniture_placement|
- authorize(furniture_placement)
- end
- end
-
- def find_or_build
- return current_room.furniture_placements.find(params[:id]) if params[:id]
-
- current_room.furniture_placements.new(furniture_placement_params)
- end
-
- def furniture_placement_params
- policy(FurniturePlacement).permit(params.require(:furniture_placement))
- end
-end
diff --git a/app/controllers/furnitures_controller.rb b/app/controllers/furnitures_controller.rb
new file mode 100644
index 000000000..ce031e143
--- /dev/null
+++ b/app/controllers/furnitures_controller.rb
@@ -0,0 +1,67 @@
+class FurnituresController < ApplicationController
+ def edit
+ respond_to do |format|
+ format.turbo_stream
+ format.html
+ end
+ end
+
+ def create
+ respond_to do |format|
+ if furniture.save!
+ format.html do
+ redirect_to(
+ [furniture.room.space, furniture.room],
+ notice: t(".success", name: furniture.furniture.model_name.human)
+ )
+ end
+ format.turbo_stream
+ end
+ end
+ end
+
+ def update
+ respond_to do |format|
+ if furniture.update!(furniture_params)
+ format.html do
+ redirect_to(
+ [:edit, furniture.room.space, furniture.room],
+ notice: t(".success", name: furniture.furniture.model_name.human)
+ )
+ end
+ end
+ end
+ end
+
+ def destroy
+ furniture.furniture.destroy!
+ respond_to do |format|
+ format.html do
+ redirect_to(
+ [furniture.room.space, furniture.room],
+ notice: t(".success", name: furniture.furniture.model_name.human.titleize)
+ )
+ end
+
+ format.turbo_stream do
+ render turbo_stream: turbo_stream.remove(furniture)
+ end
+ end
+ end
+
+ helper_method def furniture
+ @furniture ||= find_or_build.tap do |furniture|
+ authorize(furniture)
+ end
+ end
+
+ def find_or_build
+ return current_room.furnitures.find(params[:id]) if params[:id]
+
+ current_room.furnitures.new(furniture_params)
+ end
+
+ def furniture_params
+ policy(Furniture).permit(params.require(:furniture))
+ end
+end
diff --git a/app/furniture/embedded_form.rb b/app/furniture/embedded_form.rb
index ec91bee7f..d7ca3defb 100644
--- a/app/furniture/embedded_form.rb
+++ b/app/furniture/embedded_form.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-class EmbeddedForm < FurniturePlacement
+class EmbeddedForm < Furniture
def form_url=(form_url)
settings["form_url"] = form_url
end
diff --git a/app/furniture/journal/journal.rb b/app/furniture/journal/journal.rb
index 5f92f87cf..9d342ddeb 100644
--- a/app/furniture/journal/journal.rb
+++ b/app/furniture/journal/journal.rb
@@ -1,4 +1,4 @@
-class Journal::Journal < FurniturePlacement
+class Journal::Journal < Furniture
self.location_parent = :room
extend StripsNamespaceFromModelName
diff --git a/app/furniture/livestream.rb b/app/furniture/livestream.rb
index ec325afad..092a9041c 100644
--- a/app/furniture/livestream.rb
+++ b/app/furniture/livestream.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
# Renders a Twitch Livestream in a Room
-class Livestream < FurniturePlacement
+class Livestream < Furniture
def channel=(channel)
settings["channel"] = channel
end
diff --git a/app/furniture/markdown_text_block.rb b/app/furniture/markdown_text_block.rb
index 7d1fc31e3..9d276fbe0 100644
--- a/app/furniture/markdown_text_block.rb
+++ b/app/furniture/markdown_text_block.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
# Renders some HTML in a {Room}.
-class MarkdownTextBlock < FurniturePlacement
+class MarkdownTextBlock < Furniture
include RendersMarkdown
def to_html
diff --git a/app/furniture/marketplace/marketplace.rb b/app/furniture/marketplace/marketplace.rb
index c891feef0..bdaaf7f7a 100644
--- a/app/furniture/marketplace/marketplace.rb
+++ b/app/furniture/marketplace/marketplace.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class Marketplace
- class Marketplace < FurniturePlacement
+ class Marketplace < Furniture
self.location_parent = :room
has_many :products, inverse_of: :marketplace, dependent: :destroy
diff --git a/app/lib/space_routes.rb b/app/lib/space_routes.rb
index b0e9a3e69..5bf72555b 100644
--- a/app/lib/space_routes.rb
+++ b/app/lib/space_routes.rb
@@ -5,8 +5,8 @@ def self.append_routes(router)
router.resource :rsvp, only: %i[show update]
end
router.resources :rooms, only: %i[show edit update new create destroy] do
- FurniturePlacement.append_routes(router)
- router.resources :furniture_placements, only: %i[create edit update destroy]
+ Furniture.append_routes(router)
+ router.resources :furnitures, only: %i[create edit update destroy]
end
router.resources :utility_hookups
diff --git a/app/models/blueprint.rb b/app/models/blueprint.rb
index 49bc66e7a..ef4000250 100644
--- a/app/models/blueprint.rb
+++ b/app/models/blueprint.rb
@@ -26,19 +26,19 @@ def find_or_create!
def set_rooms
space_attributes.fetch(:rooms, []).each do |room_attributes|
room = space.rooms.find_or_initialize_by(name: room_attributes[:name])
- room.update!(merge_non_empty(room.attributes, room_attributes).except(:name, :furniture_placements))
+ room.update!(merge_non_empty(room.attributes, room_attributes).except(:name, :furnitures))
add_furniture(room, room_attributes)
end
end
def add_furniture(room, room_attributes)
- furniture_placements = room_attributes.fetch(:furniture_placements, {})
- furniture_placements.each.with_index do |(furniture, settings), slot|
- furniture_placement = room.furniture_placements
+ furnitures = room_attributes.fetch(:furnitures, {})
+ furnitures.each.with_index do |(furniture_kind, settings), slot|
+ furniture = room.furnitures
.find_or_initialize_by(slot: slot)
- furniture_placement
- .update!(settings: merge_non_empty(settings, furniture_placement.settings),
- furniture_kind: furniture)
+ furniture
+ .update!(settings: merge_non_empty(settings, furniture.settings),
+ furniture_kind: furniture_kind)
end
end
@@ -102,7 +102,7 @@ def space_attributes
name: "Listed Room 1",
publicity_level: :listed,
access_level: :public,
- furniture_placements: {
+ furnitures: {
markdown_text_block: {content: "# Welcome!"}
}
},
@@ -110,24 +110,24 @@ def space_attributes
name: "Listed Room 2",
publicity_level: :listed,
access_level: :public,
- furniture_placements: {}
+ furnitures: {}
},
{
name: "Unlisted Room 1",
publicity_level: :unlisted,
access_level: :public,
- furniture_placements: {}
+ furnitures: {}
},
{
name: "Unlisted Room 2",
publicity_level: :unlisted,
access_level: :public,
- furniture_placements: {}
+ furnitures: {}
},
{
name: "Entrance Hall",
publicity_level: :unlisted,
- furniture_placements: {
+ furnitures: {
markdown_text_block: {content: "# Wooo!"}
}
}
diff --git a/app/models/furniture_placement.rb b/app/models/furniture.rb
similarity index 88%
rename from app/models/furniture_placement.rb
rename to app/models/furniture.rb
index 7f0d70706..feb769681 100644
--- a/app/models/furniture_placement.rb
+++ b/app/models/furniture.rb
@@ -4,7 +4,7 @@
# {Furniture} is configured using the {#settings} attribute, which is structured
# as JSON, so that {Furniture} can be tweaked and configured as appropriate for
# it's particular use case.
-class FurniturePlacement < ApplicationRecord
+class Furniture < ApplicationRecord
include RankedModel
include WithinLocation
self.location_parent = :room
@@ -24,7 +24,7 @@ class FurniturePlacement < ApplicationRecord
delegate :attributes=, to: :furniture, prefix: true
def furniture
- @furniture ||= FurniturePlacement.from_placement(self)
+ @furniture ||= Furniture.from_placement(self)
end
def title
@@ -36,11 +36,11 @@ def utilities
end
def form_template
- "furniture_placements/noop"
+ "furnitures/noop"
end
def configurable?
- furniture.form_template != "furniture_placements/noop"
+ furniture.form_template != "furnitures/noop"
end
def write_attribute(name, value)
@@ -71,7 +71,7 @@ def self.append_routes(router)
end
end
- # @return [FurniturePlacement]
+ # @return [Furniture]
def self.from_placement(placement)
furniture_class = registry.fetch(placement.furniture_kind.to_sym)
placement.becomes(furniture_class)
diff --git a/app/models/furniture/serializer.rb b/app/models/furniture/serializer.rb
new file mode 100644
index 000000000..acb24d400
--- /dev/null
+++ b/app/models/furniture/serializer.rb
@@ -0,0 +1,12 @@
+class Furniture::Serializer < ApplicationSerializer
+ # @return [Furniture]
+ alias_method :furniture, :resource
+
+ def to_json(*_args)
+ super.merge(
+ furniture: {
+ id: furniture.id
+ }
+ )
+ end
+end
diff --git a/app/models/furniture_placement/serializer.rb b/app/models/furniture_placement/serializer.rb
deleted file mode 100644
index 4e4f83abe..000000000
--- a/app/models/furniture_placement/serializer.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-class FurniturePlacement::Serializer < ApplicationSerializer
- # @return [FurniturePlacement]
- alias_method :furniture_placement, :resource
-
- def to_json(*_args)
- super.merge(
- furniture_placement: {
- id: furniture_placement.id
- }
- )
- end
-end
diff --git a/app/models/room.rb b/app/models/room.rb
index e1106a3b2..c19cbd798 100644
--- a/app/models/room.rb
+++ b/app/models/room.rb
@@ -49,8 +49,8 @@ def unlisted?
publicity_level&.to_sym == :unlisted
end
- has_many :furniture_placements, dependent: :destroy_async
- accepts_nested_attributes_for :furniture_placements
+ has_many :furnitures, dependent: :destroy_async
+ accepts_nested_attributes_for :furnitures
def full_slug
"#{space.slug}--#{slug}"
diff --git a/app/models/room/serializer.rb b/app/models/room/serializer.rb
index 6850b99d2..459d5c8d3 100644
--- a/app/models/room/serializer.rb
+++ b/app/models/room/serializer.rb
@@ -11,7 +11,7 @@ def to_json(*_args)
id: room.id,
slug: room.slug,
name: room.name,
- furniture_placements: room.furniture_placements.map(&FurniturePlacement::Serializer.method(:new)).map(&:to_json)
+ furnitures: room.furnitures.map(&Furniture::Serializer.method(:new)).map(&:to_json)
}
)
end
diff --git a/app/policies/furniture_placement_policy.rb b/app/policies/furniture_policy.rb
similarity index 64%
rename from app/policies/furniture_placement_policy.rb
rename to app/policies/furniture_policy.rb
index 13fc15d98..b53e5a02a 100644
--- a/app/policies/furniture_placement_policy.rb
+++ b/app/policies/furniture_policy.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
-class FurniturePlacementPolicy < ApplicationPolicy
- alias_method :furniture_placement, :object
- delegate :space, to: :furniture_placement
+class FurniturePolicy < ApplicationPolicy
+ alias_method :furniture, :object
+ delegate :space, to: :furniture
class Scope < ApplicationScope
def resolve
@@ -16,7 +16,7 @@ def show?
end
def update?
- person&.operator? || person&.member_of?(furniture_placement.space)
+ person&.operator? || person&.member_of?(furniture.space)
end
alias_method :edit?, :update?
@@ -29,6 +29,6 @@ def permitted_attributes(_params)
end
def furniture_params
- FurniturePlacement.registry.values.flat_map { |f| f.new.try(:attribute_names) }.compact
+ Furniture.registry.values.flat_map { |f| f.new.try(:attribute_names) }.compact
end
end
diff --git a/app/policies/room_policy.rb b/app/policies/room_policy.rb
index f4672769a..81c199c83 100644
--- a/app/policies/room_policy.rb
+++ b/app/policies/room_policy.rb
@@ -20,8 +20,8 @@ def create?
def permitted_attributes(params)
[:access_level, :name, :slug, :publicity_level,
- furniture_placements_attributes:
- policy(FurniturePlacement).permitted_attributes(params)]
+ furnitures_attributes:
+ policy(Furniture).permitted_attributes(params)]
end
class Scope < ApplicationScope
diff --git a/app/views/furniture_placements/_form.html.erb b/app/views/furniture_placements/_form.html.erb
deleted file mode 100644
index fa4bca0c2..000000000
--- a/app/views/furniture_placements/_form.html.erb
+++ /dev/null
@@ -1,20 +0,0 @@
-
- <%- if policy(furniture_placement).edit? %>
- <%= form_with(model: [furniture_placement.room.space, furniture_placement.room, furniture_placement], local: true) do |form| %>
-
- <%= render partial: furniture_placement.furniture.form_template, locals: { form: form } %>
-
-
- <%- end %>
-
diff --git a/app/views/furniture_placements/_furniture_placement.html.erb b/app/views/furniture_placements/_furniture_placement.html.erb
deleted file mode 100644
index 46ef9053e..000000000
--- a/app/views/furniture_placements/_furniture_placement.html.erb
+++ /dev/null
@@ -1,32 +0,0 @@
-
- <%- if local_assigns[:editing] %>
-
-
- <%= furniture_placement.title %>
-
- <%- if furniture_placement.configurable? %>
- <%= render ButtonComponent.new(
- label: t('icons.edit'),
- href: [:edit, furniture_placement.room.space, furniture_placement.room, furniture_placement],
- method: :get,
- title: t('.edit_title', name: furniture_placement.furniture.model_name.human.titleize)) %>
- <%- end %>
-
- <%= render ButtonComponent.new(
- label: t('icons.remove'),
- href: [furniture_placement.room.space, furniture_placement.room, furniture_placement],
- title: t('.remove_title', name: furniture_placement.furniture.model_name.human.titleize),
- method: :delete,
- confirm: t('.confirm_destroy')) %>
-
- <%- if local_assigns[:include_form] %>
- <%= render partial: 'furniture_placements/form', locals: { furniture_placement: furniture_placement } %>
- <%- end %>
- <%- elsif furniture_placement.furniture.respond_to?(:in_room_template) %>
- <%= render partial: furniture_placement.furniture.in_room_template,
- locals: { furniture: furniture_placement.furniture, space: furniture_placement.space, room: furniture_placement.room,
- person: current_person } %>
- <%- else %>
- <%= render furniture_placement.furniture %>
- <%- end %>
-
diff --git a/app/views/furniture_placements/_new.html.erb b/app/views/furniture_placements/_new.html.erb
deleted file mode 100644
index b89489231..000000000
--- a/app/views/furniture_placements/_new.html.erb
+++ /dev/null
@@ -1,10 +0,0 @@
-
diff --git a/app/views/furniture_placements/create.turbo_stream.erb b/app/views/furniture_placements/create.turbo_stream.erb
deleted file mode 100644
index bf8f6cd87..000000000
--- a/app/views/furniture_placements/create.turbo_stream.erb
+++ /dev/null
@@ -1,6 +0,0 @@
-
-<%= turbo_stream.append(:furniture_placements) do %>
- <%= render(furniture_placement, { editing: true }) %>
-<%- end %>
-
-<%= turbo_stream.replace(:new_furniture_placement, partial: 'furniture_placements/new', locals: { furniture_placement: current_room.furniture_placements.new }) %>
diff --git a/app/views/furniture_placements/edit.html.erb b/app/views/furniture_placements/edit.html.erb
deleted file mode 100644
index d63a59ac6..000000000
--- a/app/views/furniture_placements/edit.html.erb
+++ /dev/null
@@ -1,2 +0,0 @@
-<%- breadcrumb :edit_furniture_placement, furniture_placement %>
-<%= render partial: "furniture_placements/form", locals: { furniture_placement: furniture_placement, include_form: true } %>
diff --git a/app/views/furniture_placements/edit.turbo_stream.erb b/app/views/furniture_placements/edit.turbo_stream.erb
deleted file mode 100644
index e16b8c6f2..000000000
--- a/app/views/furniture_placements/edit.turbo_stream.erb
+++ /dev/null
@@ -1,3 +0,0 @@
-<%= turbo_stream.replace(furniture_placement) do %>
- <%= render furniture_placement, editing: true, include_form: local_assigns.fetch(:include_form, true) %>
- <%- end %>
diff --git a/app/views/furnitures/_form.html.erb b/app/views/furnitures/_form.html.erb
new file mode 100644
index 000000000..c0b7ef08c
--- /dev/null
+++ b/app/views/furnitures/_form.html.erb
@@ -0,0 +1,20 @@
+
+ <%- if policy(furniture).edit? %>
+ <%= form_with(model: [furniture.room.space, furniture.room, furniture], local: true) do |form| %>
+
+ <%= render partial: furniture.furniture.form_template, locals: { form: form } %>
+
+
+ <%- end %>
+
diff --git a/app/views/furnitures/_furniture.html.erb b/app/views/furnitures/_furniture.html.erb
new file mode 100644
index 000000000..11e45a708
--- /dev/null
+++ b/app/views/furnitures/_furniture.html.erb
@@ -0,0 +1,32 @@
+
+ <%- if local_assigns[:editing] %>
+
+
+ <%= furniture.title %>
+
+ <%- if furniture.configurable? %>
+ <%= render ButtonComponent.new(
+ label: t('icons.edit'),
+ href: [:edit, furniture.room.space, furniture.room, furniture],
+ method: :get,
+ title: t('.edit_title', name: furniture.furniture.model_name.human.titleize)) %>
+ <%- end %>
+
+ <%= render ButtonComponent.new(
+ label: t('icons.remove'),
+ href: [furniture.room.space, furniture.room, furniture],
+ title: t('.remove_title', name: furniture.furniture.model_name.human.titleize),
+ method: :delete,
+ confirm: t('.confirm_destroy')) %>
+
+ <%- if local_assigns[:include_form] %>
+ <%= render partial: 'furnitures/form', locals: { furniture: furniture } %>
+ <%- end %>
+ <%- elsif furniture.furniture.respond_to?(:in_room_template) %>
+ <%= render partial: furniture.furniture.in_room_template,
+ locals: { furniture: furniture.furniture, space: furniture.space, room: furniture.room,
+ person: current_person } %>
+ <%- else %>
+ <%= render furniture.furniture %>
+ <%- end %>
+
diff --git a/app/views/furnitures/_new.html.erb b/app/views/furnitures/_new.html.erb
new file mode 100644
index 000000000..60f46decc
--- /dev/null
+++ b/app/views/furnitures/_new.html.erb
@@ -0,0 +1,10 @@
+
diff --git a/app/views/furniture_placements/_noop.html.erb b/app/views/furnitures/_noop.html.erb
similarity index 100%
rename from app/views/furniture_placements/_noop.html.erb
rename to app/views/furnitures/_noop.html.erb
diff --git a/app/views/furnitures/create.turbo_stream.erb b/app/views/furnitures/create.turbo_stream.erb
new file mode 100644
index 000000000..93184df9f
--- /dev/null
+++ b/app/views/furnitures/create.turbo_stream.erb
@@ -0,0 +1,6 @@
+
+<%= turbo_stream.append(:furnitures) do %>
+ <%= render(furniture, { editing: true }) %>
+<%- end %>
+
+<%= turbo_stream.replace(:new_furniture, partial: 'furnitures/new', locals: { furniture: current_room.furnitures.new }) %>
diff --git a/app/views/furnitures/edit.html.erb b/app/views/furnitures/edit.html.erb
new file mode 100644
index 000000000..2138ed61c
--- /dev/null
+++ b/app/views/furnitures/edit.html.erb
@@ -0,0 +1,2 @@
+<%- breadcrumb :edit_furniture, furniture %>
+<%= render partial: "furnitures/form", locals: { furniture: furniture, include_form: true } %>
diff --git a/app/views/furnitures/edit.turbo_stream.erb b/app/views/furnitures/edit.turbo_stream.erb
new file mode 100644
index 000000000..4608f8e6c
--- /dev/null
+++ b/app/views/furnitures/edit.turbo_stream.erb
@@ -0,0 +1,3 @@
+<%= turbo_stream.replace(furniture) do %>
+ <%= render furniture, editing: true, include_form: local_assigns.fetch(:include_form, true) %>
+ <%- end %>
diff --git a/app/views/rooms/_room.html.erb b/app/views/rooms/_room.html.erb
index d681ccee9..14b6136a4 100644
--- a/app/views/rooms/_room.html.erb
+++ b/app/views/rooms/_room.html.erb
@@ -1,7 +1,7 @@
-
- <%= render room.furniture_placements.rank(:slot) %>
+
+ <%= render room.furnitures.rank(:slot) %>
diff --git a/app/views/rooms/edit.html.erb b/app/views/rooms/edit.html.erb
index 30ba8d32a..b50385ff9 100644
--- a/app/views/rooms/edit.html.erb
+++ b/app/views/rooms/edit.html.erb
@@ -3,13 +3,13 @@
<%= render partial: 'form', locals: { room: room } %>
-
- <%= render room.furniture_placements.rank(:slot), editing: true %>
+
+ <%= render room.furnitures.rank(:slot), editing: true %>
-<%- new_furniture_placement = room.furniture_placements.new %>
+<%- new_furniture = room.furnitures.new %>
-<%- if policy(new_furniture_placement).new? %>
- <%= render "furniture_placements/new", furniture_placement: new_furniture_placement %>
+<%- if policy(new_furniture).new? %>
+ <%= render "furnitures/new", furniture: new_furniture %>
<%- end %>
diff --git a/config/breadcrumbs.rb b/config/breadcrumbs.rb
index efc94e6bd..61ebf347e 100644
--- a/config/breadcrumbs.rb
+++ b/config/breadcrumbs.rb
@@ -61,7 +61,7 @@
parent :root, rsvp.space
end
-crumb :edit_furniture_placement do |furniture_placement|
- link "Configure #{furniture_placement.title}"
- parent :edit_room, furniture_placement.room
+crumb :edit_furniture do |furniture|
+ link "Configure #{furniture.title}"
+ parent :edit_room, furniture.room
end
diff --git a/config/locales/furniture_placement/en.yml b/config/locales/furniture/en.yml
similarity index 86%
rename from config/locales/furniture_placement/en.yml
rename to config/locales/furniture/en.yml
index b855f95a8..57606a933 100644
--- a/config/locales/furniture_placement/en.yml
+++ b/config/locales/furniture/en.yml
@@ -1,5 +1,5 @@
en:
- furniture_placements:
+ furnitures:
update:
success: Furniture '%{name}' successfully updated! 🎉
create:
@@ -8,11 +8,11 @@ en:
success: Furniture '%{name}' successfully removed! 🎉
form:
destroy: "Remove Furniture 🗑️"
- furniture_placement:
+ furniture:
edit_title: "Configure %{name}"
remove_title: "Remove %{name}"
confirm_destroy: "This Removes the Furniture and all its Data"
helpers:
submit:
- furniture_placement:
+ furniture:
create: Add Furniture ➕
diff --git a/db/migrate/20230311011858_rename_from_furniture_placements_to_furnitures.rb b/db/migrate/20230311011858_rename_from_furniture_placements_to_furnitures.rb
new file mode 100644
index 000000000..0b9ca4da6
--- /dev/null
+++ b/db/migrate/20230311011858_rename_from_furniture_placements_to_furnitures.rb
@@ -0,0 +1,5 @@
+class RenameFromFurniturePlacementsToFurnitures < ActiveRecord::Migration[7.0]
+ def change
+ rename_table :furniture_placements, :furnitures
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index d42daa0ad..d3395eab6 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema[7.0].define(version: 2023_03_10_214954) do
+ActiveRecord::Schema[7.0].define(version: 2023_03_11_011858) do
# These are extensions that must be enabled in order to support this database
enable_extension "pgcrypto"
enable_extension "plpgsql"
@@ -83,14 +83,14 @@
t.index ["sluggable_type", "sluggable_id"], name: "index_friendly_id_slugs_on_sluggable_type_and_sluggable_id"
end
- create_table "furniture_placements", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
+ create_table "furnitures", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.integer "slot"
t.string "furniture_kind"
t.jsonb "settings"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.uuid "room_id"
- t.index ["room_id"], name: "index_furniture_placements_on_room_id"
+ t.index ["room_id"], name: "index_furnitures_on_room_id"
end
create_table "invitations", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
@@ -235,15 +235,15 @@
add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id"
- add_foreign_key "journal_entries", "furniture_placements", column: "journal_id"
+ add_foreign_key "journal_entries", "furnitures", column: "journal_id"
add_foreign_key "marketplace_cart_products", "marketplace_orders", column: "cart_id"
add_foreign_key "marketplace_cart_products", "marketplace_products", column: "product_id"
add_foreign_key "marketplace_orders", "marketplace_shoppers", column: "shopper_id"
add_foreign_key "marketplace_product_tax_rates", "marketplace_products", column: "product_id"
add_foreign_key "marketplace_product_tax_rates", "marketplace_tax_rates", column: "tax_rate_id"
- add_foreign_key "marketplace_products", "furniture_placements", column: "marketplace_id"
+ add_foreign_key "marketplace_products", "furnitures", column: "marketplace_id"
add_foreign_key "marketplace_shoppers", "people"
- add_foreign_key "marketplace_tax_rates", "furniture_placements", column: "marketplace_id"
+ add_foreign_key "marketplace_tax_rates", "furnitures", column: "marketplace_id"
add_foreign_key "memberships", "invitations"
add_foreign_key "spaces", "rooms", column: "entrance_id"
end
diff --git a/docs/erd.png b/docs/erd.png
index 25e0ad3b3..4203e931e 100644
Binary files a/docs/erd.png and b/docs/erd.png differ
diff --git a/features/lib/Room.js b/features/lib/Room.js
index 572afd051..4e1bb61fe 100644
--- a/features/lib/Room.js
+++ b/features/lib/Room.js
@@ -26,7 +26,7 @@ class Room extends Model {
room: {
name: this.name,
slug: this.slug,
- furniturePlacementsAttributes: this.furniturePlacementsAttributes,
+ furnituresAttributes: this.furnituresAttributes,
},
};
}
diff --git a/features/steps/furniture_steps.js b/features/steps/furniture_steps.js
index ca4f3a0ca..aa2d364b8 100644
--- a/features/steps/furniture_steps.js
+++ b/features/steps/furniture_steps.js
@@ -20,15 +20,16 @@ Given(
* @param {DataTable} dataTable
*/
function (_a, furniture, _a2, room, space, dataTable) {
- const furniturePlacementsAttributes = [
+ const furnituresAttributes = [
{
furnitureKind: furniture.type.toLowerCase(),
furnitureAttributes: dataTableToHash(dataTable),
},
];
+
return this.api()
.rooms(space)
- .update(room.assign({ furniturePlacementsAttributes }));
+ .update(room.assign({ furnituresAttributes }));
}
);
Then(
diff --git a/spec/factories/furniture_placement.rb b/spec/factories/furniture.rb
similarity index 82%
rename from spec/factories/furniture_placement.rb
rename to spec/factories/furniture.rb
index 8c8e9c71c..465e575fa 100644
--- a/spec/factories/furniture_placement.rb
+++ b/spec/factories/furniture.rb
@@ -1,5 +1,5 @@
FactoryBot.define do
- factory :furniture_placement do
+ factory :furniture do
room
furniture_kind { "markdown_text_block" }
settings { {content: "# Original Content"} }
diff --git a/spec/factories/room.rb b/spec/factories/room.rb
index bb503b80c..716d2d0e8 100644
--- a/spec/factories/room.rb
+++ b/spec/factories/room.rb
@@ -30,7 +30,7 @@
end
after(:create) do |room, evaluator|
- create_list(:furniture_placement, evaluator.furniture_count, room: room)
+ create_list(:furniture, evaluator.furniture_count, room: room)
end
end
end
diff --git a/spec/furniture/markdown_text_block_spec.rb b/spec/furniture/markdown_text_block_spec.rb
index 533d94dd0..3f3869ad4 100644
--- a/spec/furniture/markdown_text_block_spec.rb
+++ b/spec/furniture/markdown_text_block_spec.rb
@@ -3,7 +3,7 @@
require "rails_helper"
RSpec.describe MarkdownTextBlock do
- subject(:content_block) { create(:furniture_placement).becomes(described_class) }
+ subject(:content_block) { create(:furniture).becomes(described_class) }
describe "#to_html" do
it "renders markdown correctly" do
diff --git a/spec/models/blueprint_spec.rb b/spec/models/blueprint_spec.rb
index e282d805e..a01ac5424 100644
--- a/spec/models/blueprint_spec.rb
+++ b/spec/models/blueprint_spec.rb
@@ -9,7 +9,7 @@
rooms: [{
name: "Room A",
publicity_level: :listed,
- furniture_placements: {
+ furnitures: {
markdown_text_block: {content: "Obi Swan Kenobi"}
}
}],
@@ -23,13 +23,13 @@
# @todo add other examples of changing data after the
# blueprint has been applied
- space.rooms.first.furniture_placements.first.update(furniture_attributes: {content: "Hey there!"})
+ space.rooms.first.furnitures.first.update(furniture_attributes: {content: "Hey there!"})
described_class.new(EXAMPLE_CONFIG).find_or_create!
# @todo add other examples of confirming the changes
# were not overwritten
- expect(space.rooms.first.furniture_placements.first.furniture.content).to eql("Hey there!")
+ expect(space.rooms.first.furnitures.first.furniture.content).to eql("Hey there!")
end
it "Updates a given space" do
diff --git a/spec/models/furniture_placement_spec.rb b/spec/models/furniture_spec.rb
similarity index 59%
rename from spec/models/furniture_placement_spec.rb
rename to spec/models/furniture_spec.rb
index b34df334b..80f3c25a9 100644
--- a/spec/models/furniture_placement_spec.rb
+++ b/spec/models/furniture_spec.rb
@@ -1,25 +1,25 @@
require "rails_helper"
-RSpec.describe FurniturePlacement do
+RSpec.describe Furniture do
it { is_expected.to belong_to(:room) }
it { is_expected.to delegate_method(:space).to(:room) }
describe "#furniture" do
it "returns the configured piece of furniture" do
- furniture_placement = build(:furniture_placement, settings: {content: "# A Block"})
+ furniture = build(:furniture, settings: {content: "# A Block"})
- expect(furniture_placement.furniture).to be_a(MarkdownTextBlock)
- expect(furniture_placement.furniture.content).to eql("# A Block")
+ expect(furniture.furniture).to be_a(MarkdownTextBlock)
+ expect(furniture.furniture.content).to eql("# A Block")
end
end
describe "#slot" do
let(:room) { create(:room) }
- let!(:placements) { create_list(:furniture_placement, 3, room: room) }
+ let!(:placements) { create_list(:furniture, 3, room: room) }
it "inserts new placement between existing slots" do
placement1, placement2, placement3 = placements
- new_placement = create(:furniture_placement, room: room, slot_position: 1)
+ new_placement = create(:furniture, room: room, slot_position: 1)
expect(placement1.slot_rank).to eq(0)
expect(new_placement.slot_rank).to eq(1)
expect(placement2.slot_rank).to eq(2)
@@ -27,7 +27,7 @@
end
it "gets placed last without an explicit position" do
- new_placement = create(:furniture_placement, room: room, slot_position: nil)
+ new_placement = create(:furniture, room: room, slot_position: nil)
expect(new_placement).to be_valid
expect(new_placement.slot_position).to eq(:last)
end
diff --git a/spec/policies/furniture_placement_policy_spec.rb b/spec/policies/furniture_placement_policy_spec.rb
deleted file mode 100644
index 6f906948e..000000000
--- a/spec/policies/furniture_placement_policy_spec.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-require "rails_helper"
-
-RSpec.describe FurniturePlacementPolicy do
- subject { described_class }
-
- let(:furniture_placement) { create(:furniture_placement) }
- let(:membership) { create(:membership, space: furniture_placement.space) }
- let(:member) { membership.member }
- let(:non_member) { create(:person) }
-
- permissions :show? do
- it { is_expected.to permit(nil, furniture_placement) }
- it { is_expected.to permit(member, furniture_placement) }
- it { is_expected.to permit(non_member, furniture_placement) }
- end
-
- permissions :update?, :create?, :edit?, :new? do
- it { is_expected.to permit(member, furniture_placement) }
- it { is_expected.not_to permit(non_member, furniture_placement) }
- it { is_expected.not_to permit(nil, furniture_placement) }
- end
-end
diff --git a/spec/policies/furniture_policy_spec.rb b/spec/policies/furniture_policy_spec.rb
new file mode 100644
index 000000000..303d7a992
--- /dev/null
+++ b/spec/policies/furniture_policy_spec.rb
@@ -0,0 +1,22 @@
+require "rails_helper"
+
+RSpec.describe FurniturePolicy do
+ subject { described_class }
+
+ let(:furniture) { create(:furniture) }
+ let(:membership) { create(:membership, space: furniture.space) }
+ let(:member) { membership.member }
+ let(:non_member) { create(:person) }
+
+ permissions :show? do
+ it { is_expected.to permit(nil, furniture) }
+ it { is_expected.to permit(member, furniture) }
+ it { is_expected.to permit(non_member, furniture) }
+ end
+
+ permissions :update?, :create?, :edit?, :new? do
+ it { is_expected.to permit(member, furniture) }
+ it { is_expected.not_to permit(non_member, furniture) }
+ it { is_expected.not_to permit(nil, furniture) }
+ end
+end
diff --git a/spec/requests/furniture_placements_controller_request_spec.rb b/spec/requests/furnitures_controller_request_spec.rb
similarity index 76%
rename from spec/requests/furniture_placements_controller_request_spec.rb
rename to spec/requests/furnitures_controller_request_spec.rb
index c5f122a98..f4e01fda4 100644
--- a/spec/requests/furniture_placements_controller_request_spec.rb
+++ b/spec/requests/furnitures_controller_request_spec.rb
@@ -1,7 +1,7 @@
require "rails_helper"
-RSpec.describe FurniturePlacementsController do
- let(:placement) { create(:furniture_placement, room: room) }
+RSpec.describe FurnituresController do
+ let(:placement) { create(:furniture, room: room) }
let(:room) { create(:room) }
let(:space) { room.space }
@@ -13,10 +13,10 @@
it "creates a furniture placement of the kind of furniture provided within the room" do
expect do
- post polymorphic_path(room.location(child: :furniture_placements)), params: {furniture_placement: {furniture_kind: :markdown_text_block}}
- end.to change { room.furniture_placements.count }.by(1)
+ post polymorphic_path(room.location(child: :furnitures)), params: {furniture: {furniture_kind: :markdown_text_block}}
+ end.to change { room.furnitures.count }.by(1)
- placement = room.furniture_placements.last
+ placement = room.furnitures.last
expect(placement.furniture).to be_a(MarkdownTextBlock)
expect(placement.slot).to be(0)
expect(response).to redirect_to([space, room])
@@ -28,7 +28,7 @@
context "when the person is a guest" do
it "does not allow updating placements" do
- patch placement_path, params: {furniture_placement: {furniture_attributes: {content: "updated content"}}}
+ patch placement_path, params: {furniture: {furniture_attributes: {content: "updated content"}}}
expect(response).not_to have_http_status(:success)
end
end
@@ -40,7 +40,7 @@
before { sign_in(space, person) }
it "allows updating a placement" do
- patch placement_path, params: {furniture_placement: {furniture_attributes: {content: "updated content"}}}
+ patch placement_path, params: {furniture: {furniture_attributes: {content: "updated content"}}}
expect(response).to have_http_status(:found)
expect(placement.reload.settings["content"]).to eq("updated content")
end
diff --git a/spec/requests/rooms_request_spec.rb b/spec/requests/rooms_request_spec.rb
index 2686bf826..8197b30bc 100644
--- a/spec/requests/rooms_request_spec.rb
+++ b/spec/requests/rooms_request_spec.rb
@@ -28,12 +28,12 @@
response "200", "Room retrieved" do
run_test! do |response|
data = response_data(response)
- furniture_data = room.furniture_placements
- .map(&FurniturePlacement::Serializer.method(:new))
+ furniture_data = room.furnitures
+ .map(&Furniture::Serializer.method(:new))
.map(&:to_json)
expect(data[:room]).to eq(id: room.id, name: room.name,
slug: room.slug,
- furniture_placements: furniture_data)
+ furnitures: furniture_data)
end
end
end
@@ -52,7 +52,7 @@
properties: {
name: {type: :string, example: "Fancy Room"},
slug: {type: :string, example: "fancy-room"},
- furniture_placements_attributes: {
+ furnitures_attributes: {
type: :array,
items: {
type: :object,
@@ -70,13 +70,13 @@
response "200", "Room updated with furniture" do
let(:room) { create(:room, space: space) }
let(:attributes) do
- {name: "A new name", furniture_placements_attributes: [attributes_for(:furniture_placement)]}
+ {name: "A new name", furnitures_attributes: [attributes_for(:furniture)]}
end
run_test! do
data = response_data(response)
expect(data[:room][:name]).to eq("A new name")
- expect(data[:room][:furniture_placements]).to be_present
+ expect(data[:room][:furnitures]).to be_present
end
end
end