-
Notifications
You must be signed in to change notification settings - Fork 293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implement filters in nested select #300 #301
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -185,6 +185,83 @@ | |
end | ||
end | ||
end | ||
context "with filters", focus: true do | ||
before do | ||
register_page(Country, false) {} | ||
register_page(Region, false) {} | ||
register_page(City, false) {} | ||
|
||
register_form(Invoice, false) do |f| | ||
f.input :city_id, as: :nested_select, | ||
level_1: { attribute: :country_id }, | ||
level_2: { | ||
attribute: :region_id, | ||
filters: { name_contains: 'Met' } | ||
}, | ||
level_3: { attribute: :city_id } | ||
end | ||
|
||
create_cities | ||
create_invoice(city: @colina) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace instance variable with local variable or let. |
||
visit edit_admin_invoice_path(@invoice) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace instance variable with local variable or let. |
||
end | ||
|
||
it "shows filled select controls based on defined city_id", js: true do | ||
on_input_ctx("invoice_country_id") { expect_select2_selection("Chile") } | ||
on_input_ctx("invoice_region_id") { expect_select2_selection("Metropolitana") } | ||
on_input_ctx("invoice_city_id") { expect_select2_selection("Colina") } | ||
end | ||
|
||
context "updating medium level" do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Start context description with 'when', 'with', or 'without'. |
||
before do | ||
on_input_ctx("invoice_region_id") { open_select2_options } | ||
select2_input.set("a") | ||
end | ||
|
||
it "shows no results based on entered text", js: true do | ||
expect_select2_results_count_to_eq(1) | ||
end | ||
end | ||
end | ||
|
||
context "without filters", focus: true do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Focused spec found. |
||
before do | ||
register_page(Country, false) {} | ||
register_page(Region, false) {} | ||
register_page(City, false) {} | ||
|
||
register_form(Invoice, false) do |f| | ||
f.input :city_id, as: :nested_select, | ||
level_1: { attribute: :country_id }, | ||
level_2: { | ||
attribute: :region_id, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid comma after the last item of a hash. |
||
# filters: { name_contains: 'Met' } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Incorrect indentation detected (column 28 instead of 30). |
||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indent the right brace the same as the start of the line where the left brace is. |
||
level_3: { attribute: :city_id } | ||
end | ||
|
||
create_cities | ||
create_invoice(city: @colina) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace instance variable with local variable or let. |
||
visit edit_admin_invoice_path(@invoice) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace instance variable with local variable or let. |
||
end | ||
|
||
it "shows filled select controls based on defined city_id", js: true do | ||
on_input_ctx("invoice_country_id") { expect_select2_selection("Chile") } | ||
on_input_ctx("invoice_region_id") { expect_select2_selection("Metropolitana") } | ||
on_input_ctx("invoice_city_id") { expect_select2_selection("Colina") } | ||
end | ||
|
||
context "updating medium level" do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Start context description with 'when', 'with', or 'without'. |
||
before do | ||
on_input_ctx("invoice_region_id") { open_select2_options } | ||
select2_input.set("a") | ||
end | ||
|
||
it "shows no results based on entered text", js: true do | ||
expect_select2_results_count_to_eq(2) | ||
end | ||
end | ||
end | ||
|
||
context "with nested resources" do | ||
before do | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indent the right brace the same as the start of the line where the left brace is.