• Luke Duncalfe's avatar
    Add Note#start_of_discussion? method · ec620639
    Luke Duncalfe authored
    @engwan identified a race condition with how we were using
    Discussion#new_discussion?
    
    - A new discussion is created.
    - A reply to the discussion is quickly posted.
    - When a work is run #new_discussion? and would now return false
      because the Discussion has 2 notes.
    
    As he suggested:
    
    > I think we should remove Discussion#new_discussion? and instead have
    > something like Note#start_of_discussion? which checks if the current
    > note is the first note of a discussion.
    
    This method replaces Discussion#new_discussion? with a more reliable
    method of checking if a note is the start of a discussion, and updates
    it use in the codebase.
    
    In his review, @oswaldo identified a method with the same functionality
    existed in `DiffNote#discussion_first_note?` already. This MR removes
    that method, as DiffNote inherits from Note.
    
    https://gitlab.com/gitlab-org/gitlab/issues/36329
    ec620639
note_spec.rb 34.8 KB