summaryrefslogtreecommitdiff
path: root/spec/lib/banzai/reference_parser
Commit message (Collapse)AuthorAgeFilesLines
* Add latest changes from gitlab-org/gitlab@12-6-stable-eeGitLab Bot2019-12-206-18/+33
|
* Add latest changes from gitlab-org/gitlab@12-4-stable-eeGitLab Bot2019-10-2212-0/+152
|
* Add frozen_string_literal to spec/lib (part 1)Thong Kuah2019-07-2610-0/+20
| | | | | Using the sed script from https://gitlab.com/gitlab-org/gitlab-ce/issues/59758
* Preload project features in reference parserJan Provaznik2018-09-301-0/+18
| | | | | | | | | | | Preloading of project_features mitigates N+1 queries when checking references in other projects. When loading projects for resources referenced in comments it makes sense to include also associated project_features because in the following step (`can_read_reference?(user, projects[node], node)`) project features is used for checking permissions for the given project.
* Use `Gitlab::SafeRequestStore` in more placesMichael Kozono2018-09-241-2/+1
| | | | | | Even if it doesn’t save lines of code, since people will tend to use code they’ve seen. And `SafeRequestStore` is safer since you don’t have to remember to check `RequestStore.active?`.
* Add frozen_string_literal to recently-added files from the communitySean McGivern2018-08-101-0/+2
|
* Add a spec for a user viewing a reference to a private projectReuben Pereira2018-07-031-2/+20
|
* A working implementation of a project reference filter which links project ↵Reuben Pereira2018-06-301-0/+30
| | | | references to project profile.
* Fix reference filters in group contextJan Provaznik2018-04-121-4/+10
| | | | | | | | | Since !18150 abstract reference filter supports also `group` as a resource parent (not only `project`). Some reference filters, which inherit from abstract filter, depend on parent being `project` when checking a reference. This patch adds explicit check of parent class to the given filters.
* Support Markdown rendering using multiple projectsrendering-markdown-multiple-projectsYorick Peterse2018-04-1110-11/+25
| | | | | | | | | | | | | | | | | | | This refactors the Markdown pipeline so it supports the rendering of multiple documents that may belong to different projects. An example of where this happens is when displaying the event feed of a group. In this case we retrieve events for all projects in the group. Previously we would group events per project and render these chunks separately, but this would result in many SQL queries being executed. By extending the Markdown pipeline to support this out of the box we can drastically reduce the number of SQL queries. To achieve this we introduce a new object to the pipeline: Banzai::RenderContext. This object simply wraps two other objects: an optional Project instance, and an optional User instance. On its own this wouldn't be very helpful, but a RenderContext can also be used to associate HTML documents with specific Project instances. This work is done in Banzai::ObjectRenderer and allows us to reuse as many queries (and results) as possible.
* Fix N+1 in MergeRequestParserSean McGivern2018-04-052-4/+49
| | | | | | | | read_project can be prevented by a very expensive condition, which we want to avoid, while still not writing manual SQL queries. read_project_for_iids is used by read_issue_iid and read_merge_request_iid to satisfy both of those constraints, and allow the declarative policy runner to use its normal caching strategy.
* Port `read_cross_project` ability from EEBob Van Landuyt2018-02-221-4/+43
|
* Replace '.team << [user, role]' with 'add_role(user)' in specs36782-replace-team-user-role-with-add_role-user-in-specsblackst0ne2017-12-221-3/+3
|
* Refactor banzai to support referencing from group contextce-backport-3615Jarka Kadlecova2017-12-061-2/+2
|
* Change all `:empty_project` to `:project`rs-empty_project-defaultRobert Speicher2017-08-029-14/+14
|
* Remove superfluous lib: true, type: redis, service: true, models: true, ↵Rémy Coutable2017-07-2710-10/+10
| | | | | | services: true, no_db: true, api: true Signed-off-by: Rémy Coutable <remy@rymai.me>
* Improve support for external issue referencesadam-external-issue-references-spikeAdam Niedzielski2017-06-301-10/+0
|
* Enable Style/DotPosition Rubocop :cop:Grzegorz Bizon2017-06-215-116/+116
|
* Merge branch 'dm-fix-parser-cache' into 'master'Sean McGivern2017-06-151-1/+1
|\ | | | | | | | | Don't return nil for missing objects from parser cache See merge request !12168
| * Don't return nil for missing objects from parser cachedm-fix-parser-cacheDouwe Maan2017-06-141-1/+1
| |
* | Correct RSpec/SingleLineHook cop offensesRobert Speicher2017-06-145-5/+15
|/
* Use :request_store hooks on specsuse-request-store-helper-instead-actual-codeOswaldo Ferreira2017-06-091-10/+1
|
* Merge branch '25934-project-snippet-vis' into 'security-9-2'DJ Mountney2017-06-082-6/+185
| | | | | | Fix visibility when referencing snippets See merge request !2101
* Fix /unsubscribe slash command creating extra todos33032-invalid-you-directly-addressed-yourself-todo-when-using-unsubscribeSean McGivern2017-05-301-1/+24
| | | | | | | | | | | | | | | | | | | | | | The /unsubscribe slash command means that we check if the current user is subscribed to the issuable without having an explicit subscription. That means that we use the UserParser to find references to them in the notes. The UserParser (and all parsers inheriting from BaseParser) use RequestStore to cache ActiveRecord objects, so that we don't need to load the User object each time, if we're parsing references a bunch of times in the same request. However, it was always returning _all_ of the previously cached items, not just the ones matching the IDs passed. This would mean that we did two runs through with UserParser if you were mentioned in a comment, and then mentioned someone else in your comment while using /unsubscribe: 1. Because /unsubscribe was used, we see if you were mentioned in any comments. 2. Because you mentioned someone, we find them - but we would also get back your user, even if you didn't mention yourself. This would have the effect of creating a mention or directly addressed todo for yourself incorrectly. The fix is simple: only return values from the cache matching the IDs passed.
* Fix regression in rendering Markdown references that do not existsh-fix-base-parserStan Hu2017-04-151-2/+21
| | | | Closes #30972
* Add indication for closed or merged issuables in GFMadam-finish-5993-closed-issuableAdam Buckland2017-04-073-5/+34
| | | | | | | | | | | | | | | Example: for issues that are closed, the links will now show '[closed]' following the issue number. This is done as post-process after the markdown has been loaded from the cache as the status of the issue may change between the cache being populated and the content being displayed. In order to avoid N+1 queries problem when rendering notes ObjectRenderer populates the cache of referenced issuables for all notes at once, before the post processing phase. As a part of this change, the Banzai BaseParser#grouped_objects_for_nodes method has been refactored to return a Hash utilising the node itself as the key, since this was a common pattern of usage for this method.
* Use `:empty_project` where possible throughout spec/librs-empty_project-libRobert Speicher2017-01-251-3/+3
|
* Parse JIRA issue references even if Issue Tracker is disabledFelipe Artur2016-12-291-1/+11
|
* Merge branch 'issue_23548_dev' into 'master'Douwe Maan2016-11-0910-36/+72
| | | | | | | | | | | | | | | | | | | | | disable markdown in comments when referencing disabled features fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/23548 This MR prevents the following references when tool is disabled: - issues - snippets - commits - when repo is disabled - commit range - when repo is disabled - milestones This MR does not prevent references to repository files, since they are just markdown links and don't leak information. See merge request !2011 Signed-off-by: Rémy Coutable <remy@rymai.me>
* remove Ability.abilitieshttp://jneen.net/2016-08-302-9/+9
|
* Method for returning issues readable by a userability-batch-issue-checkingYorick Peterse2016-07-291-6/+6
| | | | | | | | | | | | | The method Ability.issues_readable_by_user takes a list of users and an optional user and returns an Array of issues readable by said user. This method in turn is used by Banzai::ReferenceParser::IssueParser#nodes_visible_to_user so this method no longer needs to get all the available abilities just to check if a user has the "read_issue" ability. To test this I benchmarked an issue with 222 comments on my development environment. Using these changes the time spent in nodes_visible_to_user was reduced from around 120 ms to around 40 ms.
* Re-use queries in reference parsersreuse-queries-in-reference-parsersYorick Peterse2016-07-081-0/+75
| | | | | This caches various queries to ensure that multiple reference extraction runs re-use any objects queried in previous runs.
* Split Markdown rendering & reference gatheringYorick Peterse2016-05-2610-0/+923
This splits the Markdown rendering and reference extraction phases into two distinct code bases. The reference extraction phase no longer relies on the html-pipeline Gem (and any related code) and allows for extracting of references from multiple HTML nodes in a single pass. This means that if you want to extract user references from 200 comments you no longer need to run 200 times N number of queries, instead only a handful of queries may be needed.