Skip to content

Commit 383a2f0

Browse files
committed
Refactor to make rubocop happy
1 parent fb2d871 commit 383a2f0

File tree

1 file changed

+26
-15
lines changed

1 file changed

+26
-15
lines changed

spec/features/modal_search_spec.rb

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,26 +56,37 @@
5656

5757
# handles opening + closing of the modal, as well as the actions performed within the modal
5858
def perform_modal_actions
59-
# Open the modal
60-
click_button 'Add a repository'
61-
expect(page).to have_text('Repository search')
59+
open_modal
6260

6361
within('#modal-search-repositories') do
64-
# Search for the Repository
65-
fill_in 'research_output_search_term', with: @model.name
66-
click_button 'Apply filter(s)'
67-
expect(page).to have_text(@model.description)
68-
# Select the repository and make sure it no longer appears in the search results
69-
click_link 'Select'
70-
expect(page).not_to have_text(@model.description)
71-
72-
# Using JS to click on button, as click_button '.modal-header button.btn-close' did not work.
73-
modal_close_button = find('.modal-header button.btn-close')
74-
# Close the modal
75-
execute_script('arguments[0].click();', modal_close_button)
62+
search_and_select_repository_within_modal
63+
close_modal
7664
end
7765
# Verify that the selection was added to the main page's dom
7866
expect(page).not_to have_text('Repository search')
7967
expect(page).to have_text(@model.description)
8068
end
69+
70+
def open_modal
71+
# Open the modal
72+
click_button 'Add a repository'
73+
expect(page).to have_text('Repository search')
74+
end
75+
76+
def search_and_select_repository_within_modal
77+
# Search for the Repository
78+
fill_in 'research_output_search_term', with: @model.name
79+
click_button 'Apply filter(s)'
80+
expect(page).to have_text(@model.description)
81+
# Select the repository and make sure it no longer appears in the search results
82+
click_link 'Select'
83+
expect(page).not_to have_text(@model.description)
84+
end
85+
86+
def close_modal
87+
# Using JS to click on button, as click_button '.modal-header button.btn-close' did not work.
88+
modal_close_button = find('.modal-header button.btn-close')
89+
# Close the modal
90+
execute_script('arguments[0].click();', modal_close_button)
91+
end
8192
end

0 commit comments

Comments
 (0)