-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We decided that instead of creating a `Slot`, we want to create Gizmos directly, and we want to make those `Gizmo` by sending users to the actual `/new` page for the particular `Gizmo`. We're thinking we will make the UI cards of Gizmos, so that they can include things like why you might want to add that Gizmo, or the help docs or the ... whatever. We don't know. It'll be fine.
- Loading branch information
Showing
10 changed files
with
64 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
class SlotsController < ApplicationController | ||
expose :slot, scope: -> { policy_scope(current_room.slots) } | ||
|
||
def new | ||
authorize(slot) | ||
end | ||
|
||
def create | ||
if authorize(slot).save | ||
redirect_to(slot.slottable.location) | ||
else | ||
render :new, status: :unprocessable_entity | ||
end | ||
end | ||
|
||
def slot_params | ||
params.require(:slot).permit([:slottable_type]) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class SlotPolicy < ApplicationPolicy | ||
alias_method :slot, :object | ||
|
||
def create? | ||
current_person.operator? || current_person.member_of?(slot.space) | ||
end | ||
|
||
class Scope < ApplicationScope | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<%= form_with(model: [slot.space, slot.section, slot]) do |slot_form| %> | ||
<%= slot_form.label(:slottable_type) %> | ||
<%= slot_form.select(:slottable_type, [:MarkdownTextBlock]) %> | ||
<%= slot_form.submit %> | ||
<%- end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe Slot do | ||
it { is_expected.to belong_to(:section).class_name(:Room) } | ||
it { is_expected.to belong_to(:slottable) } | ||
it { is_expected.to belong_to(:section).class_name(:Room).inverse_of(:slots) } | ||
it { is_expected.to belong_to(:slottable).inverse_of(:slot) } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters