Commit 40010c4d by Jon Yurek

Convert applicable hashes to 1.9 syntax

parent 1f3a7467
...@@ -3,10 +3,10 @@ require 'spec_helper' ...@@ -3,10 +3,10 @@ require 'spec_helper'
describe "Attachment Definitions" do describe "Attachment Definitions" do
it 'returns all of the attachments on the class' do it 'returns all of the attachments on the class' do
reset_class "Dummy" reset_class "Dummy"
Dummy.has_attached_file :avatar, {:path => "abc"} Dummy.has_attached_file :avatar, {path: "abc"}
Dummy.has_attached_file :other_attachment, {:url => "123"} Dummy.has_attached_file :other_attachment, {url: "123"}
Dummy.do_not_validate_attachment_file_type :avatar Dummy.do_not_validate_attachment_file_type :avatar
expected = {:avatar => {:path => "abc"}, :other_attachment => {:url => "123"}} expected = {avatar: {path: "abc"}, other_attachment: {url: "123"}}
assert_equal expected, Dummy.attachment_definitions assert_equal expected, Dummy.attachment_definitions
end end
......
...@@ -9,7 +9,7 @@ describe 'Attachment Processing' do ...@@ -9,7 +9,7 @@ describe 'Attachment Processing' do
it 'process attachments given a valid assignment' do it 'process attachments given a valid assignment' do
file = File.new(fixture_file("5k.png")) file = File.new(fixture_file("5k.png"))
Dummy.validates_attachment_content_type :avatar, :content_type => "image/png" Dummy.validates_attachment_content_type :avatar, content_type: "image/png"
instance = Dummy.new instance = Dummy.new
attachment = instance.avatar attachment = instance.avatar
attachment.expects(:post_process_styles) attachment.expects(:post_process_styles)
...@@ -19,7 +19,7 @@ describe 'Attachment Processing' do ...@@ -19,7 +19,7 @@ describe 'Attachment Processing' do
it 'not process attachments given an invalid assignment with :not' do it 'not process attachments given an invalid assignment with :not' do
file = File.new(fixture_file("5k.png")) file = File.new(fixture_file("5k.png"))
Dummy.validates_attachment_content_type :avatar, :not => "image/png" Dummy.validates_attachment_content_type :avatar, not: "image/png"
instance = Dummy.new instance = Dummy.new
attachment = instance.avatar attachment = instance.avatar
attachment.expects(:post_process_styles).never attachment.expects(:post_process_styles).never
...@@ -29,7 +29,7 @@ describe 'Attachment Processing' do ...@@ -29,7 +29,7 @@ describe 'Attachment Processing' do
it 'not process attachments given an invalid assignment with :content_type' do it 'not process attachments given an invalid assignment with :content_type' do
file = File.new(fixture_file("5k.png")) file = File.new(fixture_file("5k.png"))
Dummy.validates_attachment_content_type :avatar, :content_type => "image/tiff" Dummy.validates_attachment_content_type :avatar, content_type: "image/tiff"
instance = Dummy.new instance = Dummy.new
attachment = instance.avatar attachment = instance.avatar
attachment.expects(:post_process_styles).never attachment.expects(:post_process_styles).never
...@@ -39,7 +39,7 @@ describe 'Attachment Processing' do ...@@ -39,7 +39,7 @@ describe 'Attachment Processing' do
it 'when validation :if clause returns false, allow what would be an invalid assignment' do it 'when validation :if clause returns false, allow what would be an invalid assignment' do
invalid_assignment = File.new(fixture_file("5k.png")) invalid_assignment = File.new(fixture_file("5k.png"))
Dummy.validates_attachment_content_type :avatar, :content_type => "image/tiff", :if => lambda{false} Dummy.validates_attachment_content_type :avatar, content_type: "image/tiff", if: lambda{false}
instance = Dummy.new instance = Dummy.new
attachment = instance.avatar attachment = instance.avatar
attachment.expects(:post_process_styles) attachment.expects(:post_process_styles)
...@@ -51,7 +51,7 @@ describe 'Attachment Processing' do ...@@ -51,7 +51,7 @@ describe 'Attachment Processing' do
context 'using validates_attachment' do context 'using validates_attachment' do
it 'process attachments given a valid assignment' do it 'process attachments given a valid assignment' do
file = File.new(fixture_file("5k.png")) file = File.new(fixture_file("5k.png"))
Dummy.validates_attachment :avatar, :content_type => {:content_type => "image/png"} Dummy.validates_attachment :avatar, content_type: {content_type: "image/png"}
instance = Dummy.new instance = Dummy.new
attachment = instance.avatar attachment = instance.avatar
attachment.expects(:post_process_styles) attachment.expects(:post_process_styles)
...@@ -61,7 +61,7 @@ describe 'Attachment Processing' do ...@@ -61,7 +61,7 @@ describe 'Attachment Processing' do
it 'not process attachments given an invalid assignment with :not' do it 'not process attachments given an invalid assignment with :not' do
file = File.new(fixture_file("5k.png")) file = File.new(fixture_file("5k.png"))
Dummy.validates_attachment :avatar, :content_type => {:not => "image/png"} Dummy.validates_attachment :avatar, content_type: {not: "image/png"}
instance = Dummy.new instance = Dummy.new
attachment = instance.avatar attachment = instance.avatar
attachment.expects(:post_process_styles).never attachment.expects(:post_process_styles).never
...@@ -71,7 +71,7 @@ describe 'Attachment Processing' do ...@@ -71,7 +71,7 @@ describe 'Attachment Processing' do
it 'not process attachments given an invalid assignment with :content_type' do it 'not process attachments given an invalid assignment with :content_type' do
file = File.new(fixture_file("5k.png")) file = File.new(fixture_file("5k.png"))
Dummy.validates_attachment :avatar, :content_type => {:content_type => "image/tiff"} Dummy.validates_attachment :avatar, content_type: {content_type: "image/tiff"}
instance = Dummy.new instance = Dummy.new
attachment = instance.avatar attachment = instance.avatar
attachment.expects(:post_process_styles).never attachment.expects(:post_process_styles).never
......
...@@ -2,7 +2,7 @@ require 'spec_helper' ...@@ -2,7 +2,7 @@ require 'spec_helper'
describe Paperclip::GeometryDetector do describe Paperclip::GeometryDetector do
it 'identify an image and extract its dimensions' do it 'identify an image and extract its dimensions' do
Paperclip::GeometryParser.stubs(:new).with("434x66,").returns(stub(:make => :correct)) Paperclip::GeometryParser.stubs(:new).with("434x66,").returns(stub(make: :correct))
file = fixture_file("5k.png") file = fixture_file("5k.png")
factory = Paperclip::GeometryDetector.new(file) factory = Paperclip::GeometryDetector.new(file)
...@@ -12,7 +12,7 @@ describe Paperclip::GeometryDetector do ...@@ -12,7 +12,7 @@ describe Paperclip::GeometryDetector do
end end
it 'identify an image and extract its dimensions and orientation' do it 'identify an image and extract its dimensions and orientation' do
Paperclip::GeometryParser.stubs(:new).with("300x200,6").returns(stub(:make => :correct)) Paperclip::GeometryParser.stubs(:new).with("300x200,6").returns(stub(make: :correct))
file = fixture_file("rotated.jpg") file = fixture_file("rotated.jpg")
factory = Paperclip::GeometryDetector.new(file) factory = Paperclip::GeometryDetector.new(file)
......
...@@ -3,10 +3,10 @@ require 'spec_helper' ...@@ -3,10 +3,10 @@ require 'spec_helper'
describe Paperclip::GeometryParser do describe Paperclip::GeometryParser do
it 'identify an image and extract its dimensions with no orientation' do it 'identify an image and extract its dimensions with no orientation' do
Paperclip::Geometry.stubs(:new).with( Paperclip::Geometry.stubs(:new).with(
:height => '73', height: '73',
:width => '434', width: '434',
:modifier => nil, modifier: nil,
:orientation => nil orientation: nil
).returns(:correct) ).returns(:correct)
factory = Paperclip::GeometryParser.new("434x73") factory = Paperclip::GeometryParser.new("434x73")
...@@ -17,10 +17,10 @@ describe Paperclip::GeometryParser do ...@@ -17,10 +17,10 @@ describe Paperclip::GeometryParser do
it 'identify an image and extract its dimensions with an empty orientation' do it 'identify an image and extract its dimensions with an empty orientation' do
Paperclip::Geometry.stubs(:new).with( Paperclip::Geometry.stubs(:new).with(
:height => '73', height: '73',
:width => '434', width: '434',
:modifier => nil, modifier: nil,
:orientation => '' orientation: ''
).returns(:correct) ).returns(:correct)
factory = Paperclip::GeometryParser.new("434x73,") factory = Paperclip::GeometryParser.new("434x73,")
...@@ -31,10 +31,10 @@ describe Paperclip::GeometryParser do ...@@ -31,10 +31,10 @@ describe Paperclip::GeometryParser do
it 'identify an image and extract its dimensions and orientation' do it 'identify an image and extract its dimensions and orientation' do
Paperclip::Geometry.stubs(:new).with( Paperclip::Geometry.stubs(:new).with(
:height => '200', height: '200',
:width => '300', width: '300',
:modifier => nil, modifier: nil,
:orientation => '6' orientation: '6'
).returns(:correct) ).returns(:correct)
factory = Paperclip::GeometryParser.new("300x200,6") factory = Paperclip::GeometryParser.new("300x200,6")
...@@ -45,10 +45,10 @@ describe Paperclip::GeometryParser do ...@@ -45,10 +45,10 @@ describe Paperclip::GeometryParser do
it 'identify an image and extract its dimensions and modifier' do it 'identify an image and extract its dimensions and modifier' do
Paperclip::Geometry.stubs(:new).with( Paperclip::Geometry.stubs(:new).with(
:height => '64', height: '64',
:width => '64', width: '64',
:modifier => '#', modifier: '#',
:orientation => nil orientation: nil
).returns(:correct) ).returns(:correct)
factory = Paperclip::GeometryParser.new("64x64#") factory = Paperclip::GeometryParser.new("64x64#")
...@@ -59,10 +59,10 @@ describe Paperclip::GeometryParser do ...@@ -59,10 +59,10 @@ describe Paperclip::GeometryParser do
it 'identify an image and extract its dimensions, orientation, and modifier' do it 'identify an image and extract its dimensions, orientation, and modifier' do
Paperclip::Geometry.stubs(:new).with( Paperclip::Geometry.stubs(:new).with(
:height => '50', height: '50',
:width => '100', width: '100',
:modifier => '>', modifier: '>',
:orientation => '7' orientation: '7'
).returns(:correct) ).returns(:correct)
factory = Paperclip::GeometryParser.new("100x50,7>") factory = Paperclip::GeometryParser.new("100x50,7>")
......
...@@ -50,7 +50,7 @@ describe Paperclip::Geometry do ...@@ -50,7 +50,7 @@ describe Paperclip::Geometry do
end end
it "recognize an EXIF orientation and not rotate with auto_orient if not necessary" do it "recognize an EXIF orientation and not rotate with auto_orient if not necessary" do
geo = Paperclip::Geometry.new(:width => 1024, :height => 768, :orientation => 1) geo = Paperclip::Geometry.new(width: 1024, height: 768, orientation: 1)
assert geo assert geo
assert_equal 1024, geo.width assert_equal 1024, geo.width
assert_equal 768, geo.height assert_equal 768, geo.height
...@@ -62,7 +62,7 @@ describe Paperclip::Geometry do ...@@ -62,7 +62,7 @@ describe Paperclip::Geometry do
end end
it "recognize an EXIF orientation and rotate with auto_orient if necessary" do it "recognize an EXIF orientation and rotate with auto_orient if necessary" do
geo = Paperclip::Geometry.new(:width => 1024, :height => 768, :orientation => 6) geo = Paperclip::Geometry.new(width: 1024, height: 768, orientation: 6)
assert geo assert geo
assert_equal 1024, geo.width assert_equal 1024, geo.width
assert_equal 768, geo.height assert_equal 768, geo.height
...@@ -161,7 +161,7 @@ describe Paperclip::Geometry do ...@@ -161,7 +161,7 @@ describe Paperclip::Geometry do
end end
it "not generate from a file with no path" do it "not generate from a file with no path" do
file = mock("file", :path => "") file = mock("file", path: "")
file.stubs(:respond_to?).with(:path).returns(true) file.stubs(:respond_to?).with(:path).returns(true)
expect { @geo = Paperclip::Geometry.from_file(file) }.to raise_error(Paperclip::Errors::NotIdentifiedByImageMagickError) expect { @geo = Paperclip::Geometry.from_file(file) }.to raise_error(Paperclip::Errors::NotIdentifiedByImageMagickError)
end end
......
...@@ -46,7 +46,7 @@ describe Paperclip::Interpolations do ...@@ -46,7 +46,7 @@ describe Paperclip::Interpolations do
it "return the extension of the file as the format if defined in the style" do it "return the extension of the file as the format if defined in the style" do
attachment = mock attachment = mock
attachment.expects(:original_filename).never attachment.expects(:original_filename).never
attachment.expects(:styles).twice.returns({:style => {:format => "png"}}) attachment.expects(:styles).twice.returns({style: {format: "png"}})
[:style, 'style'].each do |style| [:style, 'style'].each do |style|
assert_equal "png", Paperclip::Interpolations.extension(attachment, style) assert_equal "png", Paperclip::Interpolations.extension(attachment, style)
...@@ -83,7 +83,7 @@ describe Paperclip::Interpolations do ...@@ -83,7 +83,7 @@ describe Paperclip::Interpolations do
it "return the format if defined in the style, ignoring the content type" do it "return the format if defined in the style, ignoring the content type" do
attachment = mock attachment = mock
attachment.expects(:content_type).returns('image/jpeg') attachment.expects(:content_type).returns('image/jpeg')
attachment.expects(:styles).returns({:style => {:format => "png"}}) attachment.expects(:styles).returns({style: {format: "png"}})
interpolations = Paperclip::Interpolations interpolations = Paperclip::Interpolations
interpolations.expects(:extension).returns('random') interpolations.expects(:extension).returns('random')
assert_equal "png", interpolations.content_type_extension(attachment, :style) assert_equal "png", interpolations.content_type_extension(attachment, :style)
...@@ -91,7 +91,7 @@ describe Paperclip::Interpolations do ...@@ -91,7 +91,7 @@ describe Paperclip::Interpolations do
it "be able to handle numeric style names" do it "be able to handle numeric style names" do
attachment = mock( attachment = mock(
:styles => {:"4" => {:format => :expected_extension}} styles: {:"4" => {format: :expected_extension}}
) )
assert_equal :expected_extension, Paperclip::Interpolations.extension(attachment, 4) assert_equal :expected_extension, Paperclip::Interpolations.extension(attachment, 4)
end end
...@@ -156,7 +156,7 @@ describe Paperclip::Interpolations do ...@@ -156,7 +156,7 @@ describe Paperclip::Interpolations do
it "reinterpolate :url" do it "reinterpolate :url" do
attachment = mock attachment = mock
attachment.expects(:url).with(:style, :timestamp => false, :escape => false).returns("1234") attachment.expects(:url).with(:style, timestamp: false, escape: false).returns("1234")
assert_equal "1234", Paperclip::Interpolations.url(attachment, :style) assert_equal "1234", Paperclip::Interpolations.url(attachment, :style)
end end
...@@ -179,7 +179,7 @@ describe Paperclip::Interpolations do ...@@ -179,7 +179,7 @@ describe Paperclip::Interpolations do
it "return the filename as basename.extension when format supplied" do it "return the filename as basename.extension when format supplied" do
attachment = mock attachment = mock
attachment.expects(:styles).returns({:style => {:format => :png}}) attachment.expects(:styles).returns({style: {format: :png}})
attachment.expects(:original_filename).returns("one.jpg").times(2) attachment.expects(:original_filename).returns("one.jpg").times(2)
assert_equal "one.png", Paperclip::Interpolations.filename(attachment, :style) assert_equal "one.png", Paperclip::Interpolations.filename(attachment, :style)
end end
......
...@@ -2,7 +2,7 @@ require 'spec_helper' ...@@ -2,7 +2,7 @@ require 'spec_helper'
describe Paperclip::AttachmentAdapter do describe Paperclip::AttachmentAdapter do
before do before do
rebuild_model :path => "tmp/:class/:attachment/:style/:filename", :styles => {:thumb => '50x50'} rebuild_model path: "tmp/:class/:attachment/:style/:filename", styles: {thumb: '50x50'}
@attachment = Dummy.new.avatar @attachment = Dummy.new.avatar
end end
......
...@@ -11,11 +11,11 @@ describe Paperclip::UploadedFileAdapter do ...@@ -11,11 +11,11 @@ describe Paperclip::UploadedFileAdapter do
tempfile.binmode tempfile.binmode
@file = UploadedFile.new( @file = UploadedFile.new(
:original_filename => "5k.png", original_filename: "5k.png",
:content_type => "image/x-png-by-browser\r", content_type: "image/x-png-by-browser\r",
:head => "", head: "",
:tempfile => tempfile, tempfile: tempfile,
:path => tempfile.path path: tempfile.path
) )
@subject = Paperclip.io_adapters.for(@file) @subject = Paperclip.io_adapters.for(@file)
end end
...@@ -58,10 +58,10 @@ describe Paperclip::UploadedFileAdapter do ...@@ -58,10 +58,10 @@ describe Paperclip::UploadedFileAdapter do
class UploadedFile < OpenStruct; end class UploadedFile < OpenStruct; end
@file = UploadedFile.new( @file = UploadedFile.new(
:original_filename => "image:restricted.gif", original_filename: "image:restricted.gif",
:content_type => "image/x-png-by-browser", content_type: "image/x-png-by-browser",
:head => "", head: "",
:path => fixture_file("5k.png") path: fixture_file("5k.png")
) )
@subject = Paperclip.io_adapters.for(@file) @subject = Paperclip.io_adapters.for(@file)
end end
...@@ -81,10 +81,10 @@ describe Paperclip::UploadedFileAdapter do ...@@ -81,10 +81,10 @@ describe Paperclip::UploadedFileAdapter do
class UploadedFile < OpenStruct; end class UploadedFile < OpenStruct; end
@file = UploadedFile.new( @file = UploadedFile.new(
:original_filename => "5k.png", original_filename: "5k.png",
:content_type => "image/x-png-by-browser", content_type: "image/x-png-by-browser",
:head => "", head: "",
:path => fixture_file("5k.png") path: fixture_file("5k.png")
) )
@subject = Paperclip.io_adapters.for(@file) @subject = Paperclip.io_adapters.for(@file)
end end
...@@ -129,10 +129,10 @@ describe Paperclip::UploadedFileAdapter do ...@@ -129,10 +129,10 @@ describe Paperclip::UploadedFileAdapter do
class UploadedFile < OpenStruct; end class UploadedFile < OpenStruct; end
@file = UploadedFile.new( @file = UploadedFile.new(
:original_filename => "5k.png", original_filename: "5k.png",
:content_type => "image/x-png-by-browser", content_type: "image/x-png-by-browser",
:head => "", head: "",
:path => fixture_file("5k.png") path: fixture_file("5k.png")
) )
@subject = Paperclip.io_adapters.for(@file) @subject = Paperclip.io_adapters.for(@file)
end end
......
...@@ -25,7 +25,7 @@ describe Paperclip::Shoulda::Matchers::ValidateAttachmentContentTypeMatcher do ...@@ -25,7 +25,7 @@ describe Paperclip::Shoulda::Matchers::ValidateAttachmentContentTypeMatcher do
context "given a class with a validation that doesn't match" do context "given a class with a validation that doesn't match" do
before do before do
Dummy.validates_attachment_content_type :avatar, :content_type => %r{audio/.*} Dummy.validates_attachment_content_type :avatar, content_type: %r{audio/.*}
end end
should_reject_dummy_class should_reject_dummy_class
...@@ -33,7 +33,7 @@ describe Paperclip::Shoulda::Matchers::ValidateAttachmentContentTypeMatcher do ...@@ -33,7 +33,7 @@ describe Paperclip::Shoulda::Matchers::ValidateAttachmentContentTypeMatcher do
context "given a class with a matching validation" do context "given a class with a matching validation" do
before do before do
Dummy.validates_attachment_content_type :avatar, :content_type => %r{image/.*} Dummy.validates_attachment_content_type :avatar, content_type: %r{image/.*}
end end
should_accept_dummy_class should_accept_dummy_class
...@@ -42,7 +42,7 @@ describe Paperclip::Shoulda::Matchers::ValidateAttachmentContentTypeMatcher do ...@@ -42,7 +42,7 @@ describe Paperclip::Shoulda::Matchers::ValidateAttachmentContentTypeMatcher do
context "given a class with other validations but matching types" do context "given a class with other validations but matching types" do
before do before do
Dummy.validates_presence_of :title Dummy.validates_presence_of :title
Dummy.validates_attachment_content_type :avatar, :content_type => %r{image/.*} Dummy.validates_attachment_content_type :avatar, content_type: %r{image/.*}
end end
should_accept_dummy_class should_accept_dummy_class
...@@ -50,7 +50,7 @@ describe Paperclip::Shoulda::Matchers::ValidateAttachmentContentTypeMatcher do ...@@ -50,7 +50,7 @@ describe Paperclip::Shoulda::Matchers::ValidateAttachmentContentTypeMatcher do
context "given a class that matches and a matcher that only specifies 'allowing'" do context "given a class that matches and a matcher that only specifies 'allowing'" do
before do before do
Dummy.validates_attachment_content_type :avatar, :content_type => %r{image/.*} Dummy.validates_attachment_content_type :avatar, content_type: %r{image/.*}
@matcher = self.class.validate_attachment_content_type(:avatar). @matcher = self.class.validate_attachment_content_type(:avatar).
allowing(%w(image/png image/jpeg)) allowing(%w(image/png image/jpeg))
end end
...@@ -60,7 +60,7 @@ describe Paperclip::Shoulda::Matchers::ValidateAttachmentContentTypeMatcher do ...@@ -60,7 +60,7 @@ describe Paperclip::Shoulda::Matchers::ValidateAttachmentContentTypeMatcher do
context "given a class that does not match and a matcher that only specifies 'allowing'" do context "given a class that does not match and a matcher that only specifies 'allowing'" do
before do before do
Dummy.validates_attachment_content_type :avatar, :content_type => %r{audio/.*} Dummy.validates_attachment_content_type :avatar, content_type: %r{audio/.*}
@matcher = self.class.validate_attachment_content_type(:avatar). @matcher = self.class.validate_attachment_content_type(:avatar).
allowing(%w(image/png image/jpeg)) allowing(%w(image/png image/jpeg))
end end
...@@ -70,7 +70,7 @@ describe Paperclip::Shoulda::Matchers::ValidateAttachmentContentTypeMatcher do ...@@ -70,7 +70,7 @@ describe Paperclip::Shoulda::Matchers::ValidateAttachmentContentTypeMatcher do
context "given a class that matches and a matcher that only specifies 'rejecting'" do context "given a class that matches and a matcher that only specifies 'rejecting'" do
before do before do
Dummy.validates_attachment_content_type :avatar, :content_type => %r{image/.*} Dummy.validates_attachment_content_type :avatar, content_type: %r{image/.*}
@matcher = self.class.validate_attachment_content_type(:avatar). @matcher = self.class.validate_attachment_content_type(:avatar).
rejecting(%w(audio/mp3 application/octet-stream)) rejecting(%w(audio/mp3 application/octet-stream))
end end
...@@ -80,7 +80,7 @@ describe Paperclip::Shoulda::Matchers::ValidateAttachmentContentTypeMatcher do ...@@ -80,7 +80,7 @@ describe Paperclip::Shoulda::Matchers::ValidateAttachmentContentTypeMatcher do
context "given a class that does not match and a matcher that only specifies 'rejecting'" do context "given a class that does not match and a matcher that only specifies 'rejecting'" do
before do before do
Dummy.validates_attachment_content_type :avatar, :content_type => %r{audio/.*} Dummy.validates_attachment_content_type :avatar, content_type: %r{audio/.*}
@matcher = self.class.validate_attachment_content_type(:avatar). @matcher = self.class.validate_attachment_content_type(:avatar).
rejecting(%w(audio/mp3 application/octet-stream)) rejecting(%w(audio/mp3 application/octet-stream))
end end
...@@ -91,7 +91,7 @@ describe Paperclip::Shoulda::Matchers::ValidateAttachmentContentTypeMatcher do ...@@ -91,7 +91,7 @@ describe Paperclip::Shoulda::Matchers::ValidateAttachmentContentTypeMatcher do
context "using an :if to control the validation" do context "using an :if to control the validation" do
before do before do
Dummy.class_eval do Dummy.class_eval do
validates_attachment_content_type :avatar, :content_type => %r{image/*} , :if => :go validates_attachment_content_type :avatar, content_type: %r{image/*} , if: :go
attr_accessor :go attr_accessor :go
end end
@matcher = self.class.validate_attachment_content_type(:avatar). @matcher = self.class.validate_attachment_content_type(:avatar).
......
...@@ -36,7 +36,7 @@ describe Paperclip::Shoulda::Matchers::ValidateAttachmentPresenceMatcher do ...@@ -36,7 +36,7 @@ describe Paperclip::Shoulda::Matchers::ValidateAttachmentPresenceMatcher do
Dummy.class_eval do Dummy.class_eval do
validates_attachment_presence :avatar validates_attachment_presence :avatar
validates_attachment_content_type :avatar, :content_type => 'image/gif' validates_attachment_content_type :avatar, content_type: 'image/gif'
end end
@dummy = Dummy.new @dummy = Dummy.new
...@@ -52,7 +52,7 @@ describe Paperclip::Shoulda::Matchers::ValidateAttachmentPresenceMatcher do ...@@ -52,7 +52,7 @@ describe Paperclip::Shoulda::Matchers::ValidateAttachmentPresenceMatcher do
context "using an :if to control the validation" do context "using an :if to control the validation" do
before do before do
Dummy.class_eval do Dummy.class_eval do
validates_attachment_presence :avatar, :if => :go validates_attachment_presence :avatar, if: :go
attr_accessor :go attr_accessor :go
end end
@dummy = Dummy.new @dummy = Dummy.new
......
...@@ -25,17 +25,17 @@ describe Paperclip::Shoulda::Matchers::ValidateAttachmentSizeMatcher do ...@@ -25,17 +25,17 @@ describe Paperclip::Shoulda::Matchers::ValidateAttachmentSizeMatcher do
end end
context "given a class with a validation that's too high" do context "given a class with a validation that's too high" do
before { Dummy.validates_attachment_size :avatar, :in => 256..2048 } before { Dummy.validates_attachment_size :avatar, in: 256..2048 }
should_reject_dummy_class should_reject_dummy_class
end end
context "given a class with a validation that's too low" do context "given a class with a validation that's too low" do
before { Dummy.validates_attachment_size :avatar, :in => 0..1024 } before { Dummy.validates_attachment_size :avatar, in: 0..1024 }
should_reject_dummy_class should_reject_dummy_class
end end
context "given a class with a validation that matches" do context "given a class with a validation that matches" do
before { Dummy.validates_attachment_size :avatar, :in => 256..1024 } before { Dummy.validates_attachment_size :avatar, in: 256..1024 }
should_accept_dummy_class should_accept_dummy_class
end end
end end
...@@ -46,12 +46,12 @@ describe Paperclip::Shoulda::Matchers::ValidateAttachmentSizeMatcher do ...@@ -46,12 +46,12 @@ describe Paperclip::Shoulda::Matchers::ValidateAttachmentSizeMatcher do
end end
context "given a class with an upper limit" do context "given a class with an upper limit" do
before { Dummy.validates_attachment_size :avatar, :less_than => 1 } before { Dummy.validates_attachment_size :avatar, less_than: 1 }
should_accept_dummy_class should_accept_dummy_class
end end
context "given a class with a lower limit" do context "given a class with a lower limit" do
before { Dummy.validates_attachment_size :avatar, :greater_than => 1 } before { Dummy.validates_attachment_size :avatar, greater_than: 1 }
should_accept_dummy_class should_accept_dummy_class
end end
end end
...@@ -59,7 +59,7 @@ describe Paperclip::Shoulda::Matchers::ValidateAttachmentSizeMatcher do ...@@ -59,7 +59,7 @@ describe Paperclip::Shoulda::Matchers::ValidateAttachmentSizeMatcher do
context "using an :if to control the validation" do context "using an :if to control the validation" do
before do before do
Dummy.class_eval do Dummy.class_eval do
validates_attachment_size :avatar, :greater_than => 1024, :if => :go validates_attachment_size :avatar, greater_than: 1024, if: :go
attr_accessor :go attr_accessor :go
end end
@dummy = Dummy.new @dummy = Dummy.new
...@@ -79,7 +79,7 @@ describe Paperclip::Shoulda::Matchers::ValidateAttachmentSizeMatcher do ...@@ -79,7 +79,7 @@ describe Paperclip::Shoulda::Matchers::ValidateAttachmentSizeMatcher do
context "post processing" do context "post processing" do
before do before do
Dummy.validates_attachment_size :avatar, :greater_than => 1024 Dummy.validates_attachment_size :avatar, greater_than: 1024
@dummy = Dummy.new @dummy = Dummy.new
@matcher = self.class.validate_attachment_size(:avatar).greater_than(1024) @matcher = self.class.validate_attachment_size(:avatar).greater_than(1024)
......
...@@ -19,41 +19,41 @@ describe 'Missing Attachment Styles' do ...@@ -19,41 +19,41 @@ describe 'Missing Attachment Styles' do
it "be able to get current attachment styles" do it "be able to get current attachment styles" do
assert_equal Hash.new, Paperclip.send(:current_attachments_styles) assert_equal Hash.new, Paperclip.send(:current_attachments_styles)
rebuild_model :styles => {:croppable => '600x600>', :big => '1000x1000>'} rebuild_model styles: {croppable: '600x600>', big: '1000x1000>'}
expected_hash = { :Dummy => {:avatar => [:big, :croppable]}} expected_hash = { Dummy: {avatar: [:big, :croppable]}}
assert_equal expected_hash, Paperclip.send(:current_attachments_styles) assert_equal expected_hash, Paperclip.send(:current_attachments_styles)
end end
it "be able to save current attachment styles for further comparison" do it "be able to save current attachment styles for further comparison" do
rebuild_model :styles => {:croppable => '600x600>', :big => '1000x1000>'} rebuild_model styles: {croppable: '600x600>', big: '1000x1000>'}
Paperclip.save_current_attachments_styles! Paperclip.save_current_attachments_styles!
expected_hash = { :Dummy => {:avatar => [:big, :croppable]}} expected_hash = { Dummy: {avatar: [:big, :croppable]}}
assert_equal expected_hash, YAML.load_file(Paperclip.registered_attachments_styles_path) assert_equal expected_hash, YAML.load_file(Paperclip.registered_attachments_styles_path)
end end
it "be able to read registered attachment styles from file" do it "be able to read registered attachment styles from file" do
rebuild_model :styles => {:croppable => '600x600>', :big => '1000x1000>'} rebuild_model styles: {croppable: '600x600>', big: '1000x1000>'}
Paperclip.save_current_attachments_styles! Paperclip.save_current_attachments_styles!
expected_hash = { :Dummy => {:avatar => [:big, :croppable]}} expected_hash = { Dummy: {avatar: [:big, :croppable]}}
assert_equal expected_hash, Paperclip.send(:get_registered_attachments_styles) assert_equal expected_hash, Paperclip.send(:get_registered_attachments_styles)
end end
it "be able to calculate differences between registered styles and current styles" do it "be able to calculate differences between registered styles and current styles" do
rebuild_model :styles => {:croppable => '600x600>', :big => '1000x1000>'} rebuild_model styles: {croppable: '600x600>', big: '1000x1000>'}
Paperclip.save_current_attachments_styles! Paperclip.save_current_attachments_styles!
rebuild_model :styles => {:thumb => 'x100', :export => 'x400>', :croppable => '600x600>', :big => '1000x1000>'} rebuild_model styles: {thumb: 'x100', export: 'x400>', croppable: '600x600>', big: '1000x1000>'}
expected_hash = { :Dummy => {:avatar => [:export, :thumb]} } expected_hash = { Dummy: {avatar: [:export, :thumb]} }
assert_equal expected_hash, Paperclip.missing_attachments_styles assert_equal expected_hash, Paperclip.missing_attachments_styles
ActiveRecord::Base.connection.create_table :books, :force => true ActiveRecord::Base.connection.create_table :books, force: true
class ::Book < ActiveRecord::Base class ::Book < ActiveRecord::Base
has_attached_file :cover, :styles => {:small => 'x100', :large => '1000x1000>'} has_attached_file :cover, styles: {small: 'x100', large: '1000x1000>'}
has_attached_file :sample, :styles => {:thumb => 'x100'} has_attached_file :sample, styles: {thumb: 'x100'}
end end
expected_hash = { expected_hash = {
:Dummy => {:avatar => [:export, :thumb]}, Dummy: {avatar: [:export, :thumb]},
:Book => {:sample => [:thumb], :cover => [:large, :small]} Book: {sample: [:thumb], cover: [:large, :small]}
} }
assert_equal expected_hash, Paperclip.missing_attachments_styles assert_equal expected_hash, Paperclip.missing_attachments_styles
Paperclip.save_current_attachments_styles! Paperclip.save_current_attachments_styles!
...@@ -61,15 +61,15 @@ describe 'Missing Attachment Styles' do ...@@ -61,15 +61,15 @@ describe 'Missing Attachment Styles' do
end end
it "be able to calculate differences when a new attachment is added to a model" do it "be able to calculate differences when a new attachment is added to a model" do
rebuild_model :styles => {:croppable => '600x600>', :big => '1000x1000>'} rebuild_model styles: {croppable: '600x600>', big: '1000x1000>'}
Paperclip.save_current_attachments_styles! Paperclip.save_current_attachments_styles!
class ::Dummy class ::Dummy
has_attached_file :photo, :styles => {:small => 'x100', :large => '1000x1000>'} has_attached_file :photo, styles: {small: 'x100', large: '1000x1000>'}
end end
expected_hash = { expected_hash = {
:Dummy => {:photo => [:large, :small]} Dummy: {photo: [:large, :small]}
} }
assert_equal expected_hash, Paperclip.missing_attachments_styles assert_equal expected_hash, Paperclip.missing_attachments_styles
Paperclip.save_current_attachments_styles! Paperclip.save_current_attachments_styles!
...@@ -78,7 +78,7 @@ describe 'Missing Attachment Styles' do ...@@ -78,7 +78,7 @@ describe 'Missing Attachment Styles' do
# It's impossible to build styles hash without loading from database whole bunch of records # It's impossible to build styles hash without loading from database whole bunch of records
it "skip lambda-styles" do it "skip lambda-styles" do
rebuild_model :styles => lambda{ |attachment| attachment.instance.other == 'a' ? {:thumb => "50x50#"} : {:large => "400x400"} } rebuild_model styles: lambda{ |attachment| attachment.instance.other == 'a' ? {thumb: "50x50#"} : {large: "400x400"} }
assert_equal Hash.new, Paperclip.send(:current_attachments_styles) assert_equal Hash.new, Paperclip.send(:current_attachments_styles)
end end
end end
...@@ -61,7 +61,7 @@ describe Paperclip do ...@@ -61,7 +61,7 @@ describe Paperclip do
context "Calling Paperclip.run with a logger" do context "Calling Paperclip.run with a logger" do
it "pass the defined logger if :log_command is set" do it "pass the defined logger if :log_command is set" do
Paperclip.options[:log_command] = true Paperclip.options[:log_command] = true
Cocaine::CommandLine.expects(:new).with("convert", "stuff", :logger => Paperclip.logger).returns(stub(:run)) Cocaine::CommandLine.expects(:new).with("convert", "stuff", logger: Paperclip.logger).returns(stub(:run))
Paperclip.run("convert", "stuff") Paperclip.run("convert", "stuff")
end end
end end
...@@ -69,9 +69,9 @@ describe Paperclip do ...@@ -69,9 +69,9 @@ describe Paperclip do
context "Paperclip.each_instance_with_attachment" do context "Paperclip.each_instance_with_attachment" do
before do before do
@file = File.new(fixture_file("5k.png"), 'rb') @file = File.new(fixture_file("5k.png"), 'rb')
d1 = Dummy.create(:avatar => @file) d1 = Dummy.create(avatar: @file)
d2 = Dummy.create d2 = Dummy.create
d3 = Dummy.create(:avatar => @file) d3 = Dummy.create(avatar: @file)
@expected = [d1, d3] @expected = [d1, d3]
end end
...@@ -109,7 +109,7 @@ describe Paperclip do ...@@ -109,7 +109,7 @@ describe Paperclip do
context "An ActiveRecord model with an 'avatar' attachment" do context "An ActiveRecord model with an 'avatar' attachment" do
before do before do
rebuild_model :path => "tmp/:class/omg/:style.:extension" rebuild_model path: "tmp/:class/omg/:style.:extension"
@file = File.new(fixture_file("5k.png"), 'rb') @file = File.new(fixture_file("5k.png"), 'rb')
end end
...@@ -133,8 +133,8 @@ describe Paperclip do ...@@ -133,8 +133,8 @@ describe Paperclip do
end end
it "not assign the avatar on mass-set" do it "not assign the avatar on mass-set" do
@dummy.attributes = { :other => "I'm set!", @dummy.attributes = { other: "I'm set!",
:avatar => @file } avatar: @file }
assert_equal "I'm set!", @dummy.other assert_equal "I'm set!", @dummy.other
assert ! @dummy.avatar? assert ! @dummy.avatar?
...@@ -157,7 +157,7 @@ describe Paperclip do ...@@ -157,7 +157,7 @@ describe Paperclip do
it "be able to use the attachment from the subclass" do it "be able to use the attachment from the subclass" do
assert_nothing_raised do assert_nothing_raised do
@subdummy = SubDummy.create(:avatar => @file) @subdummy = SubDummy.create(avatar: @file)
end end
end end
......
...@@ -19,7 +19,7 @@ describe Paperclip::Schema do ...@@ -19,7 +19,7 @@ describe Paperclip::Schema do
ActiveSupport::Deprecation.silenced = false ActiveSupport::Deprecation.silenced = false
end end
it "create attachment columns" do it "create attachment columns" do
Dummy.connection.create_table :dummies, :force => true do |t| Dummy.connection.create_table :dummies, force: true do |t|
ActiveSupport::Deprecation.silence do ActiveSupport::Deprecation.silence do
t.has_attached_file :avatar t.has_attached_file :avatar
end end
...@@ -35,7 +35,7 @@ describe Paperclip::Schema do ...@@ -35,7 +35,7 @@ describe Paperclip::Schema do
end end
it "display deprecation warning" do it "display deprecation warning" do
Dummy.connection.create_table :dummies, :force => true do |t| Dummy.connection.create_table :dummies, force: true do |t|
assert_deprecated do assert_deprecated do
t.has_attached_file :avatar t.has_attached_file :avatar
end end
...@@ -45,7 +45,7 @@ describe Paperclip::Schema do ...@@ -45,7 +45,7 @@ describe Paperclip::Schema do
context "using #attachment" do context "using #attachment" do
before do before do
Dummy.connection.create_table :dummies, :force => true do |t| Dummy.connection.create_table :dummies, force: true do |t|
t.attachment :avatar t.attachment :avatar
end end
rebuild_class rebuild_class
...@@ -64,7 +64,7 @@ describe Paperclip::Schema do ...@@ -64,7 +64,7 @@ describe Paperclip::Schema do
context "within schema statement" do context "within schema statement" do
before do before do
Dummy.connection.create_table :dummies, :force => true Dummy.connection.create_table :dummies, force: true
end end
context "migrating up" do context "migrating up" do
......
...@@ -4,7 +4,7 @@ describe Paperclip::Storage::Filesystem do ...@@ -4,7 +4,7 @@ describe Paperclip::Storage::Filesystem do
context "Filesystem" do context "Filesystem" do
context "normal file" do context "normal file" do
before do before do
rebuild_model :styles => { :thumbnail => "25x25#" } rebuild_model styles: { thumbnail: "25x25#" }
@dummy = Dummy.create! @dummy = Dummy.create!
@file = File.open(fixture_file('5k.png')) @file = File.open(fixture_file('5k.png'))
...@@ -53,7 +53,7 @@ describe Paperclip::Storage::Filesystem do ...@@ -53,7 +53,7 @@ describe Paperclip::Storage::Filesystem do
context "with file that has space in file name" do context "with file that has space in file name" do
before do before do
rebuild_model :styles => { :thumbnail => "25x25#" } rebuild_model styles: { thumbnail: "25x25#" }
@dummy = Dummy.create! @dummy = Dummy.create!
@file = File.open(fixture_file('spaced file.png')) @file = File.open(fixture_file('spaced file.png'))
......
...@@ -4,13 +4,13 @@ unless ENV["S3_BUCKET"].blank? ...@@ -4,13 +4,13 @@ unless ENV["S3_BUCKET"].blank?
describe Paperclip::Storage::S3, 'Live S3' do describe Paperclip::Storage::S3, 'Live S3' do
context "when assigning an S3 attachment directly to another model" do context "when assigning an S3 attachment directly to another model" do
before do before do
rebuild_model :styles => { :thumb => "100x100", :square => "32x32#" }, rebuild_model styles: { thumb: "100x100", square: "32x32#" },
:storage => :s3, storage: :s3,
:bucket => ENV["S3_BUCKET"], bucket: ENV["S3_BUCKET"],
:path => ":class/:attachment/:id/:style.:extension", path: ":class/:attachment/:id/:style.:extension",
:s3_credentials => { s3_credentials: {
:aws_access_key_id => ENV['AWS_ACCESS_KEY_ID'], aws_access_key_id: ENV['AWS_ACCESS_KEY_ID'],
:aws_secre_access_key => ENV['AWS_SECRET_ACCESS_KEY'] aws_secre_access_key: ENV['AWS_SECRET_ACCESS_KEY']
} }
@file = File.new(fixture_file("5k.png")) @file = File.new(fixture_file("5k.png"))
...@@ -41,13 +41,13 @@ unless ENV["S3_BUCKET"].blank? ...@@ -41,13 +41,13 @@ unless ENV["S3_BUCKET"].blank?
context "Generating an expiring url on a nonexistant attachment" do context "Generating an expiring url on a nonexistant attachment" do
before do before do
rebuild_model :styles => { :thumb => "100x100", :square => "32x32#" }, rebuild_model styles: { thumb: "100x100", square: "32x32#" },
:storage => :s3, storage: :s3,
:bucket => ENV["S3_BUCKET"], bucket: ENV["S3_BUCKET"],
:path => ":class/:attachment/:id/:style.:extension", path: ":class/:attachment/:id/:style.:extension",
:s3_credentials => { s3_credentials: {
:aws_access_key_id => ENV['AWS_ACCESS_KEY_ID'], aws_access_key_id: ENV['AWS_ACCESS_KEY_ID'],
:aws_secre_access_key => ENV['AWS_SECRET_ACCESS_KEY'] aws_secre_access_key: ENV['AWS_SECRET_ACCESS_KEY']
} }
@dummy = Dummy.new @dummy = Dummy.new
...@@ -60,13 +60,13 @@ unless ENV["S3_BUCKET"].blank? ...@@ -60,13 +60,13 @@ unless ENV["S3_BUCKET"].blank?
context "Using S3 for real, an attachment with S3 storage" do context "Using S3 for real, an attachment with S3 storage" do
before do before do
rebuild_model :styles => { :thumb => "100x100", :square => "32x32#" }, rebuild_model styles: { thumb: "100x100", square: "32x32#" },
:storage => :s3, storage: :s3,
:bucket => ENV["S3_BUCKET"], bucket: ENV["S3_BUCKET"],
:path => ":class/:attachment/:id/:style.:extension", path: ":class/:attachment/:id/:style.:extension",
:s3_credentials => { s3_credentials: {
:aws_access_key_id => ENV['AWS_ACCESS_KEY_ID'], aws_access_key_id: ENV['AWS_ACCESS_KEY_ID'],
:aws_secre_access_key => ENV['AWS_SECRET_ACCESS_KEY'] aws_secre_access_key: ENV['AWS_SECRET_ACCESS_KEY']
} }
Dummy.delete_all Dummy.delete_all
...@@ -102,12 +102,12 @@ unless ENV["S3_BUCKET"].blank? ...@@ -102,12 +102,12 @@ unless ENV["S3_BUCKET"].blank?
context "An attachment that uses S3 for storage and has spaces in file name" do context "An attachment that uses S3 for storage and has spaces in file name" do
before do before do
rebuild_model :styles => { :thumb => "100x100", :square => "32x32#" }, rebuild_model styles: { thumb: "100x100", square: "32x32#" },
:storage => :s3, storage: :s3,
:bucket => ENV["S3_BUCKET"], bucket: ENV["S3_BUCKET"],
:s3_credentials => { s3_credentials: {
:aws_access_key_id => ENV['AWS_ACCESS_KEY_ID'], aws_access_key_id: ENV['AWS_ACCESS_KEY_ID'],
:aws_secre_access_key => ENV['AWS_SECRET_ACCESS_KEY'] aws_secre_access_key: ENV['AWS_SECRET_ACCESS_KEY']
} }
Dummy.delete_all Dummy.delete_all
...@@ -142,15 +142,15 @@ unless ENV["S3_BUCKET"].blank? ...@@ -142,15 +142,15 @@ unless ENV["S3_BUCKET"].blank?
context "An attachment that uses S3 for storage and uses AES256 encryption" do context "An attachment that uses S3 for storage and uses AES256 encryption" do
before do before do
rebuild_model :styles => { :thumb => "100x100", :square => "32x32#" }, rebuild_model styles: { thumb: "100x100", square: "32x32#" },
:storage => :s3, storage: :s3,
:bucket => ENV["S3_BUCKET"], bucket: ENV["S3_BUCKET"],
:path => ":class/:attachment/:id/:style.:extension", path: ":class/:attachment/:id/:style.:extension",
:s3_credentials => { s3_credentials: {
:aws_access_key_id => ENV['AWS_ACCESS_KEY_ID'], aws_access_key_id: ENV['AWS_ACCESS_KEY_ID'],
:aws_secre_access_key => ENV['AWS_SECRET_ACCESS_KEY'] aws_secre_access_key: ENV['AWS_SECRET_ACCESS_KEY']
}, },
:s3_server_side_encryption => :aes256 s3_server_side_encryption: :aes256
Dummy.delete_all Dummy.delete_all
@dummy = Dummy.new @dummy = Dummy.new
......
...@@ -4,9 +4,9 @@ require 'spec_helper' ...@@ -4,9 +4,9 @@ require 'spec_helper'
describe Paperclip::Style do describe Paperclip::Style do
context "A style rule" do context "A style rule" do
before do before do
@attachment = attachment :path => ":basename.:extension", @attachment = attachment path: ":basename.:extension",
:styles => { :foo => {:geometry => "100x100#", :format => :png} }, styles: { foo: {geometry: "100x100#", format: :png} },
:whiny => true whiny: true
@style = @attachment.styles[:foo] @style = @attachment.styles[:foo]
end end
...@@ -38,15 +38,15 @@ describe Paperclip::Style do ...@@ -38,15 +38,15 @@ describe Paperclip::Style do
context "A style rule with properties supplied as procs" do context "A style rule with properties supplied as procs" do
before do before do
@attachment = attachment :path => ":basename.:extension", @attachment = attachment path: ":basename.:extension",
:whiny_thumbnails => true, whiny_thumbnails: true,
:processors => lambda {|a| [:test]}, processors: lambda {|a| [:test]},
:styles => { styles: {
:foo => lambda{|a| "300x300#"}, foo: lambda{|a| "300x300#"},
:bar => { bar: {
:geometry => lambda{|a| "300x300#"}, geometry: lambda{|a| "300x300#"},
:convert_options => lambda{|a| "-do_stuff"}, convert_options: lambda{|a| "-do_stuff"},
:source_file_options => lambda{|a| "-do_extra_stuff"} source_file_options: lambda{|a| "-do_extra_stuff"}
} }
} }
end end
...@@ -65,10 +65,10 @@ describe Paperclip::Style do ...@@ -65,10 +65,10 @@ describe Paperclip::Style do
before do before do
styles = {} styles = {}
styles[:aslist] = ["100x100", :png] styles[:aslist] = ["100x100", :png]
styles[:ashash] = {:geometry => "100x100", :format => :png} styles[:ashash] = {geometry: "100x100", format: :png}
styles[:asstring] = "100x100" styles[:asstring] = "100x100"
@attachment = attachment :path => ":basename.:extension", @attachment = attachment path: ":basename.:extension",
:styles => styles styles: styles
end end
it "have the right number of styles" do it "have the right number of styles" do
...@@ -101,17 +101,17 @@ describe Paperclip::Style do ...@@ -101,17 +101,17 @@ describe Paperclip::Style do
context "An attachment with :convert_options" do context "An attachment with :convert_options" do
it "not have called extra_options_for(:thumb/:large) on initialization" do it "not have called extra_options_for(:thumb/:large) on initialization" do
@attachment = attachment :path => ":basename.:extension", @attachment = attachment path: ":basename.:extension",
:styles => {:thumb => "100x100", :large => "400x400"}, styles: {thumb: "100x100", large: "400x400"},
:convert_options => {:all => "-do_stuff", :thumb => "-thumbnailize"} convert_options: {all: "-do_stuff", thumb: "-thumbnailize"}
@attachment.expects(:extra_options_for).never @attachment.expects(:extra_options_for).never
@style = @attachment.styles[:thumb] @style = @attachment.styles[:thumb]
end end
it "call extra_options_for(:thumb/:large) when convert options are requested" do it "call extra_options_for(:thumb/:large) when convert options are requested" do
@attachment = attachment :path => ":basename.:extension", @attachment = attachment path: ":basename.:extension",
:styles => {:thumb => "100x100", :large => "400x400"}, styles: {thumb: "100x100", large: "400x400"},
:convert_options => {:all => "-do_stuff", :thumb => "-thumbnailize"} convert_options: {all: "-do_stuff", thumb: "-thumbnailize"}
@style = @attachment.styles[:thumb] @style = @attachment.styles[:thumb]
@file = StringIO.new("...") @file = StringIO.new("...")
@file.stubs(:original_filename).returns("file.jpg") @file.stubs(:original_filename).returns("file.jpg")
...@@ -123,17 +123,17 @@ describe Paperclip::Style do ...@@ -123,17 +123,17 @@ describe Paperclip::Style do
context "An attachment with :source_file_options" do context "An attachment with :source_file_options" do
it "not have called extra_source_file_options_for(:thumb/:large) on initialization" do it "not have called extra_source_file_options_for(:thumb/:large) on initialization" do
@attachment = attachment :path => ":basename.:extension", @attachment = attachment path: ":basename.:extension",
:styles => {:thumb => "100x100", :large => "400x400"}, styles: {thumb: "100x100", large: "400x400"},
:source_file_options => {:all => "-density 400", :thumb => "-depth 8"} source_file_options: {all: "-density 400", thumb: "-depth 8"}
@attachment.expects(:extra_source_file_options_for).never @attachment.expects(:extra_source_file_options_for).never
@style = @attachment.styles[:thumb] @style = @attachment.styles[:thumb]
end end
it "call extra_options_for(:thumb/:large) when convert options are requested" do it "call extra_options_for(:thumb/:large) when convert options are requested" do
@attachment = attachment :path => ":basename.:extension", @attachment = attachment path: ":basename.:extension",
:styles => {:thumb => "100x100", :large => "400x400"}, styles: {thumb: "100x100", large: "400x400"},
:source_file_options => {:all => "-density 400", :thumb => "-depth 8"} source_file_options: {all: "-density 400", thumb: "-depth 8"}
@style = @attachment.styles[:thumb] @style = @attachment.styles[:thumb]
@file = StringIO.new("...") @file = StringIO.new("...")
@file.stubs(:original_filename).returns("file.jpg") @file.stubs(:original_filename).returns("file.jpg")
...@@ -145,15 +145,15 @@ describe Paperclip::Style do ...@@ -145,15 +145,15 @@ describe Paperclip::Style do
context "A style rule with its own :processors" do context "A style rule with its own :processors" do
before do before do
@attachment = attachment :path => ":basename.:extension", @attachment = attachment path: ":basename.:extension",
:styles => { styles: {
:foo => { foo: {
:geometry => "100x100#", geometry: "100x100#",
:format => :png, format: :png,
:processors => [:test] processors: [:test]
} }
}, },
:processors => [:thumbnail] processors: [:thumbnail]
@style = @attachment.styles[:foo] @style = @attachment.styles[:foo]
end end
...@@ -170,15 +170,15 @@ describe Paperclip::Style do ...@@ -170,15 +170,15 @@ describe Paperclip::Style do
context "A style rule with :processors supplied as procs" do context "A style rule with :processors supplied as procs" do
before do before do
@attachment = attachment :path => ":basename.:extension", @attachment = attachment path: ":basename.:extension",
:styles => { styles: {
:foo => { foo: {
:geometry => "100x100#", geometry: "100x100#",
:format => :png, format: :png,
:processors => lambda{|a| [:test]} processors: lambda{|a| [:test]}
} }
}, },
:processors => [:thumbnail] processors: [:thumbnail]
end end
it "defer processing of procs until they are needed" do it "defer processing of procs until they are needed" do
...@@ -192,12 +192,12 @@ describe Paperclip::Style do ...@@ -192,12 +192,12 @@ describe Paperclip::Style do
context "An attachment with :convert_options and :source_file_options in :styles" do context "An attachment with :convert_options and :source_file_options in :styles" do
before do before do
@attachment = attachment :path => ":basename.:extension", @attachment = attachment path: ":basename.:extension",
:styles => { styles: {
:thumb => "100x100", thumb: "100x100",
:large => {:geometry => "400x400", large: {geometry: "400x400",
:convert_options => "-do_stuff", convert_options: "-do_stuff",
:source_file_options => "-do_extra_stuff" source_file_options: "-do_extra_stuff"
} }
} }
@file = StringIO.new("...") @file = StringIO.new("...")
...@@ -217,13 +217,13 @@ describe Paperclip::Style do ...@@ -217,13 +217,13 @@ describe Paperclip::Style do
context "A style rule supplied with default format" do context "A style rule supplied with default format" do
before do before do
@attachment = attachment :default_format => :png, @attachment = attachment default_format: :png,
:styles => { styles: {
:asstring => "300x300#", asstring: "300x300#",
:aslist => ["300x300#", :jpg], aslist: ["300x300#", :jpg],
:ashash => { ashash: {
:geometry => "300x300#", geometry: "300x300#",
:convert_options => "-do_stuff" convert_options: "-do_stuff"
} }
} }
end end
......
...@@ -46,7 +46,7 @@ describe Paperclip::Thumbnail do ...@@ -46,7 +46,7 @@ describe Paperclip::Thumbnail do
].each do |args| ].each do |args|
context "being thumbnailed with a geometry of #{args[0]}" do context "being thumbnailed with a geometry of #{args[0]}" do
before do before do
@thumb = Paperclip::Thumbnail.new(@file, :geometry => args[0]) @thumb = Paperclip::Thumbnail.new(@file, geometry: args[0])
end end
it "start with dimensions of 434x66" do it "start with dimensions of 434x66" do
...@@ -73,7 +73,7 @@ describe Paperclip::Thumbnail do ...@@ -73,7 +73,7 @@ describe Paperclip::Thumbnail do
context "being thumbnailed at 100x50 with cropping" do context "being thumbnailed at 100x50 with cropping" do
before do before do
@thumb = Paperclip::Thumbnail.new(@file, :geometry => "100x50#") @thumb = Paperclip::Thumbnail.new(@file, geometry: "100x50#")
end end
it "let us know when a command isn't found versus a processing error" do it "let us know when a command isn't found versus a processing error" do
...@@ -129,19 +129,19 @@ describe Paperclip::Thumbnail do ...@@ -129,19 +129,19 @@ describe Paperclip::Thumbnail do
it 'properly crop a EXIF-rotated image' do it 'properly crop a EXIF-rotated image' do
file = File.new(fixture_file('rotated.jpg')) file = File.new(fixture_file('rotated.jpg'))
thumb = Paperclip::Thumbnail.new(file, :geometry => "50x50#") thumb = Paperclip::Thumbnail.new(file, geometry: "50x50#")
output_file = thumb.make output_file = thumb.make
command = Cocaine::CommandLine.new("identify", "-format %wx%h :file") command = Cocaine::CommandLine.new("identify", "-format %wx%h :file")
assert_equal "50x50", command.run(:file => output_file.path).strip assert_equal "50x50", command.run(file: output_file.path).strip
end end
context "being thumbnailed with source file options set" do context "being thumbnailed with source file options set" do
before do before do
@thumb = Paperclip::Thumbnail.new(@file, @thumb = Paperclip::Thumbnail.new(@file,
:geometry => "100x50#", geometry: "100x50#",
:source_file_options => "-strip") source_file_options: "-strip")
end end
it "have source_file_options value set" do it "have source_file_options value set" do
...@@ -164,8 +164,8 @@ describe Paperclip::Thumbnail do ...@@ -164,8 +164,8 @@ describe Paperclip::Thumbnail do
context "redefined to have bad source_file_options setting" do context "redefined to have bad source_file_options setting" do
before do before do
@thumb = Paperclip::Thumbnail.new(@file, @thumb = Paperclip::Thumbnail.new(@file,
:geometry => "100x50#", geometry: "100x50#",
:source_file_options => "-this-aint-no-option") source_file_options: "-this-aint-no-option")
end end
it "error when trying to create the thumbnail" do it "error when trying to create the thumbnail" do
...@@ -181,8 +181,8 @@ describe Paperclip::Thumbnail do ...@@ -181,8 +181,8 @@ describe Paperclip::Thumbnail do
context "being thumbnailed with convert options set" do context "being thumbnailed with convert options set" do
before do before do
@thumb = Paperclip::Thumbnail.new(@file, @thumb = Paperclip::Thumbnail.new(@file,
:geometry => "100x50#", geometry: "100x50#",
:convert_options => "-strip -depth 8") convert_options: "-strip -depth 8")
end end
it "have convert_options value set" do it "have convert_options value set" do
...@@ -205,8 +205,8 @@ describe Paperclip::Thumbnail do ...@@ -205,8 +205,8 @@ describe Paperclip::Thumbnail do
context "redefined to have bad convert_options setting" do context "redefined to have bad convert_options setting" do
before do before do
@thumb = Paperclip::Thumbnail.new(@file, @thumb = Paperclip::Thumbnail.new(@file,
:geometry => "100x50#", geometry: "100x50#",
:convert_options => "-this-aint-no-option") convert_options: "-this-aint-no-option")
end end
it "error when trying to create the thumbnail" do it "error when trying to create the thumbnail" do
...@@ -238,8 +238,8 @@ describe Paperclip::Thumbnail do ...@@ -238,8 +238,8 @@ describe Paperclip::Thumbnail do
context "being thumbnailed with a blank geometry string" do context "being thumbnailed with a blank geometry string" do
before do before do
@thumb = Paperclip::Thumbnail.new(@file, @thumb = Paperclip::Thumbnail.new(@file,
:geometry => "", geometry: "",
:convert_options => "-gravity center -crop \"300x300+0-0\"") convert_options: "-gravity center -crop \"300x300+0-0\"")
end end
it "not get resized by default" do it "not get resized by default" do
...@@ -249,7 +249,7 @@ describe Paperclip::Thumbnail do ...@@ -249,7 +249,7 @@ describe Paperclip::Thumbnail do
context "being thumbnailed with default animated option (true)" do context "being thumbnailed with default animated option (true)" do
it "call identify to check for animated images when sent #make" do it "call identify to check for animated images when sent #make" do
thumb = Paperclip::Thumbnail.new(@file, :geometry => "100x50#") thumb = Paperclip::Thumbnail.new(@file, geometry: "100x50#")
thumb.expects(:identify).at_least_once.with do |*arg| thumb.expects(:identify).at_least_once.with do |*arg|
arg[0] == '-format %m :file' && arg[0] == '-format %m :file' &&
arg[1][:file] == "#{File.expand_path(thumb.file.path)}[0]" arg[1][:file] == "#{File.expand_path(thumb.file.path)}[0]"
...@@ -274,7 +274,7 @@ describe Paperclip::Thumbnail do ...@@ -274,7 +274,7 @@ describe Paperclip::Thumbnail do
end end
end end
thumb = Paperclip::Thumbnail.new(@file, :geometry => '50x50', :file_geometry_parser => ::GeoParser) thumb = Paperclip::Thumbnail.new(@file, geometry: '50x50', file_geometry_parser: ::GeoParser)
transformation_command = thumb.transformation_command transformation_command = thumb.transformation_command
...@@ -305,7 +305,7 @@ describe Paperclip::Thumbnail do ...@@ -305,7 +305,7 @@ describe Paperclip::Thumbnail do
end end
end end
thumb = Paperclip::Thumbnail.new(@file, :geometry => '50x50', :string_geometry_parser => ::GeoParser) thumb = Paperclip::Thumbnail.new(@file, geometry: '50x50', string_geometry_parser: ::GeoParser)
transformation_command = thumb.transformation_command transformation_command = thumb.transformation_command
...@@ -329,7 +329,7 @@ describe Paperclip::Thumbnail do ...@@ -329,7 +329,7 @@ describe Paperclip::Thumbnail do
context "being thumbnailed at 100x100 with cropping" do context "being thumbnailed at 100x100 with cropping" do
before do before do
@thumb = Paperclip::Thumbnail.new(@file, :geometry => "100x100#", :format => :png) @thumb = Paperclip::Thumbnail.new(@file, geometry: "100x100#", format: :png)
end end
it "report its correct current and target geometries" do it "report its correct current and target geometries" do
...@@ -362,7 +362,7 @@ describe Paperclip::Thumbnail do ...@@ -362,7 +362,7 @@ describe Paperclip::Thumbnail do
context "with static output" do context "with static output" do
before do before do
@thumb = Paperclip::Thumbnail.new(@file, :geometry => "50x50", :format => :jpg) @thumb = Paperclip::Thumbnail.new(@file, geometry: "50x50", format: :jpg)
end end
it "create the single frame thumbnail when sent #make" do it "create the single frame thumbnail when sent #make" do
...@@ -374,7 +374,7 @@ describe Paperclip::Thumbnail do ...@@ -374,7 +374,7 @@ describe Paperclip::Thumbnail do
context "with animated output format" do context "with animated output format" do
before do before do
@thumb = Paperclip::Thumbnail.new(@file, :geometry => "50x50", :format => :gif) @thumb = Paperclip::Thumbnail.new(@file, geometry: "50x50", format: :gif)
end end
it "create the 12 frames thumbnail when sent #make" do it "create the 12 frames thumbnail when sent #make" do
...@@ -396,7 +396,7 @@ describe Paperclip::Thumbnail do ...@@ -396,7 +396,7 @@ describe Paperclip::Thumbnail do
context "with omitted output format" do context "with omitted output format" do
before do before do
@thumb = Paperclip::Thumbnail.new(@file, :geometry => "50x50") @thumb = Paperclip::Thumbnail.new(@file, geometry: "50x50")
end end
it "create the 12 frames thumbnail when sent #make" do it "create the 12 frames thumbnail when sent #make" do
...@@ -419,7 +419,7 @@ describe Paperclip::Thumbnail do ...@@ -419,7 +419,7 @@ describe Paperclip::Thumbnail do
context "with unidentified source format" do context "with unidentified source format" do
before do before do
@unidentified_file = File.new(fixture_file("animated.unknown"), 'rb') @unidentified_file = File.new(fixture_file("animated.unknown"), 'rb')
@thumb = Paperclip::Thumbnail.new(@file, :geometry => "60x60") @thumb = Paperclip::Thumbnail.new(@file, geometry: "60x60")
end end
it "create the 12 frames thumbnail when sent #make" do it "create the 12 frames thumbnail when sent #make" do
...@@ -442,7 +442,7 @@ describe Paperclip::Thumbnail do ...@@ -442,7 +442,7 @@ describe Paperclip::Thumbnail do
context "with no source format" do context "with no source format" do
before do before do
@unidentified_file = File.new(fixture_file("animated"), 'rb') @unidentified_file = File.new(fixture_file("animated"), 'rb')
@thumb = Paperclip::Thumbnail.new(@file, :geometry => "70x70") @thumb = Paperclip::Thumbnail.new(@file, geometry: "70x70")
end end
it "create the 12 frames thumbnail when sent #make" do it "create the 12 frames thumbnail when sent #make" do
...@@ -464,7 +464,7 @@ describe Paperclip::Thumbnail do ...@@ -464,7 +464,7 @@ describe Paperclip::Thumbnail do
context "with animated option set to false" do context "with animated option set to false" do
before do before do
@thumb = Paperclip::Thumbnail.new(@file, :geometry => "50x50", :animated => false) @thumb = Paperclip::Thumbnail.new(@file, geometry: "50x50", animated: false)
end end
it "output the gif format" do it "output the gif format" do
......
...@@ -5,10 +5,10 @@ describe Paperclip::UrlGenerator do ...@@ -5,10 +5,10 @@ describe Paperclip::UrlGenerator do
it "use the given interpolator" do it "use the given interpolator" do
expected = "the expected result" expected = "the expected result"
mock_attachment = MockAttachment.new mock_attachment = MockAttachment.new
mock_interpolator = MockInterpolator.new(:result => expected) mock_interpolator = MockInterpolator.new(result: expected)
url_generator = Paperclip::UrlGenerator.new(mock_attachment, url_generator = Paperclip::UrlGenerator.new(mock_attachment,
{ :interpolator => mock_interpolator }) { interpolator: mock_interpolator })
result = url_generator.for(:style_name, {}) result = url_generator.for(:style_name, {})
assert_equal expected, result assert_equal expected, result
...@@ -20,7 +20,7 @@ describe Paperclip::UrlGenerator do ...@@ -20,7 +20,7 @@ describe Paperclip::UrlGenerator do
mock_attachment = MockAttachment.new mock_attachment = MockAttachment.new
mock_interpolator = MockInterpolator.new mock_interpolator = MockInterpolator.new
default_url = "the default url" default_url = "the default url"
options = { :interpolator => mock_interpolator, :default_url => default_url} options = { interpolator: mock_interpolator, default_url: default_url}
url_generator = Paperclip::UrlGenerator.new(mock_attachment, options) url_generator = Paperclip::UrlGenerator.new(mock_attachment, options)
url_generator.for(:style_name, {}) url_generator.for(:style_name, {})
...@@ -33,7 +33,7 @@ describe Paperclip::UrlGenerator do ...@@ -33,7 +33,7 @@ describe Paperclip::UrlGenerator do
mock_attachment = MockAttachment.new mock_attachment = MockAttachment.new
mock_interpolator = MockInterpolator.new mock_interpolator = MockInterpolator.new
default_url = lambda {|attachment| "the #{attachment.class.name} default url" } default_url = lambda {|attachment| "the #{attachment.class.name} default url" }
options = { :interpolator => mock_interpolator, :default_url => default_url} options = { interpolator: mock_interpolator, default_url: default_url}
url_generator = Paperclip::UrlGenerator.new(mock_attachment, options) url_generator = Paperclip::UrlGenerator.new(mock_attachment, options)
url_generator.for(:style_name, {}) url_generator.for(:style_name, {})
...@@ -44,10 +44,10 @@ describe Paperclip::UrlGenerator do ...@@ -44,10 +44,10 @@ describe Paperclip::UrlGenerator do
it "execute the method named by the symbol as the default URL when no file is assigned" do it "execute the method named by the symbol as the default URL when no file is assigned" do
mock_model = MockModel.new mock_model = MockModel.new
mock_attachment = MockAttachment.new(:model => mock_model) mock_attachment = MockAttachment.new(model: mock_model)
mock_interpolator = MockInterpolator.new mock_interpolator = MockInterpolator.new
default_url = :to_s default_url = :to_s
options = { :interpolator => mock_interpolator, :default_url => default_url} options = { interpolator: mock_interpolator, default_url: default_url}
url_generator = Paperclip::UrlGenerator.new(mock_attachment, options) url_generator = Paperclip::UrlGenerator.new(mock_attachment, options)
url_generator.for(:style_name, {}) url_generator.for(:style_name, {})
...@@ -59,11 +59,11 @@ describe Paperclip::UrlGenerator do ...@@ -59,11 +59,11 @@ describe Paperclip::UrlGenerator do
it "URL-escape spaces if asked to" do it "URL-escape spaces if asked to" do
expected = "the expected result" expected = "the expected result"
mock_attachment = MockAttachment.new mock_attachment = MockAttachment.new
mock_interpolator = MockInterpolator.new(:result => expected) mock_interpolator = MockInterpolator.new(result: expected)
options = { :interpolator => mock_interpolator } options = { interpolator: mock_interpolator }
url_generator = Paperclip::UrlGenerator.new(mock_attachment, options) url_generator = Paperclip::UrlGenerator.new(mock_attachment, options)
result = url_generator.for(:style_name, {:escape => true}) result = url_generator.for(:style_name, {escape: true})
assert_equal "the%20expected%20result", result assert_equal "the%20expected%20result", result
end end
...@@ -75,11 +75,11 @@ describe Paperclip::UrlGenerator do ...@@ -75,11 +75,11 @@ describe Paperclip::UrlGenerator do
end end
end.new end.new
mock_attachment = MockAttachment.new mock_attachment = MockAttachment.new
mock_interpolator = MockInterpolator.new(:result => expected) mock_interpolator = MockInterpolator.new(result: expected)
options = { :interpolator => mock_interpolator } options = { interpolator: mock_interpolator }
url_generator = Paperclip::UrlGenerator.new(mock_attachment, options) url_generator = Paperclip::UrlGenerator.new(mock_attachment, options)
result = url_generator.for(:style_name, {:escape => true}) result = url_generator.for(:style_name, {escape: true})
assert_equal "the escaped result", result assert_equal "the escaped result", result
end end
...@@ -87,11 +87,11 @@ describe Paperclip::UrlGenerator do ...@@ -87,11 +87,11 @@ describe Paperclip::UrlGenerator do
it "leave spaces unescaped as asked to" do it "leave spaces unescaped as asked to" do
expected = "the expected result" expected = "the expected result"
mock_attachment = MockAttachment.new mock_attachment = MockAttachment.new
mock_interpolator = MockInterpolator.new(:result => expected) mock_interpolator = MockInterpolator.new(result: expected)
options = { :interpolator => mock_interpolator } options = { interpolator: mock_interpolator }
url_generator = Paperclip::UrlGenerator.new(mock_attachment, options) url_generator = Paperclip::UrlGenerator.new(mock_attachment, options)
result = url_generator.for(:style_name, {:escape => false}) result = url_generator.for(:style_name, {escape: false})
assert_equal "the expected result", result assert_equal "the expected result", result
end end
...@@ -99,8 +99,8 @@ describe Paperclip::UrlGenerator do ...@@ -99,8 +99,8 @@ describe Paperclip::UrlGenerator do
it "default to leaving spaces unescaped" do it "default to leaving spaces unescaped" do
expected = "the expected result" expected = "the expected result"
mock_attachment = MockAttachment.new mock_attachment = MockAttachment.new
mock_interpolator = MockInterpolator.new(:result => expected) mock_interpolator = MockInterpolator.new(result: expected)
options = { :interpolator => mock_interpolator } options = { interpolator: mock_interpolator }
url_generator = Paperclip::UrlGenerator.new(mock_attachment, options) url_generator = Paperclip::UrlGenerator.new(mock_attachment, options)
result = url_generator.for(:style_name, {}) result = url_generator.for(:style_name, {})
...@@ -110,24 +110,24 @@ describe Paperclip::UrlGenerator do ...@@ -110,24 +110,24 @@ describe Paperclip::UrlGenerator do
it "produce URLs without the updated_at value when the object does not respond to updated_at" do it "produce URLs without the updated_at value when the object does not respond to updated_at" do
expected = "the expected result" expected = "the expected result"
mock_interpolator = MockInterpolator.new(:result => expected) mock_interpolator = MockInterpolator.new(result: expected)
mock_attachment = MockAttachment.new(:responds_to_updated_at => false) mock_attachment = MockAttachment.new(responds_to_updated_at: false)
options = { :interpolator => mock_interpolator } options = { interpolator: mock_interpolator }
url_generator = Paperclip::UrlGenerator.new(mock_attachment, options) url_generator = Paperclip::UrlGenerator.new(mock_attachment, options)
result = url_generator.for(:style_name, {:timestamp => true}) result = url_generator.for(:style_name, {timestamp: true})
assert_equal expected, result assert_equal expected, result
end end
it "produce URLs without the updated_at value when the updated_at value is nil" do it "produce URLs without the updated_at value when the updated_at value is nil" do
expected = "the expected result" expected = "the expected result"
mock_interpolator = MockInterpolator.new(:result => expected) mock_interpolator = MockInterpolator.new(result: expected)
mock_attachment = MockAttachment.new(:responds_to_updated_at => true, :updated_at => nil) mock_attachment = MockAttachment.new(responds_to_updated_at: true, updated_at: nil)
options = { :interpolator => mock_interpolator } options = { interpolator: mock_interpolator }
url_generator = Paperclip::UrlGenerator.new(mock_attachment, options) url_generator = Paperclip::UrlGenerator.new(mock_attachment, options)
result = url_generator.for(:style_name, {:timestamp => true}) result = url_generator.for(:style_name, {timestamp: true})
assert_equal expected, result assert_equal expected, result
end end
...@@ -135,12 +135,12 @@ describe Paperclip::UrlGenerator do ...@@ -135,12 +135,12 @@ describe Paperclip::UrlGenerator do
it "produce URLs with the updated_at when it exists" do it "produce URLs with the updated_at when it exists" do
expected = "the expected result" expected = "the expected result"
updated_at = 1231231234 updated_at = 1231231234
mock_interpolator = MockInterpolator.new(:result => expected) mock_interpolator = MockInterpolator.new(result: expected)
mock_attachment = MockAttachment.new(:updated_at => updated_at) mock_attachment = MockAttachment.new(updated_at: updated_at)
options = { :interpolator => mock_interpolator } options = { interpolator: mock_interpolator }
url_generator = Paperclip::UrlGenerator.new(mock_attachment, options) url_generator = Paperclip::UrlGenerator.new(mock_attachment, options)
result = url_generator.for(:style_name, {:timestamp => true}) result = url_generator.for(:style_name, {timestamp: true})
assert_equal "#{expected}?#{updated_at}", result assert_equal "#{expected}?#{updated_at}", result
end end
...@@ -148,12 +148,12 @@ describe Paperclip::UrlGenerator do ...@@ -148,12 +148,12 @@ describe Paperclip::UrlGenerator do
it "produce URLs with the updated_at when it exists, separated with a & if a ? follow by = already exists" do it "produce URLs with the updated_at when it exists, separated with a & if a ? follow by = already exists" do
expected = "the?expected=result" expected = "the?expected=result"
updated_at = 1231231234 updated_at = 1231231234
mock_interpolator = MockInterpolator.new(:result => expected) mock_interpolator = MockInterpolator.new(result: expected)
mock_attachment = MockAttachment.new(:updated_at => updated_at) mock_attachment = MockAttachment.new(updated_at: updated_at)
options = { :interpolator => mock_interpolator } options = { interpolator: mock_interpolator }
url_generator = Paperclip::UrlGenerator.new(mock_attachment, options) url_generator = Paperclip::UrlGenerator.new(mock_attachment, options)
result = url_generator.for(:style_name, {:timestamp => true}) result = url_generator.for(:style_name, {timestamp: true})
assert_equal "#{expected}&#{updated_at}", result assert_equal "#{expected}&#{updated_at}", result
end end
...@@ -161,21 +161,21 @@ describe Paperclip::UrlGenerator do ...@@ -161,21 +161,21 @@ describe Paperclip::UrlGenerator do
it "produce URLs without the updated_at when told to do as much" do it "produce URLs without the updated_at when told to do as much" do
expected = "the expected result" expected = "the expected result"
updated_at = 1231231234 updated_at = 1231231234
mock_interpolator = MockInterpolator.new(:result => expected) mock_interpolator = MockInterpolator.new(result: expected)
mock_attachment = MockAttachment.new(:updated_at => updated_at) mock_attachment = MockAttachment.new(updated_at: updated_at)
options = { :interpolator => mock_interpolator } options = { interpolator: mock_interpolator }
url_generator = Paperclip::UrlGenerator.new(mock_attachment, options) url_generator = Paperclip::UrlGenerator.new(mock_attachment, options)
result = url_generator.for(:style_name, {:timestamp => false}) result = url_generator.for(:style_name, {timestamp: false})
assert_equal expected, result assert_equal expected, result
end end
it "produce the correct URL when the instance has a file name" do it "produce the correct URL when the instance has a file name" do
expected = "the expected result" expected = "the expected result"
mock_attachment = MockAttachment.new(:original_filename => 'exists') mock_attachment = MockAttachment.new(original_filename: 'exists')
mock_interpolator = MockInterpolator.new mock_interpolator = MockInterpolator.new
options = { :interpolator => mock_interpolator, :url => expected} options = { interpolator: mock_interpolator, url: expected}
url_generator = Paperclip::UrlGenerator.new(mock_attachment, options) url_generator = Paperclip::UrlGenerator.new(mock_attachment, options)
url_generator.for(:style_name, {}) url_generator.for(:style_name, {})
......
...@@ -8,14 +8,14 @@ describe Paperclip::Validators::AttachmentFileNameValidator do ...@@ -8,14 +8,14 @@ describe Paperclip::Validators::AttachmentFileNameValidator do
def build_validator(options) def build_validator(options)
@validator = Paperclip::Validators::AttachmentFileNameValidator.new(options.merge( @validator = Paperclip::Validators::AttachmentFileNameValidator.new(options.merge(
:attributes => :avatar attributes: :avatar
)) ))
end end
context "with a failing validation" do context "with a failing validation" do
before do before do
build_validator :matches => /.*\.png$/, :allow_nil => false build_validator matches: /.*\.png$/, allow_nil: false
@dummy.stubs(:avatar_file_name => "data.txt") @dummy.stubs(avatar_file_name: "data.txt")
@validator.validate(@dummy) @validator.validate(@dummy)
end end
...@@ -30,8 +30,8 @@ describe Paperclip::Validators::AttachmentFileNameValidator do ...@@ -30,8 +30,8 @@ describe Paperclip::Validators::AttachmentFileNameValidator do
end end
it "not add error to the base object with a successful validation" do it "not add error to the base object with a successful validation" do
build_validator :matches => /.*\.png$/, :allow_nil => false build_validator matches: /.*\.png$/, allow_nil: false
@dummy.stubs(:avatar_file_name => "image.png") @dummy.stubs(avatar_file_name: "image.png")
@validator.validate(@dummy) @validator.validate(@dummy)
assert @dummy.errors[:avatar].blank?, "Error was added to base attribute" assert @dummy.errors[:avatar].blank?, "Error was added to base attribute"
...@@ -41,8 +41,8 @@ describe Paperclip::Validators::AttachmentFileNameValidator do ...@@ -41,8 +41,8 @@ describe Paperclip::Validators::AttachmentFileNameValidator do
context "with an allowed type" do context "with an allowed type" do
context "as a single regexp" do context "as a single regexp" do
before do before do
build_validator :matches => /.*\.jpg$/ build_validator matches: /.*\.jpg$/
@dummy.stubs(:avatar_file_name => "image.jpg") @dummy.stubs(avatar_file_name: "image.jpg")
@validator.validate(@dummy) @validator.validate(@dummy)
end end
...@@ -53,8 +53,8 @@ describe Paperclip::Validators::AttachmentFileNameValidator do ...@@ -53,8 +53,8 @@ describe Paperclip::Validators::AttachmentFileNameValidator do
context "as a list" do context "as a list" do
before do before do
build_validator :matches => [/.*\.png$/, /.*\.jpe?g$/] build_validator matches: [/.*\.png$/, /.*\.jpe?g$/]
@dummy.stubs(:avatar_file_name => "image.jpg") @dummy.stubs(avatar_file_name: "image.jpg")
@validator.validate(@dummy) @validator.validate(@dummy)
end end
...@@ -66,8 +66,8 @@ describe Paperclip::Validators::AttachmentFileNameValidator do ...@@ -66,8 +66,8 @@ describe Paperclip::Validators::AttachmentFileNameValidator do
context "with a disallowed type" do context "with a disallowed type" do
it "set a correct default error message" do it "set a correct default error message" do
build_validator :matches => /^text\/.*/ build_validator matches: /^text\/.*/
@dummy.stubs(:avatar_file_name => "image.jpg") @dummy.stubs(avatar_file_name: "image.jpg")
@validator.validate(@dummy) @validator.validate(@dummy)
assert @dummy.errors[:avatar_file_name].present? assert @dummy.errors[:avatar_file_name].present?
...@@ -75,8 +75,8 @@ describe Paperclip::Validators::AttachmentFileNameValidator do ...@@ -75,8 +75,8 @@ describe Paperclip::Validators::AttachmentFileNameValidator do
end end
it "set a correct custom error message" do it "set a correct custom error message" do
build_validator :matches => /.*\.png$/, :message => "should be a PNG image" build_validator matches: /.*\.png$/, message: "should be a PNG image"
@dummy.stubs(:avatar_file_name => "image.jpg") @dummy.stubs(avatar_file_name: "image.jpg")
@validator.validate(@dummy) @validator.validate(@dummy)
expect(@dummy.errors[:avatar_file_name]).to include "should be a PNG image" expect(@dummy.errors[:avatar_file_name]).to include "should be a PNG image"
...@@ -88,8 +88,8 @@ describe Paperclip::Validators::AttachmentFileNameValidator do ...@@ -88,8 +88,8 @@ describe Paperclip::Validators::AttachmentFileNameValidator do
context "with an allowed type" do context "with an allowed type" do
context "as a single regexp" do context "as a single regexp" do
before do before do
build_validator :not => /^text\/.*/ build_validator not: /^text\/.*/
@dummy.stubs(:avatar_file_name => "image.jpg") @dummy.stubs(avatar_file_name: "image.jpg")
@validator.validate(@dummy) @validator.validate(@dummy)
end end
...@@ -100,8 +100,8 @@ describe Paperclip::Validators::AttachmentFileNameValidator do ...@@ -100,8 +100,8 @@ describe Paperclip::Validators::AttachmentFileNameValidator do
context "as a list" do context "as a list" do
before do before do
build_validator :not => [/.*\.png$/, /.*\.jpe?g$/] build_validator not: [/.*\.png$/, /.*\.jpe?g$/]
@dummy.stubs(:avatar_file_name => "image.gif") @dummy.stubs(avatar_file_name: "image.gif")
@validator.validate(@dummy) @validator.validate(@dummy)
end end
...@@ -113,8 +113,8 @@ describe Paperclip::Validators::AttachmentFileNameValidator do ...@@ -113,8 +113,8 @@ describe Paperclip::Validators::AttachmentFileNameValidator do
context "with a disallowed type" do context "with a disallowed type" do
it "set a correct default error message" do it "set a correct default error message" do
build_validator :not => /data.*/ build_validator not: /data.*/
@dummy.stubs(:avatar_file_name => "data.txt") @dummy.stubs(avatar_file_name: "data.txt")
@validator.validate(@dummy) @validator.validate(@dummy)
assert @dummy.errors[:avatar_file_name].present? assert @dummy.errors[:avatar_file_name].present?
...@@ -122,8 +122,8 @@ describe Paperclip::Validators::AttachmentFileNameValidator do ...@@ -122,8 +122,8 @@ describe Paperclip::Validators::AttachmentFileNameValidator do
end end
it "set a correct custom error message" do it "set a correct custom error message" do
build_validator :not => /.*\.png$/, :message => "should not be a PNG image" build_validator not: /.*\.png$/, message: "should not be a PNG image"
@dummy.stubs(:avatar_file_name => "image.png") @dummy.stubs(avatar_file_name: "image.png")
@validator.validate(@dummy) @validator.validate(@dummy)
expect(@dummy.errors[:avatar_file_name]).to include "should not be a PNG image" expect(@dummy.errors[:avatar_file_name]).to include "should not be a PNG image"
...@@ -133,7 +133,7 @@ describe Paperclip::Validators::AttachmentFileNameValidator do ...@@ -133,7 +133,7 @@ describe Paperclip::Validators::AttachmentFileNameValidator do
context "using the helper" do context "using the helper" do
before do before do
Dummy.validates_attachment_file_name :avatar, :matches => /.*\.jpg$/ Dummy.validates_attachment_file_name :avatar, matches: /.*\.jpg$/
end end
it "add the validator to the class" do it "add the validator to the class" do
...@@ -144,16 +144,16 @@ describe Paperclip::Validators::AttachmentFileNameValidator do ...@@ -144,16 +144,16 @@ describe Paperclip::Validators::AttachmentFileNameValidator do
context "given options" do context "given options" do
it "raise argument error if no required argument was given" do it "raise argument error if no required argument was given" do
assert_raises(ArgumentError) do assert_raises(ArgumentError) do
build_validator :message => "Some message" build_validator message: "Some message"
end end
end end
it "not raise argument error if :matches was given" do it "not raise argument error if :matches was given" do
build_validator :matches => /.*\.jpg$/ build_validator matches: /.*\.jpg$/
end end
it "not raise argument error if :not was given" do it "not raise argument error if :not was given" do
build_validator :not => /.*\.jpg$/ build_validator not: /.*\.jpg$/
end end
end end
end end
......
...@@ -8,7 +8,7 @@ describe Paperclip::Validators::AttachmentPresenceValidator do ...@@ -8,7 +8,7 @@ describe Paperclip::Validators::AttachmentPresenceValidator do
def build_validator(options={}) def build_validator(options={})
@validator = Paperclip::Validators::AttachmentPresenceValidator.new(options.merge( @validator = Paperclip::Validators::AttachmentPresenceValidator.new(options.merge(
:attributes => :avatar attributes: :avatar
)) ))
end end
...@@ -35,7 +35,7 @@ describe Paperclip::Validators::AttachmentPresenceValidator do ...@@ -35,7 +35,7 @@ describe Paperclip::Validators::AttachmentPresenceValidator do
context "with :if option" do context "with :if option" do
context "returning true" do context "returning true" do
before do before do
build_validator :if => true build_validator if: true
@validator.validate(@dummy) @validator.validate(@dummy)
end end
...@@ -46,7 +46,7 @@ describe Paperclip::Validators::AttachmentPresenceValidator do ...@@ -46,7 +46,7 @@ describe Paperclip::Validators::AttachmentPresenceValidator do
context "returning false" do context "returning false" do
before do before do
build_validator :if => false build_validator if: false
@validator.validate(@dummy) @validator.validate(@dummy)
end end
......
...@@ -8,7 +8,7 @@ describe Paperclip::Validators::AttachmentSizeValidator do ...@@ -8,7 +8,7 @@ describe Paperclip::Validators::AttachmentSizeValidator do
def build_validator(options) def build_validator(options)
@validator = Paperclip::Validators::AttachmentSizeValidator.new(options.merge( @validator = Paperclip::Validators::AttachmentSizeValidator.new(options.merge(
:attributes => :avatar attributes: :avatar
)) ))
end end
...@@ -60,7 +60,7 @@ describe Paperclip::Validators::AttachmentSizeValidator do ...@@ -60,7 +60,7 @@ describe Paperclip::Validators::AttachmentSizeValidator do
context "with :in option" do context "with :in option" do
context "as a range" do context "as a range" do
before do before do
build_validator :in => (5.kilobytes..10.kilobytes) build_validator in: (5.kilobytes..10.kilobytes)
end end
should_allow_attachment_file_size(7.kilobytes) should_allow_attachment_file_size(7.kilobytes)
...@@ -70,7 +70,7 @@ describe Paperclip::Validators::AttachmentSizeValidator do ...@@ -70,7 +70,7 @@ describe Paperclip::Validators::AttachmentSizeValidator do
context "as a proc" do context "as a proc" do
before do before do
build_validator :in => lambda { |avatar| (5.kilobytes..10.kilobytes) } build_validator in: lambda { |avatar| (5.kilobytes..10.kilobytes) }
end end
should_allow_attachment_file_size(7.kilobytes) should_allow_attachment_file_size(7.kilobytes)
...@@ -82,7 +82,7 @@ describe Paperclip::Validators::AttachmentSizeValidator do ...@@ -82,7 +82,7 @@ describe Paperclip::Validators::AttachmentSizeValidator do
context "with :greater_than option" do context "with :greater_than option" do
context "as number" do context "as number" do
before do before do
build_validator :greater_than => 10.kilobytes build_validator greater_than: 10.kilobytes
end end
should_allow_attachment_file_size 11.kilobytes should_allow_attachment_file_size 11.kilobytes
...@@ -91,7 +91,7 @@ describe Paperclip::Validators::AttachmentSizeValidator do ...@@ -91,7 +91,7 @@ describe Paperclip::Validators::AttachmentSizeValidator do
context "as a proc" do context "as a proc" do
before do before do
build_validator :greater_than => lambda { |avatar| 10.kilobytes } build_validator greater_than: lambda { |avatar| 10.kilobytes }
end end
should_allow_attachment_file_size 11.kilobytes should_allow_attachment_file_size 11.kilobytes
...@@ -102,7 +102,7 @@ describe Paperclip::Validators::AttachmentSizeValidator do ...@@ -102,7 +102,7 @@ describe Paperclip::Validators::AttachmentSizeValidator do
context "with :less_than option" do context "with :less_than option" do
context "as number" do context "as number" do
before do before do
build_validator :less_than => 10.kilobytes build_validator less_than: 10.kilobytes
end end
should_allow_attachment_file_size 9.kilobytes should_allow_attachment_file_size 9.kilobytes
...@@ -111,7 +111,7 @@ describe Paperclip::Validators::AttachmentSizeValidator do ...@@ -111,7 +111,7 @@ describe Paperclip::Validators::AttachmentSizeValidator do
context "as a proc" do context "as a proc" do
before do before do
build_validator :less_than => lambda { |avatar| 10.kilobytes } build_validator less_than: lambda { |avatar| 10.kilobytes }
end end
should_allow_attachment_file_size 9.kilobytes should_allow_attachment_file_size 9.kilobytes
...@@ -122,8 +122,8 @@ describe Paperclip::Validators::AttachmentSizeValidator do ...@@ -122,8 +122,8 @@ describe Paperclip::Validators::AttachmentSizeValidator do
context "with :greater_than and :less_than option" do context "with :greater_than and :less_than option" do
context "as numbers" do context "as numbers" do
before do before do
build_validator :greater_than => 5.kilobytes, build_validator greater_than: 5.kilobytes,
:less_than => 10.kilobytes less_than: 10.kilobytes
end end
should_allow_attachment_file_size 7.kilobytes should_allow_attachment_file_size 7.kilobytes
...@@ -133,8 +133,8 @@ describe Paperclip::Validators::AttachmentSizeValidator do ...@@ -133,8 +133,8 @@ describe Paperclip::Validators::AttachmentSizeValidator do
context "as a proc" do context "as a proc" do
before do before do
build_validator :greater_than => lambda { |avatar| 5.kilobytes }, build_validator greater_than: lambda { |avatar| 5.kilobytes },
:less_than => lambda { |avatar| 10.kilobytes } less_than: lambda { |avatar| 10.kilobytes }
end end
should_allow_attachment_file_size 7.kilobytes should_allow_attachment_file_size 7.kilobytes
...@@ -146,54 +146,54 @@ describe Paperclip::Validators::AttachmentSizeValidator do ...@@ -146,54 +146,54 @@ describe Paperclip::Validators::AttachmentSizeValidator do
context "with :message option" do context "with :message option" do
context "given a range" do context "given a range" do
before do before do
build_validator :in => (5.kilobytes..10.kilobytes), build_validator in: (5.kilobytes..10.kilobytes),
:message => "is invalid. (Between %{min} and %{max} please.)" message: "is invalid. (Between %{min} and %{max} please.)"
end end
should_not_allow_attachment_file_size 11.kilobytes, should_not_allow_attachment_file_size 11.kilobytes,
:message => "is invalid. (Between 5120 Bytes and 10240 Bytes please.)" message: "is invalid. (Between 5120 Bytes and 10240 Bytes please.)"
end end
context "given :less_than and :greater_than" do context "given :less_than and :greater_than" do
before do before do
build_validator :less_than => 10.kilobytes, build_validator less_than: 10.kilobytes,
:greater_than => 5.kilobytes, greater_than: 5.kilobytes,
:message => "is invalid. (Between %{min} and %{max} please.)" message: "is invalid. (Between %{min} and %{max} please.)"
end end
should_not_allow_attachment_file_size 11.kilobytes, should_not_allow_attachment_file_size 11.kilobytes,
:message => "is invalid. (Between 5120 Bytes and 10240 Bytes please.)" message: "is invalid. (Between 5120 Bytes and 10240 Bytes please.)"
end end
end end
context "default error messages" do context "default error messages" do
context "given :less_than and :greater_than" do context "given :less_than and :greater_than" do
before do before do
build_validator :greater_than => 5.kilobytes, build_validator greater_than: 5.kilobytes,
:less_than => 10.kilobytes less_than: 10.kilobytes
end end
should_not_allow_attachment_file_size 11.kilobytes, should_not_allow_attachment_file_size 11.kilobytes,
:message => "must be less than 10240 Bytes" message: "must be less than 10240 Bytes"
should_not_allow_attachment_file_size 4.kilobytes, should_not_allow_attachment_file_size 4.kilobytes,
:message => "must be greater than 5120 Bytes" message: "must be greater than 5120 Bytes"
end end
context "given a size range" do context "given a size range" do
before do before do
build_validator :in => (5.kilobytes..10.kilobytes) build_validator in: (5.kilobytes..10.kilobytes)
end end
should_not_allow_attachment_file_size 11.kilobytes, should_not_allow_attachment_file_size 11.kilobytes,
:message => "must be in between 5120 Bytes and 10240 Bytes" message: "must be in between 5120 Bytes and 10240 Bytes"
should_not_allow_attachment_file_size 4.kilobytes, should_not_allow_attachment_file_size 4.kilobytes,
:message => "must be in between 5120 Bytes and 10240 Bytes" message: "must be in between 5120 Bytes and 10240 Bytes"
end end
end end
context "using the helper" do context "using the helper" do
before do before do
Dummy.validates_attachment_size :avatar, :in => (5.kilobytes..10.kilobytes) Dummy.validates_attachment_size :avatar, in: (5.kilobytes..10.kilobytes)
end end
it "add the validator to the class" do it "add the validator to the class" do
...@@ -204,7 +204,7 @@ describe Paperclip::Validators::AttachmentSizeValidator do ...@@ -204,7 +204,7 @@ describe Paperclip::Validators::AttachmentSizeValidator do
context "given options" do context "given options" do
it "raise argument error if no required argument was given" do it "raise argument error if no required argument was given" do
assert_raises(ArgumentError) do assert_raises(ArgumentError) do
build_validator :message => "Some message" build_validator message: "Some message"
end end
end end
...@@ -215,7 +215,7 @@ describe Paperclip::Validators::AttachmentSizeValidator do ...@@ -215,7 +215,7 @@ describe Paperclip::Validators::AttachmentSizeValidator do
end end
it "not raise argument error if :in was given" do it "not raise argument error if :in was given" do
build_validator :in => (5.kilobytes..10.kilobytes) build_validator in: (5.kilobytes..10.kilobytes)
end end
end end
end end
...@@ -8,7 +8,7 @@ describe Paperclip::Validators::MediaTypeSpoofDetectionValidator do ...@@ -8,7 +8,7 @@ describe Paperclip::Validators::MediaTypeSpoofDetectionValidator do
def build_validator(options = {}) def build_validator(options = {})
@validator = Paperclip::Validators::MediaTypeSpoofDetectionValidator.new(options.merge( @validator = Paperclip::Validators::MediaTypeSpoofDetectionValidator.new(options.merge(
:attributes => :avatar attributes: :avatar
)) ))
end end
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe Paperclip::Validators do describe Paperclip::Validators do
context "using the helper" do context "using the helper" do
before do before do
Dummy.validates_attachment :avatar, :presence => true, :content_type => { :content_type => "image/jpeg" }, :size => { :in => 0..10240 } Dummy.validates_attachment :avatar, presence: true, content_type: { content_type: "image/jpeg" }, size: { in: 0..10240 }
end end
it "adds the attachment_presence validator to the class" do it "adds the attachment_presence validator to the class" do
...@@ -20,7 +20,7 @@ describe Paperclip::Validators do ...@@ -20,7 +20,7 @@ describe Paperclip::Validators do
it 'prevents you from attaching a file that violates that validation' do it 'prevents you from attaching a file that violates that validation' do
Dummy.class_eval{ validate(:name) { raise "DO NOT RUN THIS" } } Dummy.class_eval{ validate(:name) { raise "DO NOT RUN THIS" } }
dummy = Dummy.new(:avatar => File.new(fixture_file("12k.png"))) dummy = Dummy.new(avatar: File.new(fixture_file("12k.png")))
assert_equal [:avatar_content_type, :avatar, :avatar_file_size], dummy.errors.keys assert_equal [:avatar_content_type, :avatar, :avatar_file_size], dummy.errors.keys
assert_raises(RuntimeError){ dummy.valid? } assert_raises(RuntimeError){ dummy.valid? }
end end
...@@ -29,10 +29,10 @@ describe Paperclip::Validators do ...@@ -29,10 +29,10 @@ describe Paperclip::Validators do
context "using the helper with a conditional" do context "using the helper with a conditional" do
before do before do
rebuild_class rebuild_class
Dummy.validates_attachment :avatar, :presence => true, Dummy.validates_attachment :avatar, presence: true,
:content_type => { :content_type => "image/jpeg" }, content_type: { content_type: "image/jpeg" },
:size => { :in => 0..10240 }, size: { in: 0..10240 },
:if => :title_present? if: :title_present?
end end
it "validates the attachment if title is present" do it "validates the attachment if title is present" do
...@@ -41,7 +41,7 @@ describe Paperclip::Validators do ...@@ -41,7 +41,7 @@ describe Paperclip::Validators do
true true
end end
end end
dummy = Dummy.new(:avatar => File.new(fixture_file("12k.png"))) dummy = Dummy.new(avatar: File.new(fixture_file("12k.png")))
assert_equal [:avatar_content_type, :avatar, :avatar_file_size], dummy.errors.keys assert_equal [:avatar_content_type, :avatar, :avatar_file_size], dummy.errors.keys
end end
...@@ -65,31 +65,31 @@ describe Paperclip::Validators do ...@@ -65,31 +65,31 @@ describe Paperclip::Validators do
it 'raises an error when no content_type validation exists' do it 'raises an error when no content_type validation exists' do
assert_raises(Paperclip::Errors::MissingRequiredValidatorError) do assert_raises(Paperclip::Errors::MissingRequiredValidatorError) do
Dummy.new(:avatar => File.new(fixture_file("12k.png"))) Dummy.new(avatar: File.new(fixture_file("12k.png")))
end end
end end
it 'does not raise an error when a content_type validation exists' do it 'does not raise an error when a content_type validation exists' do
Dummy.validates_attachment :avatar, :content_type => { :content_type => "image/jpeg" } Dummy.validates_attachment :avatar, content_type: { content_type: "image/jpeg" }
assert_nothing_raised do assert_nothing_raised do
Dummy.new(:avatar => File.new(fixture_file("12k.png"))) Dummy.new(avatar: File.new(fixture_file("12k.png")))
end end
end end
it 'does not raise an error when a file_name validation exists' do it 'does not raise an error when a file_name validation exists' do
Dummy.validates_attachment :avatar, :file_name => { :matches => /png$/ } Dummy.validates_attachment :avatar, file_name: { matches: /png$/ }
assert_nothing_raised do assert_nothing_raised do
Dummy.new(:avatar => File.new(fixture_file("12k.png"))) Dummy.new(avatar: File.new(fixture_file("12k.png")))
end end
end end
it 'does not raise an error when a the validation has been explicitly rejected' do it 'does not raise an error when a the validation has been explicitly rejected' do
Dummy.validates_attachment :avatar, :file_type_ignorance => true Dummy.validates_attachment :avatar, file_type_ignorance: true
assert_nothing_raised do assert_nothing_raised do
Dummy.new(:avatar => File.new(fixture_file("12k.png"))) Dummy.new(avatar: File.new(fixture_file("12k.png")))
end end
end end
end end
......
...@@ -54,7 +54,7 @@ end ...@@ -54,7 +54,7 @@ end
def reset_table table_name, &block def reset_table table_name, &block
block ||= lambda { |table| true } block ||= lambda { |table| true }
ActiveRecord::Base.connection.create_table :dummies, {:force => true}, &block ActiveRecord::Base.connection.create_table :dummies, {force: true}, &block
end end
def modify_table table_name, &block def modify_table table_name, &block
...@@ -62,7 +62,7 @@ def modify_table table_name, &block ...@@ -62,7 +62,7 @@ def modify_table table_name, &block
end end
def rebuild_model options = {} def rebuild_model options = {}
ActiveRecord::Base.connection.create_table :dummies, :force => true do |table| ActiveRecord::Base.connection.create_table :dummies, force: true do |table|
table.column :title, :string table.column :title, :string
table.column :other, :string table.column :other, :string
table.column :avatar_file_name, :string table.column :avatar_file_name, :string
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment