Skip to content

Commit 0e648b5

Browse files
Ivanov-Antonsenid231
Ivanov-Anton
andauthored
to make the methods within_*_has_many more universal (#13)
* to make the method within_form_has_many more universal * removed extra empty line Co-authored-by: Denis Talakevich <[email protected]> Co-authored-by: Denis Talakevich <[email protected]>
1 parent 2e23a00 commit 0e648b5

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

lib/capybara/active_admin/finders/form.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ def within_form_has_many(association_name, index: 0)
2222
within(fieldset) { yield }
2323
end
2424

25+
# @param association_name [String]
26+
# @yield within container have_many by passed association_name
27+
def within_has_many(association_name)
28+
selector = has_many_container_selector(association_name)
29+
within(selector) { yield }
30+
end
31+
2532
# @yield within filters container.
2633
def within_filters
2734
selector = filter_form_selector

lib/capybara/active_admin/selectors/form.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ def has_many_fields_selector(association_name)
3535
"div.has_many_container.#{association_name} > fieldset.inputs.has_many_fields"
3636
end
3737

38+
# @param association_name [String]
39+
# @return [String] .has_many_container selector.
40+
def has_many_container_selector(association_name)
41+
".has_many_container.#{association_name}"
42+
end
43+
3844
# @param text [String, nil] submit button text.
3945
# @return [String] selector.
4046
def form_submit_selector(text = nil)

0 commit comments

Comments
 (0)