attr_encrypted 1.3.2 → 1.3.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,6 +6,7 @@ if defined?(ActiveRecord::Base)
6
6
  base.class_eval do
7
7
  attr_encrypted_options[:encode] = true
8
8
  class << self
9
+ alias_method :attr_encryptor, :attr_encrypted
9
10
  alias_method_chain :method_missing, :attr_encrypted
10
11
  alias_method :undefine_attribute_methods, :reset_column_information if ::ActiveRecord::VERSION::STRING < "3"
11
12
  end
@@ -3,7 +3,7 @@ module AttrEncrypted
3
3
  module Version
4
4
  MAJOR = 1
5
5
  MINOR = 3
6
- PATCH = 2
6
+ PATCH = 3
7
7
 
8
8
  # Returns a version string by joining <tt>MAJOR</tt>, <tt>MINOR</tt>, and <tt>PATCH</tt> with <tt>'.'</tt>
9
9
  #
@@ -87,6 +87,11 @@ class UserWithProtectedAttribute < ActiveRecord::Base
87
87
  attr_protected :is_admin if ::ActiveRecord::VERSION::STRING < "4.0"
88
88
  end
89
89
 
90
+ class PersonUsingAlias < ActiveRecord::Base
91
+ self.table_name = 'people'
92
+ attr_encryptor :email, :key => 'a secret key'
93
+ end
94
+
90
95
  class ActiveRecordTest < Test::Unit::TestCase
91
96
 
92
97
  def setup
@@ -197,4 +202,16 @@ class ActiveRecordTest < Test::Unit::TestCase
197
202
  assert_nil(@person.assign_attributes nil)
198
203
  end
199
204
  end
205
+
206
+ class TestAlias < Test::Unit::TestCase
207
+ def test_that_alias_encrypts_column
208
+ user = PersonUsingAlias.new
209
+ user.email = 'test@example.com'
210
+ user.save
211
+
212
+ assert_not_nil user.encrypted_email
213
+ assert_not_equal user.email, user.encrypted_email
214
+ assert_equal user.email, PersonUsingAlias.find(:first).email
215
+ end
216
+ end
200
217
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attr_encrypted
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.3.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2014-02-13 00:00:00.000000000 Z
14
+ date: 2014-08-27 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: encryptor
@@ -218,18 +218,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
218
218
  - - ! '>='
219
219
  - !ruby/object:Gem::Version
220
220
  version: '0'
221
- segments:
222
- - 0
223
- hash: -1158977372203285747
224
221
  required_rubygems_version: !ruby/object:Gem::Requirement
225
222
  none: false
226
223
  requirements:
227
224
  - - ! '>='
228
225
  - !ruby/object:Gem::Version
229
226
  version: '0'
230
- segments:
231
- - 0
232
- hash: -1158977372203285747
233
227
  requirements: []
234
228
  rubyforge_project:
235
229
  rubygems_version: 1.8.23