potential fix for #1926
This commit is contained in:
@@ -11,7 +11,7 @@ class Upload < ActiveRecord::Base
|
|||||||
before_validation :initialize_status, :on => :create
|
before_validation :initialize_status, :on => :create
|
||||||
before_create :convert_cgi_file
|
before_create :convert_cgi_file
|
||||||
after_destroy :delete_temp_file
|
after_destroy :delete_temp_file
|
||||||
validate :uploader_is_not_limited
|
validate :uploader_is_not_limited, :on => :create
|
||||||
validate :file_or_source_is_present, :on => :create
|
validate :file_or_source_is_present, :on => :create
|
||||||
|
|
||||||
module ValidationMethods
|
module ValidationMethods
|
||||||
|
|||||||
@@ -65,11 +65,16 @@ class UserTest < ActiveSupport::TestCase
|
|||||||
@user.update_column(:level, User::Levels::CONTRIBUTOR)
|
@user.update_column(:level, User::Levels::CONTRIBUTOR)
|
||||||
assert(@user.can_upload?)
|
assert(@user.can_upload?)
|
||||||
@user.update_column(:level, User::Levels::MEMBER)
|
@user.update_column(:level, User::Levels::MEMBER)
|
||||||
|
@user.update_column(:created_at, 1.month.ago)
|
||||||
|
assert_equal(10, @user.upload_limit)
|
||||||
|
|
||||||
40.times do
|
9.times do
|
||||||
FactoryGirl.create(:post, :uploader => @user, :is_deleted => true)
|
FactoryGirl.create(:post, :uploader => @user, :is_pending => true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
assert_equal(1, @user.upload_limit)
|
||||||
|
assert(@user.can_upload?)
|
||||||
|
FactoryGirl.create(:post, :uploader => @user, :is_pending => true)
|
||||||
assert(!@user.can_upload?)
|
assert(!@user.can_upload?)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user