-
-
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.
ππ¨
Section
: Deleting Sections is possible again (#1900)
- #1841 So, this was caused by me being FANCY and putting the delete button in the same form as the edit and update. A bad idea. Now, deleting a Section is handled in it's own independent form, rather than attempting to rewrite the forms hidden `_method` field to trick Rails into doing a destroy. This is also better from a design perspective because: A) omg, a delete button so close to the save button is DANGEROUS B) Deleting a Section is kinda a big deal, and while it would be better to bubble-wrap the heck out of it so people who *do* delete a section don't wind up in a sad-mad state; we can at least give them lots of "DANGER WILL ROBINSON DANGER" messaging. This is... irresponsible of us but what we can do now. If a motivated bystander or contributor wanted to design and implement a way for Sections to be Archived instead; I would be Very Happy β’οΈ
- Loading branch information
1 parent
8d91f70
commit 4dfbc8d
Showing
4 changed files
with
69 additions
and
7 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
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,53 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe "Sections" do | ||
describe "Removing a Section" do | ||
let(:space) { create(:space, :with_entrance, :with_members, member_count: 1) } | ||
|
||
before do | ||
sign_in(space.members.first, space) | ||
visit(polymorphic_path(section.location(:edit))) | ||
end | ||
|
||
context "when the section is an entrance" do | ||
let(:section) { space.entrance } | ||
|
||
it "doesn't let you delete the entrance" do | ||
expect(page).not_to have_content(I18n.t("rooms.destroy.link_to")) | ||
end | ||
end | ||
|
||
context "when the section is not the entrance" do | ||
let(:section) { create(:room, space: space) } | ||
|
||
context "when the Section has no Gizmos" do | ||
it "deletes the Section from the Database" do | ||
click_on(I18n.t("rooms.destroy.link_to")) | ||
|
||
expect(page).to have_content(I18n.t("rooms.destroy.success", room_name: section.name)) | ||
expect(space.rooms).not_to be_exist(id: section.id) | ||
end | ||
end | ||
|
||
context "when the section has Gizmos" do | ||
before { | ||
create(:furniture, room: section) | ||
refresh | ||
} | ||
|
||
# Design note: It would be far better for us to have a way to safely undo | ||
# the deletion of a Section, or even put the Gizmos into a holding space | ||
# or something to be re-assigned; but that is out of scope for me at the | ||
# moment - ZS 10/18/23 | ||
it "requires confirmation" do | ||
accept_alert(I18n.t("rooms.destroy.confirm", room_name: section.name)) do | ||
click_on(I18n.t("rooms.destroy.link_to")) | ||
end | ||
|
||
expect(page).to have_content(I18n.t("rooms.destroy.success", room_name: section.name)) | ||
expect(space.rooms).not_to be_exist(id: section.id) | ||
end | ||
end | ||
end | ||
end | ||
end |