<commit_before>describe Manager::AdministrateursController, type: :controller do
  let(:administration) { create(:administration) }

  describe 'GET #new' do
    render_views
    before do
      sign_in administration
    end

    it 'displays form to create a new admin' do
      get :new
      expect(response).to be_success
    end
  end

  describe 'POST #create' do
    let(:email) { '<EMAIL>' }
    let(:password) { '<PASSWORD>' }

    before do
      sign_in administration
    end

    subject { post :create, params: { administrateur: { email: email } } }

    context 'when email and password are correct' do
      it 'add new administrateur in database' do
        expect { subject }.to change(Administrateur, :count).by(1)
      end

      it 'alert new mail are send' do
        expect(AdministrationMailer).to receive(:new_admin_email).and_return(AdministrationMailer)
        expect(AdministrationMailer).to receive(:deliver_later)
        expect(AdministrationMailer).to receive(:invite_admin).and_return(AdministrationMailer)
        expect(AdministrationMailer).to receive(:deliver_later)
        subject
      end
    end

    context 'when email or password are missing' do
      let(:email) { '' }

      it { expect { subject }.to change(Administrateur, :count).by(0) }
    end
  end

  describe '#delete' do
    let!(:admin) { create(:administrateur) }

    before { sign_in administration }

    subject { delete :delete, params: { id: admin.id } }

    it 'deletes the admin' do
      subject

      expect(Administrateur.find_by(id: admin.id)).to be_nil
    end
  end
end<commit_msg>refactor<commit_after>describe Manager::AdministrateursController, type: :controller do
  let(:administration) { create(:administration) }

  before do
    sign_in administration
  end

  describe 'GET #new' do
    render_views
    it 'displays form to create a new admin' do
      get :new
      expect(response).to be_success
    end
  end

  describe 'POST #create' do
    let(:email) { '<EMAIL>' }
    let(:password) { '<PASSWORD>' }

    subject { post :create, params: { administrateur: { email: email } } }

    context 'when email and password are correct' do
      it 'add new administrateur in database' do
        expect { subject }.to change(Administrateur, :count).by(1)
      end

      it 'alert new mail are send' do
        expect(AdministrationMailer).to receive(:new_admin_email).and_return(AdministrationMailer)
        expect(AdministrationMailer).to receive(:deliver_later)
        expect(AdministrationMailer).to receive(:invite_admin).and_return(AdministrationMailer)
        expect(AdministrationMailer).to receive(:deliver_later)
        subject
      end
    end

    context 'when email or password are missing' do
      let(:email) { '' }

      it { expect { subject }.to change(Administrateur, :count).by(0) }
    end
  end

  describe '#delete' do
    let!(:admin) { create(:administrateur) }

    subject { delete :delete, params: { id: admin.id } }

    it 'deletes the admin' do
      subject

      expect(Administrateur.find_by(id: admin.id)).to be_nil
    end
  end
end
{'fraction_non_alphanumeric': 0.10012836970474968, 'fraction_numerical': 0.0012836970474967907, 'mean_word_length': 3.08519003931848, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '4330866', 'n_tokens_mistral': 950, 'n_tokens_neox': 903, 'n_words': 259}