require "rails_helper"

RSpec.describe Admin::MasqueradesController, type: :controller do
  render_views

  let!(:current_user) { create(:user, :admin) }
  let!(:unprivileged_user) { create(:user) }

  before do
    sign_in(current_user)
  end

  describe "#create" do
    it "redirects to the first page" do
      post :create, params: { user_id: unprivileged_user.id }

      expect(response).to redirect_to signed_in_root_path
    end
  end

  describe "#destroy" do
    it "returns to the users page" do
      post :create, params: { user_id: unprivileged_user.id }

      delete :destroy

      expect(response).to redirect_to admin_users_path
    end
  end
end
