Skip to content

Commit

Permalink
Delete PublicActivity from project
Browse files Browse the repository at this point in the history
  • Loading branch information
hmlON committed Jul 19, 2017
1 parent cfd214a commit 67d3f19
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 38 deletions.
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ gem 'jquery-rails'
gem 'omniauth-google-oauth2'
gem 'omniauth-vkontakte'
gem 'pg', '~> 0.18'
gem 'public_activity'
gem 'puma', '~> 3.0'
gem 'rails', '~> 5.0.1'
gem 'rainbow', '>= 2.1.0', '< 2.2.0' # workaround for bundler errors
Expand Down
6 changes: 0 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,6 @@ GEM
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
public_activity (1.5.0)
actionpack (>= 3.0.0)
activerecord (>= 3.0)
i18n (>= 0.5.0)
railties (>= 3.0.0)
public_suffix (2.0.5)
puma (3.9.1)
rack (2.0.3)
Expand Down Expand Up @@ -375,7 +370,6 @@ DEPENDENCIES
omniauth-vkontakte
overcommit
pg (~> 0.18)
public_activity
puma (~> 3.0)
rails (~> 5.0.1)
rails-assets-tether (>= 1.3.3)!
Expand Down
7 changes: 4 additions & 3 deletions app/controllers/dashboard_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ class DashboardController < ApplicationController

def index
@room = Room.includes(:users, room_actions: :user_actions).where(id: current_user.room_id).first
@activities = PublicActivity::Activity.order('created_at desc').where(owner_id: current_user.room.user_ids)
# TODO: get array of activities
@activities = []
end

def submit_done_action
action = current_user.user_actions.find_by(id: params[:user_action][:id])

action.update(value: action.value + 1)

action.create_activity :done, owner: current_user
# TODO: create activity
redirect_to dashboard_path, notice: "Good job, #{current_user.name}, for \"#{action.name}\"!"
end

Expand All @@ -24,7 +25,7 @@ def punish
users.each do |user|
user_action = user.user_actions.find_by(room_action_id: room_action.id)
user_action.update(value: user_action.value - 1)
user_action.create_activity :punished, owner: current_user
# create_punishment
end

redirect_to dashboard_path, notice: 'Roommates are successfully punished.'
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/rooms_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ def reset_progress
user_action.update(value: 0)
end

room.create_activity :resetted, owner: current_user

redirect_to dashboard_path, notice: 'Resetted room progress successfully.'
end

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

validates :name, presence: true

include PublicActivity::Common
has_many :activities, as: :trackable, class_name: 'PublicActivity::Activity', dependent: :destroy

def invite_url
Rails.application.routes.url_helpers.join_room_url(token: invite_token, host: 'room538.herokuapp.com')
end
Expand Down
3 changes: 0 additions & 3 deletions app/models/user_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,4 @@ class UserAction < ApplicationRecord

default_scope { includes(:room_action).order(:id) }
delegate :name, to: :room_action

include PublicActivity::Common
has_many :activities, as: :trackable, class_name: 'PublicActivity::Activity', dependent: :destroy
end
21 changes: 21 additions & 0 deletions db/migrate/20170719180335_destroy_public_activities_table.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class DestroyPublicActivitiesTable < ActiveRecord::Migration[5.0]
def up
drop_table :activities
end

def down
create_table :activities do |t|
t.belongs_to :trackable, polymorphic: true
t.belongs_to :owner, polymorphic: true
t.string :key
t.text :parameters
t.belongs_to :recipient, polymorphic: true

t.timestamps
end

add_index :activities, [:trackable_id, :trackable_type]
add_index :activities, [:owner_id, :owner_type]
add_index :activities, [:recipient_id, :recipient_type]
end
end
18 changes: 1 addition & 17 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20170719174950) do
ActiveRecord::Schema.define(version: 20170719180335) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand All @@ -22,22 +22,6 @@
t.integer "creator_id"
end

create_table "activities", force: :cascade do |t|
t.string "trackable_type"
t.integer "trackable_id"
t.string "owner_type"
t.integer "owner_id"
t.string "key"
t.text "parameters"
t.string "recipient_type"
t.integer "recipient_id"
t.datetime "created_at"
t.datetime "updated_at"
t.index ["owner_id", "owner_type"], name: "index_activities_on_owner_id_and_owner_type", using: :btree
t.index ["recipient_id", "recipient_type"], name: "index_activities_on_recipient_id_and_recipient_type", using: :btree
t.index ["trackable_id", "trackable_type"], name: "index_activities_on_trackable_id_and_trackable_type", using: :btree
end

create_table "invites", force: :cascade do |t|
t.integer "user_id"
t.integer "room_id"
Expand Down
7 changes: 4 additions & 3 deletions spec/features/dashboard_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
expect(room_action.next_on_user).not_to eq user

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

0 comments on commit 67d3f19

Please sign in to comment.