mirror of
https://github.com/internetee/registry.git
synced 2025-05-16 17:37:17 +02:00
Merge branch 'refactor-admin-registrars' into registry-640
This commit is contained in:
commit
9d735d0458
9 changed files with 85 additions and 61 deletions
|
@ -1,18 +0,0 @@
|
|||
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
|
|
@ -1,13 +0,0 @@
|
|||
require 'test_helper'
|
||||
|
||||
class RegistrarsControllerTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
login_as create(:admin_user)
|
||||
end
|
||||
|
||||
def test_accounting_customer_code
|
||||
registrar = create(:registrar, accounting_customer_code: 'test accounting customer code')
|
||||
visit admin_registrar_path(registrar)
|
||||
assert_text 'test accounting customer code'
|
||||
end
|
||||
end
|
|
@ -2,39 +2,29 @@ require 'test_helper'
|
|||
|
||||
class RegistrarsControllerTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
login_as create(:admin_user)
|
||||
login_as users(:admin)
|
||||
@registrar = registrars(:valid)
|
||||
end
|
||||
|
||||
def test_updates_website
|
||||
registrar = create(:registrar, website: 'test')
|
||||
patch admin_registrar_path(@registrar), registrar: @registrar.attributes.merge(website: 'new.example.com')
|
||||
@registrar.reload
|
||||
|
||||
patch admin_registrar_path(registrar), registrar: attributes_for(:registrar, website: 'new-website')
|
||||
registrar.reload
|
||||
|
||||
assert_equal 'new-website', registrar.website
|
||||
assert_equal 'new.example.com', @registrar.website
|
||||
end
|
||||
|
||||
def test_updates_email
|
||||
registrar = create(:registrar, email: 'test@test.com')
|
||||
patch admin_registrar_path(@registrar), registrar: @registrar.attributes.merge(email: 'new@example.com')
|
||||
@registrar.reload
|
||||
|
||||
patch admin_registrar_path(registrar), registrar: attributes_for(:registrar, email: 'new-test@test.com')
|
||||
registrar.reload
|
||||
|
||||
assert_equal 'new-test@test.com', registrar.email
|
||||
assert_equal 'new@example.com', @registrar.email
|
||||
end
|
||||
|
||||
def test_updates_billing_email
|
||||
registrar = create(:registrar, billing_email: 'test@test.com')
|
||||
patch admin_registrar_path(@registrar),
|
||||
registrar: @registrar.attributes.merge(billing_email: 'new-billing@example.com')
|
||||
@registrar.reload
|
||||
|
||||
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)
|
||||
assert_equal 'new-billing@example.com', @registrar.billing_email
|
||||
end
|
||||
end
|
||||
|
|
20
test/fixtures/registrars.yml
vendored
Normal file
20
test/fixtures/registrars.yml
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
DEFAULTS: &DEFAULTS
|
||||
name: Acme Ltd
|
||||
reg_no: 1234
|
||||
country_code: US
|
||||
email: acme@example.com
|
||||
code: 1234
|
||||
accounting_customer_code: ACCOUNT001
|
||||
|
||||
valid:
|
||||
<<: *DEFAULTS
|
||||
|
||||
complete:
|
||||
<<: *DEFAULTS
|
||||
name: 2
|
||||
reg_no: 2
|
||||
code: 2
|
||||
website: example.com
|
||||
email: info@example.com
|
||||
billing_email: billing@example.com
|
||||
vat_no: US12345
|
16
test/fixtures/users.yml
vendored
Normal file
16
test/fixtures/users.yml
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
DEFAULTS: &DEFAULTS
|
||||
username: test
|
||||
|
||||
api:
|
||||
<<: *DEFAULTS
|
||||
type: ApiUser
|
||||
registrar: valid
|
||||
roles:
|
||||
- super
|
||||
|
||||
admin:
|
||||
<<: *DEFAULTS
|
||||
type: AdminUser
|
||||
country_code: US
|
||||
roles:
|
||||
- admin
|
|
@ -2,16 +2,16 @@ require 'test_helper'
|
|||
|
||||
class EditRegistrarTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
login_as create(:admin_user)
|
||||
login_as users(:admin)
|
||||
@registrar = registrars(:valid)
|
||||
end
|
||||
|
||||
def test_updates_registrar
|
||||
registrar = create(:registrar)
|
||||
|
||||
visit admin_registrar_path(registrar)
|
||||
visit admin_registrar_path(@registrar)
|
||||
click_link_or_button 'Edit'
|
||||
click_link_or_button 'Update registrar'
|
||||
|
||||
assert_current_path admin_registrar_path(@registrar)
|
||||
assert_text 'Registrar has been successfully updated'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,7 +2,7 @@ require 'test_helper'
|
|||
|
||||
class NewRegistrarTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
login_as create(:admin_user)
|
||||
login_as users(:admin)
|
||||
end
|
||||
|
||||
def test_creates_registrar
|
||||
|
|
15
test/integration/admin/registrars/show_registrar_test.rb
Normal file
15
test/integration/admin/registrars/show_registrar_test.rb
Normal file
|
@ -0,0 +1,15 @@
|
|||
require 'test_helper'
|
||||
|
||||
class ShowRegistrarTest < ActionDispatch::IntegrationTest
|
||||
include ActionView::Helpers::NumberHelper
|
||||
|
||||
def setup
|
||||
login_as users(:admin)
|
||||
@registrar = registrars(:complete)
|
||||
visit admin_registrar_path(@registrar)
|
||||
end
|
||||
|
||||
def test_accounting_customer_code
|
||||
assert_text 'ACCOUNT001'
|
||||
end
|
||||
end
|
|
@ -1,9 +1,23 @@
|
|||
require 'test_helper'
|
||||
|
||||
class RegistrarTest < ActiveSupport::TestCase
|
||||
def setup
|
||||
@registrar = registrars(:valid)
|
||||
end
|
||||
|
||||
def test_valid
|
||||
assert @registrar.valid?
|
||||
end
|
||||
|
||||
def test_rejects_absent_accounting_customer_code
|
||||
registrar = Registrar.new(accounting_customer_code: nil)
|
||||
registrar.validate
|
||||
assert registrar.errors.added?(:accounting_customer_code, :blank)
|
||||
@registrar.accounting_customer_code = nil
|
||||
@registrar.validate
|
||||
assert @registrar.invalid?
|
||||
end
|
||||
|
||||
def test_requires_country_code
|
||||
@registrar.country_code = nil
|
||||
@registrar.validate
|
||||
assert @registrar.invalid?
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue