Skip to content

Commit

Permalink
improve 'Customer Auth' filter on cdrs index page
Browse files Browse the repository at this point in the history
  • Loading branch information
artemlutsenko authored and gigorok committed Jun 18, 2024
1 parent 4dbed9c commit 82c435c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/admin/cdr/cdrs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ def scoped_collection
contractor_filter :vendor_id_eq, label: 'Vendor', path_params: { q: { vendor_eq: true } }
account_filter :vendor_acc_id_eq, label: 'Vendor account'

filter :customer_auth, collection: proc { CustomersAuth.select(%i[id name]).reorder(:name) }, input_html: { class: 'chosen' }
association_ajax_filter :customer_auth_id_eq,
label: 'Customer Auth',
scope: -> { CustomersAuth.order(:name) },
path: '/customers_auths/search'
filter :src_prefix_routing, filters: %i[equals contains starts_with ends_with]
filter :src_area, collection: proc { Routing::Area.select(%i[id name]) }, input_html: { class: 'chosen' }
filter :dst_prefix_routing, filters: %i[equals contains starts_with ends_with]
Expand Down
1 change: 1 addition & 0 deletions app/admin/routing/customers_auths.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
acts_as_delayed_job_lock

search_support!(search_name: :search_with_return_external_id, id_column: :external_id)
search_support!

decorate_with CustomersAuthDecorator

Expand Down
28 changes: 28 additions & 0 deletions spec/features/cdr/cdr_history/cdr_filter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,32 @@
end
end
end

describe 'filter by customer auth' do
let(:filter_cdr_records) do
within_filters do
fill_in_chosen 'Customer Auth', with: customer_auths[0].name, ajax: true
end
end

let!(:customer_auths) { FactoryBot.create_list(:customers_auth, 3) }
let!(:cdrs) do
[
FactoryBot.create(:cdr, customer_auth_id: customer_auths[0].id),
FactoryBot.create(:cdr, customer_auth_id: customer_auths[1].id),
FactoryBot.create(:cdr, customer_auth_id: customer_auths[2].id)
]
end

it 'shows filtered records with customer auth' do
subject
expect(page).to have_table
expect(page).to have_table_row(count: 1)
expect(page).to have_table_cell(column: 'Id', exact_text: cdrs[0].id.to_s)
expect(page).to have_table_cell(column: 'Customer Auth', exact_text: cdrs[0].customer_auth.display_name)
within_filters do
expect(page).to have_field_chosen('Customer Auth', with: customer_auths[0].display_name)
end
end
end
end

0 comments on commit 82c435c

Please sign in to comment.