mirror of
https://github.com/internetee/registry.git
synced 2025-08-05 01:11:43 +02:00
parent
36db8598d2
commit
579da84c58
6 changed files with 82 additions and 59 deletions
18
test/controllers/admin/registrars/create_test.rb
Normal file
18
test/controllers/admin/registrars/create_test.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
require 'test_helper'
|
||||
|
||||
class RegistrarsControllerTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
login_as create(:admin_user)
|
||||
end
|
||||
|
||||
def test_creates_new_registrar
|
||||
assert_difference -> { Registrar.count } do
|
||||
post admin_registrars_path, registrar: attributes_for(:registrar)
|
||||
end
|
||||
end
|
||||
|
||||
def test_redirects_to_newly_created_registrar
|
||||
post admin_registrars_path, registrar: attributes_for(:registrar)
|
||||
assert_redirected_to admin_registrar_path(Registrar.first)
|
||||
end
|
||||
end
|
40
test/controllers/admin/registrars/update_test.rb
Normal file
40
test/controllers/admin/registrars/update_test.rb
Normal file
|
@ -0,0 +1,40 @@
|
|||
require 'test_helper'
|
||||
|
||||
class RegistrarsControllerTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
login_as create(:admin_user)
|
||||
end
|
||||
|
||||
def test_updates_website
|
||||
registrar = create(:registrar, website: 'test')
|
||||
|
||||
patch admin_registrar_path(registrar), registrar: attributes_for(:registrar, website: 'new-website')
|
||||
registrar.reload
|
||||
|
||||
assert_equal 'new-website', registrar.website
|
||||
end
|
||||
|
||||
def test_updates_email
|
||||
registrar = create(:registrar, email: 'test@test.com')
|
||||
|
||||
patch admin_registrar_path(registrar), registrar: attributes_for(:registrar, email: 'new-test@test.com')
|
||||
registrar.reload
|
||||
|
||||
assert_equal 'new-test@test.com', registrar.email
|
||||
end
|
||||
|
||||
def test_updates_billing_email
|
||||
registrar = create(:registrar, billing_email: 'test@test.com')
|
||||
|
||||
patch admin_registrar_path(registrar), registrar: attributes_for(:registrar, billing_email: 'new-test@test.com')
|
||||
registrar.reload
|
||||
|
||||
assert_equal 'new-test@test.com', registrar.billing_email
|
||||
end
|
||||
|
||||
def test_redirects_to_registrar
|
||||
registrar = create(:registrar)
|
||||
patch admin_registrar_path(registrar), registrar: attributes_for(:registrar)
|
||||
assert_redirected_to admin_registrar_path(registrar)
|
||||
end
|
||||
end
|
17
test/integration/admin/registrars/edit_registrar_test.rb
Normal file
17
test/integration/admin/registrars/edit_registrar_test.rb
Normal file
|
@ -0,0 +1,17 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EditRegistrarTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
login_as create(:admin_user)
|
||||
end
|
||||
|
||||
def test_updates_registrar
|
||||
registrar = create(:registrar)
|
||||
|
||||
visit admin_registrar_path(registrar)
|
||||
click_link_or_button 'Edit'
|
||||
click_link_or_button 'Update registrar'
|
||||
|
||||
assert_text 'Registrar has been successfully updated'
|
||||
end
|
||||
end
|
20
test/integration/admin/registrars/new_registrar_test.rb
Normal file
20
test/integration/admin/registrars/new_registrar_test.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
require 'test_helper'
|
||||
|
||||
class NewRegistrarTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
login_as create(:admin_user)
|
||||
end
|
||||
|
||||
def test_creates_registrar
|
||||
visit admin_registrars_path
|
||||
click_link_or_button 'New registrar'
|
||||
|
||||
fill_in 'registrar[name]', with: 'test'
|
||||
fill_in 'registrar[reg_no]', with: '1234567'
|
||||
fill_in 'registrar[email]', with: 'test@test.com'
|
||||
fill_in 'registrar[code]', with: 'test'
|
||||
click_link_or_button 'Create registrar'
|
||||
|
||||
assert_text 'Registrar has been successfully created'
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue