1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activerecord/test/models/post_encrypted.rb
Jorge Manrubia 81afcabd19 Extract encrypted models to their own files
We are not encrypting attributes when loading models with the table
missing. This way we make sure we only load the encrypted models when
necessary during the encryption tests and prevent the problem of missing
encrypted attributes due to having cached the class without them encrypted.
2021-04-01 15:02:14 +02:00

15 lines
398 B
Ruby

# frozen_string_literal: true
require "models/post"
class EncryptedPost < Post
self.table_name = "posts"
# We want to modify the key for testing purposes
class MutableDerivedSecretKeyProvider < ActiveRecord::Encryption::DerivedSecretKeyProvider
attr_accessor :key
end
encrypts :title
encrypts :body, key_provider: MutableDerivedSecretKeyProvider.new("my post body secret!")
end