From ed29bef7f1863b84b7a681363e678f7b19a99a0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Fri, 2 Oct 2020 10:21:38 +0300 Subject: [PATCH] Add test for registrant TARA integration --- .../registrant_user/tara/tara_users_test.rb | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 test/models/registrant_user/tara/tara_users_test.rb diff --git a/test/models/registrant_user/tara/tara_users_test.rb b/test/models/registrant_user/tara/tara_users_test.rb new file mode 100644 index 000000000..105baac5b --- /dev/null +++ b/test/models/registrant_user/tara/tara_users_test.rb @@ -0,0 +1,49 @@ +require 'application_system_test_case' + +class RegistrantAreaTaraUsersTest < ApplicationSystemTestCase + def setup + super + + OmniAuth.config.test_mode = true + @registrant = users(:registrant) + + @existing_user_hash = { + 'provider' => 'rant_tara', + 'uid' => "US1234", + 'info': { 'first_name': 'Registrant', 'last_name': 'User' } + } + + @new_user_hash = { + 'provider' => 'rant_tara', + 'uid' => 'EE51007050604', + 'info': { 'first_name': 'New Registrant', 'last_name': 'User'} + } + end + + def teardown + super + + OmniAuth.config.test_mode = false + OmniAuth.config.mock_auth['rant_tara'] = nil + end + + def test_existing_user_gets_signed_in + OmniAuth.config.mock_auth[:rant_tara] = OmniAuth::AuthHash.new(@existing_user_hash) + + visit new_registrant_user_session_path + click_link('Sign in') + + assert_text('Signed in successfully') + end + + def test_new_user_is_created_and_signed_in + OmniAuth.config.mock_auth[:tara] = OmniAuth::AuthHash.new(@new_user_hash) + + visit new_registrant_user_session_path + click_link('Sign in') + + assert_text('Signed in successfully') + assert 'New Registrant User', RegistrantUser.last.username + assert 'EE-51007050604', RegistrantUser.last.registrant_ident + end +end