Skip to content

Commit

Permalink
Bring history back
Browse files Browse the repository at this point in the history
  • Loading branch information
hmlON committed Jul 23, 2017
1 parent 5bea1b0 commit 50ecd34
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
3 changes: 1 addition & 2 deletions app/controllers/dashboard_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ class DashboardController < ApplicationController
before_action :require_room_presence

def index
# TODO: get array of activities
# @activities = @room.activities
@activities = @room.activities.order(created_at: :desc)
end

def punish
Expand Down
4 changes: 4 additions & 0 deletions app/models/room.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ class Room < ApplicationRecord

validates :name, presence: true

def activities
Activity.where(room_activity_id: room_activity_ids)
end

def create_default_room_activities
RoomActivity::DEFAULT_ROOM_ACTIVITIES.map do |activity_name|
room_activities.create(name: activity_name)
Expand Down
15 changes: 10 additions & 5 deletions app/views/dashboard/_history.html.slim
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
/ .history-wrapper
/ - if @activities.empty?
/ .no-activities There is nothing done yet. Try sumbitting done action.
/ - @activities.each do |activity|
/ = render_activity activity
.history-wrapper
- if @activities.empty?
.no-activities There is nothing done yet. Try sumbitting done action.
- @activities.each do |activity|
.activity.card.card-inverse.card-info
.card-block
.card-text
= "#{activity.user.name} has done "
em = "\"#{activity.name}\" "
= activity_time_tag(activity.created_at)
9 changes: 4 additions & 5 deletions spec/features/dashboard_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@
expect(page).to have_content 'Good job'
expect(user.reload.next_on_room_activities.pluck(:name)).not_to include(room_activity_name)

# TODO: turn on this test, it is temporary disabled
# click_on 'History'
# within '#history' do
# expect(page).to have_content "#{user.name} has done \"#{room_action.name}\""
# end
click_on 'History'
within '#history' do
expect(page).to have_content "#{user.name} has done \"#{room_activity.name}\""
end
end
end

0 comments on commit 50ecd34

Please sign in to comment.