501 copy component fails when selecting a newer srg version and a control has been previously deleted in the source component #503
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.
Fixed bug #501
Refactored the logic of
Component#duplicate
andComponent#from_mapping
to correctly copy a component and update the rules based a given new srg:where
&pluck
:where
&pluck
applies on the database level. So if the model instance the method is being called on is not persisted, the return value is an empty list. Switched to use enumerator methodsselect
andmap
instead to get the expected behavior.#from_mapping
method to correctly check if a new list of rule versions was provided for import or if a null value was givenRule#rule_id
are generated when importing new rules to always generate uniquerule_id
for a rule in a given component:rule_id
was generated based on the (total count of rules + 1) of the component. This created an error due the uniqueness constraint ofrule_id
in a given component in the scenario when some rules have been deleted from the component. Fixed it to generate newrule_id
based on thelargest_rule_id
in the given component.e.g. scenario:
rule_id
'000001' from the componenttotal count = 2
* Generating new
rule_id
based ontotal count + 1
will generate '000003' which already exist => causing db error* Generating new
rule_id
based onlargest_rule_id + 1
will generate '000004'