Skip to content

Commit

Permalink
Section: Remove Listed concept; since it's confusing
Browse files Browse the repository at this point in the history
- #1155

At some point, it would make sense for us to make a Gizmo for linking to
different places (even ones outside of the Space!) and replacing the
Section Navigation bar with that.

But in the meantime, the `Listed` vs `Unlisted` dichotomy isn't really
serving us, and is getting in the way a little bit.
  • Loading branch information
zspencer authored and rosschapman committed Oct 23, 2023
1 parent fb636f1 commit 2b26f70
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 135 deletions.
18 changes: 4 additions & 14 deletions app/models/blueprint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,34 +99,24 @@ def space_attributes
{email: "[email protected]"}],
rooms: [
{
name: "Listed Room 1",
publicity_level: :listed,
name: "Room 1",
access_level: :public,
furnitures: {
markdown_text_block: {content: "# Welcome!"}
}
},
{
name: "Listed Room 2",
publicity_level: :listed,
name: "Room 2",
access_level: :public,
furnitures: {}
},
{
name: "Unlisted Room 1",
publicity_level: :unlisted,
access_level: :public,
furnitures: {}
},
{
name: "Unlisted Room 2",
publicity_level: :unlisted,
access_level: :public,
name: "Internal Room 1",
access_level: :internal,
furnitures: {}
},
{
name: "Entrance Hall",
publicity_level: :unlisted,
furnitures: {
markdown_text_block: {content: "# Wooo!"}
}
Expand Down
10 changes: 1 addition & 9 deletions app/models/room.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# A Room in Convene acts as a gathering place.
class Room < ApplicationRecord
self.ignored_columns += [:publicity_level]
# The space whose settings govern the default publicity and access controls for the Room.
belongs_to :space, inverse_of: :rooms
location(parent: :space)
Expand All @@ -25,15 +26,6 @@ class Room < ApplicationRecord
alias_method :internal?, :internal_access?
alias_method :public?, :public_access?

# A Room's Publicity Level indicates how visible the room is.
# `listed` - The room is discoverable by anyone in the space lobby.
# `unlisted` - The room is not listed.
enum publicity_level: {
listed: "listed",
unlisted: "unlisted"
}
validates :publicity_level, presence: true

has_many :gizmos, dependent: :destroy, inverse_of: :room, class_name: :Furniture
accepts_nested_attributes_for :gizmos

Expand Down
3 changes: 1 addition & 2 deletions app/policies/room_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ def create?
alias_method :new?, :create?

def permitted_attributes(params)
[:access_level, :name, :slug, :publicity_level,
gizmos_attributes:
[:access_level, :name, :slug, gizmos_attributes:
policy(Furniture).permitted_attributes(params)]
end

Expand Down
1 change: 0 additions & 1 deletion app/views/rooms/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

<h3>Privacy and Security</h3>

<%= render "radio_group", attribute: :publicity_level, options: Room::publicity_levels.values, form: room_form %>
<%= render "radio_group", attribute: :access_level, options: Room::access_levels.values, form: room_form %>

<footer>
Expand Down
2 changes: 1 addition & 1 deletion app/views/rooms/_room.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</div>

<div class="mt-3 grid grid-cols-1 gap-5 sm:gap-6 sm:grid-cols-2 lg:grid-cols-4 items-center">
<% policy_scope(room.space.rooms.listed).each do |room| %>
<% policy_scope(room.space.rooms).each do |room| %>
<%= render partial: 'spaces/room_card', locals: { room: room } %>
<% end %>
</div>
Expand Down
38 changes: 6 additions & 32 deletions features/rooms/discovering-rooms.feature
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,19 @@ Feature: Discovering Rooms
I want to be able to explore the Space's rooms

@built @unimplemented-steps
Scenario: Space Member may discover Listed Room
Given a Space with a Listed Room
Scenario: Space Member may discover Room
Given a Space with a Room
When a Space Member is on the Space Dashboard
Then they see the Room

@built @unimplemented-steps
Scenario: Guest may discover Listed Room
Given a Space with a Listed Room
Scenario: Guest may discover Room
Given a Space with a Room
When a Guest is on the Space Dashboard
Then they see the Room

@unstarted
Scenario: Guest may not discover Listed Internal Room
Given a Space with an Listed Internal Room
Scenario: Guest may not discover Internal Room
Given a Space with an Internal Room
When a Guest is on the Space Dashboard
Then they do not see the Room

# Unlisted Rooms
@built
Scenario: Guest may not discover Unlisted Rooms
Given a "System Test" Space
When the Guest is on the "System Test" Space Dashboard
Then the Guest does not see the "Unlisted Room 1" Room's Door

@built
Scenario: Space Member may not discover Unlisted Room
Given a "System Test" Space
When the Space Member is on the "System Test" Space Dashboard
Then the Space Member does not see the "Unlisted Room 1" Room's Door

@unstarted @unimplemented-steps
Scenario: Room Creator may discover Unlisted Room
Given a Space with an Unlisted Room
When the Room Creator is on the Space Dashboard
Then they see the Room


@unstarted
Scenario: Room Previous Attendee may discover previously visited Unlisted Room
Given a Space with an Unlisted Room
When a Previous Attendee of that Room is on the Space Dashboard
Then they see the Room
22 changes: 11 additions & 11 deletions features/rooms/entering-rooms.feature
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ Feature: Entering Rooms
@built
Scenario: Entering Room via Room Picker from Space Dashboard
Given the Space Member is on the "System Test" Space Dashboard
When the Space Member taps the "Listed Room 1" Room in the Room Picker
Then the Space Member is placed in the "Listed Room 1" Room
When the Space Member taps the "Room 1" Room in the Room Picker
Then the Space Member is placed in the "Room 1" Room

@built
Scenario: Entering Room via Room Picker from another Room
Given the Space Member is in the "System Test" Space and in the "Listed Room 1" Room
When the Space Member taps the "Listed Room 2" Room in the Room Picker
Then the Space Member is placed in the "Listed Room 2" Room
Given the Space Member is in the "System Test" Space and in the "Room 1" Room
When the Space Member taps the "Room 2" Room in the Room Picker
Then the Space Member is placed in the "Room 2" Room

@built @unimplemented-steps
Scenario: Entering Room via Slug on a Branded Domain
Expand All @@ -33,13 +33,13 @@ Feature: Entering Rooms

@built
Scenario: Entering Room via Room full URL
When the Space Member visit the "System Test" Space, "Listed Room 1" Room full URL
Then the Space Member is placed in the "Listed Room 1" Room
When the Space Member visit the "System Test" Space, "Room 1" Room full URL
Then the Space Member is placed in the "Room 1" Room

@built @unimplemented-steps
Scenario: Entering Room via back button
Given the Space Member is in the "System Test" Space and in the "Listed Room 1" Room
When the Space Member taps the "Listed Room 2" Room in the Room Picker
And the Space Member is placed in the "Listed Room 2" Room
Given the Space Member is in the "System Test" Space and in the "Room 1" Room
When the Space Member taps the "Room 2" Room in the Room Picker
And the Space Member is placed in the "Room 2" Room
And the Space Member hit the back button
Then the Space Member is placed in the "Listed Room 1" Room
Then the Space Member is placed in the "Room 1" Room
12 changes: 0 additions & 12 deletions features/support/parameter-types/publicityLevel.js

This file was deleted.

9 changes: 0 additions & 9 deletions spec/factories/room.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
factory :room do
space
name { Faker::Book.genre }
publicity_level { "listed" }

trait :internal do
access_level { :internal }
Expand All @@ -12,14 +11,6 @@
access_level { :public }
end

trait :listed do
publicity_level { :listed }
end

trait :unlisted do
publicity_level { :unlisted }
end

trait :with_slug do
slug { name.parameterize }
end
Expand Down
1 change: 0 additions & 1 deletion spec/models/blueprint_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
members: [{email: "[email protected]"}],
rooms: [{
name: "Room A",
publicity_level: :listed,
furnitures: {
markdown_text_block: {content: "Obi Swan Kenobi"}
}
Expand Down
36 changes: 2 additions & 34 deletions spec/models/room_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,43 +10,11 @@
it "creates unique slugs by space scope" do
space_1 = Space.create(name: "space1")
space_2 = Space.create(name: "space2")
space_1_room = space_1.rooms.create(name: "room1", publicity_level: :listed)
space_2_room = space_2.rooms.create(name: "room1", publicity_level: :listed)
space_1_room = space_1.rooms.create(name: "room1")
space_2_room = space_2.rooms.create(name: "room1")

expect(space_1_room.slug).to eq "room1"
expect(space_2_room.slug).to eq "room1"
end
end

describe ".listed" do
it "does not include rooms whose publicity level is unlisted" do
space = Space.create(name: "space")
listed_room = space.rooms.create(publicity_level: :listed, name: "Listed Room")
unlisted_room = space.rooms.create(publicity_level: :unlisted, name: "Unlisted Room")

aggregate_failures do
expect(described_class.listed).not_to include(unlisted_room)
expect(described_class.listed).to include(listed_room)
end
end
end

describe "#publicity_level" do
it { is_expected.to validate_presence_of(:publicity_level) }
it { is_expected.to define_enum_for(:publicity_level).backed_by_column_of_type(:string) }

context "when set to 'listed'" do
subject { described_class.new(publicity_level: "listed", space: space) }

it { is_expected.not_to be_unlisted }
it { is_expected.to be_listed }
end

context "when set to 'unlisted'" do
subject { described_class.new(publicity_level: "unlisted", space: space) }

it { is_expected.to be_unlisted }
it { is_expected.not_to be_listed }
end
end
end
9 changes: 0 additions & 9 deletions spec/policies/room_policy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,13 @@
let(:space) { room.space }
let!(:internal_room) { create(:room, :internal, space: space) }
let!(:public_room) { create(:room, :public, space: space) }
let!(:listed_room) { create(:room, :listed, space: space) }
let!(:unlisted_room) { create(:room, :unlisted, space: space) }

context "when person is an operator" do
let(:person) { operator }

it "returns all the rooms" do
expect(results).to include(internal_room)
expect(results).to include(public_room)
expect(results).to include(unlisted_room)
expect(results).to include(listed_room)
end
end

Expand All @@ -64,8 +60,6 @@
it "returns all the rooms" do
expect(results).to include(internal_room)
expect(results).to include(public_room)
expect(results).to include(unlisted_room)
expect(results).to include(listed_room)
end
end

Expand All @@ -74,9 +68,6 @@

it "returns only the public rooms" do
expect(results).to include(public_room)
expect(results).to include(unlisted_room)
expect(results).to include(listed_room)

expect(results).not_to include(internal_room)
end
end
Expand Down

0 comments on commit 2b26f70

Please sign in to comment.