validates_attachment_size :file, less_than: 8.megabytes
validates :account, presence: true
- validates :description, length: { maximum: 140 }, if: :local?
+ validates :description, length: { maximum: 420 }, if: :local?
scope :attached, -> { where.not(status_id: nil) }
scope :unattached, -> { where(status_id: nil) }
end
def prepare_description
- self.description = description.strip[0...140] unless description.nil?
+ self.description = description.strip[0...420] unless description.nil?
end
def set_type_and_extension
describe 'descriptions for remote attachments' do
it 'are cut off at 140 characters' do
- media = Fabricate(:media_attachment, description: 'foo' * 100, remote_url: 'http://example.com/blah.jpg')
+ media = Fabricate(:media_attachment, description: 'foo' * 1000, remote_url: 'http://example.com/blah.jpg')
- expect(media.description.size).to be <= 140
+ expect(media.description.size).to be <= 420
end
end
end