test/mongoid_test.rb in symmetric-encryption-3.6.0 vs test/mongoid_test.rb in symmetric-encryption-3.7.0
- old
+ new
@@ -1,7 +1,11 @@
-require File.dirname(__FILE__) + '/test_helper'
-if defined?(Mongoid)
+begin
+ require 'mongoid'
+ require_relative 'test_helper'
+ require_relative '../lib/symmetric_encryption/extensions/mongoid/encrypted'
+ ENV['RACK_ENV'] = 'test'
+
Mongoid.logger = SemanticLogger[Mongoid]
filename = defined?(Mongoid::VERSION) ? "test/config/mongoid_v3.yml" : "test/config/mongoid_v2.yml"
Mongoid.load!(filename)
class MongoidUser
@@ -12,11 +16,11 @@
field :encrypted_social_security_number, type: String, encrypted: true
field :encrypted_string, type: String, encrypted: {random_iv: true}
field :encrypted_long_string, type: String, encrypted: {random_iv: true, compress: true}
field :encrypted_integer_value, type: String, encrypted: {type: :integer}
- field :aiv, type: String, encrypted: {type: :integer, encrypt_as: :aliased_integer_value}
+ field :aiv, type: String, encrypted: {type: :integer, decrypt_as: :aliased_integer_value}
field :encrypted_float_value, type: String, encrypted: {type: :float}
field :encrypted_decimal_value, type: String, encrypted: {type: :decimal}
field :encrypted_datetime_value, type: String, encrypted: {type: :datetime}
field :encrypted_time_value, type: String, encrypted: {type: :time}
field :encrypted_date_value, type: String, encrypted: {type: :date}
@@ -30,11 +34,11 @@
end
#
# Unit Tests for field encrypted and validation aspects of SymmetricEncryption
#
- class MongoidTest < Test::Unit::TestCase
+ class MongoidTest < Minitest::Test
context 'Mongoid' do
setup do
@bank_account_number = "1234567890"
@bank_account_number_encrypted = "QEVuQwIAL94ArJeFlJrZp6SYsvoOGA=="
@@ -530,6 +534,9 @@
end
end
end
+
+rescue LoadError
+ puts "Not running Mongoid tests because mongoid gem is not installed!!!"
end
\ No newline at end of file