Skip to content

Commit

Permalink
Use ApplicationWorkHistoryBreak#breakable column
Browse files Browse the repository at this point in the history
We migrated all the data in ba80a6f

Now we can use the breakable columns to link to an application_form
  • Loading branch information
CatalinVoineag committed Aug 20, 2024
1 parent 52a5be8 commit 1324bdf
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/models/application_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ApplicationForm < ApplicationRecord
has_many :application_volunteering_experiences, as: :experienceable
has_many :application_qualifications
has_many :application_references
has_many :application_work_history_breaks
has_many :application_work_history_breaks, as: :breakable
has_many :emails

belongs_to :previous_application_form, class_name: 'ApplicationForm', optional: true, inverse_of: 'subsequent_application_form'
Expand Down
6 changes: 3 additions & 3 deletions app/models/application_work_history_break.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
class ApplicationWorkHistoryBreak < ApplicationRecord
include TouchApplicationChoices

belongs_to :application_form, touch: true
belongs_to :breakable, polymorphic: true, optional: true
belongs_to :application_form, touch: true, optional: true
belongs_to :breakable, polymorphic: true

before_save -> { self.breakable = application_form }, if: -> { breakable.nil? }
before_save -> { self.application_form_id = breakable_id }, if: -> { application_form_id.nil? }

audited associated_with: :application_form

Expand Down
4 changes: 2 additions & 2 deletions spec/models/application_work_history_break_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require 'rails_helper'

RSpec.describe ApplicationWorkHistoryBreak do
it { is_expected.to belong_to(:application_form).touch(true) }
it { is_expected.to belong_to(:breakable).optional }
it { is_expected.to belong_to(:application_form).touch(true).optional }
it { is_expected.to belong_to(:breakable) }

describe 'auditing', :with_audited do
it { is_expected.to be_audited.associated_with :application_form }
Expand Down

0 comments on commit 1324bdf

Please sign in to comment.