Sha256: 20857d4201b48afbaaf573d413e20250b5d5665babda9a0eac82882186cfc12b

Contents?: true

Size: 1.12 KB

Versions: 2

Compression:

Stored size: 1.12 KB

Contents

require './spec/rails_helper'

describe ActionView::Base do
  let(:path) { ActionView::FileSystemResolver.new('./spec/fixtures') }
  let(:view_paths) { ActionView::PathSet.new([path]) }
  let(:view) do
    clazz = if ActionPack::VERSION::MAJOR >= 7
      ActionView::Base.with_empty_template_cache
    else
      ActionView::Base
    end
    clazz.new(ActionView::LookupContext.new(view_paths), [], nil)
  end
  let(:version_override) { nil }
  subject { view.render(template: 'templates/versioned', versions: version_override) }

  context 'with a 0 version' do
    before { view.lookup_context.versions = [:v0] }

    it { is_expected.to eq 'template' }
  end

  context 'with the version override set' do
    let(:version_override) { :v1 }

    it { is_expected.to eq 'template v1' }
  end

  context 'with an older version in the lookup context' do
    before { view.lookup_context.versions = [:v2] }

    it { is_expected.to eq 'template v2' }
  end

  context 'with a v4 requested, but only highest templates is v3' do
    before { view.lookup_context.versions = [:v4,:v3,:v2,:v1] }

    it { is_expected.to eq 'template v3' }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
versioncake-4.1.1 spec/integration/view/render_spec.rb
versioncake-4.1.0 spec/integration/view/render_spec.rb