diff options
author | Azul <azul@leap.se> | 2013-07-24 11:09:04 +0200 |
---|---|---|
committer | Azul <azul@leap.se> | 2013-07-24 11:38:32 +0200 |
commit | 370be6caa8a366774fba15d09fb03ee4d923b861 (patch) | |
tree | 48522a4750e4e3433b7670dfe158762f800d3eae /users | |
parent | d70c5796a2989b7b43f7e287899fb1394ae28280 (diff) |
keeping the pgp_key accessors for User so views still work
Diffstat (limited to 'users')
-rw-r--r-- | users/app/models/user.rb | 20 | ||||
-rw-r--r-- | users/test/unit/user_test.rb | 8 |
2 files changed, 25 insertions, 3 deletions
diff --git a/users/app/models/user.rb b/users/app/models/user.rb index f78f290..0a89f7c 100644 --- a/users/app/models/user.rb +++ b/users/app/models/user.rb @@ -87,6 +87,26 @@ class User < CouchRest::Model::Base Ticket.for_user(self).limit(count).all #defaults to having most recent updated first end + # DEPRECATED + # + # Please set the key on the identity directly + # WARNING: This will not be serialized with the user record! + # It is only a workaround for the key form. + def public_key=(value) + identity.set_key(:pgp, value) + end + + # DEPRECATED + # + # Please access identity.keys[:pgp] directly + def public_key + identity.keys[:pgp] + end + + def identity + @identity ||= Identity.for(self) + end + protected ## diff --git a/users/test/unit/user_test.rb b/users/test/unit/user_test.rb index 477c727..89ee749 100644 --- a/users/test/unit/user_test.rb +++ b/users/test/unit/user_test.rb @@ -70,14 +70,16 @@ class UserTest < ActiveSupport::TestCase end test "pgp key view" do - @user.public_key = SecureRandom.base64(4096) - @user.save + key = SecureRandom.base64(4096) + identity = Identity.create_for @user + identity.set_key('pgp', key) + identity.save view = Identity.pgp_key_by_email.key(@user.email_address) assert_equal 1, view.rows.count assert result = view.rows.first assert_equal @user.email_address, result["key"] - assert_equal @user.public_key, result["value"] + assert_equal key, result["value"] end end |