I suppose this is agnostic to what platform you are building your application in. For arguments sake, I am using Ruby on Rails. Here's the problem. I have two models which are tightly coupled, and by tightly coupled I mean they are in a has_many
relationship. Hypothetically, let's say the two models are the following:
- User model
- Skill model
A user has many skills. In this particular application, the Skill can only belong to one user. Once the skill has reached a certain level of mastery, I would like to increase the user's achievements attribute by one. Very straight forward problem to hash out in as far as an implementation goes.
My question is, where does the testing for this logic fit best? Does it go into user_test.rb? skill_test.rb? My initial thought is that since it is the individual skill that will update the counter for the user, all testing should go into the skill test. My other thought is, who really cares as long as the test is there in the first place? Is there a right or wrong here?