Skip to content

Commit

Permalink
Add caching to UserActivity#value
Browse files Browse the repository at this point in the history
  • Loading branch information
hmlON committed Jul 23, 2017
1 parent 3fe38f7 commit 5bea1b0
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 3 deletions.
1 change: 0 additions & 1 deletion app/controllers/dashboard_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ class DashboardController < ApplicationController
before_action :require_room_presence

def index
@room = Room.includes(:users, room_actions: :user_actions).where(id: current_user.room_id).first
# TODO: get array of activities
# @activities = @room.activities
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/user_activity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ def activities
end

def value
activities.count
@value ||= activities.count
end
end
2 changes: 1 addition & 1 deletion spec/features/dashboard_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
}.to change { Activity.count }.by(1)

expect(page).to have_content 'Good job'
expect(user.next_on_room_activities.pluck(:name)).not_to include(room_activity_name)
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'
Expand Down

0 comments on commit 5bea1b0

Please sign in to comment.