<commit_before>require 'rails_helper'

# describe LocalitiesController, type: :controller do
#   before(:example) do
#     sign_in_user(double('user', role?: 'admin'))
#   end
# 
#   describe 'GET :index' do
#     it 'assigns all localities not participating in the event to @localities' do
#       locality_names = create_list(:locality, 2).map(&:city)
#       ev = create(:event_with_registrations, registrations_count: 1)
#       loc_with_registration = ev.registrations.first.locality
# 
#       get :index
# 
#       expect(assigns(:localities).map(&:city)).to include(locality_names.first)
#       expect(assigns(:localities).map(&:city)).to include(locality_names.second)
#       expect(assigns(:localities).map(&:city)).to_not include(loc_with_registration)
#     end
# 
#     it 'assigns all event localities to @event_localities' do
#       event = create(:event_with_registrations, ensure_unique_locality: false)
#       event_localities = event.localities.map(&:city)
# 
#       get :index
# 
#       expect(assigns(:event_localities)).to match_array([event_localities])
#     end
#   end
# end<commit_msg>Fix get :index call - add missing event id. Passing tests.<commit_after>require 'rails_helper'

describe Events::LocalitiesController, type: :controller do
  before(:example) do
    sign_in_user(double('user', role?: 'admin'))
  end

  describe 'GET :index' do
    it 'assigns all localities not participating in the event to @localities' do
      locality_names = create_list(:locality, 2).map(&:city)
      event = create(:event_with_registrations, registrations_count: 1)
      loc_with_registration = event.registrations.first.locality

      get :index, event_id: event.id

      expect(assigns(:localities).map(&:city)).to include(locality_names.first)
      expect(assigns(:localities).map(&:city)).to include(locality_names.second)
      expect(assigns(:localities).map(&:city)).to_not include(loc_with_registration)
    end

    it 'assigns all event localities to @event_localities' do
      event = create(:event_with_registrations, ensure_unique_locality: false)

      get :index, event_id: event.id

      expect(assigns(:event_localities)).to match_array(event.localities)
    end
  end
end
{'fraction_non_alphanumeric': 0.11965811965811966, 'fraction_numerical': 0.001799370220422852, 'mean_word_length': 4.371980676328502, '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': '368276', 'n_tokens_mistral': 710, 'n_tokens_neox': 688, 'n_words': 146}