Project

General

Profile

Newb Question - Intuition on project model testing & project_nested_set lft rgt

Added by Steve EIghan over 8 years ago

I'm new to rails development and testing. I've been working on a plugin and started creating model tests for my plugin using minitest. I ran into an issue where my fixture didn't include lft and rgt values. After spending a bit of time trying to trace the issue, I took a look at the fixtures for the Redmine project tests. Seeing that those were explicitly stated I added those to my fixture and it worked. Also, I tried including validates_presence_of for lft and rgt in a patch for the project model and that threw a descriptive error when lft and rgt weren't included in the fixture. My thinking is that the errors could have saved me some time up front when initially trying to get my unit test up and running.

My question is, why was the model designed without a 'validates_presence_of' for lft and rgt? From my rudimentary understanding of testing so far, I would have thought rgt and lft would be in the project class spec such that presence would be validated. Then a corresponding test would be built to test the validation.

Feeling as though I am wandering around in the dark on this stuff, so any guidance is much appreciated.

Cheers,

Steve