summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitlab-ci.yml3
-rw-r--r--Gemfile2
-rw-r--r--Gemfile.rails5.lock48
-rw-r--r--app/controllers/projects/branches_controller.rb10
-rw-r--r--app/mailers/emails/merge_requests.rb1
-rw-r--r--app/services/projects/update_pages_service.rb19
-rw-r--r--app/views/notify/push_to_merge_request_email.html.haml4
-rw-r--r--app/views/notify/push_to_merge_request_email.text.haml2
-rw-r--r--changelogs/unreleased/blackst0ne-replace-spinach-project-issues-issues-feature.yml5
-rw-r--r--changelogs/unreleased/blackst0ne-replace-spinach-project-issues-labels-feature.yml5
-rw-r--r--changelogs/unreleased/sh-move-sidekiq-exporter-logs.yml5
-rw-r--r--doc/administration/logs.md8
-rw-r--r--doc/development/ee_features.md14
-rw-r--r--features/project/issues/issues.feature180
-rw-r--r--features/project/issues/labels.feature48
-rw-r--r--features/project/issues/milestones.feature1
-rw-r--r--features/steps/project/issues/issues.rb181
-rw-r--r--features/steps/project/issues/labels.rb101
-rw-r--r--features/steps/shared/issuable.rb23
-rw-r--r--features/steps/shared/markdown.rb37
-rw-r--r--features/steps/shared/note.rb22
-rw-r--r--features/steps/shared/paths.rb31
-rw-r--r--features/steps/shared/project.rb4
-rw-r--r--features/steps/shared/user.rb4
-rw-r--r--lib/gitlab/metrics/sidekiq_metrics_exporter.rb10
-rw-r--r--lib/gitlab/performance_bar.rb1
-rwxr-xr-xscripts/trigger-build-omnibus3
-rw-r--r--spec/controllers/projects/branches_controller_spec.rb18
-rw-r--r--spec/features/dashboard/issues_filter_spec.rb6
-rw-r--r--spec/features/dashboard/merge_requests_spec.rb6
-rw-r--r--spec/features/issues/user_uses_slash_commands_spec.rb26
-rw-r--r--spec/features/merge_request/user_uses_slash_commands_spec.rb22
-rw-r--r--spec/features/projects/issues/user_comments_on_issue_spec.rb73
-rw-r--r--spec/features/projects/issues/user_creates_issue_spec.rb87
-rw-r--r--spec/features/projects/issues/user_edits_issue_spec.rb25
-rw-r--r--spec/features/projects/issues/user_sorts_issues_spec.rb42
-rw-r--r--spec/features/projects/issues/user_toggles_subscription_spec.rb28
-rw-r--r--spec/features/projects/issues/user_views_issue_spec.rb16
-rw-r--r--spec/features/projects/issues/user_views_issues_spec.rb120
-rw-r--r--spec/features/projects/labels/user_creates_labels_spec.rb88
-rw-r--r--spec/features/projects/labels/user_edits_labels_spec.rb25
-rw-r--r--spec/features/projects/labels/user_removes_labels_spec.rb52
-rw-r--r--spec/features/projects/labels/user_views_labels_spec.rb23
-rw-r--r--spec/features/projects/milestones/milestones_sorting_spec.rb1
-rw-r--r--spec/features/user_sorts_things_spec.rb57
-rw-r--r--spec/lib/gitlab/metrics/sidekiq_metrics_exporter_spec.rb4
-rw-r--r--spec/lib/gitlab/performance_bar_spec.rb6
-rw-r--r--spec/mailers/notify_spec.rb30
-rw-r--r--spec/services/projects/update_pages_service_spec.rb40
-rw-r--r--spec/support/features/issuable_slash_commands_shared_examples.rb28
-rw-r--r--spec/support/helpers/features/notes_helpers.rb27
-rw-r--r--spec/support/helpers/features/sorting_helpers.rb26
-rw-r--r--spec/support/matchers/issuable_matchers.rb11
-rw-r--r--spec/support/quick_actions_helpers.rb10
-rw-r--r--spec/support/sorting_helper.rb18
-rw-r--r--spec/uploaders/workers/object_storage/background_move_worker_spec.rb146
-rw-r--r--spec/uploaders/workers/object_storage/migrate_uploads_worker_spec.rb119
57 files changed, 1173 insertions, 779 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 4890738aa3d..5be942c04ab 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -266,12 +266,13 @@ package-and-qa:
when: manual
variables:
GIT_STRATEGY: none
+ retry: 0
before_script:
# We need to download the script rather than clone the repo since the
# package-and-qa job will not be able to run when the branch gets
# deleted (when merging the MR).
- apk add --update openssl
- - wget https://gitlab.com/gitlab-org/gitlab-ce/raw/$CI_COMMIT_SHA/scripts/trigger-build-omnibus
+ - wget https://gitlab.com/$CI_PROJECT_PATH/raw/$CI_COMMIT_SHA/scripts/trigger-build-omnibus
- chmod 755 trigger-build-omnibus
script:
- ./trigger-build-omnibus
diff --git a/Gemfile b/Gemfile
index fd174a60c66..5eac6d73269 100644
--- a/Gemfile
+++ b/Gemfile
@@ -384,7 +384,7 @@ group :test do
gem 'email_spec', '~> 1.6.0'
gem 'json-schema', '~> 2.8.0'
gem 'webmock', '~> 2.3.2'
- gem 'test_after_commit', '~> 1.1'
+ gem 'test_after_commit', '~> 1.1' unless rails5? # Remove this gem when migrated to rails 5.0. It's been integrated to rails 5.0.
gem 'sham_rack', '~> 1.3.6'
gem 'concurrent-ruby', '~> 1.0.5'
gem 'test-prof', '~> 0.2.5'
diff --git a/Gemfile.rails5.lock b/Gemfile.rails5.lock
index 86a22dbe550..ca86861255b 100644
--- a/Gemfile.rails5.lock
+++ b/Gemfile.rails5.lock
@@ -60,7 +60,7 @@ GEM
faraday_middleware-multi_json (~> 0.0)
oauth2 (~> 1.0)
asciidoctor (1.5.6.1)
- asciidoctor-plantuml (0.0.7)
+ asciidoctor-plantuml (0.0.8)
asciidoctor (~> 1.5)
asset_sync (2.2.0)
activemodel (>= 4.1.0)
@@ -144,6 +144,7 @@ GEM
connection_pool (2.2.1)
crack (0.4.3)
safe_yaml (~> 1.0.0)
+ crass (1.0.3)
creole (0.5.0)
css_parser (1.6.0)
addressable
@@ -244,10 +245,11 @@ GEM
builder
excon (~> 0.58)
formatador (~> 0.2)
- fog-google (0.6.0)
+ fog-google (1.3.3)
fog-core
fog-json
fog-xml
+ google-api-client (~> 0.19.1)
fog-json (1.0.2)
fog-core (~> 1.0)
multi_json (~> 1.10)
@@ -289,7 +291,7 @@ GEM
po_to_json (>= 1.0.0)
rails (>= 3.2.0)
gherkin-ruby (0.3.2)
- gitaly-proto (0.88.0)
+ gitaly-proto (0.91.0)
google-protobuf (~> 3.1)
grpc (~> 1.0)
github-linguist (5.3.3)
@@ -484,7 +486,8 @@ GEM
activesupport (>= 4)
railties (>= 4)
request_store (~> 1.0)
- loofah (2.0.3)
+ loofah (2.2.2)
+ crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.0)
mini_mime (>= 0.1.1)
@@ -527,8 +530,8 @@ GEM
omniauth (1.8.1)
hashie (>= 3.4.6, < 3.6.0)
rack (>= 1.6.2, < 3)
- omniauth-auth0 (1.4.2)
- omniauth-oauth2 (~> 1.1)
+ omniauth-auth0 (2.0.0)
+ omniauth-oauth2 (~> 1.4)
omniauth-authentiq (0.3.1)
omniauth-oauth2 (~> 1.3, >= 1.3.1)
omniauth-azure-oauth2 (0.0.9)
@@ -551,6 +554,9 @@ GEM
jwt (>= 1.5)
omniauth (>= 1.1.1)
omniauth-oauth2 (>= 1.5)
+ omniauth-jwt (0.0.2)
+ jwt
+ omniauth (~> 1.1)
omniauth-kerberos (0.3.0)
omniauth-multipassword
timfel-krb5-auth (~> 0.8)
@@ -569,9 +575,9 @@ GEM
ruby-saml (~> 1.7)
omniauth-shibboleth (1.2.1)
omniauth (>= 1.0.0)
- omniauth-twitter (1.2.1)
- json (~> 1.3)
+ omniauth-twitter (1.4.0)
omniauth-oauth (~> 1.1)
+ rack
omniauth_crowd (2.2.3)
activesupport
nokogiri (>= 1.4.4)
@@ -808,7 +814,7 @@ GEM
rubyzip (1.2.1)
rufus-scheduler (3.4.2)
et-orbi (~> 1.0)
- rugged (0.26.0)
+ rugged (0.27.0)
safe_yaml (1.0.4)
sanitize (2.1.0)
nokogiri (>= 1.4.4)
@@ -907,8 +913,6 @@ GEM
sysexits (1.2.0)
temple (0.7.7)
test-prof (0.2.5)
- test_after_commit (1.1.0)
- activerecord (>= 3.2)
text (1.3.1)
thin (1.7.2)
daemons (~> 1.0, >= 1.0.9)
@@ -995,8 +999,8 @@ DEPENDENCIES
akismet (~> 2.0)
allocations (~> 1.0)
asana (~> 0.6.0)
- asciidoctor (~> 1.5.2)
- asciidoctor-plantuml (= 0.0.7)
+ asciidoctor (~> 1.5.6)
+ asciidoctor-plantuml (= 0.0.8)
asset_sync (~> 2.2.0)
attr_encrypted (~> 3.0.0)
awesome_print (~> 1.2.0)
@@ -1044,9 +1048,9 @@ DEPENDENCIES
flipper-active_record (~> 0.13.0)
flipper-active_support_cache_store (~> 0.13.0)
fog-aliyun (~> 0.2.0)
- fog-aws (~> 2.0)
+ fog-aws (~> 2.0.1)
fog-core (~> 1.44)
- fog-google (~> 0.5)
+ fog-google (~> 1.3.3)
fog-local (~> 0.3)
fog-openstack (~> 0.1)
fog-rackspace (~> 0.1.1)
@@ -1058,7 +1062,7 @@ DEPENDENCIES
gettext (~> 3.2.2)
gettext_i18n_rails (~> 1.8.0)
gettext_i18n_rails_js (~> 1.3)
- gitaly-proto (~> 0.88.0)
+ gitaly-proto (~> 0.91.0)
github-linguist (~> 5.3.3)
gitlab-flowdock-git-hook (~> 1.0.1)
gitlab-markup (~> 1.6.2)
@@ -1095,7 +1099,7 @@ DEPENDENCIES
license_finder (~> 3.1)
licensee (~> 8.9)
lograge (~> 0.5)
- loofah (~> 2.0.3)
+ loofah (~> 2.2)
mail_room (~> 0.9.1)
method_source (~> 0.8)
minitest (~> 5.7.0)
@@ -1107,19 +1111,20 @@ DEPENDENCIES
oauth2 (~> 1.4)
octokit (~> 4.8)
omniauth (~> 1.8)
- omniauth-auth0 (~> 1.4.1)
+ omniauth-auth0 (~> 2.0.0)
omniauth-authentiq (~> 0.3.1)
omniauth-azure-oauth2 (~> 0.0.9)
omniauth-cas3 (~> 1.1.4)
omniauth-facebook (~> 4.0.0)
omniauth-github (~> 1.1.1)
omniauth-gitlab (~> 1.0.2)
- omniauth-google-oauth2 (~> 0.5.2)
+ omniauth-google-oauth2 (~> 0.5.3)
+ omniauth-jwt (~> 0.0.2)
omniauth-kerberos (~> 0.3.0)
omniauth-oauth2-generic (~> 0.2.2)
omniauth-saml (~> 1.10)
omniauth-shibboleth (~> 1.2.0)
- omniauth-twitter (~> 1.2.0)
+ omniauth-twitter (~> 1.4)
omniauth_crowd (~> 2.2.0)
org-ruby (~> 0.9.12)
peek (~> 1.0.1)
@@ -1169,7 +1174,7 @@ DEPENDENCIES
ruby-prof (~> 0.17.0)
ruby_parser (~> 3.8)
rufus-scheduler (~> 3.4)
- rugged (~> 0.26.0)
+ rugged (~> 0.27)
sanitize (~> 2.0)
sass-rails (~> 5.0.6)
scss_lint (~> 0.56.0)
@@ -1197,7 +1202,6 @@ DEPENDENCIES
state_machines-activerecord (~> 0.5.1)
sys-filesystem (~> 1.1.6)
test-prof (~> 0.2.5)
- test_after_commit (~> 1.1)
thin (~> 1.7.0)
timecop (~> 0.8.0)
toml-rb (~> 1.0.0)
diff --git a/app/controllers/projects/branches_controller.rb b/app/controllers/projects/branches_controller.rb
index 176679f0849..b7b36f770f5 100644
--- a/app/controllers/projects/branches_controller.rb
+++ b/app/controllers/projects/branches_controller.rb
@@ -22,9 +22,13 @@ class Projects::BranchesController < Projects::ApplicationController
@refs_pipelines = @project.pipelines.latest_successful_for_refs(@branches.map(&:name))
@merged_branch_names = repository.merged_branch_names(@branches.map(&:name))
- @max_commits = @branches.reduce(0) do |memo, branch|
- diverging_commit_counts = repository.diverging_commit_counts(branch)
- [memo, diverging_commit_counts[:behind], diverging_commit_counts[:ahead]].max
+
+ # n+1: https://gitlab.com/gitlab-org/gitaly/issues/992
+ Gitlab::GitalyClient.allow_n_plus_1_calls do
+ @max_commits = @branches.reduce(0) do |memo, branch|
+ diverging_commit_counts = repository.diverging_commit_counts(branch)
+ [memo, diverging_commit_counts[:behind], diverging_commit_counts[:ahead]].max
+ end
end
render
diff --git a/app/mailers/emails/merge_requests.rb b/app/mailers/emails/merge_requests.rb
index be99f3780cc..b3f2aeb08ca 100644
--- a/app/mailers/emails/merge_requests.rb
+++ b/app/mailers/emails/merge_requests.rb
@@ -15,6 +15,7 @@ module Emails
setup_merge_request_mail(merge_request_id, recipient_id)
@new_commits = new_commits
@existing_commits = existing_commits
+ @updated_by_user = User.find(updated_by_user_id)
mail_answer_thread(@merge_request, merge_request_thread_options(updated_by_user_id, recipient_id, reason))
end
diff --git a/app/services/projects/update_pages_service.rb b/app/services/projects/update_pages_service.rb
index 9c8877be14e..7e228d1833d 100644
--- a/app/services/projects/update_pages_service.rb
+++ b/app/services/projects/update_pages_service.rb
@@ -31,15 +31,17 @@ module Projects
# Check if we did extract public directory
archive_public_path = File.join(archive_path, 'public')
- raise FailedToExtractError, 'pages miss the public folder' unless Dir.exist?(archive_public_path)
+ raise InvaildStateError, 'pages miss the public folder' unless Dir.exist?(archive_public_path)
raise InvaildStateError, 'pages are outdated' unless latest?
deploy_page!(archive_public_path)
success
end
- rescue InvaildStateError, FailedToExtractError => e
- register_failure
+ rescue InvaildStateError => e
error(e.message)
+ rescue => e
+ error(e.message, false)
+ raise e
end
private
@@ -50,12 +52,13 @@ module Projects
super
end
- def error(message, http_status = nil)
+ def error(message, allow_delete_artifact = true)
+ register_failure
log_error("Projects::UpdatePagesService: #{message}")
@status.allow_failure = !latest?
@status.description = message
@status.drop(:script_failure)
- delete_artifact!
+ delete_artifact! if allow_delete_artifact
super
end
@@ -76,7 +79,7 @@ module Projects
elsif artifacts.ends_with?('.zip')
extract_zip_archive!(temp_path)
else
- raise FailedToExtractError, 'unsupported artifacts format'
+ raise InvaildStateError, 'unsupported artifacts format'
end
end
@@ -91,13 +94,13 @@ module Projects
end
def extract_zip_archive!(temp_path)
- raise FailedToExtractError, 'missing artifacts metadata' unless build.artifacts_metadata?
+ raise InvaildStateError, 'missing artifacts metadata' unless build.artifacts_metadata?
# Calculate page size after extract
public_entry = build.artifacts_metadata_entry(SITE_PATH, recursive: true)
if public_entry.total_size > max_size
- raise FailedToExtractError, "artifacts for pages are too large: #{public_entry.total_size}"
+ raise InvaildStateError, "artifacts for pages are too large: #{public_entry.total_size}"
end
# Requires UnZip at least 6.00 Info-ZIP.
diff --git a/app/views/notify/push_to_merge_request_email.html.haml b/app/views/notify/push_to_merge_request_email.html.haml
index 5cc6f21c0f3..4c507c08ed7 100644
--- a/app/views/notify/push_to_merge_request_email.html.haml
+++ b/app/views/notify/push_to_merge_request_email.html.haml
@@ -1,7 +1,7 @@
%h3
- New commits were pushed to the merge request
+ = @updated_by_user.name
+ pushed new commits to merge request
= link_to(@merge_request.to_reference, project_merge_request_url(@merge_request.target_project, @merge_request))
- by #{@current_user.name}
- if @existing_commits.any?
- count = @existing_commits.size
diff --git a/app/views/notify/push_to_merge_request_email.text.haml b/app/views/notify/push_to_merge_request_email.text.haml
index d7722e5f41f..553f771f1a6 100644
--- a/app/views/notify/push_to_merge_request_email.text.haml
+++ b/app/views/notify/push_to_merge_request_email.text.haml
@@ -1,4 +1,4 @@
-New commits were pushed to the merge request #{@merge_request.to_reference} by #{@current_user.name}
+#{@updated_by_user.name} pushed new commits to merge request #{@merge_request.to_reference}
\
#{url_for(project_merge_request_url(@merge_request.target_project, @merge_request))}
\
diff --git a/changelogs/unreleased/blackst0ne-replace-spinach-project-issues-issues-feature.yml b/changelogs/unreleased/blackst0ne-replace-spinach-project-issues-issues-feature.yml
new file mode 100644
index 00000000000..7defdc0a28f
--- /dev/null
+++ b/changelogs/unreleased/blackst0ne-replace-spinach-project-issues-issues-feature.yml
@@ -0,0 +1,5 @@
+---
+title: Replace the spinach test with an rspec analog
+merge_request: 17950
+author: blackst0ne
+type: other
diff --git a/changelogs/unreleased/blackst0ne-replace-spinach-project-issues-labels-feature.yml b/changelogs/unreleased/blackst0ne-replace-spinach-project-issues-labels-feature.yml
new file mode 100644
index 00000000000..4e1bb15f150
--- /dev/null
+++ b/changelogs/unreleased/blackst0ne-replace-spinach-project-issues-labels-feature.yml
@@ -0,0 +1,5 @@
+---
+title: Replace the `project/issues/labels.feature` spinach test with an rspec analog
+merge_request: 18126
+author: blackst0ne
+type: other
diff --git a/changelogs/unreleased/sh-move-sidekiq-exporter-logs.yml b/changelogs/unreleased/sh-move-sidekiq-exporter-logs.yml
new file mode 100644
index 00000000000..1990f4f6124
--- /dev/null
+++ b/changelogs/unreleased/sh-move-sidekiq-exporter-logs.yml
@@ -0,0 +1,5 @@
+---
+title: Move Sidekiq exporter logs to log/sidekiq_exporter.log
+merge_request:
+author:
+type: other
diff --git a/doc/administration/logs.md b/doc/administration/logs.md
index 00a2f3d01b8..cd107a5b39c 100644
--- a/doc/administration/logs.md
+++ b/doc/administration/logs.md
@@ -206,4 +206,12 @@ is populated whenever `gitlab-ctl reconfigure` is run manually or as part of an
Reconfigure logs files are named according to the UNIX timestamp of when the reconfigure
was initiated, such as `1509705644.log`
+## `sidekiq_exporter.log`
+
+If Prometheus metrics and the Sidekiq Exporter are both enabled, Sidekiq will
+start a Web server and listen to the defined port (default: 3807). Access logs
+will be generated in `/var/log/gitlab/gitlab-rails/sidekiq_exporter.log` for
+Omnibus GitLab packages or in `/home/git/gitlab/log/sidekiq_exporter.log` for
+installations from source.
+
[repocheck]: repository_checks.md
diff --git a/doc/development/ee_features.md b/doc/development/ee_features.md
index 3ba03d2d591..287143d6255 100644
--- a/doc/development/ee_features.md
+++ b/doc/development/ee_features.md
@@ -644,6 +644,7 @@ information on managing page-specific javascript within EE.
To separate EE-specific styles in SCSS files, if a component you're adding styles for
is limited to only EE, it is better to have a separate SCSS file in appropriate directory
within `app/assets/stylesheets`.
+See [backporting changes](#backporting-changes) for instructions on how to merge changes safely.
In some cases, this is not entirely possible or creating dedicated SCSS file is an overkill,
e.g. a text style of some component is different for EE. In such cases,
@@ -683,6 +684,19 @@ to avoid conflicts during CE to EE merge.
// EE-specific end
```
+### Backporting changes from EE to CE
+
+When working in EE-specific features, you might have to tweak a few files that are not EE-specific. Here is a workflow to make sure those changes end up backported safely into CE too.
+(This approach does not refer to changes introduced via [csslab](https://gitlab.com/gitlab-org/csslab/).)
+
+1. **Make your changes in the EE branch.** If possible, keep a separated commit (to be squashed) to help backporting and review.
+1. **Open merge request to EE project.**
+1. **Apply the changes you made to CE files in a branch of the CE project.** (Tip: Use `patch` with the diff from your commit in EE branch)
+1. **Open merge request to CE project**, referring it's a backport of EE changes and link to MR open in EE.
+1. Once EE MR is merged, the MR towards CE can be merged. **But not before**.
+
+**Note:** regarding SCSS, make sure the files living outside `/ee/` don't diverge between CE and EE projects.
+
## gitlab-svgs
Conflicts in `app/assets/images/icons.json` or `app/assets/images/icons.svg` can
diff --git a/features/project/issues/issues.feature b/features/project/issues/issues.feature
deleted file mode 100644
index 819354bb780..00000000000
--- a/features/project/issues/issues.feature
+++ /dev/null
@@ -1,180 +0,0 @@
-@project_issues
-Feature: Project Issues
- Background:
- Given I sign in as a user
- And I own project "Shop"
- And project "Shop" have "Release 0.4" open issue
- And project "Shop" have "Tweet control" open issue
- And project "Shop" have "Release 0.3" closed issue
- And I visit project "Shop" issues page
-
- Scenario: I should see open issues
- Given I should see "Release 0.4" in issues
- And I should not see "Release 0.3" in issues
-
- @javascript
- Scenario: I should see closed issues
- Given I click link "Closed"
- Then I should see "Release 0.3" in issues
- And I should not see "Release 0.4" in issues
-
- @javascript
- Scenario: I should see all issues
- Given I click link "All"
- Then I should see "Release 0.3" in issues
- And I should see "Release 0.4" in issues
-
- Scenario: I visit issue page
- Given I click link "Release 0.4"
- Then I should see issue "Release 0.4"
-
- Scenario: I submit new unassigned issue
- Given I click link "New Issue"
- And I submit new issue "500 error on profile"
- Then I should see issue "500 error on profile"
-
- @javascript
- Scenario: I submit new unassigned issue with labels
- Given project "Shop" has labels: "bug", "feature", "enhancement"
- And I click link "New Issue"
- And I submit new issue "500 error on profile" with label 'bug'
- Then I should see issue "500 error on profile"
- And I should see label 'bug' with issue
-
- @javascript
- Scenario: I comment issue
- Given I visit issue page "Release 0.4"
- And I leave a comment like "XML attached"
- Then I should see comment "XML attached"
- And I should see an error alert section within the comment form
-
- @javascript
- Scenario: Visiting Issues after being sorted the list
- Given I visit project "Shop" issues page
- And I sort the list by "Last updated"
- And I visit my project's home page
- And I visit project "Shop" issues page
- Then The list should be sorted by "Last updated"
-
- @javascript
- Scenario: Visiting Merge Requests after being sorted the list
- Given project "Shop" has a "Bugfix MR" merge request open
- And I visit project "Shop" issues page
- And I sort the list by "Last updated"
- And I visit project "Shop" merge requests page
- Then The list should be sorted by "Last updated"
-
- @javascript
- Scenario: Visiting Merge Requests from a differente Project after sorting
- Given project "Shop" has a "Bugfix MR" merge request open
- And I visit project "Shop" merge requests page
- And I sort the list by "Last updated"
- And I visit dashboard merge requests page
- Then The list should be sorted by "Last updated"
-
- @javascript
- Scenario: Sort issues by upvotes/downvotes
- Given project "Shop" have "Bugfix" open issue
- And issue "Release 0.4" have 2 upvotes and 1 downvote
- And issue "Tweet control" have 1 upvote and 2 downvotes
- And I sort the list by "Popularity"
- Then The list should be sorted by "Popularity"
-
- # Markdown
-
- @javascript
- Scenario: Headers inside the description should have ids generated for them.
- Given I visit issue page "Release 0.4"
- Then Header "Description header" should have correct id and link
-
- @javascript
- Scenario: Headers inside comments should not have ids generated for them.
- Given I visit issue page "Release 0.4"
- And I leave a comment with a header containing "Comment with a header"
- Then The comment with the header should not have an ID
-
- @javascript
- Scenario: Blocks inside comments should not build relative links
- Given I visit issue page "Release 0.4"
- And I leave a comment with code block
- Then The code block should be unchanged
-
- Scenario: Issues on empty project
- Given empty project "Empty Project"
- And I have an ssh key
- When I visit empty project page
- And I see empty project details with ssh clone info
- When I visit empty project's issues page
- Given I click link "New Issue"
- And I submit new issue "500 error on profile"
- Then I should see issue "500 error on profile"
-
- Scenario: Clickable labels
- Given issue 'Release 0.4' has label 'bug'
- And I visit project "Shop" issues page
- When I click label 'bug'
- And I should see "Release 0.4" in issues
- And I should not see "Tweet control" in issues
-
- @javascript
- Scenario: Issue notes should be editable with +1
- Given project "Shop" have "Release 0.4" open issue
- When I visit issue page "Release 0.4"
- And I leave a comment with a header containing "Comment with a header"
- Then The comment with the header should not have an ID
- And I edit the last comment with a +1
- Then I should see +1 in the description
-
- # Issue description preview
-
- @javascript
- Scenario: I can't preview without text
- Given I click link "New Issue"
- And I haven't written any description text
- Then The Markdown preview tab should say there is nothing to do
-
- @javascript
- Scenario: I can preview with text
- Given I click link "New Issue"
- And I write a description like ":+1: Nice"
- Then The Markdown preview tab should display rendered Markdown
-
- @javascript
- Scenario: I preview an issue description
- Given I click link "New Issue"
- And I preview a description text like "Bug fixed :smile:"
- Then I should see the Markdown preview
- And I should not see the Markdown text field
-
- @javascript
- Scenario: I can edit after preview
- Given I click link "New Issue"
- And I preview a description text like "Bug fixed :smile:"
- Then I should see the Markdown write tab
-
- @javascript
- Scenario: I can preview when editing an existing issue
- Given I click link "Release 0.4"
- And I click link "Edit" for the issue
- And I preview a description text like "Bug fixed :smile:"
- Then I should see the Markdown write tab
-
- @javascript
- Scenario: I can unsubscribe from issue
- Given project "Shop" have "Release 0.4" open issue
- When I visit issue page "Release 0.4"
- Then I should see that I am subscribed
- When I click the subscription toggle
- Then I should see that I am unsubscribed
-
- @javascript
- Scenario: I submit new unassigned issue as guest
- Given public project "Community"
- When I visit project "Community" page
- And I visit project "Community" issues page
- And I click link "New Issue"
- And I should not see assignee field
- And I should not see milestone field
- And I should not see labels field
- And I submit new issue "500 error on profile"
- Then I should see issue "500 error on profile"
diff --git a/features/project/issues/labels.feature b/features/project/issues/labels.feature
deleted file mode 100644
index 45de57f18e3..00000000000
--- a/features/project/issues/labels.feature
+++ /dev/null
@@ -1,48 +0,0 @@
-@project_issues
-Feature: Project Issues Labels
- Background:
- Given I sign in as a user
- And I own project "Shop"
- And project "Shop" has labels: "bug", "feature", "enhancement"
- Given I visit project "Shop" labels page
-
- Scenario: I should see labels list
- Then I should see label 'bug'
- And I should see label 'feature'
-
- Scenario: I create new label
- Given I visit project "Shop" new label page
- When I submit new label 'support'
- Then I should see label 'support'
-
- Scenario: I edit label
- Given I visit 'bug' label edit page
- When I change label 'bug' to 'fix'
- Then I should not see label 'bug'
- Then I should see label 'fix'
-
- Scenario: I remove label
- When I remove label 'bug'
- Then I should not see label 'bug'
-
- @javascript
- Scenario: I remove all labels
- When I delete all labels
- Then I should see labels help message
-
- Scenario: I create a label with invalid color
- Given I visit project "Shop" new label page
- When I submit new label with invalid color
- Then I should see label color error message
-
- Scenario: I create a label that already exists
- Given I visit project "Shop" new label page
- When I submit new label 'bug'
- Then I should see label label exist error message
-
- Scenario: I create the same label on another project
- Given I own project "Forum"
- And I visit project "Forum" labels page
- And I visit project "Forum" new label page
- When I submit new label 'bug'
- Then I should see label 'bug'
diff --git a/features/project/issues/milestones.feature b/features/project/issues/milestones.feature
index d121222308d..77c8ed6e5bf 100644
--- a/features/project/issues/milestones.feature
+++ b/features/project/issues/milestones.feature
@@ -39,4 +39,5 @@ Feature: Project Issues Milestones
Scenario: Headers inside the description should have ids generated for them.
Given I click link "v2.2"
+ # PLEASE USE the `have_header_with_correct_id_and_link(level, text, id, parent)` matcher on migrating this spec to rspec.
Then Header "Description header" should have correct id and link
diff --git a/features/steps/project/issues/issues.rb b/features/steps/project/issues/issues.rb
index 3cd26bb429b..baa78c23203 100644
--- a/features/steps/project/issues/issues.rb
+++ b/features/steps/project/issues/issues.rb
@@ -7,36 +7,14 @@ class Spinach::Features::ProjectIssues < Spinach::FeatureSteps
include SharedMarkdown
include SharedUser
- step 'I should see "Release 0.4" in issues' do
- expect(page).to have_content "Release 0.4"
- end
-
step 'I should not see "Release 0.3" in issues' do
expect(page).not_to have_content "Release 0.3"
end
- step 'I should not see "Tweet control" in issues' do
- expect(page).not_to have_content "Tweet control"
- end
-
- step 'I should see that I am subscribed' do
- wait_for_requests
- expect(find('.js-issuable-subscribe-button')).to have_css 'button.is-checked'
- end
-
- step 'I should see that I am unsubscribed' do
- wait_for_requests
- expect(find('.js-issuable-subscribe-button')).to have_css 'button:not(.is-checked)'
- end
-
step 'I click link "Closed"' do
find('.issues-state-filters [data-state="closed"] span', text: 'Closed').click
end
- step 'I click the subscription toggle' do
- find('.js-issuable-subscribe-button button').click
- end
-
step 'I should see "Release 0.3" in issues' do
expect(page).to have_content "Release 0.3"
end
@@ -51,24 +29,10 @@ class Spinach::Features::ProjectIssues < Spinach::FeatureSteps
expect(find('.issues-state-filters > .active')).to have_content 'All'
end
- step 'I click link "Release 0.4"' do
- click_link "Release 0.4"
- end
-
- step 'I should see issue "Release 0.4"' do
- expect(page).to have_content "Release 0.4"
- end
-
step 'I should see issue "Tweet control"' do
expect(page).to have_content "Tweet control"
end
- step 'I click link "New issue"' do
- page.within '#content-body' do
- page.has_link?('New Issue') ? click_link('New Issue') : click_link('New issue')
- end
- end
-
step 'I click "author" dropdown' do
page.find('.js-author-search').click
sleep 1
@@ -81,18 +45,6 @@ class Spinach::Features::ProjectIssues < Spinach::FeatureSteps
expect(users[1].text).to eq "#{current_user.name} #{current_user.to_reference}"
end
- step 'I submit new issue "500 error on profile"' do
- fill_in "issue_title", with: "500 error on profile"
- click_button "Submit issue"
- end
-
- step 'I submit new issue "500 error on profile" with label \'bug\'' do
- fill_in "issue_title", with: "500 error on profile"
- click_button "Label"
- click_link "bug"
- click_button "Submit issue"
- end
-
step 'I click link "500 error on profile"' do
click_link "500 error on profile"
end
@@ -103,13 +55,6 @@ class Spinach::Features::ProjectIssues < Spinach::FeatureSteps
end
end
- step 'I should see issue "500 error on profile"' do
- issue = Issue.find_by(title: "500 error on profile")
- expect(page).to have_content issue.title
- expect(page).to have_content issue.author_name
- expect(page).to have_content issue.project.name
- end
-
step 'I fill in issue search with "Re"' do
filter_issue "Re"
end
@@ -163,49 +108,6 @@ class Spinach::Features::ProjectIssues < Spinach::FeatureSteps
expect(find(issues_assignee_selector)).to have_content(assignee_name)
end
- step 'project "Shop" have "Release 0.4" open issue' do
- create(:issue,
- title: "Release 0.4",
- project: project,
- author: project.users.first,
- description: "# Description header"
- )
- wait_for_requests
- end
-
- step 'project "Shop" have "Tweet control" open issue' do
- create(:issue,
- title: "Tweet control",
- project: project,
- author: project.users.first)
- end
-
- step 'project "Shop" have "Bugfix" open issue' do
- create(:issue,
- title: "Bugfix",
- project: project,
- author: project.users.first)
- end
-
- step 'project "Shop" have "Release 0.3" closed issue' do
- create(:closed_issue,
- title: "Release 0.3",
- project: project,
- author: project.users.first)
- end
-
- step 'issue "Release 0.4" have 2 upvotes and 1 downvote' do
- awardable = Issue.find_by(title: 'Release 0.4')
- create_list(:award_emoji, 2, awardable: awardable)
- create(:award_emoji, :downvote, awardable: awardable)
- end
-
- step 'issue "Tweet control" have 1 upvote and 2 downvotes' do
- awardable = Issue.find_by(title: 'Tweet control')
- create(:award_emoji, :upvote, awardable: awardable)
- create_list(:award_emoji, 2, awardable: awardable, name: 'thumbsdown')
- end
-
step 'The list should be sorted by "Least popular"' do
page.within '.issues-list' do
page.within 'li.issue:nth-child(1)' do
@@ -225,69 +127,16 @@ class Spinach::Features::ProjectIssues < Spinach::FeatureSteps
end
end
- step 'The list should be sorted by "Popularity"' do
- page.within '.issues-list' do
- page.within 'li.issue:nth-child(1)' do
- expect(page).to have_content 'Release 0.4'
- expect(page).to have_content '2 1'
- end
-
- page.within 'li.issue:nth-child(2)' do
- expect(page).to have_content 'Tweet control'
- expect(page).to have_content '1 2'
- end
-
- page.within 'li.issue:nth-child(3)' do
- expect(page).to have_content 'Bugfix'
- expect(page).not_to have_content '0 0'
- end
- end
- end
-
- step 'empty project "Empty Project"' do
- create :project_empty_repo, name: 'Empty Project', namespace: @user.namespace
- end
-
When 'I visit empty project page' do
project = Project.find_by(name: 'Empty Project')
visit project_path(project)
end
- step 'I see empty project details with ssh clone info' do
- project = Project.find_by(name: 'Empty Project')
- page.all(:css, '.git-empty .clone').each do |element|
- expect(element.text).to include(project.url_to_repo)
- end
- end
-
When "I visit project \"Community\" issues page" do
project = Project.find_by(name: 'Community')
visit project_issues_path(project)
end
- When "I visit empty project's issues page" do
- project = Project.find_by(name: 'Empty Project')
- visit project_issues_path(project)
- end
-
- step 'I leave a comment with code block' do
- page.within(".js-main-target-form") do
- fill_in "note[note]", with: "```\nCommand [1]: /usr/local/bin/git , see [text](doc/text)\n```"
- click_button "Comment"
- sleep 0.05
- end
- end
-
- step 'I should see an error alert section within the comment form' do
- page.within(".js-main-target-form") do
- find(".error-alert")
- end
- end
-
- step 'The code block should be unchanged' do
- expect(page).to have_content("```\nCommand [1]: /usr/local/bin/git , see [text](doc/text)\n```")
- end
-
step 'project \'Shop\' has issue \'Bugfix1\' with description: \'Description for issue1\'' do
create(:issue, title: 'Bugfix1', description: 'Description for issue1', project: project)
end
@@ -320,36 +169,6 @@ class Spinach::Features::ProjectIssues < Spinach::FeatureSteps
expect(page).not_to have_content 'Bugfix1'
end
- step 'issue \'Release 0.4\' has label \'bug\'' do
- label = project.labels.create!(name: 'bug', color: '#990000')
- issue = Issue.find_by!(title: 'Release 0.4')
- issue.labels << label
- end
-
- step 'I click label \'bug\'' do
- page.within ".issues-list" do
- click_link 'bug'
- end
- end
-
- step 'I should not see labels field' do
- page.within '.issue-form' do
- expect(page).not_to have_content("Labels")
- end
- end
-
- step 'I should not see milestone field' do
- page.within '.issue-form' do
- expect(page).not_to have_content("Milestone")
- end
- end
-
- step 'I should not see assignee field' do
- page.within '.issue-form' do
- expect(page).not_to have_content("Assign to")
- end
- end
-
def filter_issue(text)
fill_in 'issuable_search', with: text
end
diff --git a/features/steps/project/issues/labels.rb b/features/steps/project/issues/labels.rb
deleted file mode 100644
index 4df96e081f9..00000000000
--- a/features/steps/project/issues/labels.rb
+++ /dev/null
@@ -1,101 +0,0 @@
-class Spinach::Features::ProjectIssuesLabels < Spinach::FeatureSteps
- include SharedAuthentication
- include SharedProject
- include SharedPaths
-
- step 'I visit \'bug\' label edit page' do
- visit edit_project_label_path(project, bug_label)
- end
-
- step 'I remove label \'bug\'' do
- page.within "#project_label_#{bug_label.id}" do
- first(:link, 'Delete').click
- end
- end
-
- step 'I delete all labels' do
- page.within '.labels' do
- page.all('.label-list-item').each do
- first('.remove-row').click
- first(:link, 'Delete label').click
- end
- end
- end
-
- step 'I should see labels help message' do
- page.within '.labels' do
- expect(page).to have_content 'Generate a default set of labels'
- expect(page).to have_content 'New label'
- end
- end
-
- step 'I submit new label \'support\'' do
- fill_in 'Title', with: 'support'
- fill_in 'Background color', with: '#F95610'
- click_button 'Create label'
- end
-
- step 'I submit new label \'bug\'' do
- fill_in 'Title', with: 'bug'
- fill_in 'Background color', with: '#F95610'
- click_button 'Create label'
- end
-
- step 'I submit new label with invalid color' do
- fill_in 'Title', with: 'support'
- fill_in 'Background color', with: '#12'
- click_button 'Create label'
- end
-
- step 'I should see label label exist error message' do
- page.within '.label-form' do
- expect(page).to have_content 'Title has already been taken'
- end
- end
-
- step 'I should see label color error message' do
- page.within '.label-form' do
- expect(page).to have_content 'Color must be a valid color code'
- end
- end
-
- step 'I should see label \'feature\'' do
- page.within '.other-labels .manage-labels-list' do
- expect(page).to have_content 'feature'
- end
- end
-
- step 'I should see label \'bug\'' do
- page.within '.other-labels .manage-labels-list' do
- expect(page).to have_content 'bug'
- end
- end
-
- step 'I should not see label \'bug\'' do
- page.within '.other-labels .manage-labels-list' do
- expect(page).not_to have_content 'bug'
- end
- end
-
- step 'I should see label \'support\'' do
- page.within '.other-labels .manage-labels-list' do
- expect(page).to have_content 'support'
- end
- end
-
- step 'I change label \'bug\' to \'fix\'' do
- fill_in 'Title', with: 'fix'
- fill_in 'Background color', with: '#F15610'
- click_button 'Save changes'
- end
-
- step 'I should see label \'fix\'' do
- page.within '.other-labels .manage-labels-list' do
- expect(page).to have_content 'fix'
- end
- end
-
- def bug_label
- project.labels.find_or_create_by(title: 'bug')
- end
-end
diff --git a/features/steps/shared/issuable.rb b/features/steps/shared/issuable.rb
index f90247c3fe8..a9174efd334 100644
--- a/features/steps/shared/issuable.rb
+++ b/features/steps/shared/issuable.rb
@@ -105,17 +105,6 @@ module SharedIssuable
edit_issuable
end
- step 'I click link "Edit" for the issue' do
- edit_issuable
- end
-
- step 'I sort the list by "Last updated"' do
- find('button.dropdown-toggle').click
- page.within('.content ul.dropdown-menu.dropdown-menu-align-right li') do
- click_link "Last updated"
- end
- end
-
step 'I sort the list by "Least popular"' do
find('button.dropdown-toggle').click
@@ -124,18 +113,6 @@ module SharedIssuable
end
end
- step 'I sort the list by "Popularity"' do
- find('button.dropdown-toggle').click
-
- page.within('.content ul.dropdown-menu.dropdown-menu-align-right li') do
- click_link 'Popularity'
- end
- end
-
- step 'The list should be sorted by "Last updated"' do
- expect(find('.issues-filters')).to have_content('Last updated')
- end
-
step 'I click link "Next" in the sidebar' do
page.within '.issuable-sidebar' do
click_link 'Next'
diff --git a/features/steps/shared/markdown.rb b/features/steps/shared/markdown.rb
index c2bec2a6320..c66280127e9 100644
--- a/features/steps/shared/markdown.rb
+++ b/features/steps/shared/markdown.rb
@@ -18,43 +18,6 @@ module SharedMarkdown
expect(find('.gfm-form .js-md-preview')).not_to be_visible
end
- step 'The Markdown preview tab should say there is nothing to do' do
- page.within('.gfm-form') do
- find('.js-md-preview-button').click
- expect(find('.js-md-preview')).to have_content('Nothing to preview.')
- end
- end
-
- step 'I should not see the Markdown text field' do
- expect(find('.gfm-form textarea')).not_to be_visible
- end
-
- step 'I should see the Markdown write tab' do
- expect(first('.gfm-form')).to have_link('Write', visible: true)
- end
-
- step 'I should see the Markdown preview' do
- expect(find('.gfm-form')).to have_css('.js-md-preview', visible: true)
- end
-
- step 'The Markdown preview tab should display rendered Markdown' do
- page.within('.gfm-form') do
- find('.js-md-preview-button').click
- expect(find('.js-md-preview')).to have_css('gl-emoji', visible: true)
- end
- end
-
- step 'I write a description like ":+1: Nice"' do
- find('.gfm-form').fill_in 'Description', with: ':+1: Nice'
- end
-
- step 'I preview a description text like "Bug fixed :smile:"' do
- page.within(first('.gfm-form')) do
- fill_in 'Description', with: 'Bug fixed :smile:'
- click_link 'Preview'
- end
- end
-
step 'I haven\'t written any description text' do
find('.gfm-form').fill_in 'Description', with: ''
end
diff --git a/features/steps/shared/note.rb b/features/steps/shared/note.rb
index 95f0cd2156e..cbe1cae096e 100644
--- a/features/steps/shared/note.rb
+++ b/features/steps/shared/note.rb
@@ -114,34 +114,12 @@ module SharedNote
end
end
- step 'I should see comment "XML attached"' do
- page.within(".note") do
- expect(page).to have_content("XML attached")
- end
- end
-
step 'I should see no notes at all' do
expect(page).not_to have_css('.note')
end
# Markdown
- step 'I leave a comment with a header containing "Comment with a header"' do
- page.within(".js-main-target-form") do
- fill_in "note[note]", with: "# Comment with a header"
- click_button "Comment"
- end
-
- wait_for_requests
- end
-
- step 'The comment with the header should not have an ID' do
- page.within(".note-body > .note-text") do
- expect(page).to have_content("Comment with a header")
- expect(page).not_to have_css("#comment-with-a-header")
- end
- end
-
step 'I edit the last comment with a +1' do
page.within(".main-notes-list") do
note = find('.note')
diff --git a/features/steps/shared/paths.rb b/features/steps/shared/paths.rb
index bff0d58aaf4..cc893b8391e 100644
--- a/features/steps/shared/paths.rb
+++ b/features/steps/shared/paths.rb
@@ -96,10 +96,6 @@ module SharedPaths
visit assigned_issues_dashboard_path
end
- step 'I visit dashboard merge requests page' do
- visit assigned_mrs_dashboard_path
- end
-
step 'I visit dashboard search page' do
visit search_path
end
@@ -200,10 +196,6 @@ module SharedPaths
# Generic Project
# ----------------------------------------
- step "I visit my project's home page" do
- visit project_path(@project)
- end
-
step "I visit my project's settings page" do
visit edit_project_path(@project)
end
@@ -339,20 +331,11 @@ module SharedPaths
visit project_commit_path(@project, sample_commit.id)
end
- step 'I visit project "Shop" issues page' do
- visit project_issues_path(project)
- end
-
step 'I visit issue page "Release 0.4"' do
issue = Issue.find_by(title: "Release 0.4")
visit project_issue_path(issue.project, issue)
end
- step 'I visit project "Shop" labels page' do
- project = Project.find_by(name: 'Shop')
- visit project_labels_path(project)
- end
-
step 'I visit project "Forum" labels page' do
project = Project.find_by(name: 'Forum')
visit project_labels_path(project)
@@ -394,10 +377,6 @@ module SharedPaths
wait_for_requests
end
- step 'I visit project "Shop" merge requests page' do
- visit project_merge_requests_path(project)
- end
-
step 'I visit forked project "Shop" merge requests page' do
visit project_merge_requests_path(project)
end
@@ -418,11 +397,6 @@ module SharedPaths
# Visibility Projects
# ----------------------------------------
- step 'I visit project "Community" page' do
- project = Project.find_by(name: "Community")
- visit project_path(project)
- end
-
step 'I visit project "Community" source page' do
project = Project.find_by(name: 'Community')
visit project_tree_path(project, root_ref)
@@ -442,11 +416,6 @@ module SharedPaths
# Empty Projects
# ----------------------------------------
- step "I visit empty project page" do
- project = Project.find_by(name: "Empty Public Project")
- visit project_path(project)
- end
-
step "I should not see command line instructions" do
expect(page).not_to have_css('.empty_wrapper')
end
diff --git a/features/steps/shared/project.rb b/features/steps/shared/project.rb
index 07a0e2e072c..be848ebafa0 100644
--- a/features/steps/shared/project.rb
+++ b/features/steps/shared/project.rb
@@ -236,10 +236,6 @@ module SharedProject
@project.update(public_builds: false)
end
- step 'project "Shop" has a "Bugfix MR" merge request open' do
- create(:merge_request, title: "Bugfix MR", target_project: project, source_project: project, author: project.users.first)
- end
-
def user_owns_project(user_name:, project_name:, visibility: :private)
user = user_exists(user_name, username: user_name.gsub(/\s/, '').underscore)
project = Project.find_by(name: project_name)
diff --git a/features/steps/shared/user.rb b/features/steps/shared/user.rb
index 9856c510aa0..9cadc91769d 100644
--- a/features/steps/shared/user.rb
+++ b/features/steps/shared/user.rb
@@ -19,10 +19,6 @@ module SharedUser
User.find_by(name: name) || create(:user, { name: name, admin: false }.merge(options))
end
- step 'I have an ssh key' do
- create(:personal_key, user: @user)
- end
-
step 'I have no ssh keys' do
@user.keys.delete_all
end
diff --git a/lib/gitlab/metrics/sidekiq_metrics_exporter.rb b/lib/gitlab/metrics/sidekiq_metrics_exporter.rb
index db8bdde74b2..47b4af5d649 100644
--- a/lib/gitlab/metrics/sidekiq_metrics_exporter.rb
+++ b/lib/gitlab/metrics/sidekiq_metrics_exporter.rb
@@ -4,6 +4,8 @@ require 'prometheus/client/rack/exporter'
module Gitlab
module Metrics
class SidekiqMetricsExporter < Daemon
+ LOG_FILENAME = File.join(Rails.root, 'log', 'sidekiq_exporter.log')
+
def enabled?
Gitlab::Metrics.metrics_folder_present? && settings.enabled
end
@@ -17,7 +19,13 @@ module Gitlab
attr_reader :server
def start_working
- @server = ::WEBrick::HTTPServer.new(Port: settings.port, BindAddress: settings.address)
+ logger = WEBrick::Log.new(LOG_FILENAME)
+ access_log = [
+ [logger, WEBrick::AccessLog::COMBINED_LOG_FORMAT]
+ ]
+
+ @server = ::WEBrick::HTTPServer.new(Port: settings.port, BindAddress: settings.address,
+ Logger: logger, AccessLog: access_log)
server.mount "/", Rack::Handler::WEBrick, rack_app
server.start
end
diff --git a/lib/gitlab/performance_bar.rb b/lib/gitlab/performance_bar.rb
index 6c2b2036074..92a308a12dc 100644
--- a/lib/gitlab/performance_bar.rb
+++ b/lib/gitlab/performance_bar.rb
@@ -5,6 +5,7 @@ module Gitlab
def self.enabled?(user = nil)
return true if Rails.env.development?
+ return true if user&.admin?
return false unless user && allowed_group_id
allowed_user_ids.include?(user.id)
diff --git a/scripts/trigger-build-omnibus b/scripts/trigger-build-omnibus
index 85ea4aa74ac..95f35b44f5a 100755
--- a/scripts/trigger-build-omnibus
+++ b/scripts/trigger-build-omnibus
@@ -9,6 +9,7 @@ module Omnibus
class Trigger
TOKEN = ENV['BUILD_TRIGGER_TOKEN']
+ TRIGGERER = ENV['CI_PROJECT_NAME']
def initialize
@uri = URI("https://gitlab.com/api/v4/projects/#{CGI.escape(Omnibus::PROJECT_PATH)}/trigger/pipeline")
@@ -32,7 +33,7 @@ module Omnibus
private
def ee?
- File.exist?('CHANGELOG-EE.md')
+ TRIGGERER == 'gitlab-ee' || File.exist?('CHANGELOG-EE.md')
end
def env_params
diff --git a/spec/controllers/projects/branches_controller_spec.rb b/spec/controllers/projects/branches_controller_spec.rb
index 3b9e06cb5ad..16fb377b002 100644
--- a/spec/controllers/projects/branches_controller_spec.rb
+++ b/spec/controllers/projects/branches_controller_spec.rb
@@ -398,6 +398,22 @@ describe Projects::BranchesController do
end
end
+ # We need :request_store because Gitaly only counts the queries whenever
+ # `RequestStore.active?` in GitalyClient.enforce_gitaly_request_limits
+ # And the main goal of this test is making sure TooManyInvocationsError
+ # was not raised whenever the cache is enabled yet cold.
+ context 'when cache is enabled yet cold', :request_store do
+ it 'return with a status 200' do
+ get :index,
+ namespace_id: project.namespace,
+ project_id: project,
+ state: 'all',
+ format: :html
+
+ expect(response).to have_gitlab_http_status(200)
+ end
+ end
+
context 'when branch contains an invalid UTF-8 sequence' do
before do
project.repository.create_branch("wrong-\xE5-utf8-sequence")
@@ -414,7 +430,7 @@ describe Projects::BranchesController do
end
end
- context 'when depreated sort/search/page parameters are specified' do
+ context 'when deprecated sort/search/page parameters are specified' do
it 'returns with a status 301 when sort specified' do
get :index,
namespace_id: project.namespace,
diff --git a/spec/features/dashboard/issues_filter_spec.rb b/spec/features/dashboard/issues_filter_spec.rb
index 8759950e013..029fc45c791 100644
--- a/spec/features/dashboard/issues_filter_spec.rb
+++ b/spec/features/dashboard/issues_filter_spec.rb
@@ -1,7 +1,7 @@
require 'spec_helper'
feature 'Dashboard Issues filtering', :js do
- include SortingHelper
+ include Spec::Support::Helpers::Features::SortingHelpers
let(:user) { create(:user) }
let(:project) { create(:project) }
@@ -90,14 +90,14 @@ feature 'Dashboard Issues filtering', :js do
context 'sorting' do
it 'shows sorted issues' do
- sorting_by('Created date')
+ sort_by('Created date')
visit_issues
expect(find('.issues-filters')).to have_content('Created date')
end
it 'keeps sorting issues after visiting Projects Issues page' do
- sorting_by('Created date')
+ sort_by('Created date')
visit project_issues_path(project)
expect(find('.issues-filters')).to have_content('Created date')
diff --git a/spec/features/dashboard/merge_requests_spec.rb b/spec/features/dashboard/merge_requests_spec.rb
index c8f3a8449f5..4a9344115d2 100644
--- a/spec/features/dashboard/merge_requests_spec.rb
+++ b/spec/features/dashboard/merge_requests_spec.rb
@@ -1,8 +1,8 @@
require 'spec_helper'
feature 'Dashboard Merge Requests' do
+ include Spec::Support::Helpers::Features::SortingHelpers
include FilterItemSelectHelper
- include SortingHelper
include ProjectForksHelper
let(:current_user) { create :user }
@@ -115,7 +115,7 @@ feature 'Dashboard Merge Requests' do
end
it 'shows sorted merge requests' do
- sorting_by('Created date')
+ sort_by('Created date')
visit merge_requests_dashboard_path(assignee_id: current_user.id)
@@ -123,7 +123,7 @@ feature 'Dashboard Merge Requests' do
end
it 'keeps sorting merge requests after visiting Projects MR page' do
- sorting_by('Created date')
+ sort_by('Created date')
visit project_merge_requests_path(project)
diff --git a/spec/features/issues/user_uses_slash_commands_spec.rb b/spec/features/issues/user_uses_slash_commands_spec.rb
index ea7a97d02a0..ff2a0e15719 100644
--- a/spec/features/issues/user_uses_slash_commands_spec.rb
+++ b/spec/features/issues/user_uses_slash_commands_spec.rb
@@ -1,7 +1,7 @@
require 'rails_helper'
feature 'Issues > User uses quick actions', :js do
- include QuickActionsHelpers
+ include Spec::Support::Helpers::Features::NotesHelpers
it_behaves_like 'issuable record that supports quick actions in its description and notes', :issue do
let(:issuable) { create(:issue, project: project) }
@@ -36,7 +36,7 @@ feature 'Issues > User uses quick actions', :js do
context 'when the current user can update the due date' do
it 'does not create a note, and sets the due date accordingly' do
- write_note("/due 2016-08-28")
+ add_note("/due 2016-08-28")
expect(page).not_to have_content '/due 2016-08-28'
expect(page).to have_content 'Commands applied'
@@ -57,7 +57,7 @@ feature 'Issues > User uses quick actions', :js do
end
it 'does not create a note, and sets the due date accordingly' do
- write_note("/due 2016-08-28")
+ add_note("/due 2016-08-28")
expect(page).not_to have_content 'Commands applied'
@@ -75,7 +75,7 @@ feature 'Issues > User uses quick actions', :js do
it 'does not create a note, and removes the due date accordingly' do
expect(issue.due_date).to eq Date.new(2016, 8, 28)
- write_note("/remove_due_date")
+ add_note("/remove_due_date")
expect(page).not_to have_content '/remove_due_date'
expect(page).to have_content 'Commands applied'
@@ -96,7 +96,7 @@ feature 'Issues > User uses quick actions', :js do
end
it 'does not create a note, and sets the due date accordingly' do
- write_note("/remove_due_date")
+ add_note("/remove_due_date")
expect(page).not_to have_content 'Commands applied'
@@ -111,7 +111,7 @@ feature 'Issues > User uses quick actions', :js do
let(:issue) { create(:issue, project: project) }
it 'does not recognize the command nor create a note' do
- write_note("/wip")
+ add_note("/wip")
expect(page).not_to have_content '/wip'
end
@@ -123,7 +123,7 @@ feature 'Issues > User uses quick actions', :js do
context 'when the current user can update issues' do
it 'does not create a note, and marks the issue as a duplicate' do
- write_note("/duplicate ##{original_issue.to_reference}")
+ add_note("/duplicate ##{original_issue.to_reference}")
expect(page).not_to have_content "/duplicate #{original_issue.to_reference}"
expect(page).to have_content 'Commands applied'
@@ -143,7 +143,7 @@ feature 'Issues > User uses quick actions', :js do
end
it 'does not create a note, and does not mark the issue as a duplicate' do
- write_note("/duplicate ##{original_issue.to_reference}")
+ add_note("/duplicate ##{original_issue.to_reference}")
expect(page).not_to have_content 'Commands applied'
expect(page).not_to have_content "marked this issue as a duplicate of #{original_issue.to_reference}"
@@ -166,7 +166,7 @@ feature 'Issues > User uses quick actions', :js do
end
it 'moves the issue' do
- write_note("/move #{target_project.full_path}")
+ add_note("/move #{target_project.full_path}")
expect(page).to have_content 'Commands applied'
expect(issue.reload).to be_closed
@@ -186,7 +186,7 @@ feature 'Issues > User uses quick actions', :js do
end
it 'does not move the issue' do
- write_note("/move #{project_unauthorized.full_path}")
+ add_note("/move #{project_unauthorized.full_path}")
expect(page).not_to have_content 'Commands applied'
expect(issue.reload).to be_open
@@ -200,7 +200,7 @@ feature 'Issues > User uses quick actions', :js do
end
it 'does not move the issue' do
- write_note("/move not/valid")
+ add_note("/move not/valid")
expect(page).not_to have_content 'Commands applied'
expect(issue.reload).to be_open
@@ -223,7 +223,7 @@ feature 'Issues > User uses quick actions', :js do
end
it 'applies the commands to both issues and moves the issue' do
- write_note("/label ~#{bug.title} ~#{wontfix.title}\n\n/milestone %\"#{milestone.title}\"\n\n/move #{target_project.full_path}")
+ add_note("/label ~#{bug.title} ~#{wontfix.title}\n\n/milestone %\"#{milestone.title}\"\n\n/move #{target_project.full_path}")
expect(page).to have_content 'Commands applied'
expect(issue.reload).to be_closed
@@ -242,7 +242,7 @@ feature 'Issues > User uses quick actions', :js do
end
it 'moves the issue and applies the commands to both issues' do
- write_note("/move #{target_project.full_path}\n\n/label ~#{bug.title} ~#{wontfix.title}\n\n/milestone %\"#{milestone.title}\"")
+ add_note("/move #{target_project.full_path}\n\n/label ~#{bug.title} ~#{wontfix.title}\n\n/milestone %\"#{milestone.title}\"")
expect(page).to have_content 'Commands applied'
expect(issue.reload).to be_closed
diff --git a/spec/features/merge_request/user_uses_slash_commands_spec.rb b/spec/features/merge_request/user_uses_slash_commands_spec.rb
index bd739e69d6c..7f261b580f7 100644
--- a/spec/features/merge_request/user_uses_slash_commands_spec.rb
+++ b/spec/features/merge_request/user_uses_slash_commands_spec.rb
@@ -1,7 +1,7 @@
require 'rails_helper'
describe 'Merge request > User uses quick actions', :js do
- include QuickActionsHelpers
+ include Spec::Support::Helpers::Features::NotesHelpers
let(:project) { create(:project, :public, :repository) }
let(:user) { project.creator }
@@ -33,7 +33,7 @@ describe 'Merge request > User uses quick actions', :js do
describe 'toggling the WIP prefix in the title from note' do
context 'when the current user can toggle the WIP prefix' do
it 'adds the WIP: prefix to the title' do
- write_note("/wip")
+ add_note("/wip")
expect(page).not_to have_content '/wip'
expect(page).to have_content 'Commands applied'
@@ -44,7 +44,7 @@ describe 'Merge request > User uses quick actions', :js do
it 'removes the WIP: prefix from the title' do
merge_request.title = merge_request.wip_title
merge_request.save
- write_note("/wip")
+ add_note("/wip")
expect(page).not_to have_content '/wip'
expect(page).to have_content 'Commands applied'
@@ -62,7 +62,7 @@ describe 'Merge request > User uses quick actions', :js do
end
it 'does not change the WIP prefix' do
- write_note("/wip")
+ add_note("/wip")
expect(page).not_to have_content '/wip'
expect(page).not_to have_content 'Commands applied'
@@ -75,7 +75,7 @@ describe 'Merge request > User uses quick actions', :js do
describe 'merging the MR from the note' do
context 'when the current user can merge the MR' do
it 'merges the MR' do
- write_note("/merge")
+ add_note("/merge")
expect(page).to have_content 'Commands applied'
@@ -90,7 +90,7 @@ describe 'Merge request > User uses quick actions', :js do
end
it 'does not merge the MR' do
- write_note("/merge")
+ add_note("/merge")
expect(page).not_to have_content 'Your commands have been executed!'
@@ -107,7 +107,7 @@ describe 'Merge request > User uses quick actions', :js do
end
it 'does not merge the MR' do
- write_note("/merge")
+ add_note("/merge")
expect(page).not_to have_content 'Your commands have been executed!'
@@ -118,7 +118,7 @@ describe 'Merge request > User uses quick actions', :js do
describe 'adding a due date from note' do
it 'does not recognize the command nor create a note' do
- write_note('/due 2016-08-28')
+ add_note('/due 2016-08-28')
expect(page).not_to have_content '/due 2016-08-28'
end
@@ -162,7 +162,7 @@ describe 'Merge request > User uses quick actions', :js do
describe '/target_branch command from note' do
context 'when the current user can change target branch' do
it 'changes target branch from a note' do
- write_note("message start \n/target_branch merge-test\n message end.")
+ add_note("message start \n/target_branch merge-test\n message end.")
wait_for_requests
expect(page).not_to have_content('/target_branch')
@@ -173,7 +173,7 @@ describe 'Merge request > User uses quick actions', :js do
end
it 'does not fail when target branch does not exists' do
- write_note('/target_branch totally_not_existing_branch')
+ add_note('/target_branch totally_not_existing_branch')
expect(page).not_to have_content('/target_branch')
@@ -190,7 +190,7 @@ describe 'Merge request > User uses quick actions', :js do
end
it 'does not change target branch' do
- write_note('/target_branch merge-test')
+ add_note('/target_branch merge-test')
expect(page).not_to have_content '/target_branch merge-test'
diff --git a/spec/features/projects/issues/user_comments_on_issue_spec.rb b/spec/features/projects/issues/user_comments_on_issue_spec.rb
new file mode 100644
index 00000000000..c45fdc7642f
--- /dev/null
+++ b/spec/features/projects/issues/user_comments_on_issue_spec.rb
@@ -0,0 +1,73 @@
+require "spec_helper"
+
+describe "User comments on issue", :js do
+ include Spec::Support::Helpers::Features::NotesHelpers
+
+ let(:project) { create(:project_empty_repo, :public) }
+ let(:issue) { create(:issue, project: project) }
+ let(:user) { create(:user) }
+
+ before do
+ project.add_guest(user)
+ sign_in(user)
+
+ visit(project_issue_path(project, issue))
+ end
+
+ context "when adding comments" do
+ it "adds comment" do
+ content = "XML attached"
+ target_form = ".js-main-target-form"
+
+ add_note(content)
+
+ page.within(".note") do
+ expect(page).to have_content(content)
+ end
+
+ page.within(target_form) do
+ find(".error-alert", visible: false)
+ end
+ end
+
+ it "adds comment with code block" do
+ comment = "```\nCommand [1]: /usr/local/bin/git , see [text](doc/text)\n```"
+
+ add_note(comment)
+
+ expect(page).to have_content(comment)
+ end
+ end
+
+ context "when editing comments" do
+ it "edits comment" do
+ add_note("# Comment with a header")
+
+ page.within(".note-body > .note-text") do
+ expect(page).to have_content("Comment with a header").and have_no_css("#comment-with-a-header")
+ end
+
+ page.within(".main-notes-list") do
+ note = find(".note")
+
+ note.hover
+ note.find(".js-note-edit").click
+ end
+
+ expect(page).to have_css(".current-note-edit-form textarea")
+
+ comment = "+1 Awesome!"
+
+ page.within(".current-note-edit-form") do
+ fill_in("note[note]", with: comment)
+ click_button("Save comment")
+ end
+
+ wait_for_requests
+
+ page.within(".note") do
+ expect(page).to have_content(comment)
+ end
+ end
+ end
+end
diff --git a/spec/features/projects/issues/user_creates_issue_spec.rb b/spec/features/projects/issues/user_creates_issue_spec.rb
new file mode 100644
index 00000000000..e76f7c5589d
--- /dev/null
+++ b/spec/features/projects/issues/user_creates_issue_spec.rb
@@ -0,0 +1,87 @@
+require "spec_helper"
+
+describe "User creates issue" do
+ let(:project) { create(:project_empty_repo, :public) }
+ let(:user) { create(:user) }
+
+ context "when signed in as guest" do
+ before do
+ project.add_guest(user)
+ sign_in(user)
+
+ visit(new_project_issue_path(project))
+ end
+
+ it "creates issue" do
+ page.within(".issue-form") do
+ expect(page).to have_no_content("Assign to")
+ .and have_no_content("Labels")
+ .and have_no_content("Milestone")
+ end
+
+ issue_title = "500 error on profile"
+
+ fill_in("Title", with: issue_title)
+ click_button("Submit issue")
+
+ expect(page).to have_content(issue_title)
+ .and have_content(user.name)
+ .and have_content(project.name)
+ end
+ end
+
+ context "when signed in as developer", :js do
+ before do
+ project.add_developer(user)
+ sign_in(user)
+
+ visit(new_project_issue_path(project))
+ end
+
+ context "when previewing" do
+ it "previews content" do
+ form = first(".gfm-form")
+ textarea = first(".gfm-form textarea")
+
+ page.within(form) do
+ click_link("Preview")
+
+ preview = find(".js-md-preview") # this element is findable only when the "Preview" link is clicked.
+
+ expect(preview).to have_content("Nothing to preview.")
+
+ click_link("Write")
+ fill_in("Description", with: "Bug fixed :smile:")
+ click_link("Preview")
+
+ expect(preview).to have_css("gl-emoji")
+ expect(textarea).not_to be_visible
+ end
+ end
+ end
+
+ context "with labels" do
+ LABEL_TITLES = %w(bug feature enhancement).freeze
+
+ before do
+ LABEL_TITLES.each do |title|
+ create(:label, project: project, title: title)
+ end
+ end
+
+ it "creates issue" do
+ issue_title = "500 error on profile"
+
+ fill_in("Title", with: issue_title)
+ click_button("Label")
+ click_link(LABEL_TITLES.first)
+ click_button("Submit issue")
+
+ expect(page).to have_content(issue_title)
+ .and have_content(user.name)
+ .and have_content(project.name)
+ .and have_content(LABEL_TITLES.first)
+ end
+ end
+ end
+end
diff --git a/spec/features/projects/issues/user_edits_issue_spec.rb b/spec/features/projects/issues/user_edits_issue_spec.rb
new file mode 100644
index 00000000000..1d9c3abc20f
--- /dev/null
+++ b/spec/features/projects/issues/user_edits_issue_spec.rb
@@ -0,0 +1,25 @@
+require "spec_helper"
+
+describe "User edits issue", :js do
+ set(:project) { create(:project_empty_repo, :public) }
+ set(:user) { create(:user) }
+ set(:issue) { create(:issue, project: project, author: user) }
+
+ before do
+ project.add_developer(user)
+ sign_in(user)
+
+ visit(edit_project_issue_path(project, issue))
+ end
+
+ it "previews content" do
+ form = first(".gfm-form")
+
+ page.within(form) do
+ fill_in("Description", with: "Bug fixed :smile:")
+ click_link("Preview")
+ end
+
+ expect(form).to have_link("Write")
+ end
+end
diff --git a/spec/features/projects/issues/user_sorts_issues_spec.rb b/spec/features/projects/issues/user_sorts_issues_spec.rb
new file mode 100644
index 00000000000..34148ae0116
--- /dev/null
+++ b/spec/features/projects/issues/user_sorts_issues_spec.rb
@@ -0,0 +1,42 @@
+require "spec_helper"
+
+describe "User sorts issues" do
+ set(:project) { create(:project_empty_repo, :public) }
+ set(:issue1) { create(:issue, project: project) }
+ set(:issue2) { create(:issue, project: project) }
+ set(:issue3) { create(:issue, project: project) }
+
+ before do
+ create_list(:award_emoji, 2, :upvote, awardable: issue1)
+ create_list(:award_emoji, 2, :downvote, awardable: issue2)
+ create(:award_emoji, :downvote, awardable: issue1)
+ create(:award_emoji, :upvote, awardable: issue2)
+
+ visit(project_issues_path(project))
+ end
+
+ it "sorts by popularity" do
+ find("button.dropdown-toggle").click
+
+ page.within(".content ul.dropdown-menu.dropdown-menu-align-right li") do
+ click_link("Popularity")
+ end
+
+ page.within(".issues-list") do
+ page.within("li.issue:nth-child(1)") do
+ expect(page).to have_content(issue1.title)
+ expect(page).to have_content("2 1")
+ end
+
+ page.within("li.issue:nth-child(2)") do
+ expect(page).to have_content(issue2.title)
+ expect(page).to have_content("1 2")
+ end
+
+ page.within("li.issue:nth-child(3)") do
+ expect(page).to have_content(issue3.title)
+ expect(page).not_to have_content("0 0")
+ end
+ end
+ end
+end
diff --git a/spec/features/projects/issues/user_toggles_subscription_spec.rb b/spec/features/projects/issues/user_toggles_subscription_spec.rb
new file mode 100644
index 00000000000..117a614b980
--- /dev/null
+++ b/spec/features/projects/issues/user_toggles_subscription_spec.rb
@@ -0,0 +1,28 @@
+require "spec_helper"
+
+describe "User toggles subscription", :js do
+ set(:project) { create(:project_empty_repo, :public) }
+ set(:user) { create(:user) }
+ set(:issue) { create(:issue, project: project, author: user) }
+
+ before do
+ project.add_developer(user)
+ sign_in(user)
+
+ visit(project_issue_path(project, issue))
+ end
+
+ it "unsibscribes from issue" do
+ subscription_button = find(".js-issuable-subscribe-button")
+
+ # Check we're subscribed.
+ expect(subscription_button).to have_css("button.is-checked")
+
+ # Toggle subscription.
+ find(".js-issuable-subscribe-button button").click
+ wait_for_requests
+
+ # Check we're unsubscribed.
+ expect(subscription_button).to have_css("button:not(.is-checked)")
+ end
+end
diff --git a/spec/features/projects/issues/user_views_issue_spec.rb b/spec/features/projects/issues/user_views_issue_spec.rb
new file mode 100644
index 00000000000..f7f2cde3d64
--- /dev/null
+++ b/spec/features/projects/issues/user_views_issue_spec.rb
@@ -0,0 +1,16 @@
+require "spec_helper"
+
+describe "User views issue" do
+ set(:project) { create(:project_empty_repo, :public) }
+ set(:user) { create(:user) }
+ set(:issue) { create(:issue, project: project, description: "# Description header", author: user) }
+
+ before do
+ project.add_guest(user)
+ sign_in(user)
+
+ visit(project_issue_path(project, issue))
+ end
+
+ it { expect(page).to have_header_with_correct_id_and_link(1, "Description header", "description-header") }
+end
diff --git a/spec/features/projects/issues/user_views_issues_spec.rb b/spec/features/projects/issues/user_views_issues_spec.rb
index d35009b8974..58afb4efb86 100644
--- a/spec/features/projects/issues/user_views_issues_spec.rb
+++ b/spec/features/projects/issues/user_views_issues_spec.rb
@@ -1,56 +1,116 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User views issues' do
+describe "User views issues" do
+ let!(:closed_issue) { create(:closed_issue, project: project) }
+ let!(:open_issue1) { create(:issue, project: project) }
+ let!(:open_issue2) { create(:issue, project: project) }
set(:user) { create(:user) }
- shared_examples_for 'shows issues' do
- it 'shows issues' do
- expect(page).to have_content(project.name)
- .and have_content(issue1.title)
- .and have_content(issue2.title)
- .and have_no_selector('.js-new-board-list')
+ shared_examples "opens issue from list" do
+ it "opens issue" do
+ click_link(issue.title)
+
+ expect(page).to have_content(issue.title)
end
end
- context 'when project is public' do
- set(:project) { create(:project_empty_repo, :public) }
- set(:issue1) { create(:issue, project: project) }
- set(:issue2) { create(:issue, project: project) }
+ shared_examples "open issues" do
+ context "open issues" do
+ let(:label) { create(:label, project: project, title: "bug") }
- context 'when signed in' do
before do
- project.add_developer(user)
- sign_in(user)
+ open_issue1.labels << label
+
+ visit(project_issues_path(project, state: :opened))
+ end
- visit(project_issues_path(project))
+ it "shows open issues" do
+ expect(page).to have_content(project.name)
+ .and have_content(open_issue1.title)
+ .and have_content(open_issue2.title)
+ .and have_no_content(closed_issue.title)
+ .and have_no_selector(".js-new-board-list")
end
- include_examples 'shows issues'
+ it "opens issues by label" do
+ page.within(".issues-list") do
+ click_link(label.title)
+ end
+
+ expect(page).to have_content(open_issue1.title)
+ .and have_no_content(open_issue2.title)
+ .and have_no_content(closed_issue.title)
+ end
+
+ include_examples "opens issue from list" do
+ let(:issue) { open_issue1 }
+ end
end
+ end
- context 'when not signed in' do
+ shared_examples "closed issues" do
+ context "closed issues" do
before do
- visit(project_issues_path(project))
+ visit(project_issues_path(project, state: :closed))
+ end
+
+ it "shows closed issues" do
+ expect(page).to have_content(project.name)
+ .and have_content(closed_issue.title)
+ .and have_no_content(open_issue1.title)
+ .and have_no_content(open_issue2.title)
+ .and have_no_selector(".js-new-board-list")
end
- include_examples 'shows issues'
+ include_examples "opens issue from list" do
+ let(:issue) { closed_issue }
+ end
end
end
- context 'when project is internal' do
- set(:project) { create(:project_empty_repo, :internal) }
- set(:issue1) { create(:issue, project: project) }
- set(:issue2) { create(:issue, project: project) }
-
- context 'when signed in' do
+ shared_examples "all issues" do
+ context "all issues" do
before do
- project.add_developer(user)
- sign_in(user)
+ visit(project_issues_path(project, state: :all))
+ end
- visit(project_issues_path(project))
+ it "shows all issues" do
+ expect(page).to have_content(project.name)
+ .and have_content(closed_issue.title)
+ .and have_content(open_issue1.title)
+ .and have_content(open_issue2.title)
+ .and have_no_selector(".js-new-board-list")
end
- include_examples 'shows issues'
+ include_examples "opens issue from list" do
+ let(:issue) { closed_issue }
+ end
+ end
+ end
+
+ %w[internal public].each do |visibility|
+ shared_examples "#{visibility} project" do
+ context "when project is #{visibility}" do
+ let(:project) { create(:project_empty_repo, :"#{visibility}") }
+
+ include_examples "open issues"
+ include_examples "closed issues"
+ include_examples "all issues"
+ end
end
end
+
+ context "when signed in as developer" do
+ before do
+ project.add_developer(user)
+ sign_in(user)
+ end
+
+ include_examples "public project"
+ include_examples "internal project"
+ end
+
+ context "when not signed in" do
+ include_examples "public project"
+ end
end
diff --git a/spec/features/projects/labels/user_creates_labels_spec.rb b/spec/features/projects/labels/user_creates_labels_spec.rb
new file mode 100644
index 00000000000..9fd7f3ee775
--- /dev/null
+++ b/spec/features/projects/labels/user_creates_labels_spec.rb
@@ -0,0 +1,88 @@
+require "spec_helper"
+
+describe "User creates labels" do
+ set(:project) { create(:project_empty_repo, :public) }
+ set(:user) { create(:user) }
+
+ shared_examples_for "label creation" do
+ it "creates new label" do
+ title = "bug"
+
+ create_label(title)
+
+ page.within(".other-labels .manage-labels-list") do
+ expect(page).to have_content(title)
+ end
+ end
+ end
+
+ context "in project" do
+ before do
+ project.add_master(user)
+ sign_in(user)
+
+ visit(new_project_label_path(project))
+ end
+
+ context "when data is valid" do
+ include_examples "label creation"
+ end
+
+ context "when data is invalid" do
+ context "when title is invalid" do
+ it "shows error message" do
+ create_label("")
+
+ page.within(".label-form") do
+ expect(page).to have_content("Title can't be blank")
+ end
+ end
+ end
+
+ context "when color is invalid" do
+ it "shows error message" do
+ create_label("feature", "#12")
+
+ page.within(".label-form") do
+ expect(page).to have_content("Color must be a valid color code")
+ end
+ end
+ end
+ end
+
+ context "when label already exists" do
+ let!(:label) { create(:label, project: project) }
+
+ it "shows error message" do
+ create_label(label.title)
+
+ page.within(".label-form") do
+ expect(page).to have_content("Title has already been taken")
+ end
+ end
+ end
+ end
+
+ context "in another project" do
+ set(:another_project) { create(:project_empty_repo, :public) }
+
+ before do
+ create(:label, project: project, title: "bug") # Create label for `project` (not `another_project`) project.
+
+ another_project.add_master(user)
+ sign_in(user)
+
+ visit(new_project_label_path(another_project))
+ end
+
+ include_examples "label creation"
+ end
+
+ private
+
+ def create_label(title, color = "#F95610")
+ fill_in("Title", with: title)
+ fill_in("Background color", with: color)
+ click_button("Create label")
+ end
+end
diff --git a/spec/features/projects/labels/user_edits_labels_spec.rb b/spec/features/projects/labels/user_edits_labels_spec.rb
new file mode 100644
index 00000000000..d1041ff5c1e
--- /dev/null
+++ b/spec/features/projects/labels/user_edits_labels_spec.rb
@@ -0,0 +1,25 @@
+require "spec_helper"
+
+describe "User edits labels" do
+ set(:project) { create(:project_empty_repo, :public) }
+ set(:label) { create(:label, project: project) }
+ set(:user) { create(:user) }
+
+ before do
+ project.add_master(user)
+ sign_in(user)
+
+ visit(edit_project_label_path(project, label))
+ end
+
+ it "updates label's title" do
+ new_title = "fix"
+
+ fill_in("Title", with: new_title)
+ click_button("Save changes")
+
+ page.within(".other-labels .manage-labels-list") do
+ expect(page).to have_content(new_title).and have_no_content(label.title)
+ end
+ end
+end
diff --git a/spec/features/projects/labels/user_removes_labels_spec.rb b/spec/features/projects/labels/user_removes_labels_spec.rb
new file mode 100644
index 00000000000..f4fda6de465
--- /dev/null
+++ b/spec/features/projects/labels/user_removes_labels_spec.rb
@@ -0,0 +1,52 @@
+require "spec_helper"
+
+describe "User removes labels" do
+ let(:project) { create(:project_empty_repo, :public) }
+ let(:user) { create(:user) }
+
+ before do
+ project.add_master(user)
+ sign_in(user)
+ end
+
+ context "when one label" do
+ let!(:label) { create(:label, project: project) }
+
+ before do
+ visit(project_labels_path(project))
+ end
+
+ it "removes label" do
+ page.within(".labels") do
+ page.first(".label-list-item") do
+ first(".remove-row").click
+ first(:link, "Delete label").click
+ end
+ end
+
+ expect(page).to have_content("Label was removed").and have_no_content(label.title)
+ end
+ end
+
+ context "when many labels", :js do
+ before do
+ create_list(:label, 3, project: project)
+
+ visit(project_labels_path(project))
+ end
+
+ it "removes all labels" do
+ page.within(".labels") do
+ loop do
+ li = page.first(".label-list-item")
+ break unless li
+
+ li.click_link("Delete")
+ click_link("Delete label")
+ end
+
+ expect(page).to have_content("Generate a default set of labels").and have_content("New label")
+ end
+ end
+ end
+end
diff --git a/spec/features/projects/labels/user_views_labels_spec.rb b/spec/features/projects/labels/user_views_labels_spec.rb
new file mode 100644
index 00000000000..0cbeca4e392
--- /dev/null
+++ b/spec/features/projects/labels/user_views_labels_spec.rb
@@ -0,0 +1,23 @@
+require "spec_helper"
+
+describe "User views labels" do
+ set(:project) { create(:project_empty_repo, :public) }
+ set(:user) { create(:user) }
+
+ LABEL_TITLES = %w[bug enhancement feature].freeze
+
+ before do
+ LABEL_TITLES.each { |title| create(:label, project: project, title: title) }
+
+ project.add_guest(user)
+ sign_in(user)
+
+ visit(project_labels_path(project))
+ end
+
+ it "shows all labels" do
+ page.within('.other-labels .manage-labels-list') do
+ LABEL_TITLES.each { |title| expect(page).to have_content(title) }
+ end
+ end
+end
diff --git a/spec/features/projects/milestones/milestones_sorting_spec.rb b/spec/features/projects/milestones/milestones_sorting_spec.rb
index c531b81e04d..b64786d4eec 100644
--- a/spec/features/projects/milestones/milestones_sorting_spec.rb
+++ b/spec/features/projects/milestones/milestones_sorting_spec.rb
@@ -1,7 +1,6 @@
require 'spec_helper'
feature 'Milestones sorting', :js do
- include SortingHelper
let(:user) { create(:user) }
let(:project) { create(:project, name: 'test', namespace: user.namespace) }
diff --git a/spec/features/user_sorts_things_spec.rb b/spec/features/user_sorts_things_spec.rb
new file mode 100644
index 00000000000..69ebdddaeec
--- /dev/null
+++ b/spec/features/user_sorts_things_spec.rb
@@ -0,0 +1,57 @@
+require "spec_helper"
+
+# The main goal of this spec is not to check whether the sorting UI works, but
+# to check if the sorting option set by user is being kept persisted while going through pages.
+# The `it`s are named here by convention `starting point -> some pages -> final point`.
+# All those specs are moved out to this spec intentionally to keep them all in one place.
+describe "User sorts things" do
+ include Spec::Support::Helpers::Features::SortingHelpers
+ include Helpers::DashboardHelper
+
+ set(:project) { create(:project_empty_repo, :public) }
+ set(:current_user) { create(:user) } # Using `current_user` instead of just `user` because of the hardoced call in `assigned_mrs_dashboard_path` which is used below.
+ set(:issue) { create(:issue, project: project, author: current_user) }
+ set(:merge_request) { create(:merge_request, target_project: project, source_project: project, author: current_user) }
+
+ before do
+ project.add_developer(current_user)
+ sign_in(current_user)
+ end
+
+ it "issues -> project home page -> issues" do
+ sort_option = "Last updated"
+
+ visit(project_issues_path(project))
+
+ sort_by(sort_option)
+
+ visit(project_path(project))
+ visit(project_issues_path(project))
+
+ expect(find(".issues-filters")).to have_content(sort_option)
+ end
+
+ it "issues -> merge requests" do
+ sort_option = "Last updated"
+
+ visit(project_issues_path(project))
+
+ sort_by(sort_option)
+
+ visit(project_merge_requests_path(project))
+
+ expect(find(".issues-filters")).to have_content(sort_option)
+ end
+
+ it "merge requests -> dashboard merge requests" do
+ sort_option = "Last updated"
+
+ visit(project_merge_requests_path(project))
+
+ sort_by(sort_option)
+
+ visit(assigned_mrs_dashboard_path)
+
+ expect(find(".issues-filters")).to have_content(sort_option)
+ end
+end
diff --git a/spec/lib/gitlab/metrics/sidekiq_metrics_exporter_spec.rb b/spec/lib/gitlab/metrics/sidekiq_metrics_exporter_spec.rb
index 6721e02fb85..61eb059a731 100644
--- a/spec/lib/gitlab/metrics/sidekiq_metrics_exporter_spec.rb
+++ b/spec/lib/gitlab/metrics/sidekiq_metrics_exporter_spec.rb
@@ -38,7 +38,9 @@ describe Gitlab::Metrics::SidekiqMetricsExporter do
expect(::WEBrick::HTTPServer).to have_received(:new).with(
Port: port,
- BindAddress: address
+ BindAddress: address,
+ Logger: anything,
+ AccessLog: anything
)
end
end
diff --git a/spec/lib/gitlab/performance_bar_spec.rb b/spec/lib/gitlab/performance_bar_spec.rb
index b8a2267f1a4..f480376acb4 100644
--- a/spec/lib/gitlab/performance_bar_spec.rb
+++ b/spec/lib/gitlab/performance_bar_spec.rb
@@ -25,6 +25,12 @@ describe Gitlab::PerformanceBar do
expect(described_class.enabled?(nil)).to be_falsy
end
+ it 'returns true when given user is an admin' do
+ user = build_stubbed(:user, :admin)
+
+ expect(described_class.enabled?(user)).to be_truthy
+ end
+
it 'returns false when allowed_group_id is nil' do
expect(described_class).to receive(:allowed_group_id).and_return(nil)
diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb
index 83c33797bbc..971a88e9ee9 100644
--- a/spec/mailers/notify_spec.rb
+++ b/spec/mailers/notify_spec.rb
@@ -389,6 +389,36 @@ describe Notify do
end
end
end
+
+ describe 'that have new commits' do
+ let(:push_user) { create(:user) }
+
+ subject do
+ described_class.push_to_merge_request_email(recipient.id, merge_request.id, push_user.id, new_commits: merge_request.commits)
+ end
+
+ it_behaves_like 'a multiple recipients email'
+ it_behaves_like 'an answer to an existing thread with reply-by-email enabled' do
+ let(:model) { merge_request }
+ end
+ it_behaves_like 'it should show Gmail Actions View Merge request link'
+ it_behaves_like 'an unsubscribeable thread'
+
+ it 'is sent as the push user' do
+ sender = subject.header[:from].addrs[0]
+
+ expect(sender.display_name).to eq(push_user.name)
+ expect(sender.address).to eq(gitlab_sender)
+ end
+
+ it 'has the correct subject and body' do
+ aggregate_failures do
+ is_expected.to have_referable_subject(merge_request, reply: true)
+ is_expected.to have_body_text("#{push_user.name} pushed new commits")
+ is_expected.to have_body_text(project_merge_request_path(project, merge_request))
+ end
+ end
+ end
end
context 'for issue notes' do
diff --git a/spec/services/projects/update_pages_service_spec.rb b/spec/services/projects/update_pages_service_spec.rb
index 934106627a9..dd31a677dfe 100644
--- a/spec/services/projects/update_pages_service_spec.rb
+++ b/spec/services/projects/update_pages_service_spec.rb
@@ -87,7 +87,8 @@ describe Projects::UpdatePagesService do
it 'fails for empty file fails' do
build.update_attributes(legacy_artifacts_file: empty_file)
- expect(execute).not_to eq(:success)
+ expect { execute }
+ .to raise_error(Projects::UpdatePagesService::FailedToExtractError)
end
end
end
@@ -159,7 +160,8 @@ describe Projects::UpdatePagesService do
it 'fails for empty file fails' do
build.job_artifacts_archive.update_attributes(file: empty_file)
- expect(execute).not_to eq(:success)
+ expect { execute }
+ .to raise_error(Projects::UpdatePagesService::FailedToExtractError)
end
context 'when timeout happens by DNS error' do
@@ -172,7 +174,39 @@ describe Projects::UpdatePagesService do
expect { execute }.to raise_error(SocketError)
build.reload
- expect(build.artifacts?).to eq(true)
+ expect(deploy_status).to be_failed
+ expect(build.artifacts?).to be_truthy
+ end
+ end
+
+ context 'when failed to extract zip artifacts' do
+ before do
+ allow_any_instance_of(described_class)
+ .to receive(:extract_zip_archive!)
+ .and_raise(Projects::UpdatePagesService::FailedToExtractError)
+ end
+
+ it 'raises an error' do
+ expect { execute }
+ .to raise_error(Projects::UpdatePagesService::FailedToExtractError)
+
+ build.reload
+ expect(deploy_status).to be_failed
+ expect(build.artifacts?).to be_truthy
+ end
+ end
+
+ context 'when missing artifacts metadata' do
+ before do
+ allow(build).to receive(:artifacts_metadata?).and_return(false)
+ end
+
+ it 'does not raise an error and remove artifacts as failed job' do
+ execute
+
+ build.reload
+ expect(deploy_status).to be_failed
+ expect(build.artifacts?).to be_falsey
end
end
end
diff --git a/spec/support/features/issuable_slash_commands_shared_examples.rb b/spec/support/features/issuable_slash_commands_shared_examples.rb
index f61469f673d..1bd6c25100e 100644
--- a/spec/support/features/issuable_slash_commands_shared_examples.rb
+++ b/spec/support/features/issuable_slash_commands_shared_examples.rb
@@ -2,7 +2,7 @@
# It takes a `issuable_type`, and expect an `issuable`.
shared_examples 'issuable record that supports quick actions in its description and notes' do |issuable_type|
- include QuickActionsHelpers
+ include Spec::Support::Helpers::Features::NotesHelpers
let(:master) { create(:user) }
let(:project) do
@@ -61,7 +61,7 @@ shared_examples 'issuable record that supports quick actions in its description
context 'with a note containing commands' do
it 'creates a note without the commands and interpret the commands accordingly' do
assignee = create(:user, username: 'bob')
- write_note("Awesome!\n\n/assign @bob\n\n/label ~bug\n\n/milestone %\"ASAP\"")
+ add_note("Awesome!\n\n/assign @bob\n\n/label ~bug\n\n/milestone %\"ASAP\"")
expect(page).to have_content 'Awesome!'
expect(page).not_to have_content '/assign @bob'
@@ -82,7 +82,7 @@ shared_examples 'issuable record that supports quick actions in its description
context 'with a note containing only commands' do
it 'does not create a note but interpret the commands accordingly' do
assignee = create(:user, username: 'bob')
- write_note("/assign @bob\n\n/label ~bug\n\n/milestone %\"ASAP\"")
+ add_note("/assign @bob\n\n/label ~bug\n\n/milestone %\"ASAP\"")
expect(page).not_to have_content '/assign @bob'
expect(page).not_to have_content '/label ~bug'
@@ -105,7 +105,7 @@ shared_examples 'issuable record that supports quick actions in its description
context "when current user can close #{issuable_type}" do
it "closes the #{issuable_type}" do
- write_note("/close")
+ add_note("/close")
expect(page).not_to have_content '/close'
expect(page).to have_content 'Commands applied'
@@ -125,7 +125,7 @@ shared_examples 'issuable record that supports quick actions in its description
end
it "does not close the #{issuable_type}" do
- write_note("/close")
+ add_note("/close")
expect(page).not_to have_content 'Commands applied'
@@ -142,7 +142,7 @@ shared_examples 'issuable record that supports quick actions in its description
context "when current user can reopen #{issuable_type}" do
it "reopens the #{issuable_type}" do
- write_note("/reopen")
+ add_note("/reopen")
expect(page).not_to have_content '/reopen'
expect(page).to have_content 'Commands applied'
@@ -162,7 +162,7 @@ shared_examples 'issuable record that supports quick actions in its description
end
it "does not reopen the #{issuable_type}" do
- write_note("/reopen")
+ add_note("/reopen")
expect(page).not_to have_content 'Commands applied'
@@ -174,7 +174,7 @@ shared_examples 'issuable record that supports quick actions in its description
context "with a note changing the #{issuable_type}'s title" do
context "when current user can change title of #{issuable_type}" do
it "reopens the #{issuable_type}" do
- write_note("/title Awesome new title")
+ add_note("/title Awesome new title")
expect(page).not_to have_content '/title'
expect(page).to have_content 'Commands applied'
@@ -194,7 +194,7 @@ shared_examples 'issuable record that supports quick actions in its description
end
it "does not change the #{issuable_type} title" do
- write_note("/title Awesome new title")
+ add_note("/title Awesome new title")
expect(page).not_to have_content 'Commands applied'
@@ -205,7 +205,7 @@ shared_examples 'issuable record that supports quick actions in its description
context "with a note marking the #{issuable_type} as todo" do
it "creates a new todo for the #{issuable_type}" do
- write_note("/todo")
+ add_note("/todo")
expect(page).not_to have_content '/todo'
expect(page).to have_content 'Commands applied'
@@ -236,7 +236,7 @@ shared_examples 'issuable record that supports quick actions in its description
expect(todo.author).to eq master
expect(todo.user).to eq master
- write_note("/done")
+ add_note("/done")
expect(page).not_to have_content '/done'
expect(page).to have_content 'Commands applied'
@@ -249,7 +249,7 @@ shared_examples 'issuable record that supports quick actions in its description
it "creates a new todo for the #{issuable_type}" do
expect(issuable.subscribed?(master, project)).to be_falsy
- write_note("/subscribe")
+ add_note("/subscribe")
expect(page).not_to have_content '/subscribe'
expect(page).to have_content 'Commands applied'
@@ -266,7 +266,7 @@ shared_examples 'issuable record that supports quick actions in its description
it "creates a new todo for the #{issuable_type}" do
expect(issuable.subscribed?(master, project)).to be_truthy
- write_note("/unsubscribe")
+ add_note("/unsubscribe")
expect(page).not_to have_content '/unsubscribe'
expect(page).to have_content 'Commands applied'
@@ -277,7 +277,7 @@ shared_examples 'issuable record that supports quick actions in its description
context "with a note assigning the #{issuable_type} to the current user" do
it "assigns the #{issuable_type} to the current user" do
- write_note("/assign me")
+ add_note("/assign me")
expect(page).not_to have_content '/assign me'
expect(page).to have_content 'Commands applied'
diff --git a/spec/support/helpers/features/notes_helpers.rb b/spec/support/helpers/features/notes_helpers.rb
new file mode 100644
index 00000000000..1a1d5853a7a
--- /dev/null
+++ b/spec/support/helpers/features/notes_helpers.rb
@@ -0,0 +1,27 @@
+# These helpers allow you to manipulate with notes.
+#
+# Usage:
+# describe "..." do
+# include Spec::Support::Helpers::Features::NotesHelpers
+# ...
+#
+# add_note("Hello world!")
+#
+module Spec
+ module Support
+ module Helpers
+ module Features
+ module NotesHelpers
+ def add_note(text)
+ Sidekiq::Testing.fake! do
+ page.within(".js-main-target-form") do
+ fill_in("note[note]", with: text)
+ find(".js-comment-submit-button").click
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/spec/support/helpers/features/sorting_helpers.rb b/spec/support/helpers/features/sorting_helpers.rb
new file mode 100644
index 00000000000..50457b64745
--- /dev/null
+++ b/spec/support/helpers/features/sorting_helpers.rb
@@ -0,0 +1,26 @@
+# These helpers allow you to manipulate with sorting features.
+#
+# Usage:
+# describe "..." do
+# include Spec::Support::Helpers::Features::SortingHelpers
+# ...
+#
+# sort_by("Last updated")
+#
+module Spec
+ module Support
+ module Helpers
+ module Features
+ module SortingHelpers
+ def sort_by(value)
+ find('button.dropdown-toggle').click
+
+ page.within('.content ul.dropdown-menu.dropdown-menu-align-right li') do
+ click_link(value)
+ end
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/spec/support/matchers/issuable_matchers.rb b/spec/support/matchers/issuable_matchers.rb
new file mode 100644
index 00000000000..f5d9a97051a
--- /dev/null
+++ b/spec/support/matchers/issuable_matchers.rb
@@ -0,0 +1,11 @@
+RSpec::Matchers.define :have_header_with_correct_id_and_link do |level, text, id, parent = ".wiki"|
+ match do |actual|
+ node = find("#{parent} h#{level} a#user-content-#{id}")
+
+ expect(node[:href]).to end_with("##{id}")
+
+ # Work around a weird Capybara behavior where calling `parent` on a node
+ # returns the whole document, not the node's actual parent element
+ expect(find(:xpath, "#{node.path}/..").text).to eq(text)
+ end
+end
diff --git a/spec/support/quick_actions_helpers.rb b/spec/support/quick_actions_helpers.rb
deleted file mode 100644
index 361190aa352..00000000000
--- a/spec/support/quick_actions_helpers.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-module QuickActionsHelpers
- def write_note(text)
- Sidekiq::Testing.fake! do
- page.within('.js-main-target-form') do
- fill_in 'note[note]', with: text
- find('.js-comment-submit-button').click
- end
- end
- end
-end
diff --git a/spec/support/sorting_helper.rb b/spec/support/sorting_helper.rb
deleted file mode 100644
index 577518d726c..00000000000
--- a/spec/support/sorting_helper.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-# Helper allows you to sort items
-#
-# Params
-# value - value for sorting
-#
-# Usage:
-# include SortingHelper
-#
-# sorting_by('Oldest updated')
-#
-module SortingHelper
- def sorting_by(value)
- find('button.dropdown-toggle').click
- page.within('.content ul.dropdown-menu.dropdown-menu-align-right li') do
- click_link value
- end
- end
-end
diff --git a/spec/uploaders/workers/object_storage/background_move_worker_spec.rb b/spec/uploaders/workers/object_storage/background_move_worker_spec.rb
new file mode 100644
index 00000000000..b34f427fd8a
--- /dev/null
+++ b/spec/uploaders/workers/object_storage/background_move_worker_spec.rb
@@ -0,0 +1,146 @@
+require 'spec_helper'
+
+describe ObjectStorage::BackgroundMoveWorker do
+ let(:local) { ObjectStorage::Store::LOCAL }
+ let(:remote) { ObjectStorage::Store::REMOTE }
+
+ def perform
+ described_class.perform_async(uploader_class.name, subject_class, file_field, subject_id)
+ end
+
+ context 'for LFS' do
+ let!(:lfs_object) { create(:lfs_object, :with_file, file_store: local) }
+ let(:uploader_class) { LfsObjectUploader }
+ let(:subject_class) { LfsObject }
+ let(:file_field) { :file }
+ let(:subject_id) { lfs_object.id }
+
+ context 'when object storage is enabled' do
+ before do
+ stub_lfs_object_storage(background_upload: true)
+ end
+
+ it 'uploads object to storage' do
+ expect { perform }.to change { lfs_object.reload.file_store }.from(local).to(remote)
+ end
+
+ context 'when background upload is disabled' do
+ before do
+ allow(Gitlab.config.lfs.object_store).to receive(:background_upload) { false }
+ end
+
+ it 'is skipped' do
+ expect { perform }.not_to change { lfs_object.reload.file_store }
+ end
+ end
+ end
+
+ context 'when object storage is disabled' do
+ before do
+ stub_lfs_object_storage(enabled: false)
+ end
+
+ it "doesn't migrate files" do
+ perform
+
+ expect(lfs_object.reload.file_store).to eq(local)
+ end
+ end
+ end
+
+ context 'for legacy artifacts' do
+ let(:build) { create(:ci_build, :legacy_artifacts) }
+ let(:uploader_class) { LegacyArtifactUploader }
+ let(:subject_class) { Ci::Build }
+ let(:file_field) { :artifacts_file }
+ let(:subject_id) { build.id }
+
+ context 'when local storage is used' do
+ let(:store) { local }
+
+ context 'and remote storage is defined' do
+ before do
+ stub_artifacts_object_storage(background_upload: true)
+ end
+
+ it "migrates file to remote storage" do
+ perform
+
+ expect(build.reload.artifacts_file_store).to eq(remote)
+ end
+
+ context 'for artifacts_metadata' do
+ let(:file_field) { :artifacts_metadata }
+
+ it 'migrates metadata to remote storage' do
+ perform
+
+ expect(build.reload.artifacts_metadata_store).to eq(remote)
+ end
+ end
+ end
+ end
+ end
+
+ context 'for job artifacts' do
+ let(:artifact) { create(:ci_job_artifact, :archive) }
+ let(:uploader_class) { JobArtifactUploader }
+ let(:subject_class) { Ci::JobArtifact }
+ let(:file_field) { :file }
+ let(:subject_id) { artifact.id }
+
+ context 'when local storage is used' do
+ let(:store) { local }
+
+ context 'and remote storage is defined' do
+ before do
+ stub_artifacts_object_storage(background_upload: true)
+ end
+
+ it "migrates file to remote storage" do
+ perform
+
+ expect(artifact.reload.file_store).to eq(remote)
+ end
+ end
+ end
+ end
+
+ context 'for uploads' do
+ let!(:project) { create(:project, :with_avatar) }
+ let(:uploader_class) { AvatarUploader }
+ let(:file_field) { :avatar }
+
+ context 'when local storage is used' do
+ let(:store) { local }
+
+ context 'and remote storage is defined' do
+ before do
+ stub_uploads_object_storage(uploader_class, background_upload: true)
+ end
+
+ describe 'supports using the model' do
+ let(:subject_class) { project.class }
+ let(:subject_id) { project.id }
+
+ it "migrates file to remote storage" do
+ perform
+
+ expect(project.reload.avatar.file_storage?).to be_falsey
+ end
+ end
+
+ describe 'supports using the Upload' do
+ let(:subject_class) { Upload }
+ let(:subject_id) { project.avatar.upload.id }
+
+ it "migrates file to remote storage" do
+ perform
+
+ expect(project.reload.avatar.file_storage?).to be_falsey
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/spec/uploaders/workers/object_storage/migrate_uploads_worker_spec.rb b/spec/uploaders/workers/object_storage/migrate_uploads_worker_spec.rb
new file mode 100644
index 00000000000..7a7dcb71680
--- /dev/null
+++ b/spec/uploaders/workers/object_storage/migrate_uploads_worker_spec.rb
@@ -0,0 +1,119 @@
+require 'spec_helper'
+
+describe ObjectStorage::MigrateUploadsWorker, :sidekiq do
+ shared_context 'sanity_check! fails' do
+ before do
+ expect(described_class).to receive(:sanity_check!).and_raise(described_class::SanityCheckError)
+ end
+ end
+
+ let!(:projects) { create_list(:project, 10, :with_avatar) }
+ let(:uploads) { Upload.all }
+ let(:model_class) { Project }
+ let(:mounted_as) { :avatar }
+ let(:to_store) { ObjectStorage::Store::REMOTE }
+
+ before do
+ stub_uploads_object_storage(AvatarUploader)
+ end
+
+ describe '.enqueue!' do
+ def enqueue!
+ described_class.enqueue!(uploads, Project, mounted_as, to_store)
+ end
+
+ it 'is guarded by .sanity_check!' do
+ expect(described_class).to receive(:perform_async)
+ expect(described_class).to receive(:sanity_check!)
+
+ enqueue!
+ end
+
+ context 'sanity_check! fails' do
+ include_context 'sanity_check! fails'
+
+ it 'does not enqueue a job' do
+ expect(described_class).not_to receive(:perform_async)
+
+ expect { enqueue! }.to raise_error(described_class::SanityCheckError)
+ end
+ end
+ end
+
+ describe '.sanity_check!' do
+ shared_examples 'raises a SanityCheckError' do
+ let(:mount_point) { nil }
+
+ it do
+ expect { described_class.sanity_check!(uploads, model_class, mount_point) }
+ .to raise_error(described_class::SanityCheckError)
+ end
+ end
+
+ context 'uploader types mismatch' do
+ let!(:outlier) { create(:upload, uploader: 'FileUploader') }
+
+ include_examples 'raises a SanityCheckError'
+ end
+
+ context 'model types mismatch' do
+ let!(:outlier) { create(:upload, model_type: 'Potato') }
+
+ include_examples 'raises a SanityCheckError'
+ end
+
+ context 'mount point not found' do
+ include_examples 'raises a SanityCheckError' do
+ let(:mount_point) { :potato }
+ end
+ end
+ end
+
+ describe '#perform' do
+ def perform
+ described_class.new.perform(uploads.ids, model_class.to_s, mounted_as, to_store)
+ rescue ObjectStorage::MigrateUploadsWorker::Report::MigrationFailures
+ # swallow
+ end
+
+ shared_examples 'outputs correctly' do |success: 0, failures: 0|
+ total = success + failures
+
+ if success > 0
+ it 'outputs the reports' do
+ expect(Rails.logger).to receive(:info).with(%r{Migrated #{success}/#{total} files})
+
+ perform
+ end
+ end
+
+ if failures > 0
+ it 'outputs upload failures' do
+ expect(Rails.logger).to receive(:warn).with(/Error .* I am a teapot/)
+
+ perform
+ end
+ end
+ end
+
+ it_behaves_like 'outputs correctly', success: 10
+
+ it 'migrates files' do
+ perform
+
+ aggregate_failures do
+ projects.each do |project|
+ expect(project.reload.avatar.upload.local?).to be_falsey
+ end
+ end
+ end
+
+ context 'migration is unsuccessful' do
+ before do
+ allow_any_instance_of(ObjectStorage::Concern).to receive(:migrate!).and_raise(CarrierWave::UploadError, "I am a teapot.")
+ end
+
+ it_behaves_like 'outputs correctly', failures: 10
+ end
+ end
+end