<commit_before>require 'rails_helper'

RSpec.describe ActiveAdmin::ResourceController::Sidebars, type: :controller do
  let(:klass){ Admin::PostsController }

  before do
    @controller = klass.new
  end

  context 'without skip_sidebar! before filter' do
    before do
      ActiveAdmin.register Post
      reload_routes!
    end

    it 'does not set @skip_sidebar' do
      get :index

      expect(controller.instance_variable_get(:@skip_sidebar)).to eq nil
    end
  end

  context 'with skip_sidebar! before_filter' do
    before do
      ActiveAdmin.register Post do
        before_filter :skip_sidebar!
      end
      reload_routes!
    end

    it 'works' do
      get :index

      expect(controller.instance_variable_get(:@skip_sidebar)).to eq true
    end
  end
end unless ActiveAdmin::Dependency.rails < 4
<commit_msg>Extract common setup to a shared context<commit_after>require 'rails_helper'

RSpec.describe ActiveAdmin::ResourceController::Sidebars, type: :controller do
  let(:klass){ Admin::PostsController }

  shared_context 'with post config' do
    before do
      @controller = klass.new

      post_config
      reload_routes!

      get :index
    end
  end

  context 'without skip_sidebar! before filter' do
    include_context 'with post config' do
      let(:post_config) { ActiveAdmin.register Post }
    end

    it 'does not set @skip_sidebar' do
      expect(controller.instance_variable_get(:@skip_sidebar)).to eq nil
    end
  end

  context 'with skip_sidebar! before_filter' do
    include_context 'with post config' do
      let(:post_config) do
        ActiveAdmin.register(Post) { before_filter :skip_sidebar! }
      end
    end

    it 'works' do
      expect(controller.instance_variable_get(:@skip_sidebar)).to eq true
    end
  end
end unless ActiveAdmin::Dependency.rails < 4

{'fraction_non_alphanumeric': 0.07671232876712329, 'fraction_numerical': 0.001095890410958904, 'mean_word_length': 3.2863849765258215, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3862334', 'n_tokens_mistral': 544, 'n_tokens_neox': 524, 'n_words': 153}