Sha256: 558bda712bebe9c49a63221c56c67d98e8d41db4fc6457a1b85ac9920ea7d5df

Contents?: true

Size: 1.49 KB

Versions: 11

Compression:

Stored size: 1.49 KB

Contents

require 'spec_helper'

describe Premailer::Rails::CSSLoaders::AssetPipelineLoader do
  before do
    allow(Rails.configuration)
      .to receive(:assets).and_return(double(prefix: '/assets'))
    allow(Rails.configuration).to receive(:relative_url_root).and_return(nil)
  end

  describe ".file_name" do
    subject do
      Premailer::Rails::CSSLoaders::AssetPipelineLoader.file_name(asset)
    end

    context "when asset file path contains prefix" do
      let(:asset) { '/assets/application.css' }
      it { is_expected.to eq('application.css') }
    end

    context "when asset file path contains prefix and relative_url_root is set" do
      before do
        allow(Rails.configuration)
          .to receive(:relative_url_root).and_return('/foo')
      end

      let(:asset) { '/foo/assets/application.css' }
      it { is_expected.to eq('application.css') }
    end

    context "when asset file path contains 32 chars fingerprint" do
      let(:asset) { 'application-6776f581a4329e299531e1d52aa59832.css' }
      it { is_expected.to eq('application.css') }
    end

    context "when asset file path contains 64 chars fingerprint" do
      let(:asset) { 'application-02275ccb3fd0c11615bbfb11c99ea123ca2287e75045fe7b72cefafb880dad2b.css' }
      it { is_expected.to eq('application.css') }
    end

    context "when asset file page contains numbers, but not a fingerprint" do
      let(:asset) { 'test/20130708152545-foo-bar.css' }
      it { is_expected.to eq("test/20130708152545-foo-bar.css") }
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
premailer-rails-1.11.1 spec/unit/css_loaders/asset_pipeline_loader_spec.rb
premailer-rails-1.11.0 spec/unit/css_loaders/asset_pipeline_loader_spec.rb
premailer-rails-1.10.3 spec/unit/css_loaders/asset_pipeline_loader_spec.rb
premailer-rails-1.10.2 spec/unit/css_loaders/asset_pipeline_loader_spec.rb
premailer-rails-1.10.1 spec/unit/css_loaders/asset_pipeline_loader_spec.rb
premailer-rails-1.10.0 spec/unit/css_loaders/asset_pipeline_loader_spec.rb
premailer-rails-1.9.7 spec/unit/css_loaders/asset_pipeline_loader_spec.rb
premailer-rails-1.9.6 spec/unit/css_loaders/asset_pipeline_loader_spec.rb
premailer-rails-1.9.5 spec/unit/css_loaders/asset_pipeline_loader_spec.rb
premailer-rails-1.9.4 spec/unit/css_loaders/asset_pipeline_loader_spec.rb
premailer-rails-1.9.3 spec/unit/css_loaders/asset_pipeline_loader_spec.rb