From a1e8c70ac7685db87bd45d556e8e0975d880128f Mon Sep 17 00:00:00 2001 From: Nastia Gorokhova-Alekseeva Date: Thu, 30 Dec 2021 17:57:01 +0300 Subject: [PATCH] =?UTF-8?q?=D0=92=D1=8B=D0=BD=D0=BE=D1=81=D0=B8=D0=BC=20?= =?UTF-8?q?=D1=82=D0=B5=D1=81=D1=82=D1=8B=20=D0=BF=D1=80=D0=BE=20=D0=BF?= =?UTF-8?q?=D0=B0=D1=80=D1=81=D0=B5=D1=80=20=D1=81=D1=82=D0=B8=D0=BB=D0=B5?= =?UTF-8?q?=D0=B9=20=D0=B2=20styles=5Fparser=5Ftest?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/styles_parser_test.rb | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 test/styles_parser_test.rb diff --git a/test/styles_parser_test.rb b/test/styles_parser_test.rb new file mode 100644 index 0000000..5be61d9 --- /dev/null +++ b/test/styles_parser_test.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +require 'test_helper' + +class StylesParserTest < Test::Unit::TestCase + context "An attachment with :convert_options" do + setup do + options = { + styles: { + thumb: "100x100", + large: "400x400" + }, + convert_options: { + all: "-do_stuff", + thumb: "-thumbnailize" + } + } + @parser = Paperclip::StylesParser.new(options) + end + + should "report the correct options when sent #extra_options_for(:thumb)" do + assert_equal "-thumbnailize -do_stuff", @parser.extra_options_for(:thumb), @parser.convert_options.inspect + end + + should "report the correct options when sent #extra_options_for(:large)" do + assert_equal "-do_stuff", @parser.extra_options_for(:large) + end + + before_should "call extra_options_for(:thumb/:large)" do + Paperclip::StylesParser.any_instance.expects(:extra_options_for).with(:thumb).at_least_once + Paperclip::StylesParser.any_instance.expects(:extra_options_for).with(:large).at_least_once + end + end +end