Introduce a concept of "state" to projects #1473
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We want to be able to mark projects as "deleted", but not actually delete the record from the database. We intend to add a deleted state to projects .
Ahead of this, we have decided to add a
state
to projects, and enumerate it for the various different states a project can be in. For now, this is "active" and "completed"Add an enumerator to projects - 0 for active (default) and 1 for completed.
As the state is an enumerator, we get the scope Project.completed for free now. Due to Rails magic, we also get Project.not_completed - anything not in the completed state. In the first commit, we keep Project.not_completed as is; in the second, we replace Project.not_completed with the more semantic Project.active.
As the original Project.completed scope had an order (ordering by completed_at date) we have had to split this ordering out and add it as a new scope.
We have added the new state to the project factories, and updated the relevant tests.
Unfortunately this was the smallest single commit we could make for this change.
(No user-facing changes in this commit)