Sha256: f46a524cb4f205a4be625c4be3e1d3471a5d31f224ffad97f6e847285a59d871

Contents?: true

Size: 973 Bytes

Versions: 4

Compression:

Stored size: 973 Bytes

Contents

require 'spec_helper'

describe HighVoltage::PagesController, '#action_caching' do
  let(:page_name) { :exists }

  context 'action_caching set to true' do
    after do
      set_action_caching_without_deprecation(false)
    end

    it 'caches the action' do
      allow(controller).to receive(:_save_fragment)
      set_action_caching_without_deprecation(true)

      get :show, id: page_name

      expect(controller).to have_received(:_save_fragment)
        .with("test.host#{page_path(page_name)}", {})
    end
  end

  context 'action_caching set to false' do
    it 'does not cache the action' do
      allow(controller).to receive(:_save_fragment)
      set_action_caching_without_deprecation(false)

      get :show, id: page_name

      expect(controller).not_to have_received(:_save_fragment)
    end
  end

  def set_action_caching_without_deprecation(value)
    ActiveSupport::Deprecation.silence do
      HighVoltage.action_caching = value
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
high_voltage-2.4.0 spec/controllers/action_caching_controller_spec.rb
high_voltage-2.3.0 spec/controllers/action_caching_controller_spec.rb
high_voltage-2.2.1 spec/controllers/action_caching_controller_spec.rb
high_voltage-2.2.0 spec/controllers/action_caching_controller_spec.rb