Permalink
Browse files

wip

  • Loading branch information...
1 parent 0fdae34 commit 6decb1e70a243fc555337a6a52f1e4c0786bc3a9 @mike-burns mike-burns committed with jyurek Jul 16, 2012
Showing with 29 additions and 3 deletions.
  1. +5 −0 lib/paperclip/schema.rb
  2. +6 −0 lib/paperclip/style_adder.rb
  3. +18 −3 test/schema_test.rb
View
@@ -1,4 +1,5 @@
require 'active_support/deprecation'
+require 'paperclip/style_adder'
module Paperclip
# Provides helper methods that can be used in migrations.
@@ -43,6 +44,10 @@ def drop_attached_file(*args)
ActiveSupport::Deprecation.warn "Method `drop_attached_file` in the migration has been deprecated and will be replaced by `remove_attachment`."
remove_attachment(*args)
end
+
+ def add_style(table_name, attachment_name, styles)
+ StyleAdder.run(table_name, attachment_name, styles)
+ end
end
module TableDefinition
@@ -0,0 +1,6 @@
+class StyleAdder
+ def self.run(table_name, attachment_name, styles)
+ model = table_name.to_s.???
+ new(model, attachment_name, styles).run
+ end
+end
View
@@ -198,17 +198,32 @@ def teardown
end
context '#add_style' do
- should 'process the specific style'
+ should 'process the specific style' do
+ rebuild_class thumbnail: '24x24', large: '124x124', processors: [:recording]
+
+ Dummy.connection.add_style :dummies, :avatar, large: '124x124'
+
+ assert RecordingProcessor.has_processed?(large: '124x124')
+ assert !RecordingProcessor.has_processed?(thumbnail: '24x24')
+ end
should 'raise if the style is missing' do
assert_raise ArgumentError do
Dummy.connection.add_style :dummies, :avatar, missing_style: '24x24'
end
end
- should 'raise if the attachment is missing'
+ should 'raise if the attachment is missing' do
+ assert_raise ArgumentError do
+ Dummy.connection.add_style :dummies, :missng_attachment, thumbnail: '24x24'
+ end
+ end
- should 'raise if the model is missing'
+ should 'raise if the model is missing' do
+ assert_raise ArgumentError do
+ Dummy.connection.add_style :missing_model, :avatar, thumbnail: '24x24'
+ end
+ end
end
end
end

0 comments on commit 6decb1e

Please sign in to comment.