paperclip 2.3.11 → 2.3.16
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.
Potentially problematic release.
This version of paperclip might be problematic. Click here for more details.
- data/README.md +30 -4
- data/Rakefile +3 -3
- data/init.rb +3 -0
- data/lib/generators/paperclip/paperclip_generator.rb +3 -1
- data/lib/paperclip/attachment.rb +27 -12
- data/lib/paperclip/{callback_compatability.rb → callback_compatibility.rb} +0 -0
- data/lib/paperclip/geometry.rb +4 -1
- data/lib/paperclip/interpolations.rb +8 -3
- data/lib/paperclip/iostream.rb +1 -1
- data/lib/paperclip/matchers/validate_attachment_content_type_matcher.rb +20 -14
- data/lib/paperclip/processor.rb +1 -1
- data/lib/paperclip/storage/filesystem.rb +8 -3
- data/lib/paperclip/storage/fog.rb +48 -13
- data/lib/paperclip/storage/s3.rb +54 -16
- data/lib/paperclip/style.rb +4 -3
- data/lib/paperclip/thumbnail.rb +18 -3
- data/lib/paperclip/upfile.rb +20 -13
- data/lib/paperclip/version.rb +1 -1
- data/lib/paperclip.rb +60 -27
- data/lib/tasks/paperclip.rake +32 -23
- data/test/attachment_test.rb +116 -0
- data/test/fixtures/animated.gif +0 -0
- data/test/fog_test.rb +30 -19
- data/test/geometry_test.rb +29 -0
- data/test/helper.rb +3 -0
- data/test/integration_test.rb +40 -4
- data/test/interpolations_test.rb +14 -0
- data/test/matchers/validate_attachment_content_type_matcher_test.rb +42 -2
- data/test/paperclip_test.rb +18 -40
- data/test/storage_test.rb +244 -7
- data/test/style_test.rb +30 -5
- data/test/thumbnail_test.rb +111 -6
- data/test/upfile_test.rb +3 -2
- metadata +103 -122
- data/lib/paperclip/command_line.rb +0 -86
- data/test/command_line_test.rb +0 -138
data/test/command_line_test.rb
DELETED
@@ -1,138 +0,0 @@
|
|
1
|
-
require './test/helper'
|
2
|
-
|
3
|
-
class CommandLineTest < Test::Unit::TestCase
|
4
|
-
def setup
|
5
|
-
Paperclip::CommandLine.path = nil
|
6
|
-
File.stubs(:exist?).with("/dev/null").returns(true)
|
7
|
-
end
|
8
|
-
|
9
|
-
should "allow colons in parameters" do
|
10
|
-
cmd = Paperclip::CommandLine.new("convert", "'a.jpg' -resize 175x220> -size 175x220 xc:black +swap -gravity center -composite 'b.jpg'", :swallow_stderr => false)
|
11
|
-
assert_equal "convert 'a.jpg' -resize 175x220> -size 175x220 xc:black +swap -gravity center -composite 'b.jpg'", cmd.command
|
12
|
-
end
|
13
|
-
|
14
|
-
should "take a command and parameters and produce a shell command for bash" do
|
15
|
-
cmd = Paperclip::CommandLine.new("convert", "a.jpg b.png", :swallow_stderr => false)
|
16
|
-
assert_equal "convert a.jpg b.png", cmd.command
|
17
|
-
end
|
18
|
-
|
19
|
-
should "be able to set a path and produce commands with that path" do
|
20
|
-
Paperclip::CommandLine.path = "/opt/bin"
|
21
|
-
cmd = Paperclip::CommandLine.new("convert", "a.jpg b.png", :swallow_stderr => false)
|
22
|
-
assert_equal "/opt/bin/convert a.jpg b.png", cmd.command
|
23
|
-
end
|
24
|
-
|
25
|
-
should "be able to interpolate quoted variables into the parameters" do
|
26
|
-
cmd = Paperclip::CommandLine.new("convert",
|
27
|
-
":one :{two}",
|
28
|
-
:one => "a.jpg",
|
29
|
-
:two => "b.png",
|
30
|
-
:swallow_stderr => false)
|
31
|
-
assert_equal "convert 'a.jpg' 'b.png'", cmd.command
|
32
|
-
end
|
33
|
-
|
34
|
-
should "quote command line options differently if we're on windows" do
|
35
|
-
File.stubs(:exist?).with("/dev/null").returns(false)
|
36
|
-
cmd = Paperclip::CommandLine.new("convert",
|
37
|
-
":one :{two}",
|
38
|
-
:one => "a.jpg",
|
39
|
-
:two => "b.png",
|
40
|
-
:swallow_stderr => false)
|
41
|
-
assert_equal 'convert "a.jpg" "b.png"', cmd.command
|
42
|
-
end
|
43
|
-
|
44
|
-
should "be able to quote and interpolate dangerous variables" do
|
45
|
-
cmd = Paperclip::CommandLine.new("convert",
|
46
|
-
":one :two",
|
47
|
-
:one => "`rm -rf`.jpg",
|
48
|
-
:two => "ha'ha.png",
|
49
|
-
:swallow_stderr => false)
|
50
|
-
assert_equal "convert '`rm -rf`.jpg' 'ha'\\''ha.png'", cmd.command
|
51
|
-
end
|
52
|
-
|
53
|
-
should "be able to quote and interpolate dangerous variables even on windows" do
|
54
|
-
File.stubs(:exist?).with("/dev/null").returns(false)
|
55
|
-
cmd = Paperclip::CommandLine.new("convert",
|
56
|
-
":one :two",
|
57
|
-
:one => "`rm -rf`.jpg",
|
58
|
-
:two => "ha'ha.png",
|
59
|
-
:swallow_stderr => false)
|
60
|
-
assert_equal %{convert "`rm -rf`.jpg" "ha'ha.png"}, cmd.command
|
61
|
-
end
|
62
|
-
|
63
|
-
should "add redirection to get rid of stderr in bash" do
|
64
|
-
File.stubs(:exist?).with("/dev/null").returns(true)
|
65
|
-
cmd = Paperclip::CommandLine.new("convert",
|
66
|
-
"a.jpg b.png",
|
67
|
-
:swallow_stderr => true)
|
68
|
-
|
69
|
-
assert_equal "convert a.jpg b.png 2>/dev/null", cmd.command
|
70
|
-
end
|
71
|
-
|
72
|
-
should "add redirection to get rid of stderr in cmd.exe" do
|
73
|
-
File.stubs(:exist?).with("/dev/null").returns(false)
|
74
|
-
cmd = Paperclip::CommandLine.new("convert",
|
75
|
-
"a.jpg b.png",
|
76
|
-
:swallow_stderr => true)
|
77
|
-
|
78
|
-
assert_equal "convert a.jpg b.png 2>NUL", cmd.command
|
79
|
-
end
|
80
|
-
|
81
|
-
should "raise if trying to interpolate :swallow_stderr or :expected_outcodes" do
|
82
|
-
cmd = Paperclip::CommandLine.new("convert",
|
83
|
-
":swallow_stderr :expected_outcodes",
|
84
|
-
:swallow_stderr => false,
|
85
|
-
:expected_outcodes => [0, 1])
|
86
|
-
assert_raise(Paperclip::PaperclipCommandLineError) do
|
87
|
-
cmd.command
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
should "run the #command it's given and return the output" do
|
92
|
-
cmd = Paperclip::CommandLine.new("convert", "a.jpg b.png", :swallow_stderr => false)
|
93
|
-
cmd.class.stubs(:"`").with("convert a.jpg b.png").returns(:correct_value)
|
94
|
-
with_exitstatus_returning(0) do
|
95
|
-
assert_equal :correct_value, cmd.run
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
should "raise a PaperclipCommandLineError if the result code isn't expected" do
|
100
|
-
cmd = Paperclip::CommandLine.new("convert", "a.jpg b.png", :swallow_stderr => false)
|
101
|
-
cmd.class.stubs(:"`").with("convert a.jpg b.png").returns(:correct_value)
|
102
|
-
with_exitstatus_returning(1) do
|
103
|
-
assert_raises(Paperclip::PaperclipCommandLineError) do
|
104
|
-
cmd.run
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
should "not raise a PaperclipCommandLineError if the result code is expected" do
|
110
|
-
cmd = Paperclip::CommandLine.new("convert",
|
111
|
-
"a.jpg b.png",
|
112
|
-
:expected_outcodes => [0, 1],
|
113
|
-
:swallow_stderr => false)
|
114
|
-
cmd.class.stubs(:"`").with("convert a.jpg b.png").returns(:correct_value)
|
115
|
-
with_exitstatus_returning(1) do
|
116
|
-
assert_nothing_raised do
|
117
|
-
cmd.run
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
should "log the command" do
|
123
|
-
cmd = Paperclip::CommandLine.new("convert", "a.jpg b.png", :swallow_stderr => false)
|
124
|
-
cmd.class.stubs(:'`')
|
125
|
-
Paperclip.expects(:log).with("convert a.jpg b.png")
|
126
|
-
cmd.run
|
127
|
-
end
|
128
|
-
|
129
|
-
should "detect that the system is unix or windows based on presence of /dev/null" do
|
130
|
-
File.stubs(:exist?).returns(true)
|
131
|
-
assert Paperclip::CommandLine.unix?
|
132
|
-
end
|
133
|
-
|
134
|
-
should "detect that the system is not unix or windows based on absence of /dev/null" do
|
135
|
-
File.stubs(:exist?).returns(false)
|
136
|
-
assert ! Paperclip::CommandLine.unix?
|
137
|
-
end
|
138
|
-
end
|