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.
- data/README.rdoc +0 -4
- data/lib/carrierwave/neo4j.rb +6 -0
- data/lib/carrierwave/neo4j/version.rb +1 -1
- data/spec/neo4j_spec.rb +34 -0
- metadata +1 -1
data/README.rdoc
CHANGED
data/lib/carrierwave/neo4j.rb
CHANGED
@@ -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}!"
|
data/spec/neo4j_spec.rb
CHANGED
@@ -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
|