This works around a condition where the Issue and the MergeRequest
created by FactoryBoth both had the same ID, which caused `for_target`
to return two records when we only expected one.
This refactors the TodoService class according to our code reuse
guidelines. The resulting code is a wee bit more verbose, but it allows
us to decouple the column names from the input, resulting in fewer
changes being necessary when we change the schema.
One particular noteworthy line in TodoService is the following:
todos_ids = todos.update_state(state)
Technically this is a violation of the guidelines, because
`update_state` is a class method, which services are not supposed to use
(safe for a few allowed ones). I decided to keep this, since there is no
alternative. `update_state` doesn't produce a relation so it doesn't
belong in a Finder, and we can't move it to another Service either. As
such I opted to just use the method directly.
Cases like this may happen more frequently, at which point we should
update our documentation with some sort of recommendation. For now, I
want to refrain from doing so until we have a few more examples.
This refactors the TodosFinder finder according to the new code reuse
rules, as enforced by the CodeReuse cops. I also changed some of the
methods to use regular if statements, instead of assignments and/or
early returns. This results in a more natural flow when reading the
code, and it makes it harder to accidentally return the wrong result.
Improved todo message when an issue is assigned to yourself.
- The new message when an user assign to himself an issue or a mr is: "You
assigned issue xx to yourself"
- The new message when an user adds a todo to himself is: "You added a
todo for issue xx"
- The new message when and user mention himself is: "You mentioned
yourself on issue xx"
- The new message when an user directly address himself is: "You
directly addressed yourself on issue xx"
- The new message when an user mark himself as an approver is: "You set
yourself as an approver for merge request xx"
In 8278b763d9 the default behaviour of annotation
has changes, which was causing a lot of noise in diffs. We decided in #17382
that it is better to get rid of the whole annotate gem, and instead let people
look at schema.rb for the columns in a table.
Fixes: #17382