mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Query rewriting in rack_test form submission
This commit is contained in:
parent
f05a2a033a
commit
6dc1615504
3 changed files with 18 additions and 1 deletions
|
@ -30,7 +30,9 @@ class Capybara::RackTest::Browser
|
|||
|
||||
def submit(method, path, attributes)
|
||||
path = request_path if path.nil? || path.empty?
|
||||
process_and_follow_redirects(method, path, attributes, 'HTTP_REFERER' => current_url)
|
||||
uri = build_uri(path)
|
||||
uri.query = '' if method&.to_s&.downcase == 'get'
|
||||
process_and_follow_redirects(method, uri.to_s, attributes, 'HTTP_REFERER' => current_url)
|
||||
end
|
||||
|
||||
def follow(method, path, **attributes)
|
||||
|
|
|
@ -517,6 +517,7 @@ New line after and before textarea tag
|
|||
|
||||
<p>
|
||||
<input type="submit" name="form[mediocre]" id="mediocre" value="med" aria-label="Mediocre Button"/>
|
||||
<input type="submit" formaction="/form/get?bar=foo" id="mediocre2" value="med2"/>
|
||||
<p>
|
||||
</form>
|
||||
|
||||
|
|
|
@ -127,6 +127,20 @@ RSpec.describe Capybara::Session do # rubocop:disable RSpec/MultipleDescribes
|
|||
session.find(:label, 'Female').click
|
||||
expect(session).to have_unchecked_field('gender_male')
|
||||
end
|
||||
|
||||
it 'should rewrite the forms action query for get submission' do
|
||||
session.visit('/form')
|
||||
session.click_button('mediocre')
|
||||
puts session.current_url
|
||||
expect(session).not_to have_current_path(/foo|bar/)
|
||||
end
|
||||
|
||||
it 'should rewrite the submit buttons formaction query for get submission' do
|
||||
session.visit('/form')
|
||||
session.click_button('mediocre2')
|
||||
puts session.current_url
|
||||
expect(session).not_to have_current_path(/foo|bar/)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue