summaryrefslogtreecommitdiff
path: root/spec/models/snippet_spec.rb
Commit message (Collapse)AuthorAgeFilesLines
* Add # frozen_string_literal to spec/modelsThong Kuah2019-04-011-0/+2
| | | | Adds `# frozen_string_literal: true` to spec/models ruby files
* Move embeddable? to model to be used outside viewMark Chao2018-12-201-0/+37
|
* Rewrite SnippetsFinder to improve performanceYorick Peterse2018-11-051-0/+211
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This completely rewrites the SnippetsFinder class from the ground up in order to improve its performance. The old code was beyond salvaging. It was complex, included various Rails 5 workarounds, comments that shouldn't be necessary, and most important of all: it produced a really poorly performing database query. As a result, I opted for rewriting the finder from scratch, instead of trying to patch the existing code. Instead of trying to reuse as many existing methods as possible, I opted for defining new methods specifically meant for the SnippetsFinder. This requires some extra code here and there, but allows us to have much more control over the resulting SQL queries. It is these changes that then allow us to produce a _much_ more efficient query. To illustrate how bad the old query was, we will use my own snippets as an example. Currently I have 52 snippets, most of which are global ones. To retrieve these, you would run the following Ruby code: user = User.find_by(username: 'yorickpeterse') SnippetsFinder.new(user, author: user).execute On GitLab.com the resulting query will take between 10 and 15 seconds to run, producing the query plan found at https://explain.depesz.com/s/Y5IX. Apart from the long execution time, the total number of buffers (the sum of all shared hits) is around 185 GB, though the real number is probably (hopefully) much lower as I doubt simply summing these numbers produces the true total number of buffers used. The new query's plan can be found at https://explain.depesz.com/s/wHdN, and this query takes between 10 and 100-ish milliseconds to run. The total number of buffers used is only about 30 MB. Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/52639
* Use fuzzy search with minimum length of 3 characters where appropriatedm-search-patternDouwe Maan2017-11-271-1/+1
|
* Change all `:empty_project` to `:project`rs-empty_project-defaultRobert Speicher2017-08-021-5/+5
|
* Remove superfluous lib: true, type: redis, service: true, models: true, ↵Rémy Coutable2017-07-271-1/+1
| | | | | | services: true, no_db: true, api: true Signed-off-by: Rémy Coutable <remy@rymai.me>
* Merge branch 'snippets-finder-visibility' into 'security'Douwe Maan2017-05-101-40/+0
| | | | | | Refactor snippets finder & dont return internal snippets for external users See merge request !2094
* Use blob viewers for snippetsDouwe Maan2017-04-301-1/+12
|
* Spam check only when spammable attributes have changedOswaldo Ferreira2017-03-211-0/+43
|
* Use `:empty_project` where possible in model specsrs-empty_project-modelsRobert Speicher2017-01-261-3/+3
|
* Merge branch '25209-improve-length-validators' into 'master' Rémy Coutable2016-12-071-2/+22
|\ | | | | | | | | | | | | Use :maximum instead of :within for length validators with a 0..N range Closes #25209 See merge request !7894
| * Use :maximum instead of :within for length validators with a 0..N range25209-improve-length-validatorsRémy Coutable2016-12-061-2/+22
| | | | | | | | Signed-off-by: Rémy Coutable <remy@rymai.me>
* | Add shorthand support to gitlab markdown referencesOswaldo Ferreira2016-12-021-7/+22
|/
* Add markdown cache columns to the database, but don't use them yetNick Thomas2016-10-071-0/+7
| | | | | | | | | | | | This commit adds a number of _html columns and, with the exception of Note, starts updating them whenever the content of their partner fields changes. Note has a collision with the note_html attr_accessor; that will be fixed later A background worker for clearing these cache columns is also introduced - use `rake cache:clear` to set it off. You can clear the database or Redis caches separately by running `rake cache:clear:db` or `rake cache:clear:redis`, respectively.
* Snippets get award emoji! :thumbsup:Z.J. van de Weg2016-09-191-0/+2
|
* Fix visibility of private project snippets for members when searchingDouglas Barbosa Alexandre2016-06-221-8/+28
|
* Fix internal snippets can be searched by anyoneDouglas Barbosa Alexandre2016-06-221-1/+21
|
* Refactor ParticipableYorick Peterse2016-06-011-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are several changes to this module: 1. The use of an explicit stack in Participable#participants 2. Proc behaviour has been changed 3. Batch permissions checking == Explicit Stack Participable#participants no longer uses recursion to process "self" and all child objects, instead it uses an Array and processes objects in breadth-first order. This allows us to for example create a single Gitlab::ReferenceExtractor instance and pass this to any Procs. Re-using a ReferenceExtractor removes the need for running potentially many SQL queries every time a Proc is called on a new object. == Proc Behaviour Changed Previously a Proc in Participable was expected to return an Array of User instances. This has been changed and instead it's now expected that a Proc modifies the Gitlab::ReferenceExtractor passed to it. The return value of the Proc is ignored. == Permissions Checking The method Participable#participants uses Ability.users_that_can_read_project to check if the returned users have access to the project of "self" _without_ running multiple SQL queries for every user.
* Remove the annotate gem and delete old annotationsJeroen van Baarsen2016-05-091-16/+0
| | | | | | | | | In 8278b763d96ef10c6494409b18b7eb541463af29 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
* Use ILIKE/LIKE for searching snippetsYorick Peterse2016-03-111-0/+44
| | | | | | Previously this used a regular LIKE which is case-sensitive on PostgreSQL. This ensures that for both PostgreSQL and MySQL the searching is case-insensitive similar to searching for projects.
* Remove `Snippet#expires_at`rs-snippets-dont-expireRobert Speicher2016-03-051-1/+0
| | | | | | This was removed from the interface in https://github.com/gitlabhq/gitlabhq/pull/6027 but its implementation lingered around for two years.
* Tag model specsDouwe Maan2015-12-091-1/+1
|
* Make snippet filename optional.Nicolas2015-06-201-1/+0
| | | | Fixes #2384.
* ensure_length_of -> validate_length_ofRobert Speicher2015-06-101-2/+2
|
* Minor model spec cleanupsRobert Speicher2015-05-261-5/+5
| | | | Snippet model was missing project association
* Add `to_reference` for models that support referencesRobert Speicher2015-05-261-1/+25
| | | | | Now there is a single source of information for which attribute a model uses to be referenced, and its special character.
* Updated rspec to rspec 3.x syntaxJeroen van Baarsen2015-02-121-8/+8
| | | | Signed-off-by: Jeroen van Baarsen <jeroenvanbaarsen@gmail.com>
* annotateValery Sizov2014-10-091-11/+11
|
* Remove mass assgnment specsDmitriy Zaporozhets2014-06-261-1/+0
| | | | Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
* Re-annotate modelsDmitriy Zaporozhets2014-04-091-3/+3
| | | | Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
* ReannotateDmitriy Zaporozhets2013-08-211-3/+3
|
* AnnotatedDmitriy Zaporozhets2013-06-191-3/+5
|
* Project snippet moved to separate modelAndrew8xx82013-03-241-3/+0
|
* fix testsValeriy Sizov2013-01-221-1/+0
|
* Annotated. schema updatedDmitriy Zaporozhets2012-11-191-5/+5
|
* AnnotatedDmitriy Zaporozhets2012-10-091-0/+15
|
* tests fixAndrey Kumanyaev2012-10-091-2/+2
|
* set activerecord whitelist_attributes to trueNihad Abbasov2012-09-261-0/+5
|
* Add more coverage for model validations and associationsRobert Speicher2012-08-291-2/+9
|
* Remove annotations from specsRobert Speicher2012-08-291-15/+0
|
* Reannotatedrandx2012-06-261-5/+5
|
* test expired snippetsNihad Abbasov2011-10-281-0/+1
|
* annotatedgitlabhq2011-10-171-0/+14
|
* snippets are readygitlabhq2011-10-171-0/+16