dragonfly 1.1.3 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of dragonfly might be problematic. Click here for more details.

@@ -29,8 +29,8 @@ describe Dragonfly::ImageMagick::Processors::Convert do
29
29
  image.should have_width(280)
30
30
  end
31
31
 
32
- it "should work for files with spaces in the name" do
33
- image = Dragonfly::Content.new(app, SAMPLES_DIR.join('white pixel.png'))
32
+ it "should work for files with spaces/apostrophes in the name" do
33
+ image = Dragonfly::Content.new(app, SAMPLES_DIR.join("mevs' white pixel.png"))
34
34
  processor.call(image, "-resize 2x2!")
35
35
  image.should have_width(2)
36
36
  end
@@ -65,7 +65,7 @@ describe Dragonfly::ImageMagick::Processors::Convert do
65
65
  it "allows converting using specific delegates" do
66
66
  expect {
67
67
  processor.call(image, '', 'format' => 'jpg', 'delegate' => 'png')
68
- }.to call_command(app.shell, %r{'convert' 'png:/[^']+?/beach\.png' '/[^']+?\.jpg'})
68
+ }.to call_command(app.shell, %r{convert png:/[^']+?/beach\.png /[^']+?\.jpg})
69
69
  end
70
70
 
71
71
  it "maintains the mime_type meta if it exists already" do
@@ -1,4 +1,5 @@
1
1
  require 'spec_helper'
2
+ require 'base64'
2
3
 
3
4
  describe Dragonfly::Job::FetchUrl do
4
5
 
@@ -162,6 +163,18 @@ describe Dragonfly::Job::FetchUrl do
162
163
  job.ext.should == 'txt'
163
164
  end
164
165
 
166
+ it "accepts long base64 encoded data uris with newline" do
167
+ str = 'hello' * 10
168
+ job.fetch_url!("data:text/plain;base64,#{Base64.encode64(str)}")
169
+ job.data.should == str
170
+ end
171
+
172
+ it "accepts long base64 encoded data uris without newline" do
173
+ str = 'hello' * 10
174
+ job.fetch_url!("data:text/plain;base64,#{Base64.strict_encode64(str)}")
175
+ job.data.should == str
176
+ end
177
+
165
178
  it "doesn't accept other data uris" do
166
179
  expect {
167
180
  job.fetch_url!("data:text/html;charset=utf-8,<stuff />").apply
@@ -0,0 +1,62 @@
1
+ # jruby has problems with installing sqlite3 - don't bother with these tests for jruby
2
+ unless RUBY_PLATFORM == "java"
3
+ require "spec_helper"
4
+ require "active_record"
5
+ require "sqlite3"
6
+
7
+ # ActiveRecord specific stuff goes here (there should be very little!)
8
+ describe "ActiveRecord models" do
9
+ let! :dragonfly_app do test_app(:test_ar) end
10
+
11
+ before :all do
12
+ @connection = ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
13
+
14
+ ActiveRecord::Migration.verbose = false
15
+
16
+ ActiveRecord::Schema.define(:version => 1) do
17
+ create_table :photos do |t|
18
+ t.string :image_uid
19
+ end
20
+ end
21
+
22
+ class Photo < ActiveRecord::Base
23
+ extend Dragonfly::Model
24
+ dragonfly_accessor :image, app: :test_ar
25
+ end
26
+ end
27
+
28
+ after :all do
29
+ Photo.destroy_all
30
+ ActiveRecord::Base.remove_connection(@connection)
31
+ end
32
+
33
+ describe "destroying" do
34
+ before do
35
+ Photo.destroy_all
36
+ @photo = Photo.create(image: "some data")
37
+ end
38
+
39
+ def data_exists(uid)
40
+ !!dragonfly_app.datastore.read(uid)
41
+ end
42
+
43
+ it "should not remove the attachment if a transaction is cancelled" do
44
+ Photo.transaction do
45
+ @photo.destroy
46
+ raise ActiveRecord::Rollback
47
+ end
48
+ photo = Photo.last
49
+ expect(photo.image_uid).not_to be_nil
50
+ expect(data_exists(photo.image_uid)).to eq(true)
51
+ end
52
+
53
+ it "should remove the attachment as per usual otherwise" do
54
+ uid = @photo.image_uid
55
+ @photo.destroy
56
+ photo = Photo.last
57
+ expect(photo).to be_nil
58
+ expect(data_exists(uid)).to eq(false)
59
+ end
60
+ end
61
+ end
62
+ end
@@ -22,19 +22,21 @@ describe Dragonfly::Shell do
22
22
 
23
23
  unless Dragonfly.running_on_windows?
24
24
 
25
+ # NOTE: every \\ translates to a single \ on the command line
25
26
  describe "escaping args" do
26
27
  {
27
- %q(hello) => %q('hello'),
28
- %q("hello") => %q('hello'),
29
- %q('hello') => %q('hello'),
30
- %q(he\'llo) => %q('he'\''llo'),
31
- %q('he'\''llo') => %q('he'\''llo'),
32
- %q("he'llo") => %q('he'\''llo'),
33
- %q(hel$(lo)) => %q('hel$(lo)'),
34
- %q(hel\$(lo)) => %q('hel$(lo)'),
35
- %q('hel\$(lo)') => %q('hel\$(lo)')
28
+ %q(hello there) => %q(hello there),
29
+ %q('hello' 'there') => %q(hello there),
30
+ %q(he\\'llo there) => %q(he\\'llo there),
31
+ %q(he\\ llo there) => %q(he\\ llo there),
32
+ %q("he'llo" there) => %q(he\\'llo there),
33
+ %q('he'\\''llo' there) => %q(he\\'llo there),
34
+ %q(hel$(lo) there) => %q(hel\\$\\(lo\\) there),
35
+ %q(hel\\$(lo) > there) => %q(hel\\$\\(lo\\) \\> there),
36
+ %q('hel$(lo) > there') => %q(hel\\$\\(lo\\)\\ \\>\\ there),
37
+ %q(hello -there) => %q(hello -there),
36
38
  }.each do |args, escaped_args|
37
- it "should escape #{args.inspect} -> #{escaped_args.inspect}" do
39
+ it "should escape #{args} -> #{escaped_args}" do
38
40
  shell.escape_args(args).should == escaped_args
39
41
  end
40
42
  end
@@ -12,23 +12,47 @@ describe Dragonfly do
12
12
  end
13
13
 
14
14
  describe "logging" do
15
- before do
16
- Dragonfly.logger = Logger.new(StringIO.new)
17
- end
15
+ context "logger exists" do
16
+ before do
17
+ Dragonfly.logger = Logger.new(StringIO.new)
18
+ end
18
19
 
19
- it "debugs" do
20
- Dragonfly.logger.should_receive(:debug).with(/something/)
21
- Dragonfly.debug("something")
22
- end
20
+ it "debugs" do
21
+ Dragonfly.logger.should_receive(:debug).with(/something/)
22
+ Dragonfly.debug("something")
23
+ end
24
+
25
+ it "warns" do
26
+ Dragonfly.logger.should_receive(:warn).with(/something/)
27
+ Dragonfly.warn("something")
28
+ end
23
29
 
24
- it "warns" do
25
- Dragonfly.logger.should_receive(:warn).with(/something/)
26
- Dragonfly.warn("something")
30
+ it "shows info" do
31
+ Dragonfly.logger.should_receive(:info).with(/something/)
32
+ Dragonfly.info("something")
33
+ end
27
34
  end
28
35
 
29
- it "shows info" do
30
- Dragonfly.logger.should_receive(:info).with(/something/)
31
- Dragonfly.info("something")
36
+ context "logger is nil" do
37
+ before do
38
+ allow_message_expectations_on_nil
39
+ Dragonfly.logger = nil
40
+ end
41
+
42
+ it "does not call debug" do
43
+ Dragonfly.logger.should_not_receive(:debug)
44
+ Dragonfly.debug("something")
45
+ end
46
+
47
+ it "does not warn" do
48
+ Dragonfly.logger.should_not_receive(:warn)
49
+ Dragonfly.warn("something")
50
+ end
51
+
52
+ it "does not show info" do
53
+ Dragonfly.logger.should_not_receive(:info)
54
+ Dragonfly.info("something")
55
+ end
32
56
  end
33
57
  end
34
58
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dragonfly
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Evans
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-02 00:00:00.000000000 Z
11
+ date: 2021-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -94,6 +94,34 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: activerecord
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: sqlite3
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
97
125
  description: |-
98
126
  Dragonfly is a framework that enables on-the-fly processing for any content type.
99
127
  It is especially suited to image handling. Its uses range from image thumbnails to standard attachments to on-demand text generation.
@@ -178,10 +206,10 @@ files:
178
206
  - samples/beach.png
179
207
  - samples/egg.png
180
208
  - samples/gif.gif
209
+ - samples/mevs' white pixel.png
181
210
  - samples/round.gif
182
211
  - samples/sample.docx
183
212
  - samples/taj.jpg
184
- - samples/white pixel.png
185
213
  - spec/dragonfly/app_spec.rb
186
214
  - spec/dragonfly/configurable_spec.rb
187
215
  - spec/dragonfly/content_spec.rb
@@ -208,6 +236,7 @@ files:
208
236
  - spec/dragonfly/job_spec.rb
209
237
  - spec/dragonfly/memory_data_store_spec.rb
210
238
  - spec/dragonfly/middleware_spec.rb
239
+ - spec/dragonfly/model/active_record_spec.rb
211
240
  - spec/dragonfly/model/model_spec.rb
212
241
  - spec/dragonfly/model/validations_spec.rb
213
242
  - spec/dragonfly/register_spec.rb
@@ -241,7 +270,7 @@ homepage: http://github.com/markevans/dragonfly
241
270
  licenses:
242
271
  - MIT
243
272
  metadata: {}
244
- post_install_message:
273
+ post_install_message:
245
274
  rdoc_options: []
246
275
  require_paths:
247
276
  - lib
@@ -256,9 +285,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
256
285
  - !ruby/object:Gem::Version
257
286
  version: '0'
258
287
  requirements: []
259
- rubyforge_project:
260
- rubygems_version: 2.6.7
261
- signing_key:
288
+ rubyforge_project:
289
+ rubygems_version: 2.7.6
290
+ signing_key:
262
291
  specification_version: 4
263
292
  summary: Ideal gem for handling attachments in Rails, Sinatra and Rack applications.
264
293
  test_files:
@@ -288,6 +317,7 @@ test_files:
288
317
  - spec/dragonfly/job_spec.rb
289
318
  - spec/dragonfly/memory_data_store_spec.rb
290
319
  - spec/dragonfly/middleware_spec.rb
320
+ - spec/dragonfly/model/active_record_spec.rb
291
321
  - spec/dragonfly/model/model_spec.rb
292
322
  - spec/dragonfly/model/validations_spec.rb
293
323
  - spec/dragonfly/register_spec.rb