roachclip 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/roachclip/validations.rb +13 -0
- data/lib/roachclip.rb +5 -0
- data/roachclip.gemspec +3 -2
- data/test/test_helper.rb +1 -0
- data/test/unit/test_roachclip.rb +32 -6
- metadata +4 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/lib/roachclip.rb
CHANGED
@@ -2,6 +2,7 @@ require 'set'
|
|
2
2
|
require 'tempfile'
|
3
3
|
require 'paperclip'
|
4
4
|
require 'joint'
|
5
|
+
require 'roachclip/validations'
|
5
6
|
|
6
7
|
module Paperclip
|
7
8
|
class << self
|
@@ -34,6 +35,10 @@ module Roachclip
|
|
34
35
|
before_save :process_roaches
|
35
36
|
before_save :destroy_nil_roaches
|
36
37
|
end
|
38
|
+
|
39
|
+
def validates_roachclip(*args)
|
40
|
+
add_validations(args, Roachclip::Validations::ValidatesPresenceOf)
|
41
|
+
end
|
37
42
|
end
|
38
43
|
|
39
44
|
module InstanceMethods
|
data/roachclip.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{roachclip}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Ryan Angilly"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-08-10}
|
13
13
|
s.description = %q{Let you upload images and have use paperclip's hotness to post process them}
|
14
14
|
s.email = %q{ryan@angilly.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -22,6 +22,7 @@ Gem::Specification.new do |s|
|
|
22
22
|
"Rakefile",
|
23
23
|
"VERSION",
|
24
24
|
"lib/roachclip.rb",
|
25
|
+
"lib/roachclip/validations.rb",
|
25
26
|
"lib/roachclip/version.rb",
|
26
27
|
"roachclip.gemspec",
|
27
28
|
"script/runner.rb",
|
data/test/test_helper.rb
CHANGED
data/test/unit/test_roachclip.rb
CHANGED
@@ -43,6 +43,26 @@ class RoachclipTest < Test::Unit::TestCase
|
|
43
43
|
Doc.roachclip :image, @opts
|
44
44
|
end
|
45
45
|
|
46
|
+
context "with validations" do
|
47
|
+
setup do
|
48
|
+
Doc.validates_roachclip :image
|
49
|
+
end
|
50
|
+
|
51
|
+
context "on a new instance" do
|
52
|
+
setup do
|
53
|
+
@doc = Doc.new
|
54
|
+
end
|
55
|
+
|
56
|
+
should "validate presence of images" do
|
57
|
+
assert !@doc.valid?
|
58
|
+
assert @doc.errors.on(:image)
|
59
|
+
|
60
|
+
@doc.image = File.open(test_file_path)
|
61
|
+
assert @doc.valid?
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
46
66
|
should "add attachments for each option style" do
|
47
67
|
d = Doc.new
|
48
68
|
|
@@ -54,10 +74,8 @@ class RoachclipTest < Test::Unit::TestCase
|
|
54
74
|
|
55
75
|
context "with a saved document w/ image" do
|
56
76
|
setup do
|
57
|
-
@fname = 'fonz.jpg'
|
58
|
-
@test_file_path = File.join(File.dirname(__FILE__), '..', 'data', @fname)
|
59
77
|
@doc = Doc.new
|
60
|
-
@doc.image = File.open(
|
78
|
+
@doc.image = File.open(test_file_path)
|
61
79
|
|
62
80
|
assert @doc.save
|
63
81
|
end
|
@@ -65,14 +83,14 @@ class RoachclipTest < Test::Unit::TestCase
|
|
65
83
|
should "still save documents w/ images" do
|
66
84
|
d = Doc.find @doc.id
|
67
85
|
|
68
|
-
assert_equal
|
69
|
-
assert_equal File.size(
|
86
|
+
assert_equal fname, d.image_name
|
87
|
+
assert_equal File.size(test_file_path), d.image_size
|
70
88
|
end
|
71
89
|
|
72
90
|
should "destroy thumbs when image set to nil" do
|
73
91
|
@doc.image = nil
|
74
92
|
@doc.save!
|
75
|
-
|
93
|
+
|
76
94
|
d = Doc.find(@doc.id)
|
77
95
|
# until joint supports clearing IDs
|
78
96
|
assert_raises(Mongo::GridFileNotFound) { d.image_thumb.read }
|
@@ -89,4 +107,12 @@ class RoachclipTest < Test::Unit::TestCase
|
|
89
107
|
end
|
90
108
|
end
|
91
109
|
end
|
110
|
+
|
111
|
+
def fname
|
112
|
+
'fonz.jpg'
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_file_path
|
116
|
+
@test_file_path = File.join(File.dirname(__FILE__), '..', 'data', fname)
|
117
|
+
end
|
92
118
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 2
|
9
|
+
version: 0.1.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Ryan Angilly
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-08-10 00:00:00 -06:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -102,6 +102,7 @@ files:
|
|
102
102
|
- Rakefile
|
103
103
|
- VERSION
|
104
104
|
- lib/roachclip.rb
|
105
|
+
- lib/roachclip/validations.rb
|
105
106
|
- lib/roachclip/version.rb
|
106
107
|
- roachclip.gemspec
|
107
108
|
- script/runner.rb
|