Skip to content

Commit

Permalink
fix uninitialised constant DestinationRatePolicy exception (#943)
Browse files Browse the repository at this point in the history
* fix DestinationRatePolicy namespace and add test for /destination_imports

* add more check to test

* add namesmapce to destination rate policy in interval data

* remove extra lines

* replace customer_id to destination_rate_policy_id

* remove destination_rate_policy column

Co-authored-by: Artem Lutsenko <[email protected]>
  • Loading branch information
BigG1947 and Artem Lutsenko authored Apr 16, 2021
1 parent c40f937 commit 78d1aad
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/models/importing/destination.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Importing::Destination < Importing::Base
self.table_name = 'data_import.import_destinations'

belongs_to :rate_group, class_name: 'Routing::RateGroup', optional: true
belongs_to :rate_policy, class_name: '::DestinationRatePolicy', optional: true
belongs_to :rate_policy, class_name: 'Routing::DestinationRatePolicy', optional: true
belongs_to :profit_control_mode, class_name: 'Routing::RateProfitControlMode', foreign_key: 'profit_control_mode_id', optional: true
belongs_to :routing_tag_mode, class_name: 'Routing::RoutingTagMode', foreign_key: :routing_tag_mode_id, optional: true

Expand Down
2 changes: 1 addition & 1 deletion app/models/report/interval_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class Report::IntervalData < Cdr::Base
belongs_to :disconnect_initiator, optional: true
belongs_to :vendor_invoice, class_name: 'Invoice', foreign_key: :vendor_invoice_id, optional: true
belongs_to :customer_invoice, class_name: 'Invoice', foreign_key: :customer_invoice_id, optional: true
belongs_to :destination_rate_policy, class_name: 'DestinationRatePolicy', foreign_key: :destination_rate_policy_id, optional: true
belongs_to :destination_rate_policy, class_name: 'Routing::DestinationRatePolicy', foreign_key: :destination_rate_policy_id, optional: true
belongs_to :node, class_name: 'Node', foreign_key: :node_id, optional: true
belongs_to :pop, class_name: 'Pop', foreign_key: :pop_id, optional: true
belongs_to :dst_country, class_name: 'System::Country', foreign_key: :dst_country_id, optional: true
Expand Down
1 change: 1 addition & 0 deletions spec/factories/reports/interval_cdr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
date_start { Time.now.utc }
date_end { Time.now.utc + 1.week }
interval_length { 10 }
group_by { 'destination_rate_policy_id' }
aggregator_id { Report::IntervalAggregator.take.id }
aggregate_by { 'destination_fee' }
end
Expand Down
8 changes: 8 additions & 0 deletions spec/factories/reports/interval_data.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# frozen_string_literal: true

FactoryBot.define do
factory :interval_data, class: Report::IntervalData do
report { association :interval_cdr }
destination_rate_policy_id { 1 }
end
end
18 changes: 18 additions & 0 deletions spec/features/reports/interval_cdrs/show_interval_cdr_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true

RSpec.describe 'Show interval cdrs report' do
include_context :login_as_admin

let!(:report) { create(:interval_cdr) }
let!(:interval_data) { create(:interval_data, report: report) }

subject { visit report_interval_cdr_interval_items_path report_interval_cdr_id: report.id }

it 'should have tabel with interval data and destination rate pocily' do
subject
expect(page).to have_table
within_table_row(id: interval_data.id) do
expect(page).to have_table_cell(text: 'Fixed', column: 'Destination Rate Policy')
end
end
end
27 changes: 27 additions & 0 deletions spec/features/routing/destinations/import_destination_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# frozen_string_literal: true

RSpec.describe 'Destination imports', type: :feature do
include_context :login_as_admin

subject { visit destination_imports_path }

context 'with importing destination items' do
let!(:importing_destination) { create(:importing_destination) }

it 'should have table with items' do
subject
expect(page).to have_table
within_table_row(id: importing_destination.id) do
expect(page).to have_table_cell(text: 'Fixed', column: 'Rate Policy')
end
end
end

context 'without importing destintaion items' do
it 'shouldn`t have table with items' do
subject
expect(page).to_not have_table
expect(page).to have_text('There are no Destination Imports yet.')
end
end
end

0 comments on commit 78d1aad

Please sign in to comment.