-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #744 from Ivanov-Anton/filter_bug
resolve #743, fixed filters named routing_tag_ids_array_contains and tagged
- Loading branch information
Showing
10 changed files
with
218 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,6 @@ | ||
# frozen_string_literal: true | ||
|
||
# https://github.com/activerecord-hackery/ransack/issues/321 | ||
Ransack.configure do |config| | ||
{ array_contains: :contains }.each do |rp, ap| | ||
config.add_predicate rp, arel_predicate: ap, wants_array: true | ||
end | ||
config.ignore_unknown_conditions = false | ||
config.sanitize_custom_scope_booleans = false | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe 'Filter Customers Auths records', :js do | ||
include_context :login_as_admin | ||
let!(:_customers_auths_list) { create_list :customers_auth, 2 } | ||
before { visit customers_auths_path } | ||
|
||
context 'by' do | ||
context '"SRC PREFIX"' do | ||
prefix = '_src_' | ||
let!(:customers_auth_src) { create(:customers_auth, src_prefix: [prefix]) } | ||
it 'should have filtered record only' do | ||
fill_in 'SRC Prefix', with: prefix | ||
click_button :Filter | ||
expect(page).to have_css 'table.index_table tbody tr', count: 1 | ||
expect(page).to have_css '.resource_id_link', text: customers_auth_src.id | ||
expect(page).to have_field 'SRC Prefix', with: prefix | ||
end | ||
end | ||
|
||
context '"DST PREFIX"' do | ||
prefix = '_dst_' | ||
let!(:customers_auth_dst) { create(:customers_auth, dst_prefix: [prefix]) } | ||
it 'should have filtered record only' do | ||
fill_in 'DST Prefix', with: prefix | ||
click_button :Filter | ||
expect(page).to have_css 'table.index_table tbody tr', count: 1 | ||
expect(page).to have_css '.resource_id_link', text: customers_auth_dst.id | ||
expect(page).to have_field 'DST Prefix', with: prefix | ||
end | ||
end | ||
|
||
context '"URI DOMAIN"' do | ||
domain = 'main.com' | ||
let!(:customers_auth_domain) { create(:customers_auth, uri_domain: [domain]) } | ||
it 'should have filtered record only' do | ||
fill_in 'URI Domain', with: domain | ||
click_button :Filter | ||
expect(page).to have_css 'table.index_table tbody tr', count: 1 | ||
expect(page).to have_css '.resource_id_link', text: customers_auth_domain.id | ||
expect(page).to have_field 'URI Domain', with: domain | ||
end | ||
end | ||
|
||
context '"FROM DOMAIN"' do | ||
domain = 'main.com' | ||
let!(:customers_auth_f_domain) { create(:customers_auth, from_domain: [domain]) } | ||
it 'should have filtered record only' do | ||
fill_in 'From Domain', with: domain | ||
click_button :Filter | ||
expect(page).to have_css 'table.index_table tbody tr', count: 1 | ||
expect(page).to have_css '.resource_id_link', text: customers_auth_f_domain.id | ||
expect(page).to have_field 'From Domain', with: domain | ||
end | ||
end | ||
|
||
context '"TO DOMAIN"' do | ||
domain = 'main.com' | ||
let!(:customers_auth_t_domain) { create(:customers_auth, to_domain: [domain]) } | ||
it 'should have filtered record only' do | ||
fill_in 'To Domain', with: domain | ||
click_button :Filter | ||
expect(page).to have_css 'table.index_table tbody tr', count: 1 | ||
expect(page).to have_css '.resource_id_link', text: customers_auth_t_domain.id | ||
expect(page).to have_field 'To Domain', with: domain | ||
end | ||
end | ||
|
||
context '"X-YETI-AUTH"' do | ||
domain = 'string' | ||
let!(:customers_auth_x_domain) { create(:customers_auth, x_yeti_auth: [domain]) } | ||
it 'should have filtered record only' do | ||
fill_in 'X-Yeti-Auth', with: domain | ||
click_button :Filter | ||
expect(page).to have_css 'table.index_table tbody tr', count: 1 | ||
expect(page).to have_css '.resource_id_link', text: customers_auth_x_domain.id | ||
expect(page).to have_field 'X-Yeti-Auth', with: domain | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe 'Filter Destination records', :js do | ||
include_context :login_as_admin | ||
let!(:other_destinations_list) { create_list :destination, 2 } | ||
|
||
context 'by' do | ||
context '"TAGGED"' do | ||
let!(:tag) { create :routing_tag, :ua } | ||
let!(:customers_auth_tagged) { create :destination, routing_tag_ids: [tag.id] } | ||
|
||
it 'should have records with any tag' do | ||
visit destinations_path | ||
select :Yes, from: :Tagged | ||
click_button :Filter | ||
expect(page).to have_css 'table.index_table tbody tr', count: 1 | ||
expect(page).to have_css '.resource_id_link', text: customers_auth_tagged.id | ||
expect(page).to have_select :Tagged, selected: 'Yes' | ||
end | ||
|
||
it 'should have record without any tag' do | ||
visit destinations_path | ||
select :No, from: :Tagged | ||
click_button :Filter | ||
expect(page).to have_css 'table.index_table tbody tr', count: other_destinations_list.count | ||
expect(page).to have_select :Tagged, selected: 'No' | ||
other_destinations_list.each { |d| expect(page).to have_css('.resource_id_link', text: d.id) } | ||
end | ||
end | ||
|
||
context '"ROUTING TAG IDS CONTAINS"' do | ||
let!(:tag_us) { create :routing_tag } | ||
let!(:tag_ua) { create :routing_tag } | ||
let!(:destinations_tag_contains) { create :destination, routing_tag_ids: [tag_us.id, tag_ua.id] } | ||
|
||
it 'should have one record with routing_tag only' do | ||
visit destinations_path | ||
chosen_pick '#q_routing_tag_ids_array_contains_chosen', text: tag_us.name | ||
chosen_pick '#q_routing_tag_ids_array_contains_chosen', text: tag_ua.name | ||
click_button :Filter | ||
expect(page).to have_css 'table.index_table tbody tr', count: 1 | ||
expect(page).to have_css '.resource_id_link', text: destinations_tag_contains.id | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe 'Filter Destination records', :js do | ||
include_context :login_as_admin | ||
let!(:other_dialpeers) { create_list :dialpeer, 2 } | ||
before { visit dialpeers_path } | ||
|
||
context 'by' do | ||
context '"TAGGED"' do | ||
let!(:tag) { create :routing_tag } | ||
let!(:dialpeer_tagged) { create :dialpeer, routing_tag_ids: [tag.id] } | ||
|
||
it 'should have record with any tag' do | ||
select :Yes, from: :Tagged | ||
click_button :Filter | ||
expect(page).to have_css 'table.index_table tbody tr', count: 1 | ||
expect(page).to have_css '.resource_id_link', text: dialpeer_tagged.id | ||
expect(page).to have_select :Tagged, selected: 'Yes' | ||
end | ||
|
||
it 'should have record without any tag' do | ||
select :No, from: :Tagged | ||
click_button :Filter | ||
expect(page).to have_css('table.index_table tbody tr', count: other_dialpeers.count) | ||
expect(page).to have_select :Tagged, selected: 'No' | ||
other_dialpeers.each { |p| expect(page).to have_css '.resource_id_link', text: p.id } | ||
end | ||
end | ||
|
||
context '"ROUTING TAG IDS CONTAINS"' do | ||
let!(:tag_us) { create :routing_tag, :us } | ||
let!(:tag_ua) { create :routing_tag, :ua } | ||
let!(:dialpeer_tag_countains) { create :dialpeer, routing_tag_ids: [tag_us.id, tag_ua.id] } | ||
|
||
it 'should have one record with routing_tag only' do | ||
visit dialpeers_path | ||
chosen_pick '#q_routing_tag_ids_array_contains_chosen', text: tag_us.name | ||
chosen_pick '#q_routing_tag_ids_array_contains_chosen', text: tag_ua.name | ||
click_button :Filter | ||
expect(page).to have_css 'table.index_table tbody tr', count: 1 | ||
expect(page).to have_css '.resource_id_link', text: dialpeer_tag_countains.id | ||
end | ||
end | ||
end | ||
end |
21 changes: 21 additions & 0 deletions
21
spec/features/routing/routing_tag_detection_rules/filters_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe 'Filter Routing Tag detection rule records', :js do | ||
include_context :login_as_admin | ||
let!(:routing_tag_detection_rule_list) { create_list :routing_tag_detection_rule, 2 } | ||
context 'by' do | ||
context '"ROUTING TAG IDS CONTAINS"' do | ||
let!(:tag_us) { create :routing_tag, :us } | ||
let!(:tag_ua) { create :routing_tag, :ua } | ||
let!(:routing_tag_contains) { create :routing_tag_detection_rule, routing_tag_ids: [tag_us.id, tag_ua.id] } | ||
it 'should have one record with routing_tags only' do | ||
visit routing_routing_tag_detection_rules_path | ||
chosen_pick '#q_routing_tag_ids_array_contains_chosen', text: tag_us.name | ||
chosen_pick '#q_routing_tag_ids_array_contains_chosen', text: tag_ua.name | ||
click_button :Filter | ||
expect(page).to have_css 'table.index_table tbody tr', count: 1 | ||
expect(page).to have_css '.resource_id_link', text: routing_tag_contains.id | ||
end | ||
end | ||
end | ||
end |