1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
This commit is contained in:
Jorge Manrubia 2021-03-12 16:20:37 +01:00
parent 7945d4fde3
commit c0fa9428e5
2 changed files with 10 additions and 11 deletions

View file

@ -1,7 +1,7 @@
# frozen_string_literal: true
require "cases/encryption/helper"
require "models/book_encrypted"
require "models/pirate"
class ActiveRecord::Encryption::ConfigurableTest < ActiveRecord::TestCase
test "can access context properties with top level getters" do
@ -15,9 +15,8 @@ class ActiveRecord::Encryption::ConfigurableTest < ActiveRecord::TestCase
@attribute_name = declared_attribute_name
end
klass = Class.new(EncryptedBook) do
self.table_name = "books"
encrypt_attribute :isbn
klass = Class.new(Book) do
encrypts :isbn
end
assert_equal klass, @klass
@ -28,11 +27,11 @@ class ActiveRecord::Encryption::ConfigurableTest < ActiveRecord::TestCase
application = OpenStruct.new(config: OpenStruct.new(filter_parameters: []))
ActiveRecord::Encryption.install_auto_filtered_parameters(application)
Class.new(EncryptedBook) do
self.table_name = "books"
encrypt_attribute :isbn
Class.new(Pirate) do
self.table_name = "pirates"
encrypts :catchphrase
end
assert_includes application.config.filter_parameters, :isbn
assert_includes application.config.filter_parameters, :catchphrase
end
end

View file

@ -2,19 +2,19 @@
require "models/book"
class EncryptedBook < Book
class EncryptedBook < ActiveRecord::Base
self.table_name = "books"
encrypts :name, deterministic: true
end
class EncryptedBookWithDowncaseName < Book
class EncryptedBookWithDowncaseName < ActiveRecord::Base
self.table_name = "books"
encrypts :name, deterministic: true, downcase: true
end
class EncryptedBookThatIgnoresCase < Book
class EncryptedBookThatIgnoresCase < ActiveRecord::Base
self.table_name = "books"
encrypts :name, deterministic: true, ignore_case: true