Is there a nice simple guide to how gym battles and training works?
Gym : if it's your teams gym
Battle the lowest guy with whomever you pick, win to increase XP if XP increases the gym level, then you can add a Pokemon of your choice to that gym it's now got an extra slot. The more slots the more xp must rise to add another slot.
If it's another teams gym
Choose to battle, re order the Six by tap on one, tap who you want in that slot and repeat: then battle: just tap tap tap fast and if the blue bar under the blue blocks fills up long press to special attack, keep defeating gym pokemons until you defeat them all or all your guys die. Defeat at least one to knock xp off the gym keep healing and repeating this until xp drops so far you have one gym monster left, defeat him and then the gym is empty, put your choice in the empty gym, before someon else grabs it.
That's it.
Normally in an hour to several hours or a day, the gym is turned over and you get your Pokemon back the symbol next to it in the list vanishes and the shop reward stops saying "1" on it. (Or "2" if you have two gyms, etc)
Imo after the first few times for the lolz it isn't worth doing. Any of it. For one gyms get turned over you don't collect more than the once 10 gold piece bonus and for another the battling is tedious.