couch_potato-extensions 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -31,11 +31,15 @@ module CouchPotato
31
31
  end
32
32
 
33
33
  def encrypt(value)
34
- Base64.encode64(EzCrypto::Key.encrypt_with_password(@options[:password], @options[:salt], value))
34
+ if not value.nil?
35
+ value.empty? ? value : Base64.encode64(EzCrypto::Key.encrypt_with_password(@options[:password], @options[:salt], value))
36
+ end
35
37
  end
36
38
 
37
39
  def decrypt(value)
38
- EzCrypto::Key.decrypt_with_password(@options[:password], @options[:salt], Base64.decode64(value))
40
+ if not value.nil?
41
+ EzCrypto::Key.decrypt_with_password(@options[:password], @options[:salt], Base64.decode64(value))
42
+ end
39
43
  end
40
44
 
41
45
  def encrypted_value(object)
@@ -5,6 +5,6 @@ require File.expand_path(File.dirname(__FILE__) + "/extensions/encrypted_view_sp
5
5
 
6
6
  module CouchPotato
7
7
  module Extensions
8
- VERSION = '0.0.5'
8
+ VERSION = '0.0.6'
9
9
  end
10
10
  end
@@ -32,7 +32,7 @@ describe CouchPotato::Extensions::EncryptedProperty do
32
32
 
33
33
  describe "saving documents" do
34
34
  let(:document) { SecureDocument.new(:body => "very important") }
35
-
35
+
36
36
  it "should encrypt the property when accessing the document hash" do
37
37
  body = document.to_hash[:body]
38
38
  body.should_not == nil
@@ -48,6 +48,24 @@ describe CouchPotato::Extensions::EncryptedProperty do
48
48
  EzCrypto::Key.should_not_receive(:encrypt_with_password)
49
49
  CouchPotato.database.save_document @document
50
50
  end
51
+
52
+ describe "with nil'd properties" do
53
+ before do
54
+ @document = SecureDocument.new(:body => nil)
55
+ end
56
+
57
+ it "should not fail when saving" do
58
+ lambda do
59
+ CouchPotato.database.save_document @document
60
+ end.should_not raise_error
61
+ end
62
+
63
+ it "should return nil when loading" do
64
+ CouchPotato.database.save_document @document
65
+ @document = CouchPotato.database.load_document(@document.id)
66
+ @document.body.should == nil
67
+ end
68
+ end
51
69
  end
52
70
 
53
71
  describe "loading documents" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: couch_potato-extensions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mathias Meyer
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-04-19 00:00:00 +02:00
12
+ date: 2010-04-26 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency