Commit graph

22 commits

Author SHA1 Message Date
Timothy Andrew
f51af49676 Support wildcard matches for protected branches at the model level.
1. The main implementation is in the `ProtectedBranch` model. The
   wildcard is converted to a Regex and compared. This has been tested
   thoroughly.

    - While `Project#protected_branch?` is the main entry point,
      `project#open_branches` and
      `project#developers_can_push_to_protected_branch?`
      have also been modified to work with wildcard protected branches.

    - The regex is memoized (within the `ProtectedBranch` instance)

2. Improve the performance of `Project#protected_branch?`

    -  This method is called from `Project#open_branches` once _per branch_
       in the project, to check if that branch is protected or not.

    -  Before, `#protected_branch?` was making a database call every
       time it was invoked (in the above case, that amounts to once
       per branch), which is expensive.

    -  This commit caches the list of protected branches in memory, which
       reduces the number of database calls down to 1.

    -  A downside to this approach is that `#protected_branch?` _could_
       return a stale value (due to the caching), but this is
       an acceptable tradeoff.

3. Remove the (now) unused `Project#protected_branch_names` method.

    - This was previously used to check for protected branch status.
2016-07-05 10:50:34 +05:30
Jeroen van Baarsen
f1479b56b7
Remove the annotate gem and delete old annotations
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
2016-05-09 18:00:28 +02:00
Douwe Maan
1e8d703a85 Tag model specs 2015-12-09 10:50:51 +01:00
Jeroen van Baarsen
0c4a70a306 Updated rspec to rspec 3.x syntax
Signed-off-by: Jeroen van Baarsen <jeroenvanbaarsen@gmail.com>
2015-02-12 19:17:35 +01:00
Dmitriy Zaporozhets
98ee4a1fa7 Annotate models 2015-01-22 09:40:03 -08:00
Dmitriy Zaporozhets
0f550aa386
Remove mass assgnment specs
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-06-26 23:57:55 +03:00
Dmitriy Zaporozhets
36f861f1b1
Re-annotate models
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-04-09 15:05:03 +03:00
Dmitriy Zaporozhets
70e3bffd95 Fixed: post-receive, project remove, tests 2013-02-05 12:47:50 +02:00
Dmitriy Zaporozhets
e3d7ce2cc4 Tests are fixed now 2013-01-05 12:12:02 +02:00
Dmitriy Zaporozhets
9a88e4d184 Fix some tests. Use travis-ci 1.9.2 2013-01-05 00:43:32 +02:00
Dmitriy Zaporozhets
95c23b2f97 Annotated. schema updated 2012-11-19 21:24:05 +03:00
Dmitriy Zaporozhets
41e53eb980 Annotated 2012-10-09 11:14:17 +03:00
Andrey Kumanyaev
a4cd738686 tests fix 2012-10-09 04:10:16 +04:00
Nihad Abbasov
83efcabc82 set activerecord whitelist_attributes to true 2012-09-26 11:18:35 -07:00
Robert Speicher
97423a0bed Add more coverage for model validations and associations 2012-08-29 11:36:02 -04:00
Robert Speicher
9e7d77cece Remove annotations from specs 2012-08-29 10:44:34 -04:00
Robert Speicher
7754189187 Fully embrace Ruby 1.9 hash syntax
Didn't bother with files in db/, config/, or features/
2012-08-10 18:25:15 -04:00
randx
4a437cdf86 Remove useless Protected branch test 2012-08-02 09:05:00 +03:00
randx
6abc649590 Reannotated 2012-06-26 21:23:09 +03:00
randx
3272620f72 lib/ refactoring. Module Gitlabhq renamed to Gitlab 2012-05-26 13:37:49 +03:00
Robb Kidd
d50446088c Add spec for ProtectedBranch. 2012-05-10 22:43:12 +00:00
Dmitriy Zaporozhets
37224dc9c1 ProtectedBranches model, Master permission for repo\n Allow push to protected branch for masters only 2012-02-15 22:02:33 +02:00