Remove job_opportunities table (#6932)

This commit is contained in:
rhymes 2020-03-30 18:08:10 +02:00 committed by GitHub
parent ba4b6593bc
commit 4baa9d3165
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 89 deletions

View file

@ -19,7 +19,6 @@ class Article < ApplicationRecord
delegate :username, to: :user, prefix: true
belongs_to :user
belongs_to :job_opportunity, optional: true
belongs_to :organization, optional: true
# touch: true was removed because when an article is updated, the associated collection
# is touched along with all its articles(including this one). This causes eventually a deadlock.

View file

@ -1,16 +0,0 @@
class JobOpportunity < ApplicationRecord
REMOTENESS_PHRASES = {
"on_premise" => "In Office",
"fully_remote" => "Fully Remote",
"remote_optional" => "Remote Optional",
"on_premise_flexible" => "Mostly in Office but Flexible"
}.freeze
has_many :articles
validates :remoteness, inclusion: { in: REMOTENESS_PHRASES.keys }
def remoteness_in_words
REMOTENESS_PHRASES[remoteness]
end
end

View file

@ -0,0 +1,17 @@
class DropJobOpportunities < ActiveRecord::Migration[5.2]
def change
drop_table :job_opportunities do |t|
t.string :experience_level
t.string :location_city
t.string :location_country_code
t.string :location_given
t.decimal :location_lat, precision: 10, scale: 6
t.decimal :location_long, precision: 10, scale: 6
t.string :location_postal_code
t.string :permanency
t.string :remoteness
t.string :time_commitment
t.timestamps
end
end
end

View file

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2020_03_26_111645) do
ActiveRecord::Schema.define(version: 2020_03_29_103305) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -569,21 +569,6 @@ ActiveRecord::Schema.define(version: 2020_03_26_111645) do
t.index ["provider", "user_id"], name: "index_identities_on_provider_and_user_id", unique: true
end
create_table "job_opportunities", force: :cascade do |t|
t.datetime "created_at", null: false
t.string "experience_level"
t.string "location_city"
t.string "location_country_code"
t.string "location_given"
t.decimal "location_lat", precision: 10, scale: 6
t.decimal "location_long", precision: 10, scale: 6
t.string "location_postal_code"
t.string "permanency"
t.string "remoteness"
t.string "time_commitment"
t.datetime "updated_at", null: false
end
create_table "mentions", id: :serial, force: :cascade do |t|
t.datetime "created_at", null: false
t.integer "mentionable_id"

View file

@ -1,56 +0,0 @@
require "rails_helper"
RSpec.describe JobOpportunity, type: :model do
let(:job_opportunity) { described_class.new(remoteness: "on_premise") }
context "when validations" do
describe "#remoteness" do
it "is valid with on_premise" do
job_opportunity.remoteness = "on_premise"
expect(job_opportunity).to be_valid
end
it "is valid with fully_remote" do
job_opportunity.remoteness = "fully_remote"
expect(job_opportunity).to be_valid
end
it "is valid with remote_optional" do
job_opportunity.remoteness = "remote_optional"
expect(job_opportunity).to be_valid
end
it "is valid with on_premise_flexible" do
job_opportunity.remoteness = "on_premise_flexible"
expect(job_opportunity).to be_valid
end
it "is not valid an arbitrary word" do
job_opportunity.remoteness = "foobar"
expect(job_opportunity).not_to be_valid
end
end
end
describe "#remoteness_in_words" do
it "returns remoteness in words for on_premise" do
job_opportunity.remoteness = "on_premise"
expect(job_opportunity.remoteness_in_words).to eq("In Office")
end
it "returns remoteness in words for fully_remote" do
job_opportunity.remoteness = "fully_remote"
expect(job_opportunity.remoteness_in_words).to eq("Fully Remote")
end
it "returns remoteness in words for remote_optional" do
job_opportunity.remoteness = "remote_optional"
expect(job_opportunity.remoteness_in_words).to eq("Remote Optional")
end
it "returns remoteness in words for on_premise_flexible" do
job_opportunity.remoteness = "on_premise_flexible"
expect(job_opportunity.remoteness_in_words).to eq("Mostly in Office but Flexible")
end
end
end