Add park <-> alert relations
This commit is contained in:
@@ -1,2 +1,4 @@
|
||||
class Alert < ApplicationRecord
|
||||
belongs_to :park, foreign_key: :park_code, primary_key: :code,
|
||||
inverse_of: :alerts
|
||||
end
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
class Park < ApplicationRecord
|
||||
has_many :alerts, foreign_key: :park_code, primary_key: :code,
|
||||
inverse_of: :park, dependent: :destroy
|
||||
end
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Alert, type: :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
describe "#park" do
|
||||
it "has a park" do
|
||||
expect(alerts(:one).park).to eq(parks(:one))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user