mirror of
https://github.com/internetee/registry.git
synced 2025-06-10 14:44:47 +02:00
Add tests
This commit is contained in:
parent
19e45f0a70
commit
90f4480f37
1 changed files with 58 additions and 0 deletions
58
test/system/admin_area/api_users_test.rb
Normal file
58
test/system/admin_area/api_users_test.rb
Normal file
|
@ -0,0 +1,58 @@
|
|||
require 'application_system_test_case'
|
||||
|
||||
class AdminApiUsersSystemTest < ApplicationSystemTestCase
|
||||
setup do
|
||||
sign_in users(:admin)
|
||||
end
|
||||
|
||||
def test_shows_api_user_list
|
||||
visit admin_api_users_path
|
||||
|
||||
api_user = users(:api_bestnames)
|
||||
assert_link api_user.username, href: admin_api_user_path(api_user)
|
||||
end
|
||||
|
||||
def test_shows_api_user_details
|
||||
api_user = users(:api_bestnames)
|
||||
|
||||
visit admin_api_user_path(api_user)
|
||||
|
||||
assert_text "Username #{api_user.username}"
|
||||
assert_text "Password #{api_user.plain_text_password}"
|
||||
assert_link api_user.registrar.name, href: admin_registrar_path(api_user.registrar)
|
||||
assert_text "Role #{api_user.roles.first}"
|
||||
assert_text "Active #{api_user.active}"
|
||||
end
|
||||
|
||||
def test_updates_api_user
|
||||
api_user = users(:api_bestnames)
|
||||
new_username = 'new username'
|
||||
assert_not_equal new_username, api_user.name
|
||||
|
||||
visit admin_api_user_path(api_user)
|
||||
click_link_or_button 'Edit'
|
||||
fill_in 'Username', with: new_username
|
||||
click_link_or_button 'Save'
|
||||
|
||||
assert_text 'Record updated'
|
||||
assert_text "Username #{new_username}"
|
||||
end
|
||||
|
||||
def test_deletes_api_user
|
||||
api_user = unassociated_api_user
|
||||
|
||||
visit admin_api_user_path(api_user)
|
||||
click_on 'Delete'
|
||||
|
||||
assert_text 'Record deleted'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def unassociated_api_user
|
||||
new_api_user = users(:api_bestnames).dup
|
||||
new_api_user.username = "unique-#{rand(100)}"
|
||||
new_api_user.save!
|
||||
new_api_user
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue