Skip to content

Commit

Permalink
πŸžπŸ”¨ Section: Permit setting the #description (#2058)
Browse files Browse the repository at this point in the history
* `Section`: Permit setting the `#description`

- #1155

- I forgot this in #2055.
  Which probably means I should write a system spec.

* Redirect ftw
  • Loading branch information
zspencer authored Dec 21, 2023
1 parent 2abef4a commit 30d64fe
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/policies/room_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def create?
alias_method :new?, :create?

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

Expand Down
4 changes: 4 additions & 0 deletions spec/factories/room.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
slug { name.parameterize }
end

trait :with_description do
description { Faker::TvShows::TheExpanse.quote }
end

trait :with_furniture do
transient do
furniture_count { 1 }
Expand Down
11 changes: 8 additions & 3 deletions spec/requests/rooms_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
}

let(:path) { polymorphic_path(space.location(child: :rooms)) }
let(:room_params) { attributes_for(:room, :with_slug, space: space) }
let(:room_params) { attributes_for(:room, :with_description, :with_slug, space: space) }

context "when the person is a guest" do
it "does not allow creating a new room" do
Expand All @@ -151,8 +151,13 @@

before { sign_in(space, person) }

specify { expect { do_request }.to(change { space.rooms.count }.by(1)) }
it { is_expected.to redirect_to(polymorphic_path(space.rooms.last.location(:edit))) }
it "creates the room" do
expect { do_request }.to(change { space.rooms.count }.by(1))
created_room = space.rooms.last
expect(created_room.slug).to eql(room_params[:slug])
expect(created_room.description).to eql(room_params[:description])
expect(response).to redirect_to(polymorphic_path(space.rooms.last.location(:edit)))
end

context "when the space has an entrance" do
before { space.update(entrance: create(:room, space: space)) }
Expand Down

0 comments on commit 30d64fe

Please sign in to comment.