Remove search keywords (#5259) [deploy]
This commit is contained in:
parent
660852b711
commit
d015fb7c85
4 changed files with 14 additions and 50 deletions
|
|
@ -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
|
||||
13
db/migrate/20191227114543_drop_search_keywords.rb
Normal file
13
db/migrate/20191227114543_drop_search_keywords.rb
Normal file
|
|
@ -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
|
||||
14
db/schema.rb
14
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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
Loading…
Add table
Reference in a new issue