Commit graph

12 commits

Author SHA1 Message Date
Patrick Derichs
c9b4dc677a Filter out old system notes for epics 2019-08-28 15:04:23 +02:00
Stan Hu
8044440d7a Eliminate many Gitaly calls in discussions API
Previously, the API to retrieve discussions from merge requests often
generated hundreds of Gitaly calls to determine whether a system note
should be shown to the user. It did this by:

1. Rendering the Markdown
2. Extracting cross-references from the Markdown
3. For cross-references that were commits, a Gitaly FindCommit RPC
   would be issued to validate that the commit exists.

The last step is unnecessary because we don't need to display a commit
if the user doesn't have access to the project in the first place.

`RendersNotes#prepare_notes_for_rendering` is already used in
`MergeRequestsController`, which is why we don't see N+1 Gitaly calls
there. We use it here to optimize the note redaction process.

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/65957
2019-08-15 08:02:30 -07:00
Patrick Derichs
932a9a0c77 Use NotesFinder to fetch notes on API and Controllers
Fix missing iid query on NotesFinder

Changed parameters of find_noteable, 
so changes across a few files were needed.
MergeRequest also requires iid instead of id query

Make NotesFinder fail with RecordNotFound again

Add specs for target_iid

Using RSpec tablesyntax for target_iid specs

Revert "Using RSpec tablesyntax for target_iid specs"

This reverts commit ba45c7f569a.

Allow find_by! here

Fix variable name

Add readable check

Revert "Add readable check"

This reverts commit 9e3a1a7aa39.

Remove unnecessary assignment

Add required changes for EE

Fix parameter count

Reduce code duplication by extracting a noteable module method

The call to find_noteable was redundant so
multiple files and lines have changed in that
commit to use the newly introduced module
method `noteable`.

Replace casecmp with include check

Add parent_type parameter


Revert "Reduce code duplication by extracting
a noteable module method"

This reverts commit 8c0923babff16.

Method is no longer needed

Check whether noteable can be read by user
2019-06-19 10:56:55 +02:00
Bob Van Landuyt
4504959aa6 Make resolvable_types a class method
This turns Notable::RESOLVABLE_TYPES into a
`Notable.resolvable_types`. That allows us to override it in EE.
2019-06-03 16:41:05 +02:00
Sean McGivern
00af4c6d6a Allow replying to an individual note in the API
If you can do this in the UI, you should be able to do it in the API. If
a discussion is not a single note discussion, or it is replyable, you
can reply to it.
2019-05-06 19:48:32 +01:00
Yorick Peterse
654c4dd922
Refactor API noteable types constants
This replaces API::Notes::NOTEABLE_TYPES and
API::Discussions::NOTEABLE_TYPES with class methods defined in a
separate helper modules. This allows EE to extend the list of noteable
types, without having to modify the constant in-place. We can't define
these methods directly in the API classes, as they would be used before
we're able to extend them in EE.
2019-03-04 17:44:56 +01:00
Imre Farkas
b1e070bf49
Fix API::Namespaces to accept namepaces with dots
It also renames the API::PROJECT_ENDPOINT_REQUIREMENTS constant to
API::NAMESPACE_OR_PROJECT_REQUIREMENTS
2018-11-28 12:54:11 +01:00
gfyoung
3836d69119 Enable frozen string in lib/api and lib/backup
Partially addresses #47424.

Had to make changes to spec files because
stubbing methods on frozen objects is a mess
in RSpec and leads to failures:

https://github.com/rspec/rspec-mocks/issues/1190
2018-09-29 21:04:50 -07:00
Yorick Peterse
2039c8280d
Disable existing offenses for the CodeReuse cops
This whitelists all existing offenses for the various CodeReuse cops, of
which most are triggered by the CodeReuse/ActiveRecord cop.
2018-09-11 17:32:00 +02:00
Jan Provaznik
7a76caa5a8 Merge request and commit discussions API 2018-05-01 12:39:44 +00:00
🙈 jacopo beschi 🙉
c6b1043e9d Resolve "Make a Rubocop that forbids returning from a block" 2018-04-18 09:19:40 +00:00
Jan Provaznik
dcdfa04b32 Add discussion API
* adds basic discussions API for issues and snippets
* reorganizes notes specs (so same tests can be used for all noteable types - issues, MRs, snippets)
2018-03-07 12:27:50 +01:00