Skip to content

Commit

Permalink
fix[Op#48569] pass response code as integer
Browse files Browse the repository at this point in the history
  • Loading branch information
akabiru committed Jul 17, 2023
1 parent d15955f commit 7ac4c6a
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions modules/storages/spec/features/admin_storages_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,18 @@
expect(page).to have_title("Automatically managed project folders")
expect(page).to have_content("Password can't be blank.")

# Test the error path for an invalid storage password.
# Mock a valid response (=401) for example.com, so the password validation should fail
mock_nextcloud_application_credentials_validation("https://example.com", password: "1234567890", response_code: 401)
automatically_managed_switch = page.find('[name="storages_nextcloud_storage[automatically_managed]"]')
expect(automatically_managed_switch).to be_checked
page.fill_in 'storages_nextcloud_storage_password', with: "1234567890"
# Clicking submit with application password empty should show an error
page.click_button('Save')
# Check that we're still on the same page
expect(page).to have_title("Automatically managed project folders")
expect(page).to have_content("Password is not valid.")

# Test the happy path for a valid storage password.
# Mock a valid response (=200) for example.com, so the password validation should succeed
# Fill in application password and submit
Expand Down Expand Up @@ -203,16 +215,6 @@
page.find('.button--icon.icon-edit').click
page.find('a', text: 'Edit automatically managed project folders').click

# Test the error path for an invalid storage password.
# Mock a valid response (=401) for example.com, so the password validation should fail
mock_nextcloud_application_credentials_validation("https://example.com", password: "1234567890", response_code: '401')
automatically_managed_switch = page.find('[name="storages_nextcloud_storage[automatically_managed]"]')
expect(automatically_managed_switch).to be_checked
page.fill_in 'storages_nextcloud_storage_password', with: "1234567890"
# Clicking submit with application password empty should show an error
page.click_button('Save')
expect(page).to have_content("Password is not valid.")

expect(page).to have_title("Automatically managed project folders")
automatically_managed_switch = page.find('[name="storages_nextcloud_storage[automatically_managed]"]')
application_password_input = page.find_by_id('storages_nextcloud_storage_password')
Expand Down

0 comments on commit 7ac4c6a

Please sign in to comment.