Nuclear state densities are important inputs to statistical models of compound-nucleus reactions. State densities are often calculated with self-consistent mean-field approximations that do not include important correlations and have to be augmented with empirical collective enhancement factors. Here, we benchmark the static-path plus random-phase approximation (SPA+RPA) to the state density in a chain of samarium isotopes $^{148-155}$Sm against exact results (up to statistical errors) obtained with the shell model Monte Carlo (SMMC) method. The SPA+RPA method incorporates all static fluctuations beyond the mean field together with small-amplitude quantal fluctuations around each static fluctuation. Using a pairing plus quadrupole interaction, we show that the SPA+RPA state densities agree well with the exact SMMC densities for both the even- and odd-mass isotopes. For the even-mass isotopes, we also compare our results with mean-field state densities calculated with the finite-temperature Hartree-Fock-Bogoliubov (HFB) approximation. We find that the SPA+RPA repairs the deficiencies of the mean-field approximation associated with broken rotational symmetry in deformed nuclei and the violation of particle-number conservation in the pairing condensate. In particular, in deformed nuclei the SPA+RPA reproduces the rotational enhancement of the state density relative to the mean-field state density.