describe Manager::DemandesController, type: :controller do
  let(:super_admin) { create(:super_admin) }

  describe 'GET #index' do
    before do
      sign_in super_admin
    end

    it "display pending demandes" do
      approved_administrateur = create(:administrateur, email: "approved@example.com")
      pending_demande = { email: 'pending@example.com' }
      demandes = [{ email: approved_administrateur.email }, pending_demande]
      allow(PipedriveService).to receive(:get_demandes).and_return(demandes)

      get :index

      expect(assigns(:pending_demandes)).to eq([pending_demande])
    end
  end
end
