spec/paperclip/interpolations_spec.rb in paperclip-4.3.1 vs spec/paperclip/interpolations_spec.rb in paperclip-4.3.2
- old
+ new
@@ -22,19 +22,20 @@
it "returns the class of the Interpolations module when called with no params" do
assert_equal Module, Paperclip::Interpolations.class
end
it "returns the class of the instance" do
+ class Thing ; end
attachment = mock
attachment.expects(:instance).returns(attachment)
- attachment.expects(:class).returns("Thing")
+ attachment.expects(:class).returns(Thing)
assert_equal "things", Paperclip::Interpolations.class(attachment, :style)
end
it "returns the basename of the file" do
attachment = mock
- attachment.expects(:original_filename).returns("one.jpg").times(2)
+ attachment.expects(:original_filename).returns("one.jpg").times(1)
assert_equal "one", Paperclip::Interpolations.basename(attachment, :style)
end
it "returns the extension of the file" do
attachment = mock
@@ -185,18 +186,18 @@
end
it "returns the filename as basename.extension" do
attachment = mock
attachment.expects(:styles).returns({})
- attachment.expects(:original_filename).returns("one.jpg").times(3)
+ attachment.expects(:original_filename).returns("one.jpg").times(2)
assert_equal "one.jpg", Paperclip::Interpolations.filename(attachment, :style)
end
it "returns the filename as basename.extension when format supplied" do
attachment = mock
attachment.expects(:styles).returns({style: {format: :png}})
- attachment.expects(:original_filename).returns("one.jpg").times(2)
+ attachment.expects(:original_filename).returns("one.jpg").times(1)
assert_equal "one.png", Paperclip::Interpolations.filename(attachment, :style)
end
it "returns the filename as basename when extension is blank" do
attachment = mock
@@ -246,7 +247,16 @@
Paperclip::Interpolations.expects(:id).with(:attachment, :style).returns(1234)
Paperclip::Interpolations.expects(:attachment).with(:attachment, :style).returns("attachments")
Paperclip::Interpolations.expects(:notreal).never
value = Paperclip::Interpolations.interpolate(":notreal/:id/:attachment", :attachment, :style)
assert_equal ":notreal/1234/attachments", value
+ end
+
+ it "handles question marks" do
+ Paperclip.interpolates :foo? do
+ "bar"
+ end
+ Paperclip::Interpolations.expects(:fool).never
+ value = Paperclip::Interpolations.interpolate(":fo/:foo?")
+ assert_equal ":fo/bar", value
end
end