delayed_paperclip 0.6.4 → 0.6.5
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/delayed_paperclip.gemspec +2 -2
- data/lib/delayed/paperclip.rb +6 -4
- data/test/delayed_paperclip_test.rb +7 -0
- data/test/test_helper.rb +12 -15
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
1
|
+
0.6.5
|
data/delayed_paperclip.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{delayed_paperclip}
|
8
|
-
s.version = "0.6.
|
8
|
+
s.version = "0.6.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Jesse Storimer"]
|
12
|
-
s.date = %q{2010-03-
|
12
|
+
s.date = %q{2010-03-13}
|
13
13
|
s.description = %q{Process your Paperclip attachments in the background with delayed_job.}
|
14
14
|
s.email = %q{jesse@jstorimer.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/delayed/paperclip.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Delayed
|
2
2
|
module Paperclip
|
3
|
-
def self.included(base)
|
3
|
+
def self.included(base)
|
4
4
|
base.extend(ClassMethods)
|
5
5
|
end
|
6
6
|
|
@@ -76,17 +76,18 @@ module Delayed
|
|
76
76
|
def column_exists?(column)
|
77
77
|
self.class.columns_hash.has_key?(column.to_s)
|
78
78
|
end
|
79
|
-
end
|
79
|
+
end
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
83
|
module Paperclip
|
84
84
|
class Attachment
|
85
85
|
attr_accessor :job_is_processing
|
86
|
-
|
86
|
+
|
87
87
|
def url_with_processed style = default_style, include_updated_timestamp = true
|
88
|
+
return url_without_processed style, include_updated_timestamp unless @instance.respond_to?(:column_exists?)
|
88
89
|
return url_without_processed style, include_updated_timestamp if job_is_processing
|
89
|
-
|
90
|
+
|
90
91
|
if !@instance.column_exists?(:"#{@name}_processing")
|
91
92
|
url_without_processed style, include_updated_timestamp
|
92
93
|
else
|
@@ -101,6 +102,7 @@ module Paperclip
|
|
101
102
|
end
|
102
103
|
end
|
103
104
|
end
|
105
|
+
|
104
106
|
alias_method_chain :url, :processed
|
105
107
|
end
|
106
108
|
end
|
@@ -138,4 +138,11 @@ class DelayedPaperclipTest < Test::Unit::TestCase
|
|
138
138
|
|
139
139
|
assert_match(/images\/.*missing.*/, @dummy.image.url)
|
140
140
|
end
|
141
|
+
|
142
|
+
def test_should_not_blow_up_if_dsl_unused
|
143
|
+
reset_class "Dummy", false
|
144
|
+
@dummy = Dummy.new(:image => File.open("#{RAILS_ROOT}/test/fixtures/12k.png"))
|
145
|
+
|
146
|
+
assert @dummy.image.url
|
147
|
+
end
|
141
148
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,19 +1,7 @@
|
|
1
1
|
require 'test/unit'
|
2
2
|
require 'rubygems'
|
3
3
|
require 'mocha'
|
4
|
-
|
5
4
|
require 'active_record'
|
6
|
-
require 'active_support'
|
7
|
-
|
8
|
-
gem 'sqlite3-ruby'
|
9
|
-
|
10
|
-
gem 'paperclip'
|
11
|
-
require 'paperclip'
|
12
|
-
|
13
|
-
FIXTURES_DIR = File.join(File.dirname(__FILE__), "fixtures")
|
14
|
-
config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml'))
|
15
|
-
ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log")
|
16
|
-
ActiveRecord::Base.establish_connection(config['test'])
|
17
5
|
|
18
6
|
ROOT = File.join(File.dirname(__FILE__), '..')
|
19
7
|
RAILS_ROOT = ROOT
|
@@ -25,6 +13,16 @@ $LOAD_PATH << File.join(ROOT, 'test')
|
|
25
13
|
|
26
14
|
require File.join(ROOT, 'lib', 'delayed_paperclip.rb')
|
27
15
|
|
16
|
+
require 'active_support'
|
17
|
+
gem 'sqlite3-ruby'
|
18
|
+
|
19
|
+
gem 'paperclip'
|
20
|
+
require 'paperclip'
|
21
|
+
|
22
|
+
FIXTURES_DIR = File.join(File.dirname(__FILE__), "fixtures")
|
23
|
+
config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml'))
|
24
|
+
ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log")
|
25
|
+
ActiveRecord::Base.establish_connection(config['test'])
|
28
26
|
|
29
27
|
def reset_dummy(with_processed = false)
|
30
28
|
build_dummy_table(with_processed)
|
@@ -34,13 +32,12 @@ def reset_dummy(with_processed = false)
|
|
34
32
|
@dummy = Dummy.new(:image => File.open("#{RAILS_ROOT}/test/fixtures/12k.png"))
|
35
33
|
end
|
36
34
|
|
37
|
-
def reset_class class_name
|
38
|
-
ActiveRecord::Base.send(:include, Paperclip)
|
35
|
+
def reset_class class_name, include_process = true
|
39
36
|
Object.send(:remove_const, class_name) rescue nil
|
40
37
|
klass = Object.const_set(class_name, Class.new(ActiveRecord::Base))
|
41
38
|
klass.class_eval do
|
42
39
|
has_attached_file :image
|
43
|
-
process_in_background :image
|
40
|
+
process_in_background :image if include_process
|
44
41
|
end
|
45
42
|
@dummy_class = klass
|
46
43
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 6
|
8
|
-
-
|
9
|
-
version: 0.6.
|
8
|
+
- 5
|
9
|
+
version: 0.6.5
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Jesse Storimer
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-03-
|
17
|
+
date: 2010-03-13 00:00:00 -05:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|