public
Rubygem
Description: Ruby helpers for avatar display
Clone URL: git://github.com/gcnovus/avatar.git
added PaperclipSource and PaperclipSourceTest
gcnovus (author)
Tue Apr 01 10:03:01 -0700 2008
commit  5bb512673c9b06b4604dc87d743932ee71cb85c8
tree    c8dfc207d5cf6f0e9ae469f9e3a25a000cd95c85
parent  6610b6c43d6eee44032b99c1532a404489c517b6
...
1
2
 
3
4
5
 
 
 
 
 
 
 
 
 
 
 
 
 
6
7
8
...
1
 
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
0
@@ -1,7 +1,20 @@
0
 ActiveRecord::Schema.define :version => 0 do
0
- create_table :users, :force => true do |t|
0
+ create_table :file_column_users, :force => true do |t|
0
     t.column :name, :text, :nil => false
0
     t.column :email, :text, :nil => false
0
     t.column :avatar, :string
0
+ t.column :icon, :string
0
+ end
0
+ create_table :paperclip_users, :force => true do |t|
0
+ t.column :name, :text, :nil => false
0
+ t.column :email, :text, :nil => false
0
+
0
+ t.column :avatar_file_name, :string
0
+ t.column :avatar_content_type, :string
0
+ t.column :avatar_file_size, :integer
0
+
0
+ t.column :icon_file_name, :string
0
+ t.column :icon_content_type, :string
0
+ t.column :icon_file_size, :integer
0
   end
0
 end
0
\ No newline at end of file
...
 
1
 
2
3
4
5
 
6
7
8
...
12
13
14
15
16
17
 
 
 
18
19
20
...
26
27
28
29
 
30
31
32
33
 
34
35
36
...
1
2
3
4
5
6
 
7
8
9
10
...
14
15
16
 
 
 
17
18
19
20
21
22
...
28
29
30
 
31
32
33
34
 
35
36
37
38
0
@@ -1,8 +1,10 @@
0
+$: << File.expand_path(File.join(File.dirname(__FILE__), ['lib', 'file_column', 'lib']))
0
 require File.join(File.dirname(__FILE__), 'test_helper.rb')
0
+require File.join(File.dirname(__FILE__), ['lib', 'file_column', 'init'])
0
 require 'file_column'
0
 require 'avatar/source/file_column_source'
0
 
0
-class User < ActiveRecord::Base
0
+class FileColumnUser < ActiveRecord::Base
0
   file_column :avatar
0
   file_column :icon
0
 end
0
@@ -12,9 +14,9 @@ class TestFileColumnSource < Test::Unit::TestCase
0
   def setup
0
     @source = Avatar::Source::FileColumnSource.new
0
     png = File.new(File.join(File.dirname(__FILE__), ['lib', 'user_suit.png']))
0
- @user_with_avatar = User.create!(:email => 'joe@example.com', :avatar => png)
0
- @user_with_icon = User.create!(:email => 'terry@example.com', :icon => png)
0
- @user_without_avatar = User.create!(:email => 'sue@example.com')
0
+ @user_with_avatar = FileColumnUser.create!(:email => 'joe@example.com', :avatar => png)
0
+ @user_with_icon = FileColumnUser.create!(:email => 'terry@example.com', :icon => png)
0
+ @user_without_avatar = FileColumnUser.create!(:email => 'sue@example.com')
0
   end
0
   
0
   def test_avatar_url_is_nil_if_person_is_nil
0
@@ -26,11 +28,11 @@ class TestFileColumnSource < Test::Unit::TestCase
0
   end
0
   
0
   def test_avatar_url_for_person_with_avatar
0
- assert_equal "/user/avatar/#{@user_with_avatar.id}/0/user_suit.png", @source.avatar_url_for(@user_with_avatar)
0
+ assert_equal "/file_column_user/avatar/#{@user_with_avatar.id}/0/user_suit.png", @source.avatar_url_for(@user_with_avatar)
0
   end
0
   
0
   def test_avatar_url_for_person_with_icon_and_custom_file_column_field
0
- assert_equal "/user/icon/#{@user_with_icon.id}/0/user_suit.png", @source.avatar_url_for(@user_with_icon, :file_column_field => :icon)
0
+ assert_equal "/file_column_user/icon/#{@user_with_icon.id}/0/user_suit.png", @source.avatar_url_for(@user_with_icon, :file_column_field => :icon)
0
   end
0
   
0
 end
...
7
8
9
10
11
 
 
 
 
 
 
 
12
13
14
...
7
8
9
 
 
10
11
12
13
14
15
16
17
18
19
0
@@ -7,8 +7,13 @@ require 'active_record'
0
 require 'active_support'
0
 require 'action_controller'
0
 require 'action_view'
0
-$: << File.expand_path(File.join(File.dirname(__FILE__), ['lib', 'file_column', 'lib']))
0
-require File.join(File.dirname(__FILE__), ['lib', 'file_column', 'init'])
0
+
0
+#$: << File.expand_path(File.join(File.dirname(__FILE__), ['lib', 'file_column', 'lib']))
0
+#$: << File.expand_path(File.join(File.dirname(__FILE__), ['lib', 'paperclip', 'lib']))
0
+
0
+#require File.join(File.dirname(__FILE__), ['lib', 'file_column', 'init'])
0
+#require File.join(File.dirname(__FILE__), ['lib', 'paperclip', 'init'])
0
+
0
 require File.join(File.dirname(__FILE__), ['lib', 'database'])
0
 require File.join(File.dirname(__FILE__), ['lib', 'schema'])
0
 require File.join(File.dirname(__FILE__), ['..', 'lib', 'avatar'])

Comments

    No one has commented yet.