-
Alex Kalderimis authored
This adds a new model entity `DesignManagement::DesignAtVersion`, which wraps a design and an associated version. Mechanisms are provided for lazy-finding and validation. These do not have mutable properties, and validate the important constraint that they share an issue Finding DesignManagement::DesignAtVersion objects requires querying both the designs and the versions tables, and is at present more expensive than a single fetch. It also returns an Array instead of a relation, since this is not a ActiveModel object. We validate invariants in find, this ensures we never fetch invalid objects. * Validations: - checking that there is both a design and a version - checking that the design and the version have the same issue - checking that both the design and the version have an issue These validations are checked during `find` and when calling `instantiate` * ID It is important for GraphQL and the front-end that the model has an ID that can be used to lookup each combination, and be used to store this identity on the client. * deleted? and status methods These supplement their analogues in DesignManagement::Design with an awareness of the current version. Thus a DesignManagement::DesignAtVersion as of a version in which is was deleted will respond to `deleted?` appropriately. Callers should be be careful to distinguish between `dav.state == :current` and `!dav.deleted?` - as of a version before a design has been created it will respond with: * `#deleted? == false` * `#status == :not_created_yet` Reflecting the fact that this is not deleted because it has not been created yet. This requires changes to the design and version factories to be able to create valid objects with nil issues, a condition that is found when these objects are being imported.
e88fd1a4