Commit Graph

274 Commits

Author SHA1 Message Date
Dmitriy Zaporozhets eafb03cfd5
Remove unnecessary set_flash.now from controller specs
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2017-07-24 15:21:16 +03:00
Filipa Lacerda 706d99aed8 Update Pipeline's badge count in Merge Request and Commits view to match real-time content 2017-07-14 15:52:54 +00:00
Douwe Maan 70b05a8377 Split up MergeRequestsController 2017-06-28 18:17:44 -05:00
Grzegorz Bizon 0430b76441 Enable Style/DotPosition Rubocop 👮 2017-06-21 13:48:12 +00:00
Robert Speicher a6ec5121f0 Correct RSpec/SingleLineHook cop offenses 2017-06-14 13:18:56 -05:00
Oswaldo Ferreira 34ba80392d Use :request_store hooks on specs 2017-06-09 18:18:36 -03:00
Oswaldo Ferreira c3d5faa0ee Use RequestStore on MR show.json query count spec 2017-06-08 14:03:08 -03:00
Paul Charlton d93352825a redesign caching of application settings 2017-06-06 16:48:10 +00:00
Nick Thomas 23db8409aa Skip loading application settings from the database when migrations are pending
Various Rails initializers (metrics, sentry, etc) are run before migrations,
which can lead to a mismatch between app/models/application_settings.rb and
schema.
2017-06-02 16:02:08 +01:00
Douwe Maan 26bcef97d6 Merge branch 'rework-authorizations-performance' into 'master'
Rework project authorizations and nested groups for better performance

See merge request !10885
2017-05-29 15:49:56 +00:00
Robert Speicher 6f4e977046 Merge branch 'issue_32225' into 'master'
Add transient head_pipeline_of to pipeline factories

See merge request !11566
2017-05-23 18:53:29 +00:00
Felipe Artur 921c2be44a Add transient head_pipeline_of to pipeline factories 2017-05-22 17:06:45 -03:00
Oswaldo Ferreira 28ffb4bf2f Handle transient MR query count spec 2017-05-19 22:51:52 -03:00
Oswaldo Ferreira b3cf3d046b Make sure fixture creation does not affect query count test 2017-05-19 10:19:04 -03:00
Oswaldo Ferreira e8841e8dbc Drop merge_check endpoint and use only MR show instead 2017-05-18 19:23:05 -03:00
Yorick Peterse ac382b5682
Use CTEs for nested groups and authorizations
This commit introduces the usage of Common Table Expressions (CTEs) to
efficiently retrieve nested group hierarchies, without having to rely on
the "routes" table (which is an _incredibly_ inefficient way of getting
the data). This requires a patch to ActiveRecord (found in the added
initializer) to work properly as ActiveRecord doesn't support WITH
statements properly out of the box.

Unfortunately MySQL provides no efficient way of getting nested groups.
For example, the old routes setup could easily take 5-10 seconds
depending on the amount of "routes" in a database. Providing vastly
different logic for both MySQL and PostgreSQL will negatively impact the
development process. Because of this the various nested groups related
methods return empty relations when used in combination with MySQL.

For project authorizations the logic is split up into two classes:

* Gitlab::ProjectAuthorizations::WithNestedGroups
* Gitlab::ProjectAuthorizations::WithoutNestedGroups

Both classes get the fresh project authorizations (= as they should be
in the "project_authorizations" table), including nested groups if
PostgreSQL is used. The logic of these two classes is quite different
apart from their public interface. This complicates development a bit,
but unfortunately there is no way around this.

This commit also introduces Gitlab::GroupHierarchy. This class can be
used to get the ancestors and descendants of a base relation, or both by
using a UNION. This in turn is used by methods such as:

* Namespace#ancestors
* Namespace#descendants
* User#all_expanded_groups

Again this class relies on CTEs and thus only works on PostgreSQL. The
Namespace methods will return an empty relation when MySQL is used,
while User#all_expanded_groups will return only the groups a user is a
direct member of.

Performance wise the impact is quite large. For example, on GitLab.com
Namespace#descendants used to take around 580 ms to retrieve data for a
particular user. Using CTEs we are able to reduce this down to roughly 1
millisecond, returning the exact same data.

== On The Fly Refreshing

Refreshing of authorizations on the fly (= when
users.authorized_projects_populated was not set) is removed with this
commit. This simplifies the code, and ensures any queries used for
authorizations are not mutated because they are executed in a Rails
scope (e.g. Project.visible_to_user).

This commit includes a migration to schedule refreshing authorizations
for all users, ensuring all of them have their authorizations in place.
Said migration schedules users in batches of 5000, with 5 minutes
between every batch to smear the load around a bit.

== Spec Changes

This commit also introduces some changes to various specs. For example,
some specs for ProjectTeam assumed that creating a personal project
would _not_ lead to the owner having access, which is incorrect. Because
we also no longer refresh authorizations on the fly for new users some
code had to be added to the "empty_project" factory. This chunk of code
ensures that the owner's permissions are refreshed after creating the
project, something that is normally done in Projects::CreateService.
2017-05-17 16:51:08 +02:00
Sean McGivern ad2bfeb857 Fix conflict resolution from corrupted upstream
I don't know why this happens exactly, but given an upstream and fork repository
from a customer, both of which required GC, resolving conflicts would corrupt
the fork so badly that it couldn't be cloned.

This isn't a perfect fix for that case, because the MR may still need to be
merged manually, but it does ensure that the repository is at least usable.

My best guess is that when we generate the index for the conflict
resolution (which we previously did in the target project), we obtain a
reference to an OID that doesn't exist in the source, even though we already
fetch the refs from the target into the source.

Explicitly setting the source project as the place to get the merge index from
seems to prevent repository corruption in this way.
2017-05-12 20:47:51 +01:00
Sean McGivern a3607aa439 Merge branch 'issue_27168_2' into 'master'
Preloads head pipeline for each merge request

Closes #27168

See merge request !10064
2017-05-09 15:16:31 +00:00
Fatih Acet 0151325dac Merge request widget redesign 2017-05-09 04:15:34 +00:00
Felipe Artur d9bebd89df Fix specs 2 2017-05-08 11:29:10 -03:00
Felipe Artur 24824cbb4c Fix Specs 2017-05-08 11:26:04 -03:00
Valery Sizov 387c4b2c21 Backport of multiple_assignees_feature [ci skip] 2017-05-04 17:11:53 +03:00
Jacopo ff76adb547 Unnecessary "include WaitForAjax" and "include ApiHelpers"
Removed all the unnecessary include of `WaitForAjax` and `ApiHelpers` in the specs.
Removed unnecessary usage of `api:true`
2017-04-21 22:32:02 +02:00
Luke "Jared" Bennett b544d8fade
Review changes, used eq instead of match 2017-04-17 13:18:40 +01:00
Luke "Jared" Bennett b24cb99856
Updated specs 2017-04-13 12:50:03 +01:00
Luke "Jared" Bennett 9cee280d70
Merge branch 'update-droplab-to-webpack-version' into new-resolvable-discussion 2017-04-06 13:47:52 +01:00
Sean McGivern b80653bb6a Merge branch 'open-redirect-host-fix' into 'security'
Fix for three open redirect vulns using redirect_to url_for(params.merge)))

See merge request !2082
2017-04-05 21:06:58 -07:00
Douwe Maan 336016fa85
Satisfy Rubocop 2017-04-05 17:44:14 +01:00
Douwe Maan 08bbb9fce6
Add option to start a new discussion on an MR 2017-04-05 17:44:14 +01:00
Shinya Maeda a375d80eb0 Use detailed_status effectively. Remove unnecesarry context(nest). Add new context in merge_requests_controller_spec.rb and fix a bug. Correct description of spec. 2017-03-23 17:11:49 +09:00
Shinya Maeda 361f85122b Rename endpoints 'status' to 'pipeline_status' in merge_requests 2017-03-23 17:11:49 +09:00
Shinya Maeda 08a0bc5397 Add more specs 2017-03-23 17:11:49 +09:00
Shinya Maeda 38b1ec2cc0 Fix rspec failure 2017-03-23 17:11:49 +09:00
Shinya Maeda 3b63500297 3 lines to One line. Correct spec caption. 2017-03-23 17:11:49 +09:00
Shinya Maeda f8d6e81b92 Fix rubocop anger 2017-03-23 17:11:49 +09:00
Shinya Maeda 4fa4a2ce99 Add controllers spec 2017-03-23 17:11:48 +09:00
DJ Mountney 7be39a894b Merge branch 'render-json-leak' into 'security'
fix for render json include leaks

See merge request !2074
2017-03-20 18:54:17 -07:00
Douwe Maan 7e2ad5d47a Merge branch 'fix/mwbs-to-mwps' into 'master'
Rename MWBS to MWPS

Closes #24707

See merge request !9335
2017-03-01 20:30:51 +00:00
James Lopez a0101ebf84 Update occurrences of MWBS to MWPS
Rename column in the database
 Rename fields related to import/export feature
 Rename API endpoints
 Rename documentation links
 Rename the rest of occurrences in the code
 Replace the images that contain the words "build succeeds" and docs referencing to them
 Make sure pipeline is green and nothing is missing.

updated doc images

renamed only_allow_merge_if_build_succeeds in projects and fixed references

more updates

fix some spec failures

fix rubocop offences

fix v3 api spec

fix MR  specs

fixed issues with partials

fix MR spec

fix alignment

add missing v3 to v4 doc

wip - refactor v3 endpoints

fix specs

fix a few typos

fix project specs

copy entities fully to V3

fix  entity error

more fixes

fix failing specs

fixed missing entities in V3 API

remove comment

updated code based on feedback

typo

fix spec
2017-03-01 12:02:02 +01:00
Grzegorz Bizon f0f7af5069 Reinstate new merge request pipelines hash in API 2017-02-28 10:47:48 +01:00
Sean McGivern dfd15596a4 Merge branch 'issue_24815' into 'master'
fix ERR_CONTENT_LENGTH_MISMATCH on task checkboxes

See merge request !8567
2017-02-27 14:14:20 +00:00
Felipe Artur 0d000d351c Fix issuable stale object error handler for js when updating tasklists 2017-02-24 15:13:42 -03:00
Douwe Maan ad640bc5f9 Use Namespace#full_path instead of #path where appropriate 2017-02-23 17:55:01 -06:00
Douwe Maan 56de781a2c Revert "Enable Style/DotPosition"
This reverts commit e00fb2bdc2090e9cabeb1eb35a2672a882cc96e9.

# Conflicts:
#	.rubocop.yml
#	.rubocop_todo.yml
#	lib/gitlab/ci/config/entry/global.rb
#	lib/gitlab/ci/config/entry/jobs.rb
#	spec/lib/gitlab/ci/config/entry/factory_spec.rb
#	spec/lib/gitlab/ci/config/entry/global_spec.rb
#	spec/lib/gitlab/ci/config/entry/job_spec.rb
#	spec/lib/gitlab/ci/status/build/factory_spec.rb
#	spec/lib/gitlab/incoming_email_spec.rb
2017-02-23 09:33:19 -06:00
Douwe Maan 1fe7501b49 Revert "Prefer leading style for Style/DotPosition"
This reverts commit cb10b725c8929b8b4460f89c9d96c773af39ba6b.
2017-02-23 09:33:05 -06:00
Douwe Maan 7d4b52b27d Enable Style/WordArray 2017-02-23 09:32:41 -06:00
Douwe Maan eacae00516 Enable Style/MultilineHashBraceLayout 2017-02-23 09:32:22 -06:00
Douwe Maan 206953a430 Prefer leading style for Style/DotPosition 2017-02-23 09:32:22 -06:00
Douwe Maan 3dadf306dd Enable Style/DotPosition 2017-02-23 09:31:56 -06:00
Jarka Kadlecova d89f4d73b9 Fix error in MR widget after /merge slash command 2017-02-16 13:27:31 +01:00
Felipe Artur 0b14b654b6 Gather issuable metadata to avoid n+ queries on index view 2017-02-09 17:40:37 -02:00
Grzegorz Bizon 3ea1f91e1e Fix merge request controller specs for new action 2017-02-07 17:50:13 +01:00
Filipa Lacerda 035cb734d2 Add time ago auto-update to the 2 newest tables 2017-02-03 09:43:56 +00:00
Grzegorz Bizon 562b5015ed Add basic specs for new merge requests pipelines API 2017-02-03 09:43:55 +00:00
Grzegorz Bizon 8e8ec9d7bf Use ApiHelpers in merge request specs for API routes 2017-01-30 15:31:28 +01:00
Grzegorz Bizon 30c73d2d9f Add controller test for merge requests pipelines API 2017-01-27 14:45:56 +01:00
Jarka Kadlecova 557a0bf14c Address MR comments 2017-01-13 09:16:35 -05:00
Jarka Kadlecova aa934c7469 refresh merge widget after using /merge command 2017-01-11 08:48:07 -05:00
Tiago Botelho d7a2e92ca0 applies url_for so that we dont lose filters when redirecting 2016-12-23 15:09:34 +00:00
Tiago Botelho 805bbe8893 adds specs for respective behaviour 2016-12-21 23:53:24 +00:00
Filipa Lacerda dfa842ce1d Removes builds tab from merge request
Fix specs
2016-12-21 11:17:09 +00:00
Grzegorz Bizon 01f238893a Rename MWBS service to Merge When Pipeline Succeeds 2016-11-21 10:22:09 +01:00
Alex Sanford 317c388347 Ensure labels are loaded on "show" methods of MR
Previously, they were only being loaded on the actual `show` action, but
not the actions representing the tabs (commits, builds, etc).
2016-11-11 14:06:43 -04:00
Rémy Coutable 3f02914460 Complete and improve specs
Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-11-04 14:58:40 +01:00
Rodolfo Santos 1db9f826c1 Add setting to only allow merge requests to be merged when all discussions are resolved
Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-11-04 14:58:40 +01:00
Z.J. van de Weg c1212beaa4 Use deployment IID when saving refs 2016-10-20 14:17:22 +02:00
Sean McGivern 86dcb79be3 Merge branch 'master' into merge-conflicts-editor-2 2016-10-17 10:56:55 +01:00
Z.J. van de Weg cf15af3135 Add test, fix merge error 2016-10-14 12:28:19 +02:00
Sean McGivern 3764fd4b41 Add blob_ace_mode to conflict content response 2016-10-13 14:16:35 -05:00
Alfredo Sumaran 54bfe70795 Add more tests to check conflicts resolution 2016-10-13 14:16:35 -05:00
Sean McGivern 7529bbae94 Add JSON Schema 2016-10-13 14:16:34 -05:00
Sean McGivern 9727366b5a Make RuboCop happy 2016-10-13 14:16:34 -05:00
Sean McGivern 3f71c43e88 Allow setting content for resolutions
When reading conflicts:

1. Add a `type` field. `text` works as before, and has `sections`;
   `text-editor` is a file with ambiguous conflict markers that can only
   be resolved in an editor.
2. Add a `content_path` field pointing to a JSON representation of the
   file's content for a single file.
3. Hitting `content_path` returns a similar datastructure to the `file`,
   but without the `content_path` and `sections` fields, and with a
   `content` field containing the full contents of the file (with
   conflict markers).

When writing conflicts:

1. Instead of `sections` being at the top level, they are now in a
   `files` array. This matches the read format better.
2. The `files` array contains file hashes, each of which must contain:
   a. `new_path`
   b. `old_path`
   c. EITHER `sections` (which works as before) or `content` (with the
      full content of the resolved file).
2016-10-13 14:16:34 -05:00
James Edwards-Jones 6606642f8f fixup! Added link to bulk assign issues to MR author. (Issue #18876) 2016-10-10 16:19:46 +01:00
James Edwards-Jones 8d2de73a83 fixup! Added link to bulk assign issues to MR author. (Issue #18876) 2016-10-07 17:16:42 +01:00
James 492b4332a4 Added link to bulk assign issues to MR author. (Issue #18876) 2016-10-06 13:37:37 +01:00
Thomas Balthazar ddbe676dc3 Add a /wip slash command
It toggles the 'WIP' prefix in the MR title.
2016-10-03 09:36:21 +02:00
Douglas Barbosa Alexandre d86c666662 Refresh todos count cache when an Issue/MR is deleted 2016-09-08 15:50:07 -03:00
Katarzyna Kobierska 6b02c82cfe Improve grammar 2016-08-30 13:05:40 +02:00
Katarzyna Kobierska c9c2503c51 User can edit closed MR with deleted fork
Add test for closed MR without fork

Add view test visibility of Reopen and Close buttons

Fix controller tests and validation method

Fix missing space

Remove unused variables from test

closed_without_fork? method refactoring

Add information about missing fork

When closed MR without fork can't edit target branch

Tests for closed MR edit view

Fix indentation and rebase, refactoring
2016-08-30 13:05:40 +02:00
Sean McGivern ce7eb4e492 Add more tests for conflicts 2016-08-12 23:24:48 +03:00
Sean McGivern 46f8e6421a Remove undo endpoint
This reverts commit 2536fea8db0967a817615eb3e951eb6ba22f8ede.
2016-08-12 23:24:48 +03:00
Sean McGivern 3b84cfdc74 Use same resolution format on FE and BE 2016-08-12 23:24:46 +03:00
Sean McGivern 99e00856eb REMOVE THIS COMMIT: allow undoing last resolution 2016-08-12 23:24:44 +03:00
Sean McGivern f2f844693e Handle conflict resolution errors in controller 2016-08-12 23:24:44 +03:00
Sean McGivern 14a4b17d1c Allow resolving conflicts in MR controller 2016-08-12 23:24:43 +03:00
Sean McGivern a1c7961217 Handle multiple merge conflict files in collection 2016-08-12 23:24:43 +03:00
tiagonbotelho 519275c110 fixes part1 of files to start using active tense 2016-08-09 15:06:23 +01:00
Paco Guzman 8f359ea917 Move to Gitlab::Diff::FileCollection
Instead calling diff_collection.count use diff_collection.size which is cache on the diff_collection
2016-08-03 07:00:20 +02:00
Paco Guzman cd7c2cb6dd Cache highlighted diff lines for merge requests
Introducing the concept of SafeDiffs which relates 
diffs with UI highlighting.
2016-08-03 07:00:19 +02:00
Sean McGivern 5266ae87c4 Support renames in diff_for_path actions 2016-07-11 09:31:34 +01:00
Sean McGivern e462e12278 Tidy up spec action names 2016-07-08 18:11:47 +01:00
Sean McGivern b6b26692ea Collapse large diffs by default
When rendering a list of diff files, skip those where the diff is over
10 KB and provide an endpoint to render individually instead.
2016-07-08 10:56:55 +01:00
Douwe Maan ddec2ed0df Add send_git_patch helper 2016-07-06 18:51:01 -04:00
Douwe Maan 6ce25e7b4c Rename MergeRequest methods that return commits or shas to be more clear and consistent 2016-07-06 18:50:58 -04:00
Grzegorz Bizon 9e211091a8 Enable Style/EmptyLines cop, remove redundant ones 2016-07-01 21:56:17 +02:00
Robert Speicher 5423e6e2d5 Merge branch 'zj-workhorse-format-patch' into 'master'
Workhorse to serve email diffs

See merge request !4590
2016-06-29 02:26:38 +00:00
Z.J. van de Weg c31f876a27 Workhorse to serve email diffs
Depends on the changes in Workhorse (gitlab-org/gitlab-workhorse!48).
2016-06-28 14:26:38 +02:00
Z.J. van de Weg abca19da8b Use HTTP matchers if possible 2016-06-27 20:10:42 +02:00
Rémy Coutable e3d464d82a
Fix a wrong MR status when merge_when_build_succeeds & project.only_allow_merge_if_build_succeeds are true
The issue was that `MergeRequest#mergeable?` returns false when the CI
state is not success and project.only_allow_merge_if_build_succeeds is
true. In this case `Projects::MergeRequestsController#merge` would
return the `:failed` status when enabling `merge_when_build_succeeds`,
thus leading to a weird state and the MR never automatically merged.

The fix is to disable the CI state check in the controller safeguard
that early return the `:failed` status.

Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-06-24 18:33:02 +02:00
Douwe Maan a9857f8c2f Add send_git_diff helper 2016-06-08 14:30:15 +02:00
Jacob Vosmaer (GitLab) afa21054fa Merge branch 'zj-workhorse-to-serve-diffs' into 'master'
Workhorse to serve raw diffs

Fixes (partially) #13999

Dependent on: gitlab-org/gitlab-workhorse!45

See merge request !4130
2016-06-07 12:50:29 +00:00
Zeger-Jan van de Weg 01e1139f68 Workhorse to serve raw diffs 2016-06-03 18:43:22 +02:00
Kamil Trzcinski 20c7144ed2 Rename all `[ci_]commit` to `[ci_]pipeline` in specs and features 2016-06-03 16:22:26 +02:00
Sean McGivern f680eca912 Don't allow merges with new commits
Set a `sha` parameter on the MR form. If this doesn't match the HEAD of
the source branch when the form is submitted, show a warning (like with
a merge conflict) and don't merge the branch.
2016-06-01 20:34:41 +01:00
Grzegorz Bizon c370dce01c Enable Style/RedundantParentheses rubocop cop
See #17478
2016-05-30 15:07:18 +02:00
Robert Speicher 8530ce4c6f Clarify that the diff view setting always comes from the cookie
This invalidates one test, which we've removed.
2016-04-19 17:47:58 -04:00
Felipe Artur a64f1c7636 Add changelog entry, improve specs and model code 2016-04-12 15:52:03 -03:00
Felipe Artur 476cf23fc3 Allow to close invalid merge request 2016-04-11 19:00:59 -03:00
Gabriel Mazetto 808bcf5bc6 Fixed MergeRequestController spec 2016-03-30 00:02:32 -03:00
Zeger-Jan van de Weg 3b088fc5b5 Minor improvements on IssuableActions 2016-03-21 16:59:35 +01:00
Zeger-Jan van de Weg 1d77822816 minor improvements and fixed specs 2016-03-19 21:24:05 +01:00
Zeger-Jan van de Weg 7342a4566c Dry destroy action on issuables 2016-03-19 21:24:05 +01:00
Zeger-Jan van de Weg 212e83bab3 Soft delete issuables 2016-03-19 21:23:03 +01:00
Rubén Dávila 2770de9617 Reopened MRs should also be considered as open. 2016-02-17 21:15:13 -05:00
Robert Speicher 551ce0f245 Add spec for assigning view param from cookie 2016-02-05 16:03:20 -05:00
Rémy Coutable f6d816f9fe Add a controller test for the new 'diff_view' cookie 2016-02-05 15:40:44 +01:00
Douglas Barbosa Alexandre 12fdc13ad3 Fix 500 error when creating a merge request that removes a submodule 2015-12-04 17:35:14 -02:00
Minsik Yoon 3d0efa8e0a Add ignore white space option in merge request diff
fix this issue(https://gitlab.com/gitlab-org/gitlab-ce/issues/1393).

Add ignore whitespace optoin to Commits Compare view
2015-11-13 16:53:53 +09:00
Dmitriy Zaporozhets f40b99d02e
Merge branch 'master' into rubocop-for-tests
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>

Conflicts:
	spec/features/issues_spec.rb
	spec/models/forked_project_link_spec.rb
	spec/models/hooks/service_hook_spec.rb
	spec/models/hooks/web_hook_spec.rb
	spec/models/project_services/hipchat_service_spec.rb
	spec/requests/api/project_members_spec.rb
	spec/requests/api/projects_spec.rb
	spec/requests/api/system_hooks_spec.rb
	spec/services/archive_repository_service_spec.rb
	spec/support/matchers.rb
	spec/tasks/gitlab/backup_rake_spec.rb
2015-06-23 10:44:03 +02:00
Stan Hu 359ed48638 Fix Style/AlignHash cop violations 2015-06-22 22:24:39 -07:00
Robert Speicher bf71d53f63 Change `to_not` calls to `not_to`
Both work, but now we're consistent across the entire app.
2015-06-22 12:13:49 +02:00
Robert Speicher bc027c5183 Load the Merge Request > Commits tab lazily 2015-06-17 16:59:51 -04:00
Robert Speicher 5c78d7fce8 Move Projects::MergeRequestsController spec to its correct location 2015-06-17 16:37:11 -04:00