Sha256: d4c5d038766c9e24a5a445be03c3c852d7ef8e3dd532c319eac58e92b1fa7357

Contents?: true

Size: 1.4 KB

Versions: 9

Compression:

Stored size: 1.4 KB

Contents

require 'spec_helper'
require 'cloudinary'
require 'action_view'
require 'cloudinary/helper'

helper_class = Class.new do
  include CloudinaryHelper
end

describe CloudinaryHelper do
  let(:helper) { helper_class.new }


  context "#cl_image_upload_tag" do
    let(:options) { {} }
    subject(:input) { helper.cl_image_upload_tag(:image_id, options) }

    before do
      Cloudinary::Utils.stub(:cloudinary_api_url)
      Cloudinary::Utils.stub(:sign_request)
      helper.stub(:build_callback_url)
    end

    it "allow multiple upload" do
      options[:multiple] = true
      expect(input).to include('data-cloudinary-field="image_id[]"')
      expect(input).to include('multiple="multiple"')
    end
  end

  context "#cl_image_tag" do
    subject(:input) { helper.cl_image_tag("sample.jpg", options) }

    context "responsive_width" do
      let(:options) { {responsive_width: true, cloud_name: "test"} }
      it "should use data-src for responsive_width" do
        expect(input).to eq("<img class=\"cld-responsive\" data-src=\"http://res.cloudinary.com/test/image/upload/c_limit,w_auto/sample.jpg\"></img>")
      end
    end

    context "dpr_auto" do
      let(:options) { {dpr: :auto, cloud_name: "test"} }
      it "should use data-src for dpr auto" do
        expect(input).to eq("<img class=\"cld-hidpi\" data-src=\"http://res.cloudinary.com/test/image/upload/dpr_auto/sample.jpg\"></img>")
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
cloudinary-1.0.81 spec/cloudinary_helper_spec.rb
cloudinary-1.0.80 spec/cloudinary_helper_spec.rb
cloudinary-1.0.79 spec/cloudinary_helper_spec.rb
cloudinary-1.0.78 spec/cloudinary_helper_spec.rb
cloudinary-1.0.77 spec/cloudinary_helper_spec.rb
cloudinary-1.0.76 spec/cloudinary_helper_spec.rb
cloudinary-1.0.75 spec/cloudinary_helper_spec.rb
cloudinary-1.0.74 spec/cloudinary_helper_spec.rb
cloudinary-1.0.73 spec/cloudinary_helper_spec.rb