From 42ccefe2ce86455b10ebdf98a2d98c810886469d Mon Sep 17 00:00:00 2001 From: Oleksii Kriuchykhin Date: Thu, 30 Mar 2017 11:47:57 +0200 Subject: [PATCH] Remove logs table and old unused logging code [SCI-1127] --- app/controllers/application_controller.rb | 12 --------- app/models/log.rb | 6 ----- app/models/my_module.rb | 6 ----- app/models/project.rb | 6 ----- app/models/team.rb | 7 ----- .../20170330092353_remove_logs_table.rb | 5 ++++ test/models/log_test.rb | 27 ------------------- test/models/my_module_test.rb | 7 ----- test/models/team_test.rb | 7 ----- 9 files changed, 5 insertions(+), 78 deletions(-) delete mode 100644 app/models/log.rb create mode 100644 db/migrate/20170330092353_remove_logs_table.rb delete mode 100644 test/models/log_test.rb diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index b3fcb0de1..60bfa9b06 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -32,18 +32,6 @@ class ApplicationController < ActionController::Base protected - def log(message) - if @my_module - @my_module.log(message) - elsif @project - @project.log(message) - elsif @team - @team.log(message) - else - logger.error(message) - end - end - def render_403(style = 'danger') respond_to do |format| format.html do diff --git a/app/models/log.rb b/app/models/log.rb deleted file mode 100644 index 0fa88e1e5..000000000 --- a/app/models/log.rb +++ /dev/null @@ -1,6 +0,0 @@ -class Log < ActiveRecord::Base - validates :message, presence: true - validates :team, presence: true - - belongs_to :team, inverse_of: :logs -end diff --git a/app/models/my_module.rb b/app/models/my_module.rb index 99be7b97f..a2e0d6ebf 100644 --- a/app/models/my_module.rb +++ b/app/models/my_module.rb @@ -348,12 +348,6 @@ class MyModule < ActiveRecord::Base return clone end - # Writes to user log. - def log(message) - final = "[%s] %s" % [name, message] - experiment.project.log(final) - end - # Find an empty position for the restored module. It's # basically a first empty row with empty space inside x=[0, 32). def get_new_position diff --git a/app/models/project.rb b/app/models/project.rb index dd9f12186..d86761d62 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -160,12 +160,6 @@ class Project < ActiveRecord::Base st end - # Writes to user log. - def log(message) - final = "[%s] %s" % [name, message] - team.log(final) - end - def assigned_samples Sample.joins(:my_modules).where(my_modules: { id: my_modules_ids.split(',') diff --git a/app/models/team.rb b/app/models/team.rb index 4a31155f6..7099e78ce 100644 --- a/app/models/team.rb +++ b/app/models/team.rb @@ -20,7 +20,6 @@ class Team < ActiveRecord::Base has_many :samples_tables, inverse_of: :team, dependent: :destroy has_many :sample_groups, inverse_of: :team has_many :sample_types, inverse_of: :team - has_many :logs, inverse_of: :team has_many :projects, inverse_of: :team has_many :custom_fields, inverse_of: :team has_many :protocols, inverse_of: :team, dependent: :destroy @@ -71,12 +70,6 @@ class Team < ActiveRecord::Base .where_attributes_like(attributes, a_query) end - # Writes to user log - def log(message) - final = "[%s] %s" % [Time.current.to_s, message] - logs.create(message: final) - end - # Imports samples into db # -1 == sample_name, # -2 == sample_type, diff --git a/db/migrate/20170330092353_remove_logs_table.rb b/db/migrate/20170330092353_remove_logs_table.rb new file mode 100644 index 000000000..75028158f --- /dev/null +++ b/db/migrate/20170330092353_remove_logs_table.rb @@ -0,0 +1,5 @@ +class RemoveLogsTable < ActiveRecord::Migration + def change + drop_table :logs + end +end diff --git a/test/models/log_test.rb b/test/models/log_test.rb deleted file mode 100644 index ca270dad2..000000000 --- a/test/models/log_test.rb +++ /dev/null @@ -1,27 +0,0 @@ -require 'test_helper' - -class LogTest < ActiveSupport::TestCase - def setup - @log = logs(:one) - end - - test 'should validate log with valid data' do - assert @log.valid? - end - - test 'should have non-blank message' do - @log.message = '' - assert @log.invalid?, 'Log with blank message returns valid? = true' - @log.message = nil - assert @log.invalid?, 'Log with nil message returns valid? = true' - end - - test 'should have team' do - @log.team_id = 12321321 - assert @log.invalid?, 'Log without team returns valid? = true' - @log.team = nil - assert @log.invalid?, 'Log without team returns valid? = true' - @log.team = Team.new - assert @log.valid?, 'Log with team returns valid? = false' - end -end diff --git a/test/models/my_module_test.rb b/test/models/my_module_test.rb index 77b82cb1b..4e2872016 100644 --- a/test/models/my_module_test.rb +++ b/test/models/my_module_test.rb @@ -141,11 +141,4 @@ class MyModuleTest < ActiveSupport::TestCase test "should deep clone module" do skip end - - test "should save log message" do - message = "This is test message for my module" - @my_module.log(message) - log_message = Log.last.message - assert_equal log_message[57..-1], message - end end diff --git a/test/models/team_test.rb b/test/models/team_test.rb index e0a039e88..0f8fa510b 100644 --- a/test/models/team_test.rb +++ b/test/models/team_test.rb @@ -32,13 +32,6 @@ class TeamTest < ActiveSupport::TestCase assert_equal Constants::MINIMAL_TEAM_SPACE_TAKEN, team.space_taken end - test 'should save log message' do - message = 'This is test message' - @team.log(message) - log_message = Log.last.message[26..-1] - assert_equal log_message, message - end - test 'should open spreadsheet file' do skip end