@@ -7,52 +7,52 @@ class UniquenessValidatorTest < ClientSideValidations::ActiveRecordTestBase
77 def test_uniqueness_client_side_hash
88 expected_hash = { message : 'has already been taken' }
99
10- assert_equal expected_hash , UniquenessValidator . new ( attributes : [ :name ] ) . client_side_hash ( @user , :name )
10+ assert_equal expected_hash , UniquenessValidator . new ( class : ClientSideValidations :: ActiveRecordTestBase , attributes : [ :name ] ) . client_side_hash ( @user , :name )
1111 end
1212
1313 def test_uniqueness_client_side_hash_allowing_blank
1414 expected_hash = { message : 'has already been taken' , allow_blank : true }
1515
16- assert_equal expected_hash , UniquenessValidator . new ( attributes : [ :name ] , allow_blank : true ) . client_side_hash ( @user , :name )
16+ assert_equal expected_hash , UniquenessValidator . new ( class : ClientSideValidations :: ActiveRecordTestBase , attributes : [ :name ] , allow_blank : true ) . client_side_hash ( @user , :name )
1717 end
1818
1919 def test_uniqueness_client_side_hash_allowing_nil
2020 expected_hash = { message : 'has already been taken' , allow_blank : true }
2121
22- assert_equal expected_hash , UniquenessValidator . new ( attributes : [ :name ] , allow_nil : true ) . client_side_hash ( @user , :name )
22+ assert_equal expected_hash , UniquenessValidator . new ( class : ClientSideValidations :: ActiveRecordTestBase , attributes : [ :name ] , allow_nil : true ) . client_side_hash ( @user , :name )
2323 end
2424
2525 def test_uniqueness_client_side_hash_case_insensitive
2626 expected_hash = { message : 'has already been taken' }
2727
28- assert_equal expected_hash , UniquenessValidator . new ( attributes : [ :name ] , case_sensitive : false ) . client_side_hash ( @user , :name )
28+ assert_equal expected_hash , UniquenessValidator . new ( class : ClientSideValidations :: ActiveRecordTestBase , attributes : [ :name ] , case_sensitive : false ) . client_side_hash ( @user , :name )
2929 end
3030
3131 def test_uniqueness_client_side_hash_case_sensitive
3232 expected_hash = { message : 'has already been taken' , case_sensitive : true }
3333
34- assert_equal expected_hash , UniquenessValidator . new ( attributes : [ :name ] , case_sensitive : true ) . client_side_hash ( @user , :name )
34+ assert_equal expected_hash , UniquenessValidator . new ( class : ClientSideValidations :: ActiveRecordTestBase , attributes : [ :name ] , case_sensitive : true ) . client_side_hash ( @user , :name )
3535 end
3636
3737 def test_uniqueness_client_side_hash_with_custom_message
3838 expected_hash = { message : 'is not available' }
3939
40- assert_equal expected_hash , UniquenessValidator . new ( attributes : [ :name ] , message : 'is not available' ) . client_side_hash ( @user , :name )
40+ assert_equal expected_hash , UniquenessValidator . new ( class : ClientSideValidations :: ActiveRecordTestBase , attributes : [ :name ] , message : 'is not available' ) . client_side_hash ( @user , :name )
4141 end
4242
4343 def test_uniqueness_client_side_hash_with_existing_record
4444 @user . stubs ( :new_record? ) . returns ( false )
4545 @user . stubs ( :id ) . returns ( 1 )
4646 expected_hash = { message : 'has already been taken' , id : 1 }
4747
48- assert_equal expected_hash , UniquenessValidator . new ( attributes : [ :name ] ) . client_side_hash ( @user , :name )
48+ assert_equal expected_hash , UniquenessValidator . new ( class : ClientSideValidations :: ActiveRecordTestBase , attributes : [ :name ] ) . client_side_hash ( @user , :name )
4949 end
5050
5151 def test_uniqueness_client_side_hash_with_single_scope_item
5252 @user . stubs ( :age ) . returns ( 30 )
5353 @user . stubs ( :title ) . returns ( 'test title' )
5454 expected_hash = { message : 'has already been taken' , scope : { title : 'test title' } }
55- result_hash = UniquenessValidator . new ( attributes : [ :name ] , scope : :title ) . client_side_hash ( @user , :name )
55+ result_hash = UniquenessValidator . new ( class : ClientSideValidations :: ActiveRecordTestBase , attributes : [ :name ] , scope : :title ) . client_side_hash ( @user , :name )
5656
5757 assert_equal expected_hash , result_hash
5858 end
@@ -61,14 +61,14 @@ def test_uniqueness_client_side_hash_with_multiple_scope_items
6161 @user . stubs ( :age ) . returns ( 30 )
6262 @user . stubs ( :title ) . returns ( 'test title' )
6363 expected_hash = { message : 'has already been taken' , scope : { age : 30 , title : 'test title' } }
64- result_hash = UniquenessValidator . new ( attributes : [ :name ] , scope : %i[ age title ] ) . client_side_hash ( @user , :name )
64+ result_hash = UniquenessValidator . new ( class : ClientSideValidations :: ActiveRecordTestBase , attributes : [ :name ] , scope : %i[ age title ] ) . client_side_hash ( @user , :name )
6565
6666 assert_equal expected_hash , result_hash
6767 end
6868
6969 def test_uniqueness_client_side_hash_with_empty_scope_array
7070 expected_hash = { message : 'has already been taken' }
71- result_hash = UniquenessValidator . new ( attributes : [ :name ] , scope : [ ] ) . client_side_hash ( @user , :name )
71+ result_hash = UniquenessValidator . new ( class : ClientSideValidations :: ActiveRecordTestBase , attributes : [ :name ] , scope : [ ] ) . client_side_hash ( @user , :name )
7272
7373 assert_equal expected_hash , result_hash
7474 end
@@ -77,14 +77,14 @@ def test_uniqueness_client_side_hash_when_nested_module
7777 @user = ActiveRecordTestModule ::User2 . new
7878 expected_hash = { message : 'has already been taken' , class : 'active_record_test_module/user2' }
7979
80- assert_equal expected_hash , UniquenessValidator . new ( attributes : [ :name ] ) . client_side_hash ( @user , :name )
80+ assert_equal expected_hash , UniquenessValidator . new ( class : ClientSideValidations :: ActiveRecordTestBase , attributes : [ :name ] ) . client_side_hash ( @user , :name )
8181 end
8282
8383 def test_uniqueness_client_side_hash_with_class_from_options
8484 @user = UserForm . new
8585 expected_hash = { message : 'has already been taken' , class : 'user' }
8686
87- assert_equal expected_hash , UniquenessValidator . new ( attributes : [ :name ] , client_validations : { class : 'User' } ) . client_side_hash ( @user , :name )
87+ assert_equal expected_hash , UniquenessValidator . new ( class : ClientSideValidations :: ActiveRecordTestBase , attributes : [ :name ] , client_validations : { class : 'User' } ) . client_side_hash ( @user , :name )
8888 end
8989 end
9090end
0 commit comments