cluster configuration for new machine
[selectricity-live] / vendor / plugins / attachment_fu / test / fixtures / attachment.rb
1 class Attachment < ActiveRecord::Base
2   @@saves = 0
3   cattr_accessor :saves
4   has_attachment :processor => :rmagick
5   validates_as_attachment
6   after_attachment_saved do |record|
7     self.saves += 1
8   end
9 end
10
11 class SmallAttachment < Attachment
12   has_attachment :max_size => 1.kilobyte
13 end
14
15 class BigAttachment < Attachment
16   has_attachment :size => 1.megabyte..2.megabytes
17 end
18
19 class PdfAttachment < Attachment
20   has_attachment :content_type => 'pdf'
21 end
22
23 class DocAttachment < Attachment
24   has_attachment :content_type => %w(pdf doc txt)
25 end
26
27 class ImageAttachment < Attachment
28   has_attachment :content_type => :image, :resize_to => [50,50]
29 end
30
31 class ImageOrPdfAttachment < Attachment
32   has_attachment :content_type => ['pdf', :image], :resize_to => 'x50'
33 end
34
35 class ImageWithThumbsAttachment < Attachment
36   has_attachment :thumbnails => { :thumb => [50, 50], :geometry => 'x50' }, :resize_to => [55,55]
37   after_resize do |record, img|
38     record.aspect_ratio = img.columns.to_f / img.rows.to_f
39   end
40 end
41
42 class FileAttachment < ActiveRecord::Base
43   has_attachment :path_prefix => 'vendor/plugins/attachment_fu/test/files', :processor => :rmagick
44   validates_as_attachment
45 end
46
47 class ImageFileAttachment < FileAttachment
48   has_attachment :path_prefix => 'vendor/plugins/attachment_fu/test/files',
49     :content_type => :image, :resize_to => [50,50]
50 end
51
52 class ImageWithThumbsFileAttachment < FileAttachment
53   has_attachment :path_prefix => 'vendor/plugins/attachment_fu/test/files',
54     :thumbnails => { :thumb => [50, 50], :geometry => 'x50' }, :resize_to => [55,55]
55   after_resize do |record, img|
56     record.aspect_ratio = img.columns.to_f / img.rows.to_f
57   end
58 end
59
60 class ImageWithThumbsClassFileAttachment < FileAttachment
61   # use file_system_path to test backwards compatibility
62   has_attachment :file_system_path => 'vendor/plugins/attachment_fu/test/files',
63     :thumbnails => { :thumb => [50, 50] }, :resize_to => [55,55],
64     :thumbnail_class => 'ImageThumbnail'
65 end
66
67 class ImageThumbnail < FileAttachment
68   has_attachment :path_prefix => 'vendor/plugins/attachment_fu/test/files/thumbnails'
69 end
70
71 # no parent
72 class OrphanAttachment < ActiveRecord::Base
73   has_attachment :processor => :rmagick
74   validates_as_attachment
75 end
76
77 # no filename, no size, no content_type
78 class MinimalAttachment < ActiveRecord::Base
79   has_attachment :path_prefix => 'vendor/plugins/attachment_fu/test/files', :processor => :rmagick
80   validates_as_attachment
81   
82   def filename
83     "#{id}.file"
84   end
85 end
86
87 begin
88   class ImageScienceAttachment < ActiveRecord::Base
89     has_attachment :path_prefix => 'vendor/plugins/attachment_fu/test/files',
90       :processor => :image_science, :thumbnails => { :thumb => [50, 51], :geometry => '31>' }, :resize_to => 55
91   end
92 rescue MissingSourceFile
93   puts $!.message
94   puts "no ImageScience"
95 end
96
97 begin
98   class MiniMagickAttachment < ActiveRecord::Base
99     has_attachment :path_prefix => 'vendor/plugins/attachment_fu/test/files',
100       :processor => :mini_magick, :thumbnails => { :thumb => [50, 51], :geometry => '31>' }, :resize_to => 55
101   end
102 rescue MissingSourceFile
103   puts $!.message
104   puts "no Mini Magick"
105 end
106
107 begin
108   class MiniMagickAttachment < ActiveRecord::Base
109     has_attachment :path_prefix => 'vendor/plugins/attachment_fu/test/files',
110       :processor => :mini_magick, :thumbnails => { :thumb => [50, 51], :geometry => '31>' }, :resize_to => 55
111   end
112 rescue MissingSourceFile
113 end
114
115 begin
116   class S3Attachment < ActiveRecord::Base
117     has_attachment :storage => :s3, :processor => :rmagick, :s3_config_path => File.join(File.dirname(__FILE__), '../amazon_s3.yml')
118     validates_as_attachment
119   end
120
121   class S3WithPathPrefixAttachment < S3Attachment
122     has_attachment :storage => :s3, :path_prefix => 'some/custom/path/prefix', :processor => :rmagick
123     validates_as_attachment
124   end
125 rescue Technoweenie::AttachmentFu::Backends::S3Backend::ConfigFileNotFoundError
126   puts "S3 error: #{$!}"
127 end

Benjamin Mako Hill || Want to submit a patch?