Skip to content

Commit 4f2fa59

Browse files
committed
Don't modify existing test model in a test case
It will affect to other tests.
1 parent 2fbb25b commit 4f2fa59

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

activerecord/test/cases/secure_token_test.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,13 @@ def test_token_length_cannot_be_less_than_24_characters
6767
end
6868

6969
def test_token_on_callback
70-
User.class_eval do
71-
undef regenerate_token
72-
70+
model = Class.new(ActiveRecord::Base) do
71+
self.table_name = "users"
7372
has_secure_token on: :initialize
7473
end
7574

76-
model = User.new
75+
user = model.new
7776

78-
assert_predicate model.token, :present?
77+
assert_predicate user.token, :present?
7978
end
8079
end

0 commit comments

Comments
 (0)