Convert specs to tests

This commit is contained in:
Artur Beljajev 2017-11-22 04:35:06 +02:00
parent 61b6df197e
commit 93b0037c39
6 changed files with 48 additions and 60 deletions

View file

@ -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

View file

@ -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

View file

@ -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