I didn't really have a problem with how McCoy treated Spock in G7, since a) McCoy's a senior officer, so he's got the rank to be able to address Spock on a more equal footing, and b) he's been dealing with Spock long enough that he's more or less earned the right to rag on him from time to time. Besides, McCoy's picking on Spock was to drive home the point that Spock's logical approach to the situation was failing miserably. Lt. Boma was just plain pissed off, and completely out of line (which is why both McCoy and Scotty shut his snotty ass down when he popped off with that line, "I'm tired of this machine!").
In short, McCoy had racked up enough brownie points to entitle him to pick on Spock. Boma hadn't.
Okay, but you see, the fact that McCoy and Spock were "friends" is even MORE reason that McCoy should have behaved better... because yeah, they kid and stuff all the time, but number one, Spock IS IN COMMAND here. Number two, McCoy, seeing how Lt. Boma and the others were treating Spock should have manned up, and backed Spock's orders, even though he may not like them.
For McCoy to do what he did showed a glaring lack of professionalism, and a great degree of childish immaturity. Imagine how many MORE points McCoy could have scored with Spock, as both an officer and a human, if when they got back to the ship, Spock was able to report to Kirk that the Doctor carried himself in the finest tradition of an officer... he focused on the task at hand, followed orders, and backed his superior officer. Instead, what we got was McCoy as a whiny little bitch.