<commit_before>require "rails_helper"

describe Admin::CustomersController, type: :controller do
  describe "GET index" do
    it "passes all customers to the view" do
      customer = create(:customer)

      locals = capture_view_locals { get :index }
      expect(locals[:resources]).to eq([customer])
    end

    it "passes the search term to the view" do
      locals = capture_view_locals do
        get :index, search: "foo"
      end

      expect(locals[:search_term]).to eq("foo")
    end

    it "passes the page object to the view" do
      locals = capture_view_locals { get :index }

      expect(locals[:page]).to be_instance_of(Administrate::Page::Collection)
    end
  end

  def expect_locals
    first_call = true

    expect(@controller).to have_received(:render).twice do |options|
      if first_call
        expect(options).not_to be_nil
        yield options[:locals]
      end

      first_call = false
    end
  end

  describe "GET show" do
    it "passes a page object to the view" do
      customer = create(:customer)

      locals = capture_view_locals do
        get :show, id: customer.to_param
      end

      page = locals[:page]
      expect(page).to be_instance_of(Administrate::Page::Show)
      expect(page.resource).to eq(customer)
    end
  end

  describe "GET new" do
    it "passes a new form page object to the view" do
      locals = capture_view_locals { get :new }<commit_msg>Remove unused helper<commit_after>require "rails_helper"

describe Admin::CustomersController, type: :controller do
  describe "GET index" do
    it "passes all customers to the view" do
      customer = create(:customer)

      locals = capture_view_locals { get :index }
      expect(locals[:resources]).to eq([customer])
    end

    it "passes the search term to the view" do
      locals = capture_view_locals do
        get :index, search: "foo"
      end

      expect(locals[:search_term]).to eq("foo")
    end

    it "passes the page object to the view" do
      locals = capture_view_locals { get :index }

      expect(locals[:page]).to be_instance_of(Administrate::Page::Collection)
    end
  end

  describe "GET show" do
    it "passes a page object to the view" do
      customer = create(:customer)

      locals = capture_view_locals do
        get :show, id: customer.to_param
      end

      page = locals[:page]
      expect(page).to be_instance_of(Administrate::Page::Show)
      expect(page.resource).to eq(customer)
    end
  end

  describe "GET new" do
    it "passes a new form page object to the view" do
      locals = capture_view_locals { get :new }
{'fraction_non_alphanumeric': 0.08975834292289989, 'fraction_numerical': 0.0, 'mean_word_length': 2.8694362017804154, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3102464', 'n_tokens_mistral': 804, 'n_tokens_neox': 783, 'n_words': 251}