carrierwave-neo4j 0.0.1-java → 0.0.2-java

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,7 +13,3 @@ Use it like this:
13
13
  Using bundler:
14
14
 
15
15
  gem "carrierwave-neo4j", :require => "carrierwave/neo4j"
16
-
17
- == TODO
18
-
19
- Add support for CarrierWave validations.
@@ -1,6 +1,7 @@
1
1
  require "carrierwave/neo4j/version"
2
2
  require "neo4j"
3
3
  require "carrierwave"
4
+ require "carrierwave/validations/active_model"
4
5
 
5
6
  module CarrierWave
6
7
  module Neo4j
@@ -17,6 +18,11 @@ module CarrierWave
17
18
  alias_method :read_uploader, :read_attribute
18
19
  alias_method :write_uploader, :write_attribute
19
20
 
21
+ include CarrierWave::Validations::ActiveModel
22
+
23
+ validates_integrity_of column if uploader_option(column.to_sym, :validate_integrity)
24
+ validates_processing_of column if uploader_option(column.to_sym, :validate_processing)
25
+
20
26
  after_save :"store_#{column}!"
21
27
  before_save :"write_#{column}_identifier"
22
28
  after_destroy :"remove_#{column}!"
@@ -1,5 +1,5 @@
1
1
  module CarrierWave
2
2
  module Neo4j
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -14,6 +14,20 @@ end
14
14
 
15
15
  class DefaultUploader < CarrierWave::Uploader::Base; end
16
16
 
17
+ class PngUploader < CarrierWave::Uploader::Base
18
+ def extension_white_list
19
+ %w(png)
20
+ end
21
+ end
22
+
23
+ class ProcessingErrorUploader < CarrierWave::Uploader::Base
24
+ process :end_on_an_era
25
+
26
+ def end_on_an_era
27
+ raise CarrierWave::ProcessingError, "Bye Tarja"
28
+ end
29
+ end
30
+
17
31
  describe CarrierWave::Neo4j do
18
32
  let(:user_class) { reset_class }
19
33
  let(:user) { user_class.new }
@@ -71,6 +85,26 @@ describe CarrierWave::Neo4j do
71
85
 
72
86
  its(:image) { should be_blank }
73
87
  end
88
+
89
+ context "when validating integrity" do
90
+ subject do
91
+ user = reset_class(PngUploader).new
92
+ user.image = File.open(file_path("tarja.jpg"))
93
+ user
94
+ end
95
+
96
+ it { should_not be_valid }
97
+ end
98
+
99
+ context "when validating processing" do
100
+ subject do
101
+ user = reset_class(ProcessingErrorUploader).new
102
+ user.image = File.open(file_path("tarja.jpg"))
103
+ user
104
+ end
105
+
106
+ it { should_not be_valid }
107
+ end
74
108
  end
75
109
 
76
110
  describe "#destroy" do
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: carrierwave-neo4j
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.1
5
+ version: 0.0.2
6
6
  platform: java
7
7
  authors:
8
8
  - Rodrigo Navarro