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 !
fixed avatar file uploads

git-svn-id: http://svn.techno-weenie.net/projects/mephisto/trunk@1008 
567b1171-46fb-0310-a4c9-b4bef9110e78
technoweenie (author)
Sun Mar 26 18:53:39 -0800 2006
commit  c98067555f605e3176ab2dba8748b44aa58a43a8
tree    6a47ff34529b045edaab688fe3bff26fcda7f089
parent  5e4ad794fbaff127c11f7718b5c64913a3e70374
...
3
4
5
 
6
7
...
3
4
5
6
7
8
0
@@ -3,5 +3,6 @@
0
 # If it's a User Asset, it's a profile image.
0
 # Template and Resource inherit from Asset but serve different purposes.
0
 class Asset < Attachment
0
+ validates_presence_of :attachable_id, :attachable_type
0
   belongs_to :attachable, :polymorphic => true
0
 end
...
78
79
80
81
 
 
82
83
84
...
78
79
80
 
81
82
83
84
85
0
@@ -78,7 +78,8 @@ class User < ActiveRecord::Base
0
 
0
   protected
0
   def save_uploaded_avatar
0
- build_avatar :uploaded_data => @uploaded_avatar if @uploaded_avatar && @uploaded_avatar.size > 0
0
+ return unless @uploaded_avatar && @uploaded_avatar.size > 0
0
+ (self.avatar ||= build_avatar).update_attributes :uploaded_data => @uploaded_avatar, :attachable => self
0
   end
0
 
0
   def encrypt_password
...
36
37
38
39
 
40
41
42
...
67
68
69
70
71
72
73
...
36
37
38
 
39
40
41
42
...
67
68
69
 
70
71
72
0
@@ -36,7 +36,7 @@ Rails::Initializer.run do |config|
0
   # config.action_controller.fragment_cache_store = :file_store, "#{RAILS_ROOT}/cache"
0
 
0
   # Activate observers that should always be running
0
- # config.active_record.observers = :cacher, :garbage_collector
0
+ # config.active_record.observers = [:article_observer]
0
 
0
   # Make Active Record use UTC-base instead of local time
0
   config.active_record.default_timezone = :utc
0
@@ -67,7 +67,6 @@ Liquid::Template.register_tag('textile', Mephisto::Liquid::Textile)
0
 Liquid::Template.register_tag('commentform', Mephisto::Liquid::CommentForm)
0
 Liquid::Template.register_tag('pagenavigation', Mephisto::Liquid::PageNavigation)
0
 Liquid::Template.register_tag('head', Mephisto::Liquid::Head)
0
-
0
 FilteredColumn.constant_filters << :macro_filter
0
 
0
 ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.update \
...
4
5
6
7
8
 
 
9
10
11
 
 
12
13
14
...
19
20
21
22
23
 
 
24
25
26
...
4
5
6
 
 
7
8
9
 
 
10
11
12
13
14
...
19
20
21
 
 
22
23
24
25
26
0
@@ -4,11 +4,11 @@
0
 server.port = 3000
0
 
0
 server.modules = ( "mod_rewrite", "mod_accesslog", "mod_fastcgi" )
0
-server.error-handler-404 = "/dispatch.fcgi"
0
-server.document-root = "public/"
0
+server.error-handler-404 = "/Users/rick/p/mephisto/trunk/dispatch.fcgi"
0
+server.document-root = "/Users/rick/p/mephisto/trunk/public/"
0
 
0
-server.errorlog = "log/lighttpd.error.log"
0
-accesslog.filename = "log/lighttpd.access.log"
0
+server.errorlog = "/Users/rick/p/mephisto/trunk/log/lighttpd.error.log"
0
+accesslog.filename = "/Users/rick/p/mephisto/trunk/log/lighttpd.access.log"
0
 
0
 url.rewrite = ( "^/$" => "index.html", "^([^.]+)$" => "$1.html" )
0
 
0
@@ -19,8 +19,8 @@ fastcgi.server = ( ".fcgi" =>
0
       (
0
         "min-procs" => 1,
0
         "max-procs" => 1,
0
- "socket" => "log/fcgi.socket",
0
- "bin-path" => "public/dispatch.fcgi",
0
+ "socket" => "/Users/rick/p/mephisto/trunk/log/fcgi.socket",
0
+ "bin-path" => "/Users/rick/p/mephisto/trunk/public/dispatch.fcgi",
0
         "bin-environment" => ( "RAILS_ENV" => "development" )
0
       )
0
   )
...
35
36
37
38
 
39
40
41
...
35
36
37
 
38
39
40
41
0
@@ -35,7 +35,7 @@ class AccountControllerTest < Test::Unit::TestCase
0
     login_as :quentin
0
     get :logout
0
     assert_nil session[:user]
0
- assert_redirected_to section_url(:sections => [])
0
+ assert_redirected_to section_url
0
     assert_response :redirect
0
   end
0
 
...
49
50
51
52
 
53
54
55
...
49
50
51
 
52
53
54
55
0
@@ -49,7 +49,7 @@ class Admin::ResourcesControllerTest < Test::Unit::TestCase
0
 
0
   def test_should_upload_resource
0
     assert_attachment_created do
0
- post :upload, :resource => { :uploaded_data => file_upload }
0
+ post :upload, :resource => { :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png') }
0
     end
0
     
0
     assert_redirected_to :controller => 'admin/design', :action => 'index'
...
64
65
66
67
68
69
70
71
 
 
 
 
 
 
72
73
74
...
64
65
66
 
 
 
 
 
67
68
69
70
71
72
73
74
75
0
@@ -64,11 +64,12 @@ class Admin::UsersControllerTest < Test::Unit::TestCase
0
 
0
   def test_should_upload_avatar
0
     assert_attachment_created do
0
- post :update, :id => users(:quentin).login, :user => { :email => 'foo', :password => 'testy', :password_confirmation => 'testy', :uploaded_avatar => file_upload }
0
- users(:quentin).reload
0
- assert_equal 'foo', users(:quentin).email
0
- assert_equal users(:quentin), User.authenticate('quentin', 'testy')
0
- assert_redirected_to :action => 'show', :id => users(:quentin).login
0
+ post :update, :id => users(:arthur).login, :user => { :email => 'foo', :password => 'testy', :password_confirmation => 'testy',
0
+ :uploaded_avatar => fixture_file_upload('/files/rails.png', 'image/png') }
0
+ users(:arthur).reload
0
+ assert_equal 'foo', users(:arthur).email
0
+ assert_equal users(:arthur), User.authenticate('arthur', 'testy')
0
+ assert_redirected_to :action => 'show', :id => users(:arthur).login
0
     end
0
   end
0
 
...
49
50
51
52
53
54
55
56
57
58
...
49
50
51
 
 
 
 
52
53
54
0
@@ -49,10 +49,6 @@ class Test::Unit::TestCase
0
       yield
0
     end
0
   end
0
-
0
- def file_upload(options = {})
0
- Technoweenie::FileUpload.new(options[:filename] || 'rails.png', options[:content_type] || 'image/png')
0
- end
0
 end
0
 
0
 class ActionController::IntegrationTest

Comments

    No one has commented yet.