<commit_before>require "rails_helper"

RSpec.describe DriversController, type: :controller do
  login_admin_as_current_user
  
  # This should return the minimal set of attributes required to create a valid
  # Driver. As you add validations to Driver, be sure to
  # adjust the attributes here as well.
  let(:valid_attributes) {
    attributes_for(:driver, 
      name: '<NAME>',
      phone_number: '(801)4567890', 
      user_id: create(:user, :current_provider => @current_user.current_provider).id,
      address_attributes: attributes_for(:address)
      )
  }

  let(:invalid_attributes) {
    attributes_for(:driver, :phone_number => nil)
  }

  describe "GET #index" do
    it "assigns all drivers for the current provider as @drivers" do
      driver_1 = create(:driver, :provider => @current_user.current_provider, :active => true)
      driver_2 = create(:driver, :active => true)
      get :index, {}
      expect(assigns(:drivers)).to match([driver_1])
    end

    it "default to only active drivers" do
      active_driver = create(:driver, :provider => @current_user.current_provider, :active => true)
      inactive_driver = create(:driver, :provider => @current_user.current_provider, :active => false)
      get :index, {}
      expect(assigns(:drivers)).to match([active_driver])
    end

    it "gets all drivers with show_inactive param as true" do
      active_driver = create(:driver, :provider => @current_user.current_provider, :active => true)
      inactive_driver = create(:driver, :provider => @current_user.current_provider, :active => false)
      get :index, {show_inactive: 'true'}
      expect(assigns(:drivers)).to match([active_driver, inactive_driver])
    end
  end

  describe "GET #show" do
    it "assigns the requested driver as @driver" do
      driver = create(:driver, :provider => @current_user.current_provider)
      get :show, {:id => driver.to_param}
      expect(assigns(:driver)).to eq(driver)
    end
<commit_msg>Update spec<commit_after>require "rails_helper"

RSpec.describe DriversController, type: :controller do
  login_admin_as_current_user
  
  # This should return the minimal set of attributes required to create a valid
  # Driver. As you add validations to Driver, be sure to
  # adjust the attributes here as well.
  let(:valid_attributes) {
    attributes_for(:driver, 
      name: 'test drivers',
      phone_number: '(801)4567890', 
      user_id: create(:user, :current_provider => @current_user.current_provider).id,
      address_attributes: attributes_for(:address)
      )
  }

  let(:invalid_attributes) {
    attributes_for(:driver, :phone_number => nil)
  }

  describe "GET #index" do
    it "assigns all drivers for the current provider as @drivers" do
      driver_1 = create(:driver, :provider => @current_user.current_provider, :active => true)
      driver_2 = create(:driver, :active => true)
      get :index, {}
      expect(assigns(:drivers)).to match([driver_1])
    end

    it "default to only active drivers" do
      active_driver = create(:driver, :provider => @current_user.current_provider, :active => true)
      inactive_driver = create(:driver, :provider => @current_user.current_provider, :active => false)
      get :index, {}
      expect(assigns(:drivers)).to match([active_driver])
    end

    it "gets all drivers with show_inactive param as true" do
      active_driver = create(:driver, :provider => @current_user.current_provider, :active => true)
      inactive_driver = create(:driver, :provider => @current_user.current_provider, :active => false)
      get :index, {show_inactive: 'true'}
      expect(assigns(:drivers)).to match_array([active_driver, inactive_driver])
    end
  end

  describe "GET #show" do
    it "assigns the requested driver as @driver" do
      driver = create(:driver, :provider => @current_user.current_provider)
      get :show, {:id => driver.to_param}
      expect(assigns(:driver)).to eq(driver)
    end

{'fraction_non_alphanumeric': 0.1160081053698075, 'fraction_numerical': 0.006585612968591692, 'mean_word_length': 3.8934324659231723, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 34, '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': '923008', 'n_tokens_mistral': 1193, 'n_tokens_neox': 1149, 'n_words': 324}