Heat the oil in a large saucepan over medium heat. Saute the diced onion for 3-4 minutes, until it starts to soften.
Reduce heat to medium-low, and add the enchilada sauce, black beans, and refried beans to the saucepan. Stir slowly until mixed thoroughly.
Add any "extra goodies" to the sauce and continue heating and stirring until it starts to simmer. Be sure to stir continuously, else it may start to splatter as it comes to a boil.
The goal is not necessarily to cook the veggies and sauce, rather to be sure it's evenly mixed and hot. If using fresh spinach, you'll want the leaves to be wilted/softened, so they don't take up too much space.
Once everything is mixed well, turn off heat and start layering the casserole in a lightly greased 9x13 baking pan.
First, add thin layer of the sauce to the bottom (if you start with tortillas first, they may burn). Add a layer of tortillas (see diagram, below). Then alternate sauce and tortillas until there's about 1/4" of space left (or you run out of sauce or tortillas!), ending with a layer of sauce on top. Be sure all the tortillas are covered by sauce; any tortilla that's not covered will dry out.
Sprinkle the cheese on top, and cover with aluminum foil. "Tent" the foil so it's not resting on the cheese (this makes it easier to remove later).
Bake at 350°F for 40 minutes. (If doubling the recipe, or using a deeper pan, you may want to bake a little longer). Remove foil, and bake for another 10 minutes, until cheese begins to brown. Allow to cool for at least ten minutes before serving.