public
Fork of halorgium/mephisto
Description: A mirror of the mephisto code-base
Homepage: http://mephistoblog.com/
Clone URL: git://github.com/technoweenie/mephisto.git
Click here to lend your support to: mephisto and make a donation at www.pledgie.com !
add tests for models that don't store the filename

git-svn-id: http://svn.techno-weenie.net/projects/mephisto/trunk@2456 
567b1171-46fb-0310-a4c9-b4bef9110e78
technoweenie (author)
Wed Nov 08 21:43:50 -0800 2006
commit  f0d8659f0cb797c1a5ef93b2e8a7c5563ef2475f
tree    3b7b0f246d9ac2f57142cd2d17cecb6a761c0126
parent  2f1befcea511fccf66668880e6700dd02dca16a7
...
58
59
60
61
 
62
63
64
...
58
59
60
 
61
62
63
64
0
@@ -58,7 +58,7 @@ module Technoweenie # :nodoc:
0
           with_options :foreign_key => 'parent_id' do |m|
0
             m.has_many :thumbnails, :dependent => :destroy, :class_name => options[:thumbnail_class].to_s
0
             m.belongs_to :parent, :class_name => self.base_class.to_s
0
- end #if attachment_attributes[:parent_id]
0
+ end if attachment_attributes[:parent_id]
0
 
0
           include set_fs_path || options[:storage] == :file_system ? FileSystemMethods : DbFileMethods
0
           after_save :create_attachment_thumbnails # allows thumbnails with parent_id to be created
...
50
51
52
53
 
54
55
56
...
50
51
52
 
53
54
55
56
0
@@ -50,7 +50,7 @@ module Technoweenie # :nodoc:
0
       def uploaded_data=(file_data)
0
         return nil if file_data.nil? || file_data.size == 0
0
         self.content_type = file_data.content_type.strip
0
- self.filename = file_data.original_filename.strip
0
+ self.filename = file_data.original_filename.strip if respond_to?(:filename)
0
         self.attachment_data = file_data.read
0
       end
0
 
...
67
68
69
70
71
72
73
74
75
 
 
 
 
76
...
67
68
69
 
 
 
 
 
70
71
72
73
74
75
0
@@ -67,8 +67,7 @@ class OrphanAttachmentTest < Test::Unit::TestCase
0
     end
0
   end
0
 end
0
-#
0
-#class MinimalAttachmentTest < Test::Unit::TestCase
0
-# include BaseAttachmentTests
0
-# attachment_model MinimalAttachment
0
-#end
0
\ No newline at end of file
0
+
0
+class MinimalAttachmentTest < OrphanAttachmentTest
0
+ attachment_model MinimalAttachment
0
+end
0
\ No newline at end of file
...
72
73
74
75
76
77
78
79
80
81
 
 
 
 
 
 
 
 
 
 
 
82
83
84
...
72
73
74
 
 
 
 
 
 
 
75
76
77
78
79
80
81
82
83
84
85
86
87
88
0
@@ -72,13 +72,17 @@ class OrphanAttachment < ActiveRecord::Base
0
   acts_as_attachment
0
   validates_as_attachment
0
 end
0
-#
0
-## no filename, no size, no content_type
0
-#class MinimalAttachment < ActiveRecord::Base
0
-# acts_as_attachment :file_system_path => 'vendor/plugins/acts_as_attachment/test/files'
0
-# validates_as_attachment
0
-#end
0
-#
0
+
0
+# no filename, no size, no content_type
0
+class MinimalAttachment < ActiveRecord::Base
0
+ acts_as_attachment :file_system_path => 'vendor/plugins/acts_as_attachment/test/files'
0
+ validates_as_attachment
0
+
0
+ def filename
0
+ "#{id}.file"
0
+ end
0
+end
0
+
0
 ## db attachment with no db_file_id
0
 #class InvalidAttachment < ActiveRecord::Base
0
 # acts_as_attachment
...
36
37
38
39
 
40
41
42
...
36
37
38
 
39
40
41
42
0
@@ -36,7 +36,7 @@ module BaseAttachmentTests
0
       #assert_equal 1784, attachment.size
0
       assert_nil attachment.width
0
       assert_nil attachment.height
0
- assert_equal [], attachment.thumbnails
0
+ assert_equal [], attachment.thumbnails
0
     end
0
   end
0
   
...
29
30
31
32
33
34
35
 
 
 
 
 
36
37
38
...
29
30
31
 
 
 
 
32
33
34
35
36
37
38
39
0
@@ -29,10 +29,11 @@ ActiveRecord::Schema.define(:version => 0) do
0
     t.column :content_type, :string, :limit => 255
0
     t.column :size, :integer
0
   end
0
- #
0
- #create_table :minimal_attachments, :force => true do |t|
0
- # t.column :size, :integer
0
- #end
0
+
0
+ create_table :minimal_attachments, :force => true do |t|
0
+ t.column :size, :integer
0
+ t.column :content_type, :string, :limit => 255
0
+ end
0
   #
0
   #create_table :invalid_attachments, :force => true do |t|
0
   # t.column :size, :integer

Comments

    No one has commented yet.