diff --git a/Gemfile b/Gemfile index 309e08d..d2a1edd 100644 --- a/Gemfile +++ b/Gemfile @@ -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 diff --git a/Gemfile.lock b/Gemfile.lock index 9ffe373..d6c13bd 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) @@ -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)! diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index b976949..330f959 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -4,7 +4,8 @@ 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 @@ -12,7 +13,7 @@ def submit_done_action 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 @@ -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.' diff --git a/app/controllers/rooms_controller.rb b/app/controllers/rooms_controller.rb index 2501761..ea12b35 100644 --- a/app/controllers/rooms_controller.rb +++ b/app/controllers/rooms_controller.rb @@ -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 diff --git a/app/models/room.rb b/app/models/room.rb index baea35d..a91d672 100644 --- a/app/models/room.rb +++ b/app/models/room.rb @@ -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 diff --git a/app/models/user_action.rb b/app/models/user_action.rb index 5d70036..c1a1135 100644 --- a/app/models/user_action.rb +++ b/app/models/user_action.rb @@ -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 diff --git a/db/migrate/20170719180335_destroy_public_activities_table.rb b/db/migrate/20170719180335_destroy_public_activities_table.rb new file mode 100644 index 0000000..fad61bc --- /dev/null +++ b/db/migrate/20170719180335_destroy_public_activities_table.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index 3c3014d..623d76e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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" @@ -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" diff --git a/spec/features/dashboard_spec.rb b/spec/features/dashboard_spec.rb index 228e289..4a77c56 100644 --- a/spec/features/dashboard_spec.rb +++ b/spec/features/dashboard_spec.rb @@ -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