added unapproval+upload functional test

This commit is contained in:
albert
2011-01-31 18:01:48 -05:00
parent 28b42e791c
commit df20d9233b
13 changed files with 174 additions and 9 deletions

View File

@@ -3,4 +3,10 @@ class Unapproval < ActiveRecord::Base
belongs_to :unapprover, :class_name => "User"
validates_presence_of :reason, :unapprover_id, :unapprover_ip_addr
before_validation :initialize_unapprover, :on => :create
def initialize_unapprover
self.unapprover_id = CurrentUser.id
self.unapprover_ip_addr = CurrentUser.ip_addr
end
end

View File

@@ -12,6 +12,7 @@ class Upload < ActiveRecord::Base
before_create :convert_cgi_file
after_destroy :delete_temp_file
validate :uploader_is_not_limited
scope :uploaded_by, lambda {|user_id| where(["uploader_id = ?", user_id])}
module ValidationMethods
def uploader_is_not_limited
@@ -70,6 +71,7 @@ class Upload < ActiveRecord::Base
end
end
rescue Exception => x
raise
update_attribute(:status, "error: #{x} - #{x.message}")
ensure
delete_temp_file