Merge pull request #348 from abf/rosa-build:347-update_paperclip

[#347] update paperclip
This commit is contained in:
avokhmin 2014-02-13 19:59:23 +04:00
commit f77f286b7e
5 changed files with 21 additions and 17 deletions

View File

@ -14,7 +14,7 @@ gem 'omniauth-github'
gem 'cancan', '1.6.7' # 1.6.8 fail specs with strange error
gem 'ancestry', '~> 1.3.0'
gem 'paperclip', '~> 3.3.1'
gem 'paperclip', '~> 4.1.0'
gem 'resque', '~> 1.24'
gem 'resque-status', '~> 0.3.3'
gem 'resque_mailer', '~> 2.2'

View File

@ -98,7 +98,10 @@ GEM
charlock_holmes (0.6.9.4)
chronic (0.10.2)
chunky_png (1.2.9)
cocaine (0.4.2)
climate_control (0.0.3)
activesupport (>= 3.0)
cocaine (0.5.3)
climate_control (>= 0.0.3, < 1.0)
coderay (1.1.0)
coffee-rails (3.2.2)
coffee-script (>= 2.2.0)
@ -263,11 +266,10 @@ GEM
oauth2 (~> 0.8.0)
omniauth (~> 1.0)
orm_adapter (0.5.0)
paperclip (3.3.1)
paperclip (4.1.0)
activemodel (>= 3.0.0)
activerecord (>= 3.0.0)
activesupport (>= 3.0.0)
cocaine (~> 0.4.0)
cocaine (~> 0.5.3)
mime-types
pg (0.14.1)
polyglot (0.3.3)
@ -313,7 +315,7 @@ GEM
rdoc (3.12.2)
json (~> 1.4)
redcarpet (2.2.2)
redis (3.0.7)
redis (3.0.6)
redis-actionpack (3.2.4)
actionpack (~> 3.2.0)
redis-rack (~> 1.4.4)
@ -341,10 +343,10 @@ GEM
redis-namespace (~> 1.2)
sinatra (>= 0.9.2)
vegas (~> 0.1.2)
resque-scheduler (2.5.1)
redis (>= 3.0.0)
resque (~> 1.25)
rufus-scheduler (~> 2.0)
resque-scheduler (2.5.3)
redis (~> 3.0.4)
resque (~> 1.25.1)
rufus-scheduler (~> 2.0.24)
resque-status (0.3.3)
redisk (>= 0.2.1)
resque (~> 1.19)
@ -504,7 +506,7 @@ DEPENDENCIES
omniauth-facebook
omniauth-github
omniauth-google-oauth2
paperclip (~> 3.3.1)
paperclip (~> 4.1.0)
perform_later!
pg (~> 0.14.0)
puma

View File

@ -10,7 +10,9 @@ class Avatar < ActiveRecord::Base
end
end
has_attached_file :avatar, styles: AVATAR_SIZES_HASH
validates_inclusion_of :avatar_file_size, in: (0..MAX_AVATAR_SIZE), allow_nil: true
validates_attachment_size :avatar, less_than_or_equal_to: MAX_AVATAR_SIZE
validates_attachment_content_type :avatar, content_type: /\Aimage/
validates_attachment_file_name :avatar, matches: [ /(png|jpe?g|gif|bmp|tif?f)\z/i ]
attr_accessible :avatar

View File

@ -14,7 +14,8 @@ Mime::Type.register "text/plain", 'patch'
["application/x-c++src", ['cpp', 'cc'], '8bit'],
["application/x-csharp", ['cs'], '8bit'],
["text/x-diff", ['diff'], '8bit'],
["text/x-markdown", ['md'], '8bit']
["text/x-markdown", ['md'], '8bit'],
["application/x-rpm", ['rpm'], '8bit']
].each do |type|
MIME::Types.add MIME::Type.from_array(type)
end

View File

@ -7,11 +7,10 @@ module Modules
extend ActiveSupport::Concern
included do
validates_attachment_size :srpm, less_than: 500.megabytes
validates_attachment_content_type :srpm, content_type: ['application/octet-stream', "application/x-rpm", "application/x-redhat-package-manager"], message: I18n.t('layout.invalid_content_type')
has_attached_file :srpm
# attr_accessible :srpm
validates_attachment_size :srpm, less_than_or_equal_to: 500.megabytes
validates_attachment_content_type :srpm, content_type: ['application/octet-stream', "application/x-rpm", "application/x-redhat-package-manager"], message: I18n.t('layout.invalid_content_type')
after_create :create_git_repo
after_commit(on: :create) {|p| p.fork_git_repo unless p.is_root?} # later with resque