summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-12-10 14:04:34 +0100
committerDouwe Maan <douwe@gitlab.com>2015-12-10 14:04:34 +0100
commit10387f6b8a9071688d7db9a12c910ca02660ca87 (patch)
tree211b55d18305793aa76fa6260ff25ca1b74dc36e /spec
parentbcd89a58e736685bcce662fe0acf793ee925b536 (diff)
parentbdc62d704c79b8f4e39dc7b5660b8d657a434895 (diff)
downloadgitlab-ce-10387f6b8a9071688d7db9a12c910ca02660ca87.tar.gz
Merge branch 'master' into tmp-reference-pipeline-and-cachingtmp-reference-pipeline-and-caching
# Conflicts: # spec/lib/gitlab/markdown/autolink_filter_spec.rb # spec/lib/gitlab/markdown/commit_range_reference_filter_spec.rb # spec/lib/gitlab/markdown/commit_reference_filter_spec.rb # spec/lib/gitlab/markdown/cross_project_reference_spec.rb # spec/lib/gitlab/markdown/emoji_filter_spec.rb # spec/lib/gitlab/markdown/external_issue_reference_filter_spec.rb # spec/lib/gitlab/markdown/external_link_filter_spec.rb # spec/lib/gitlab/markdown/issue_reference_filter_spec.rb # spec/lib/gitlab/markdown/label_reference_filter_spec.rb # spec/lib/gitlab/markdown/merge_request_reference_filter_spec.rb # spec/lib/gitlab/markdown/redactor_filter_spec.rb # spec/lib/gitlab/markdown/reference_gatherer_filter_spec.rb # spec/lib/gitlab/markdown/relative_link_filter_spec.rb # spec/lib/gitlab/markdown/sanitization_filter_spec.rb # spec/lib/gitlab/markdown/snippet_reference_filter_spec.rb # spec/lib/gitlab/markdown/syntax_highlight_filter_spec.rb # spec/lib/gitlab/markdown/table_of_contents_filter_spec.rb # spec/lib/gitlab/markdown/task_list_filter_spec.rb # spec/lib/gitlab/markdown/upload_link_filter_spec.rb # spec/lib/gitlab/markdown/user_reference_filter_spec.rb
Diffstat (limited to 'spec')
-rw-r--r--spec/factories/ci/commits.rb23
-rw-r--r--spec/factories/commit_statuses.rb2
-rw-r--r--spec/factories/lfs_objects.rb12
-rw-r--r--spec/factories/lfs_objects_projects.rb11
-rw-r--r--spec/factories/merge_requests.rb5
-rw-r--r--spec/factories/notes.rb1
-rw-r--r--spec/factories/projects.rb1
-rw-r--r--spec/features/atom/users_spec.rb2
-rw-r--r--spec/features/issues_spec.rb4
-rw-r--r--spec/features/merge_requests/merge_when_build_succeeds_spec.rb85
-rw-r--r--spec/features/password_reset_spec.rb26
-rw-r--r--spec/helpers/visibility_level_helper_spec.rb85
-rw-r--r--spec/javascripts/fixtures/merge_request_tabs.html.haml6
-rw-r--r--spec/lib/ci/ansi2html_spec.rb2
-rw-r--r--spec/lib/ci/charts_spec.rb2
-rw-r--r--spec/lib/ci/gitlab_ci_yaml_processor_spec.rb2
-rw-r--r--spec/lib/disable_email_interceptor_spec.rb2
-rw-r--r--spec/lib/extracts_path_spec.rb2
-rw-r--r--spec/lib/file_size_validator_spec.rb2
-rw-r--r--spec/lib/git_ref_validator_spec.rb2
-rw-r--r--spec/lib/gitlab/asciidoc_spec.rb2
-rw-r--r--spec/lib/gitlab/auth_spec.rb2
-rw-r--r--spec/lib/gitlab/backend/grack_auth_spec.rb2
-rw-r--r--spec/lib/gitlab/backend/shell_spec.rb4
-rw-r--r--spec/lib/gitlab/bitbucket_import/client_spec.rb2
-rw-r--r--spec/lib/gitlab/bitbucket_import/project_creator_spec.rb2
-rw-r--r--spec/lib/gitlab/closing_issue_extractor_spec.rb2
-rw-r--r--spec/lib/gitlab/color_schemes_spec.rb2
-rw-r--r--spec/lib/gitlab/database_spec.rb2
-rw-r--r--spec/lib/gitlab/diff/file_spec.rb2
-rw-r--r--spec/lib/gitlab/diff/parser_spec.rb2
-rw-r--r--spec/lib/gitlab/email/attachment_uploader_spec.rb2
-rw-r--r--spec/lib/gitlab/email/receiver_spec.rb2
-rw-r--r--spec/lib/gitlab/email/reply_parser_spec.rb2
-rw-r--r--spec/lib/gitlab/git_access_spec.rb2
-rw-r--r--spec/lib/gitlab/git_access_wiki_spec.rb2
-rw-r--r--spec/lib/gitlab/github_import/client_spec.rb2
-rw-r--r--spec/lib/gitlab/github_import/project_creator_spec.rb2
-rw-r--r--spec/lib/gitlab/gitlab_import/client_spec.rb2
-rw-r--r--spec/lib/gitlab/gitlab_import/project_creator_spec.rb2
-rw-r--r--spec/lib/gitlab/gitorious_import/project_creator_spec.rb2
-rw-r--r--spec/lib/gitlab/google_code_import/client_spec.rb2
-rw-r--r--spec/lib/gitlab/google_code_import/importer_spec.rb2
-rw-r--r--spec/lib/gitlab/google_code_import/project_creator_spec.rb2
-rw-r--r--spec/lib/gitlab/incoming_email_spec.rb2
-rw-r--r--spec/lib/gitlab/inline_diff_spec.rb2
-rw-r--r--spec/lib/gitlab/key_fingerprint_spec.rb2
-rw-r--r--spec/lib/gitlab/ldap/access_spec.rb2
-rw-r--r--spec/lib/gitlab/ldap/adapter_spec.rb2
-rw-r--r--spec/lib/gitlab/ldap/auth_hash_spec.rb2
-rw-r--r--spec/lib/gitlab/ldap/authentication_spec.rb2
-rw-r--r--spec/lib/gitlab/ldap/config_spec.rb2
-rw-r--r--spec/lib/gitlab/ldap/user_spec.rb2
-rw-r--r--spec/lib/gitlab/lfs/lfs_router_spec.rb2
-rw-r--r--spec/lib/gitlab/markdown/cross_project_reference_spec.rb2
-rw-r--r--spec/lib/gitlab/markdown/filter/autolink_filter_spec.rb2
-rw-r--r--spec/lib/gitlab/markdown/filter/commit_range_reference_filter_spec.rb2
-rw-r--r--spec/lib/gitlab/markdown/filter/commit_reference_filter_spec.rb2
-rw-r--r--spec/lib/gitlab/markdown/filter/emoji_filter_spec.rb2
-rw-r--r--spec/lib/gitlab/markdown/filter/external_issue_reference_filter_spec.rb2
-rw-r--r--spec/lib/gitlab/markdown/filter/external_link_filter_spec.rb2
-rw-r--r--spec/lib/gitlab/markdown/filter/issue_reference_filter_spec.rb2
-rw-r--r--spec/lib/gitlab/markdown/filter/label_reference_filter_spec.rb2
-rw-r--r--spec/lib/gitlab/markdown/filter/merge_request_reference_filter_spec.rb2
-rw-r--r--spec/lib/gitlab/markdown/filter/redactor_filter_spec.rb2
-rw-r--r--spec/lib/gitlab/markdown/filter/reference_gatherer_filter_spec.rb2
-rw-r--r--spec/lib/gitlab/markdown/filter/relative_link_filter_spec.rb2
-rw-r--r--spec/lib/gitlab/markdown/filter/sanitization_filter_spec.rb2
-rw-r--r--spec/lib/gitlab/markdown/filter/snippet_reference_filter_spec.rb2
-rw-r--r--spec/lib/gitlab/markdown/filter/syntax_highlight_filter_spec.rb2
-rw-r--r--spec/lib/gitlab/markdown/filter/table_of_contents_filter_spec.rb2
-rw-r--r--spec/lib/gitlab/markdown/filter/task_list_filter_spec.rb2
-rw-r--r--spec/lib/gitlab/markdown/filter/upload_link_filter_spec.rb2
-rw-r--r--spec/lib/gitlab/markdown/filter/user_reference_filter_spec.rb2
-rw-r--r--spec/lib/gitlab/markup_helper_spec.rb2
-rw-r--r--spec/lib/gitlab/note_data_builder_spec.rb2
-rw-r--r--spec/lib/gitlab/o_auth/auth_hash_spec.rb2
-rw-r--r--spec/lib/gitlab/o_auth/user_spec.rb2
-rw-r--r--spec/lib/gitlab/popen_spec.rb2
-rw-r--r--spec/lib/gitlab/project_search_results_spec.rb2
-rw-r--r--spec/lib/gitlab/push_data_builder_spec.rb2
-rw-r--r--spec/lib/gitlab/reference_extractor_spec.rb2
-rw-r--r--spec/lib/gitlab/regex_spec.rb2
-rw-r--r--spec/lib/gitlab/sherlock/collection_spec.rb2
-rw-r--r--spec/lib/gitlab/sherlock/file_sample_spec.rb2
-rw-r--r--spec/lib/gitlab/sherlock/line_profiler_spec.rb2
-rw-r--r--spec/lib/gitlab/sherlock/line_sample_spec.rb2
-rw-r--r--spec/lib/gitlab/sherlock/location_spec.rb2
-rw-r--r--spec/lib/gitlab/sherlock/middleware_spec.rb2
-rw-r--r--spec/lib/gitlab/sherlock/query_spec.rb2
-rw-r--r--spec/lib/gitlab/sherlock/transaction_spec.rb2
-rw-r--r--spec/lib/gitlab/sql/union_spec.rb2
-rw-r--r--spec/lib/gitlab/themes_spec.rb2
-rw-r--r--spec/lib/gitlab/upgrader_spec.rb2
-rw-r--r--spec/lib/gitlab/uploads_transfer_spec.rb2
-rw-r--r--spec/lib/gitlab/url_builder_spec.rb2
-rw-r--r--spec/lib/gitlab/version_info_spec.rb2
-rw-r--r--spec/lib/repository_cache_spec.rb2
-rw-r--r--spec/models/broadcast_message_spec.rb2
-rw-r--r--spec/models/build_spec.rb2
-rw-r--r--spec/models/ci/commit_spec.rb2
-rw-r--r--spec/models/ci/project_services/hip_chat_message_spec.rb2
-rw-r--r--spec/models/ci/project_services/hip_chat_service_spec.rb2
-rw-r--r--spec/models/ci/project_services/mail_service_spec.rb2
-rw-r--r--spec/models/ci/project_services/slack_message_spec.rb2
-rw-r--r--spec/models/ci/project_services/slack_service_spec.rb2
-rw-r--r--spec/models/ci/project_spec.rb2
-rw-r--r--spec/models/ci/runner_project_spec.rb2
-rw-r--r--spec/models/ci/runner_spec.rb2
-rw-r--r--spec/models/ci/service_spec.rb2
-rw-r--r--spec/models/ci/trigger_spec.rb2
-rw-r--r--spec/models/ci/variable_spec.rb2
-rw-r--r--spec/models/ci/web_hook_spec.rb2
-rw-r--r--spec/models/commit_range_spec.rb2
-rw-r--r--spec/models/commit_spec.rb2
-rw-r--r--spec/models/commit_status_spec.rb2
-rw-r--r--spec/models/concerns/case_sensitivity_spec.rb2
-rw-r--r--spec/models/deploy_key_spec.rb2
-rw-r--r--spec/models/deploy_keys_project_spec.rb2
-rw-r--r--spec/models/event_spec.rb2
-rw-r--r--spec/models/external_issue_spec.rb2
-rw-r--r--spec/models/external_wiki_service_spec.rb2
-rw-r--r--spec/models/generic_commit_status_spec.rb2
-rw-r--r--spec/models/global_milestone_spec.rb2
-rw-r--r--spec/models/group_spec.rb2
-rw-r--r--spec/models/hooks/project_hook_spec.rb2
-rw-r--r--spec/models/hooks/service_hook_spec.rb2
-rw-r--r--spec/models/hooks/system_hook_spec.rb2
-rw-r--r--spec/models/hooks/web_hook_spec.rb2
-rw-r--r--spec/models/issue_spec.rb2
-rw-r--r--spec/models/key_spec.rb2
-rw-r--r--spec/models/label_link_spec.rb2
-rw-r--r--spec/models/label_spec.rb2
-rw-r--r--spec/models/member_spec.rb2
-rw-r--r--spec/models/members/group_member_spec.rb2
-rw-r--r--spec/models/members/project_member_spec.rb2
-rw-r--r--spec/models/merge_request_spec.rb68
-rw-r--r--spec/models/milestone_spec.rb2
-rw-r--r--spec/models/namespace_spec.rb2
-rw-r--r--spec/models/note_spec.rb3
-rw-r--r--spec/models/project_security_spec.rb2
-rw-r--r--spec/models/project_services/buildkite_service_spec.rb2
-rw-r--r--spec/models/project_services/drone_ci_service_spec.rb2
-rw-r--r--spec/models/project_services/flowdock_service_spec.rb2
-rw-r--r--spec/models/project_services/gemnasium_service_spec.rb2
-rw-r--r--spec/models/project_services/gitlab_ci_service_spec.rb2
-rw-r--r--spec/models/project_services/gitlab_issue_tracker_service_spec.rb2
-rw-r--r--spec/models/project_services/hipchat_service_spec.rb2
-rw-r--r--spec/models/project_services/irker_service_spec.rb2
-rw-r--r--spec/models/project_services/jira_service_spec.rb2
-rw-r--r--spec/models/project_services/pushover_service_spec.rb2
-rw-r--r--spec/models/project_services/slack_service/issue_message_spec.rb2
-rw-r--r--spec/models/project_services/slack_service/merge_message_spec.rb2
-rw-r--r--spec/models/project_services/slack_service/note_message_spec.rb2
-rw-r--r--spec/models/project_services/slack_service/push_message_spec.rb2
-rw-r--r--spec/models/project_services/slack_service_spec.rb2
-rw-r--r--spec/models/project_snippet_spec.rb2
-rw-r--r--spec/models/project_spec.rb3
-rw-r--r--spec/models/project_team_spec.rb2
-rw-r--r--spec/models/project_wiki_spec.rb2
-rw-r--r--spec/models/protected_branch_spec.rb2
-rw-r--r--spec/models/repository_spec.rb2
-rw-r--r--spec/models/service_spec.rb2
-rw-r--r--spec/models/snippet_spec.rb2
-rw-r--r--spec/models/user_spec.rb3
-rw-r--r--spec/models/wiki_page_spec.rb2
-rw-r--r--spec/requests/api/merge_requests_spec.rb17
-rw-r--r--spec/services/archive_repository_service_spec.rb2
-rw-r--r--spec/services/ci/create_commit_service_spec.rb2
-rw-r--r--spec/services/ci/create_trigger_request_service_spec.rb2
-rw-r--r--spec/services/ci/event_service_spec.rb2
-rw-r--r--spec/services/ci/image_for_build_service_spec.rb2
-rw-r--r--spec/services/ci/register_build_service_spec.rb2
-rw-r--r--spec/services/ci/web_hook_service_spec.rb2
-rw-r--r--spec/services/create_release_service_spec.rb2
-rw-r--r--spec/services/create_snippet_service_spec.rb2
-rw-r--r--spec/services/destroy_group_service_spec.rb2
-rw-r--r--spec/services/event_create_service_spec.rb2
-rw-r--r--spec/services/git_hooks_service_spec.rb2
-rw-r--r--spec/services/git_push_service_spec.rb2
-rw-r--r--spec/services/git_tag_push_service_spec.rb2
-rw-r--r--spec/services/issues/bulk_update_service_spec.rb2
-rw-r--r--spec/services/issues/close_service_spec.rb2
-rw-r--r--spec/services/issues/create_service_spec.rb2
-rw-r--r--spec/services/issues/update_service_spec.rb2
-rw-r--r--spec/services/merge_requests/close_service_spec.rb2
-rw-r--r--spec/services/merge_requests/create_service_spec.rb2
-rw-r--r--spec/services/merge_requests/merge_service_spec.rb11
-rw-r--r--spec/services/merge_requests/merge_when_build_succeeds_service_spec.rb84
-rw-r--r--spec/services/merge_requests/refresh_service_spec.rb8
-rw-r--r--spec/services/merge_requests/reopen_service_spec.rb2
-rw-r--r--spec/services/merge_requests/update_service_spec.rb2
-rw-r--r--spec/services/milestones/close_service_spec.rb2
-rw-r--r--spec/services/milestones/create_service_spec.rb2
-rw-r--r--spec/services/notes/create_service_spec.rb2
-rw-r--r--spec/services/notification_service_spec.rb2
-rw-r--r--spec/services/projects/create_service_spec.rb2
-rw-r--r--spec/services/projects/destroy_service_spec.rb2
-rw-r--r--spec/services/projects/download_service_spec.rb2
-rw-r--r--spec/services/projects/fork_service_spec.rb2
-rw-r--r--spec/services/projects/transfer_service_spec.rb2
-rw-r--r--spec/services/projects/update_service_spec.rb2
-rw-r--r--spec/services/projects/upload_service_spec.rb2
-rw-r--r--spec/services/search_service_spec.rb2
-rw-r--r--spec/services/system_hooks_service_spec.rb2
-rw-r--r--spec/services/system_note_service_spec.rb28
-rw-r--r--spec/services/test_hook_service_spec.rb2
-rw-r--r--spec/services/update_release_service_spec.rb2
-rw-r--r--spec/services/update_snippet_service_spec.rb2
209 files changed, 579 insertions, 285 deletions
diff --git a/spec/factories/ci/commits.rb b/spec/factories/ci/commits.rb
index 79e000b7ccb..70e3fa319c6 100644
--- a/spec/factories/ci/commits.rb
+++ b/spec/factories/ci/commits.rb
@@ -2,17 +2,18 @@
#
# Table name: commits
#
-# id :integer not null, primary key
-# project_id :integer
-# ref :string(255)
-# sha :string(255)
-# before_sha :string(255)
-# push_data :text
-# created_at :datetime
-# updated_at :datetime
-# tag :boolean default(FALSE)
-# yaml_errors :text
-# committed_at :datetime
+# id :integer not null, primary key
+# project_id :integer
+# ref :string(255)
+# sha :string(255)
+# before_sha :string(255)
+# push_data :text
+# created_at :datetime
+# updated_at :datetime
+# tag :boolean default(FALSE)
+# yaml_errors :text
+# committed_at :datetime
+# gl_project_id :integer
#
# Read about factories at https://github.com/thoughtbot/factory_girl
diff --git a/spec/factories/commit_statuses.rb b/spec/factories/commit_statuses.rb
index 52de437052d..8898b71e2a3 100644
--- a/spec/factories/commit_statuses.rb
+++ b/spec/factories/commit_statuses.rb
@@ -5,7 +5,7 @@ FactoryGirl.define do
name 'default'
status 'success'
description 'commit status'
- commit factory: :ci_commit
+ commit factory: :ci_commit_with_one_job
factory :generic_commit_status, class: GenericCommitStatus do
name 'generic'
diff --git a/spec/factories/lfs_objects.rb b/spec/factories/lfs_objects.rb
index 7fb2d77ca32..2da107ba24b 100644
--- a/spec/factories/lfs_objects.rb
+++ b/spec/factories/lfs_objects.rb
@@ -1,3 +1,15 @@
+# == Schema Information
+#
+# Table name: lfs_objects
+#
+# id :integer not null, primary key
+# oid :string(255) not null
+# size :integer not null
+# created_at :datetime
+# updated_at :datetime
+# file :string(255)
+#
+
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
diff --git a/spec/factories/lfs_objects_projects.rb b/spec/factories/lfs_objects_projects.rb
index 93de6607df8..3772236a77a 100644
--- a/spec/factories/lfs_objects_projects.rb
+++ b/spec/factories/lfs_objects_projects.rb
@@ -1,3 +1,14 @@
+# == Schema Information
+#
+# Table name: lfs_objects_projects
+#
+# id :integer not null, primary key
+# lfs_object_id :integer not null
+# project_id :integer not null
+# created_at :datetime
+# updated_at :datetime
+#
+
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
diff --git a/spec/factories/merge_requests.rb b/spec/factories/merge_requests.rb
index 729a49c9f72..5b4d7f41bc4 100644
--- a/spec/factories/merge_requests.rb
+++ b/spec/factories/merge_requests.rb
@@ -65,6 +65,11 @@ FactoryGirl.define do
target_branch "master"
end
+ trait :merge_when_build_succeeds do
+ merge_when_build_succeeds true
+ merge_user author
+ end
+
factory :closed_merge_request, traits: [:closed]
factory :reopened_merge_request, traits: [:reopened]
factory :merge_request_with_diffs, traits: [:with_diffs]
diff --git a/spec/factories/notes.rb b/spec/factories/notes.rb
index 9d777ddfccd..35a20adeef3 100644
--- a/spec/factories/notes.rb
+++ b/spec/factories/notes.rb
@@ -16,6 +16,7 @@
# system :boolean default(FALSE), not null
# st_diff :text
# updated_by_id :integer
+# is_award :boolean default(FALSE), not null
#
require_relative '../support/repo_helpers'
diff --git a/spec/factories/projects.rb b/spec/factories/projects.rb
index 1d500a11ad7..112213377ff 100644
--- a/spec/factories/projects.rb
+++ b/spec/factories/projects.rb
@@ -28,6 +28,7 @@
# import_type :string(255)
# import_source :string(255)
# commit_count :integer default(0)
+# import_error :text
#
FactoryGirl.define do
diff --git a/spec/features/atom/users_spec.rb b/spec/features/atom/users_spec.rb
index dc41be8246f..52134556339 100644
--- a/spec/features/atom/users_spec.rb
+++ b/spec/features/atom/users_spec.rb
@@ -79,6 +79,6 @@ describe "User Feed", feature: true do
end
def safe_name
- html_escape(user.name)
+ CGI.escapeHTML(user.name)
end
end
diff --git a/spec/features/issues_spec.rb b/spec/features/issues_spec.rb
index 0af5e6fc1a6..3d6d87e764a 100644
--- a/spec/features/issues_spec.rb
+++ b/spec/features/issues_spec.rb
@@ -293,10 +293,10 @@ describe 'Issues', feature: true do
end
def first_issue
- page.all('ul.issues-list li').first.text
+ page.all('ul.issues-list > li').first.text
end
def last_issue
- page.all('ul.issues-list li').last.text
+ page.all('ul.issues-list > li').last.text
end
end
diff --git a/spec/features/merge_requests/merge_when_build_succeeds_spec.rb b/spec/features/merge_requests/merge_when_build_succeeds_spec.rb
new file mode 100644
index 00000000000..a674124aab7
--- /dev/null
+++ b/spec/features/merge_requests/merge_when_build_succeeds_spec.rb
@@ -0,0 +1,85 @@
+require 'spec_helper'
+
+feature 'Merge When Build Succeeds', feature: true, js: true do
+ let(:user) { create(:user) }
+
+ let(:project) { create(:project, :public) }
+ let(:merge_request) { create(:merge_request_with_diffs, source_project: project, author: user, title: "Bug NS-04") }
+
+ before do
+ project.team << [user, :master]
+ project.enable_ci
+ end
+
+ context "Active build for Merge Request" do
+ let!(:ci_commit) { create(:ci_commit, gl_project: project, sha: merge_request.last_commit.id, ref: merge_request.source_branch) }
+ let!(:ci_build) { create(:ci_build, commit: ci_commit) }
+
+ before do
+ login_as user
+ visit_merge_request(merge_request)
+ end
+
+ it 'displays the Merge When Build Succeeds button' do
+ expect(page).to have_link "Merge When Build Succeeds"
+ end
+
+ context "Merge When Build succeeds enabled" do
+ before do
+ click_link "Merge When Build Succeeds"
+ end
+
+ it 'activates Merge When Build Succeeds feature' do
+ expect(page).to have_link "Cancel Automatic Merge"
+
+ expect(page).to have_content "Set by #{user.name} to be merged automatically when the build succeeds."
+ expect(page).to have_content "The source branch will not be removed."
+
+ visit_merge_request(merge_request) # Needed to refresh the page
+ expect(page).to have_content /Enabled an automatic merge when the build for [0-9a-f]{8} succeeds/i
+ end
+ end
+ end
+
+ context 'When it is enabled' do
+ let(:merge_request) do
+ create(:merge_request_with_diffs, :simple, source_project: project, author: user,
+ merge_user: user, title: "MepMep", merge_when_build_succeeds: true)
+ end
+
+ let!(:ci_commit) { create(:ci_commit, gl_project: project, sha: merge_request.last_commit.id, ref: merge_request.source_branch) }
+ let!(:ci_build) { create(:ci_build, commit: ci_commit) }
+
+ before do
+ login_as user
+ visit_merge_request(merge_request)
+ end
+
+ it 'cancels the automatic merge' do
+ click_link "Cancel Automatic Merge"
+
+ expect(page).to have_link "Merge When Build Succeeds"
+
+ visit_merge_request(merge_request) # Needed to refresh the page
+ expect(page).to have_content "Canceled the automatic merge"
+ end
+
+ it "allows the user to remove the source branch" do
+ expect(page).to have_link "Remove Source Branch When Merged"
+
+ click_link "Remove Source Branch When Merged"
+ expect(page).to have_content "The source branch will be removed"
+ end
+ end
+
+ context 'Build is not active' do
+ it "should not allow for enabling" do
+ visit_merge_request(merge_request)
+ expect(page).not_to have_link "Merge When Build Succeeds"
+ end
+ end
+
+ def visit_merge_request(merge_request)
+ visit namespace_project_merge_request_path(merge_request.project.namespace, merge_request.project, merge_request)
+ end
+end
diff --git a/spec/features/password_reset_spec.rb b/spec/features/password_reset_spec.rb
index 85e70b4d47f..257d363438c 100644
--- a/spec/features/password_reset_spec.rb
+++ b/spec/features/password_reset_spec.rb
@@ -3,11 +3,12 @@ require 'spec_helper'
feature 'Password reset', feature: true do
describe 'throttling' do
it 'sends reset instructions when not previously sent' do
- visit root_path
- forgot_password(create(:user))
+ user = create(:user)
+ forgot_password(user)
- expect(page).to have_content(I18n.t('devise.passwords.send_instructions'))
+ expect(page).to have_content(I18n.t('devise.passwords.send_paranoid_instructions'))
expect(current_path).to eq new_user_session_path
+ expect(user.recently_sent_password_reset?).to be_truthy
end
it 'sends reset instructions when previously sent more than a minute ago' do
@@ -15,26 +16,25 @@ feature 'Password reset', feature: true do
user.send_reset_password_instructions
user.update_attribute(:reset_password_sent_at, 5.minutes.ago)
- visit root_path
- forgot_password(user)
-
- expect(page).to have_content(I18n.t('devise.passwords.send_instructions'))
+ expect{ forgot_password(user) }.to change{ user.reset_password_sent_at }
+ expect(page).to have_content(I18n.t('devise.passwords.send_paranoid_instructions'))
expect(current_path).to eq new_user_session_path
end
- it "throttles multiple resets in a short timespan" do
+ it 'throttles multiple resets in a short timespan' do
user = create(:user)
user.send_reset_password_instructions
+ # Reload because PG handles datetime less precisely than Ruby/Rails
+ user.reload
- visit root_path
- forgot_password(user)
-
- expect(page).to have_content(I18n.t('devise.passwords.recently_reset'))
- expect(current_path).to eq new_user_password_path
+ expect{ forgot_password(user) }.not_to change{ user.reset_password_sent_at }
+ expect(page).to have_content(I18n.t('devise.passwords.send_paranoid_instructions'))
+ expect(current_path).to eq new_user_session_path
end
end
def forgot_password(user)
+ visit root_path
click_on 'Forgot your password?'
fill_in 'Email', with: user.email
click_button 'Reset password'
diff --git a/spec/helpers/visibility_level_helper_spec.rb b/spec/helpers/visibility_level_helper_spec.rb
index c4f7693329c..aafc24397a9 100644
--- a/spec/helpers/visibility_level_helper_spec.rb
+++ b/spec/helpers/visibility_level_helper_spec.rb
@@ -7,69 +7,52 @@ describe VisibilityLevelHelper do
init_haml_helpers
end
- let(:project) { create(:project) }
+ let(:project) { build(:project) }
+ let(:personal_snippet) { build(:personal_snippet) }
+ let(:project_snippet) { build(:project_snippet) }
describe 'visibility_level_description' do
- shared_examples 'a visibility level description' do
- let(:desc) do
- visibility_level_description(Gitlab::VisibilityLevel::PRIVATE,
- form_model)
- end
-
- let(:expected_class) do
- class_name = case form_model.class.name
- when 'String'
- form_model
- else
- form_model.class.name
- end
-
- class_name.match(/(project|snippet)$/i)[0]
- end
-
- it 'should refer to the correct class' do
- expect(desc).to match(/#{expected_class}/i)
+ context 'used with a Project' do
+ it 'delegates projects to #project_visibility_level_description' do
+ expect(visibility_level_description(Gitlab::VisibilityLevel::PRIVATE, project))
+ .to match /project/i
end
end
- context 'form_model argument is a String' do
- context 'model object is a personal snippet' do
- it_behaves_like 'a visibility level description' do
- let(:form_model) { 'PersonalSnippet' }
- end
+ context 'called with a Snippet' do
+ it 'delegates snippets to #snippet_visibility_level_description' do
+ expect(visibility_level_description(Gitlab::VisibilityLevel::INTERNAL, project_snippet))
+ .to match /snippet/i
end
+ end
+ end
- context 'model object is a project snippet' do
- it_behaves_like 'a visibility level description' do
- let(:form_model) { 'ProjectSnippet' }
- end
- end
+ describe "#project_visibility_level_description" do
+ it "describes private projects" do
+ expect(project_visibility_level_description(Gitlab::VisibilityLevel::PRIVATE))
+ .to eq "Project access must be granted explicitly to each user."
+ end
- context 'model object is a project' do
- it_behaves_like 'a visibility level description' do
- let(:form_model) { 'Project' }
- end
- end
+ it "describes public projects" do
+ expect(project_visibility_level_description(Gitlab::VisibilityLevel::PUBLIC))
+ .to eq "The project can be cloned without any authentication."
end
+ end
- context 'form_model argument is a model object' do
- context 'model object is a personal snippet' do
- it_behaves_like 'a visibility level description' do
- let(:form_model) { create(:personal_snippet) }
- end
- end
+ describe "#snippet_visibility_level_description" do
+ it 'describes visibility only for me' do
+ expect(snippet_visibility_level_description(Gitlab::VisibilityLevel::PRIVATE, personal_snippet))
+ .to eq "The snippet is visible only to me."
+ end
- context 'model object is a project snippet' do
- it_behaves_like 'a visibility level description' do
- let(:form_model) { create(:project_snippet, project: project) }
- end
- end
+ it 'describes visibility for project members' do
+ expect(snippet_visibility_level_description(Gitlab::VisibilityLevel::PRIVATE, project_snippet))
+ .to eq "The snippet is visible only to project members."
+ end
- context 'model object is a project' do
- it_behaves_like 'a visibility level description' do
- let(:form_model) { project }
- end
- end
+ it 'defaults to personal snippet' do
+ expect(snippet_visibility_level_description(Gitlab::VisibilityLevel::PRIVATE))
+ .to eq "The snippet is visible only to me."
end
end
diff --git a/spec/javascripts/fixtures/merge_request_tabs.html.haml b/spec/javascripts/fixtures/merge_request_tabs.html.haml
index 7624a713948..68678c3d7e3 100644
--- a/spec/javascripts/fixtures/merge_request_tabs.html.haml
+++ b/spec/javascripts/fixtures/merge_request_tabs.html.haml
@@ -1,12 +1,12 @@
%ul.nav.nav-tabs.merge-request-tabs
%li.notes-tab
- %a{href: '/foo/bar/merge_requests/1', data: {target: '#notes', action: 'notes', toggle: 'tab'}}
+ %a{href: '/foo/bar/merge_requests/1', data: {target: 'div#notes', action: 'notes', toggle: 'tab'}}
Discussion
%li.commits-tab
- %a{href: '/foo/bar/merge_requests/1/commits', data: {target: '#commits', action: 'commits', toggle: 'tab'}}
+ %a{href: '/foo/bar/merge_requests/1/commits', data: {target: 'div#commits', action: 'commits', toggle: 'tab'}}
Commits
%li.diffs-tab
- %a{href: '/foo/bar/merge_requests/1/diffs', data: {target: '#diffs', action: 'diffs', toggle: 'tab'}}
+ %a{href: '/foo/bar/merge_requests/1/diffs', data: {target: 'div#diffs', action: 'diffs', toggle: 'tab'}}
Diffs
.tab-content
diff --git a/spec/lib/ci/ansi2html_spec.rb b/spec/lib/ci/ansi2html_spec.rb
index 75c023bbc43..3a2b568f4c7 100644
--- a/spec/lib/ci/ansi2html_spec.rb
+++ b/spec/lib/ci/ansi2html_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Ci::Ansi2html do
+describe Ci::Ansi2html, lib: true do
subject { Ci::Ansi2html }
it "prints non-ansi as-is" do
diff --git a/spec/lib/ci/charts_spec.rb b/spec/lib/ci/charts_spec.rb
index 83e2ad220b8..50a77308cde 100644
--- a/spec/lib/ci/charts_spec.rb
+++ b/spec/lib/ci/charts_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe "Charts" do
+describe Ci::Charts, lib: true do
context "build_times" do
before do
diff --git a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
index 6f287719ba6..ce4a5244bd0 100644
--- a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
+++ b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
@@ -1,7 +1,7 @@
require 'spec_helper'
module Ci
- describe GitlabCiYamlProcessor do
+ describe GitlabCiYamlProcessor, lib: true do
let(:path) { 'path' }
describe "#builds_for_ref" do
diff --git a/spec/lib/disable_email_interceptor_spec.rb b/spec/lib/disable_email_interceptor_spec.rb
index a9624e9a2b7..c2a7b20b84d 100644
--- a/spec/lib/disable_email_interceptor_spec.rb
+++ b/spec/lib/disable_email_interceptor_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe DisableEmailInterceptor do
+describe DisableEmailInterceptor, lib: true do
before do
ActionMailer::Base.register_interceptor(DisableEmailInterceptor)
end
diff --git a/spec/lib/extracts_path_spec.rb b/spec/lib/extracts_path_spec.rb
index 48bc60eed16..f38fadda9ba 100644
--- a/spec/lib/extracts_path_spec.rb
+++ b/spec/lib/extracts_path_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe ExtractsPath do
+describe ExtractsPath, lib: true do
include ExtractsPath
include RepoHelpers
include Gitlab::Application.routes.url_helpers
diff --git a/spec/lib/file_size_validator_spec.rb b/spec/lib/file_size_validator_spec.rb
index 12ccc051c74..fda6f9a6c88 100644
--- a/spec/lib/file_size_validator_spec.rb
+++ b/spec/lib/file_size_validator_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe 'Gitlab::FileSizeValidatorSpec' do
+describe FileSizeValidator, lib: true do
let(:validator) { FileSizeValidator.new(options) }
let(:attachment) { AttachmentUploader.new }
let(:note) { create(:note) }
diff --git a/spec/lib/git_ref_validator_spec.rb b/spec/lib/git_ref_validator_spec.rb
index 4633b6f3934..dc57e94f193 100644
--- a/spec/lib/git_ref_validator_spec.rb
+++ b/spec/lib/git_ref_validator_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::GitRefValidator do
+describe Gitlab::GitRefValidator, lib: true do
it { expect(Gitlab::GitRefValidator.validate('feature/new')).to be_truthy }
it { expect(Gitlab::GitRefValidator.validate('implement_@all')).to be_truthy }
it { expect(Gitlab::GitRefValidator.validate('my_new_feature')).to be_truthy }
diff --git a/spec/lib/gitlab/asciidoc_spec.rb b/spec/lib/gitlab/asciidoc_spec.rb
index e8c8180e1c4..3a860899e18 100644
--- a/spec/lib/gitlab/asciidoc_spec.rb
+++ b/spec/lib/gitlab/asciidoc_spec.rb
@@ -2,7 +2,7 @@ require 'spec_helper'
require 'nokogiri'
module Gitlab
- describe Asciidoc do
+ describe Asciidoc, lib: true do
let(:input) { '<b>ascii</b>' }
let(:context) { {} }
diff --git a/spec/lib/gitlab/auth_spec.rb b/spec/lib/gitlab/auth_spec.rb
index 72806bebe1f..aad291c03cd 100644
--- a/spec/lib/gitlab/auth_spec.rb
+++ b/spec/lib/gitlab/auth_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::Auth do
+describe Gitlab::Auth, lib: true do
let(:gl_auth) { Gitlab::Auth.new }
describe :find do
diff --git a/spec/lib/gitlab/backend/grack_auth_spec.rb b/spec/lib/gitlab/backend/grack_auth_spec.rb
index dfa0e10318a..73458735ad9 100644
--- a/spec/lib/gitlab/backend/grack_auth_spec.rb
+++ b/spec/lib/gitlab/backend/grack_auth_spec.rb
@@ -1,6 +1,6 @@
require "spec_helper"
-describe Grack::Auth do
+describe Grack::Auth, lib: true do
let(:user) { create(:user) }
let(:project) { create(:project) }
diff --git a/spec/lib/gitlab/backend/shell_spec.rb b/spec/lib/gitlab/backend/shell_spec.rb
index b60e23454d6..fd869f48b5c 100644
--- a/spec/lib/gitlab/backend/shell_spec.rb
+++ b/spec/lib/gitlab/backend/shell_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::Shell do
+describe Gitlab::Shell, lib: true do
let(:project) { double('Project', id: 7, path: 'diaspora') }
let(:gitlab_shell) { Gitlab::Shell.new }
@@ -16,7 +16,7 @@ describe Gitlab::Shell do
it { expect(gitlab_shell.url_to_repo('diaspora')).to eq(Gitlab.config.gitlab_shell.ssh_path_prefix + "diaspora.git") }
- describe Gitlab::Shell::KeyAdder do
+ describe Gitlab::Shell::KeyAdder, lib: true do
describe '#add_key' do
it 'normalizes space characters in the key' do
io = spy
diff --git a/spec/lib/gitlab/bitbucket_import/client_spec.rb b/spec/lib/gitlab/bitbucket_import/client_spec.rb
index dfe58637eee..aa0699f2ebf 100644
--- a/spec/lib/gitlab/bitbucket_import/client_spec.rb
+++ b/spec/lib/gitlab/bitbucket_import/client_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::BitbucketImport::Client do
+describe Gitlab::BitbucketImport::Client, lib: true do
let(:token) { '123456' }
let(:secret) { 'secret' }
let(:client) { Gitlab::BitbucketImport::Client.new(token, secret) }
diff --git a/spec/lib/gitlab/bitbucket_import/project_creator_spec.rb b/spec/lib/gitlab/bitbucket_import/project_creator_spec.rb
index 0e826a319e0..e1c60e07b4d 100644
--- a/spec/lib/gitlab/bitbucket_import/project_creator_spec.rb
+++ b/spec/lib/gitlab/bitbucket_import/project_creator_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::BitbucketImport::ProjectCreator do
+describe Gitlab::BitbucketImport::ProjectCreator, lib: true do
let(:user) { create(:user) }
let(:repo) do
{
diff --git a/spec/lib/gitlab/closing_issue_extractor_spec.rb b/spec/lib/gitlab/closing_issue_extractor_spec.rb
index fe1b94a484e..99288da1e43 100644
--- a/spec/lib/gitlab/closing_issue_extractor_spec.rb
+++ b/spec/lib/gitlab/closing_issue_extractor_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::ClosingIssueExtractor do
+describe Gitlab::ClosingIssueExtractor, lib: true do
let(:project) { create(:project) }
let(:project2) { create(:project) }
let(:issue) { create(:issue, project: project) }
diff --git a/spec/lib/gitlab/color_schemes_spec.rb b/spec/lib/gitlab/color_schemes_spec.rb
index c7be45dbcd3..0a1ec66f199 100644
--- a/spec/lib/gitlab/color_schemes_spec.rb
+++ b/spec/lib/gitlab/color_schemes_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::ColorSchemes do
+describe Gitlab::ColorSchemes, lib: true do
describe '.body_classes' do
it 'returns a space-separated list of class names' do
css = described_class.body_classes
diff --git a/spec/lib/gitlab/database_spec.rb b/spec/lib/gitlab/database_spec.rb
index 7cdebdf209a..8461e8ce50d 100644
--- a/spec/lib/gitlab/database_spec.rb
+++ b/spec/lib/gitlab/database_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::Database do
+describe Gitlab::Database, lib: true do
# These are just simple smoke tests to check if the methods work (regardless
# of what they may return).
describe '.mysql?' do
diff --git a/spec/lib/gitlab/diff/file_spec.rb b/spec/lib/gitlab/diff/file_spec.rb
index 8b7946f3117..c7cdf8691d6 100644
--- a/spec/lib/gitlab/diff/file_spec.rb
+++ b/spec/lib/gitlab/diff/file_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::Diff::File do
+describe Gitlab::Diff::File, lib: true do
include RepoHelpers
let(:project) { create(:project) }
diff --git a/spec/lib/gitlab/diff/parser_spec.rb b/spec/lib/gitlab/diff/parser_spec.rb
index 4d5d1431683..ba577bd28e5 100644
--- a/spec/lib/gitlab/diff/parser_spec.rb
+++ b/spec/lib/gitlab/diff/parser_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::Diff::Parser do
+describe Gitlab::Diff::Parser, lib: true do
include RepoHelpers
let(:project) { create(:project) }
diff --git a/spec/lib/gitlab/email/attachment_uploader_spec.rb b/spec/lib/gitlab/email/attachment_uploader_spec.rb
index 8fb432367b6..476a21bf996 100644
--- a/spec/lib/gitlab/email/attachment_uploader_spec.rb
+++ b/spec/lib/gitlab/email/attachment_uploader_spec.rb
@@ -1,6 +1,6 @@
require "spec_helper"
-describe Gitlab::Email::AttachmentUploader do
+describe Gitlab::Email::AttachmentUploader, lib: true do
describe "#execute" do
let(:project) { build(:project) }
let(:message_raw) { fixture_file("emails/attachment.eml") }
diff --git a/spec/lib/gitlab/email/receiver_spec.rb b/spec/lib/gitlab/email/receiver_spec.rb
index e470b7cd5f5..b535413bbd4 100644
--- a/spec/lib/gitlab/email/receiver_spec.rb
+++ b/spec/lib/gitlab/email/receiver_spec.rb
@@ -1,6 +1,6 @@
require "spec_helper"
-describe Gitlab::Email::Receiver do
+describe Gitlab::Email::Receiver, lib: true do
before do
stub_incoming_email_setting(enabled: true, address: "reply+%{key}@appmail.adventuretime.ooo")
end
diff --git a/spec/lib/gitlab/email/reply_parser_spec.rb b/spec/lib/gitlab/email/reply_parser_spec.rb
index 7cae1da8050..6f8e9a4be64 100644
--- a/spec/lib/gitlab/email/reply_parser_spec.rb
+++ b/spec/lib/gitlab/email/reply_parser_spec.rb
@@ -1,7 +1,7 @@
require "spec_helper"
# Inspired in great part by Discourse's Email::Receiver
-describe Gitlab::Email::ReplyParser do
+describe Gitlab::Email::ReplyParser, lib: true do
describe '#execute' do
def test_parse_body(mail_string)
described_class.new(Mail::Message.new(mail_string)).execute
diff --git a/spec/lib/gitlab/git_access_spec.rb b/spec/lib/gitlab/git_access_spec.rb
index c7291689e32..9b3a0e3a75f 100644
--- a/spec/lib/gitlab/git_access_spec.rb
+++ b/spec/lib/gitlab/git_access_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::GitAccess do
+describe Gitlab::GitAccess, lib: true do
let(:access) { Gitlab::GitAccess.new(actor, project) }
let(:project) { create(:project) }
let(:user) { create(:user) }
diff --git a/spec/lib/gitlab/git_access_wiki_spec.rb b/spec/lib/gitlab/git_access_wiki_spec.rb
index 4cb91094cb3..77ecfce6f17 100644
--- a/spec/lib/gitlab/git_access_wiki_spec.rb
+++ b/spec/lib/gitlab/git_access_wiki_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::GitAccessWiki do
+describe Gitlab::GitAccessWiki, lib: true do
let(:access) { Gitlab::GitAccessWiki.new(user, project) }
let(:project) { create(:project) }
let(:user) { create(:user) }
diff --git a/spec/lib/gitlab/github_import/client_spec.rb b/spec/lib/gitlab/github_import/client_spec.rb
index 26618120316..49d8cdf4314 100644
--- a/spec/lib/gitlab/github_import/client_spec.rb
+++ b/spec/lib/gitlab/github_import/client_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::GithubImport::Client do
+describe Gitlab::GithubImport::Client, lib: true do
let(:token) { '123456' }
let(:client) { Gitlab::GithubImport::Client.new(token) }
diff --git a/spec/lib/gitlab/github_import/project_creator_spec.rb b/spec/lib/gitlab/github_import/project_creator_spec.rb
index ca61d3c5234..c93a3ebdaec 100644
--- a/spec/lib/gitlab/github_import/project_creator_spec.rb
+++ b/spec/lib/gitlab/github_import/project_creator_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::GithubImport::ProjectCreator do
+describe Gitlab::GithubImport::ProjectCreator, lib: true do
let(:user) { create(:user) }
let(:repo) do
OpenStruct.new(
diff --git a/spec/lib/gitlab/gitlab_import/client_spec.rb b/spec/lib/gitlab/gitlab_import/client_spec.rb
index c511c515474..e6831e7c383 100644
--- a/spec/lib/gitlab/gitlab_import/client_spec.rb
+++ b/spec/lib/gitlab/gitlab_import/client_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::GitlabImport::Client do
+describe Gitlab::GitlabImport::Client, lib: true do
let(:token) { '123456' }
let(:client) { Gitlab::GitlabImport::Client.new(token) }
diff --git a/spec/lib/gitlab/gitlab_import/project_creator_spec.rb b/spec/lib/gitlab/gitlab_import/project_creator_spec.rb
index 2d8923d14bb..483f65cd053 100644
--- a/spec/lib/gitlab/gitlab_import/project_creator_spec.rb
+++ b/spec/lib/gitlab/gitlab_import/project_creator_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::GitlabImport::ProjectCreator do
+describe Gitlab::GitlabImport::ProjectCreator, lib: true do
let(:user) { create(:user) }
let(:repo) do
{
diff --git a/spec/lib/gitlab/gitorious_import/project_creator_spec.rb b/spec/lib/gitlab/gitorious_import/project_creator_spec.rb
index c1125ca6357..946712ca38e 100644
--- a/spec/lib/gitlab/gitorious_import/project_creator_spec.rb
+++ b/spec/lib/gitlab/gitorious_import/project_creator_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::GitoriousImport::ProjectCreator do
+describe Gitlab::GitoriousImport::ProjectCreator, lib: true do
let(:user) { create(:user) }
let(:repo) { Gitlab::GitoriousImport::Repository.new('foo/bar-baz-qux') }
let(:namespace){ create(:group, owner: user) }
diff --git a/spec/lib/gitlab/google_code_import/client_spec.rb b/spec/lib/gitlab/google_code_import/client_spec.rb
index 37985c062b4..85949ae8dc4 100644
--- a/spec/lib/gitlab/google_code_import/client_spec.rb
+++ b/spec/lib/gitlab/google_code_import/client_spec.rb
@@ -1,6 +1,6 @@
require "spec_helper"
-describe Gitlab::GoogleCodeImport::Client do
+describe Gitlab::GoogleCodeImport::Client, lib: true do
let(:raw_data) { JSON.parse(fixture_file("GoogleCodeProjectHosting.json")) }
subject { described_class.new(raw_data) }
diff --git a/spec/lib/gitlab/google_code_import/importer_spec.rb b/spec/lib/gitlab/google_code_import/importer_spec.rb
index 65ad7524cc2..647631271e0 100644
--- a/spec/lib/gitlab/google_code_import/importer_spec.rb
+++ b/spec/lib/gitlab/google_code_import/importer_spec.rb
@@ -1,6 +1,6 @@
require "spec_helper"
-describe Gitlab::GoogleCodeImport::Importer do
+describe Gitlab::GoogleCodeImport::Importer, lib: true do
let(:mapped_user) { create(:user, username: "thilo123") }
let(:raw_data) { JSON.parse(fixture_file("GoogleCodeProjectHosting.json")) }
let(:client) { Gitlab::GoogleCodeImport::Client.new(raw_data) }
diff --git a/spec/lib/gitlab/google_code_import/project_creator_spec.rb b/spec/lib/gitlab/google_code_import/project_creator_spec.rb
index 35549b48687..499a896ee76 100644
--- a/spec/lib/gitlab/google_code_import/project_creator_spec.rb
+++ b/spec/lib/gitlab/google_code_import/project_creator_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::GoogleCodeImport::ProjectCreator do
+describe Gitlab::GoogleCodeImport::ProjectCreator, lib: true do
let(:user) { create(:user) }
let(:repo) do
Gitlab::GoogleCodeImport::Repository.new(
diff --git a/spec/lib/gitlab/incoming_email_spec.rb b/spec/lib/gitlab/incoming_email_spec.rb
index 5fdb9c723b1..bcdba8d4c12 100644
--- a/spec/lib/gitlab/incoming_email_spec.rb
+++ b/spec/lib/gitlab/incoming_email_spec.rb
@@ -1,6 +1,6 @@
require "spec_helper"
-describe Gitlab::IncomingEmail do
+describe Gitlab::IncomingEmail, lib: true do
describe "self.enabled?" do
context "when reply by email is enabled" do
before do
diff --git a/spec/lib/gitlab/inline_diff_spec.rb b/spec/lib/gitlab/inline_diff_spec.rb
index 2e0a05088cc..c690c195112 100644
--- a/spec/lib/gitlab/inline_diff_spec.rb
+++ b/spec/lib/gitlab/inline_diff_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::InlineDiff do
+describe Gitlab::InlineDiff, lib: true do
describe '#processing' do
let(:diff) do
<<eos
diff --git a/spec/lib/gitlab/key_fingerprint_spec.rb b/spec/lib/gitlab/key_fingerprint_spec.rb
index 266eab6e793..d09f51f3bfc 100644
--- a/spec/lib/gitlab/key_fingerprint_spec.rb
+++ b/spec/lib/gitlab/key_fingerprint_spec.rb
@@ -1,6 +1,6 @@
require "spec_helper"
-describe Gitlab::KeyFingerprint do
+describe Gitlab::KeyFingerprint, lib: true do
let(:key) { "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0=" }
let(:fingerprint) { "3f:a2:ee:de:b5:de:53:c3:aa:2f:9c:45:24:4c:47:7b" }
diff --git a/spec/lib/gitlab/ldap/access_spec.rb b/spec/lib/gitlab/ldap/access_spec.rb
index 960547a0ad7..a628d0c0157 100644
--- a/spec/lib/gitlab/ldap/access_spec.rb
+++ b/spec/lib/gitlab/ldap/access_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::LDAP::Access do
+describe Gitlab::LDAP::Access, lib: true do
let(:access) { Gitlab::LDAP::Access.new user }
let(:user) { create(:omniauth_user) }
diff --git a/spec/lib/gitlab/ldap/adapter_spec.rb b/spec/lib/gitlab/ldap/adapter_spec.rb
index 38076602df9..4847b5f3b0e 100644
--- a/spec/lib/gitlab/ldap/adapter_spec.rb
+++ b/spec/lib/gitlab/ldap/adapter_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::LDAP::Adapter do
+describe Gitlab::LDAP::Adapter, lib: true do
let(:adapter) { Gitlab::LDAP::Adapter.new 'ldapmain' }
describe '#dn_matches_filter?' do
diff --git a/spec/lib/gitlab/ldap/auth_hash_spec.rb b/spec/lib/gitlab/ldap/auth_hash_spec.rb
index 7d8268536a4..6a53ed1db64 100644
--- a/spec/lib/gitlab/ldap/auth_hash_spec.rb
+++ b/spec/lib/gitlab/ldap/auth_hash_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::LDAP::AuthHash do
+describe Gitlab::LDAP::AuthHash, lib: true do
let(:auth_hash) do
Gitlab::LDAP::AuthHash.new(
OmniAuth::AuthHash.new(
diff --git a/spec/lib/gitlab/ldap/authentication_spec.rb b/spec/lib/gitlab/ldap/authentication_spec.rb
index 6e3de914a45..b8f3290e84c 100644
--- a/spec/lib/gitlab/ldap/authentication_spec.rb
+++ b/spec/lib/gitlab/ldap/authentication_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::LDAP::Authentication do
+describe Gitlab::LDAP::Authentication, lib: true do
let(:user) { create(:omniauth_user, extern_uid: dn) }
let(:dn) { 'uid=john,ou=people,dc=example,dc=com' }
let(:login) { 'john' }
diff --git a/spec/lib/gitlab/ldap/config_spec.rb b/spec/lib/gitlab/ldap/config_spec.rb
index 3548d647c84..835853a83a4 100644
--- a/spec/lib/gitlab/ldap/config_spec.rb
+++ b/spec/lib/gitlab/ldap/config_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::LDAP::Config do
+describe Gitlab::LDAP::Config, lib: true do
let(:config) { Gitlab::LDAP::Config.new provider }
let(:provider) { 'ldapmain' }
diff --git a/spec/lib/gitlab/ldap/user_spec.rb b/spec/lib/gitlab/ldap/user_spec.rb
index b5b56a34952..3bba5e2efa2 100644
--- a/spec/lib/gitlab/ldap/user_spec.rb
+++ b/spec/lib/gitlab/ldap/user_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::LDAP::User do
+describe Gitlab::LDAP::User, lib: true do
let(:ldap_user) { Gitlab::LDAP::User.new(auth_hash) }
let(:gl_user) { ldap_user.gl_user }
let(:info) do
diff --git a/spec/lib/gitlab/lfs/lfs_router_spec.rb b/spec/lib/gitlab/lfs/lfs_router_spec.rb
index 5b13d65c7c0..5852b31ab3a 100644
--- a/spec/lib/gitlab/lfs/lfs_router_spec.rb
+++ b/spec/lib/gitlab/lfs/lfs_router_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::Lfs::Router do
+describe Gitlab::Lfs::Router, lib: true do
let(:project) { create(:project) }
let(:public_project) { create(:project, :public) }
let(:forked_project) { fork_project(public_project, user) }
diff --git a/spec/lib/gitlab/markdown/cross_project_reference_spec.rb b/spec/lib/gitlab/markdown/cross_project_reference_spec.rb
index f86d52b9d0a..f594fe4ccf6 100644
--- a/spec/lib/gitlab/markdown/cross_project_reference_spec.rb
+++ b/spec/lib/gitlab/markdown/cross_project_reference_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::Markdown::CrossProjectReference do
+describe Gitlab::Markdown::CrossProjectReference, lib: true do
include described_class
describe '#project_from_ref' do
diff --git a/spec/lib/gitlab/markdown/filter/autolink_filter_spec.rb b/spec/lib/gitlab/markdown/filter/autolink_filter_spec.rb
index 837bdb56f74..a0844aee559 100644
--- a/spec/lib/gitlab/markdown/filter/autolink_filter_spec.rb
+++ b/spec/lib/gitlab/markdown/filter/autolink_filter_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::Markdown::AutolinkFilter do
+describe Gitlab::Markdown::AutolinkFilter, lib: true do
include FilterSpecHelper
let(:link) { 'http://about.gitlab.com/' }
diff --git a/spec/lib/gitlab/markdown/filter/commit_range_reference_filter_spec.rb b/spec/lib/gitlab/markdown/filter/commit_range_reference_filter_spec.rb
index 05404fea724..570c9767628 100644
--- a/spec/lib/gitlab/markdown/filter/commit_range_reference_filter_spec.rb
+++ b/spec/lib/gitlab/markdown/filter/commit_range_reference_filter_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::Markdown::CommitRangeReferenceFilter do
+describe Gitlab::Markdown::CommitRangeReferenceFilter, lib: true do
include FilterSpecHelper
let(:project) { create(:project, :public) }
diff --git a/spec/lib/gitlab/markdown/filter/commit_reference_filter_spec.rb b/spec/lib/gitlab/markdown/filter/commit_reference_filter_spec.rb
index eeddf33e175..76e7957bbb9 100644
--- a/spec/lib/gitlab/markdown/filter/commit_reference_filter_spec.rb
+++ b/spec/lib/gitlab/markdown/filter/commit_reference_filter_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::Markdown::CommitReferenceFilter do
+describe Gitlab::Markdown::CommitReferenceFilter, lib: true do
include FilterSpecHelper
let(:project) { create(:project, :public) }
diff --git a/spec/lib/gitlab/markdown/filter/emoji_filter_spec.rb b/spec/lib/gitlab/markdown/filter/emoji_filter_spec.rb
index e0c5622e85d..ea9b81862cf 100644
--- a/spec/lib/gitlab/markdown/filter/emoji_filter_spec.rb
+++ b/spec/lib/gitlab/markdown/filter/emoji_filter_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::Markdown::EmojiFilter do
+describe Gitlab::Markdown::EmojiFilter, lib: true do
include FilterSpecHelper
before do
diff --git a/spec/lib/gitlab/markdown/filter/external_issue_reference_filter_spec.rb b/spec/lib/gitlab/markdown/filter/external_issue_reference_filter_spec.rb
index 216fcb66cef..d8420102648 100644
--- a/spec/lib/gitlab/markdown/filter/external_issue_reference_filter_spec.rb
+++ b/spec/lib/gitlab/markdown/filter/external_issue_reference_filter_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::Markdown::ExternalIssueReferenceFilter do
+describe Gitlab::Markdown::ExternalIssueReferenceFilter, lib: true do
include FilterSpecHelper
def helper
diff --git a/spec/lib/gitlab/markdown/filter/external_link_filter_spec.rb b/spec/lib/gitlab/markdown/filter/external_link_filter_spec.rb
index 20d37e0c978..e559f5741cc 100644
--- a/spec/lib/gitlab/markdown/filter/external_link_filter_spec.rb
+++ b/spec/lib/gitlab/markdown/filter/external_link_filter_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::Markdown::ExternalLinkFilter do
+describe Gitlab::Markdown::ExternalLinkFilter, lib: true do
include FilterSpecHelper
it 'ignores elements without an href attribute' do
diff --git a/spec/lib/gitlab/markdown/filter/issue_reference_filter_spec.rb b/spec/lib/gitlab/markdown/filter/issue_reference_filter_spec.rb
index cb04b4a7aca..1aa5d44568e 100644
--- a/spec/lib/gitlab/markdown/filter/issue_reference_filter_spec.rb
+++ b/spec/lib/gitlab/markdown/filter/issue_reference_filter_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::Markdown::IssueReferenceFilter do
+describe Gitlab::Markdown::IssueReferenceFilter, lib: true do
include FilterSpecHelper
def helper
diff --git a/spec/lib/gitlab/markdown/filter/label_reference_filter_spec.rb b/spec/lib/gitlab/markdown/filter/label_reference_filter_spec.rb
index 1126bf2fd84..4fcbb329fe4 100644
--- a/spec/lib/gitlab/markdown/filter/label_reference_filter_spec.rb
+++ b/spec/lib/gitlab/markdown/filter/label_reference_filter_spec.rb
@@ -1,7 +1,7 @@
require 'spec_helper'
require 'html/pipeline'
-describe Gitlab::Markdown::LabelReferenceFilter do
+describe Gitlab::Markdown::LabelReferenceFilter, lib: true do
include FilterSpecHelper
let(:project) { create(:empty_project, :public) }
diff --git a/spec/lib/gitlab/markdown/filter/merge_request_reference_filter_spec.rb b/spec/lib/gitlab/markdown/filter/merge_request_reference_filter_spec.rb
index 731dca5fe1e..589550e15c4 100644
--- a/spec/lib/gitlab/markdown/filter/merge_request_reference_filter_spec.rb
+++ b/spec/lib/gitlab/markdown/filter/merge_request_reference_filter_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::Markdown::MergeRequestReferenceFilter do
+describe Gitlab::Markdown::MergeRequestReferenceFilter, lib: true do
include FilterSpecHelper
let(:project) { create(:project, :public) }
diff --git a/spec/lib/gitlab/markdown/filter/redactor_filter_spec.rb b/spec/lib/gitlab/markdown/filter/redactor_filter_spec.rb
index 7760a1c86fa..9e6ee9f0d61 100644
--- a/spec/lib/gitlab/markdown/filter/redactor_filter_spec.rb
+++ b/spec/lib/gitlab/markdown/filter/redactor_filter_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::Markdown::RedactorFilter do
+describe Gitlab::Markdown::RedactorFilter, lib: true do
include ActionView::Helpers::UrlHelper
include FilterSpecHelper
diff --git a/spec/lib/gitlab/markdown/filter/reference_gatherer_filter_spec.rb b/spec/lib/gitlab/markdown/filter/reference_gatherer_filter_spec.rb
index caa9d5f36cc..abfb5ad5e49 100644
--- a/spec/lib/gitlab/markdown/filter/reference_gatherer_filter_spec.rb
+++ b/spec/lib/gitlab/markdown/filter/reference_gatherer_filter_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::Markdown::ReferenceGathererFilter do
+describe Gitlab::Markdown::ReferenceGathererFilter, lib: true do
include ActionView::Helpers::UrlHelper
include FilterSpecHelper
diff --git a/spec/lib/gitlab/markdown/filter/relative_link_filter_spec.rb b/spec/lib/gitlab/markdown/filter/relative_link_filter_spec.rb
index 3d978505564..e0f53e2a533 100644
--- a/spec/lib/gitlab/markdown/filter/relative_link_filter_spec.rb
+++ b/spec/lib/gitlab/markdown/filter/relative_link_filter_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-describe Gitlab::Markdown::RelativeLinkFilter do
+describe Gitlab::Markdown::RelativeLinkFilter, lib: true do
def filter(doc, contexts = {})
contexts.reverse_merge!({
commit: project.commit,
diff --git a/spec/lib/gitlab/markdown/filter/sanitization_filter_spec.rb b/spec/lib/gitlab/markdown/filter/sanitization_filter_spec.rb
index 33d850d0dd3..a5e5ee0e08a 100644
--- a/spec/lib/gitlab/markdown/filter/sanitization_filter_spec.rb
+++ b/spec/lib/gitlab/markdown/filter/sanitization_filter_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::Markdown::SanitizationFilter do
+describe Gitlab::Markdown::SanitizationFilter, lib: true do
include FilterSpecHelper
describe 'default whitelist' do
diff --git a/spec/lib/gitlab/markdown/filter/snippet_reference_filter_spec.rb b/spec/lib/gitlab/markdown/filter/snippet_reference_filter_spec.rb
index e54dc3cfa33..51526b58597 100644
--- a/spec/lib/gitlab/markdown/filter/snippet_reference_filter_spec.rb
+++ b/spec/lib/gitlab/markdown/filter/snippet_reference_filter_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::Markdown::SnippetReferenceFilter do
+describe Gitlab::Markdown::SnippetReferenceFilter, lib: true do
include FilterSpecHelper
let(:project) { create(:empty_project, :public) }
diff --git a/spec/lib/gitlab/markdown/filter/syntax_highlight_filter_spec.rb b/spec/lib/gitlab/markdown/filter/syntax_highlight_filter_spec.rb
index 2df81282fa2..8b76048f3e3 100644
--- a/spec/lib/gitlab/markdown/filter/syntax_highlight_filter_spec.rb
+++ b/spec/lib/gitlab/markdown/filter/syntax_highlight_filter_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::Markdown::SyntaxHighlightFilter do
+describe Gitlab::Markdown::SyntaxHighlightFilter, lib: true do
include FilterSpecHelper
it 'highlights valid code blocks' do
diff --git a/spec/lib/gitlab/markdown/filter/table_of_contents_filter_spec.rb b/spec/lib/gitlab/markdown/filter/table_of_contents_filter_spec.rb
index 3aba29f0f27..c8c79c41847 100644
--- a/spec/lib/gitlab/markdown/filter/table_of_contents_filter_spec.rb
+++ b/spec/lib/gitlab/markdown/filter/table_of_contents_filter_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-describe Gitlab::Markdown::TableOfContentsFilter do
+describe Gitlab::Markdown::TableOfContentsFilter, lib: true do
include FilterSpecHelper
def header(level, text)
diff --git a/spec/lib/gitlab/markdown/filter/task_list_filter_spec.rb b/spec/lib/gitlab/markdown/filter/task_list_filter_spec.rb
index 8b205adbbc4..1b1714ef882 100644
--- a/spec/lib/gitlab/markdown/filter/task_list_filter_spec.rb
+++ b/spec/lib/gitlab/markdown/filter/task_list_filter_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::Markdown::TaskListFilter do
+describe Gitlab::Markdown::TaskListFilter, lib: true do
include FilterSpecHelper
it 'does not apply `task-list` class to non-task lists' do
diff --git a/spec/lib/gitlab/markdown/filter/upload_link_filter_spec.rb b/spec/lib/gitlab/markdown/filter/upload_link_filter_spec.rb
index aec22ee4168..38a007b5bee 100644
--- a/spec/lib/gitlab/markdown/filter/upload_link_filter_spec.rb
+++ b/spec/lib/gitlab/markdown/filter/upload_link_filter_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-describe Gitlab::Markdown::UploadLinkFilter do
+describe Gitlab::Markdown::UploadLinkFilter, lib: true do
def filter(doc, contexts = {})
contexts.reverse_merge!({
project: project
diff --git a/spec/lib/gitlab/markdown/filter/user_reference_filter_spec.rb b/spec/lib/gitlab/markdown/filter/user_reference_filter_spec.rb
index 4ebf5704c70..277037cf68a 100644
--- a/spec/lib/gitlab/markdown/filter/user_reference_filter_spec.rb
+++ b/spec/lib/gitlab/markdown/filter/user_reference_filter_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::Markdown::UserReferenceFilter do
+describe Gitlab::Markdown::UserReferenceFilter, lib: true do
include FilterSpecHelper
let(:project) { create(:empty_project, :public) }
diff --git a/spec/lib/gitlab/markup_helper_spec.rb b/spec/lib/gitlab/markup_helper_spec.rb
index e610fab05da..93b91b849f2 100644
--- a/spec/lib/gitlab/markup_helper_spec.rb
+++ b/spec/lib/gitlab/markup_helper_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::MarkupHelper do
+describe Gitlab::MarkupHelper, lib: true do
describe '#markup?' do
%w(textile rdoc org creole wiki
mediawiki rst adoc ad asciidoc mdown md markdown).each do |type|
diff --git a/spec/lib/gitlab/note_data_builder_spec.rb b/spec/lib/gitlab/note_data_builder_spec.rb
index 448cd0c6880..6cbdae737f4 100644
--- a/spec/lib/gitlab/note_data_builder_spec.rb
+++ b/spec/lib/gitlab/note_data_builder_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe 'Gitlab::NoteDataBuilder' do
+describe 'Gitlab::NoteDataBuilder', lib: true do
let(:project) { create(:project) }
let(:user) { create(:user) }
let(:data) { Gitlab::NoteDataBuilder.build(note, user) }
diff --git a/spec/lib/gitlab/o_auth/auth_hash_spec.rb b/spec/lib/gitlab/o_auth/auth_hash_spec.rb
index 5632f2306ec..a4f8b44e38e 100644
--- a/spec/lib/gitlab/o_auth/auth_hash_spec.rb
+++ b/spec/lib/gitlab/o_auth/auth_hash_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::OAuth::AuthHash do
+describe Gitlab::OAuth::AuthHash, lib: true do
let(:auth_hash) do
Gitlab::OAuth::AuthHash.new(
OmniAuth::AuthHash.new(
diff --git a/spec/lib/gitlab/o_auth/user_spec.rb b/spec/lib/gitlab/o_auth/user_spec.rb
index fd3ab1fb7c8..925bc442a90 100644
--- a/spec/lib/gitlab/o_auth/user_spec.rb
+++ b/spec/lib/gitlab/o_auth/user_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::OAuth::User do
+describe Gitlab::OAuth::User, lib: true do
let(:oauth_user) { Gitlab::OAuth::User.new(auth_hash) }
let(:gl_user) { oauth_user.gl_user }
let(:uid) { 'my-uid' }
diff --git a/spec/lib/gitlab/popen_spec.rb b/spec/lib/gitlab/popen_spec.rb
index e53efec6c67..795cf241278 100644
--- a/spec/lib/gitlab/popen_spec.rb
+++ b/spec/lib/gitlab/popen_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe 'Gitlab::Popen', no_db: true do
+describe 'Gitlab::Popen', lib: true, no_db: true do
let(:path) { Rails.root.join('tmp').to_s }
before do
diff --git a/spec/lib/gitlab/project_search_results_spec.rb b/spec/lib/gitlab/project_search_results_spec.rb
index 19327ac8ce0..efc2e5f4ef1 100644
--- a/spec/lib/gitlab/project_search_results_spec.rb
+++ b/spec/lib/gitlab/project_search_results_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::ProjectSearchResults do
+describe Gitlab::ProjectSearchResults, lib: true do
let(:project) { create(:project) }
let(:query) { 'hello world' }
diff --git a/spec/lib/gitlab/push_data_builder_spec.rb b/spec/lib/gitlab/push_data_builder_spec.rb
index 2170399ab5c..3ef61685398 100644
--- a/spec/lib/gitlab/push_data_builder_spec.rb
+++ b/spec/lib/gitlab/push_data_builder_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe 'Gitlab::PushDataBuilder' do
+describe 'Gitlab::PushDataBuilder', lib: true do
let(:project) { create(:project) }
let(:user) { create(:user) }
diff --git a/spec/lib/gitlab/reference_extractor_spec.rb b/spec/lib/gitlab/reference_extractor_spec.rb
index ad84d2274e8..66dc5d4911d 100644
--- a/spec/lib/gitlab/reference_extractor_spec.rb
+++ b/spec/lib/gitlab/reference_extractor_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::ReferenceExtractor do
+describe Gitlab::ReferenceExtractor, lib: true do
let(:project) { create(:project) }
subject { Gitlab::ReferenceExtractor.new(project, project.creator) }
diff --git a/spec/lib/gitlab/regex_spec.rb b/spec/lib/gitlab/regex_spec.rb
index 7fdc8fa600d..d67ee423b9b 100644
--- a/spec/lib/gitlab/regex_spec.rb
+++ b/spec/lib/gitlab/regex_spec.rb
@@ -1,7 +1,7 @@
# coding: utf-8
require 'spec_helper'
-describe Gitlab::Regex do
+describe Gitlab::Regex, lib: true do
describe 'project path regex' do
it { expect('gitlab-ce').to match(Gitlab::Regex.project_path_regex) }
it { expect('gitlab_git').to match(Gitlab::Regex.project_path_regex) }
diff --git a/spec/lib/gitlab/sherlock/collection_spec.rb b/spec/lib/gitlab/sherlock/collection_spec.rb
index a8a9d6fc7bc..de6bb86c5dd 100644
--- a/spec/lib/gitlab/sherlock/collection_spec.rb
+++ b/spec/lib/gitlab/sherlock/collection_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::Sherlock::Collection do
+describe Gitlab::Sherlock::Collection, lib: true do
let(:collection) { described_class.new }
let(:transaction) do
diff --git a/spec/lib/gitlab/sherlock/file_sample_spec.rb b/spec/lib/gitlab/sherlock/file_sample_spec.rb
index f05a59f56f6..cadf8bbce78 100644
--- a/spec/lib/gitlab/sherlock/file_sample_spec.rb
+++ b/spec/lib/gitlab/sherlock/file_sample_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::Sherlock::FileSample do
+describe Gitlab::Sherlock::FileSample, lib: true do
let(:sample) { described_class.new(__FILE__, [], 150.4, 2) }
describe '#id' do
diff --git a/spec/lib/gitlab/sherlock/line_profiler_spec.rb b/spec/lib/gitlab/sherlock/line_profiler_spec.rb
index 8f2e1299714..d57627bba2b 100644
--- a/spec/lib/gitlab/sherlock/line_profiler_spec.rb
+++ b/spec/lib/gitlab/sherlock/line_profiler_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::Sherlock::LineProfiler do
+describe Gitlab::Sherlock::LineProfiler, lib: true do
let(:profiler) { described_class.new }
describe '#profile' do
diff --git a/spec/lib/gitlab/sherlock/line_sample_spec.rb b/spec/lib/gitlab/sherlock/line_sample_spec.rb
index 5f02f6a3213..f9b61f8684e 100644
--- a/spec/lib/gitlab/sherlock/line_sample_spec.rb
+++ b/spec/lib/gitlab/sherlock/line_sample_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::Sherlock::LineSample do
+describe Gitlab::Sherlock::LineSample, lib: true do
let(:sample) { described_class.new(150.0, 4) }
describe '#duration' do
diff --git a/spec/lib/gitlab/sherlock/location_spec.rb b/spec/lib/gitlab/sherlock/location_spec.rb
index b295a624b35..5739afa6b1e 100644
--- a/spec/lib/gitlab/sherlock/location_spec.rb
+++ b/spec/lib/gitlab/sherlock/location_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::Sherlock::Location do
+describe Gitlab::Sherlock::Location, lib: true do
let(:location) { described_class.new(__FILE__, 1) }
describe 'from_ruby_location' do
diff --git a/spec/lib/gitlab/sherlock/middleware_spec.rb b/spec/lib/gitlab/sherlock/middleware_spec.rb
index aa74fc53a79..2bbeb25ce98 100644
--- a/spec/lib/gitlab/sherlock/middleware_spec.rb
+++ b/spec/lib/gitlab/sherlock/middleware_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::Sherlock::Middleware do
+describe Gitlab::Sherlock::Middleware, lib: true do
let(:app) { double(:app) }
let(:middleware) { described_class.new(app) }
diff --git a/spec/lib/gitlab/sherlock/query_spec.rb b/spec/lib/gitlab/sherlock/query_spec.rb
index a9afef5dc1d..05da915ccfd 100644
--- a/spec/lib/gitlab/sherlock/query_spec.rb
+++ b/spec/lib/gitlab/sherlock/query_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::Sherlock::Query do
+describe Gitlab::Sherlock::Query, lib: true do
let(:started_at) { Time.utc(2015, 1, 1) }
let(:finished_at) { started_at + 5 }
diff --git a/spec/lib/gitlab/sherlock/transaction_spec.rb b/spec/lib/gitlab/sherlock/transaction_spec.rb
index fb80c62c794..7553f2a045f 100644
--- a/spec/lib/gitlab/sherlock/transaction_spec.rb
+++ b/spec/lib/gitlab/sherlock/transaction_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::Sherlock::Transaction do
+describe Gitlab::Sherlock::Transaction, lib: true do
let(:transaction) { described_class.new('POST', '/cat_pictures') }
describe '#id' do
diff --git a/spec/lib/gitlab/sql/union_spec.rb b/spec/lib/gitlab/sql/union_spec.rb
index 9e1cd4419e0..0cdbab87544 100644
--- a/spec/lib/gitlab/sql/union_spec.rb
+++ b/spec/lib/gitlab/sql/union_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::SQL::Union do
+describe Gitlab::SQL::Union, lib: true do
describe '#to_sql' do
it 'returns a String joining relations together using a UNION' do
rel1 = User.where(email: 'alice@example.com')
diff --git a/spec/lib/gitlab/themes_spec.rb b/spec/lib/gitlab/themes_spec.rb
index e554458e41c..7a140518dd2 100644
--- a/spec/lib/gitlab/themes_spec.rb
+++ b/spec/lib/gitlab/themes_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::Themes do
+describe Gitlab::Themes, lib: true do
describe '.body_classes' do
it 'returns a space-separated list of class names' do
css = described_class.body_classes
diff --git a/spec/lib/gitlab/upgrader_spec.rb b/spec/lib/gitlab/upgrader_spec.rb
index 8df84665e16..e958e087a80 100644
--- a/spec/lib/gitlab/upgrader_spec.rb
+++ b/spec/lib/gitlab/upgrader_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::Upgrader do
+describe Gitlab::Upgrader, lib: true do
let(:upgrader) { Gitlab::Upgrader.new }
let(:current_version) { Gitlab::VERSION }
diff --git a/spec/lib/gitlab/uploads_transfer_spec.rb b/spec/lib/gitlab/uploads_transfer_spec.rb
index 260364a513e..4092f7fb638 100644
--- a/spec/lib/gitlab/uploads_transfer_spec.rb
+++ b/spec/lib/gitlab/uploads_transfer_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::UploadsTransfer do
+describe Gitlab::UploadsTransfer, lib: true do
before do
@root_dir = File.join(Rails.root, "public", "uploads")
@upload_transfer = Gitlab::UploadsTransfer.new
diff --git a/spec/lib/gitlab/url_builder_spec.rb b/spec/lib/gitlab/url_builder_spec.rb
index 5153ed15af3..f023be6ae45 100644
--- a/spec/lib/gitlab/url_builder_spec.rb
+++ b/spec/lib/gitlab/url_builder_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::UrlBuilder do
+describe Gitlab::UrlBuilder, lib: true do
describe 'When asking for an issue' do
it 'returns the issue url' do
issue = create(:issue)
diff --git a/spec/lib/gitlab/version_info_spec.rb b/spec/lib/gitlab/version_info_spec.rb
index 18f71b40fe0..706ee9bec58 100644
--- a/spec/lib/gitlab/version_info_spec.rb
+++ b/spec/lib/gitlab/version_info_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe 'Gitlab::VersionInfo', no_db: true do
+describe 'Gitlab::VersionInfo', lib: true, no_db: true do
before do
@unknown = Gitlab::VersionInfo.new
@v0_0_1 = Gitlab::VersionInfo.new(0, 0, 1)
diff --git a/spec/lib/repository_cache_spec.rb b/spec/lib/repository_cache_spec.rb
index 37240d51310..63b5292b098 100644
--- a/spec/lib/repository_cache_spec.rb
+++ b/spec/lib/repository_cache_spec.rb
@@ -1,6 +1,6 @@
require_relative '../../lib/repository_cache'
-describe RepositoryCache do
+describe RepositoryCache, lib: true do
let(:backend) { double('backend').as_null_object }
let(:cache) { RepositoryCache.new('example', backend) }
diff --git a/spec/models/broadcast_message_spec.rb b/spec/models/broadcast_message_spec.rb
index 2b325f44f64..e4cac105110 100644
--- a/spec/models/broadcast_message_spec.rb
+++ b/spec/models/broadcast_message_spec.rb
@@ -15,7 +15,7 @@
require 'spec_helper'
-describe BroadcastMessage do
+describe BroadcastMessage, models: true do
subject { create(:broadcast_message) }
it { is_expected.to be_valid }
diff --git a/spec/models/build_spec.rb b/spec/models/build_spec.rb
index 839b4c6b16e..70c831b7cbe 100644
--- a/spec/models/build_spec.rb
+++ b/spec/models/build_spec.rb
@@ -25,7 +25,7 @@
require 'spec_helper'
-describe Ci::Build do
+describe Ci::Build, models: true do
let(:project) { FactoryGirl.create :ci_project }
let(:gl_project) { FactoryGirl.create :empty_project, gitlab_ci_project: project }
let(:commit) { FactoryGirl.create :ci_commit, gl_project: gl_project }
diff --git a/spec/models/ci/commit_spec.rb b/spec/models/ci/commit_spec.rb
index a13f6458cac..89813cdf7fc 100644
--- a/spec/models/ci/commit_spec.rb
+++ b/spec/models/ci/commit_spec.rb
@@ -18,7 +18,7 @@
require 'spec_helper'
-describe Ci::Commit do
+describe Ci::Commit, models: true do
let(:project) { FactoryGirl.create :ci_project }
let(:gl_project) { FactoryGirl.create :empty_project, gitlab_ci_project: project }
let(:commit) { FactoryGirl.create :ci_commit, gl_project: gl_project }
diff --git a/spec/models/ci/project_services/hip_chat_message_spec.rb b/spec/models/ci/project_services/hip_chat_message_spec.rb
index e23d6ae2c28..7d54b6cf84c 100644
--- a/spec/models/ci/project_services/hip_chat_message_spec.rb
+++ b/spec/models/ci/project_services/hip_chat_message_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Ci::HipChatMessage do
+describe Ci::HipChatMessage, models: true do
subject { Ci::HipChatMessage.new(build) }
let(:commit) { FactoryGirl.create(:ci_commit_with_two_jobs) }
diff --git a/spec/models/ci/project_services/hip_chat_service_spec.rb b/spec/models/ci/project_services/hip_chat_service_spec.rb
index d9ccc855edf..714f1e17e0b 100644
--- a/spec/models/ci/project_services/hip_chat_service_spec.rb
+++ b/spec/models/ci/project_services/hip_chat_service_spec.rb
@@ -15,7 +15,7 @@
require 'spec_helper'
-describe Ci::HipChatService do
+describe Ci::HipChatService, models: true do
describe "Validations" do
diff --git a/spec/models/ci/project_services/mail_service_spec.rb b/spec/models/ci/project_services/mail_service_spec.rb
index c03be3ef75f..638d9a4a626 100644
--- a/spec/models/ci/project_services/mail_service_spec.rb
+++ b/spec/models/ci/project_services/mail_service_spec.rb
@@ -14,7 +14,7 @@
require 'spec_helper'
-describe Ci::MailService do
+describe Ci::MailService, models: true do
describe "Associations" do
it { is_expected.to belong_to :project }
end
diff --git a/spec/models/ci/project_services/slack_message_spec.rb b/spec/models/ci/project_services/slack_message_spec.rb
index 8adda6c86cc..226032b4cda 100644
--- a/spec/models/ci/project_services/slack_message_spec.rb
+++ b/spec/models/ci/project_services/slack_message_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Ci::SlackMessage do
+describe Ci::SlackMessage, models: true do
subject { Ci::SlackMessage.new(commit) }
let(:commit) { FactoryGirl.create(:ci_commit_with_two_jobs) }
diff --git a/spec/models/ci/project_services/slack_service_spec.rb b/spec/models/ci/project_services/slack_service_spec.rb
index 1ac7dfe568d..e7d7d5d6f4c 100644
--- a/spec/models/ci/project_services/slack_service_spec.rb
+++ b/spec/models/ci/project_services/slack_service_spec.rb
@@ -14,7 +14,7 @@
require 'spec_helper'
-describe Ci::SlackService do
+describe Ci::SlackService, models: true do
describe "Associations" do
it { is_expected.to belong_to :project }
end
diff --git a/spec/models/ci/project_spec.rb b/spec/models/ci/project_spec.rb
index ac7e38bbcb0..346471aa9b5 100644
--- a/spec/models/ci/project_spec.rb
+++ b/spec/models/ci/project_spec.rb
@@ -27,7 +27,7 @@
require 'spec_helper'
-describe Ci::Project do
+describe Ci::Project, models: true do
let(:project) { FactoryGirl.create :ci_project }
let(:gl_project) { project.gl_project }
subject { project }
diff --git a/spec/models/ci/runner_project_spec.rb b/spec/models/ci/runner_project_spec.rb
index 37682c6ea0c..da8491357a5 100644
--- a/spec/models/ci/runner_project_spec.rb
+++ b/spec/models/ci/runner_project_spec.rb
@@ -11,6 +11,6 @@
require 'spec_helper'
-describe Ci::RunnerProject do
+describe Ci::RunnerProject, models: true do
pending "add some examples to (or delete) #{__FILE__}"
end
diff --git a/spec/models/ci/runner_spec.rb b/spec/models/ci/runner_spec.rb
index 9a1233b9095..6ebb5e86863 100644
--- a/spec/models/ci/runner_spec.rb
+++ b/spec/models/ci/runner_spec.rb
@@ -19,7 +19,7 @@
require 'spec_helper'
-describe Ci::Runner do
+describe Ci::Runner, models: true do
describe '#display_name' do
it 'should return the description if it has a value' do
runner = FactoryGirl.build(:ci_runner, description: 'Linux/Ruby-1.9.3-p448')
diff --git a/spec/models/ci/service_spec.rb b/spec/models/ci/service_spec.rb
index 36cda988eb4..34e3af7f810 100644
--- a/spec/models/ci/service_spec.rb
+++ b/spec/models/ci/service_spec.rb
@@ -14,7 +14,7 @@
require 'spec_helper'
-describe Ci::Service do
+describe Ci::Service, models: true do
describe "Associations" do
it { is_expected.to belong_to :project }
diff --git a/spec/models/ci/trigger_spec.rb b/spec/models/ci/trigger_spec.rb
index b8aa3c1e777..61eb3c08296 100644
--- a/spec/models/ci/trigger_spec.rb
+++ b/spec/models/ci/trigger_spec.rb
@@ -12,7 +12,7 @@
require 'spec_helper'
-describe Ci::Trigger do
+describe Ci::Trigger, models: true do
let(:project) { FactoryGirl.create :ci_project }
describe 'before_validation' do
diff --git a/spec/models/ci/variable_spec.rb b/spec/models/ci/variable_spec.rb
index a515f5881ff..31b56953a13 100644
--- a/spec/models/ci/variable_spec.rb
+++ b/spec/models/ci/variable_spec.rb
@@ -13,7 +13,7 @@
require 'spec_helper'
-describe Ci::Variable do
+describe Ci::Variable, models: true do
subject { Ci::Variable.new }
let(:secret_value) { 'secret' }
diff --git a/spec/models/ci/web_hook_spec.rb b/spec/models/ci/web_hook_spec.rb
index 2865482a212..1a4edec9d4f 100644
--- a/spec/models/ci/web_hook_spec.rb
+++ b/spec/models/ci/web_hook_spec.rb
@@ -11,7 +11,7 @@
require 'spec_helper'
-describe Ci::WebHook do
+describe Ci::WebHook, models: true do
describe "Associations" do
it { is_expected.to belong_to :project }
end
diff --git a/spec/models/commit_range_spec.rb b/spec/models/commit_range_spec.rb
index 3c1009a2eb0..9307d97e214 100644
--- a/spec/models/commit_range_spec.rb
+++ b/spec/models/commit_range_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe CommitRange do
+describe CommitRange, models: true do
describe 'modules' do
subject { described_class }
diff --git a/spec/models/commit_spec.rb b/spec/models/commit_spec.rb
index 38a3dc1f4a6..ecf37b40c58 100644
--- a/spec/models/commit_spec.rb
+++ b/spec/models/commit_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Commit do
+describe Commit, models: true do
let(:project) { create(:project) }
let(:commit) { project.commit }
diff --git a/spec/models/commit_status_spec.rb b/spec/models/commit_status_spec.rb
index dca0715eed8..5e311ead28b 100644
--- a/spec/models/commit_status_spec.rb
+++ b/spec/models/commit_status_spec.rb
@@ -33,7 +33,7 @@
require 'spec_helper'
-describe CommitStatus do
+describe CommitStatus, models: true do
let(:commit) { FactoryGirl.create :ci_commit }
let(:commit_status) { FactoryGirl.create :commit_status, commit: commit }
diff --git a/spec/models/concerns/case_sensitivity_spec.rb b/spec/models/concerns/case_sensitivity_spec.rb
index f7ed30f8198..25b3f4e50da 100644
--- a/spec/models/concerns/case_sensitivity_spec.rb
+++ b/spec/models/concerns/case_sensitivity_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe CaseSensitivity do
+describe CaseSensitivity, models: true do
describe '.iwhere' do
let(:connection) { ActiveRecord::Base.connection }
let(:model) { Class.new { include CaseSensitivity } }
diff --git a/spec/models/deploy_key_spec.rb b/spec/models/deploy_key_spec.rb
index 95729932459..64ba778afea 100644
--- a/spec/models/deploy_key_spec.rb
+++ b/spec/models/deploy_key_spec.rb
@@ -15,7 +15,7 @@
require 'spec_helper'
-describe DeployKey do
+describe DeployKey, models: true do
let(:project) { create(:project) }
let(:deploy_key) { create(:deploy_key, projects: [project]) }
diff --git a/spec/models/deploy_keys_project_spec.rb b/spec/models/deploy_keys_project_spec.rb
index 0eb22599d18..8aedbfb8636 100644
--- a/spec/models/deploy_keys_project_spec.rb
+++ b/spec/models/deploy_keys_project_spec.rb
@@ -11,7 +11,7 @@
require 'spec_helper'
-describe DeployKeysProject do
+describe DeployKeysProject, models: true do
describe "Associations" do
it { is_expected.to belong_to(:deploy_key) }
it { is_expected.to belong_to(:project) }
diff --git a/spec/models/event_spec.rb b/spec/models/event_spec.rb
index ae53f7a536b..071582b0282 100644
--- a/spec/models/event_spec.rb
+++ b/spec/models/event_spec.rb
@@ -16,7 +16,7 @@
require 'spec_helper'
-describe Event do
+describe Event, models: true do
describe "Associations" do
it { is_expected.to belong_to(:project) }
it { is_expected.to belong_to(:target) }
diff --git a/spec/models/external_issue_spec.rb b/spec/models/external_issue_spec.rb
index 7744610db78..6ec6b9037a4 100644
--- a/spec/models/external_issue_spec.rb
+++ b/spec/models/external_issue_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe ExternalIssue do
+describe ExternalIssue, models: true do
let(:project) { double('project', to_reference: 'namespace1/project1') }
let(:issue) { described_class.new('EXT-1234', project) }
diff --git a/spec/models/external_wiki_service_spec.rb b/spec/models/external_wiki_service_spec.rb
index 4bd5b0be61c..b198aa77526 100644
--- a/spec/models/external_wiki_service_spec.rb
+++ b/spec/models/external_wiki_service_spec.rb
@@ -20,7 +20,7 @@
require 'spec_helper'
-describe ExternalWikiService do
+describe ExternalWikiService, models: true do
include ExternalWikiHelper
describe "Associations" do
it { should belong_to :project }
diff --git a/spec/models/generic_commit_status_spec.rb b/spec/models/generic_commit_status_spec.rb
index c86314c454c..d61c1c96bde 100644
--- a/spec/models/generic_commit_status_spec.rb
+++ b/spec/models/generic_commit_status_spec.rb
@@ -33,7 +33,7 @@
require 'spec_helper'
-describe GenericCommitStatus do
+describe GenericCommitStatus, models: true do
let(:commit) { FactoryGirl.create :ci_commit }
let(:generic_commit_status) { FactoryGirl.create :generic_commit_status, commit: commit }
diff --git a/spec/models/global_milestone_spec.rb b/spec/models/global_milestone_spec.rb
index 6eeff30b20e..ba03e6aabd0 100644
--- a/spec/models/global_milestone_spec.rb
+++ b/spec/models/global_milestone_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe GlobalMilestone do
+describe GlobalMilestone, models: true do
let(:user) { create(:user) }
let(:user2) { create(:user) }
let(:group) { create(:group) }
diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb
index 6f166b5ab75..646f767e6fe 100644
--- a/spec/models/group_spec.rb
+++ b/spec/models/group_spec.rb
@@ -16,7 +16,7 @@
require 'spec_helper'
-describe Group do
+describe Group, models: true do
let!(:group) { create(:group) }
describe 'associations' do
diff --git a/spec/models/hooks/project_hook_spec.rb b/spec/models/hooks/project_hook_spec.rb
index a2dc66fce3e..645ee0b929a 100644
--- a/spec/models/hooks/project_hook_spec.rb
+++ b/spec/models/hooks/project_hook_spec.rb
@@ -18,7 +18,7 @@
require 'spec_helper'
-describe ProjectHook do
+describe ProjectHook, models: true do
describe '.push_hooks' do
it 'should return hooks for push events only' do
hook = create(:project_hook, push_events: true)
diff --git a/spec/models/hooks/service_hook_spec.rb b/spec/models/hooks/service_hook_spec.rb
index 16641c12124..1455661485b 100644
--- a/spec/models/hooks/service_hook_spec.rb
+++ b/spec/models/hooks/service_hook_spec.rb
@@ -18,7 +18,7 @@
require "spec_helper"
-describe ServiceHook do
+describe ServiceHook, models: true do
describe "Associations" do
it { is_expected.to belong_to :service }
end
diff --git a/spec/models/hooks/system_hook_spec.rb b/spec/models/hooks/system_hook_spec.rb
index 02d2cc2c77a..138b87a9a06 100644
--- a/spec/models/hooks/system_hook_spec.rb
+++ b/spec/models/hooks/system_hook_spec.rb
@@ -18,7 +18,7 @@
require "spec_helper"
-describe SystemHook do
+describe SystemHook, models: true do
describe "execute" do
before(:each) do
@system_hook = create(:system_hook)
diff --git a/spec/models/hooks/web_hook_spec.rb b/spec/models/hooks/web_hook_spec.rb
index 35042788c65..2d90b0793cc 100644
--- a/spec/models/hooks/web_hook_spec.rb
+++ b/spec/models/hooks/web_hook_spec.rb
@@ -18,7 +18,7 @@
require 'spec_helper'
-describe ProjectHook do
+describe ProjectHook, models: true do
describe "Associations" do
it { is_expected.to belong_to :project }
end
diff --git a/spec/models/issue_spec.rb b/spec/models/issue_spec.rb
index c9aa1b063c6..52271c7c8c6 100644
--- a/spec/models/issue_spec.rb
+++ b/spec/models/issue_spec.rb
@@ -20,7 +20,7 @@
require 'spec_helper'
-describe Issue do
+describe Issue, models: true do
describe "Associations" do
it { is_expected.to belong_to(:milestone) }
end
diff --git a/spec/models/key_spec.rb b/spec/models/key_spec.rb
index 2f819f60cbb..d7fe01976d8 100644
--- a/spec/models/key_spec.rb
+++ b/spec/models/key_spec.rb
@@ -15,7 +15,7 @@
require 'spec_helper'
-describe Key do
+describe Key, models: true do
describe "Associations" do
it { is_expected.to belong_to(:user) }
end
diff --git a/spec/models/label_link_spec.rb b/spec/models/label_link_spec.rb
index 8c240826582..dc7510b1de3 100644
--- a/spec/models/label_link_spec.rb
+++ b/spec/models/label_link_spec.rb
@@ -12,7 +12,7 @@
require 'spec_helper'
-describe LabelLink do
+describe LabelLink, models: true do
let(:label) { create(:label_link) }
it { expect(label).to be_valid }
diff --git a/spec/models/label_spec.rb b/spec/models/label_spec.rb
index 511ee8cbd96..696fbf7e0aa 100644
--- a/spec/models/label_spec.rb
+++ b/spec/models/label_spec.rb
@@ -13,7 +13,7 @@
require 'spec_helper'
-describe Label do
+describe Label, models: true do
let(:label) { create(:label) }
describe 'associations' do
diff --git a/spec/models/member_spec.rb b/spec/models/member_spec.rb
index 57f840c1e91..2aedca20df2 100644
--- a/spec/models/member_spec.rb
+++ b/spec/models/member_spec.rb
@@ -19,7 +19,7 @@
require 'spec_helper'
-describe Member do
+describe Member, models: true do
describe "Associations" do
it { is_expected.to belong_to(:user) }
end
diff --git a/spec/models/members/group_member_spec.rb b/spec/models/members/group_member_spec.rb
index 652026729bb..5424c9b9cba 100644
--- a/spec/models/members/group_member_spec.rb
+++ b/spec/models/members/group_member_spec.rb
@@ -19,7 +19,7 @@
require 'spec_helper'
-describe GroupMember do
+describe GroupMember, models: true do
context 'notification' do
describe "#after_create" do
it "should send email to user" do
diff --git a/spec/models/members/project_member_spec.rb b/spec/models/members/project_member_spec.rb
index ee912bf12a2..9f26d9eb5ce 100644
--- a/spec/models/members/project_member_spec.rb
+++ b/spec/models/members/project_member_spec.rb
@@ -19,7 +19,7 @@
require 'spec_helper'
-describe ProjectMember do
+describe ProjectMember, models: true do
describe :import_team do
before do
@abilities = Six.new
diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb
index 567c911425c..1aeba9b2b3b 100644
--- a/spec/models/merge_request_spec.rb
+++ b/spec/models/merge_request_spec.rb
@@ -25,13 +25,13 @@
require 'spec_helper'
-describe MergeRequest do
+describe MergeRequest, models: true do
subject { create(:merge_request) }
describe 'associations' do
it { is_expected.to belong_to(:target_project).with_foreign_key(:target_project_id).class_name('Project') }
it { is_expected.to belong_to(:source_project).with_foreign_key(:source_project_id).class_name('Project') }
-
+ it { is_expected.to belong_to(:merge_user).class_name("User") }
it { is_expected.to have_one(:merge_request_diff).dependent(:destroy) }
end
@@ -48,12 +48,32 @@ describe MergeRequest do
describe 'validation' do
it { is_expected.to validate_presence_of(:target_branch) }
it { is_expected.to validate_presence_of(:source_branch) }
+
+ context "Validation of merge user with Merge When Build succeeds" do
+ it "allows user to be nil when the feature is disabled" do
+ expect(subject).to be_valid
+ end
+
+ it "is invalid without merge user" do
+ subject.merge_when_build_succeeds = true
+ expect(subject).not_to be_valid
+ end
+
+ it "is valid with merge user" do
+ subject.merge_when_build_succeeds = true
+ subject.merge_user = build(:user)
+
+ expect(subject).to be_valid
+ end
+ end
end
describe 'respond to' do
it { is_expected.to respond_to(:unchecked?) }
it { is_expected.to respond_to(:can_be_merged?) }
it { is_expected.to respond_to(:cannot_be_merged?) }
+ it { is_expected.to respond_to(:merge_params) }
+ it { is_expected.to respond_to(:merge_when_build_succeeds) }
end
describe '#to_reference' do
@@ -172,6 +192,50 @@ describe MergeRequest do
end
end
+ describe '#can_remove_source_branch?' do
+ let(:user) { create(:user) }
+ let(:user2) { create(:user) }
+
+ before do
+ subject.source_project.team << [user, :master]
+
+ subject.source_branch = "feature"
+ subject.target_branch = "master"
+ subject.save!
+ end
+
+ it "can't be removed when its a protected branch" do
+ allow(subject.source_project).to receive(:protected_branch?).and_return(true)
+ expect(subject.can_remove_source_branch?(user)).to be_falsey
+ end
+
+ it "cant remove a root ref" do
+ subject.source_branch = "master"
+ subject.target_branch = "feature"
+
+ expect(subject.can_remove_source_branch?(user)).to be_falsey
+ end
+
+ it "is unable to remove the source branch for a project the user cannot push to" do
+ expect(subject.can_remove_source_branch?(user2)).to be_falsey
+ end
+
+ it "is can be removed in all other cases" do
+ expect(subject.can_remove_source_branch?(user)).to be_truthy
+ end
+ end
+
+ describe "#reset_merge_when_build_succeeds" do
+ let(:merge_if_green) { create :merge_request, merge_when_build_succeeds: true, merge_user: create(:user) }
+
+ it "sets the item to false" do
+ merge_if_green.reset_merge_when_build_succeeds
+ merge_if_green.reload
+
+ expect(merge_if_green.merge_when_build_succeeds).to be_falsey
+ end
+ end
+
describe "#hook_attrs" do
it "has all the required keys" do
attrs = subject.hook_attrs
diff --git a/spec/models/milestone_spec.rb b/spec/models/milestone_spec.rb
index 77c58627322..30a71987d86 100644
--- a/spec/models/milestone_spec.rb
+++ b/spec/models/milestone_spec.rb
@@ -15,7 +15,7 @@
require 'spec_helper'
-describe Milestone do
+describe Milestone, models: true do
describe "Associations" do
it { is_expected.to belong_to(:project) }
it { is_expected.to have_many(:issues) }
diff --git a/spec/models/namespace_spec.rb b/spec/models/namespace_spec.rb
index a98b9cb7321..4fa2d2bc4d2 100644
--- a/spec/models/namespace_spec.rb
+++ b/spec/models/namespace_spec.rb
@@ -16,7 +16,7 @@
require 'spec_helper'
-describe Namespace do
+describe Namespace, models: true do
let!(:namespace) { create(:namespace) }
it { is_expected.to have_many :projects }
diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb
index f347f537550..cd3c868ecc5 100644
--- a/spec/models/note_spec.rb
+++ b/spec/models/note_spec.rb
@@ -16,11 +16,12 @@
# system :boolean default(FALSE), not null
# st_diff :text
# updated_by_id :integer
+# is_award :boolean default(FALSE), not null
#
require 'spec_helper'
-describe Note do
+describe Note, models: true do
describe 'associations' do
it { is_expected.to belong_to(:project) }
it { is_expected.to belong_to(:noteable) }
diff --git a/spec/models/project_security_spec.rb b/spec/models/project_security_spec.rb
index f600a240c46..3643ad1b052 100644
--- a/spec/models/project_security_spec.rb
+++ b/spec/models/project_security_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Project do
+describe Project, models: true do
describe :authorization do
before do
@p1 = create(:project)
diff --git a/spec/models/project_services/buildkite_service_spec.rb b/spec/models/project_services/buildkite_service_spec.rb
index 230807ea672..88cd624877a 100644
--- a/spec/models/project_services/buildkite_service_spec.rb
+++ b/spec/models/project_services/buildkite_service_spec.rb
@@ -20,7 +20,7 @@
require 'spec_helper'
-describe BuildkiteService do
+describe BuildkiteService, models: true do
describe 'Associations' do
it { is_expected.to belong_to :project }
it { is_expected.to have_one :service_hook }
diff --git a/spec/models/project_services/drone_ci_service_spec.rb b/spec/models/project_services/drone_ci_service_spec.rb
index e9967f5fe0b..a2cf68a9e38 100644
--- a/spec/models/project_services/drone_ci_service_spec.rb
+++ b/spec/models/project_services/drone_ci_service_spec.rb
@@ -20,7 +20,7 @@
require 'spec_helper'
-describe DroneCiService do
+describe DroneCiService, models: true do
describe 'associations' do
it { is_expected.to belong_to(:project) }
it { is_expected.to have_one(:service_hook) }
diff --git a/spec/models/project_services/flowdock_service_spec.rb b/spec/models/project_services/flowdock_service_spec.rb
index 16296607a94..ff7fbcaa004 100644
--- a/spec/models/project_services/flowdock_service_spec.rb
+++ b/spec/models/project_services/flowdock_service_spec.rb
@@ -20,7 +20,7 @@
require 'spec_helper'
-describe FlowdockService do
+describe FlowdockService, models: true do
describe "Associations" do
it { is_expected.to belong_to :project }
it { is_expected.to have_one :service_hook }
diff --git a/spec/models/project_services/gemnasium_service_spec.rb b/spec/models/project_services/gemnasium_service_spec.rb
index 9e156472316..ecb3ccb1673 100644
--- a/spec/models/project_services/gemnasium_service_spec.rb
+++ b/spec/models/project_services/gemnasium_service_spec.rb
@@ -20,7 +20,7 @@
require 'spec_helper'
-describe GemnasiumService do
+describe GemnasiumService, models: true do
describe "Associations" do
it { is_expected.to belong_to :project }
it { is_expected.to have_one :service_hook }
diff --git a/spec/models/project_services/gitlab_ci_service_spec.rb b/spec/models/project_services/gitlab_ci_service_spec.rb
index b9006b693b2..835bf364050 100644
--- a/spec/models/project_services/gitlab_ci_service_spec.rb
+++ b/spec/models/project_services/gitlab_ci_service_spec.rb
@@ -20,7 +20,7 @@
require 'spec_helper'
-describe GitlabCiService do
+describe GitlabCiService, models: true do
describe 'associations' do
it { is_expected.to belong_to(:project) }
it { is_expected.to have_one(:service_hook) }
diff --git a/spec/models/project_services/gitlab_issue_tracker_service_spec.rb b/spec/models/project_services/gitlab_issue_tracker_service_spec.rb
index e34ca09bffc..3518dbd1728 100644
--- a/spec/models/project_services/gitlab_issue_tracker_service_spec.rb
+++ b/spec/models/project_services/gitlab_issue_tracker_service_spec.rb
@@ -20,7 +20,7 @@
require 'spec_helper'
-describe GitlabIssueTrackerService do
+describe GitlabIssueTrackerService, models: true do
describe "Associations" do
it { is_expected.to belong_to :project }
it { is_expected.to have_one :service_hook }
diff --git a/spec/models/project_services/hipchat_service_spec.rb b/spec/models/project_services/hipchat_service_spec.rb
index f67d7b30980..c96ab548149 100644
--- a/spec/models/project_services/hipchat_service_spec.rb
+++ b/spec/models/project_services/hipchat_service_spec.rb
@@ -20,7 +20,7 @@
require 'spec_helper'
-describe HipchatService do
+describe HipchatService, models: true do
describe "Associations" do
it { is_expected.to belong_to :project }
it { is_expected.to have_one :service_hook }
diff --git a/spec/models/project_services/irker_service_spec.rb b/spec/models/project_services/irker_service_spec.rb
index 7d483a44c53..b783b1a576e 100644
--- a/spec/models/project_services/irker_service_spec.rb
+++ b/spec/models/project_services/irker_service_spec.rb
@@ -22,7 +22,7 @@ require 'spec_helper'
require 'socket'
require 'json'
-describe IrkerService do
+describe IrkerService, models: true do
describe 'Associations' do
it { is_expected.to belong_to :project }
it { is_expected.to have_one :service_hook }
diff --git a/spec/models/project_services/jira_service_spec.rb b/spec/models/project_services/jira_service_spec.rb
index 576f5fc79eb..7d91ebe9ce6 100644
--- a/spec/models/project_services/jira_service_spec.rb
+++ b/spec/models/project_services/jira_service_spec.rb
@@ -20,7 +20,7 @@
require 'spec_helper'
-describe JiraService do
+describe JiraService, models: true do
describe "Associations" do
it { is_expected.to belong_to :project }
it { is_expected.to have_one :service_hook }
diff --git a/spec/models/project_services/pushover_service_spec.rb b/spec/models/project_services/pushover_service_spec.rb
index ac10ffbd39b..96039f9491b 100644
--- a/spec/models/project_services/pushover_service_spec.rb
+++ b/spec/models/project_services/pushover_service_spec.rb
@@ -20,7 +20,7 @@
require 'spec_helper'
-describe PushoverService do
+describe PushoverService, models: true do
describe 'Associations' do
it { is_expected.to belong_to :project }
it { is_expected.to have_one :service_hook }
diff --git a/spec/models/project_services/slack_service/issue_message_spec.rb b/spec/models/project_services/slack_service/issue_message_spec.rb
index b78d92f23a1..97e6f03e308 100644
--- a/spec/models/project_services/slack_service/issue_message_spec.rb
+++ b/spec/models/project_services/slack_service/issue_message_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe SlackService::IssueMessage do
+describe SlackService::IssueMessage, models: true do
subject { SlackService::IssueMessage.new(args) }
let(:args) do
diff --git a/spec/models/project_services/slack_service/merge_message_spec.rb b/spec/models/project_services/slack_service/merge_message_spec.rb
index 581c50d6c88..dae8bd90922 100644
--- a/spec/models/project_services/slack_service/merge_message_spec.rb
+++ b/spec/models/project_services/slack_service/merge_message_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe SlackService::MergeMessage do
+describe SlackService::MergeMessage, models: true do
subject { SlackService::MergeMessage.new(args) }
let(:args) do
diff --git a/spec/models/project_services/slack_service/note_message_spec.rb b/spec/models/project_services/slack_service/note_message_spec.rb
index 21fb575480b..ebf8837570e 100644
--- a/spec/models/project_services/slack_service/note_message_spec.rb
+++ b/spec/models/project_services/slack_service/note_message_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe SlackService::NoteMessage do
+describe SlackService::NoteMessage, models: true do
let(:color) { '#345' }
before do
diff --git a/spec/models/project_services/slack_service/push_message_spec.rb b/spec/models/project_services/slack_service/push_message_spec.rb
index ddc290820d1..cda9ee670b0 100644
--- a/spec/models/project_services/slack_service/push_message_spec.rb
+++ b/spec/models/project_services/slack_service/push_message_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe SlackService::PushMessage do
+describe SlackService::PushMessage, models: true do
subject { SlackService::PushMessage.new(args) }
let(:args) do
diff --git a/spec/models/project_services/slack_service_spec.rb b/spec/models/project_services/slack_service_spec.rb
index 97b60e19e40..a9e0afad90f 100644
--- a/spec/models/project_services/slack_service_spec.rb
+++ b/spec/models/project_services/slack_service_spec.rb
@@ -20,7 +20,7 @@
require 'spec_helper'
-describe SlackService do
+describe SlackService, models: true do
describe "Associations" do
it { is_expected.to belong_to :project }
it { is_expected.to have_one :service_hook }
diff --git a/spec/models/project_snippet_spec.rb b/spec/models/project_snippet_spec.rb
index 3e8f106d27f..cc92eb0bd9f 100644
--- a/spec/models/project_snippet_spec.rb
+++ b/spec/models/project_snippet_spec.rb
@@ -17,7 +17,7 @@
require 'spec_helper'
-describe ProjectSnippet do
+describe ProjectSnippet, models: true do
describe "Associations" do
it { is_expected.to belong_to(:project) }
end
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index 06a02c13bf1..6ddb0e2b8f7 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -28,11 +28,12 @@
# import_type :string(255)
# import_source :string(255)
# commit_count :integer default(0)
+# import_error :text
#
require 'spec_helper'
-describe Project do
+describe Project, models: true do
describe 'associations' do
it { is_expected.to belong_to(:group) }
it { is_expected.to belong_to(:namespace) }
diff --git a/spec/models/project_team_spec.rb b/spec/models/project_team_spec.rb
index 26e8fdae472..5cd5ae327bf 100644
--- a/spec/models/project_team_spec.rb
+++ b/spec/models/project_team_spec.rb
@@ -1,6 +1,6 @@
require "spec_helper"
-describe ProjectTeam do
+describe ProjectTeam, models: true do
let(:master) { create(:user) }
let(:reporter) { create(:user) }
let(:guest) { create(:user) }
diff --git a/spec/models/project_wiki_spec.rb b/spec/models/project_wiki_spec.rb
index 3b889144447..876b927eaea 100644
--- a/spec/models/project_wiki_spec.rb
+++ b/spec/models/project_wiki_spec.rb
@@ -1,6 +1,6 @@
require "spec_helper"
-describe ProjectWiki do
+describe ProjectWiki, models: true do
let(:project) { create(:empty_project) }
let(:repository) { project.repository }
let(:user) { project.owner }
diff --git a/spec/models/protected_branch_spec.rb b/spec/models/protected_branch_spec.rb
index 1e6937b536c..7e956cf6779 100644
--- a/spec/models/protected_branch_spec.rb
+++ b/spec/models/protected_branch_spec.rb
@@ -12,7 +12,7 @@
require 'spec_helper'
-describe ProtectedBranch do
+describe ProtectedBranch, models: true do
describe 'Associations' do
it { is_expected.to belong_to(:project) }
end
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb
index fa261e64c35..e6c415da267 100644
--- a/spec/models/repository_spec.rb
+++ b/spec/models/repository_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Repository do
+describe Repository, models: true do
include RepoHelpers
let(:repository) { create(:project).repository }
diff --git a/spec/models/service_spec.rb b/spec/models/service_spec.rb
index 692e5fda3ba..0ca82365b98 100644
--- a/spec/models/service_spec.rb
+++ b/spec/models/service_spec.rb
@@ -20,7 +20,7 @@
require 'spec_helper'
-describe Service do
+describe Service, models: true do
describe "Associations" do
it { is_expected.to belong_to :project }
diff --git a/spec/models/snippet_spec.rb b/spec/models/snippet_spec.rb
index 81581838675..eb2dbbdc5a4 100644
--- a/spec/models/snippet_spec.rb
+++ b/spec/models/snippet_spec.rb
@@ -17,7 +17,7 @@
require 'spec_helper'
-describe Snippet do
+describe Snippet, models: true do
describe 'modules' do
subject { described_class }
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index a0f78d3b336..daa9d1087bf 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -56,11 +56,12 @@
# project_view :integer default(0)
# consumed_timestep :integer
# layout :integer default(0)
+# hide_project_limit :boolean default(FALSE)
#
require 'spec_helper'
-describe User do
+describe User, models: true do
include Gitlab::CurrentSettings
describe 'modules' do
diff --git a/spec/models/wiki_page_spec.rb b/spec/models/wiki_page_spec.rb
index d7802d1734f..c1b03838aa9 100644
--- a/spec/models/wiki_page_spec.rb
+++ b/spec/models/wiki_page_spec.rb
@@ -1,6 +1,6 @@
require "spec_helper"
-describe WikiPage do
+describe WikiPage, models: true do
let(:project) { create(:empty_project) }
let(:user) { project.owner }
let(:wiki) { ProjectWiki.new(project, user) }
diff --git a/spec/requests/api/merge_requests_spec.rb b/spec/requests/api/merge_requests_spec.rb
index c6d3aef0af9..a91fa735321 100644
--- a/spec/requests/api/merge_requests_spec.rb
+++ b/spec/requests/api/merge_requests_spec.rb
@@ -320,19 +320,21 @@ describe API::API, api: true do
end
describe "PUT /projects/:id/merge_request/:merge_request_id/merge" do
+ let(:ci_commit) { create(:ci_commit_without_jobs) }
+
it "should return merge_request in case of success" do
put api("/projects/#{project.id}/merge_request/#{merge_request.id}/merge", user)
expect(response.status).to eq(200)
end
- it "should return 405 if branch can't be merged" do
+ it "should return 406 if branch can't be merged" do
allow_any_instance_of(MergeRequest).
to receive(:can_be_merged?).and_return(false)
put api("/projects/#{project.id}/merge_request/#{merge_request.id}/merge", user)
- expect(response.status).to eq(405)
+ expect(response.status).to eq(406)
expect(json_response['message']).to eq('Branch cannot be merged')
end
@@ -357,6 +359,17 @@ describe API::API, api: true do
expect(response.status).to eq(401)
expect(json_response['message']).to eq('401 Unauthorized')
end
+
+ it "enables merge when build succeeds if the ci is active" do
+ allow_any_instance_of(MergeRequest).to receive(:ci_commit).and_return(ci_commit)
+ allow(ci_commit).to receive(:active?).and_return(true)
+
+ put api("/projects/#{project.id}/merge_request/#{merge_request.id}/merge", user), merge_when_build_succeeds: true
+
+ expect(response.status).to eq(200)
+ expect(json_response['title']).to eq('Test')
+ expect(json_response['merge_when_build_succeeds']).to eq(true)
+ end
end
describe "PUT /projects/:id/merge_request/:merge_request_id" do
diff --git a/spec/services/archive_repository_service_spec.rb b/spec/services/archive_repository_service_spec.rb
index f7a36cd9670..bd871605c66 100644
--- a/spec/services/archive_repository_service_spec.rb
+++ b/spec/services/archive_repository_service_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe ArchiveRepositoryService do
+describe ArchiveRepositoryService, services: true do
let(:project) { create(:project) }
subject { ArchiveRepositoryService.new(project, "master", "zip") }
diff --git a/spec/services/ci/create_commit_service_spec.rb b/spec/services/ci/create_commit_service_spec.rb
index e0ede1d58b7..c2fafca2ad2 100644
--- a/spec/services/ci/create_commit_service_spec.rb
+++ b/spec/services/ci/create_commit_service_spec.rb
@@ -1,7 +1,7 @@
require 'spec_helper'
module Ci
- describe CreateCommitService do
+ describe CreateCommitService, services: true do
let(:service) { CreateCommitService.new }
let(:project) { FactoryGirl.create(:ci_project) }
let(:user) { nil }
diff --git a/spec/services/ci/create_trigger_request_service_spec.rb b/spec/services/ci/create_trigger_request_service_spec.rb
index 2ef4bb50a57..c80cb58163a 100644
--- a/spec/services/ci/create_trigger_request_service_spec.rb
+++ b/spec/services/ci/create_trigger_request_service_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Ci::CreateTriggerRequestService do
+describe Ci::CreateTriggerRequestService, services: true do
let(:service) { Ci::CreateTriggerRequestService.new }
let(:gl_project) { create(:project) }
let(:project) { gl_project.ensure_gitlab_ci_project }
diff --git a/spec/services/ci/event_service_spec.rb b/spec/services/ci/event_service_spec.rb
index 1264e17ff5e..32516c75cf3 100644
--- a/spec/services/ci/event_service_spec.rb
+++ b/spec/services/ci/event_service_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Ci::EventService do
+describe Ci::EventService, services: true do
let(:project) { FactoryGirl.create :ci_project }
let(:user) { double(username: "root", id: 1) }
diff --git a/spec/services/ci/image_for_build_service_spec.rb b/spec/services/ci/image_for_build_service_spec.rb
index cda7d0c4a51..b43cabb4ee4 100644
--- a/spec/services/ci/image_for_build_service_spec.rb
+++ b/spec/services/ci/image_for_build_service_spec.rb
@@ -1,7 +1,7 @@
require 'spec_helper'
module Ci
- describe ImageForBuildService do
+ describe ImageForBuildService, services: true do
let(:service) { ImageForBuildService.new }
let(:project) { FactoryGirl.create(:ci_project) }
let(:gl_project) { FactoryGirl.create(:project, gitlab_ci_project: project) }
diff --git a/spec/services/ci/register_build_service_spec.rb b/spec/services/ci/register_build_service_spec.rb
index b370dfbe113..379e07982fb 100644
--- a/spec/services/ci/register_build_service_spec.rb
+++ b/spec/services/ci/register_build_service_spec.rb
@@ -1,7 +1,7 @@
require 'spec_helper'
module Ci
- describe RegisterBuildService do
+ describe RegisterBuildService, services: true do
let!(:service) { RegisterBuildService.new }
let!(:gl_project) { FactoryGirl.create :empty_project }
let!(:commit) { FactoryGirl.create :ci_commit, gl_project: gl_project }
diff --git a/spec/services/ci/web_hook_service_spec.rb b/spec/services/ci/web_hook_service_spec.rb
index aa48fcbcbfd..e7d8ab30652 100644
--- a/spec/services/ci/web_hook_service_spec.rb
+++ b/spec/services/ci/web_hook_service_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Ci::WebHookService do
+describe Ci::WebHookService, services: true do
let(:project) { FactoryGirl.create :ci_project }
let(:gl_project) { FactoryGirl.create :empty_project, gitlab_ci_project: project }
let(:commit) { FactoryGirl.create :ci_commit, gl_project: gl_project }
diff --git a/spec/services/create_release_service_spec.rb b/spec/services/create_release_service_spec.rb
index 26d7f365bbb..61e5ae72f51 100644
--- a/spec/services/create_release_service_spec.rb
+++ b/spec/services/create_release_service_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe CreateReleaseService do
+describe CreateReleaseService, services: true do
let(:project) { create(:project) }
let(:user) { create(:user) }
let(:tag_name) { project.repository.tag_names.first }
diff --git a/spec/services/create_snippet_service_spec.rb b/spec/services/create_snippet_service_spec.rb
index 8edabe9450b..c800dea04fa 100644
--- a/spec/services/create_snippet_service_spec.rb
+++ b/spec/services/create_snippet_service_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe CreateSnippetService do
+describe CreateSnippetService, services: true do
before do
@user = create :user
@admin = create :user, admin: true
diff --git a/spec/services/destroy_group_service_spec.rb b/spec/services/destroy_group_service_spec.rb
index e28564b3866..afa89b84175 100644
--- a/spec/services/destroy_group_service_spec.rb
+++ b/spec/services/destroy_group_service_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe DestroyGroupService do
+describe DestroyGroupService, services: true do
let!(:user) { create(:user) }
let!(:group) { create(:group) }
let!(:project) { create(:project, namespace: group) }
diff --git a/spec/services/event_create_service_spec.rb b/spec/services/event_create_service_spec.rb
index 7756b973ecd..f6dc9d4008f 100644
--- a/spec/services/event_create_service_spec.rb
+++ b/spec/services/event_create_service_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe EventCreateService do
+describe EventCreateService, services: true do
let(:service) { EventCreateService.new }
describe 'Issues' do
diff --git a/spec/services/git_hooks_service_spec.rb b/spec/services/git_hooks_service_spec.rb
index 7e018d3c9fe..2bb9c3b3db3 100644
--- a/spec/services/git_hooks_service_spec.rb
+++ b/spec/services/git_hooks_service_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe GitHooksService do
+describe GitHooksService, services: true do
include RepoHelpers
let(:user) { create :user }
diff --git a/spec/services/git_push_service_spec.rb b/spec/services/git_push_service_spec.rb
index 17015d29e51..a04c242cf0e 100644
--- a/spec/services/git_push_service_spec.rb
+++ b/spec/services/git_push_service_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe GitPushService do
+describe GitPushService, services: true do
include RepoHelpers
let(:user) { create :user }
diff --git a/spec/services/git_tag_push_service_spec.rb b/spec/services/git_tag_push_service_spec.rb
index eed50c7ebac..e2d15f1a83d 100644
--- a/spec/services/git_tag_push_service_spec.rb
+++ b/spec/services/git_tag_push_service_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe GitTagPushService do
+describe GitTagPushService, services: true do
include RepoHelpers
let(:user) { create :user }
diff --git a/spec/services/issues/bulk_update_service_spec.rb b/spec/services/issues/bulk_update_service_spec.rb
index 4c62fbafd73..6a7ea4b2f44 100644
--- a/spec/services/issues/bulk_update_service_spec.rb
+++ b/spec/services/issues/bulk_update_service_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Issues::BulkUpdateService do
+describe Issues::BulkUpdateService, services: true do
let(:issue) { create(:issue, project: @project) }
before do
diff --git a/spec/services/issues/close_service_spec.rb b/spec/services/issues/close_service_spec.rb
index d711e3da104..3a8daf28f5e 100644
--- a/spec/services/issues/close_service_spec.rb
+++ b/spec/services/issues/close_service_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Issues::CloseService do
+describe Issues::CloseService, services: true do
let(:user) { create(:user) }
let(:user2) { create(:user) }
let(:issue) { create(:issue, assignee: user2) }
diff --git a/spec/services/issues/create_service_spec.rb b/spec/services/issues/create_service_spec.rb
index 7f1ebcb3198..2148d091a57 100644
--- a/spec/services/issues/create_service_spec.rb
+++ b/spec/services/issues/create_service_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Issues::CreateService do
+describe Issues::CreateService, services: true do
let(:project) { create(:empty_project) }
let(:user) { create(:user) }
diff --git a/spec/services/issues/update_service_spec.rb b/spec/services/issues/update_service_spec.rb
index 73d0b7f7abe..87da0e9618b 100644
--- a/spec/services/issues/update_service_spec.rb
+++ b/spec/services/issues/update_service_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Issues::UpdateService do
+describe Issues::UpdateService, services: true do
let(:user) { create(:user) }
let(:user2) { create(:user) }
let(:user3) { create(:user) }
diff --git a/spec/services/merge_requests/close_service_spec.rb b/spec/services/merge_requests/close_service_spec.rb
index 272f3897938..50d0c288790 100644
--- a/spec/services/merge_requests/close_service_spec.rb
+++ b/spec/services/merge_requests/close_service_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe MergeRequests::CloseService do
+describe MergeRequests::CloseService, services: true do
let(:user) { create(:user) }
let(:user2) { create(:user) }
let(:merge_request) { create(:merge_request, assignee: user2) }
diff --git a/spec/services/merge_requests/create_service_spec.rb b/spec/services/merge_requests/create_service_spec.rb
index cc64d69361e..be8f1676eeb 100644
--- a/spec/services/merge_requests/create_service_spec.rb
+++ b/spec/services/merge_requests/create_service_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe MergeRequests::CreateService do
+describe MergeRequests::CreateService, services: true do
let(:project) { create(:project) }
let(:user) { create(:user) }
diff --git a/spec/services/merge_requests/merge_service_spec.rb b/spec/services/merge_requests/merge_service_spec.rb
index c0961ceb11e..ceb3f97280e 100644
--- a/spec/services/merge_requests/merge_service_spec.rb
+++ b/spec/services/merge_requests/merge_service_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe MergeRequests::MergeService do
+describe MergeRequests::MergeService, services: true do
let(:user) { create(:user) }
let(:user2) { create(:user) }
let(:merge_request) { create(:merge_request, assignee: user2) }
@@ -13,12 +13,13 @@ describe MergeRequests::MergeService do
describe :execute do
context 'valid params' do
- let(:service) { MergeRequests::MergeService.new(project, user, {}) }
+ let(:service) { MergeRequests::MergeService.new(project, user, commit_message: 'Awesome message') }
before do
allow(service).to receive(:execute_hooks)
+
perform_enqueued_jobs do
- service.execute(merge_request, 'Awesome message')
+ service.execute(merge_request)
end
end
@@ -38,14 +39,14 @@ describe MergeRequests::MergeService do
end
context "error handling" do
- let(:service) { MergeRequests::MergeService.new(project, user, {}) }
+ let(:service) { MergeRequests::MergeService.new(project, user, commit_message: 'Awesome message') }
it 'saves error if there is an exception' do
allow(service).to receive(:repository).and_raise("error")
allow(service).to receive(:execute_hooks)
- service.execute(merge_request, 'Awesome message')
+ service.execute(merge_request)
expect(merge_request.merge_error).to eq("Something went wrong during merge")
end
diff --git a/spec/services/merge_requests/merge_when_build_succeeds_service_spec.rb b/spec/services/merge_requests/merge_when_build_succeeds_service_spec.rb
new file mode 100644
index 00000000000..188fda6211f
--- /dev/null
+++ b/spec/services/merge_requests/merge_when_build_succeeds_service_spec.rb
@@ -0,0 +1,84 @@
+require 'spec_helper'
+
+describe MergeRequests::MergeWhenBuildSucceedsService do
+ let(:user) { create(:user) }
+ let(:merge_request) { create(:merge_request) }
+
+ let(:mr_merge_if_green_enabled) do
+ create(:merge_request, merge_when_build_succeeds: true, merge_user: user,
+ source_branch: "source_branch", target_branch: project.default_branch,
+ source_project: project, target_project: project, state: "opened")
+ end
+
+ let(:project) { create(:project) }
+ let(:ci_commit) { create(:ci_commit_with_one_job, ref: mr_merge_if_green_enabled.source_branch, gl_project: project) }
+ let(:service) { MergeRequests::MergeWhenBuildSucceedsService.new(project, user, commit_message: 'Awesome message') }
+
+ describe "#execute" do
+ context 'first time enabling' do
+ before do
+ allow(merge_request).to receive(:ci_commit).and_return(ci_commit)
+ service.execute(merge_request)
+ end
+
+ it 'sets the params, merge_user, and flag' do
+ expect(merge_request).to be_valid
+ expect(merge_request.merge_when_build_succeeds).to be_truthy
+ expect(merge_request.merge_params).to eq commit_message: 'Awesome message'
+ expect(merge_request.merge_user).to be user
+ end
+
+ it 'creates a system note' do
+ note = merge_request.notes.last
+ expect(note.note).to match /Enabled an automatic merge when the build for (\w+\/\w+@)?[0-9a-z]{8}/
+ end
+ end
+
+ context 'already approved' do
+ let(:service) { MergeRequests::MergeWhenBuildSucceedsService.new(project, user, new_key: true) }
+ let(:build) { create(:ci_build, ref: mr_merge_if_green_enabled.source_branch) }
+
+ before do
+ allow(mr_merge_if_green_enabled).to receive(:ci_commit).and_return(ci_commit)
+ allow(mr_merge_if_green_enabled).to receive(:mergeable?).and_return(true)
+ allow(ci_commit).to receive(:success?).and_return(true)
+ end
+
+ it 'updates the merge params' do
+ expect(SystemNoteService).not_to receive(:merge_when_build_succeeds)
+
+ service.execute(mr_merge_if_green_enabled)
+ expect(mr_merge_if_green_enabled.merge_params).to have_key(:new_key)
+ end
+ end
+ end
+
+ describe "#trigger" do
+ let(:build) { create(:ci_build, ref: mr_merge_if_green_enabled.source_branch, status: "success") }
+
+ it "merges all merge requests with merge when build succeeds enabled" do
+ allow_any_instance_of(MergeRequest).to receive(:ci_commit).and_return(ci_commit)
+ allow(ci_commit).to receive(:success?).and_return(true)
+
+ expect(MergeWorker).to receive(:perform_async)
+ service.trigger(build)
+ end
+ end
+
+ describe "#cancel" do
+ before do
+ service.cancel(mr_merge_if_green_enabled)
+ end
+
+ it "resets all the merge_when_build_succeeds params" do
+ expect(mr_merge_if_green_enabled.merge_when_build_succeeds).to be_falsey
+ expect(mr_merge_if_green_enabled.merge_params).to eq({})
+ expect(mr_merge_if_green_enabled.merge_user).to be nil
+ end
+
+ it 'Posts a system note' do
+ note = mr_merge_if_green_enabled.notes.last
+ expect(note.note).to include 'Canceled the automatic merge'
+ end
+ end
+end
diff --git a/spec/services/merge_requests/refresh_service_spec.rb b/spec/services/merge_requests/refresh_service_spec.rb
index 7ee4488521d..450250ba032 100644
--- a/spec/services/merge_requests/refresh_service_spec.rb
+++ b/spec/services/merge_requests/refresh_service_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe MergeRequests::RefreshService do
+describe MergeRequests::RefreshService, services: true do
let(:project) { create(:project) }
let(:user) { create(:user) }
let(:service) { MergeRequests::RefreshService }
@@ -17,7 +17,9 @@ describe MergeRequests::RefreshService do
source_project: @project,
source_branch: 'master',
target_branch: 'feature',
- target_project: @project)
+ target_project: @project,
+ merge_when_build_succeeds: true,
+ merge_user: @user)
@fork_merge_request = create(:merge_request,
source_project: @fork_project,
@@ -46,6 +48,7 @@ describe MergeRequests::RefreshService do
it { expect(@merge_request.notes).not_to be_empty }
it { expect(@merge_request).to be_open }
+ it { expect(@merge_request.merge_when_build_succeeds).to be_falsey}
it { expect(@fork_merge_request).to be_open }
it { expect(@fork_merge_request.notes).to be_empty }
end
@@ -146,6 +149,7 @@ describe MergeRequests::RefreshService do
end
end
+
def reload_mrs
@merge_request.reload
@fork_merge_request.reload
diff --git a/spec/services/merge_requests/reopen_service_spec.rb b/spec/services/merge_requests/reopen_service_spec.rb
index 05146bf43f4..ac0221998f5 100644
--- a/spec/services/merge_requests/reopen_service_spec.rb
+++ b/spec/services/merge_requests/reopen_service_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe MergeRequests::ReopenService do
+describe MergeRequests::ReopenService, services: true do
let(:user) { create(:user) }
let(:user2) { create(:user) }
let(:merge_request) { create(:merge_request, assignee: user2) }
diff --git a/spec/services/merge_requests/update_service_spec.rb b/spec/services/merge_requests/update_service_spec.rb
index d899b1f01d1..2e9e6e0870d 100644
--- a/spec/services/merge_requests/update_service_spec.rb
+++ b/spec/services/merge_requests/update_service_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe MergeRequests::UpdateService do
+describe MergeRequests::UpdateService, services: true do
let(:user) { create(:user) }
let(:user2) { create(:user) }
let(:user3) { create(:user) }
diff --git a/spec/services/milestones/close_service_spec.rb b/spec/services/milestones/close_service_spec.rb
index 034c0f22e12..1cd6eb2ab38 100644
--- a/spec/services/milestones/close_service_spec.rb
+++ b/spec/services/milestones/close_service_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Milestones::CloseService do
+describe Milestones::CloseService, services: true do
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:milestone) { create(:milestone, title: "Milestone v1.2", project: project) }
diff --git a/spec/services/milestones/create_service_spec.rb b/spec/services/milestones/create_service_spec.rb
index 757c9a226d8..c793026e300 100644
--- a/spec/services/milestones/create_service_spec.rb
+++ b/spec/services/milestones/create_service_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Milestones::CreateService do
+describe Milestones::CreateService, services: true do
let(:project) { create(:empty_project) }
let(:user) { create(:user) }
diff --git a/spec/services/notes/create_service_spec.rb b/spec/services/notes/create_service_spec.rb
index cc38d257792..a797a2fe4aa 100644
--- a/spec/services/notes/create_service_spec.rb
+++ b/spec/services/notes/create_service_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Notes::CreateService do
+describe Notes::CreateService, services: true do
let(:project) { create(:empty_project) }
let(:issue) { create(:issue, project: project) }
let(:user) { create(:user) }
diff --git a/spec/services/notification_service_spec.rb b/spec/services/notification_service_spec.rb
index 35fa412ed80..d7a898e85ff 100644
--- a/spec/services/notification_service_spec.rb
+++ b/spec/services/notification_service_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe NotificationService do
+describe NotificationService, services: true do
let(:notification) { NotificationService.new }
around(:each) do |example|
diff --git a/spec/services/projects/create_service_spec.rb b/spec/services/projects/create_service_spec.rb
index e81c4edb7d8..2d8c316e38d 100644
--- a/spec/services/projects/create_service_spec.rb
+++ b/spec/services/projects/create_service_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Projects::CreateService do
+describe Projects::CreateService, services: true do
describe :create_by_user do
before do
@user = create :user
diff --git a/spec/services/projects/destroy_service_spec.rb b/spec/services/projects/destroy_service_spec.rb
index e83eef0b1a2..1ec27077717 100644
--- a/spec/services/projects/destroy_service_spec.rb
+++ b/spec/services/projects/destroy_service_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Projects::DestroyService do
+describe Projects::DestroyService, services: true do
let!(:user) { create(:user) }
let!(:project) { create(:project, namespace: user.namespace) }
let!(:path) { project.repository.path_to_repo }
diff --git a/spec/services/projects/download_service_spec.rb b/spec/services/projects/download_service_spec.rb
index ddee2e62dfc..5ceed5af9a5 100644
--- a/spec/services/projects/download_service_spec.rb
+++ b/spec/services/projects/download_service_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Projects::DownloadService do
+describe Projects::DownloadService, services: true do
describe 'File service' do
before do
@user = create :user
diff --git a/spec/services/projects/fork_service_spec.rb b/spec/services/projects/fork_service_spec.rb
index 1feba6ce048..d1ee60a0aea 100644
--- a/spec/services/projects/fork_service_spec.rb
+++ b/spec/services/projects/fork_service_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Projects::ForkService do
+describe Projects::ForkService, services: true do
describe :fork_by_user do
before do
@from_namespace = create(:namespace)
diff --git a/spec/services/projects/transfer_service_spec.rb b/spec/services/projects/transfer_service_spec.rb
index 47755bfc990..c46259431aa 100644
--- a/spec/services/projects/transfer_service_spec.rb
+++ b/spec/services/projects/transfer_service_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Projects::TransferService do
+describe Projects::TransferService, services: true do
let(:user) { create(:user) }
let(:group) { create(:group) }
let(:project) { create(:project, namespace: user.namespace) }
diff --git a/spec/services/projects/update_service_spec.rb b/spec/services/projects/update_service_spec.rb
index b347fa15f87..c36d4581989 100644
--- a/spec/services/projects/update_service_spec.rb
+++ b/spec/services/projects/update_service_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Projects::UpdateService do
+describe Projects::UpdateService, services: true do
describe :update_by_user do
before do
@user = create :user
diff --git a/spec/services/projects/upload_service_spec.rb b/spec/services/projects/upload_service_spec.rb
index 1b1a80d1fe7..9268a9fb1a2 100644
--- a/spec/services/projects/upload_service_spec.rb
+++ b/spec/services/projects/upload_service_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Projects::UploadService do
+describe Projects::UploadService, services: true do
describe 'File service' do
before do
@user = create :user
diff --git a/spec/services/search_service_spec.rb b/spec/services/search_service_spec.rb
index f57bfaea879..7b3a9a75d7c 100644
--- a/spec/services/search_service_spec.rb
+++ b/spec/services/search_service_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe 'Search::GlobalService' do
+describe 'Search::GlobalService', services: true do
let(:user) { create(:user) }
let(:public_user) { create(:user) }
let(:internal_user) { create(:user) }
diff --git a/spec/services/system_hooks_service_spec.rb b/spec/services/system_hooks_service_spec.rb
index a31fc1e4b07..febc78d2784 100644
--- a/spec/services/system_hooks_service_spec.rb
+++ b/spec/services/system_hooks_service_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe SystemHooksService do
+describe SystemHooksService, services: true do
let(:user) { create :user }
let(:project) { create :project }
let(:project_member) { create :project_member }
diff --git a/spec/services/system_note_service_spec.rb b/spec/services/system_note_service_spec.rb
index a45130bd473..0a4f9b230e8 100644
--- a/spec/services/system_note_service_spec.rb
+++ b/spec/services/system_note_service_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe SystemNoteService do
+describe SystemNoteService, services: true do
let(:project) { create(:project) }
let(:author) { create(:user) }
let(:noteable) { create(:issue, project: project) }
@@ -207,6 +207,32 @@ describe SystemNoteService do
end
end
+ describe '.merge_when_build_succeeds' do
+ let(:ci_commit) { build :ci_commit_without_jobs }
+ let(:noteable) { create :merge_request }
+
+ subject { described_class.merge_when_build_succeeds(noteable, project, author, noteable.last_commit) }
+
+ it_behaves_like 'a system note'
+
+ it "posts the Merge When Build Succeeds system note" do
+ expect(subject.note).to match /Enabled an automatic merge when the build for (\w+\/\w+@)?[0-9a-f]{40} succeeds/
+ end
+ end
+
+ describe '.cancel_merge_when_build_succeeds' do
+ let(:ci_commit) { build :ci_commit_without_jobs }
+ let(:noteable) { create :merge_request }
+
+ subject { described_class.cancel_merge_when_build_succeeds(noteable, project, author) }
+
+ it_behaves_like 'a system note'
+
+ it "posts the Merge When Build Succeeds system note" do
+ expect(subject.note).to eq "Canceled the automatic merge"
+ end
+ end
+
describe '.change_title' do
subject { described_class.change_title(noteable, project, author, 'Old title') }
diff --git a/spec/services/test_hook_service_spec.rb b/spec/services/test_hook_service_spec.rb
index 226196eedae..f034f251ba4 100644
--- a/spec/services/test_hook_service_spec.rb
+++ b/spec/services/test_hook_service_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe TestHookService do
+describe TestHookService, services: true do
let(:user) { create :user }
let(:project) { create :project }
let(:hook) { create :project_hook, project: project }
diff --git a/spec/services/update_release_service_spec.rb b/spec/services/update_release_service_spec.rb
index 93368c45b88..bba211089a8 100644
--- a/spec/services/update_release_service_spec.rb
+++ b/spec/services/update_release_service_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe UpdateReleaseService do
+describe UpdateReleaseService, services: true do
let(:project) { create(:project) }
let(:user) { create(:user) }
let(:tag_name) { project.repository.tag_names.first }
diff --git a/spec/services/update_snippet_service_spec.rb b/spec/services/update_snippet_service_spec.rb
index d7c516e3934..124bb76e678 100644
--- a/spec/services/update_snippet_service_spec.rb
+++ b/spec/services/update_snippet_service_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe UpdateSnippetService do
+describe UpdateSnippetService, services: true do
before do
@user = create :user
@admin = create :user, admin: true