Skip to content

Commit

Permalink
Add ability to destroy room_activities
Browse files Browse the repository at this point in the history
  • Loading branch information
hmlON committed Jul 29, 2017
1 parent 3ef50d8 commit 3477833
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/models/room_activity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class RoomActivity < ApplicationRecord
].freeze

belongs_to :room
has_many :activities
has_many :activities, dependent: :destroy

validates :name, presence: true

Expand Down
7 changes: 3 additions & 4 deletions app/views/room_activities/_edit_form.html.slim
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
.form.row
.edit_activities.form.row
- @room_activities.each do |activity|
.checkbox.col-sm-6
.checkbox.col-sm-6 class="room_activity_#{activity.id}_field"
label for="#{dom_id(activity)}"
= check_box_tag 'activity_ids[]', activity.id, activity.enabled?, id: dom_id(activity), class: "js-update-room-activity", data: { id: activity.id }
= activity.name
/ - unless activity.creator.nil?
/ = link_to '&times;'.html_safe, room_activity_path(id: activity.id), method: :delete
= link_to '×', room_activity_path(id: activity.id), method: :delete
14 changes: 12 additions & 2 deletions spec/features/rooms_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
let(:room) { create :room, :with_activities }
let(:user) { room.users.first }
let(:new_room_name) { 'New room name' }
let(:room_activity_name) { room.room_activities.first.name }
let(:new_room_activity_name) { room.room_activities.first.name }
# let(:room_activity_name) { room.room_activities.first.name }
let(:destroyed_room_activity) { room.room_activities.last }

background do
sign_in user
Expand All @@ -58,6 +58,16 @@
# uncheck room_activity_name
# expect(room.room_activities.find_by(name: room_activity_name).enabled?).to eq false
# end

scenario 'User destroys room activity' do
within ".room_activity_#{destroyed_room_activity.id}_field" do
click_on '×'
end

within '.edit_activities' do
expect(page).not_to have_content destroyed_room_activity.name
end
end
end

context 'leaving' do
Expand Down

0 comments on commit 3477833

Please sign in to comment.