There are no exact conditions for gaining and losing ranking points (other than you only gain when you win and only lose when you, well, lose).
Behind the scenes, ranks aren't actually used for matchmaking. Instead, there's a hidden MMR (MatchMaking Rating) score, and the matchmaker aims to create matchups where both teams have MMR values that are broadly similar (although there is some debate as to how well it is achieving that goal). When you win, your MMR goes up, and when you lose it goes down - but you don't get to see this since the MMR is completely hidden.
When you win a ranked game, Blizzard looks at the two team's MMR scores and takes into account how likely you were to win that game. If it was very likely, since your team had a higher MMR score, you will receive less ranking points than if you were facing a team with a similar or even lower MMR. Similarly, if you lose to a team with a far higher MMR, you won't lose many ranking points since that was the expected result.
If you're losing a game and then not losing any ranking points, the likely reason is that you lost to a team with a far higher MMR than yours, to the point where Blizzard's algorithm decides it shouldn't have any impact whatsoever on your ranking score.
You do occasionally see people claiming that anybody can get to rank 1, since your ranking score goes up more for a win than it goes down for a loss. This is only true because they're starting out with the "default" MMR which assumes a lower skill level than their true level. Thus, they get matched with inferior opposition, win most of their games, and Blizzard hand them a lot of ranking points because their algorithm assumes they were unlikely to win. Once their MMR gets to the point where it reflects their real skill level, and their win rate comes down to roughly the 50% mark because they're now facing similar opponents, they'll find they're getting about the same for a win as they get for a loss. A lot of good-but-not-great players start out by getting a ton of points, assume rank 1 is easy, then get stuck at (for example) rank 8 because suddenly they're no longer getting far more for a win than for a loss.