According to a study recently published in the journal Neuroscience and Biobehavioral Reviews and highlighted by New Scientist, dogs can tell when someone's being a jerk, and they use that information when deciding how to interact with the humans around them.
James Anderson of Kyoto University tested dogs and monkeys to see if their behavior changed in reaction to 'moral' situations. In the study, dogs watched their owners struggling to open a container while an actor either helped, acted passively, or refused to lend them a hand. When one of the bystanders had helped open the container, the dogs didn't really favor the helpful one over the passive one - they were just as likely to take the treat from either of the two. But in the second condition, when the active bystander was actively being a jerk, the dogs showed a clear preference, shunning them in favor of the one who didn't do anything.