Welcome to mirror list, hosted at ThFree Co, Russian Federation.

attr_encrypted_thread_safe_spec.rb « initializers « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e79b7c716ec18b3dca4b38ae8edd861c25ede58f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe AttrEncrypted do
  describe '#encrypted_attributes' do
    subject do
      Class.new(ActiveRecord::Base) do
        self.table_name = 'projects'

        attr_accessor :encrypted_foo
        attr_accessor :encrypted_foo_iv

        attr_encrypted :foo, key: 'This is a key that is 256 bits!!'
      end
    end

    it 'does not share state with other instances' do
      instance = subject.new
      instance.foo = 'bar'

      another_instance = subject.new

      expect(instance.encrypted_attributes[:foo][:operation]).to eq(:encrypting)
      expect(another_instance.encrypted_attributes[:foo][:operation]).to be_nil
    end
  end
end