@@ -17,7 +17,7 @@ class AuthenticationOptionTest < ActiveSupport::TestCase
17
17
original_teacher_email = '[email protected] '
18
18
new_teacher_email = '[email protected] '
19
19
teacher = create ( :teacher , email : original_teacher_email )
20
- email_auth = create ( :email_authentication_option , user : teacher , email : new_teacher_email )
20
+ email_auth = create ( :authentication_option , user : teacher , email : new_teacher_email )
21
21
teacher . update ( primary_contact_info : email_auth , provider : 'migrated' )
22
22
assert_equal teacher . primary_contact_info_id , email_auth . id
23
23
assert_equal new_teacher_email , teacher . email
@@ -28,15 +28,15 @@ class AuthenticationOptionTest < ActiveSupport::TestCase
28
28
teacher_email = '[email protected] '
29
29
30
30
teacher = create ( :teacher , email : teacher_email )
31
- email_auth = create ( :email_authentication_option , user : teacher , email : teacher_email )
31
+ email_auth = create ( :authentication_option , user : teacher , email : teacher_email )
32
32
assert_equal sanitized , email_auth . email
33
33
assert_equal email_auth . hashed_email , AuthenticationOption . hash_email ( sanitized )
34
34
end
35
35
36
36
test 'student email is not stored but hashed_email is' do
37
37
student_email = '[email protected] '
38
38
student = create ( :student , email : student_email )
39
- email_auth = create ( :email_authentication_option , user : student , email : student_email )
39
+ email_auth = create ( :authentication_option , user : student , email : student_email )
40
40
assert email_auth . user . student?
41
41
assert_equal '' , email_auth . email
42
42
assert_equal student . hashed_email , email_auth . hashed_email
@@ -155,4 +155,59 @@ class AuthenticationOptionTest < ActiveSupport::TestCase
155
155
}
156
156
assert_equal new_data , auth_option . data_hash
157
157
end
158
+
159
+ test "factory: :authentication_option" do
160
+ option = create :authentication_option
161
+ assert option . valid?
162
+ assert option . persisted?
163
+ assert_equal AuthenticationOption ::EMAIL , option . credential_type
164
+
165
+ # Default user is a student so email is empty
166
+ assert option . user . student?
167
+ assert_empty option . email
168
+
169
+ refute_empty option . hashed_email
170
+ assert_equal option . hashed_email , option . authentication_id
171
+ end
172
+
173
+ test "factory: :authentication_option for teacher" do
174
+ option = create :authentication_option , user : create ( :teacher )
175
+ assert option . valid?
176
+ assert option . persisted?
177
+ assert_equal AuthenticationOption ::EMAIL , option . credential_type
178
+
179
+ assert option . user . teacher?
180
+ refute_empty option . email
181
+
182
+ refute_empty option . hashed_email
183
+ assert_equal option . hashed_email , option . authentication_id
184
+ end
185
+
186
+ test "factory: :google_authentication_option" do
187
+ option = create :google_authentication_option
188
+ assert option . valid?
189
+ assert option . persisted?
190
+ assert_equal AuthenticationOption ::GOOGLE , option . credential_type
191
+
192
+ # Default user is a student so email is empty
193
+ assert option . user . student?
194
+ assert_empty option . email
195
+
196
+ refute_empty option . hashed_email
197
+ refute_empty option . authentication_id
198
+ end
199
+
200
+ test "factory: :facebook_authentication_option" do
201
+ option = create :facebook_authentication_option
202
+ assert option . valid?
203
+ assert option . persisted?
204
+ assert_equal AuthenticationOption ::FACEBOOK , option . credential_type
205
+
206
+ # Default user is a student so email is empty
207
+ assert option . user . student?
208
+ assert_empty option . email
209
+
210
+ refute_empty option . hashed_email
211
+ refute_empty option . authentication_id
212
+ end
158
213
end
0 commit comments