diff --git a/spec/features/admin/registrars/edit_spec.rb b/spec/features/admin/registrars/edit_spec.rb deleted file mode 100644 index f02164f91..000000000 --- a/spec/features/admin/registrars/edit_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'rails_helper' - -RSpec.feature 'Edit registrar' do - given!(:registrar) { create(:registrar) } - - background do - sign_in_to_admin_area - end - - it 'updates registrar' do - visit admin_registrar_url(registrar) - click_link_or_button 'Edit' - - click_link_or_button 'Update registrar' - - expect(page).to have_text('Registrar has been successfully updated') - end -end diff --git a/spec/requests/admin/registrars/create_spec.rb b/spec/requests/admin/registrars/create_spec.rb deleted file mode 100644 index e66fb0765..000000000 --- a/spec/requests/admin/registrars/create_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -require 'rails_helper' - -RSpec.describe 'admin registrar create' do - subject(:registrar) { Registrar.first } - - before :example do - sign_in_to_admin_area - end - - it 'creates new registrar' do - expect { post admin_registrars_path, registrar: attributes_for(:registrar) } - .to change { Registrar.count }.from(0).to(1) - end - - it 'saves website' do - post admin_registrars_path, { registrar: attributes_for(:registrar, website: 'test') } - expect(registrar.website).to eq('test') - end - - it 'saves email' do - post admin_registrars_path, { registrar: attributes_for(:registrar, email: 'test@test.com') } - expect(registrar.email).to eq('test@test.com') - end - - it 'saves billing email' do - post admin_registrars_path, { registrar: attributes_for(:registrar, billing_email: 'test@test.com') } - expect(registrar.billing_email).to eq('test@test.com') - end - - it 'redirects to :show' do - post admin_registrars_path, { registrar: attributes_for(:registrar) } - expect(response).to redirect_to admin_registrar_path(registrar) - end -end diff --git a/test/controllers/admin/registrars/create_test.rb b/test/controllers/admin/registrars/create_test.rb new file mode 100644 index 000000000..e7ee57011 --- /dev/null +++ b/test/controllers/admin/registrars/create_test.rb @@ -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 diff --git a/test/controllers/admin/registrars/update_test.rb b/test/controllers/admin/registrars/update_test.rb new file mode 100644 index 000000000..bf79aca65 --- /dev/null +++ b/test/controllers/admin/registrars/update_test.rb @@ -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 diff --git a/test/integration/admin/registrars/edit_registrar_test.rb b/test/integration/admin/registrars/edit_registrar_test.rb new file mode 100644 index 000000000..6965cfd02 --- /dev/null +++ b/test/integration/admin/registrars/edit_registrar_test.rb @@ -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 diff --git a/spec/features/admin/registrars/create_spec.rb b/test/integration/admin/registrars/new_registrar_test.rb similarity index 54% rename from spec/features/admin/registrars/create_spec.rb rename to test/integration/admin/registrars/new_registrar_test.rb index 24cc8bc2a..5c6395673 100644 --- a/spec/features/admin/registrars/create_spec.rb +++ b/test/integration/admin/registrars/new_registrar_test.rb @@ -1,12 +1,12 @@ -require 'rails_helper' +require 'test_helper' -RSpec.feature 'New registrar' do - background do - sign_in_to_admin_area +class NewRegistrarTest < ActionDispatch::IntegrationTest + def setup + login_as create(:admin_user) end - it 'creates registrar' do - visit admin_registrars_url + def test_creates_registrar + visit admin_registrars_path click_link_or_button 'New registrar' fill_in 'registrar[name]', with: 'test' @@ -15,6 +15,6 @@ RSpec.feature 'New registrar' do fill_in 'registrar[code]', with: 'test' click_link_or_button 'Create registrar' - expect(page).to have_text('Registrar has been successfully created') + assert_text 'Registrar has been successfully created' end end