Skip to content

Commit

Permalink
feat: rename integration_error_detail model to error_detail
Browse files Browse the repository at this point in the history
  • Loading branch information
Anna Velentsevich authored and annvelents committed Jul 23, 2024
1 parent 8bce450 commit f02db0e
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# frozen_string_literal: true

class IntegrationErrorDetail < ApplicationRecord
class ErrorDetail < ApplicationRecord
include Discard::Model
self.discard_column = :deleted_at

belongs_to :error_producer, polymorphic: true
belongs_to :integration, polymorphic: true
belongs_to :owner, polymorphic: true
end
2 changes: 1 addition & 1 deletion app/models/integrations/base_integration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class BaseIntegration < ApplicationRecord
class_name: 'IntegrationCustomers::BaseCustomer',
foreign_key: :integration_id,
dependent: :destroy
has_many :integration_error_details, as: :error_producer
has_many :error_details, as: :integration

validates :code, uniqueness: {scope: :organization_id}
validates :name, presence: true
Expand Down
2 changes: 1 addition & 1 deletion app/models/invoice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Invoice < ApplicationRecord
has_many :applied_taxes, class_name: 'Invoice::AppliedTax', dependent: :destroy
has_many :taxes, through: :applied_taxes
has_many :integration_resources, as: :syncable
has_many :integration_error_details, as: :owner, dependent: :destroy
has_many :error_details, as: :owner, dependent: :destroy

has_one_attached :file

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# frozen_string_literal: true

FactoryBot.define do
factory :integration_error_detail do
factory :error_detail do
association :owner, factory: %i[invoice].sample
association :error_producer, factory: :anrok_integration
association :integration, factory: :anrok_integration
end
end
8 changes: 8 additions & 0 deletions spec/models/error_detail_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe ErrorDetail, type: :model do
it { is_expected.to belong_to(:owner) }
it { is_expected.to belong_to(:integration).optional }
end
8 changes: 0 additions & 8 deletions spec/models/integration_error_detail_spec.rb

This file was deleted.

2 changes: 1 addition & 1 deletion spec/models/integrations/base_integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
it { is_expected.to have_many(:integration_customers).dependent(:destroy) }
it { is_expected.to have_many(:integration_items).dependent(:destroy) }
it { is_expected.to have_many(:integration_resources).dependent(:destroy) }
it { is_expected.to have_many(:integration_error_details) }
it { is_expected.to have_many(:error_details) }

describe '.secrets_json' do
it { expect(integration.secrets_json).to eq(secrets) }
Expand Down
3 changes: 1 addition & 2 deletions spec/models/invoice_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
it_behaves_like 'paper_trail traceable'

it { is_expected.to have_many(:integration_resources) }

it { is_expected.to have_many(:integration_error_details) }
it { is_expected.to have_many(:error_details) }

describe 'validation' do
describe 'of payment dispute lost absence' do
Expand Down

0 comments on commit f02db0e

Please sign in to comment.