diff --git a/app/models/search_keyword.rb b/app/models/search_keyword.rb deleted file mode 100644 index a2d53c485..000000000 --- a/app/models/search_keyword.rb +++ /dev/null @@ -1,15 +0,0 @@ -class SearchKeyword < ApplicationRecord - validates :keyword, presence: true - validates :google_result_path, presence: true - validates :google_position, presence: true - validates :google_volume, presence: true - validates :google_difficulty, presence: true - validates :google_checked_at, presence: true - validate :path_format - - private - - def path_format - errors.add(:google_result_path, "must start with / and be properly formatted") unless google_result_path&.starts_with?("/") && google_result_path&.count("/") == 2 - end -end diff --git a/db/migrate/20191227114543_drop_search_keywords.rb b/db/migrate/20191227114543_drop_search_keywords.rb new file mode 100644 index 000000000..56442c9cc --- /dev/null +++ b/db/migrate/20191227114543_drop_search_keywords.rb @@ -0,0 +1,13 @@ +class DropSearchKeywords < ActiveRecord::Migration[5.2] + def change + drop_table :search_keywords do |t| + t.string :keyword + t.string :google_result_path + t.integer :google_position + t.integer :google_volume + t.integer :google_difficulty + t.datetime :google_checked_at + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 258af4354..eb6e5efc7 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: 2019_12_26_202114) do +ActiveRecord::Schema.define(version: 2019_12_27_114543) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -885,18 +885,6 @@ ActiveRecord::Schema.define(version: 2019_12_26_202114) do t.index ["name"], name: "index_roles_on_name" end - create_table "search_keywords", force: :cascade do |t| - t.datetime "created_at", null: false - t.datetime "google_checked_at" - t.integer "google_difficulty" - t.integer "google_position" - t.string "google_result_path" - t.integer "google_volume" - t.string "keyword" - t.datetime "updated_at", null: false - t.index ["google_result_path"], name: "index_search_keywords_on_google_result_path" - end - create_table "site_configs", force: :cascade do |t| t.datetime "created_at", null: false t.datetime "updated_at", null: false diff --git a/spec/models/search_keyword_spec.rb b/spec/models/search_keyword_spec.rb deleted file mode 100644 index 951e91dc1..000000000 --- a/spec/models/search_keyword_spec.rb +++ /dev/null @@ -1,22 +0,0 @@ -require "rails_helper" - -RSpec.describe SearchKeyword, type: :model do - let(:search_keyword) { build(:search_keyword) } - - it { is_expected.to validate_presence_of(:keyword) } - it { is_expected.to validate_presence_of(:google_result_path) } - it { is_expected.to validate_presence_of(:google_position) } - it { is_expected.to validate_presence_of(:google_volume) } - it { is_expected.to validate_presence_of(:google_difficulty) } - it { is_expected.to validate_presence_of(:google_checked_at) } - - it "is valid with proper path" do - search_keyword.google_result_path = "/hello/goodbye" - expect(search_keyword).to be_valid - end - - it "is invalid with improper path" do - search_keyword.google_result_path = "hello/goodbye" - expect(search_keyword).not_to be_valid - end -end