diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-07-31 11:50:10 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-07-31 11:50:10 +0300 |
commit | 8f1274ae0350590a8a0d8f16558d24a9514b78c1 (patch) | |
tree | 514a6628a0a45dac10608b408cf3f011c893431b /spec | |
parent | 79a7f7b6e59fa1225c440547796331caedabeaab (diff) | |
parent | 9a3b283402b8cc1c86802c526f19a459ce09c2e3 (diff) |
Merge commit '9a3b283402b8cc1c86802c526f19a459ce09c2e3' into backstage/gb/migrate-stages-statuses
* commit '9a3b283402b8cc1c86802c526f19a459ce09c2e3': (270 commits)
Add a note about EFS and GitLab log files
Projects logo are not centered vertically on projects page
Fix spec/features/projects/branches_spec
Fixup POST /v3/:id/hooks and PUT /v3/:id/hooks/:hook_id
Fix a spec that was assuming to be on the wrong page
Add copy about search terms to ux guide
Update documentation of user creation by replacing the 'confirm' param with 'skip_confirmation'
Fix replying to commit comments on MRs from forks
Fix 500 error when rendering avatar for deleted project creator
Load and process at most 100 commits when pushing into default branch
Ensure Gitlab::Application.routes.default_url_options are set correctly in Capybara + :js specs
Add log messages to clarify log messages about API CSRF token verification failure
Update gitlab_flow.md, Teatro seems to be completely dead, see also https://forum.gitlab.com/t/gitlab-flow-documentation-teatro/7774
Fix diff commenting results just after changing view
Update CHANGELOG.md for 9.4.2
none is not a CSS Value for sizes ;-)
Merge issuable "reopened" state into "opened"
Make access level more compatible with EE
Add link to JIRA article in docs
Expand pipeline_trigger_service_spec by godfat request
...
Diffstat (limited to 'spec')
934 files changed, 4408 insertions, 2129 deletions
diff --git a/spec/controllers/admin/applications_controller_spec.rb b/spec/controllers/admin/applications_controller_spec.rb index e311b8a63b2..7bd6c0e6117 100644 --- a/spec/controllers/admin/applications_controller_spec.rb +++ b/spec/controllers/admin/applications_controller_spec.rb @@ -28,13 +28,16 @@ describe Admin::ApplicationsController do describe 'POST #create' do it 'creates the application' do + create_params = attributes_for(:application, trusted: true) + expect do - post :create, doorkeeper_application: attributes_for(:application) + post :create, doorkeeper_application: create_params end.to change { Doorkeeper::Application.count }.by(1) application = Doorkeeper::Application.last expect(response).to redirect_to(admin_application_path(application)) + expect(application).to have_attributes(create_params.except(:uid, :owner_type)) end it 'renders the application form on errors' do @@ -49,10 +52,12 @@ describe Admin::ApplicationsController do describe 'PATCH #update' do it 'updates the application' do - patch :update, id: application.id, doorkeeper_application: { redirect_uri: 'http://example.com/' } + patch :update, id: application.id, doorkeeper_application: { redirect_uri: 'http://example.com/', trusted: true } + + application.reload expect(response).to redirect_to(admin_application_path(application)) - expect(application.reload.redirect_uri).to eq 'http://example.com/' + expect(application).to have_attributes(redirect_uri: 'http://example.com/', trusted: true) end it 'renders the application form on errors' do diff --git a/spec/controllers/oauth/authorizations_controller_spec.rb b/spec/controllers/oauth/authorizations_controller_spec.rb index d321bfcea9d..ac7f73c6e81 100644 --- a/spec/controllers/oauth/authorizations_controller_spec.rb +++ b/spec/controllers/oauth/authorizations_controller_spec.rb @@ -42,8 +42,8 @@ describe Oauth::AuthorizationsController do end it 'deletes session.user_return_to and redirects when skip authorization' do + doorkeeper.update(trusted: true) request.session['user_return_to'] = 'http://example.com' - allow(controller).to receive(:skip_authorization?).and_return(true) get :new, params diff --git a/spec/controllers/projects/notes_controller_spec.rb b/spec/controllers/projects/notes_controller_spec.rb index 45f4cf9180d..3b88d5b0d7d 100644 --- a/spec/controllers/projects/notes_controller_spec.rb +++ b/spec/controllers/projects/notes_controller_spec.rb @@ -131,7 +131,7 @@ describe Projects::NotesController do before do sign_in(user) - project.team << [user, :developer] + project.add_developer(user) end it "returns status 302 for html" do @@ -165,6 +165,66 @@ describe Projects::NotesController do expect(response).to have_http_status(302) end end + + context 'when creating a commit comment from an MR fork' do + let(:project) { create(:project) } + + let(:fork_project) do + create(:project).tap do |fork| + create(:forked_project_link, forked_to_project: fork, forked_from_project: project) + end + end + + let(:merge_request) do + create(:merge_request, source_project: fork_project, target_project: project, source_branch: 'feature', target_branch: 'master') + end + + let(:existing_comment) do + create(:note_on_commit, note: 'a note', project: fork_project, commit_id: merge_request.commit_shas.first) + end + + def post_create(extra_params = {}) + post :create, { + note: { note: 'some other note' }, + namespace_id: project.namespace, + project_id: project, + target_type: 'merge_request', + target_id: merge_request.id, + note_project_id: fork_project.id, + in_reply_to_discussion_id: existing_comment.discussion_id + }.merge(extra_params) + end + + context 'when the note_project_id is not correct' do + it 'returns a 404' do + post_create(note_project_id: Project.maximum(:id).succ) + + expect(response).to have_http_status(404) + end + end + + context 'when the user has no access to the fork' do + it 'returns a 404' do + post_create + + expect(response).to have_http_status(404) + end + end + + context 'when the user has access to the fork' do + let(:discussion) { fork_project.notes.find_discussion(existing_comment.discussion_id) } + + before do + fork_project.add_developer(user) + + existing_comment + end + + it 'creates the note' do + expect { post_create }.to change { fork_project.notes.count }.by(1) + end + end + end end describe 'DELETE destroy' do diff --git a/spec/controllers/sent_notifications_controller_spec.rb b/spec/controllers/sent_notifications_controller_spec.rb index c8771eda313..5d2734b8827 100644 --- a/spec/controllers/sent_notifications_controller_spec.rb +++ b/spec/controllers/sent_notifications_controller_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe SentNotificationsController, type: :controller do +describe SentNotificationsController do let(:user) { create(:user) } let(:project) { create(:empty_project) } let(:sent_notification) { create(:sent_notification, project: project, noteable: issue, recipient: user) } diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index 842d82cdbe9..7aeb6efd86d 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -80,9 +80,9 @@ describe UsersController do it 'renders calendar' do sign_in(user) - get :calendar, username: user.username + get :calendar, username: user.username, format: :json - expect(response).to render_template('calendar') + expect(response).to have_http_status(200) end context 'forked project' do diff --git a/spec/db/production/settings_spec.rb b/spec/db/production/settings_spec.rb index a9d015e0666..79e67330854 100644 --- a/spec/db/production/settings_spec.rb +++ b/spec/db/production/settings_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'rainbow/ext/string' -describe 'seed production settings', lib: true do +describe 'seed production settings' do include StubENV let(:settings_file) { Rails.root.join('db/fixtures/production/010_settings.rb') } let(:settings) { Gitlab::CurrentSettings.current_application_settings } diff --git a/spec/factories/ci/pipeline_variable_variables.rb b/spec/factories/ci/pipeline_variable_variables.rb new file mode 100644 index 00000000000..7c1a7faec08 --- /dev/null +++ b/spec/factories/ci/pipeline_variable_variables.rb @@ -0,0 +1,8 @@ +FactoryGirl.define do + factory :ci_pipeline_variable, class: Ci::PipelineVariable do + sequence(:key) { |n| "VARIABLE_#{n}" } + value 'VARIABLE_VALUE' + + pipeline factory: :ci_empty_pipeline + end +end diff --git a/spec/factories/gpg_keys.rb b/spec/factories/gpg_keys.rb new file mode 100644 index 00000000000..1258dce8940 --- /dev/null +++ b/spec/factories/gpg_keys.rb @@ -0,0 +1,8 @@ +require_relative '../support/gpg_helpers' + +FactoryGirl.define do + factory :gpg_key do + key GpgHelpers::User1.public_key + user + end +end diff --git a/spec/factories/gpg_signature.rb b/spec/factories/gpg_signature.rb new file mode 100644 index 00000000000..a5aeffbe12d --- /dev/null +++ b/spec/factories/gpg_signature.rb @@ -0,0 +1,11 @@ +require_relative '../support/gpg_helpers' + +FactoryGirl.define do + factory :gpg_signature do + commit_sha { Digest::SHA1.hexdigest(SecureRandom.hex) } + project + gpg_key + gpg_key_primary_keyid { gpg_key.primary_keyid } + valid_signature true + end +end diff --git a/spec/factories/issues.rb b/spec/factories/issues.rb index f1fd1fd7f73..a16695cb7c1 100644 --- a/spec/factories/issues.rb +++ b/spec/factories/issues.rb @@ -16,12 +16,8 @@ FactoryGirl.define do state :closed end - trait :reopened do - state :reopened - end - factory :closed_issue, traits: [:closed] - factory :reopened_issue, traits: [:reopened] + factory :reopened_issue, traits: [:opened] factory :labeled_issue do transient do diff --git a/spec/factories/merge_requests.rb b/spec/factories/merge_requests.rb index 253a025af48..1bc530d06db 100644 --- a/spec/factories/merge_requests.rb +++ b/spec/factories/merge_requests.rb @@ -44,10 +44,6 @@ FactoryGirl.define do state :opened end - trait :reopened do - state :reopened - end - trait :locked do state :locked end @@ -74,7 +70,7 @@ FactoryGirl.define do factory :merged_merge_request, traits: [:merged] factory :closed_merge_request, traits: [:closed] - factory :reopened_merge_request, traits: [:reopened] + factory :reopened_merge_request, traits: [:opened] factory :merge_request_with_diffs, traits: [:with_diffs] factory :merge_request_with_diff_notes do after(:create) do |mr| diff --git a/spec/factories/projects.rb b/spec/factories/projects.rb index 1bb2db11e7f..485ed48d2de 100644 --- a/spec/factories/projects.rb +++ b/spec/factories/projects.rb @@ -171,10 +171,6 @@ FactoryGirl.define do end after :create do |project, evaluator| - TestEnv.copy_repo(project, - bare_repo: TestEnv.factory_repo_path_bare, - refs: TestEnv::BRANCH_SHA) - if evaluator.create_template args = evaluator.create_template diff --git a/spec/factories/protected_branches.rb b/spec/factories/protected_branches.rb index b2695e0482a..3dbace4b38a 100644 --- a/spec/factories/protected_branches.rb +++ b/spec/factories/protected_branches.rb @@ -3,26 +3,58 @@ FactoryGirl.define do name project - after(:build) do |protected_branch| - protected_branch.push_access_levels.new(access_level: Gitlab::Access::MASTER) - protected_branch.merge_access_levels.new(access_level: Gitlab::Access::MASTER) + transient do + default_push_level true + default_merge_level true + default_access_level true end trait :developers_can_push do - after(:create) do |protected_branch| - protected_branch.push_access_levels.first.update!(access_level: Gitlab::Access::DEVELOPER) + transient do + default_push_level false + end + + after(:build) do |protected_branch| + protected_branch.push_access_levels.new(access_level: Gitlab::Access::DEVELOPER) end end trait :developers_can_merge do - after(:create) do |protected_branch| - protected_branch.merge_access_levels.first.update!(access_level: Gitlab::Access::DEVELOPER) + transient do + default_merge_level false + end + + after(:build) do |protected_branch| + protected_branch.merge_access_levels.new(access_level: Gitlab::Access::DEVELOPER) end end trait :no_one_can_push do - after(:create) do |protected_branch| - protected_branch.push_access_levels.first.update!(access_level: Gitlab::Access::NO_ACCESS) + transient do + default_push_level false + end + + after(:build) do |protected_branch| + protected_branch.push_access_levels.new(access_level: Gitlab::Access::NO_ACCESS) + end + end + + trait :masters_can_push do + transient do + default_push_level false + end + + after(:build) do |protected_branch| + protected_branch.push_access_levels.new(access_level: Gitlab::Access::MASTER) + end + end + + after(:build) do |protected_branch, evaluator| + if evaluator.default_access_level && evaluator.default_push_level + protected_branch.push_access_levels.new(access_level: Gitlab::Access::MASTER) + end + if evaluator.default_access_level && evaluator.default_merge_level + protected_branch.merge_access_levels.new(access_level: Gitlab::Access::MASTER) end end end diff --git a/spec/factories/protected_tags.rb b/spec/factories/protected_tags.rb index d8e90ae1ee1..225588b23cc 100644 --- a/spec/factories/protected_tags.rb +++ b/spec/factories/protected_tags.rb @@ -3,19 +3,43 @@ FactoryGirl.define do name project - after(:build) do |protected_tag| - protected_tag.create_access_levels.new(access_level: Gitlab::Access::MASTER) + transient do + default_access_level true end trait :developers_can_create do - after(:create) do |protected_tag| - protected_tag.create_access_levels.first.update!(access_level: Gitlab::Access::DEVELOPER) + transient do + default_access_level false + end + + after(:build) do |protected_tag| + protected_tag.create_access_levels.new(access_level: Gitlab::Access::DEVELOPER) end end trait :no_one_can_create do - after(:create) do |protected_tag| - protected_tag.create_access_levels.first.update!(access_level: Gitlab::Access::NO_ACCESS) + transient do + default_access_level false + end + + after(:build) do |protected_tag| + protected_tag.create_access_levels.new(access_level: Gitlab::Access::NO_ACCESS) + end + end + + trait :masters_can_create do + transient do + default_access_level false + end + + after(:build) do |protected_tag| + protected_tag.create_access_levels.new(access_level: Gitlab::Access::MASTER) + end + end + + after(:build) do |protected_tag, evaluator| + if evaluator.default_access_level + protected_tag.create_access_levels.new(access_level: Gitlab::Access::MASTER) end end end diff --git a/spec/features/abuse_report_spec.rb b/spec/features/abuse_report_spec.rb index f26d3a6a72f..091fdcec3db 100644 --- a/spec/features/abuse_report_spec.rb +++ b/spec/features/abuse_report_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Abuse reports', feature: true do +feature 'Abuse reports' do let(:another_user) { create(:user) } before do diff --git a/spec/features/admin/admin_abuse_reports_spec.rb b/spec/features/admin/admin_abuse_reports_spec.rb index 8672c009f90..2144f6ba635 100644 --- a/spec/features/admin/admin_abuse_reports_spec.rb +++ b/spec/features/admin/admin_abuse_reports_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe "Admin::AbuseReports", feature: true, js: true do +describe "Admin::AbuseReports", js: true do let(:user) { create(:user) } context 'as an admin' do diff --git a/spec/features/admin/admin_appearance_spec.rb b/spec/features/admin/admin_appearance_spec.rb index 2f90f668e89..5f3a37c1dcc 100644 --- a/spec/features/admin/admin_appearance_spec.rb +++ b/spec/features/admin/admin_appearance_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Admin Appearance', feature: true do +feature 'Admin Appearance' do let!(:appearance) { create(:appearance) } scenario 'Create new appearance' do diff --git a/spec/features/admin/admin_broadcast_messages_spec.rb b/spec/features/admin/admin_broadcast_messages_spec.rb index e55308e393b..cbccf370514 100644 --- a/spec/features/admin/admin_broadcast_messages_spec.rb +++ b/spec/features/admin/admin_broadcast_messages_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Admin Broadcast Messages', feature: true do +feature 'Admin Broadcast Messages' do before do sign_in(create(:admin)) create(:broadcast_message, :expired, message: 'Migration to new server') diff --git a/spec/features/admin/admin_cohorts_spec.rb b/spec/features/admin/admin_cohorts_spec.rb index 6840456e509..bca52bf674c 100644 --- a/spec/features/admin/admin_cohorts_spec.rb +++ b/spec/features/admin/admin_cohorts_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature 'Admin cohorts page', feature: true do +feature 'Admin cohorts page' do before do sign_in(create(:admin)) end diff --git a/spec/features/admin/admin_deploy_keys_spec.rb b/spec/features/admin/admin_deploy_keys_spec.rb index aaeaaa829e1..241c7cbc34e 100644 --- a/spec/features/admin/admin_deploy_keys_spec.rb +++ b/spec/features/admin/admin_deploy_keys_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -RSpec.describe 'admin deploy keys', type: :feature do +RSpec.describe 'admin deploy keys' do let!(:deploy_key) { create(:deploy_key, public: true) } let!(:another_deploy_key) { create(:another_deploy_key, public: true) } diff --git a/spec/features/admin/admin_disables_git_access_protocol_spec.rb b/spec/features/admin/admin_disables_git_access_protocol_spec.rb index e2280b6e3b1..931f4ec3d24 100644 --- a/spec/features/admin/admin_disables_git_access_protocol_spec.rb +++ b/spec/features/admin/admin_disables_git_access_protocol_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature 'Admin disables Git access protocol', feature: true do +feature 'Admin disables Git access protocol' do include StubENV let(:project) { create(:empty_project, :empty_repo) } diff --git a/spec/features/admin/admin_disables_two_factor_spec.rb b/spec/features/admin/admin_disables_two_factor_spec.rb index 15dc6b6c234..e214ae6b78d 100644 --- a/spec/features/admin/admin_disables_two_factor_spec.rb +++ b/spec/features/admin/admin_disables_two_factor_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature 'Admin disables 2FA for a user', feature: true do +feature 'Admin disables 2FA for a user' do scenario 'successfully', js: true do sign_in(create(:admin)) user = create(:user, :two_factor) diff --git a/spec/features/admin/admin_groups_spec.rb b/spec/features/admin/admin_groups_spec.rb index d15d9982884..2e1bfcdcec3 100644 --- a/spec/features/admin/admin_groups_spec.rb +++ b/spec/features/admin/admin_groups_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Admin Groups', feature: true do +feature 'Admin Groups' do include Select2Helper let(:internal) { Gitlab::VisibilityLevel::INTERNAL } diff --git a/spec/features/admin/admin_health_check_spec.rb b/spec/features/admin/admin_health_check_spec.rb index c404e054dba..106e7370a98 100644 --- a/spec/features/admin/admin_health_check_spec.rb +++ b/spec/features/admin/admin_health_check_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature "Admin Health Check", feature: true do +feature "Admin Health Check" do include StubENV before do diff --git a/spec/features/admin/admin_hook_logs_spec.rb b/spec/features/admin/admin_hook_logs_spec.rb index 94dace7a1fd..7910d5fb72b 100644 --- a/spec/features/admin/admin_hook_logs_spec.rb +++ b/spec/features/admin/admin_hook_logs_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' -feature 'Admin::HookLogs', feature: true do - let(:project) { create(:project) } +feature 'Admin::HookLogs' do + let(:project) { create(:empty_project) } let(:system_hook) { create(:system_hook) } let(:hook_log) { create(:web_hook_log, web_hook: system_hook, internal_error_message: 'some error') } diff --git a/spec/features/admin/admin_hooks_spec.rb b/spec/features/admin/admin_hooks_spec.rb index 9a438b65e68..141109fd464 100644 --- a/spec/features/admin/admin_hooks_spec.rb +++ b/spec/features/admin/admin_hooks_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' -describe 'Admin::Hooks', feature: true do +describe 'Admin::Hooks' do before do - @project = create(:project) + @project = create(:empty_project) sign_in(create(:admin)) @system_hook = create(:system_hook) diff --git a/spec/features/admin/admin_manage_applications_spec.rb b/spec/features/admin/admin_manage_applications_spec.rb index 2e04a82806f..f979d2f6090 100644 --- a/spec/features/admin/admin_manage_applications_spec.rb +++ b/spec/features/admin/admin_manage_applications_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -RSpec.describe 'admin manage applications', feature: true do +RSpec.describe 'admin manage applications' do before do sign_in(create(:admin)) end @@ -13,19 +13,24 @@ RSpec.describe 'admin manage applications', feature: true do fill_in :doorkeeper_application_name, with: 'test' fill_in :doorkeeper_application_redirect_uri, with: 'https://test.com' + check :doorkeeper_application_trusted click_on 'Submit' expect(page).to have_content('Application: test') expect(page).to have_content('Application Id') expect(page).to have_content('Secret') + expect(page).to have_content('Trusted Y') click_on 'Edit' expect(page).to have_content('Edit application') fill_in :doorkeeper_application_name, with: 'test_changed' + uncheck :doorkeeper_application_trusted + click_on 'Submit' expect(page).to have_content('test_changed') expect(page).to have_content('Application Id') expect(page).to have_content('Secret') + expect(page).to have_content('Trusted N') visit admin_applications_path page.within '.oauth-applications' do diff --git a/spec/features/admin/admin_projects_spec.rb b/spec/features/admin/admin_projects_spec.rb index 942cc60e5dd..4f69eafcb9d 100644 --- a/spec/features/admin/admin_projects_spec.rb +++ b/spec/features/admin/admin_projects_spec.rb @@ -1,20 +1,21 @@ require 'spec_helper' -describe "Admin::Projects", feature: true do +describe "Admin::Projects" do include Select2Helper let(:user) { create :user } - let!(:project) { create(:project) } - let!(:current_user) { create(:admin) } + let(:project) { create(:empty_project) } + let(:current_user) { create(:admin) } before do sign_in(current_user) end describe "GET /admin/projects" do - let!(:archived_project) { create :project, :public, :archived } + let!(:archived_project) { create :empty_project, :public, :archived } before do + expect(project).to be_persisted visit admin_projects_path end @@ -39,15 +40,14 @@ describe "Admin::Projects", feature: true do describe "GET /admin/projects/:namespace_id/:id" do before do - visit admin_projects_path - click_link "#{project.name}" - end + expect(project).to be_persisted - it do - expect(current_path).to eq admin_project_path(project) + visit admin_projects_path + click_link project.name end it "has project info" do + expect(current_path).to eq admin_project_path(project) expect(page).to have_content(project.path) expect(page).to have_content(project.name) expect(page).to have_content(project.name_with_namespace) @@ -56,6 +56,9 @@ describe "Admin::Projects", feature: true do end describe 'transfer project' do + # The gitlab-shell transfer will fail for a project without a repository + let(:project) { create(:project, :repository) } + before do create(:group, name: 'Web') diff --git a/spec/features/admin/admin_requests_profiles_spec.rb b/spec/features/admin/admin_requests_profiles_spec.rb index bf0c21cd04a..380cd5d7703 100644 --- a/spec/features/admin/admin_requests_profiles_spec.rb +++ b/spec/features/admin/admin_requests_profiles_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'Admin::RequestsProfilesController', feature: true do +describe 'Admin::RequestsProfilesController' do before do FileUtils.mkdir_p(Gitlab::RequestProfiler::PROFILES_DIR) sign_in(create(:admin)) diff --git a/spec/features/admin/admin_settings_spec.rb b/spec/features/admin/admin_settings_spec.rb index a44fa0b86d5..c1eced417cf 100644 --- a/spec/features/admin/admin_settings_spec.rb +++ b/spec/features/admin/admin_settings_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Admin updates settings', feature: true do +feature 'Admin updates settings' do include StubENV before do diff --git a/spec/features/admin/admin_users_impersonation_tokens_spec.rb b/spec/features/admin/admin_users_impersonation_tokens_spec.rb index d01722805c4..97ffc54415c 100644 --- a/spec/features/admin/admin_users_impersonation_tokens_spec.rb +++ b/spec/features/admin/admin_users_impersonation_tokens_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'Admin > Users > Impersonation Tokens', feature: true, js: true do +describe 'Admin > Users > Impersonation Tokens', js: true do let(:admin) { create(:admin) } let!(:user) { create(:user) } diff --git a/spec/features/admin/admin_users_spec.rb b/spec/features/admin/admin_users_spec.rb index 3bc8f8aed54..0dde8bb696c 100644 --- a/spec/features/admin/admin_users_spec.rb +++ b/spec/features/admin/admin_users_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe "Admin::Users", feature: true do +describe "Admin::Users" do let!(:user) do create(:omniauth_user, provider: 'twitter', extern_uid: '123456') end @@ -257,7 +257,7 @@ describe "Admin::Users", feature: true do describe "GET /admin/users/:id/projects" do let(:group) { create(:group) } - let!(:project) { create(:project, group: group) } + let!(:project) { create(:empty_project, group: group) } before do group.add_developer(user) diff --git a/spec/features/admin/admin_uses_repository_checks_spec.rb b/spec/features/admin/admin_uses_repository_checks_spec.rb index 113353862be..5b3ee6ee822 100644 --- a/spec/features/admin/admin_uses_repository_checks_spec.rb +++ b/spec/features/admin/admin_uses_repository_checks_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature 'Admin uses repository checks', feature: true do +feature 'Admin uses repository checks' do include StubENV before do diff --git a/spec/features/atom/dashboard_issues_spec.rb b/spec/features/atom/dashboard_issues_spec.rb index 711c8a710f3..d70da7f09e9 100644 --- a/spec/features/atom/dashboard_issues_spec.rb +++ b/spec/features/atom/dashboard_issues_spec.rb @@ -1,11 +1,11 @@ require 'spec_helper' -describe "Dashboard Issues Feed", feature: true do +describe "Dashboard Issues Feed" do describe "GET /issues" do let!(:user) { create(:user, email: 'private1@example.com', public_email: 'public1@example.com') } let!(:assignee) { create(:user, email: 'private2@example.com', public_email: 'public2@example.com') } - let!(:project1) { create(:project) } - let!(:project2) { create(:project) } + let!(:project1) { create(:empty_project) } + let!(:project2) { create(:empty_project) } before do project1.team << [user, :master] diff --git a/spec/features/atom/dashboard_spec.rb b/spec/features/atom/dashboard_spec.rb index 2f4bb45d74b..a7c12853981 100644 --- a/spec/features/atom/dashboard_spec.rb +++ b/spec/features/atom/dashboard_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe "Dashboard Feed", feature: true do +describe "Dashboard Feed" do describe "GET /" do let!(:user) { create(:user, name: "Jonh") } @@ -19,7 +19,7 @@ describe "Dashboard Feed", feature: true do end context 'feed content' do - let(:project) { create(:project) } + let(:project) { create(:empty_project) } let(:issue) { create(:issue, project: project, author: user, description: '') } let(:note) { create(:note, noteable: issue, author: user, note: 'Bug confirmed', project: project) } diff --git a/spec/features/atom/issues_spec.rb b/spec/features/atom/issues_spec.rb index 011fdce21d8..59e20d7e24d 100644 --- a/spec/features/atom/issues_spec.rb +++ b/spec/features/atom/issues_spec.rb @@ -1,11 +1,11 @@ require 'spec_helper' -describe 'Issues Feed', feature: true do +describe 'Issues Feed' do describe 'GET /issues' do let!(:user) { create(:user, email: 'private1@example.com', public_email: 'public1@example.com') } let!(:assignee) { create(:user, email: 'private2@example.com', public_email: 'public2@example.com') } let!(:group) { create(:group) } - let!(:project) { create(:project) } + let!(:project) { create(:empty_project) } let!(:issue) { create(:issue, author: user, assignees: [assignee], project: project) } before do diff --git a/spec/features/atom/users_spec.rb b/spec/features/atom/users_spec.rb index 44ae7204bcf..79069bbca8e 100644 --- a/spec/features/atom/users_spec.rb +++ b/spec/features/atom/users_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe "User Feed", feature: true do +describe "User Feed" do describe "GET /" do let!(:user) { create(:user) } @@ -19,7 +19,7 @@ describe "User Feed", feature: true do end context 'feed content' do - let(:project) { create(:project) } + let(:project) { create(:project, :repository) } let(:issue) do create(:issue, project: project, diff --git a/spec/features/boards/add_issues_modal_spec.rb b/spec/features/boards/add_issues_modal_spec.rb index d883b467c67..c87469696da 100644 --- a/spec/features/boards/add_issues_modal_spec.rb +++ b/spec/features/boards/add_issues_modal_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'Issue Boards add issue modal', :feature, :js do +describe 'Issue Boards add issue modal', :js do let(:project) { create(:empty_project, :public) } let(:board) { create(:board, project: project) } let(:user) { create(:user) } diff --git a/spec/features/boards/boards_spec.rb b/spec/features/boards/boards_spec.rb index b939fb5e89e..c3711c9b2c5 100644 --- a/spec/features/boards/boards_spec.rb +++ b/spec/features/boards/boards_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'Issue Boards', feature: true, js: true do +describe 'Issue Boards', js: true do include DragTo let(:group) { create(:group, :nested) } diff --git a/spec/features/boards/issue_ordering_spec.rb b/spec/features/boards/issue_ordering_spec.rb index 17b0da80947..f4be56a4463 100644 --- a/spec/features/boards/issue_ordering_spec.rb +++ b/spec/features/boards/issue_ordering_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'Issue Boards', :feature, :js do +describe 'Issue Boards', :js do include DragTo let(:project) { create(:empty_project, :public) } diff --git a/spec/features/boards/keyboard_shortcut_spec.rb b/spec/features/boards/keyboard_shortcut_spec.rb index 8c16148023e..415eda0e058 100644 --- a/spec/features/boards/keyboard_shortcut_spec.rb +++ b/spec/features/boards/keyboard_shortcut_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'Issue Boards shortcut', feature: true, js: true do +describe 'Issue Boards shortcut', js: true do let(:project) { create(:empty_project) } before do diff --git a/spec/features/boards/modal_filter_spec.rb b/spec/features/boards/modal_filter_spec.rb index ce05bb71759..1c8b9c46569 100644 --- a/spec/features/boards/modal_filter_spec.rb +++ b/spec/features/boards/modal_filter_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'Issue Boards add issue modal filtering', :feature, :js do +describe 'Issue Boards add issue modal filtering', :js do let(:project) { create(:empty_project, :public) } let(:board) { create(:board, project: project) } let(:planning) { create(:label, project: project, name: 'Planning') } diff --git a/spec/features/boards/new_issue_spec.rb b/spec/features/boards/new_issue_spec.rb index 6b267694201..1dbe3dbda11 100644 --- a/spec/features/boards/new_issue_spec.rb +++ b/spec/features/boards/new_issue_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'Issue Boards new issue', feature: true, js: true do +describe 'Issue Boards new issue', js: true do let(:project) { create(:empty_project, :public) } let(:board) { create(:board, project: project) } let!(:list) { create(:list, board: board, position: 0) } diff --git a/spec/features/boards/sidebar_spec.rb b/spec/features/boards/sidebar_spec.rb index fa17ef92bbb..3f58fe1c32c 100644 --- a/spec/features/boards/sidebar_spec.rb +++ b/spec/features/boards/sidebar_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'Issue Boards', feature: true, js: true do +describe 'Issue Boards', js: true do let(:user) { create(:user) } let(:user2) { create(:user) } let(:project) { create(:empty_project, :public) } diff --git a/spec/features/boards/sub_group_project_spec.rb b/spec/features/boards/sub_group_project_spec.rb index f88bf237301..f54f2234203 100644 --- a/spec/features/boards/sub_group_project_spec.rb +++ b/spec/features/boards/sub_group_project_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'Sub-group project issue boards', :feature, :js do +describe 'Sub-group project issue boards', :js do let(:group) { create(:group) } let(:nested_group_1) { create(:group, parent: group) } let(:project) { create(:empty_project, group: nested_group_1) } diff --git a/spec/features/calendar_spec.rb b/spec/features/calendar_spec.rb index adbd82e3057..1e7fd7b62bd 100644 --- a/spec/features/calendar_spec.rb +++ b/spec/features/calendar_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Contributions Calendar', :feature, :js do +feature 'Contributions Calendar', :js do let(:user) { create(:user) } let(:contributed_project) { create(:empty_project, :public) } let(:issue_note) { create(:note, project: contributed_project) } diff --git a/spec/features/commits_spec.rb b/spec/features/commits_spec.rb index fb1e47994ef..15ec6f20763 100644 --- a/spec/features/commits_spec.rb +++ b/spec/features/commits_spec.rb @@ -77,7 +77,7 @@ describe 'Commits' do end end - describe 'Commit builds', :feature, :js do + describe 'Commit builds', :js do before do visit ci_status_path(pipeline) end @@ -152,7 +152,7 @@ describe 'Commits' do visit ci_status_path(pipeline) end - it 'Renders header', :feature, :js do + it 'Renders header', :js do expect(page).to have_content pipeline.sha[0..7] expect(page).to have_content pipeline.git_commit_message expect(page).to have_content pipeline.user.name @@ -165,7 +165,7 @@ describe 'Commits' do end end - context 'when accessing internal project with disallowed access', :feature, :js do + context 'when accessing internal project with disallowed access', :js do before do project.update( visibility_level: Gitlab::VisibilityLevel::INTERNAL, @@ -203,4 +203,105 @@ describe 'Commits' do end end end + + describe 'GPG signed commits', :js do + it 'changes from unverified to verified when the user changes his email to match the gpg key' do + user = create :user, email: 'unrelated.user@example.org' + project.team << [user, :master] + + Sidekiq::Testing.inline! do + create :gpg_key, key: GpgHelpers::User1.public_key, user: user + end + + sign_in(user) + + visit project_commits_path(project, :'signed-commits') + + within '#commits-list' do + expect(page).to have_content 'Unverified' + expect(page).not_to have_content 'Verified' + end + + # user changes his email which makes the gpg key verified + Sidekiq::Testing.inline! do + user.skip_reconfirmation! + user.update_attributes!(email: GpgHelpers::User1.emails.first) + end + + visit project_commits_path(project, :'signed-commits') + + within '#commits-list' do + expect(page).to have_content 'Unverified' + expect(page).to have_content 'Verified' + end + end + + it 'changes from unverified to verified when the user adds the missing gpg key' do + user = create :user, email: GpgHelpers::User1.emails.first + project.team << [user, :master] + + sign_in(user) + + visit project_commits_path(project, :'signed-commits') + + within '#commits-list' do + expect(page).to have_content 'Unverified' + expect(page).not_to have_content 'Verified' + end + + # user adds the gpg key which makes the signature valid + Sidekiq::Testing.inline! do + create :gpg_key, key: GpgHelpers::User1.public_key, user: user + end + + visit project_commits_path(project, :'signed-commits') + + within '#commits-list' do + expect(page).to have_content 'Unverified' + expect(page).to have_content 'Verified' + end + end + + it 'shows popover badges' do + gpg_user = create :user, email: GpgHelpers::User1.emails.first, username: 'nannie.bernhard', name: 'Nannie Bernhard' + Sidekiq::Testing.inline! do + create :gpg_key, key: GpgHelpers::User1.public_key, user: gpg_user + end + + user = create :user + project.team << [user, :master] + + sign_in(user) + visit project_commits_path(project, :'signed-commits') + + # unverified signature + click_on 'Unverified', match: :first + within '.popover' do + expect(page).to have_content 'This commit was signed with an unverified signature.' + expect(page).to have_content "GPG Key ID: #{GpgHelpers::User2.primary_keyid}" + end + + # verified and the gpg user has a gitlab profile + click_on 'Verified' + within '.popover' do + expect(page).to have_content 'This commit was signed with a verified signature.' + expect(page).to have_content 'Nannie Bernhard' + expect(page).to have_content '@nannie.bernhard' + expect(page).to have_content "GPG Key ID: #{GpgHelpers::User1.primary_keyid}" + end + + # verified and the gpg user's profile doesn't exist anymore + gpg_user.destroy! + + visit project_commits_path(project, :'signed-commits') + + click_on 'Verified' + within '.popover' do + expect(page).to have_content 'This commit was signed with a verified signature.' + expect(page).to have_content 'Nannie Bernhard' + expect(page).to have_content 'nannie.bernhard@example.com' + expect(page).to have_content "GPG Key ID: #{GpgHelpers::User1.primary_keyid}" + end + end + end end diff --git a/spec/features/copy_as_gfm_spec.rb b/spec/features/copy_as_gfm_spec.rb index 11d5a4f421f..3e6a27eafd8 100644 --- a/spec/features/copy_as_gfm_spec.rb +++ b/spec/features/copy_as_gfm_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'Copy as GFM', feature: true, js: true do +describe 'Copy as GFM', js: true do include MarkupHelper include RepoHelpers include ActionView::Helpers::JavaScriptHelper diff --git a/spec/features/cycle_analytics_spec.rb b/spec/features/cycle_analytics_spec.rb index f530063352a..5c60cca10b9 100644 --- a/spec/features/cycle_analytics_spec.rb +++ b/spec/features/cycle_analytics_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Cycle Analytics', feature: true, js: true do +feature 'Cycle Analytics', js: true do let(:user) { create(:user) } let(:guest) { create(:user) } let(:project) { create(:project, :repository) } diff --git a/spec/features/dashboard/active_tab_spec.rb b/spec/features/dashboard/active_tab_spec.rb index 203d206b80b..067e4337e6a 100644 --- a/spec/features/dashboard/active_tab_spec.rb +++ b/spec/features/dashboard/active_tab_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -RSpec.describe 'Dashboard Active Tab', js: true, feature: true do +RSpec.describe 'Dashboard Active Tab', js: true do before do sign_in(create(:user)) end diff --git a/spec/features/dashboard/archived_projects_spec.rb b/spec/features/dashboard/archived_projects_spec.rb index dda4d517e39..ceac6a0a27c 100644 --- a/spec/features/dashboard/archived_projects_spec.rb +++ b/spec/features/dashboard/archived_projects_spec.rb @@ -1,9 +1,9 @@ require 'spec_helper' -RSpec.describe 'Dashboard Archived Project', feature: true do +RSpec.describe 'Dashboard Archived Project' do let(:user) { create :user } let(:project) { create :project} - let(:archived_project) { create(:project, :archived) } + let(:archived_project) { create(:empty_project, :archived) } before do project.team << [user, :master] diff --git a/spec/features/dashboard/datetime_on_tooltips_spec.rb b/spec/features/dashboard/datetime_on_tooltips_spec.rb index 8949267c82e..05dcdd93f37 100644 --- a/spec/features/dashboard/datetime_on_tooltips_spec.rb +++ b/spec/features/dashboard/datetime_on_tooltips_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' -feature 'Tooltips on .timeago dates', feature: true, js: true do +feature 'Tooltips on .timeago dates', js: true do let(:user) { create(:user) } - let(:project) { create(:project, name: 'test', namespace: user.namespace) } + let(:project) { create(:empty_project, name: 'test', namespace: user.namespace) } let(:created_date) { Date.yesterday.to_time } let(:expected_format) { created_date.in_time_zone.strftime('%b %-d, %Y %l:%M%P') } diff --git a/spec/features/dashboard/group_spec.rb b/spec/features/dashboard/group_spec.rb index ffaefb9c632..60a16830cdc 100644 --- a/spec/features/dashboard/group_spec.rb +++ b/spec/features/dashboard/group_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -RSpec.describe 'Dashboard Group', feature: true do +RSpec.describe 'Dashboard Group' do before do sign_in(create(:user)) end diff --git a/spec/features/dashboard/help_spec.rb b/spec/features/dashboard/help_spec.rb index fa7ea4c96b6..68bfbf22736 100644 --- a/spec/features/dashboard/help_spec.rb +++ b/spec/features/dashboard/help_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -RSpec.describe 'Dashboard Help', feature: true do +RSpec.describe 'Dashboard Help' do before do sign_in(create(:user)) end diff --git a/spec/features/dashboard/issuables_counter_spec.rb b/spec/features/dashboard/issuables_counter_spec.rb index 6b666934563..ae68b0f65d5 100644 --- a/spec/features/dashboard/issuables_counter_spec.rb +++ b/spec/features/dashboard/issuables_counter_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'Navigation bar counter', :use_clean_rails_memory_store_caching, feature: true do +describe 'Navigation bar counter', :use_clean_rails_memory_store_caching do let(:user) { create(:user) } let(:project) { create(:empty_project, namespace: user.namespace) } let(:issue) { create(:issue, project: project) } diff --git a/spec/features/dashboard/issues_filter_spec.rb b/spec/features/dashboard/issues_filter_spec.rb index 9b84f67b555..0ce642f32f2 100644 --- a/spec/features/dashboard/issues_filter_spec.rb +++ b/spec/features/dashboard/issues_filter_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Dashboard Issues filtering', js: true do +feature 'Dashboard Issues filtering', :js do include SortingHelper let(:user) { create(:user) } diff --git a/spec/features/dashboard/issues_spec.rb b/spec/features/dashboard/issues_spec.rb index 2a5ef08da60..82adde6258f 100644 --- a/spec/features/dashboard/issues_spec.rb +++ b/spec/features/dashboard/issues_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -RSpec.describe 'Dashboard Issues', feature: true do +RSpec.describe 'Dashboard Issues' do let(:current_user) { create :user } let(:user) { current_user } # Shared examples depend on this being available let!(:public_project) { create(:empty_project, :public) } @@ -79,13 +79,7 @@ RSpec.describe 'Dashboard Issues', feature: true do end end - it 'shows the new issue page', js: true do - Gitlab::Application.routes.default_url_options = { - host: Capybara.current_session.server.host, - port: Capybara.current_session.server.port, - protocol: 'http' - } - + it 'shows the new issue page', :js do find('.new-project-item-select-button').trigger('click') wait_for_requests find('.select2-results li').click diff --git a/spec/features/dashboard/label_filter_spec.rb b/spec/features/dashboard/label_filter_spec.rb index 8b7dacef913..8e19fb93665 100644 --- a/spec/features/dashboard/label_filter_spec.rb +++ b/spec/features/dashboard/label_filter_spec.rb @@ -1,9 +1,9 @@ require 'spec_helper' -describe 'Dashboard > label filter', feature: true, js: true do +describe 'Dashboard > label filter', js: true do let(:user) { create(:user) } - let(:project) { create(:project, name: 'test', namespace: user.namespace) } - let(:project2) { create(:project, name: 'test2', path: 'test2', namespace: user.namespace) } + let(:project) { create(:empty_project, name: 'test', namespace: user.namespace) } + let(:project2) { create(:empty_project, name: 'test2', path: 'test2', namespace: user.namespace) } let(:label) { create(:label, title: 'bug', color: '#ff0000') } let(:label2) { create(:label, title: 'bug') } diff --git a/spec/features/dashboard/milestone_filter_spec.rb b/spec/features/dashboard/milestone_filter_spec.rb index d06497041de..5ebef1eb097 100644 --- a/spec/features/dashboard/milestone_filter_spec.rb +++ b/spec/features/dashboard/milestone_filter_spec.rb @@ -1,10 +1,10 @@ require 'spec_helper' -feature 'Dashboard > milestone filter', :feature, :js do +feature 'Dashboard > milestone filter', :js do include FilterItemSelectHelper let(:user) { create(:user) } - let(:project) { create(:project, name: 'test', namespace: user.namespace) } + let(:project) { create(:empty_project, name: 'test', namespace: user.namespace) } let(:milestone) { create(:milestone, title: 'v1.0', project: project) } let(:milestone2) { create(:milestone, title: 'v2.0', project: project) } let!(:issue) { create :issue, author: user, project: project, milestone: milestone } diff --git a/spec/features/dashboard/milestone_tabs_spec.rb b/spec/features/dashboard/milestone_tabs_spec.rb index 8340a4f59df..cf32d705365 100644 --- a/spec/features/dashboard/milestone_tabs_spec.rb +++ b/spec/features/dashboard/milestone_tabs_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'Dashboard milestone tabs', :js, :feature do +describe 'Dashboard milestone tabs', :js do let(:user) { create(:user) } let(:project) { create(:empty_project) } let!(:label) { create(:label, project: project) } diff --git a/spec/features/dashboard/milestones_spec.rb b/spec/features/dashboard/milestones_spec.rb index 7a6a448d4c2..488f7397c69 100644 --- a/spec/features/dashboard/milestones_spec.rb +++ b/spec/features/dashboard/milestones_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Dashboard > Milestones', feature: true do +feature 'Dashboard > Milestones' do describe 'as anonymous user' do before do visit dashboard_milestones_path diff --git a/spec/features/dashboard/project_member_activity_index_spec.rb b/spec/features/dashboard/project_member_activity_index_spec.rb index ea0b2e99c3e..f3b538e490e 100644 --- a/spec/features/dashboard/project_member_activity_index_spec.rb +++ b/spec/features/dashboard/project_member_activity_index_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Project member activity', feature: true, js: true do +feature 'Project member activity', js: true do let(:user) { create(:user) } let(:project) { create(:empty_project, :public, name: 'x', namespace: user.namespace) } diff --git a/spec/features/dashboard/shortcuts_spec.rb b/spec/features/dashboard/shortcuts_spec.rb index bb29dae1bdc..5f1f0c10339 100644 --- a/spec/features/dashboard/shortcuts_spec.rb +++ b/spec/features/dashboard/shortcuts_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Dashboard shortcuts', :feature, :js do +feature 'Dashboard shortcuts', :js do context 'logged in' do before do sign_in(create(:user)) diff --git a/spec/features/dashboard/snippets_spec.rb b/spec/features/dashboard/snippets_spec.rb index c5ae9aad9c6..c29bcc7c9e9 100644 --- a/spec/features/dashboard/snippets_spec.rb +++ b/spec/features/dashboard/snippets_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'Dashboard snippets', feature: true do +describe 'Dashboard snippets' do context 'when the project has snippets' do let(:project) { create(:empty_project, :public) } let!(:snippets) { create_list(:project_snippet, 2, :public, author: project.owner, project: project) } diff --git a/spec/features/dashboard/todos/target_state_spec.rb b/spec/features/dashboard/todos/target_state_spec.rb index 030a86d1c01..93da36c08fc 100644 --- a/spec/features/dashboard/todos/target_state_spec.rb +++ b/spec/features/dashboard/todos/target_state_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' feature 'Dashboard > Todo target states' do let(:user) { create(:user) } let(:author) { create(:user) } - let(:project) { create(:project, :public) } + let(:project) { create(:empty_project, :public) } before do sign_in(user) diff --git a/spec/features/dashboard/todos/todos_spec.rb b/spec/features/dashboard/todos/todos_spec.rb index 30bab7eeaa7..c2a61cf5aff 100644 --- a/spec/features/dashboard/todos/todos_spec.rb +++ b/spec/features/dashboard/todos/todos_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' feature 'Dashboard Todos' do let(:user) { create(:user) } let(:author) { create(:user) } - let(:project) { create(:project, :public) } + let(:project) { create(:empty_project, :public) } let(:issue) { create(:issue, due_date: Date.today) } context 'User does not have todos' do @@ -212,7 +212,7 @@ feature 'Dashboard Todos' do note1 = create(:note_on_issue, note: "Hello #{label1.to_reference(format: :name)}", noteable_id: issue.id, noteable_type: 'Issue', project: issue.project) create(:todo, :mentioned, project: project, target: issue, user: user, note_id: note1.id) - project2 = create(:project, :public) + project2 = create(:empty_project, :public) label2 = create(:label, project: project2) issue2 = create(:issue, project: project2) note2 = create(:note_on_issue, note: "Test #{label2.to_reference(format: :name)}", noteable_id: issue2.id, noteable_type: 'Issue', project: project2) diff --git a/spec/features/dashboard/user_filters_projects_spec.rb b/spec/features/dashboard/user_filters_projects_spec.rb index 711d3617335..a88fe207e0e 100644 --- a/spec/features/dashboard/user_filters_projects_spec.rb +++ b/spec/features/dashboard/user_filters_projects_spec.rb @@ -1,10 +1,10 @@ require 'spec_helper' -describe 'Dashboard > User filters projects', :feature do +describe 'Dashboard > User filters projects' do let(:user) { create(:user) } - let(:project) { create(:project, name: 'Victorialand', namespace: user.namespace) } + let(:project) { create(:empty_project, name: 'Victorialand', namespace: user.namespace) } let(:user2) { create(:user) } - let(:project2) { create(:project, name: 'Treasure', namespace: user2.namespace) } + let(:project2) { create(:empty_project, name: 'Treasure', namespace: user2.namespace) } before do project.team << [user, :master] diff --git a/spec/features/discussion_comments/commit_spec.rb b/spec/features/discussion_comments/commit_spec.rb index 26d21207678..fa83ad5d17c 100644 --- a/spec/features/discussion_comments/commit_spec.rb +++ b/spec/features/discussion_comments/commit_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'Discussion Comments Merge Request', :feature, :js do +describe 'Discussion Comments Merge Request', :js do include RepoHelpers let(:user) { create(:user) } diff --git a/spec/features/discussion_comments/issue_spec.rb b/spec/features/discussion_comments/issue_spec.rb index 11dbe10e1df..f52ba9c4d09 100644 --- a/spec/features/discussion_comments/issue_spec.rb +++ b/spec/features/discussion_comments/issue_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'Discussion Comments Issue', :feature, :js do +describe 'Discussion Comments Issue', :js do let(:user) { create(:user) } let(:project) { create(:empty_project) } let(:issue) { create(:issue, project: project) } diff --git a/spec/features/discussion_comments/merge_request_spec.rb b/spec/features/discussion_comments/merge_request_spec.rb index db745be6fa1..042f39f47e0 100644 --- a/spec/features/discussion_comments/merge_request_spec.rb +++ b/spec/features/discussion_comments/merge_request_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'Discussion Comments Merge Request', :feature, :js do +describe 'Discussion Comments Merge Request', :js do let(:user) { create(:user) } let(:project) { create(:project) } let(:merge_request) { create(:merge_request, source_project: project) } diff --git a/spec/features/discussion_comments/snippets_spec.rb b/spec/features/discussion_comments/snippets_spec.rb index eddbd4bde9b..50ba13499d9 100644 --- a/spec/features/discussion_comments/snippets_spec.rb +++ b/spec/features/discussion_comments/snippets_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'Discussion Comments Issue', :feature, :js do +describe 'Discussion Comments Issue', :js do let(:user) { create(:user) } let(:project) { create(:empty_project) } let(:snippet) { create(:project_snippet, :private, project: project, author: user) } diff --git a/spec/features/expand_collapse_diffs_spec.rb b/spec/features/expand_collapse_diffs_spec.rb index 18c06a48111..357d86497d9 100644 --- a/spec/features/expand_collapse_diffs_spec.rb +++ b/spec/features/expand_collapse_diffs_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Expand and collapse diffs', js: true, feature: true do +feature 'Expand and collapse diffs', js: true do let(:branch) { 'expand-collapse-diffs' } let(:project) { create(:project, :repository) } diff --git a/spec/features/explore/groups_list_spec.rb b/spec/features/explore/groups_list_spec.rb index 008d12714cc..84f41eca999 100644 --- a/spec/features/explore/groups_list_spec.rb +++ b/spec/features/explore/groups_list_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'Explore Groups page', :js, :feature do +describe 'Explore Groups page', :js do let!(:user) { create :user } let!(:group) { create(:group) } let!(:public_group) { create(:group, :public) } diff --git a/spec/features/explore/new_menu_spec.rb b/spec/features/explore/new_menu_spec.rb index e51d527bdf9..b1ccf80c28e 100644 --- a/spec/features/explore/new_menu_spec.rb +++ b/spec/features/explore/new_menu_spec.rb @@ -1,10 +1,10 @@ require 'spec_helper' -feature 'Top Plus Menu', feature: true, js: true do +feature 'Top Plus Menu', :js do let(:user) { create(:user) } let(:group) { create(:group) } let(:project) { create(:project, :repository, creator: user, namespace: user.namespace) } - let(:public_project) { create(:project, :public) } + let(:public_project) { create(:empty_project, :public) } before do group.add_owner(user) diff --git a/spec/features/gitlab_flavored_markdown_spec.rb b/spec/features/gitlab_flavored_markdown_spec.rb index 8659a868682..300296a2b94 100644 --- a/spec/features/gitlab_flavored_markdown_spec.rb +++ b/spec/features/gitlab_flavored_markdown_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe "GitLab Flavored Markdown", feature: true do +describe "GitLab Flavored Markdown" do let(:user) { create(:user) } let(:project) { create(:empty_project) } let(:issue) { create(:issue, project: project) } @@ -49,7 +49,7 @@ describe "GitLab Flavored Markdown", feature: true do end end - describe "for issues", feature: true, js: true do + describe "for issues", js: true do before do @other_issue = create(:issue, author: user, diff --git a/spec/features/global_search_spec.rb b/spec/features/global_search_spec.rb index efa5e95de89..627a930c997 100644 --- a/spec/features/global_search_spec.rb +++ b/spec/features/global_search_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Global search', feature: true do +feature 'Global search' do let(:user) { create(:user) } let(:project) { create(:empty_project, namespace: user.namespace) } diff --git a/spec/features/groups/activity_spec.rb b/spec/features/groups/activity_spec.rb index 262d9434ddf..d3b25ec3d6c 100644 --- a/spec/features/groups/activity_spec.rb +++ b/spec/features/groups/activity_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Group activity page', feature: true do +feature 'Group activity page' do let(:user) { create(:group_member, :developer, user: create(:user), group: group ).user } let(:group) { create(:group) } let(:path) { activity_group_path(group) } diff --git a/spec/features/groups/group_name_toggle_spec.rb b/spec/features/groups/group_name_toggle_spec.rb index ea779a3baf0..a7b8b702ab7 100644 --- a/spec/features/groups/group_name_toggle_spec.rb +++ b/spec/features/groups/group_name_toggle_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Group name toggle', feature: true, js: true do +feature 'Group name toggle', js: true do let(:group) { create(:group) } let(:nested_group_1) { create(:group, parent: group) } let(:nested_group_2) { create(:group, parent: nested_group_1) } diff --git a/spec/features/groups/group_settings_spec.rb b/spec/features/groups/group_settings_spec.rb index f7ef7f29066..121df1ec635 100644 --- a/spec/features/groups/group_settings_spec.rb +++ b/spec/features/groups/group_settings_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Edit group settings', feature: true do +feature 'Edit group settings' do given(:user) { create(:user) } given(:group) { create(:group, path: 'foo') } @@ -49,7 +49,7 @@ feature 'Edit group settings', feature: true do end context 'with a project' do - given!(:project) { create(:project, group: group, path: 'project') } + given!(:project) { create(:empty_project, group: group) } given(:old_project_full_path) { "/#{group.path}/#{project.path}" } given(:new_project_full_path) { "/#{new_group_path}/#{project.path}" } @@ -65,14 +65,14 @@ feature 'Edit group settings', feature: true do update_path(new_group_path) visit new_project_full_path expect(current_path).to eq(new_project_full_path) - expect(find('h1.project-title')).to have_content(project.name) + expect(find('h1.title')).to have_content(project.path) end scenario 'the old project path redirects to the new path' do update_path(new_group_path) visit old_project_full_path expect(current_path).to eq(new_project_full_path) - expect(find('h1.project-title')).to have_content(project.name) + expect(find('h1.title')).to have_content(project.path) end end end diff --git a/spec/features/groups/issues_spec.rb b/spec/features/groups/issues_spec.rb index d6b88542ef7..449a99a2c7b 100644 --- a/spec/features/groups/issues_spec.rb +++ b/spec/features/groups/issues_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Group issues page', feature: true do +feature 'Group issues page' do let(:path) { issues_group_path(group) } let(:issuable) { create(:issue, project: project, title: "this is my created issuable")} diff --git a/spec/features/groups/labels/edit_spec.rb b/spec/features/groups/labels/edit_spec.rb index 88d104d5a06..fb338127861 100644 --- a/spec/features/groups/labels/edit_spec.rb +++ b/spec/features/groups/labels/edit_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Edit group label', feature: true do +feature 'Edit group label' do given(:user) { create(:user) } given(:group) { create(:group) } given(:label) { create(:group_label, group: group) } diff --git a/spec/features/groups/labels/subscription_spec.rb b/spec/features/groups/labels/subscription_spec.rb index 8b891c52d08..1dd09d4f203 100644 --- a/spec/features/groups/labels/subscription_spec.rb +++ b/spec/features/groups/labels/subscription_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Labels subscription', feature: true do +feature 'Labels subscription' do let(:user) { create(:user) } let(:group) { create(:group) } let!(:feature) { create(:group_label, group: group, title: 'feature') } diff --git a/spec/features/groups/members/leave_group_spec.rb b/spec/features/groups/members/leave_group_spec.rb index b438f57753c..067a2dc850f 100644 --- a/spec/features/groups/members/leave_group_spec.rb +++ b/spec/features/groups/members/leave_group_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Groups > Members > Leave group', feature: true do +feature 'Groups > Members > Leave group' do let(:user) { create(:user) } let(:other_user) { create(:user) } let(:group) { create(:group) } diff --git a/spec/features/groups/members/list_members_spec.rb b/spec/features/groups/members/list_members_spec.rb index f6493c4c50e..5c5d48c3623 100644 --- a/spec/features/groups/members/list_members_spec.rb +++ b/spec/features/groups/members/list_members_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Groups > Members > List members', feature: true do +feature 'Groups > Members > List members' do include Select2Helper let(:user1) { create(:user, name: 'John Doe') } diff --git a/spec/features/groups/members/manage_access_requests_spec.rb b/spec/features/groups/members/manage_access_requests_spec.rb index 51a4d769b9c..b83cd657ef7 100644 --- a/spec/features/groups/members/manage_access_requests_spec.rb +++ b/spec/features/groups/members/manage_access_requests_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Groups > Members > Manage access requests', feature: true do +feature 'Groups > Members > Manage access requests' do let(:user) { create(:user) } let(:owner) { create(:user) } let(:group) { create(:group, :public, :access_requestable) } diff --git a/spec/features/groups/members/manage_members.rb b/spec/features/groups/members/manage_members.rb index 4b226893701..9039b283393 100644 --- a/spec/features/groups/members/manage_members.rb +++ b/spec/features/groups/members/manage_members.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Groups > Members > Manage members', feature: true do +feature 'Groups > Members > Manage members' do include Select2Helper let(:user1) { create(:user, name: 'John Doe') } diff --git a/spec/features/groups/members/request_access_spec.rb b/spec/features/groups/members/request_access_spec.rb index 3764e4792ca..6141981023c 100644 --- a/spec/features/groups/members/request_access_spec.rb +++ b/spec/features/groups/members/request_access_spec.rb @@ -1,10 +1,10 @@ require 'spec_helper' -feature 'Groups > Members > Request access', feature: true do +feature 'Groups > Members > Request access' do let(:user) { create(:user) } let(:owner) { create(:user) } let(:group) { create(:group, :public, :access_requestable) } - let!(:project) { create(:project, :private, namespace: group) } + let!(:project) { create(:empty_project, :private, namespace: group) } background do group.add_owner(owner) diff --git a/spec/features/groups/members/sort_members_spec.rb b/spec/features/groups/members/sort_members_spec.rb index 92ff45e0cdc..e175ad04f86 100644 --- a/spec/features/groups/members/sort_members_spec.rb +++ b/spec/features/groups/members/sort_members_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Groups > Members > Sort members', feature: true do +feature 'Groups > Members > Sort members' do let(:owner) { create(:user, name: 'John Doe') } let(:developer) { create(:user, name: 'Mary Jane', last_sign_in_at: 5.days.ago) } let(:group) { create(:group) } diff --git a/spec/features/groups/merge_requests_spec.rb b/spec/features/groups/merge_requests_spec.rb index b55078c3bf6..c2241feb9f7 100644 --- a/spec/features/groups/merge_requests_spec.rb +++ b/spec/features/groups/merge_requests_spec.rb @@ -1,13 +1,13 @@ require 'spec_helper' -feature 'Group merge requests page', feature: true do +feature 'Group merge requests page' do let(:path) { merge_requests_group_path(group) } let(:issuable) { create(:merge_request, source_project: project, target_project: project, title: 'this is my created issuable') } include_examples 'project features apply to issuables', MergeRequest context 'archived issuable' do - let(:project_archived) { create(:project, :archived, :merge_requests_enabled, group: group) } + let(:project_archived) { create(:project, :archived, :merge_requests_enabled, :repository, group: group) } let(:issuable_archived) { create(:merge_request, source_project: project_archived, target_project: project_archived, title: 'issuable of an archived project') } let(:access_level) { ProjectFeature::ENABLED } let(:user) { user_in_group } diff --git a/spec/features/groups/milestone_spec.rb b/spec/features/groups/milestone_spec.rb index 0f3f005040f..574bbe0e0e1 100644 --- a/spec/features/groups/milestone_spec.rb +++ b/spec/features/groups/milestone_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature 'Group milestones', :feature, :js do +feature 'Group milestones', :js do let(:group) { create(:group) } let!(:project) { create(:project_empty_repo, group: group) } let(:user) { create(:group_member, :master, user: create(:user), group: group ).user } diff --git a/spec/features/groups/show_spec.rb b/spec/features/groups/show_spec.rb index cbf97d0674b..303013e59d5 100644 --- a/spec/features/groups/show_spec.rb +++ b/spec/features/groups/show_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Group show page', feature: true do +feature 'Group show page' do let(:group) { create(:group) } let(:path) { group_path(group) } diff --git a/spec/features/groups_spec.rb b/spec/features/groups_spec.rb index 6f8c8999f98..e59a484d992 100644 --- a/spec/features/groups_spec.rb +++ b/spec/features/groups_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Group', feature: true do +feature 'Group' do before do sign_in(create(:admin)) end diff --git a/spec/features/help_pages_spec.rb b/spec/features/help_pages_spec.rb index 7fe65ee554d..bd4f233cba9 100644 --- a/spec/features/help_pages_spec.rb +++ b/spec/features/help_pages_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'Help Pages', feature: true do +describe 'Help Pages' do describe 'Get the main help page' do shared_examples_for 'help page' do |prefix: ''| it 'prefixes links correctly' do diff --git a/spec/features/issuables/close_reopen_report_toggle_spec.rb b/spec/features/issuables/close_reopen_report_toggle_spec.rb index 9a99bb705b7..0e43eed8699 100644 --- a/spec/features/issuables/close_reopen_report_toggle_spec.rb +++ b/spec/features/issuables/close_reopen_report_toggle_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'Issuables Close/Reopen/Report toggle', :feature do +describe 'Issuables Close/Reopen/Report toggle' do let(:user) { create(:user) } shared_examples 'an issuable close/reopen/report toggle' do @@ -79,7 +79,7 @@ describe 'Issuables Close/Reopen/Report toggle', :feature do end context 'on a merge request' do - let(:project) { create(:project) } + let(:project) { create(:project, :repository) } let(:issuable) { create(:merge_request, source_project: project) } before do @@ -96,7 +96,7 @@ describe 'Issuables Close/Reopen/Report toggle', :feature do end context 'when user doesnt have permission to update' do - let(:cant_project) { create(:project) } + let(:cant_project) { create(:project, :repository) } let(:cant_issuable) { create(:merge_request, source_project: cant_project) } before do diff --git a/spec/features/issuables/default_sort_order_spec.rb b/spec/features/issuables/default_sort_order_spec.rb index 56c9b10e757..7c20c96528e 100644 --- a/spec/features/issuables/default_sort_order_spec.rb +++ b/spec/features/issuables/default_sort_order_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'Projects > Issuables > Default sort order', feature: true do +describe 'Projects > Issuables > Default sort order' do let(:project) { create(:empty_project, :public) } let(:first_created_issuable) { issuables.order_created_asc.first } diff --git a/spec/features/issuables/issuable_list_spec.rb b/spec/features/issuables/issuable_list_spec.rb index 32fee2d9c34..557de721222 100644 --- a/spec/features/issuables/issuable_list_spec.rb +++ b/spec/features/issuables/issuable_list_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'issuable list', feature: true do +describe 'issuable list' do let(:project) { create(:empty_project) } let(:user) { create(:user) } diff --git a/spec/features/issuables/markdown_references_spec.rb b/spec/features/issuables/markdown_references_spec.rb index f51b2e4001a..169381d703a 100644 --- a/spec/features/issuables/markdown_references_spec.rb +++ b/spec/features/issuables/markdown_references_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'Markdown References', :feature, :js do +describe 'Markdown References', :js do let(:user) { create(:user) } let(:actual_project) { create(:project, :public) } let(:merge_request) { create(:merge_request, target_project: actual_project, source_project: actual_project)} diff --git a/spec/features/issuables/user_sees_sidebar_spec.rb b/spec/features/issuables/user_sees_sidebar_spec.rb index 948d151a517..2bd1c8aab86 100644 --- a/spec/features/issuables/user_sees_sidebar_spec.rb +++ b/spec/features/issuables/user_sees_sidebar_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' describe 'Issue Sidebar on Mobile' do include MobileHelpers - let(:project) { create(:project, :public) } + let(:project) { create(:project, :public, :repository) } let(:merge_request) { create(:merge_request, source_project: project) } let(:issue) { create(:issue, project: project) } let!(:user) { create(:user)} diff --git a/spec/features/issues/award_emoji_spec.rb b/spec/features/issues/award_emoji_spec.rb index 823c779e0d9..6cb0bf6fdfd 100644 --- a/spec/features/issues/award_emoji_spec.rb +++ b/spec/features/issues/award_emoji_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' -describe 'Awards Emoji', feature: true do - let!(:project) { create(:project, :public) } +describe 'Awards Emoji' do + let!(:project) { create(:empty_project, :public) } let!(:user) { create(:user) } let(:issue) do create(:issue, diff --git a/spec/features/issues/award_spec.rb b/spec/features/issues/award_spec.rb index 76cffc1d8c9..740281c1050 100644 --- a/spec/features/issues/award_spec.rb +++ b/spec/features/issues/award_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -feature 'Issue awards', js: true, feature: true do +feature 'Issue awards', js: true do let(:user) { create(:user) } - let(:project) { create(:project, :public) } + let(:project) { create(:empty_project, :public) } let(:issue) { create(:issue, project: project) } describe 'logged in' do diff --git a/spec/features/issues/bulk_assignment_labels_spec.rb b/spec/features/issues/bulk_assignment_labels_spec.rb index 034d8afb54d..5acf8fdae84 100644 --- a/spec/features/issues/bulk_assignment_labels_spec.rb +++ b/spec/features/issues/bulk_assignment_labels_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -feature 'Issues > Labels bulk assignment', feature: true do +feature 'Issues > Labels bulk assignment' do let(:user) { create(:user) } - let!(:project) { create(:project) } + let!(:project) { create(:empty_project) } let!(:issue1) { create(:issue, project: project, title: "Issue 1") } let!(:issue2) { create(:issue, project: project, title: "Issue 2") } let!(:bug) { create(:label, project: project, title: 'bug') } diff --git a/spec/features/issues/create_branch_merge_request_spec.rb b/spec/features/issues/create_branch_merge_request_spec.rb index 6e778f4d7e5..f59f687cf51 100644 --- a/spec/features/issues/create_branch_merge_request_spec.rb +++ b/spec/features/issues/create_branch_merge_request_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -feature 'Create Branch/Merge Request Dropdown on issue page', feature: true, js: true do +feature 'Create Branch/Merge Request Dropdown on issue page', js: true do let(:user) { create(:user) } - let!(:project) { create(:project) } + let!(:project) { create(:project, :repository) } let(:issue) { create(:issue, project: project, title: 'Cherry-Coloured Funk') } context 'for team members' do @@ -15,16 +15,14 @@ feature 'Create Branch/Merge Request Dropdown on issue page', feature: true, js: visit project_issue_path(project, issue) select_dropdown_option('create-mr') + + expect(page).to have_content('WIP: Resolve "Cherry-Coloured Funk"') + expect(current_path).to eq(project_merge_request_path(project, MergeRequest.first)) - wait_for_requests + visit project_issue_path(project, issue) expect(page).to have_content("created branch 1-cherry-coloured-funk") expect(page).to have_content("mentioned in merge request !1") - - visit project_merge_request_path(project, MergeRequest.first) - - expect(page).to have_content('WIP: Resolve "Cherry-Coloured Funk"') - expect(current_path).to eq(project_merge_request_path(project, MergeRequest.first)) end it 'allows creating a branch from the issue page' do diff --git a/spec/features/issues/create_issue_for_discussions_in_merge_request_spec.rb b/spec/features/issues/create_issue_for_discussions_in_merge_request_spec.rb index dd9a7f1253d..80cc8d22999 100644 --- a/spec/features/issues/create_issue_for_discussions_in_merge_request_spec.rb +++ b/spec/features/issues/create_issue_for_discussions_in_merge_request_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -feature 'Resolving all open discussions in a merge request from an issue', feature: true, js: true do +feature 'Resolving all open discussions in a merge request from an issue', js: true do let(:user) { create(:user) } - let(:project) { create(:project) } + let(:project) { create(:project, :repository) } let(:merge_request) { create(:merge_request, source_project: project) } let!(:discussion) { create(:diff_note_on_merge_request, noteable: merge_request, project: project).to_discussion } diff --git a/spec/features/issues/create_issue_for_single_discussion_in_merge_request_spec.rb b/spec/features/issues/create_issue_for_single_discussion_in_merge_request_spec.rb index 5c291f7b817..ad5fd0fd97b 100644 --- a/spec/features/issues/create_issue_for_single_discussion_in_merge_request_spec.rb +++ b/spec/features/issues/create_issue_for_single_discussion_in_merge_request_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -feature 'Resolve an open discussion in a merge request by creating an issue', feature: true do +feature 'Resolve an open discussion in a merge request by creating an issue' do let(:user) { create(:user) } - let(:project) { create(:project, only_allow_merge_if_all_discussions_are_resolved: true) } + let(:project) { create(:project, :repository, only_allow_merge_if_all_discussions_are_resolved: true) } let(:merge_request) { create(:merge_request, source_project: project) } let!(:discussion) { create(:diff_note_on_merge_request, noteable: merge_request, project: project).to_discussion } diff --git a/spec/features/issues/filtered_search/dropdown_assignee_spec.rb b/spec/features/issues/filtered_search/dropdown_assignee_spec.rb index 2765d5448a4..a403d885de0 100644 --- a/spec/features/issues/filtered_search/dropdown_assignee_spec.rb +++ b/spec/features/issues/filtered_search/dropdown_assignee_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'Dropdown assignee', :feature, :js do +describe 'Dropdown assignee', :js do include FilteredSearchHelpers let!(:project) { create(:empty_project) } diff --git a/spec/features/issues/filtered_search/dropdown_author_spec.rb b/spec/features/issues/filtered_search/dropdown_author_spec.rb index 98b1c5ee1b5..b7d9bbd7e1d 100644 --- a/spec/features/issues/filtered_search/dropdown_author_spec.rb +++ b/spec/features/issues/filtered_search/dropdown_author_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'Dropdown author', js: true, feature: true do +describe 'Dropdown author', js: true do include FilteredSearchHelpers let!(:project) { create(:empty_project) } diff --git a/spec/features/issues/filtered_search/dropdown_hint_spec.rb b/spec/features/issues/filtered_search/dropdown_hint_spec.rb index fdc003f81b3..292fd683271 100644 --- a/spec/features/issues/filtered_search/dropdown_hint_spec.rb +++ b/spec/features/issues/filtered_search/dropdown_hint_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'Dropdown hint', :js, :feature do +describe 'Dropdown hint', :js do include FilteredSearchHelpers let!(:project) { create(:empty_project) } diff --git a/spec/features/issues/filtered_search/dropdown_label_spec.rb b/spec/features/issues/filtered_search/dropdown_label_spec.rb index 26a0320675f..e8f005d7752 100644 --- a/spec/features/issues/filtered_search/dropdown_label_spec.rb +++ b/spec/features/issues/filtered_search/dropdown_label_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'Dropdown label', js: true, feature: true do +describe 'Dropdown label', js: true do include FilteredSearchHelpers let(:project) { create(:empty_project) } diff --git a/spec/features/issues/filtered_search/dropdown_milestone_spec.rb b/spec/features/issues/filtered_search/dropdown_milestone_spec.rb index 7c74d8dffff..ace73f4b1a6 100644 --- a/spec/features/issues/filtered_search/dropdown_milestone_spec.rb +++ b/spec/features/issues/filtered_search/dropdown_milestone_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'Dropdown milestone', :feature, :js do +describe 'Dropdown milestone', :js do include FilteredSearchHelpers let!(:project) { create(:empty_project) } diff --git a/spec/features/issues/filtered_search/filter_issues_spec.rb b/spec/features/issues/filtered_search/filter_issues_spec.rb index 9fc6391fa98..265bcb3a8e5 100644 --- a/spec/features/issues/filtered_search/filter_issues_spec.rb +++ b/spec/features/issues/filtered_search/filter_issues_spec.rb @@ -1,11 +1,11 @@ require 'spec_helper' -describe 'Filter issues', js: true, feature: true do +describe 'Filter issues', js: true do include Devise::Test::IntegrationHelpers include FilteredSearchHelpers let!(:group) { create(:group) } - let!(:project) { create(:project, group: group) } + let!(:project) { create(:empty_project, group: group) } let!(:user) { create(:user, username: 'joe', name: 'Joe') } let!(:user2) { create(:user, username: 'jane') } let!(:label) { create(:label, project: project) } diff --git a/spec/features/issues/filtered_search/recent_searches_spec.rb b/spec/features/issues/filtered_search/recent_searches_spec.rb index 4a91ce4be07..5842bb22beb 100644 --- a/spec/features/issues/filtered_search/recent_searches_spec.rb +++ b/spec/features/issues/filtered_search/recent_searches_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'Recent searches', js: true, feature: true do +describe 'Recent searches', js: true do include FilteredSearchHelpers let(:project_1) { create(:empty_project, :public) } diff --git a/spec/features/issues/filtered_search/search_bar_spec.rb b/spec/features/issues/filtered_search/search_bar_spec.rb index b16c5c280c7..115875d72ce 100644 --- a/spec/features/issues/filtered_search/search_bar_spec.rb +++ b/spec/features/issues/filtered_search/search_bar_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'Search bar', js: true, feature: true do +describe 'Search bar', js: true do include FilteredSearchHelpers let!(:project) { create(:empty_project) } diff --git a/spec/features/issues/filtered_search/visual_tokens_spec.rb b/spec/features/issues/filtered_search/visual_tokens_spec.rb index a15c3d1d447..d00d0a9c81b 100644 --- a/spec/features/issues/filtered_search/visual_tokens_spec.rb +++ b/spec/features/issues/filtered_search/visual_tokens_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'Visual tokens', js: true, feature: true do +describe 'Visual tokens', js: true do include FilteredSearchHelpers include WaitForRequests diff --git a/spec/features/issues/form_spec.rb b/spec/features/issues/form_spec.rb index 05742004f06..0ba02ba42ba 100644 --- a/spec/features/issues/form_spec.rb +++ b/spec/features/issues/form_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' -describe 'New/edit issue', :feature, :js do +describe 'New/edit issue', :js do include ActionView::Helpers::JavaScriptHelper include FormHelper - let!(:project) { create(:project) } + let!(:project) { create(:empty_project) } let!(:user) { create(:user)} let!(:user2) { create(:user)} let!(:milestone) { create(:milestone, project: project) } diff --git a/spec/features/issues/gfm_autocomplete_spec.rb b/spec/features/issues/gfm_autocomplete_spec.rb index 9b4cc653af5..1b36f16e8b6 100644 --- a/spec/features/issues/gfm_autocomplete_spec.rb +++ b/spec/features/issues/gfm_autocomplete_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -feature 'GFM autocomplete', feature: true, js: true do +feature 'GFM autocomplete', js: true do let(:user) { create(:user, name: '💃speciąl someone💃', username: 'someone.special') } - let(:project) { create(:project) } + let(:project) { create(:empty_project) } let(:label) { create(:label, project: project, title: 'special+') } let(:issue) { create(:issue, project: project) } diff --git a/spec/features/issues/group_label_sidebar_spec.rb b/spec/features/issues/group_label_sidebar_spec.rb index 5531a662c67..a8ac1d605cb 100644 --- a/spec/features/issues/group_label_sidebar_spec.rb +++ b/spec/features/issues/group_label_sidebar_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'Group label on issue', :feature do +describe 'Group label on issue' do it 'renders link to the project issues page' do group = create(:group) project = create(:empty_project, :public, namespace: group) diff --git a/spec/features/issues/issue_detail_spec.rb b/spec/features/issues/issue_detail_spec.rb index e1c55d246ab..a7a7e02b59c 100644 --- a/spec/features/issues/issue_detail_spec.rb +++ b/spec/features/issues/issue_detail_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -feature 'Issue Detail', js: true, feature: true do +feature 'Issue Detail', :js do let(:user) { create(:user) } - let(:project) { create(:project, :public) } + let(:project) { create(:empty_project, :public) } let(:issue) { create(:issue, project: project, author: user) } context 'when user displays the issue' do diff --git a/spec/features/issues/issue_sidebar_spec.rb b/spec/features/issues/issue_sidebar_spec.rb index f75d2c72672..28f93cfd971 100644 --- a/spec/features/issues/issue_sidebar_spec.rb +++ b/spec/features/issues/issue_sidebar_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' -feature 'Issue Sidebar', feature: true do +feature 'Issue Sidebar' do include MobileHelpers let(:group) { create(:group, :nested) } - let(:project) { create(:project, :public, namespace: group) } + let(:project) { create(:empty_project, :public, namespace: group) } let(:issue) { create(:issue, project: project) } let!(:user) { create(:user)} let!(:label) { create(:label, project: project, title: 'bug') } diff --git a/spec/features/issues/markdown_toolbar_spec.rb b/spec/features/issues/markdown_toolbar_spec.rb index affba35f61c..0f869970460 100644 --- a/spec/features/issues/markdown_toolbar_spec.rb +++ b/spec/features/issues/markdown_toolbar_spec.rb @@ -1,9 +1,9 @@ require 'rails_helper' -feature 'Issue markdown toolbar', feature: true, js: true do - let(:project) { create(:project, :public) } +feature 'Issue markdown toolbar', js: true do + let(:project) { create(:empty_project, :public) } let(:issue) { create(:issue, project: project) } - let(:user) { create(:user) } + let(:user) { create(:user) } before do sign_in(user) diff --git a/spec/features/issues/move_spec.rb b/spec/features/issues/move_spec.rb index 833eb47efb2..2ab7d1a71b7 100644 --- a/spec/features/issues/move_spec.rb +++ b/spec/features/issues/move_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' feature 'issue move to another project' do let(:user) { create(:user) } - let(:old_project) { create(:project) } + let(:old_project) { create(:project, :repository) } let(:text) { 'Some issue description' } let(:issue) do @@ -25,8 +25,8 @@ feature 'issue move to another project' do context 'user has permission to move issue' do let!(:mr) { create(:merge_request, source_project: old_project) } - let(:new_project) { create(:project) } - let(:new_project_search) { create(:project) } + let(:new_project) { create(:empty_project) } + let(:new_project_search) { create(:empty_project) } let(:text) { "Text with #{mr.to_reference}" } let(:cross_reference) { old_project.to_reference(new_project) } @@ -63,8 +63,8 @@ feature 'issue move to another project' do end context 'user does not have permission to move the issue to a project', js: true do - let!(:private_project) { create(:project, :private) } - let(:another_project) { create(:project) } + let!(:private_project) { create(:empty_project, :private) } + let(:another_project) { create(:empty_project) } background { another_project.team << [user, :guest] } scenario 'browsing projects in projects select' do diff --git a/spec/features/issues/note_polling_spec.rb b/spec/features/issues/note_polling_spec.rb index 184cde5b9c5..b524260750e 100644 --- a/spec/features/issues/note_polling_spec.rb +++ b/spec/features/issues/note_polling_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Issue notes polling', :feature, :js do +feature 'Issue notes polling', :js do include NoteInteractionHelpers let(:project) { create(:empty_project, :public) } diff --git a/spec/features/issues/notes_on_issues_spec.rb b/spec/features/issues/notes_on_issues_spec.rb index 6fb103e5477..29c9b99030a 100644 --- a/spec/features/issues/notes_on_issues_spec.rb +++ b/spec/features/issues/notes_on_issues_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'Create notes on issues', :js, :feature do +describe 'Create notes on issues', :js do let(:user) { create(:user) } shared_examples 'notes with reference' do @@ -35,42 +35,42 @@ describe 'Create notes on issues', :js, :feature do context 'mentioning issue on a private project' do it_behaves_like 'notes with reference' do - let(:project) { create(:project, :private) } + let(:project) { create(:empty_project, :private) } let(:mention) { create(:issue, project: project) } end end context 'mentioning issue on an internal project' do it_behaves_like 'notes with reference' do - let(:project) { create(:project, :internal) } + let(:project) { create(:empty_project, :internal) } let(:mention) { create(:issue, project: project) } end end context 'mentioning issue on a public project' do it_behaves_like 'notes with reference' do - let(:project) { create(:project, :public) } + let(:project) { create(:empty_project, :public) } let(:mention) { create(:issue, project: project) } end end context 'mentioning merge request on a private project' do it_behaves_like 'notes with reference' do - let(:project) { create(:project, :private) } + let(:project) { create(:project, :private, :repository) } let(:mention) { create(:merge_request, source_project: project) } end end context 'mentioning merge request on an internal project' do it_behaves_like 'notes with reference' do - let(:project) { create(:project, :internal) } + let(:project) { create(:project, :internal, :repository) } let(:mention) { create(:merge_request, source_project: project) } end end context 'mentioning merge request on a public project' do it_behaves_like 'notes with reference' do - let(:project) { create(:project, :public) } + let(:project) { create(:project, :public, :repository) } let(:mention) { create(:merge_request, source_project: project) } end end diff --git a/spec/features/issues/spam_issues_spec.rb b/spec/features/issues/spam_issues_spec.rb index 39a458fe3d0..7a05e8b2ccc 100644 --- a/spec/features/issues/spam_issues_spec.rb +++ b/spec/features/issues/spam_issues_spec.rb @@ -1,9 +1,9 @@ require 'rails_helper' -describe 'New issue', feature: true, js: true do +describe 'New issue', js: true do include StubENV - let(:project) { create(:project, :public) } + let(:project) { create(:empty_project, :public) } let(:user) { create(:user)} before do diff --git a/spec/features/issues/todo_spec.rb b/spec/features/issues/todo_spec.rb index f57b58f68e3..2460ae817f9 100644 --- a/spec/features/issues/todo_spec.rb +++ b/spec/features/issues/todo_spec.rb @@ -1,9 +1,9 @@ require 'rails_helper' -feature 'Manually create a todo item from issue', feature: true, js: true do - let!(:project) { create(:project) } - let!(:issue) { create(:issue, project: project) } - let!(:user) { create(:user)} +feature 'Manually create a todo item from issue', js: true do + let!(:project) { create(:empty_project) } + let!(:issue) { create(:issue, project: project) } + let!(:user) { create(:user)} before do project.team << [user, :master] diff --git a/spec/features/issues/update_issues_spec.rb b/spec/features/issues/update_issues_spec.rb index 5a7c4f54cb6..389151e63f0 100644 --- a/spec/features/issues/update_issues_spec.rb +++ b/spec/features/issues/update_issues_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' feature 'Multiple issue updating from issues#index', :js do - let!(:project) { create(:project) } + let!(:project) { create(:empty_project) } let!(:issue) { create(:issue, project: project) } let!(:user) { create(:user)} diff --git a/spec/features/issues/user_uses_slash_commands_spec.rb b/spec/features/issues/user_uses_slash_commands_spec.rb index 0c3c27e3e45..d28ad52ff56 100644 --- a/spec/features/issues/user_uses_slash_commands_spec.rb +++ b/spec/features/issues/user_uses_slash_commands_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature 'Issues > User uses quick actions', feature: true, js: true do +feature 'Issues > User uses quick actions', js: true do include QuickActionsHelpers it_behaves_like 'issuable record that supports quick actions in its description and notes', :issue do @@ -9,7 +9,7 @@ feature 'Issues > User uses quick actions', feature: true, js: true do describe 'issue-only commands' do let(:user) { create(:user) } - let(:project) { create(:project, :public) } + let(:project) { create(:empty_project, :public) } before do project.team << [user, :master] diff --git a/spec/features/issues_spec.rb b/spec/features/issues_spec.rb index 0016fa10f67..722237481ea 100644 --- a/spec/features/issues_spec.rb +++ b/spec/features/issues_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'Issues', feature: true do +describe 'Issues' do include DropzoneHelper include IssueHelpers include SortingHelper diff --git a/spec/features/login_spec.rb b/spec/features/login_spec.rb index 2a2213b67ed..c9983f0941f 100644 --- a/spec/features/login_spec.rb +++ b/spec/features/login_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Login', feature: true do +feature 'Login' do describe 'initial login after setup' do it 'allows the initial admin to create a password' do # This behavior is dependent on there only being one user diff --git a/spec/features/markdown_spec.rb b/spec/features/markdown_spec.rb index 1aca3e3a9fd..b70d3060f05 100644 --- a/spec/features/markdown_spec.rb +++ b/spec/features/markdown_spec.rb @@ -24,7 +24,7 @@ require 'erb' # # See the MarkdownFeature class for setup details. -describe 'GitLab Markdown', feature: true do +describe 'GitLab Markdown' do include Capybara::Node::Matchers include MarkupHelper include MarkdownMatchers diff --git a/spec/features/merge_requests/assign_issues_spec.rb b/spec/features/merge_requests/assign_issues_spec.rb index 985f42e484c..63fa72650ac 100644 --- a/spec/features/merge_requests/assign_issues_spec.rb +++ b/spec/features/merge_requests/assign_issues_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -feature 'Merge request issue assignment', js: true, feature: true do +feature 'Merge request issue assignment', js: true do let(:user) { create(:user) } - let(:project) { create(:project, :public) } + let(:project) { create(:project, :public, :repository) } let(:issue1) { create(:issue, project: project) } let(:issue2) { create(:issue, project: project) } let(:merge_request) { create(:merge_request, :simple, source_project: project, author: user, description: "fixes #{issue1.to_reference} and #{issue2.to_reference}") } diff --git a/spec/features/merge_requests/award_spec.rb b/spec/features/merge_requests/award_spec.rb index 3b01c763281..e886309133d 100644 --- a/spec/features/merge_requests/award_spec.rb +++ b/spec/features/merge_requests/award_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -feature 'Merge request awards', js: true, feature: true do +feature 'Merge request awards', js: true do let(:user) { create(:user) } - let(:project) { create(:project, :public) } + let(:project) { create(:project, :public, :repository) } let(:merge_request) { create(:merge_request, source_project: project) } describe 'logged in' do diff --git a/spec/features/merge_requests/check_if_mergeable_with_unresolved_discussions_spec.rb b/spec/features/merge_requests/check_if_mergeable_with_unresolved_discussions_spec.rb index f2d6c0d9769..1f5e7b55fb0 100644 --- a/spec/features/merge_requests/check_if_mergeable_with_unresolved_discussions_spec.rb +++ b/spec/features/merge_requests/check_if_mergeable_with_unresolved_discussions_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' -feature 'Check if mergeable with unresolved discussions', js: true, feature: true do +feature 'Check if mergeable with unresolved discussions', js: true do let(:user) { create(:user) } - let(:project) { create(:project) } + let(:project) { create(:project, :repository) } let!(:merge_request) { create(:merge_request_with_diff_notes, source_project: project, author: user) } before do diff --git a/spec/features/merge_requests/cherry_pick_spec.rb b/spec/features/merge_requests/cherry_pick_spec.rb index e4c33d57e8d..4b1e1b9a8d4 100644 --- a/spec/features/merge_requests/cherry_pick_spec.rb +++ b/spec/features/merge_requests/cherry_pick_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe 'Cherry-pick Merge Requests', js: true do let(:user) { create(:user) } let(:group) { create(:group) } - let(:project) { create(:project, namespace: group) } + let(:project) { create(:project, :repository, namespace: group) } let(:merge_request) { create(:merge_request_with_diffs, source_project: project, author: user) } before do diff --git a/spec/features/merge_requests/closes_issues_spec.rb b/spec/features/merge_requests/closes_issues_spec.rb index 527837b56be..0e97254eada 100644 --- a/spec/features/merge_requests/closes_issues_spec.rb +++ b/spec/features/merge_requests/closes_issues_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' -feature 'Merge Request closing issues message', feature: true, js: true do +feature 'Merge Request closing issues message', js: true do let(:user) { create(:user) } - let(:project) { create(:project, :public) } + let(:project) { create(:project, :public, :repository) } let(:issue_1) { create(:issue, project: project)} let(:issue_2) { create(:issue, project: project)} let(:merge_request) do diff --git a/spec/features/merge_requests/conflicts_spec.rb b/spec/features/merge_requests/conflicts_spec.rb index 5c0909b6a59..2c560632a1b 100644 --- a/spec/features/merge_requests/conflicts_spec.rb +++ b/spec/features/merge_requests/conflicts_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' -feature 'Merge request conflict resolution', js: true, feature: true do +feature 'Merge request conflict resolution', js: true do let(:user) { create(:user) } - let(:project) { create(:project) } + let(:project) { create(:project, :repository) } before do # In order to have the diffs collapsed, we need to disable the increase feature diff --git a/spec/features/merge_requests/create_new_mr_spec.rb b/spec/features/merge_requests/create_new_mr_spec.rb index e0d97dec586..11a74276898 100644 --- a/spec/features/merge_requests/create_new_mr_spec.rb +++ b/spec/features/merge_requests/create_new_mr_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' -feature 'Create New Merge Request', feature: true, js: true do +feature 'Create New Merge Request', js: true do let(:user) { create(:user) } - let(:project) { create(:project, :public) } + let(:project) { create(:project, :public, :repository) } before do project.team << [user, :master] @@ -63,7 +63,7 @@ feature 'Create New Merge Request', feature: true, js: true do context 'when target project cannot be viewed by the current user' do it 'does not leak the private project name & namespace' do - private_project = create(:project, :private) + private_project = create(:project, :private, :repository) visit project_new_merge_request_path(project, merge_request: { target_project_id: private_project.id }) @@ -74,7 +74,7 @@ feature 'Create New Merge Request', feature: true, js: true do context 'when source project cannot be viewed by the current user' do it 'does not leak the private project name & namespace' do - private_project = create(:project, :private) + private_project = create(:project, :private, :repository) visit project_new_merge_request_path(project, merge_request: { source_project_id: private_project.id }) diff --git a/spec/features/merge_requests/created_from_fork_spec.rb b/spec/features/merge_requests/created_from_fork_spec.rb index 9b7795ace62..09541873f71 100644 --- a/spec/features/merge_requests/created_from_fork_spec.rb +++ b/spec/features/merge_requests/created_from_fork_spec.rb @@ -2,8 +2,8 @@ require 'spec_helper' feature 'Merge request created from fork' do given(:user) { create(:user) } - given(:project) { create(:project, :public) } - given(:fork_project) { create(:project, :public) } + given(:project) { create(:project, :public, :repository) } + given(:fork_project) { create(:project, :public, :repository) } given!(:merge_request) do create(:forked_project_link, forked_to_project: fork_project, @@ -25,6 +25,33 @@ feature 'Merge request created from fork' do expect(page).to have_content 'Test merge request' end + context 'when a commit comment exists on the merge request' do + given(:comment) { 'A commit comment' } + given(:reply) { 'A reply comment' } + + background do + create(:note_on_commit, note: comment, + project: fork_project, + commit_id: merge_request.commit_shas.first) + end + + scenario 'user can reply to the comment', js: true do + visit_merge_request(merge_request) + + expect(page).to have_content(comment) + + page.within('.discussion-notes') do + find('.btn-text-field').click + find('#note_note').send_keys(reply) + find('.comment-btn').click + end + + wait_for_requests + + expect(page).to have_content(reply) + end + end + context 'source project is deleted' do background do MergeRequests::MergeService.new(project, user).execute(merge_request) diff --git a/spec/features/merge_requests/deleted_source_branch_spec.rb b/spec/features/merge_requests/deleted_source_branch_spec.rb index 8d7160e2df2..874c6e2ff69 100644 --- a/spec/features/merge_requests/deleted_source_branch_spec.rb +++ b/spec/features/merge_requests/deleted_source_branch_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' # This test serves as a regression test for a bug that caused an error # message to be shown by JavaScript when the source branch was deleted. # Please do not remove "js: true". -describe 'Deleted source branch', feature: true, js: true do +describe 'Deleted source branch', js: true do let(:user) { create(:user) } let(:merge_request) { create(:merge_request) } diff --git a/spec/features/merge_requests/diff_notes_avatars_spec.rb b/spec/features/merge_requests/diff_notes_avatars_spec.rb index 4fc70027193..2d9419d6124 100644 --- a/spec/features/merge_requests/diff_notes_avatars_spec.rb +++ b/spec/features/merge_requests/diff_notes_avatars_spec.rb @@ -1,10 +1,10 @@ require 'spec_helper' -feature 'Diff note avatars', feature: true, js: true do +feature 'Diff note avatars', js: true do include NoteInteractionHelpers let(:user) { create(:user) } - let(:project) { create(:project, :public) } + let(:project) { create(:project, :public, :repository) } let(:merge_request) { create(:merge_request_with_diffs, source_project: project, author: user, title: "Bug NS-04") } let(:path) { "files/ruby/popen.rb" } let(:position) do diff --git a/spec/features/merge_requests/diff_notes_resolve_spec.rb b/spec/features/merge_requests/diff_notes_resolve_spec.rb index 93e2d134389..ac7f75bd308 100644 --- a/spec/features/merge_requests/diff_notes_resolve_spec.rb +++ b/spec/features/merge_requests/diff_notes_resolve_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' -feature 'Diff notes resolve', feature: true, js: true do +feature 'Diff notes resolve', js: true do let(:user) { create(:user) } - let(:project) { create(:project, :public) } + let(:project) { create(:project, :public, :repository) } let(:merge_request) { create(:merge_request_with_diffs, source_project: project, author: user, title: "Bug NS-04") } let!(:note) { create(:diff_note_on_merge_request, project: project, noteable: merge_request) } let(:path) { "files/ruby/popen.rb" } diff --git a/spec/features/merge_requests/diffs_spec.rb b/spec/features/merge_requests/diffs_spec.rb index d9de4e388d5..201be4b9e40 100644 --- a/spec/features/merge_requests/diffs_spec.rb +++ b/spec/features/merge_requests/diffs_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' -feature 'Diffs URL', js: true, feature: true do - let(:project) { create(:project, :public) } +feature 'Diffs URL', js: true do + let(:project) { create(:project, :public, :repository) } let(:merge_request) { create(:merge_request, source_project: project) } context 'when visit with */* as accept header' do diff --git a/spec/features/merge_requests/discussion_spec.rb b/spec/features/merge_requests/discussion_spec.rb index 55846f8609b..d1cc43e0690 100644 --- a/spec/features/merge_requests/discussion_spec.rb +++ b/spec/features/merge_requests/discussion_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Merge Request Discussions', feature: true do +feature 'Merge Request Discussions' do before do sign_in(create(:admin)) end diff --git a/spec/features/merge_requests/edit_mr_spec.rb b/spec/features/merge_requests/edit_mr_spec.rb index b7063f35546..7386e78fb13 100644 --- a/spec/features/merge_requests/edit_mr_spec.rb +++ b/spec/features/merge_requests/edit_mr_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' -feature 'Edit Merge Request', feature: true do +feature 'Edit Merge Request' do let(:user) { create(:user) } - let(:project) { create(:project, :public) } + let(:project) { create(:project, :public, :repository) } let(:merge_request) { create(:merge_request, :simple, source_project: project) } before do diff --git a/spec/features/merge_requests/filter_by_labels_spec.rb b/spec/features/merge_requests/filter_by_labels_spec.rb index 754f82900e4..1d52a4659ad 100644 --- a/spec/features/merge_requests/filter_by_labels_spec.rb +++ b/spec/features/merge_requests/filter_by_labels_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' -feature 'Issue filtering by Labels', feature: true, js: true do +feature 'Merge Request filtering by Labels', js: true do include FilteredSearchHelpers include MergeRequestHelpers - let(:project) { create(:project, :public) } + let(:project) { create(:project, :public, :repository) } let!(:user) { create(:user) } let!(:label) { create(:label, project: project) } diff --git a/spec/features/merge_requests/filter_by_milestone_spec.rb b/spec/features/merge_requests/filter_by_milestone_spec.rb index d2af150d852..521fcabc881 100644 --- a/spec/features/merge_requests/filter_by_milestone_spec.rb +++ b/spec/features/merge_requests/filter_by_milestone_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' -feature 'Merge Request filtering by Milestone', feature: true do +feature 'Merge Request filtering by Milestone' do include FilteredSearchHelpers include MergeRequestHelpers - let(:project) { create(:project, :public) } + let(:project) { create(:project, :public, :repository) } let!(:user) { create(:user)} let(:milestone) { create(:milestone, project: project) } diff --git a/spec/features/merge_requests/filter_merge_requests_spec.rb b/spec/features/merge_requests/filter_merge_requests_spec.rb index e8085ec36aa..f0019be86ad 100644 --- a/spec/features/merge_requests/filter_merge_requests_spec.rb +++ b/spec/features/merge_requests/filter_merge_requests_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' -describe 'Filter merge requests', feature: true do +describe 'Filter merge requests' do include FilteredSearchHelpers include MergeRequestHelpers - let!(:project) { create(:project) } + let!(:project) { create(:project, :repository) } let!(:group) { create(:group) } let!(:user) { create(:user) } let!(:milestone) { create(:milestone, project: project) } diff --git a/spec/features/merge_requests/form_spec.rb b/spec/features/merge_requests/form_spec.rb index 171386e16ad..6ffb05c5030 100644 --- a/spec/features/merge_requests/form_spec.rb +++ b/spec/features/merge_requests/form_spec.rb @@ -1,13 +1,13 @@ require 'rails_helper' -describe 'New/edit merge request', feature: true, js: true do - let!(:project) { create(:project, visibility_level: Gitlab::VisibilityLevel::PUBLIC) } - let(:fork_project) { create(:project, forked_from_project: project) } - let!(:user) { create(:user)} - let!(:user2) { create(:user)} - let!(:milestone) { create(:milestone, project: project) } - let!(:label) { create(:label, project: project) } - let!(:label2) { create(:label, project: project) } +describe 'New/edit merge request', :js do + let!(:project) { create(:project, :public, :repository) } + let(:fork_project) { create(:project, :repository, forked_from_project: project) } + let!(:user) { create(:user) } + let!(:user2) { create(:user) } + let!(:milestone) { create(:milestone, project: project) } + let!(:label) { create(:label, project: project) } + let!(:label2) { create(:label, project: project) } before do project.team << [user, :master] diff --git a/spec/features/merge_requests/merge_commit_message_toggle_spec.rb b/spec/features/merge_requests/merge_commit_message_toggle_spec.rb index 6cd62ecec72..429bc277d73 100644 --- a/spec/features/merge_requests/merge_commit_message_toggle_spec.rb +++ b/spec/features/merge_requests/merge_commit_message_toggle_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' -feature 'Clicking toggle commit message link', feature: true, js: true do +feature 'Clicking toggle commit message link', js: true do let(:user) { create(:user) } - let(:project) { create(:project, :public) } + let(:project) { create(:project, :public, :repository) } let(:issue_1) { create(:issue, project: project)} let(:issue_2) { create(:issue, project: project)} let(:merge_request) do diff --git a/spec/features/merge_requests/merge_immediately_with_pipeline_spec.rb b/spec/features/merge_requests/merge_immediately_with_pipeline_spec.rb index d3475bee5cc..0b5a595acce 100644 --- a/spec/features/merge_requests/merge_immediately_with_pipeline_spec.rb +++ b/spec/features/merge_requests/merge_immediately_with_pipeline_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' -feature 'Merge immediately', :feature, :js do +feature 'Merge immediately', :js do let(:user) { create(:user) } - let(:project) { create(:project, :public) } + let(:project) { create(:project, :public, :repository) } let!(:merge_request) do create(:merge_request_with_diffs, source_project: project, diff --git a/spec/features/merge_requests/merge_when_pipeline_succeeds_spec.rb b/spec/features/merge_requests/merge_when_pipeline_succeeds_spec.rb index 230b04296b3..574f5fe353e 100644 --- a/spec/features/merge_requests/merge_when_pipeline_succeeds_spec.rb +++ b/spec/features/merge_requests/merge_when_pipeline_succeeds_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' -feature 'Merge When Pipeline Succeeds', :feature, :js do +feature 'Merge When Pipeline Succeeds', :js do let(:user) { create(:user) } - let(:project) { create(:project, :public) } + let(:project) { create(:project, :public, :repository) } let(:merge_request) do create(:merge_request_with_diffs, source_project: project, diff --git a/spec/features/merge_requests/mini_pipeline_graph_spec.rb b/spec/features/merge_requests/mini_pipeline_graph_spec.rb index 4adf72a60b0..b1215f9ba63 100644 --- a/spec/features/merge_requests/mini_pipeline_graph_spec.rb +++ b/spec/features/merge_requests/mini_pipeline_graph_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -feature 'Mini Pipeline Graph', :js, :feature do +feature 'Mini Pipeline Graph', :js do let(:user) { create(:user) } - let(:project) { create(:project, :public) } + let(:project) { create(:project, :public, :repository) } let(:merge_request) { create(:merge_request, source_project: project, head_pipeline: pipeline) } let(:pipeline) { create(:ci_empty_pipeline, project: project, ref: 'master', status: 'running', sha: project.commit.id) } diff --git a/spec/features/merge_requests/only_allow_merge_if_build_succeeds_spec.rb b/spec/features/merge_requests/only_allow_merge_if_build_succeeds_spec.rb index 651cb9d86fb..5c6eec44ff7 100644 --- a/spec/features/merge_requests/only_allow_merge_if_build_succeeds_spec.rb +++ b/spec/features/merge_requests/only_allow_merge_if_build_succeeds_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Only allow merge requests to be merged if the pipeline succeeds', feature: true, js: true do +feature 'Only allow merge requests to be merged if the pipeline succeeds', js: true do let(:merge_request) { create(:merge_request_with_diffs) } let(:project) { merge_request.target_project } diff --git a/spec/features/merge_requests/pipelines_spec.rb b/spec/features/merge_requests/pipelines_spec.rb index 837366ced3c..b3d6cf8deb4 100644 --- a/spec/features/merge_requests/pipelines_spec.rb +++ b/spec/features/merge_requests/pipelines_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Pipelines for Merge Requests', feature: true, js: true do +feature 'Pipelines for Merge Requests', js: true do given(:user) { create(:user) } given(:merge_request) { create(:merge_request) } given(:project) { merge_request.target_project } diff --git a/spec/features/merge_requests/reset_filters_spec.rb b/spec/features/merge_requests/reset_filters_spec.rb index 275f81f50dc..c1b90e5f875 100644 --- a/spec/features/merge_requests/reset_filters_spec.rb +++ b/spec/features/merge_requests/reset_filters_spec.rb @@ -1,11 +1,11 @@ require 'rails_helper' -feature 'Merge requests filter clear button', feature: true, js: true do +feature 'Merge requests filter clear button', js: true do include FilteredSearchHelpers include MergeRequestHelpers include IssueHelpers - let!(:project) { create(:project, :public) } + let!(:project) { create(:project, :public, :repository) } let!(:user) { create(:user) } let!(:milestone) { create(:milestone, project: project) } let!(:bug) { create(:label, project: project, name: 'bug')} diff --git a/spec/features/merge_requests/target_branch_spec.rb b/spec/features/merge_requests/target_branch_spec.rb index 3ed76926eab..9bbf2610bcb 100644 --- a/spec/features/merge_requests/target_branch_spec.rb +++ b/spec/features/merge_requests/target_branch_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'Target branch', feature: true, js: true do +describe 'Target branch', js: true do let(:user) { create(:user) } let(:merge_request) { create(:merge_request) } let(:project) { merge_request.project } diff --git a/spec/features/merge_requests/toggle_whitespace_changes_spec.rb b/spec/features/merge_requests/toggle_whitespace_changes_spec.rb index 912aa34b0c8..dd989fd49b2 100644 --- a/spec/features/merge_requests/toggle_whitespace_changes_spec.rb +++ b/spec/features/merge_requests/toggle_whitespace_changes_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Toggle Whitespace Changes', js: true, feature: true do +feature 'Toggle Whitespace Changes', js: true do before do sign_in(create(:admin)) merge_request = create(:merge_request) diff --git a/spec/features/merge_requests/toggler_behavior_spec.rb b/spec/features/merge_requests/toggler_behavior_spec.rb index 01251105f72..4e5ec9fbd2d 100644 --- a/spec/features/merge_requests/toggler_behavior_spec.rb +++ b/spec/features/merge_requests/toggler_behavior_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' -feature 'toggler_behavior', js: true, feature: true do +feature 'toggler_behavior', js: true do let(:user) { create(:user) } - let(:project) { create(:project) } + let(:project) { create(:project, :repository) } let(:merge_request) { create(:merge_request, source_project: project, author: user) } let(:note) { create(:diff_note_on_merge_request, noteable: merge_request, project: project) } let(:fragment_id) { "#note_#{note.id}" } diff --git a/spec/features/merge_requests/update_merge_requests_spec.rb b/spec/features/merge_requests/update_merge_requests_spec.rb index 43153e2cfa4..cf30a687df8 100644 --- a/spec/features/merge_requests/update_merge_requests_spec.rb +++ b/spec/features/merge_requests/update_merge_requests_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -feature 'Multiple merge requests updating from merge_requests#index', feature: true do +feature 'Multiple merge requests updating from merge_requests#index' do let!(:user) { create(:user)} - let!(:project) { create(:project) } + let!(:project) { create(:project, :repository) } let!(:merge_request) { create(:merge_request, source_project: project, target_project: project) } before do diff --git a/spec/features/merge_requests/user_lists_merge_requests_spec.rb b/spec/features/merge_requests/user_lists_merge_requests_spec.rb index f541f495995..d62b035b40b 100644 --- a/spec/features/merge_requests/user_lists_merge_requests_spec.rb +++ b/spec/features/merge_requests/user_lists_merge_requests_spec.rb @@ -1,10 +1,10 @@ require 'spec_helper' -describe 'Projects > Merge requests > User lists merge requests', feature: true do +describe 'Projects > Merge requests > User lists merge requests' do include MergeRequestHelpers include SortingHelper - let(:project) { create(:project, :public) } + let(:project) { create(:project, :public, :repository) } let(:user) { create(:user) } before do diff --git a/spec/features/merge_requests/user_posts_notes_spec.rb b/spec/features/merge_requests/user_posts_notes_spec.rb index 35ed08e0a5e..74d21822a59 100644 --- a/spec/features/merge_requests/user_posts_notes_spec.rb +++ b/spec/features/merge_requests/user_posts_notes_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe 'Merge requests > User posts notes', :js do include NoteInteractionHelpers - let(:project) { create(:project) } + let(:project) { create(:project, :repository) } let(:merge_request) do create(:merge_request, source_project: project, target_project: project) end diff --git a/spec/features/merge_requests/user_sees_system_notes_spec.rb b/spec/features/merge_requests/user_sees_system_notes_spec.rb index 624a425ae52..03dc61c2efa 100644 --- a/spec/features/merge_requests/user_sees_system_notes_spec.rb +++ b/spec/features/merge_requests/user_sees_system_notes_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' feature 'Merge requests > User sees system notes' do - let(:public_project) { create(:project, :public) } - let(:private_project) { create(:project, :private) } + let(:public_project) { create(:project, :public, :repository) } + let(:private_project) { create(:project, :private, :repository) } let(:issue) { create(:issue, project: private_project) } let(:merge_request) { create(:merge_request, source_project: public_project, source_branch: 'markdown') } let!(:note) { create(:note_on_merge_request, :system, noteable: merge_request, project: public_project, note: "mentioned in #{issue.to_reference(public_project)}") } diff --git a/spec/features/merge_requests/user_uses_slash_commands_spec.rb b/spec/features/merge_requests/user_uses_slash_commands_spec.rb index b2187e01bdb..43cab65d287 100644 --- a/spec/features/merge_requests/user_uses_slash_commands_spec.rb +++ b/spec/features/merge_requests/user_uses_slash_commands_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' -feature 'Merge Requests > User uses quick actions', feature: true, js: true do +feature 'Merge Requests > User uses quick actions', js: true do include QuickActionsHelpers let(:user) { create(:user) } - let(:project) { create(:project, :public) } + let(:project) { create(:project, :public, :repository) } let(:merge_request) { create(:merge_request, source_project: project) } let!(:milestone) { create(:milestone, project: project, title: 'ASAP') } @@ -129,7 +129,7 @@ feature 'Merge Requests > User uses quick actions', feature: true, js: true do end describe '/target_branch command in merge request' do - let(:another_project) { create(:project, :public) } + let(:another_project) { create(:project, :public, :repository) } let(:new_url_opts) { { merge_request: { source_branch: 'feature' } } } before do diff --git a/spec/features/merge_requests/versions_spec.rb b/spec/features/merge_requests/versions_spec.rb index 218d57b49e3..8e231fbc281 100644 --- a/spec/features/merge_requests/versions_spec.rb +++ b/spec/features/merge_requests/versions_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Merge Request versions', js: true, feature: true do +feature 'Merge Request versions', js: true do let(:merge_request) { create(:merge_request, importing: true) } let(:project) { merge_request.source_project } let!(:merge_request_diff1) { merge_request.merge_request_diffs.create(head_commit_sha: '6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9') } diff --git a/spec/features/merge_requests/widget_deployments_spec.rb b/spec/features/merge_requests/widget_deployments_spec.rb index b0fe5f3e1cb..c0221525c9f 100644 --- a/spec/features/merge_requests/widget_deployments_spec.rb +++ b/spec/features/merge_requests/widget_deployments_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Widget Deployments Header', feature: true, js: true do +feature 'Widget Deployments Header', js: true do describe 'when deployed to an environment' do given(:user) { create(:user) } given(:project) { merge_request.target_project } diff --git a/spec/features/merge_requests/widget_spec.rb b/spec/features/merge_requests/widget_spec.rb index 46c558659c7..69e31c7481f 100644 --- a/spec/features/merge_requests/widget_spec.rb +++ b/spec/features/merge_requests/widget_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe 'Merge request', :feature, :js do +describe 'Merge request', :js do let(:user) { create(:user) } - let(:project) { create(:project) } + let(:project) { create(:project, :repository) } let(:merge_request) { create(:merge_request, source_project: project) } before do @@ -200,7 +200,7 @@ describe 'Merge request', :feature, :js do end context 'user can merge into source project but cannot push to fork', js: true do - let(:fork_project) { create(:project, :public) } + let(:fork_project) { create(:project, :public, :repository) } let(:user2) { create(:user) } before do diff --git a/spec/features/merge_requests/wip_message_spec.rb b/spec/features/merge_requests/wip_message_spec.rb index 91cf8fc7218..b422c76249d 100644 --- a/spec/features/merge_requests/wip_message_spec.rb +++ b/spec/features/merge_requests/wip_message_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' -feature 'Work In Progress help message', feature: true do - let!(:project) { create(:project, visibility_level: Gitlab::VisibilityLevel::PUBLIC) } +feature 'Work In Progress help message' do + let!(:project) { create(:project, :public, :repository) } let!(:user) { create(:user) } before do diff --git a/spec/features/milestone_spec.rb b/spec/features/milestone_spec.rb index ce0c27cbe77..1d05184d6fc 100644 --- a/spec/features/milestone_spec.rb +++ b/spec/features/milestone_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature 'Milestone', feature: true do +feature 'Milestone' do let(:group) { create(:group, :public) } let(:project) { create(:empty_project, :public, namespace: group) } let(:user) { create(:user) } diff --git a/spec/features/milestones/show_spec.rb b/spec/features/milestones/show_spec.rb index 626a1f35e62..199a5ba83b3 100644 --- a/spec/features/milestones/show_spec.rb +++ b/spec/features/milestones/show_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'Milestone show', feature: true do +describe 'Milestone show' do let(:user) { create(:user) } let(:project) { create(:empty_project) } let(:milestone) { create(:milestone, project: project) } diff --git a/spec/features/oauth_login_spec.rb b/spec/features/oauth_login_spec.rb index 0064c9ef25e..49d8e52f861 100644 --- a/spec/features/oauth_login_spec.rb +++ b/spec/features/oauth_login_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'OAuth Login', js: true do +feature 'OAuth Login', :js, :allow_forgery_protection do include DeviseHelpers def enter_code(code) diff --git a/spec/features/password_reset_spec.rb b/spec/features/password_reset_spec.rb index 257d363438c..5e1e7dc078f 100644 --- a/spec/features/password_reset_spec.rb +++ b/spec/features/password_reset_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Password reset', feature: true do +feature 'Password reset' do describe 'throttling' do it 'sends reset instructions when not previously sent' do user = create(:user) diff --git a/spec/features/profile_spec.rb b/spec/features/profile_spec.rb index fae11a993b5..672022304da 100644 --- a/spec/features/profile_spec.rb +++ b/spec/features/profile_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'Profile account page', feature: true do +describe 'Profile account page' do let(:user) { create(:user) } before do diff --git a/spec/features/profiles/account_spec.rb b/spec/features/profiles/account_spec.rb index 9d782ecf63b..56c1f7ae9c7 100644 --- a/spec/features/profiles/account_spec.rb +++ b/spec/features/profiles/account_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature 'Profile > Account', feature: true do +feature 'Profile > Account' do given(:user) { create(:user, username: 'foo') } before do @@ -27,7 +27,7 @@ feature 'Profile > Account', feature: true do end context 'with a project' do - given!(:project) { create(:project, namespace: user.namespace, path: 'project') } + given!(:project) { create(:empty_project, namespace: user.namespace) } given(:new_project_path) { "/#{new_username}/#{project.path}" } given(:old_project_path) { "/#{user.username}/#{project.path}" } @@ -43,14 +43,14 @@ feature 'Profile > Account', feature: true do update_username(new_username) visit new_project_path expect(current_path).to eq(new_project_path) - expect(find('h1.project-title')).to have_content(project.name) + expect(find('h1.title')).to have_content(project.path) end scenario 'the old project path redirects to the new path' do update_username(new_username) visit old_project_path expect(current_path).to eq(new_project_path) - expect(find('h1.project-title')).to have_content(project.name) + expect(find('h1.title')).to have_content(project.path) end end end diff --git a/spec/features/profiles/chat_names_spec.rb b/spec/features/profiles/chat_names_spec.rb index e4c236f4c68..35793539e0e 100644 --- a/spec/features/profiles/chat_names_spec.rb +++ b/spec/features/profiles/chat_names_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature 'Profile > Chat', feature: true do +feature 'Profile > Chat' do given(:user) { create(:user) } given(:service) { create(:service) } diff --git a/spec/features/profiles/gpg_keys_spec.rb b/spec/features/profiles/gpg_keys_spec.rb new file mode 100644 index 00000000000..6edc482b47e --- /dev/null +++ b/spec/features/profiles/gpg_keys_spec.rb @@ -0,0 +1,58 @@ +require 'rails_helper' + +feature 'Profile > GPG Keys' do + let(:user) { create(:user, email: GpgHelpers::User2.emails.first) } + + before do + login_as(user) + end + + describe 'User adds a key' do + before do + visit profile_gpg_keys_path + end + + scenario 'saves the new key' do + fill_in('Key', with: GpgHelpers::User2.public_key) + click_button('Add key') + + expect(page).to have_content('bette.cartwright@example.com Verified') + expect(page).to have_content('bette.cartwright@example.net Unverified') + expect(page).to have_content(GpgHelpers::User2.fingerprint) + end + end + + scenario 'User sees their key' do + create(:gpg_key, user: user, key: GpgHelpers::User2.public_key) + visit profile_gpg_keys_path + + expect(page).to have_content('bette.cartwright@example.com Verified') + expect(page).to have_content('bette.cartwright@example.net Unverified') + expect(page).to have_content(GpgHelpers::User2.fingerprint) + end + + scenario 'User removes a key via the key index' do + create(:gpg_key, user: user, key: GpgHelpers::User2.public_key) + visit profile_gpg_keys_path + + click_link('Remove') + + expect(page).to have_content('Your GPG keys (0)') + end + + scenario 'User revokes a key via the key index' do + gpg_key = create :gpg_key, user: user, key: GpgHelpers::User2.public_key + gpg_signature = create :gpg_signature, gpg_key: gpg_key, valid_signature: true + + visit profile_gpg_keys_path + + click_link('Revoke') + + expect(page).to have_content('Your GPG keys (0)') + + expect(gpg_signature.reload).to have_attributes( + valid_signature: false, + gpg_key: nil + ) + end +end diff --git a/spec/features/profiles/keys_spec.rb b/spec/features/profiles/keys_spec.rb index 9439a258a75..6541ea6bf57 100644 --- a/spec/features/profiles/keys_spec.rb +++ b/spec/features/profiles/keys_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature 'Profile > SSH Keys', feature: true do +feature 'Profile > SSH Keys' do let(:user) { create(:user) } before do diff --git a/spec/features/profiles/oauth_applications_spec.rb b/spec/features/profiles/oauth_applications_spec.rb index c7886421c83..45f78444362 100644 --- a/spec/features/profiles/oauth_applications_spec.rb +++ b/spec/features/profiles/oauth_applications_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'Profile > Applications', feature: true do +describe 'Profile > Applications' do let(:user) { create(:user) } before do diff --git a/spec/features/profiles/password_spec.rb b/spec/features/profiles/password_spec.rb index 26d6d6658aa..2c757f99a27 100644 --- a/spec/features/profiles/password_spec.rb +++ b/spec/features/profiles/password_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'Profile > Password', feature: true do +describe 'Profile > Password' do context 'Password authentication enabled' do let(:user) { create(:user, password_automatically_set: true) } diff --git a/spec/features/profiles/personal_access_tokens_spec.rb b/spec/features/profiles/personal_access_tokens_spec.rb index 3c08b6bc091..f3124bbf29e 100644 --- a/spec/features/profiles/personal_access_tokens_spec.rb +++ b/spec/features/profiles/personal_access_tokens_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'Profile > Personal Access Tokens', feature: true, js: true do +describe 'Profile > Personal Access Tokens', js: true do let(:user) { create(:user) } def active_personal_access_tokens diff --git a/spec/features/profiles/preferences_spec.rb b/spec/features/profiles/preferences_spec.rb index 65fed82c256..9123aa9d155 100644 --- a/spec/features/profiles/preferences_spec.rb +++ b/spec/features/profiles/preferences_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'Profile > Preferences', feature: true do +describe 'Profile > Preferences' do let(:user) { create(:user) } before do diff --git a/spec/features/profiles/user_changes_notified_of_own_activity_spec.rb b/spec/features/profiles/user_changes_notified_of_own_activity_spec.rb index 75daef0c38c..6a4173d43e1 100644 --- a/spec/features/profiles/user_changes_notified_of_own_activity_spec.rb +++ b/spec/features/profiles/user_changes_notified_of_own_activity_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Profile > Notifications > User changes notified_of_own_activity setting', feature: true, js: true do +feature 'Profile > Notifications > User changes notified_of_own_activity setting', js: true do let(:user) { create(:user) } before do diff --git a/spec/features/projects/artifacts/browse_spec.rb b/spec/features/projects/artifacts/browse_spec.rb index a34c0c4cecd..f5f7eba8e40 100644 --- a/spec/features/projects/artifacts/browse_spec.rb +++ b/spec/features/projects/artifacts/browse_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' -feature 'Browse artifact', :js, feature: true do - let(:project) { create(:project, :public) } - let(:pipeline) { create(:ci_empty_pipeline, project: project, sha: project.commit.sha, ref: 'master') } +feature 'Browse artifact', :js do + let(:project) { create(:empty_project, :public) } + let(:pipeline) { create(:ci_empty_pipeline, project: project) } let(:job) { create(:ci_build, :artifacts, pipeline: pipeline) } def browse_path(path) diff --git a/spec/features/projects/artifacts/download_spec.rb b/spec/features/projects/artifacts/download_spec.rb index b76f2be880e..c1bba8c15c4 100644 --- a/spec/features/projects/artifacts/download_spec.rb +++ b/spec/features/projects/artifacts/download_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' -feature 'Download artifact', :js, feature: true do - let(:project) { create(:project, :public) } - let(:pipeline) { create(:ci_empty_pipeline, status: :success, project: project, sha: project.commit.sha, ref: 'master') } +feature 'Download artifact', :js do + let(:project) { create(:empty_project, :public) } + let(:pipeline) { create(:ci_empty_pipeline, status: :success, project: project) } let(:job) { create(:ci_build, :artifacts, :success, pipeline: pipeline) } shared_examples 'downloading' do diff --git a/spec/features/projects/artifacts/file_spec.rb b/spec/features/projects/artifacts/file_spec.rb index 6d48470ca3a..4c268b876ea 100644 --- a/spec/features/projects/artifacts/file_spec.rb +++ b/spec/features/projects/artifacts/file_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' -feature 'Artifact file', :js, feature: true do - let(:project) { create(:project, :public) } - let(:pipeline) { create(:ci_empty_pipeline, project: project, sha: project.commit.sha, ref: 'master') } +feature 'Artifact file', :js do + let(:project) { create(:empty_project, :public) } + let(:pipeline) { create(:ci_empty_pipeline, project: project) } let(:build) { create(:ci_build, :artifacts, pipeline: pipeline) } def visit_file(path) diff --git a/spec/features/projects/artifacts/raw_spec.rb b/spec/features/projects/artifacts/raw_spec.rb index 3f38d720a0f..128e39e7803 100644 --- a/spec/features/projects/artifacts/raw_spec.rb +++ b/spec/features/projects/artifacts/raw_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' -feature 'Raw artifact', :js, feature: true do - let(:project) { create(:project, :public) } - let(:pipeline) { create(:ci_empty_pipeline, project: project, sha: project.commit.sha, ref: 'master') } +feature 'Raw artifact', :js do + let(:project) { create(:empty_project, :public) } + let(:pipeline) { create(:ci_empty_pipeline, project: project) } let(:job) { create(:ci_build, :artifacts, pipeline: pipeline) } def raw_path(path) diff --git a/spec/features/projects/badges/coverage_spec.rb b/spec/features/projects/badges/coverage_spec.rb index 5c5a7c96763..8cf4bfbf978 100644 --- a/spec/features/projects/badges/coverage_spec.rb +++ b/spec/features/projects/badges/coverage_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' feature 'test coverage badge' do given!(:user) { create(:user) } - given!(:project) { create(:project, :private) } + given!(:project) { create(:empty_project, :private) } context 'when user has access to view badge' do background do @@ -55,7 +55,7 @@ feature 'test coverage badge' do end def create_pipeline - opts = { project: project, ref: 'master', sha: project.commit.id } + opts = { project: project } create(:ci_pipeline, opts).tap do |pipeline| yield pipeline diff --git a/spec/features/projects/badges/list_spec.rb b/spec/features/projects/badges/list_spec.rb index fd8e9232b02..89ae891037e 100644 --- a/spec/features/projects/badges/list_spec.rb +++ b/spec/features/projects/badges/list_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' feature 'list of badges' do background do user = create(:user) - project = create(:project) + project = create(:project, :repository) project.team << [user, :master] sign_in(user) visit project_pipelines_settings_path(project) diff --git a/spec/features/projects/blobs/blob_line_permalink_updater_spec.rb b/spec/features/projects/blobs/blob_line_permalink_updater_spec.rb index 7564338b301..1160f674974 100644 --- a/spec/features/projects/blobs/blob_line_permalink_updater_spec.rb +++ b/spec/features/projects/blobs/blob_line_permalink_updater_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Blob button line permalinks (BlobLinePermalinkUpdater)', feature: true, js: true do +feature 'Blob button line permalinks (BlobLinePermalinkUpdater)', js: true do include TreeHelper let(:project) { create(:project, :public, :repository) } diff --git a/spec/features/projects/blobs/blob_show_spec.rb b/spec/features/projects/blobs/blob_show_spec.rb index 3427f639930..3d465e709b9 100644 --- a/spec/features/projects/blobs/blob_show_spec.rb +++ b/spec/features/projects/blobs/blob_show_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' -feature 'File blob', :js, feature: true do - let(:project) { create(:project, :public) } +feature 'File blob', :js do + let(:project) { create(:project, :public, :repository) } def visit_blob(path, anchor: nil, ref: 'master') visit project_blob_path(project, File.join(ref, path), anchor: anchor) diff --git a/spec/features/projects/blobs/edit_spec.rb b/spec/features/projects/blobs/edit_spec.rb index c9384a09ccd..9855cfd85c4 100644 --- a/spec/features/projects/blobs/edit_spec.rb +++ b/spec/features/projects/blobs/edit_spec.rb @@ -1,9 +1,9 @@ require 'spec_helper' -feature 'Editing file blob', feature: true, js: true do +feature 'Editing file blob', js: true do include TreeHelper - let(:project) { create(:project, :public, :test_repo) } + let(:project) { create(:project, :public) } let(:merge_request) { create(:merge_request, source_project: project, source_branch: 'feature', target_branch: 'master') } let(:branch) { 'master' } let(:file_path) { project.repository.ls_files(project.repository.root_ref)[1] } diff --git a/spec/features/projects/blobs/shortcuts_blob_spec.rb b/spec/features/projects/blobs/shortcuts_blob_spec.rb index 9cacda84378..1e3080fa319 100644 --- a/spec/features/projects/blobs/shortcuts_blob_spec.rb +++ b/spec/features/projects/blobs/shortcuts_blob_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Blob shortcuts', feature: true do +feature 'Blob shortcuts' do include TreeHelper let(:project) { create(:project, :public, :repository) } let(:path) { project.repository.ls_files(project.repository.root_ref)[0] } diff --git a/spec/features/projects/branches/download_buttons_spec.rb b/spec/features/projects/branches/download_buttons_spec.rb index f01860cc434..ad06cee4e81 100644 --- a/spec/features/projects/branches/download_buttons_spec.rb +++ b/spec/features/projects/branches/download_buttons_spec.rb @@ -1,10 +1,10 @@ require 'spec_helper' -feature 'Download buttons in branches page', feature: true do +feature 'Download buttons in branches page' do given(:user) { create(:user) } given(:role) { :developer } given(:status) { 'success' } - given(:project) { create(:project) } + given(:project) { create(:project, :repository) } given(:pipeline) do create(:ci_pipeline, diff --git a/spec/features/projects/branches/new_branch_ref_dropdown_spec.rb b/spec/features/projects/branches/new_branch_ref_dropdown_spec.rb index 8c35dac0b3d..0be434a567b 100644 --- a/spec/features/projects/branches/new_branch_ref_dropdown_spec.rb +++ b/spec/features/projects/branches/new_branch_ref_dropdown_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' -describe 'New Branch Ref Dropdown', :js, :feature do +describe 'New Branch Ref Dropdown', :js do let(:user) { create(:user) } - let(:project) { create(:project, :public) } + let(:project) { create(:project, :public, :repository) } let(:toggle) { find('.create-from .dropdown-menu-toggle') } before do diff --git a/spec/features/projects/branches_spec.rb b/spec/features/projects/branches_spec.rb index d18cd3d6adc..ad4527a0b74 100644 --- a/spec/features/projects/branches_spec.rb +++ b/spec/features/projects/branches_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' -describe 'Branches', feature: true do +describe 'Branches' do let(:user) { create(:user) } - let(:project) { create(:project, :public) } + let(:project) { create(:project, :public, :repository) } let(:repository) { project.repository } def set_protected_branch_name(branch_name) @@ -29,7 +29,7 @@ describe 'Branches', feature: true do it 'sorts the branches by name' do visit project_branches_path(project) - click_button "Name" # Open sorting dropdown + click_button "Last updated" # Open sorting dropdown click_link "Name" sorted = repository.branches_sorted_by(:name).first(20).map do |branch| @@ -41,7 +41,7 @@ describe 'Branches', feature: true do it 'sorts the branches by last updated' do visit project_branches_path(project) - click_button "Name" # Open sorting dropdown + click_button "Last updated" # Open sorting dropdown click_link "Last updated" sorted = repository.branches_sorted_by(:updated_desc).first(20).map do |branch| @@ -53,7 +53,7 @@ describe 'Branches', feature: true do it 'sorts the branches by oldest updated' do visit project_branches_path(project) - click_button "Name" # Open sorting dropdown + click_button "Last updated" # Open sorting dropdown click_link "Oldest updated" sorted = repository.branches_sorted_by(:updated_asc).first(20).map do |branch| diff --git a/spec/features/projects/commit/builds_spec.rb b/spec/features/projects/commit/builds_spec.rb index 257a7418f16..740331fe42a 100644 --- a/spec/features/projects/commit/builds_spec.rb +++ b/spec/features/projects/commit/builds_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' feature 'project commit pipelines', js: true do - given(:project) { create(:project) } + given(:project) { create(:project, :repository) } background do user = create(:user) diff --git a/spec/features/projects/commit/cherry_pick_spec.rb b/spec/features/projects/commit/cherry_pick_spec.rb index 2d18add82b5..7086f56bb1b 100644 --- a/spec/features/projects/commit/cherry_pick_spec.rb +++ b/spec/features/projects/commit/cherry_pick_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe 'Cherry-pick Commits' do let(:user) { create(:user) } let(:group) { create(:group) } - let(:project) { create(:project, namespace: group) } + let(:project) { create(:project, :repository, namespace: group) } let(:master_pickable_commit) { project.commit('7d3b0f7cff5f37573aea97cebfd5692ea1689924') } let(:master_pickable_merge) { project.commit('e56497bb5f03a90a51293fc6d516788730953899') } diff --git a/spec/features/projects/commit/mini_pipeline_graph_spec.rb b/spec/features/projects/commit/mini_pipeline_graph_spec.rb index a5736b6072a..2ef74e8857c 100644 --- a/spec/features/projects/commit/mini_pipeline_graph_spec.rb +++ b/spec/features/projects/commit/mini_pipeline_graph_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -feature 'Mini Pipeline Graph in Commit View', :js, :feature do +feature 'Mini Pipeline Graph in Commit View', :js do let(:user) { create(:user) } - let(:project) { create(:project, :public) } + let(:project) { create(:project, :public, :repository) } before do sign_in(user) diff --git a/spec/features/projects/compare_spec.rb b/spec/features/projects/compare_spec.rb index 0f48751fa10..82d73fe8531 100644 --- a/spec/features/projects/compare_spec.rb +++ b/spec/features/projects/compare_spec.rb @@ -2,7 +2,7 @@ require "spec_helper" describe "Compare", js: true do let(:user) { create(:user) } - let(:project) { create(:project) } + let(:project) { create(:project, :repository) } before do project.team << [user, :master] diff --git a/spec/features/projects/deploy_keys_spec.rb b/spec/features/projects/deploy_keys_spec.rb index cf3e1ff451e..2d1a9b931b5 100644 --- a/spec/features/projects/deploy_keys_spec.rb +++ b/spec/features/projects/deploy_keys_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'Project deploy keys', :js, :feature do +describe 'Project deploy keys', :js do let(:user) { create(:user) } let(:project) { create(:project_empty_repo) } diff --git a/spec/features/projects/developer_views_empty_project_instructions_spec.rb b/spec/features/projects/developer_views_empty_project_instructions_spec.rb index 1b0d13e07db..7145e286229 100644 --- a/spec/features/projects/developer_views_empty_project_instructions_spec.rb +++ b/spec/features/projects/developer_views_empty_project_instructions_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature 'Developer views empty project instructions', feature: true do +feature 'Developer views empty project instructions' do let(:project) { create(:empty_project, :empty_repo) } let(:developer) { create(:user) } diff --git a/spec/features/projects/diffs/diff_show_spec.rb b/spec/features/projects/diffs/diff_show_spec.rb index 4baccb24806..bc102895aaf 100644 --- a/spec/features/projects/diffs/diff_show_spec.rb +++ b/spec/features/projects/diffs/diff_show_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Diff file viewer', :js, feature: true do +feature 'Diff file viewer', :js do let(:project) { create(:project, :public, :repository) } def visit_commit(sha, anchor: nil) diff --git a/spec/features/projects/edit_spec.rb b/spec/features/projects/edit_spec.rb index 1fca0dde534..4b5436027f9 100644 --- a/spec/features/projects/edit_spec.rb +++ b/spec/features/projects/edit_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -feature 'Project edit', feature: true, js: true do +feature 'Project edit', js: true do let(:user) { create(:user) } - let(:project) { create(:project) } + let(:project) { create(:empty_project) } before do project.team << [user, :master] @@ -20,7 +20,7 @@ feature 'Project edit', feature: true, js: true do end context 'given project with merge_requests_disabled access level' do - let(:project) { create(:project, :merge_requests_disabled) } + let(:project) { create(:empty_project, :merge_requests_disabled) } it 'hides merge requests section' do expect(page).to have_selector('.merge-requests-feature', visible: false) @@ -36,7 +36,7 @@ feature 'Project edit', feature: true, js: true do end context 'given project with builds_disabled access level' do - let(:project) { create(:project, :builds_disabled) } + let(:project) { create(:empty_project, :builds_disabled) } it 'hides builds select section' do expect(page).to have_selector('.builds-feature', visible: false) diff --git a/spec/features/projects/environments/environment_metrics_spec.rb b/spec/features/projects/environments/environment_metrics_spec.rb index cf0dfcfb1f3..82a722c5960 100644 --- a/spec/features/projects/environments/environment_metrics_spec.rb +++ b/spec/features/projects/environments/environment_metrics_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Environment > Metrics', :feature do +feature 'Environment > Metrics' do include PrometheusHelpers given(:user) { create(:user) } diff --git a/spec/features/projects/environments/environment_spec.rb b/spec/features/projects/environments/environment_spec.rb index c31b816f7fb..c6b7e611a5c 100644 --- a/spec/features/projects/environments/environment_spec.rb +++ b/spec/features/projects/environments/environment_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Environment', :feature do +feature 'Environment' do given(:project) { create(:empty_project) } given(:user) { create(:user) } given(:role) { :developer } @@ -205,7 +205,7 @@ feature 'Environment', :feature do end feature 'auto-close environment when branch is deleted' do - given(:project) { create(:project) } + given(:project) { create(:project, :repository) } given!(:environment) do create(:environment, :with_review_app, project: project, diff --git a/spec/features/projects/environments/environments_spec.rb b/spec/features/projects/environments/environments_spec.rb index 99b917cb420..36cf307fbe2 100644 --- a/spec/features/projects/environments/environments_spec.rb +++ b/spec/features/projects/environments/environments_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Environments page', :feature, :js do +feature 'Environments page', :js do given(:project) { create(:empty_project) } given(:user) { create(:user) } given(:role) { :developer } @@ -111,7 +111,7 @@ feature 'Environments page', :feature, :js do end context 'with deployments' do - given(:project) { create(:project) } + given(:project) { create(:project, :repository) } given(:deployment) do create(:deployment, environment: environment, diff --git a/spec/features/projects/features_visibility_spec.rb b/spec/features/projects/features_visibility_spec.rb index 1588f8a828a..37fa61d038e 100644 --- a/spec/features/projects/features_visibility_spec.rb +++ b/spec/features/projects/features_visibility_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' -describe 'Edit Project Settings', feature: true do +describe 'Edit Project Settings' do let(:member) { create(:user) } - let!(:project) { create(:project, :public, path: 'gitlab', name: 'sample') } + let!(:project) { create(:project, :public, :repository) } let!(:issue) { create(:issue, project: project) } let(:non_member) { create(:user) } @@ -249,7 +249,7 @@ describe 'Edit Project Settings', feature: true do # Regression spec for https://gitlab.com/gitlab-org/gitlab-ce/issues/24056 describe 'project statistic visibility' do - let!(:project) { create(:project, :private) } + let!(:project) { create(:empty_project, :private) } before do project.team << [member, :guest] diff --git a/spec/features/projects/files/browse_files_spec.rb b/spec/features/projects/files/browse_files_spec.rb index d9a561b23a2..f62a9edd37e 100644 --- a/spec/features/projects/files/browse_files_spec.rb +++ b/spec/features/projects/files/browse_files_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' -feature 'user browses project', feature: true, js: true do - let(:project) { create(:project) } +feature 'user browses project', js: true do + let(:project) { create(:project, :repository) } let(:user) { create(:user) } before do diff --git a/spec/features/projects/files/creating_a_file_spec.rb b/spec/features/projects/files/creating_a_file_spec.rb index 55350db4c34..e13bf4b6089 100644 --- a/spec/features/projects/files/creating_a_file_spec.rb +++ b/spec/features/projects/files/creating_a_file_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' -feature 'User wants to create a file', feature: true do - let(:project) { create(:project) } +feature 'User wants to create a file' do + let(:project) { create(:project, :repository) } let(:user) { create(:user) } background do diff --git a/spec/features/projects/files/dockerfile_dropdown_spec.rb b/spec/features/projects/files/dockerfile_dropdown_spec.rb index 0cd0c9addd0..cebb238dda1 100644 --- a/spec/features/projects/files/dockerfile_dropdown_spec.rb +++ b/spec/features/projects/files/dockerfile_dropdown_spec.rb @@ -1,10 +1,10 @@ require 'spec_helper' require 'fileutils' -feature 'User wants to add a Dockerfile file', feature: true do +feature 'User wants to add a Dockerfile file' do before do user = create(:user) - project = create(:project) + project = create(:project, :repository) project.team << [user, :master] sign_in user diff --git a/spec/features/projects/files/download_buttons_spec.rb b/spec/features/projects/files/download_buttons_spec.rb index a2874483149..d2382d55c0b 100644 --- a/spec/features/projects/files/download_buttons_spec.rb +++ b/spec/features/projects/files/download_buttons_spec.rb @@ -1,10 +1,10 @@ require 'spec_helper' -feature 'Download buttons in files tree', feature: true do +feature 'Download buttons in files tree' do given(:user) { create(:user) } given(:role) { :developer } given(:status) { 'success' } - given(:project) { create(:project) } + given(:project) { create(:project, :repository) } given(:pipeline) do create(:ci_pipeline, diff --git a/spec/features/projects/files/edit_file_soft_wrap_spec.rb b/spec/features/projects/files/edit_file_soft_wrap_spec.rb index 930e4cf488a..c7e3f657639 100644 --- a/spec/features/projects/files/edit_file_soft_wrap_spec.rb +++ b/spec/features/projects/files/edit_file_soft_wrap_spec.rb @@ -1,9 +1,9 @@ require 'spec_helper' -feature 'User uses soft wrap whilst editing file', feature: true, js: true do +feature 'User uses soft wrap whilst editing file', js: true do before do user = create(:user) - project = create(:project) + project = create(:project, :repository) project.team << [user, :master] sign_in user visit project_new_blob_path(project, 'master', file_name: 'test_file-name') diff --git a/spec/features/projects/files/editing_a_file_spec.rb b/spec/features/projects/files/editing_a_file_spec.rb index c295380dfc9..20be968e89f 100644 --- a/spec/features/projects/files/editing_a_file_spec.rb +++ b/spec/features/projects/files/editing_a_file_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' -feature 'User wants to edit a file', feature: true do - let(:project) { create(:project) } +feature 'User wants to edit a file' do + let(:project) { create(:project, :repository) } let(:user) { create(:user) } let(:commit_params) do { diff --git a/spec/features/projects/files/files_sort_submodules_with_folders_spec.rb b/spec/features/projects/files/files_sort_submodules_with_folders_spec.rb index 9a1eaee08de..702b99de733 100644 --- a/spec/features/projects/files/files_sort_submodules_with_folders_spec.rb +++ b/spec/features/projects/files/files_sort_submodules_with_folders_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'User views files page', feature: true do +feature 'User views files page' do let(:user) { create(:user) } let(:project) { create(:forked_project_with_submodules) } diff --git a/spec/features/projects/files/find_file_keyboard_spec.rb b/spec/features/projects/files/find_file_keyboard_spec.rb index 772f81c8853..7f97fdb8cc9 100644 --- a/spec/features/projects/files/find_file_keyboard_spec.rb +++ b/spec/features/projects/files/find_file_keyboard_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' -feature 'Find file keyboard shortcuts', feature: true, js: true do +feature 'Find file keyboard shortcuts', js: true do let(:user) { create(:user) } - let(:project) { create(:project) } + let(:project) { create(:project, :repository) } before do project.team << [user, :master] diff --git a/spec/features/projects/files/find_files_spec.rb b/spec/features/projects/files/find_files_spec.rb index 7a99596585f..57d67b28920 100644 --- a/spec/features/projects/files/find_files_spec.rb +++ b/spec/features/projects/files/find_files_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' -feature 'Find files button in the tree header', feature: true do +feature 'Find files button in the tree header' do given(:user) { create(:user) } - given(:project) { create(:project) } + given(:project) { create(:project, :repository) } background do sign_in(user) diff --git a/spec/features/projects/files/gitignore_dropdown_spec.rb b/spec/features/projects/files/gitignore_dropdown_spec.rb index a3a7b08c013..e2044c9d5aa 100644 --- a/spec/features/projects/files/gitignore_dropdown_spec.rb +++ b/spec/features/projects/files/gitignore_dropdown_spec.rb @@ -1,9 +1,9 @@ require 'spec_helper' -feature 'User wants to add a .gitignore file', feature: true do +feature 'User wants to add a .gitignore file' do before do user = create(:user) - project = create(:project) + project = create(:project, :repository) project.team << [user, :master] sign_in user visit project_new_blob_path(project, 'master', file_name: '.gitignore') diff --git a/spec/features/projects/files/gitlab_ci_yml_dropdown_spec.rb b/spec/features/projects/files/gitlab_ci_yml_dropdown_spec.rb index 41afe8014d9..ab242b0b0b5 100644 --- a/spec/features/projects/files/gitlab_ci_yml_dropdown_spec.rb +++ b/spec/features/projects/files/gitlab_ci_yml_dropdown_spec.rb @@ -1,9 +1,9 @@ require 'spec_helper' -feature 'User wants to add a .gitlab-ci.yml file', feature: true do +feature 'User wants to add a .gitlab-ci.yml file' do before do user = create(:user) - project = create(:project) + project = create(:project, :repository) project.team << [user, :master] sign_in user visit project_new_blob_path(project, 'master', file_name: '.gitlab-ci.yml') diff --git a/spec/features/projects/files/project_owner_creates_license_file_spec.rb b/spec/features/projects/files/project_owner_creates_license_file_spec.rb index 57f4a6f1b6f..95af263bcac 100644 --- a/spec/features/projects/files/project_owner_creates_license_file_spec.rb +++ b/spec/features/projects/files/project_owner_creates_license_file_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' -feature 'project owner creates a license file', feature: true, js: true do +feature 'project owner creates a license file', js: true do let(:project_master) { create(:user) } - let(:project) { create(:project) } + let(:project) { create(:project, :repository) } background do project.repository.delete_file(project_master, 'LICENSE', message: 'Remove LICENSE', branch_name: 'master') diff --git a/spec/features/projects/files/project_owner_sees_link_to_create_license_file_in_empty_project_spec.rb b/spec/features/projects/files/project_owner_sees_link_to_create_license_file_in_empty_project_spec.rb index 0604ecb8c8b..1f4b3763b40 100644 --- a/spec/features/projects/files/project_owner_sees_link_to_create_license_file_in_empty_project_spec.rb +++ b/spec/features/projects/files/project_owner_sees_link_to_create_license_file_in_empty_project_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'project owner sees a link to create a license file in empty project', feature: true, js: true do +feature 'project owner sees a link to create a license file in empty project', js: true do let(:project_master) { create(:user) } let(:project) { create(:empty_project) } background do diff --git a/spec/features/projects/files/template_type_dropdown_spec.rb b/spec/features/projects/files/template_type_dropdown_spec.rb index a0846643269..48003eeaa87 100644 --- a/spec/features/projects/files/template_type_dropdown_spec.rb +++ b/spec/features/projects/files/template_type_dropdown_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' feature 'Template type dropdown selector', js: true do - let(:project) { create(:project) } + let(:project) { create(:project, :repository) } let(:user) { create(:user) } before do diff --git a/spec/features/projects/files/undo_template_spec.rb b/spec/features/projects/files/undo_template_spec.rb index d50ddb1f1a9..4238d25e9ee 100644 --- a/spec/features/projects/files/undo_template_spec.rb +++ b/spec/features/projects/files/undo_template_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' feature 'Template Undo Button', js: true do - let(:project) { create(:project) } + let(:project) { create(:project, :repository) } let(:user) { create(:user) } before do diff --git a/spec/features/projects/gfm_autocomplete_load_spec.rb b/spec/features/projects/gfm_autocomplete_load_spec.rb index aa2306069ad..b63e5ae46ee 100644 --- a/spec/features/projects/gfm_autocomplete_load_spec.rb +++ b/spec/features/projects/gfm_autocomplete_load_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' -describe 'GFM autocomplete loading', feature: true, js: true do - let(:project) { create(:project) } +describe 'GFM autocomplete loading', js: true do + let(:project) { create(:empty_project) } before do sign_in(create(:admin)) diff --git a/spec/features/projects/group_links_spec.rb b/spec/features/projects/group_links_spec.rb index 631955a60a1..698baad97ff 100644 --- a/spec/features/projects/group_links_spec.rb +++ b/spec/features/projects/group_links_spec.rb @@ -1,10 +1,10 @@ require 'spec_helper' -feature 'Project group links', :feature, :js do +feature 'Project group links', :js do include Select2Helper let(:master) { create(:user) } - let(:project) { create(:project) } + let(:project) { create(:empty_project) } let!(:group) { create(:group) } background do @@ -35,7 +35,7 @@ feature 'Project group links', :feature, :js do context 'nested group project' do let!(:nested_group) { create(:group, parent: group) } let!(:another_group) { create(:group) } - let!(:project) { create(:project, namespace: nested_group) } + let!(:project) { create(:empty_project, namespace: nested_group) } background do group.add_master(master) diff --git a/spec/features/projects/import_export/export_file_spec.rb b/spec/features/projects/import_export/export_file_spec.rb index 43c2c401f4a..62d244ff259 100644 --- a/spec/features/projects/import_export/export_file_spec.rb +++ b/spec/features/projects/import_export/export_file_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' # It looks up for any sensitive word inside the JSON, so if a sensitive word is found # we''l have to either include it adding the model that includes it to the +safe_list+ # or make sure the attribute is blacklisted in the +import_export.yml+ configuration -feature 'Import/Export - project export integration test', feature: true, js: true do +feature 'Import/Export - project export integration test', js: true do include Select2Helper include ExportFileHelper diff --git a/spec/features/projects/import_export/import_file_spec.rb b/spec/features/projects/import_export/import_file_spec.rb index 533ff4612ff..f924725870b 100644 --- a/spec/features/projects/import_export/import_file_spec.rb +++ b/spec/features/projects/import_export/import_file_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Import/Export - project import integration test', feature: true, js: true do +feature 'Import/Export - project import integration test', js: true do include Select2Helper let(:file) { File.join(Rails.root, 'spec', 'features', 'projects', 'import_export', 'test_project_export.tar.gz') } @@ -46,7 +46,7 @@ feature 'Import/Export - project import integration test', feature: true, js: tr end scenario 'invalid project' do - project = create(:project, namespace: namespace) + project = create(:empty_project, namespace: namespace) visit new_project_path @@ -62,7 +62,7 @@ feature 'Import/Export - project import integration test', feature: true, js: tr end scenario 'project with no name' do - create(:project, namespace: namespace) + create(:empty_project, namespace: namespace) visit new_project_path diff --git a/spec/features/projects/import_export/namespace_export_file_spec.rb b/spec/features/projects/import_export/namespace_export_file_spec.rb index 74ced0d3b35..3917e72c39e 100644 --- a/spec/features/projects/import_export/namespace_export_file_spec.rb +++ b/spec/features/projects/import_export/namespace_export_file_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Import/Export - Namespace export file cleanup', feature: true, js: true do +feature 'Import/Export - Namespace export file cleanup', js: true do let(:export_path) { "#{Dir.tmpdir}/import_file_spec" } let(:config_hash) { YAML.load_file(Gitlab::ImportExport.config_file).deep_stringify_keys } diff --git a/spec/features/projects/issuable_templates_spec.rb b/spec/features/projects/issuable_templates_spec.rb index 88bb678362b..d2789d0aa52 100644 --- a/spec/features/projects/issuable_templates_spec.rb +++ b/spec/features/projects/issuable_templates_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' -feature 'issuable templates', feature: true, js: true do +feature 'issuable templates', js: true do let(:user) { create(:user) } - let(:project) { create(:project, :public) } + let(:project) { create(:project, :public, :repository) } before do project.team << [user, :master] @@ -120,7 +120,7 @@ feature 'issuable templates', feature: true, js: true do context 'user creates a merge request from a forked project using templates' do let(:template_content) { 'this is a test "feature-proposal" template' } let(:fork_user) { create(:user) } - let(:fork_project) { create(:project, :public) } + let(:fork_project) { create(:project, :public, :repository) } let(:merge_request) { create(:merge_request, :with_diffs, source_project: fork_project, target_project: project) } background do diff --git a/spec/features/projects/jobs_spec.rb b/spec/features/projects/jobs_spec.rb index 411987573fa..037ac00d39f 100644 --- a/spec/features/projects/jobs_spec.rb +++ b/spec/features/projects/jobs_spec.rb @@ -1,10 +1,10 @@ require 'spec_helper' require 'tempfile' -feature 'Jobs', :feature do +feature 'Jobs' do let(:user) { create(:user) } let(:user_access_level) { :developer } - let(:project) { create(:project) } + let(:project) { create(:project, :repository) } let(:pipeline) { create(:ci_pipeline, project: project) } let(:job) { create(:ci_build, :trace, pipeline: pipeline) } diff --git a/spec/features/projects/labels/issues_sorted_by_priority_spec.rb b/spec/features/projects/labels/issues_sorted_by_priority_spec.rb index 652008bae73..2b0aead440c 100644 --- a/spec/features/projects/labels/issues_sorted_by_priority_spec.rb +++ b/spec/features/projects/labels/issues_sorted_by_priority_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' -feature 'Issue prioritization', feature: true do +feature 'Issue prioritization' do let(:user) { create(:user) } - let(:project) { create(:project, name: 'test', namespace: user.namespace) } + let(:project) { create(:empty_project, name: 'test', namespace: user.namespace) } # Labels let(:label_1) { create(:label, title: 'label_1', project: project, priority: 1) } diff --git a/spec/features/projects/labels/subscription_spec.rb b/spec/features/projects/labels/subscription_spec.rb index 58421e11e0a..3115a643d5d 100644 --- a/spec/features/projects/labels/subscription_spec.rb +++ b/spec/features/projects/labels/subscription_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Labels subscription', feature: true do +feature 'Labels subscription' do let(:user) { create(:user) } let(:group) { create(:group) } let(:project) { create(:empty_project, :public, namespace: group) } diff --git a/spec/features/projects/labels/update_prioritization_spec.rb b/spec/features/projects/labels/update_prioritization_spec.rb index 61f6d734ed3..223f94ff9f9 100644 --- a/spec/features/projects/labels/update_prioritization_spec.rb +++ b/spec/features/projects/labels/update_prioritization_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Prioritize labels', feature: true do +feature 'Prioritize labels' do include DragTo let(:user) { create(:user) } @@ -114,6 +114,12 @@ feature 'Prioritize labels', feature: true do expect(page.all('li').last).to have_content('bug') end end + + it 'shows a help message about prioritized labels' do + visit project_labels_path(project) + + expect(page).to have_content 'Star a label' + end end context 'as a guest' do @@ -128,6 +134,7 @@ feature 'Prioritize labels', feature: true do expect(page).to have_content 'wontfix' expect(page).to have_content 'feature' expect(page).not_to have_css('.prioritized-labels') + expect(page).not_to have_content 'Star a label' end end @@ -139,6 +146,7 @@ feature 'Prioritize labels', feature: true do expect(page).to have_content 'wontfix' expect(page).to have_content 'feature' expect(page).not_to have_css('.prioritized-labels') + expect(page).not_to have_content 'Star a label' end end end diff --git a/spec/features/projects/main/download_buttons_spec.rb b/spec/features/projects/main/download_buttons_spec.rb index 8b952d2f3a5..3f2579bb01a 100644 --- a/spec/features/projects/main/download_buttons_spec.rb +++ b/spec/features/projects/main/download_buttons_spec.rb @@ -1,10 +1,10 @@ require 'spec_helper' -feature 'Download buttons in project main page', feature: true do +feature 'Download buttons in project main page' do given(:user) { create(:user) } given(:role) { :developer } given(:status) { 'success' } - given(:project) { create(:project) } + given(:project) { create(:project, :repository) } given(:pipeline) do create(:ci_pipeline, diff --git a/spec/features/projects/members/anonymous_user_sees_members_spec.rb b/spec/features/projects/members/anonymous_user_sees_members_spec.rb index 28c8d20aad5..a26e7becdb9 100644 --- a/spec/features/projects/members/anonymous_user_sees_members_spec.rb +++ b/spec/features/projects/members/anonymous_user_sees_members_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Projects > Members > Anonymous user sees members', feature: true do +feature 'Projects > Members > Anonymous user sees members' do let(:user) { create(:user) } let(:group) { create(:group, :public) } let(:project) { create(:empty_project, :public) } diff --git a/spec/features/projects/members/group_links_spec.rb b/spec/features/projects/members/group_links_spec.rb index b9154915b34..acda5808313 100644 --- a/spec/features/projects/members/group_links_spec.rb +++ b/spec/features/projects/members/group_links_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Projects > Members > Anonymous user sees members', feature: true, js: true do +feature 'Projects > Members > Anonymous user sees members', js: true do let(:user) { create(:user) } let(:group) { create(:group, :public) } let(:project) { create(:empty_project, :public) } diff --git a/spec/features/projects/members/group_member_cannot_leave_group_project_spec.rb b/spec/features/projects/members/group_member_cannot_leave_group_project_spec.rb index 2c99c2c7888..1fb5e000239 100644 --- a/spec/features/projects/members/group_member_cannot_leave_group_project_spec.rb +++ b/spec/features/projects/members/group_member_cannot_leave_group_project_spec.rb @@ -1,9 +1,9 @@ require 'spec_helper' -feature 'Projects > Members > Group member cannot leave group project', feature: true do +feature 'Projects > Members > Group member cannot leave group project' do let(:user) { create(:user) } let(:group) { create(:group) } - let(:project) { create(:project, namespace: group) } + let(:project) { create(:empty_project, namespace: group) } background do group.add_developer(user) diff --git a/spec/features/projects/members/group_member_cannot_request_access_to_his_group_project_spec.rb b/spec/features/projects/members/group_member_cannot_request_access_to_his_group_project_spec.rb index 35142273eae..8e3520f9f15 100644 --- a/spec/features/projects/members/group_member_cannot_request_access_to_his_group_project_spec.rb +++ b/spec/features/projects/members/group_member_cannot_request_access_to_his_group_project_spec.rb @@ -1,9 +1,9 @@ require 'spec_helper' -feature 'Projects > Members > Group member cannot request access to his group project', feature: true do +feature 'Projects > Members > Group member cannot request access to his group project' do let(:user) { create(:user) } let(:group) { create(:group) } - let(:project) { create(:project, namespace: group) } + let(:project) { create(:empty_project, namespace: group) } scenario 'owner does not see the request access button' do group.add_owner(user) diff --git a/spec/features/projects/members/group_members_spec.rb b/spec/features/projects/members/group_members_spec.rb index bfc604bb8d6..154f9f4a26c 100644 --- a/spec/features/projects/members/group_members_spec.rb +++ b/spec/features/projects/members/group_members_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Projects members', feature: true do +feature 'Projects members' do let(:user) { create(:user) } let(:developer) { create(:user) } let(:group) { create(:group, :public, :access_requestable) } diff --git a/spec/features/projects/members/group_requester_cannot_request_access_to_project_spec.rb b/spec/features/projects/members/group_requester_cannot_request_access_to_project_spec.rb index 46f5744b32d..6865d721201 100644 --- a/spec/features/projects/members/group_requester_cannot_request_access_to_project_spec.rb +++ b/spec/features/projects/members/group_requester_cannot_request_access_to_project_spec.rb @@ -1,10 +1,10 @@ require 'spec_helper' -feature 'Projects > Members > Group requester cannot request access to project', feature: true, js: true do +feature 'Projects > Members > Group requester cannot request access to project', js: true do let(:user) { create(:user) } let(:owner) { create(:user) } let(:group) { create(:group, :public, :access_requestable) } - let(:project) { create(:project, :public, :access_requestable, namespace: group) } + let(:project) { create(:empty_project, :public, :access_requestable, namespace: group) } background do group.add_owner(owner) diff --git a/spec/features/projects/members/list_spec.rb b/spec/features/projects/members/list_spec.rb index 301f68a67d3..f9c54d267b5 100644 --- a/spec/features/projects/members/list_spec.rb +++ b/spec/features/projects/members/list_spec.rb @@ -1,12 +1,12 @@ require 'spec_helper' -feature 'Project members list', feature: true do +feature 'Project members list' do include Select2Helper let(:user1) { create(:user, name: 'John Doe') } let(:user2) { create(:user, name: 'Mary Jane') } let(:group) { create(:group) } - let(:project) { create(:project, namespace: group) } + let(:project) { create(:empty_project, namespace: group) } background do sign_in(user1) diff --git a/spec/features/projects/members/master_adds_member_with_expiration_date_spec.rb b/spec/features/projects/members/master_adds_member_with_expiration_date_spec.rb index 14edfb6e673..b4381ea373e 100644 --- a/spec/features/projects/members/master_adds_member_with_expiration_date_spec.rb +++ b/spec/features/projects/members/master_adds_member_with_expiration_date_spec.rb @@ -1,11 +1,11 @@ require 'spec_helper' -feature 'Projects > Members > Master adds member with expiration date', feature: true, js: true do +feature 'Projects > Members > Master adds member with expiration date', js: true do include Select2Helper include ActiveSupport::Testing::TimeHelpers let(:master) { create(:user) } - let(:project) { create(:project) } + let(:project) { create(:empty_project) } let!(:new_member) { create(:user) } background do diff --git a/spec/features/projects/members/master_manages_access_requests_spec.rb b/spec/features/projects/members/master_manages_access_requests_spec.rb index a359c209556..0f96a7cc70d 100644 --- a/spec/features/projects/members/master_manages_access_requests_spec.rb +++ b/spec/features/projects/members/master_manages_access_requests_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Projects > Members > Master manages access requests', feature: true do +feature 'Projects > Members > Master manages access requests' do let(:user) { create(:user) } let(:master) { create(:user) } let(:project) { create(:empty_project, :public, :access_requestable) } diff --git a/spec/features/projects/members/member_cannot_request_access_to_his_project_spec.rb b/spec/features/projects/members/member_cannot_request_access_to_his_project_spec.rb index 55852012bae..7f39f5b2513 100644 --- a/spec/features/projects/members/member_cannot_request_access_to_his_project_spec.rb +++ b/spec/features/projects/members/member_cannot_request_access_to_his_project_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' -feature 'Projects > Members > Member cannot request access to his project', feature: true do +feature 'Projects > Members > Member cannot request access to his project' do let(:member) { create(:user) } - let(:project) { create(:project) } + let(:project) { create(:empty_project) } background do project.team << [member, :developer] diff --git a/spec/features/projects/members/member_leaves_project_spec.rb b/spec/features/projects/members/member_leaves_project_spec.rb index 3de13aee0ee..1bcf827d33c 100644 --- a/spec/features/projects/members/member_leaves_project_spec.rb +++ b/spec/features/projects/members/member_leaves_project_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' -feature 'Projects > Members > Member leaves project', feature: true do +feature 'Projects > Members > Member leaves project' do let(:user) { create(:user) } - let(:project) { create(:project) } + let(:project) { create(:project, :repository) } background do project.team << [user, :developer] diff --git a/spec/features/projects/members/owner_cannot_leave_project_spec.rb b/spec/features/projects/members/owner_cannot_leave_project_spec.rb index fae52325be0..8b6d0aafcf8 100644 --- a/spec/features/projects/members/owner_cannot_leave_project_spec.rb +++ b/spec/features/projects/members/owner_cannot_leave_project_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' -feature 'Projects > Members > Owner cannot leave project', feature: true do - let(:project) { create(:project) } +feature 'Projects > Members > Owner cannot leave project' do + let(:project) { create(:empty_project) } background do sign_in(project.owner) diff --git a/spec/features/projects/members/owner_cannot_request_access_to_his_project_spec.rb b/spec/features/projects/members/owner_cannot_request_access_to_his_project_spec.rb index a7a5e01465f..d838af6d976 100644 --- a/spec/features/projects/members/owner_cannot_request_access_to_his_project_spec.rb +++ b/spec/features/projects/members/owner_cannot_request_access_to_his_project_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' -feature 'Projects > Members > Owner cannot request access to his project', feature: true do - let(:project) { create(:project) } +feature 'Projects > Members > Owner cannot request access to his project' do + let(:project) { create(:empty_project) } background do sign_in(project.owner) diff --git a/spec/features/projects/members/sorting_spec.rb b/spec/features/projects/members/sorting_spec.rb index dc7236fa120..45c2647e6e2 100644 --- a/spec/features/projects/members/sorting_spec.rb +++ b/spec/features/projects/members/sorting_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Projects > Members > Sorting', feature: true do +feature 'Projects > Members > Sorting' do let(:master) { create(:user, name: 'John Doe') } let(:developer) { create(:user, name: 'Mary Jane', last_sign_in_at: 5.days.ago) } let(:project) { create(:empty_project, namespace: master.namespace, creator: master) } diff --git a/spec/features/projects/members/user_requests_access_spec.rb b/spec/features/projects/members/user_requests_access_spec.rb index ab86e2da4f6..24c9f708456 100644 --- a/spec/features/projects/members/user_requests_access_spec.rb +++ b/spec/features/projects/members/user_requests_access_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' -feature 'Projects > Members > User requests access', feature: true do +feature 'Projects > Members > User requests access' do let(:user) { create(:user) } - let(:project) { create(:project, :public, :access_requestable) } + let(:project) { create(:project, :public, :access_requestable, :repository) } let(:master) { project.owner } background do diff --git a/spec/features/projects/merge_request_button_spec.rb b/spec/features/projects/merge_request_button_spec.rb index 8cbd26551bc..85d518c0cc3 100644 --- a/spec/features/projects/merge_request_button_spec.rb +++ b/spec/features/projects/merge_request_button_spec.rb @@ -3,8 +3,8 @@ require 'spec_helper' feature 'Merge Request button' do shared_examples 'Merge request button only shown when allowed' do let(:user) { create(:user) } - let(:project) { create(:project, :public) } - let(:forked_project) { create(:project, :public, forked_from_project: project) } + let(:project) { create(:project, :public, :repository) } + let(:forked_project) { create(:project, :public, :repository, forked_from_project: project) } context 'not logged in' do it 'does not show Create merge request button' do diff --git a/spec/features/projects/merge_requests/list_spec.rb b/spec/features/projects/merge_requests/list_spec.rb index 6548b4b83e6..a879efef4b5 100644 --- a/spec/features/projects/merge_requests/list_spec.rb +++ b/spec/features/projects/merge_requests/list_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' feature 'Merge Requests List' do let(:user) { create(:user) } - let(:project) { create(:project) } + let(:project) { create(:project, :repository) } background do project.team << [user, :developer] diff --git a/spec/features/projects/milestones/milestone_spec.rb b/spec/features/projects/milestones/milestone_spec.rb index 642ca7448a3..b1c38ecc9ab 100644 --- a/spec/features/projects/milestones/milestone_spec.rb +++ b/spec/features/projects/milestones/milestone_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Project milestone', :feature do +feature 'Project milestone' do let(:user) { create(:user) } let(:project) { create(:empty_project, name: 'test', namespace: user.namespace) } let(:milestone) { create(:milestone, project: project) } diff --git a/spec/features/projects/milestones/milestones_sorting_spec.rb b/spec/features/projects/milestones/milestones_sorting_spec.rb index 53cd2711666..4bd1929ac1e 100644 --- a/spec/features/projects/milestones/milestones_sorting_spec.rb +++ b/spec/features/projects/milestones/milestones_sorting_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Milestones sorting', :feature, :js do +feature 'Milestones sorting', :js do include SortingHelper let(:user) { create(:user) } let(:project) { create(:empty_project, name: 'test', namespace: user.namespace) } diff --git a/spec/features/projects/milestones/new_spec.rb b/spec/features/projects/milestones/new_spec.rb index 3c81db502bc..7cfcccda439 100644 --- a/spec/features/projects/milestones/new_spec.rb +++ b/spec/features/projects/milestones/new_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Creating a new project milestone', :feature, :js do +feature 'Creating a new project milestone', :js do let(:user) { create(:user) } let(:project) { create(:empty_project, name: 'test', namespace: user.namespace) } diff --git a/spec/features/projects/no_password_spec.rb b/spec/features/projects/no_password_spec.rb index d22a6daac08..6aff079dd39 100644 --- a/spec/features/projects/no_password_spec.rb +++ b/spec/features/projects/no_password_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' feature 'No Password Alert' do - let(:project) { create(:project, namespace: user.namespace) } + let(:project) { create(:project, :repository, namespace: user.namespace) } context 'with internal auth enabled' do before do diff --git a/spec/features/projects/pages_spec.rb b/spec/features/projects/pages_spec.rb index a8593709f1b..42f23ee5dec 100644 --- a/spec/features/projects/pages_spec.rb +++ b/spec/features/projects/pages_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Pages', feature: true do +feature 'Pages' do given(:project) { create(:empty_project) } given(:user) { create(:user) } given(:role) { :master } diff --git a/spec/features/projects/pipeline_schedules_spec.rb b/spec/features/projects/pipeline_schedules_spec.rb index de6dd8fc8a6..605415d2af4 100644 --- a/spec/features/projects/pipeline_schedules_spec.rb +++ b/spec/features/projects/pipeline_schedules_spec.rb @@ -1,9 +1,9 @@ require 'spec_helper' -feature 'Pipeline Schedules', :feature, js: true do +feature 'Pipeline Schedules', :js do include PipelineSchedulesHelper - let!(:project) { create(:project) } + let!(:project) { create(:project, :repository) } let!(:pipeline_schedule) { create(:ci_pipeline_schedule, :nightly, project: project ) } let!(:pipeline) { create(:ci_pipeline, pipeline_schedule: pipeline_schedule) } let(:scope) { nil } diff --git a/spec/features/projects/pipelines/pipeline_spec.rb b/spec/features/projects/pipelines/pipeline_spec.rb index 4a08d9088aa..0b626749275 100644 --- a/spec/features/projects/pipelines/pipeline_spec.rb +++ b/spec/features/projects/pipelines/pipeline_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'Pipeline', :feature, :js do +describe 'Pipeline', :js do let(:project) { create(:empty_project) } let(:user) { create(:user) } @@ -42,7 +42,7 @@ describe 'Pipeline', :feature, :js do describe 'GET /:project/pipelines/:id' do include_context 'pipeline builds' - let(:project) { create(:project) } + let(:project) { create(:project, :repository) } let(:pipeline) { create(:ci_pipeline, project: project, ref: 'master', sha: project.commit.id, user: user) } before do @@ -188,7 +188,7 @@ describe 'Pipeline', :feature, :js do describe 'GET /:project/pipelines/:id/builds' do include_context 'pipeline builds' - let(:project) { create(:project) } + let(:project) { create(:project, :repository) } let(:pipeline) { create(:ci_pipeline, project: project, ref: 'master', sha: project.commit.id) } before do @@ -262,7 +262,7 @@ describe 'Pipeline', :feature, :js do end describe 'GET /:project/pipelines/:id/failures' do - let(:project) { create(:project) } + let(:project) { create(:project, :repository) } let(:pipeline) { create(:ci_pipeline, project: project, ref: 'master', sha: project.commit.id) } let(:pipeline_failures_page) { failures_project_pipeline_path(project, pipeline) } let!(:failed_build) { create(:ci_build, :failed, pipeline: pipeline) } diff --git a/spec/features/projects/pipelines/pipelines_spec.rb b/spec/features/projects/pipelines/pipelines_spec.rb index d776fbc2b12..59dff22eca3 100644 --- a/spec/features/projects/pipelines/pipelines_spec.rb +++ b/spec/features/projects/pipelines/pipelines_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'Pipelines', :feature, :js do +describe 'Pipelines', :js do let(:project) { create(:empty_project) } context 'when user is logged in' do @@ -12,7 +12,7 @@ describe 'Pipelines', :feature, :js do end describe 'GET /:project/pipelines' do - let(:project) { create(:project) } + let(:project) { create(:project, :repository) } let!(:pipeline) do create( @@ -385,7 +385,7 @@ describe 'Pipelines', :feature, :js do end describe 'GET /:project/pipelines/show' do - let(:project) { create(:project) } + let(:project) { create(:project, :repository) } let(:pipeline) do create(:ci_empty_pipeline, @@ -437,7 +437,7 @@ describe 'Pipelines', :feature, :js do end describe 'POST /:project/pipelines' do - let(:project) { create(:project) } + let(:project) { create(:project, :repository) } before do visit new_project_pipeline_path(project) @@ -476,7 +476,7 @@ describe 'Pipelines', :feature, :js do end describe 'Create pipelines' do - let(:project) { create(:project) } + let(:project) { create(:project, :repository) } before do visit new_project_pipeline_path(project) @@ -512,14 +512,14 @@ describe 'Pipelines', :feature, :js do end context 'when project is public' do - let(:project) { create(:project, :public) } + let(:project) { create(:project, :public, :repository) } it { expect(page).to have_content 'Build with confidence' } it { expect(page).to have_http_status(:success) } end context 'when project is private' do - let(:project) { create(:project, :private) } + let(:project) { create(:project, :private, :repository) } it { expect(page).to have_content 'You need to sign in' } end diff --git a/spec/features/projects/project_settings_spec.rb b/spec/features/projects/project_settings_spec.rb index 89d227eb98f..6001bcfff0a 100644 --- a/spec/features/projects/project_settings_spec.rb +++ b/spec/features/projects/project_settings_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'Edit Project Settings', feature: true do +describe 'Edit Project Settings' do include Select2Helper let(:user) { create(:user) } @@ -55,8 +55,7 @@ describe 'Edit Project Settings', feature: true do end context 'when changing project path' do - # Not using empty project because we need a repo to exist - let(:project) { create(:project, namespace: user.namespace, name: 'gitlabhq') } + let(:project) { create(:project, :repository, namespace: user.namespace, name: 'gitlabhq') } before(:context) do TestEnv.clean_test_path @@ -97,8 +96,7 @@ describe 'Edit Project Settings', feature: true do end describe 'Transfer project section', js: true do - # Not using empty project because we need a repo to exist - let!(:project) { create(:project, namespace: user.namespace, name: 'gitlabhq') } + let!(:project) { create(:project, :repository, namespace: user.namespace, name: 'gitlabhq') } let!(:group) { create(:group) } before(:context) do diff --git a/spec/features/projects/ref_switcher_spec.rb b/spec/features/projects/ref_switcher_spec.rb index 31c7b492ab7..f0a23729220 100644 --- a/spec/features/projects/ref_switcher_spec.rb +++ b/spec/features/projects/ref_switcher_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -feature 'Ref switcher', feature: true, js: true do +feature 'Ref switcher', js: true do let(:user) { create(:user) } - let(:project) { create(:project, :public) } + let(:project) { create(:project, :public, :repository) } before do project.team << [user, :master] @@ -19,14 +19,14 @@ feature 'Ref switcher', feature: true, js: true do input.set 'binary' wait_for_requests - expect(find('.dropdown-content ul')).to have_selector('li', count: 6) + expect(find('.dropdown-content ul')).to have_selector('li', count: 7) page.within '.dropdown-content ul' do input.native.send_keys :enter end end - expect(page).to have_title 'binary-encoding' + expect(page).to have_title 'add-pdf-text-binary' end it "user selects ref with special characters" do diff --git a/spec/features/projects/services/jira_service_spec.rb b/spec/features/projects/services/jira_service_spec.rb index b71eec0ecfd..ecaa69c49dd 100644 --- a/spec/features/projects/services/jira_service_spec.rb +++ b/spec/features/projects/services/jira_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Setup Jira service', :feature, :js do +feature 'Setup Jira service', :js do let(:user) { create(:user) } let(:project) { create(:empty_project) } let(:service) { project.create_jira_service } @@ -62,7 +62,7 @@ feature 'Setup Jira service', :feature, :js do click_button('Test settings and save changes') wait_for_requests - expect(find('.flash-container-page')).to have_content 'Test failed.' + expect(find('.flash-container-page')).to have_content 'Test failed. message' expect(find('.flash-container-page')).to have_content 'Save anyway' find('.flash-alert .flash-action').trigger('click') diff --git a/spec/features/projects/services/mattermost_slash_command_spec.rb b/spec/features/projects/services/mattermost_slash_command_spec.rb index 3319b0fedf3..134d7e5e8b7 100644 --- a/spec/features/projects/services/mattermost_slash_command_spec.rb +++ b/spec/features/projects/services/mattermost_slash_command_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Setup Mattermost slash commands', :feature, :js do +feature 'Setup Mattermost slash commands', :js do let(:user) { create(:user) } let(:project) { create(:empty_project) } let(:service) { project.create_mattermost_slash_commands_service } diff --git a/spec/features/projects/services/slack_service_spec.rb b/spec/features/projects/services/slack_service_spec.rb index 709cd1226c3..824cae261e0 100644 --- a/spec/features/projects/services/slack_service_spec.rb +++ b/spec/features/projects/services/slack_service_spec.rb @@ -1,9 +1,9 @@ require 'spec_helper' -feature 'Projects > Slack service > Setup events', feature: true do +feature 'Projects > Slack service > Setup events' do let(:user) { create(:user) } let(:service) { SlackService.new } - let(:project) { create(:project, slack_service: service) } + let(:project) { create(:empty_project, slack_service: service) } background do service.fields diff --git a/spec/features/projects/services/slack_slash_command_spec.rb b/spec/features/projects/services/slack_slash_command_spec.rb index 71f5a8d7a4e..6002c589fba 100644 --- a/spec/features/projects/services/slack_slash_command_spec.rb +++ b/spec/features/projects/services/slack_slash_command_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' -feature 'Slack slash commands', feature: true do +feature 'Slack slash commands' do given(:user) { create(:user) } - given(:project) { create(:project) } + given(:project) { create(:empty_project) } given(:service) { project.create_slack_slash_commands_service } background do diff --git a/spec/features/projects/settings/integration_settings_spec.rb b/spec/features/projects/settings/integration_settings_spec.rb index 6ae242af87f..1de4918e142 100644 --- a/spec/features/projects/settings/integration_settings_spec.rb +++ b/spec/features/projects/settings/integration_settings_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Integration settings', feature: true do +feature 'Integration settings' do let(:project) { create(:empty_project) } let(:user) { create(:user) } let(:role) { :developer } diff --git a/spec/features/projects/settings/merge_requests_settings_spec.rb b/spec/features/projects/settings/merge_requests_settings_spec.rb index ecaf65c4ad9..796e2026905 100644 --- a/spec/features/projects/settings/merge_requests_settings_spec.rb +++ b/spec/features/projects/settings/merge_requests_settings_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Project settings > Merge Requests', feature: true, js: true do +feature 'Project settings > Merge Requests', :js do let(:project) { create(:empty_project, :public) } let(:user) { create(:user) } diff --git a/spec/features/projects/settings/pipelines_settings_spec.rb b/spec/features/projects/settings/pipelines_settings_spec.rb index 724cfa10e72..f24d7ff64d0 100644 --- a/spec/features/projects/settings/pipelines_settings_spec.rb +++ b/spec/features/projects/settings/pipelines_settings_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature "Pipelines settings", feature: true do +feature "Pipelines settings" do let(:project) { create(:empty_project) } let(:user) { create(:user) } let(:role) { :developer } diff --git a/spec/features/projects/settings/repository_settings_spec.rb b/spec/features/projects/settings/repository_settings_spec.rb index 98539518f6c..15180d4b498 100644 --- a/spec/features/projects/settings/repository_settings_spec.rb +++ b/spec/features/projects/settings/repository_settings_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Repository settings', feature: true do +feature 'Repository settings' do let(:project) { create(:project_empty_repo) } let(:user) { create(:user) } let(:role) { :developer } diff --git a/spec/features/projects/settings/visibility_settings_spec.rb b/spec/features/projects/settings/visibility_settings_spec.rb index 32d8f1fd16a..1e705d211ea 100644 --- a/spec/features/projects/settings/visibility_settings_spec.rb +++ b/spec/features/projects/settings/visibility_settings_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' -feature 'Visibility settings', feature: true, js: true do +feature 'Visibility settings', js: true do let(:user) { create(:user) } - let(:project) { create(:project, namespace: user.namespace, visibility_level: 20) } + let(:project) { create(:empty_project, namespace: user.namespace, visibility_level: 20) } context 'as owner' do before do diff --git a/spec/features/projects/shortcuts_spec.rb b/spec/features/projects/shortcuts_spec.rb index 8dd70e07b30..2c6d0a56311 100644 --- a/spec/features/projects/shortcuts_spec.rb +++ b/spec/features/projects/shortcuts_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' -feature 'Project shortcuts', feature: true do - let(:project) { create(:project, name: 'Victorialand') } +feature 'Project shortcuts' do + let(:project) { create(:empty_project, name: 'Victorialand') } let(:user) { create(:user) } describe 'On a project', js: true do diff --git a/spec/features/projects/show_project_spec.rb b/spec/features/projects/show_project_spec.rb new file mode 100644 index 00000000000..1bc6fae9e7f --- /dev/null +++ b/spec/features/projects/show_project_spec.rb @@ -0,0 +1,20 @@ +require 'spec_helper' + +describe 'Project show page', feature: true do + context 'when project pending delete' do + let(:project) { create(:project, :empty_repo, pending_delete: true) } + + before do + sign_in(project.owner) + end + + it 'shows error message if deletion for project fails' do + project.update_attributes(delete_error: "Something went wrong", pending_delete: false) + + visit project_path(project) + + expect(page).to have_selector('.project-deletion-failed-message') + expect(page).to have_content("This project was scheduled for deletion, but failed with the following message: #{project.delete_error}") + end + end +end diff --git a/spec/features/projects/snippets/create_snippet_spec.rb b/spec/features/projects/snippets/create_snippet_spec.rb index 06d32423a13..7f0e7e3116c 100644 --- a/spec/features/projects/snippets/create_snippet_spec.rb +++ b/spec/features/projects/snippets/create_snippet_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' -feature 'Create Snippet', :js, feature: true do +feature 'Create Snippet', :js do include DropzoneHelper let(:user) { create(:user) } - let(:project) { create(:project, :repository, :public) } + let(:project) { create(:empty_project, :public) } def fill_form fill_in 'project_snippet_title', with: 'My Snippet Title' diff --git a/spec/features/projects/snippets/show_spec.rb b/spec/features/projects/snippets/show_spec.rb index 52698fe1fa3..08dc7cf6c5b 100644 --- a/spec/features/projects/snippets/show_spec.rb +++ b/spec/features/projects/snippets/show_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Project snippet', :js, feature: true do +feature 'Project snippet', :js do let(:user) { create(:user) } let(:project) { create(:project, :repository) } let(:snippet) { create(:project_snippet, project: project, file_name: file_name, content: content) } diff --git a/spec/features/projects/snippets_spec.rb b/spec/features/projects/snippets_spec.rb index 513a05151b2..0822684a42c 100644 --- a/spec/features/projects/snippets_spec.rb +++ b/spec/features/projects/snippets_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'Project snippets', :js, feature: true do +describe 'Project snippets', :js do context 'when the project has snippets' do let(:project) { create(:empty_project, :public) } let!(:snippets) { create_list(:project_snippet, 2, :public, author: project.owner, project: project) } diff --git a/spec/features/projects/sub_group_issuables_spec.rb b/spec/features/projects/sub_group_issuables_spec.rb index 007910bb931..262dcc0abff 100644 --- a/spec/features/projects/sub_group_issuables_spec.rb +++ b/spec/features/projects/sub_group_issuables_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'Subgroup Issuables', :feature, :js, :nested_groups do +describe 'Subgroup Issuables', :js, :nested_groups do let!(:group) { create(:group, name: 'group') } let!(:subgroup) { create(:group, parent: group, name: 'subgroup') } let!(:project) { create(:empty_project, namespace: subgroup, name: 'project') } diff --git a/spec/features/projects/tags/download_buttons_spec.rb b/spec/features/projects/tags/download_buttons_spec.rb index 34c5e59c3e5..a6c5a486bcc 100644 --- a/spec/features/projects/tags/download_buttons_spec.rb +++ b/spec/features/projects/tags/download_buttons_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Download buttons in tags page', feature: true do +feature 'Download buttons in tags page' do given(:user) { create(:user) } given(:role) { :developer } given(:status) { 'success' } diff --git a/spec/features/projects/user_browses_files_spec.rb b/spec/features/projects/user_browses_files_spec.rb index 263a3a29a66..b7a0b72db50 100644 --- a/spec/features/projects/user_browses_files_spec.rb +++ b/spec/features/projects/user_browses_files_spec.rb @@ -7,7 +7,7 @@ describe 'User browses files' do "You're not allowed to make changes to this project directly. "\ "A fork of this project has been created that you can make changes in, so you can submit a merge request." end - let(:project) { create(:project, name: 'Shop') } + let(:project) { create(:project, :repository, name: 'Shop') } let(:project2) { create(:project, :repository, name: 'Another Project', path: 'another-project') } let(:project2_tree_path_root_ref) { project_tree_path(project2, project2.repository.root_ref) } let(:tree_path_ref_6d39438) { project_tree_path(project, '6d39438') } diff --git a/spec/features/projects/user_creates_directory_spec.rb b/spec/features/projects/user_creates_directory_spec.rb index 635bd4493dd..1ba5d83eadf 100644 --- a/spec/features/projects/user_creates_directory_spec.rb +++ b/spec/features/projects/user_creates_directory_spec.rb @@ -5,7 +5,7 @@ feature 'User creates a directory', js: true do "You're not allowed to make changes to this project directly. "\ "A fork of this project has been created that you can make changes in, so you can submit a merge request." end - let(:project) { create(:project) } + let(:project) { create(:project, :repository) } let(:project2) { create(:project, :repository, name: 'Another Project', path: 'another-project') } let(:project2_tree_path_root_ref) { project_tree_path(project2, project2.repository.root_ref) } let(:user) { create(:user) } diff --git a/spec/features/projects/user_creates_files_spec.rb b/spec/features/projects/user_creates_files_spec.rb index 0c7f1a775c1..4b78cc4fc53 100644 --- a/spec/features/projects/user_creates_files_spec.rb +++ b/spec/features/projects/user_creates_files_spec.rb @@ -5,7 +5,7 @@ describe 'User creates files' do "You're not allowed to make changes to this project directly. "\ "A fork of this project has been created that you can make changes in, so you can submit a merge request." end - let(:project) { create(:project, name: 'Shop') } + let(:project) { create(:project, :repository, name: 'Shop') } let(:project2) { create(:project, :repository, name: 'Another Project', path: 'another-project') } let(:project_tree_path_root_ref) { project_tree_path(project, project.repository.root_ref) } let(:project2_tree_path_root_ref) { project_tree_path(project2, project2.repository.root_ref) } diff --git a/spec/features/projects/user_deletes_files_spec.rb b/spec/features/projects/user_deletes_files_spec.rb index 97e60862b4f..95cd316be0e 100644 --- a/spec/features/projects/user_deletes_files_spec.rb +++ b/spec/features/projects/user_deletes_files_spec.rb @@ -5,7 +5,7 @@ describe 'User deletes files' do "You're not allowed to make changes to this project directly. "\ "A fork of this project has been created that you can make changes in, so you can submit a merge request." end - let(:project) { create(:project, name: 'Shop') } + let(:project) { create(:project, :repository, name: 'Shop') } let(:project2) { create(:project, :repository, name: 'Another Project', path: 'another-project') } let(:project_tree_path_root_ref) { project_tree_path(project, project.repository.root_ref) } let(:project2_tree_path_root_ref) { project_tree_path(project2, project2.repository.root_ref) } diff --git a/spec/features/projects/user_edits_files_spec.rb b/spec/features/projects/user_edits_files_spec.rb index eb26f1bc123..8ae89c980b9 100644 --- a/spec/features/projects/user_edits_files_spec.rb +++ b/spec/features/projects/user_edits_files_spec.rb @@ -5,7 +5,7 @@ describe 'User edits files' do "You're not allowed to make changes to this project directly. "\ "A fork of this project has been created that you can make changes in, so you can submit a merge request." end - let(:project) { create(:project, name: 'Shop') } + let(:project) { create(:project, :repository, name: 'Shop') } let(:project2) { create(:project, :repository, name: 'Another Project', path: 'another-project') } let(:project_tree_path_root_ref) { project_tree_path(project, project.repository.root_ref) } let(:project2_tree_path_root_ref) { project_tree_path(project2, project2.repository.root_ref) } diff --git a/spec/features/projects/user_replaces_files_spec.rb b/spec/features/projects/user_replaces_files_spec.rb index 50f2ffc4bbf..e284fdefd4f 100644 --- a/spec/features/projects/user_replaces_files_spec.rb +++ b/spec/features/projects/user_replaces_files_spec.rb @@ -7,7 +7,7 @@ describe 'User replaces files' do "You're not allowed to make changes to this project directly. "\ "A fork of this project has been created that you can make changes in, so you can submit a merge request." end - let(:project) { create(:project, name: 'Shop') } + let(:project) { create(:project, :repository, name: 'Shop') } let(:project2) { create(:project, :repository, name: 'Another Project', path: 'another-project') } let(:project_tree_path_root_ref) { project_tree_path(project, project.repository.root_ref) } let(:project2_tree_path_root_ref) { project_tree_path(project2, project2.repository.root_ref) } diff --git a/spec/features/projects/user_uploads_files_spec.rb b/spec/features/projects/user_uploads_files_spec.rb index 64a1439badd..98871317ca3 100644 --- a/spec/features/projects/user_uploads_files_spec.rb +++ b/spec/features/projects/user_uploads_files_spec.rb @@ -7,7 +7,7 @@ describe 'User uploads files' do "You're not allowed to make changes to this project directly. "\ "A fork of this project has been created that you can make changes in, so you can submit a merge request." end - let(:project) { create(:project, name: 'Shop') } + let(:project) { create(:project, :repository, name: 'Shop') } let(:project2) { create(:project, :repository, name: 'Another Project', path: 'another-project') } let(:project_tree_path_root_ref) { project_tree_path(project, project.repository.root_ref) } let(:project2_tree_path_root_ref) { project_tree_path(project2, project2.repository.root_ref) } diff --git a/spec/features/projects/wiki/markdown_preview_spec.rb b/spec/features/projects/wiki/markdown_preview_spec.rb index 231e8eed4fb..dbe98a38197 100644 --- a/spec/features/projects/wiki/markdown_preview_spec.rb +++ b/spec/features/projects/wiki/markdown_preview_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' -feature 'Projects > Wiki > User previews markdown changes', feature: true, js: true do +feature 'Projects > Wiki > User previews markdown changes', js: true do let(:user) { create(:user) } - let(:project) { create(:project, namespace: user.namespace) } + let(:project) { create(:empty_project, namespace: user.namespace) } let(:wiki_content) do <<-HEREDOC [regular link](regular) diff --git a/spec/features/projects/wiki/shortcuts_spec.rb b/spec/features/projects/wiki/shortcuts_spec.rb index ea816082479..2c668185666 100644 --- a/spec/features/projects/wiki/shortcuts_spec.rb +++ b/spec/features/projects/wiki/shortcuts_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Wiki shortcuts', :feature, :js do +feature 'Wiki shortcuts', :js do let(:user) { create(:user) } let(:project) { create(:empty_project, namespace: user.namespace) } let(:wiki_page) do diff --git a/spec/features/projects/wiki/user_creates_wiki_page_spec.rb b/spec/features/projects/wiki/user_creates_wiki_page_spec.rb index 9d66f482c8d..78c619f6301 100644 --- a/spec/features/projects/wiki/user_creates_wiki_page_spec.rb +++ b/spec/features/projects/wiki/user_creates_wiki_page_spec.rb @@ -11,7 +11,7 @@ feature 'Projects > Wiki > User creates wiki page', :js do end context 'in the user namespace' do - let(:project) { create(:project, namespace: user.namespace) } + let(:project) { create(:empty_project, namespace: user.namespace) } context 'when wiki is empty' do before do @@ -157,7 +157,7 @@ feature 'Projects > Wiki > User creates wiki page', :js do end context 'in a group namespace' do - let(:project) { create(:project, namespace: create(:group, :public)) } + let(:project) { create(:empty_project, namespace: create(:group, :public)) } context 'when wiki is empty' do before do diff --git a/spec/features/projects/wiki/user_git_access_wiki_page_spec.rb b/spec/features/projects/wiki/user_git_access_wiki_page_spec.rb index 9445b88af8d..9c58e336605 100644 --- a/spec/features/projects/wiki/user_git_access_wiki_page_spec.rb +++ b/spec/features/projects/wiki/user_git_access_wiki_page_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' -describe 'Projects > Wiki > User views Git access wiki page', :feature do +describe 'Projects > Wiki > User views Git access wiki page' do let(:user) { create(:user) } - let(:project) { create(:project, :public) } + let(:project) { create(:empty_project, :public) } let(:wiki_page) do WikiPages::CreateService.new( project, diff --git a/spec/features/projects/wiki/user_updates_wiki_page_spec.rb b/spec/features/projects/wiki/user_updates_wiki_page_spec.rb index 425195840d8..8271428582d 100644 --- a/spec/features/projects/wiki/user_updates_wiki_page_spec.rb +++ b/spec/features/projects/wiki/user_updates_wiki_page_spec.rb @@ -1,18 +1,18 @@ require 'spec_helper' -feature 'Projects > Wiki > User updates wiki page', feature: true do +feature 'Projects > Wiki > User updates wiki page' do let(:user) { create(:user) } + let!(:wiki_page) { WikiPages::CreateService.new(project, user, title: 'home', content: 'Home page').execute } background do project.team << [user, :master] - WikiPages::CreateService.new(project, user, title: 'home', content: 'Home page').execute sign_in(user) visit project_wikis_path(project) end context 'in the user namespace' do - let(:project) { create(:project, namespace: user.namespace) } + let(:project) { create(:empty_project, namespace: user.namespace) } context 'the home page' do scenario 'success when the wiki content is not empty' do @@ -51,10 +51,20 @@ feature 'Projects > Wiki > User updates wiki page', feature: true do expect(page).to have_selector('.atwho-view') end end + + scenario 'page has been updated since the user opened the edit page' do + click_link 'Edit' + + wiki_page.update('Update') + + click_button 'Save changes' + + expect(page).to have_content 'Someone edited the page the same time you did.' + end end context 'in a group namespace' do - let(:project) { create(:project, namespace: create(:group, :public)) } + let(:project) { create(:empty_project, namespace: create(:group, :public)) } scenario 'the home page' do click_link 'Edit' diff --git a/spec/features/projects/wiki/user_views_project_wiki_page_spec.rb b/spec/features/projects/wiki/user_views_project_wiki_page_spec.rb index 13e882ad665..4f94ab1a609 100644 --- a/spec/features/projects/wiki/user_views_project_wiki_page_spec.rb +++ b/spec/features/projects/wiki/user_views_project_wiki_page_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' -feature 'Projects > Wiki > User views the wiki page', feature: true do +feature 'Projects > Wiki > User views the wiki page' do let(:user) { create(:user) } - let(:project) { create(:project, :public) } + let(:project) { create(:empty_project, :public) } let(:old_page_version_id) { wiki_page.versions.last.id } let(:wiki_page) do WikiPages::CreateService.new( diff --git a/spec/features/projects/wiki/user_views_wiki_in_project_page_spec.rb b/spec/features/projects/wiki/user_views_wiki_in_project_page_spec.rb index 2234af1d795..8d1e6f66039 100644 --- a/spec/features/projects/wiki/user_views_wiki_in_project_page_spec.rb +++ b/spec/features/projects/wiki/user_views_wiki_in_project_page_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'Projects > Wiki > User views wiki in project page', feature: true do +describe 'Projects > Wiki > User views wiki in project page' do let(:user) { create(:user) } before do diff --git a/spec/features/projects_spec.rb b/spec/features/projects_spec.rb index 10c7e5934e4..3295f7f9174 100644 --- a/spec/features/projects_spec.rb +++ b/spec/features/projects_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Project', feature: true do +feature 'Project' do describe 'description' do let(:project) { create(:project, :repository) } let(:path) { project_path(project) } diff --git a/spec/features/protected_branches_spec.rb b/spec/features/protected_branches_spec.rb index 8a3574546c2..3677bf38724 100644 --- a/spec/features/protected_branches_spec.rb +++ b/spec/features/protected_branches_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Protected Branches', feature: true, js: true do +feature 'Protected Branches', js: true do let(:user) { create(:user, :admin) } let(:project) { create(:project, :repository) } diff --git a/spec/features/protected_tags_spec.rb b/spec/features/protected_tags_spec.rb index 7a22cf60996..c9ba1a8c088 100644 --- a/spec/features/protected_tags_spec.rb +++ b/spec/features/protected_tags_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Projected Tags', feature: true, js: true do +feature 'Projected Tags', js: true do let(:user) { create(:user, :admin) } let(:project) { create(:project, :repository) } diff --git a/spec/features/raven_js_spec.rb b/spec/features/raven_js_spec.rb index e8fa49c18cb..b1f51959d54 100644 --- a/spec/features/raven_js_spec.rb +++ b/spec/features/raven_js_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'RavenJS', :feature, :js do +feature 'RavenJS', :js do let(:raven_path) { '/raven.bundle.js' } it 'should not load raven if sentry is disabled' do diff --git a/spec/features/reportable_note/commit_spec.rb b/spec/features/reportable_note/commit_spec.rb index d82ebe02f77..1074eb62b33 100644 --- a/spec/features/reportable_note/commit_spec.rb +++ b/spec/features/reportable_note/commit_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'Reportable note on commit', :feature, :js do +describe 'Reportable note on commit', :js do include RepoHelpers let(:user) { create(:user) } diff --git a/spec/features/reportable_note/issue_spec.rb b/spec/features/reportable_note/issue_spec.rb index cb1cb1a1417..9964a32db2e 100644 --- a/spec/features/reportable_note/issue_spec.rb +++ b/spec/features/reportable_note/issue_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'Reportable note on issue', :feature, :js do +describe 'Reportable note on issue', :js do let(:user) { create(:user) } let(:project) { create(:empty_project) } let(:issue) { create(:issue, project: project) } diff --git a/spec/features/reportable_note/merge_request_spec.rb b/spec/features/reportable_note/merge_request_spec.rb index 8a531b9a9e9..a491abdb6cb 100644 --- a/spec/features/reportable_note/merge_request_spec.rb +++ b/spec/features/reportable_note/merge_request_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'Reportable note on merge request', :feature, :js do +describe 'Reportable note on merge request', :js do let(:user) { create(:user) } let(:project) { create(:project) } let(:merge_request) { create(:merge_request, source_project: project) } diff --git a/spec/features/reportable_note/snippets_spec.rb b/spec/features/reportable_note/snippets_spec.rb index f560a0ebfd9..9a14024684c 100644 --- a/spec/features/reportable_note/snippets_spec.rb +++ b/spec/features/reportable_note/snippets_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'Reportable note on snippets', :feature, :js do +describe 'Reportable note on snippets', :js do let(:user) { create(:user) } let(:project) { create(:empty_project) } diff --git a/spec/features/search_spec.rb b/spec/features/search_spec.rb index 12ef23440b7..b29f19f1562 100644 --- a/spec/features/search_spec.rb +++ b/spec/features/search_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe "Search", feature: true do +describe "Search" do include FilteredSearchHelpers let(:user) { create(:user) } @@ -154,7 +154,7 @@ describe "Search", feature: true do end end - describe 'Right header search field', feature: true do + describe 'Right header search field' do it 'allows enter key to search', js: true do visit project_path(project) fill_in 'search', with: 'gitlab' diff --git a/spec/features/security/admin_access_spec.rb b/spec/features/security/admin_access_spec.rb index e180ca53eb5..3ca1303bda6 100644 --- a/spec/features/security/admin_access_spec.rb +++ b/spec/features/security/admin_access_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe "Admin::Projects", feature: true do +describe "Admin::Projects" do include AccessMatchers describe "GET /admin/projects" do diff --git a/spec/features/security/dashboard_access_spec.rb b/spec/features/security/dashboard_access_spec.rb index 40f773956d1..149bd32e736 100644 --- a/spec/features/security/dashboard_access_spec.rb +++ b/spec/features/security/dashboard_access_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe "Dashboard access", feature: true do +describe "Dashboard access" do include AccessMatchers describe "GET /dashboard" do diff --git a/spec/features/security/group/internal_access_spec.rb b/spec/features/security/group/internal_access_spec.rb index 87cce32d6c6..bf7be33013e 100644 --- a/spec/features/security/group/internal_access_spec.rb +++ b/spec/features/security/group/internal_access_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' -describe 'Internal Group access', feature: true do +describe 'Internal Group access' do include AccessMatchers let(:group) { create(:group, :internal) } - let(:project) { create(:project, :internal, group: group) } + let(:project) { create(:empty_project, :internal, group: group) } let(:project_guest) do create(:user) do |user| project.add_guest(user) @@ -49,6 +49,7 @@ describe 'Internal Group access', feature: true do end describe 'GET /groups/:path/merge_requests' do + let(:project) { create(:project, :internal, :repository, group: group) } subject { merge_requests_group_path(group) } it { is_expected.to be_allowed_for(:admin) } diff --git a/spec/features/security/group/private_access_spec.rb b/spec/features/security/group/private_access_spec.rb index 1d6b3e77c22..c399d7a0851 100644 --- a/spec/features/security/group/private_access_spec.rb +++ b/spec/features/security/group/private_access_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' -describe 'Private Group access', feature: true do +describe 'Private Group access' do include AccessMatchers let(:group) { create(:group, :private) } - let(:project) { create(:project, :private, group: group) } + let(:project) { create(:empty_project, :private, group: group) } let(:project_guest) do create(:user) do |user| project.add_guest(user) @@ -49,6 +49,7 @@ describe 'Private Group access', feature: true do end describe 'GET /groups/:path/merge_requests' do + let(:project) { create(:project, :private, :repository, group: group) } subject { merge_requests_group_path(group) } it { is_expected.to be_allowed_for(:admin) } diff --git a/spec/features/security/group/public_access_spec.rb b/spec/features/security/group/public_access_spec.rb index d7d76177269..63e4d7ca65c 100644 --- a/spec/features/security/group/public_access_spec.rb +++ b/spec/features/security/group/public_access_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' -describe 'Public Group access', feature: true do +describe 'Public Group access' do include AccessMatchers let(:group) { create(:group, :public) } - let(:project) { create(:project, :public, group: group) } + let(:project) { create(:empty_project, :public, group: group) } let(:project_guest) do create(:user) do |user| project.add_guest(user) @@ -49,6 +49,7 @@ describe 'Public Group access', feature: true do end describe 'GET /groups/:path/merge_requests' do + let(:project) { create(:project, :public, :repository, group: group) } subject { merge_requests_group_path(group) } it { is_expected.to be_allowed_for(:admin) } diff --git a/spec/features/security/profile_access_spec.rb b/spec/features/security/profile_access_spec.rb index c19678ab381..41eb7b26578 100644 --- a/spec/features/security/profile_access_spec.rb +++ b/spec/features/security/profile_access_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe "Profile access", feature: true do +describe "Profile access" do include AccessMatchers describe "GET /profile/keys" do diff --git a/spec/features/security/project/internal_access_spec.rb b/spec/features/security/project/internal_access_spec.rb index 1000a0bdd89..a7928857b7d 100644 --- a/spec/features/security/project/internal_access_spec.rb +++ b/spec/features/security/project/internal_access_spec.rb @@ -1,9 +1,9 @@ require 'spec_helper' -describe "Internal Project Access", feature: true do +describe "Internal Project Access" do include AccessMatchers - set(:project) { create(:project, :internal) } + set(:project) { create(:project, :internal, :repository) } describe "Project should be internal" do describe '#internal?' do diff --git a/spec/features/security/project/private_access_spec.rb b/spec/features/security/project/private_access_spec.rb index 94d759393ca..a4396b20afd 100644 --- a/spec/features/security/project/private_access_spec.rb +++ b/spec/features/security/project/private_access_spec.rb @@ -1,9 +1,9 @@ require 'spec_helper' -describe "Private Project Access", feature: true do +describe "Private Project Access" do include AccessMatchers - set(:project) { create(:project, :private, public_builds: false) } + set(:project) { create(:project, :private, :repository, public_builds: false) } describe "Project should be private" do describe '#private?' do diff --git a/spec/features/security/project/public_access_spec.rb b/spec/features/security/project/public_access_spec.rb index d45e1dbc09b..fccdeb0e5b7 100644 --- a/spec/features/security/project/public_access_spec.rb +++ b/spec/features/security/project/public_access_spec.rb @@ -1,9 +1,9 @@ require 'spec_helper' -describe "Public Project Access", feature: true do +describe "Public Project Access" do include AccessMatchers - set(:project) { create(:project, :public) } + set(:project) { create(:project, :public, :repository) } describe "Project should be public" do describe '#public?' do diff --git a/spec/features/security/project/snippet/internal_access_spec.rb b/spec/features/security/project/snippet/internal_access_spec.rb index 2420caa88c4..178782af56c 100644 --- a/spec/features/security/project/snippet/internal_access_spec.rb +++ b/spec/features/security/project/snippet/internal_access_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe "Internal Project Snippets Access", feature: true do +describe "Internal Project Snippets Access" do include AccessMatchers let(:project) { create(:empty_project, :internal) } diff --git a/spec/features/security/project/snippet/private_access_spec.rb b/spec/features/security/project/snippet/private_access_spec.rb index 0b8548a675b..7725c25ca1f 100644 --- a/spec/features/security/project/snippet/private_access_spec.rb +++ b/spec/features/security/project/snippet/private_access_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe "Private Project Snippets Access", feature: true do +describe "Private Project Snippets Access" do include AccessMatchers let(:project) { create(:empty_project, :private) } diff --git a/spec/features/security/project/snippet/public_access_spec.rb b/spec/features/security/project/snippet/public_access_spec.rb index 153f8f964a6..52aec75dcd0 100644 --- a/spec/features/security/project/snippet/public_access_spec.rb +++ b/spec/features/security/project/snippet/public_access_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe "Public Project Snippets Access", feature: true do +describe "Public Project Snippets Access" do include AccessMatchers let(:project) { create(:empty_project, :public) } diff --git a/spec/features/signup_spec.rb b/spec/features/signup_spec.rb index 5d6d1e79af2..b6367b88e17 100644 --- a/spec/features/signup_spec.rb +++ b/spec/features/signup_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Signup', feature: true do +feature 'Signup' do describe 'signup with no errors' do context "when sending confirmation email" do before do diff --git a/spec/features/snippets/explore_spec.rb b/spec/features/snippets/explore_spec.rb index 97d1c2d65e6..835fd90adc8 100644 --- a/spec/features/snippets/explore_spec.rb +++ b/spec/features/snippets/explore_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature 'Explore Snippets', feature: true do +feature 'Explore Snippets' do let!(:public_snippet) { create(:personal_snippet, :public) } let!(:internal_snippet) { create(:personal_snippet, :internal) } let!(:private_snippet) { create(:personal_snippet, :private) } diff --git a/spec/features/snippets/internal_snippet_spec.rb b/spec/features/snippets/internal_snippet_spec.rb index fb3e75f2102..3a229612235 100644 --- a/spec/features/snippets/internal_snippet_spec.rb +++ b/spec/features/snippets/internal_snippet_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature 'Internal Snippets', feature: true, js: true do +feature 'Internal Snippets', js: true do let(:internal_snippet) { create(:personal_snippet, :internal) } describe 'normal user' do diff --git a/spec/features/snippets/notes_on_personal_snippets_spec.rb b/spec/features/snippets/notes_on_personal_snippets_spec.rb index 17e93209f0c..f1d0905738b 100644 --- a/spec/features/snippets/notes_on_personal_snippets_spec.rb +++ b/spec/features/snippets/notes_on_personal_snippets_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'Comments on personal snippets', :js, feature: true do +describe 'Comments on personal snippets', :js do include NoteInteractionHelpers let!(:user) { create(:user) } diff --git a/spec/features/snippets/public_snippets_spec.rb b/spec/features/snippets/public_snippets_spec.rb index afd945a8555..bdeeca7187e 100644 --- a/spec/features/snippets/public_snippets_spec.rb +++ b/spec/features/snippets/public_snippets_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature 'Public Snippets', :js, feature: true do +feature 'Public Snippets', :js do scenario 'Unauthenticated user should see public snippets' do public_snippet = create(:personal_snippet, :public) diff --git a/spec/features/snippets/search_snippets_spec.rb b/spec/features/snippets/search_snippets_spec.rb index 5483df39a8b..cd66a2cb20c 100644 --- a/spec/features/snippets/search_snippets_spec.rb +++ b/spec/features/snippets/search_snippets_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature 'Search Snippets', feature: true do +feature 'Search Snippets' do scenario 'User searches for snippets by title' do public_snippet = create(:personal_snippet, :public, title: 'Beginning and Middle') private_snippet = create(:personal_snippet, :private, title: 'Middle and End') diff --git a/spec/features/snippets/show_spec.rb b/spec/features/snippets/show_spec.rb index 95fc1d2bb62..5a48f5774ca 100644 --- a/spec/features/snippets/show_spec.rb +++ b/spec/features/snippets/show_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Snippet', :js, feature: true do +feature 'Snippet', :js do let(:project) { create(:project, :repository) } let(:snippet) { create(:personal_snippet, :public, file_name: file_name, content: content) } diff --git a/spec/features/snippets/user_creates_snippet_spec.rb b/spec/features/snippets/user_creates_snippet_spec.rb index 698d3b5d3e3..a919f5fa20b 100644 --- a/spec/features/snippets/user_creates_snippet_spec.rb +++ b/spec/features/snippets/user_creates_snippet_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature 'User creates snippet', :js, feature: true do +feature 'User creates snippet', :js do include DropzoneHelper let(:user) { create(:user) } diff --git a/spec/features/snippets/user_deletes_snippet_spec.rb b/spec/features/snippets/user_deletes_snippet_spec.rb index 162c2c9e730..ae5b883c477 100644 --- a/spec/features/snippets/user_deletes_snippet_spec.rb +++ b/spec/features/snippets/user_deletes_snippet_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature 'User deletes snippet', feature: true do +feature 'User deletes snippet' do let(:user) { create(:user) } let(:content) { 'puts "test"' } let(:snippet) { create(:personal_snippet, :public, content: content, author: user) } diff --git a/spec/features/snippets/user_edits_snippet_spec.rb b/spec/features/snippets/user_edits_snippet_spec.rb index c9f9741b4bb..26070e508e2 100644 --- a/spec/features/snippets/user_edits_snippet_spec.rb +++ b/spec/features/snippets/user_edits_snippet_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature 'User edits snippet', :js, feature: true do +feature 'User edits snippet', :js do include DropzoneHelper let(:file_name) { 'test.rb' } diff --git a/spec/features/snippets/user_snippets_spec.rb b/spec/features/snippets/user_snippets_spec.rb index 019310f2326..7bc27486787 100644 --- a/spec/features/snippets/user_snippets_spec.rb +++ b/spec/features/snippets/user_snippets_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature 'User Snippets', feature: true do +feature 'User Snippets' do let(:author) { create(:user) } let!(:public_snippet) { create(:personal_snippet, :public, author: author, title: "This is a public snippet") } let!(:internal_snippet) { create(:personal_snippet, :internal, author: author, title: "This is an internal snippet") } diff --git a/spec/features/snippets_spec.rb b/spec/features/snippets_spec.rb index 70b16bfc810..ae3b876f87c 100644 --- a/spec/features/snippets_spec.rb +++ b/spec/features/snippets_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'Snippets', feature: true do +describe 'Snippets' do context 'when the project has snippets' do let(:project) { create(:empty_project, :public) } let!(:snippets) { create_list(:project_snippet, 2, :public, author: project.owner, project: project) } diff --git a/spec/features/tags/master_creates_tag_spec.rb b/spec/features/tags/master_creates_tag_spec.rb index 1cef3d5c6f4..35e1ca32f67 100644 --- a/spec/features/tags/master_creates_tag_spec.rb +++ b/spec/features/tags/master_creates_tag_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Master creates tag', feature: true do +feature 'Master creates tag' do let(:user) { create(:user) } let(:project) { create(:project, namespace: user.namespace) } diff --git a/spec/features/tags/master_deletes_tag_spec.rb b/spec/features/tags/master_deletes_tag_spec.rb index 98af1d6b4f7..e3c904ef3aa 100644 --- a/spec/features/tags/master_deletes_tag_spec.rb +++ b/spec/features/tags/master_deletes_tag_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Master deletes tag', feature: true do +feature 'Master deletes tag' do let(:user) { create(:user) } let(:project) { create(:project, namespace: user.namespace) } diff --git a/spec/features/tags/master_updates_tag_spec.rb b/spec/features/tags/master_updates_tag_spec.rb index 1b61fde7227..d6e84a1c685 100644 --- a/spec/features/tags/master_updates_tag_spec.rb +++ b/spec/features/tags/master_updates_tag_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Master updates tag', feature: true do +feature 'Master updates tag' do let(:user) { create(:user) } let(:project) { create(:project, namespace: user.namespace) } diff --git a/spec/features/tags/master_views_tags_spec.rb b/spec/features/tags/master_views_tags_spec.rb index fb910feae34..27936bc7f52 100644 --- a/spec/features/tags/master_views_tags_spec.rb +++ b/spec/features/tags/master_views_tags_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Master views tags', feature: true do +feature 'Master views tags' do let(:user) { create(:user) } before do diff --git a/spec/features/task_lists_spec.rb b/spec/features/task_lists_spec.rb index dfc362321aa..7e198ce0677 100644 --- a/spec/features/task_lists_spec.rb +++ b/spec/features/task_lists_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Task Lists', feature: true do +feature 'Task Lists' do include Warden::Test::Helpers let(:project) { create(:empty_project) } @@ -62,7 +62,7 @@ feature 'Task Lists', feature: true do visit project_issue_path(project, issue) end - describe 'for Issues', feature: true do + describe 'for Issues' do describe 'multiple tasks', js: true do let!(:issue) { create(:issue, description: markdown, author: user, project: project) } diff --git a/spec/features/triggers_spec.rb b/spec/features/triggers_spec.rb index 47d5f94f54e..604fe326e96 100644 --- a/spec/features/triggers_spec.rb +++ b/spec/features/triggers_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Triggers', feature: true, js: true do +feature 'Triggers', js: true do let(:trigger_title) { 'trigger desc' } let(:user) { create(:user) } let(:user2) { create(:user) } diff --git a/spec/features/unsubscribe_links_spec.rb b/spec/features/unsubscribe_links_spec.rb index 352f8ba70ac..d728dc59b3f 100644 --- a/spec/features/unsubscribe_links_spec.rb +++ b/spec/features/unsubscribe_links_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'Unsubscribe links', feature: true do +describe 'Unsubscribe links' do include Warden::Test::Helpers let(:recipient) { create(:user) } diff --git a/spec/features/uploads/user_uploads_avatar_to_group_spec.rb b/spec/features/uploads/user_uploads_avatar_to_group_spec.rb index 8188d4c79f4..e8884bc1a00 100644 --- a/spec/features/uploads/user_uploads_avatar_to_group_spec.rb +++ b/spec/features/uploads/user_uploads_avatar_to_group_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature 'User uploads avatar to group', feature: true do +feature 'User uploads avatar to group' do scenario 'they see the new avatar' do user = create(:user) group = create(:group) diff --git a/spec/features/uploads/user_uploads_avatar_to_profile_spec.rb b/spec/features/uploads/user_uploads_avatar_to_profile_spec.rb index 2628508afe8..52003bb0859 100644 --- a/spec/features/uploads/user_uploads_avatar_to_profile_spec.rb +++ b/spec/features/uploads/user_uploads_avatar_to_profile_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature 'User uploads avatar to profile', feature: true do +feature 'User uploads avatar to profile' do scenario 'they see their new avatar' do user = create(:user) sign_in(user) diff --git a/spec/features/uploads/user_uploads_file_to_note_spec.rb b/spec/features/uploads/user_uploads_file_to_note_spec.rb index 01f10ca0933..0654923d9a6 100644 --- a/spec/features/uploads/user_uploads_file_to_note_spec.rb +++ b/spec/features/uploads/user_uploads_file_to_note_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature 'User uploads file to note', feature: true do +feature 'User uploads file to note' do include DropzoneHelper let(:user) { create(:user) } diff --git a/spec/features/users/projects_spec.rb b/spec/features/users/projects_spec.rb index 797ed0e6437..b961d2337ed 100644 --- a/spec/features/users/projects_spec.rb +++ b/spec/features/users/projects_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'Projects tab on a user profile', :feature, :js do +describe 'Projects tab on a user profile', :js do let(:user) { create(:user) } let!(:project) { create(:empty_project, namespace: user.namespace) } let!(:project2) { create(:empty_project, namespace: user.namespace) } diff --git a/spec/features/users/snippets_spec.rb b/spec/features/users/snippets_spec.rb index 42738b137af..13760b4c2fc 100644 --- a/spec/features/users/snippets_spec.rb +++ b/spec/features/users/snippets_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'Snippets tab on a user profile', feature: true, js: true do +describe 'Snippets tab on a user profile', js: true do context 'when the user has snippets' do let(:user) { create(:user) } diff --git a/spec/features/users_spec.rb b/spec/features/users_spec.rb index 84af13d3e49..ff004d85272 100644 --- a/spec/features/users_spec.rb +++ b/spec/features/users_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Users', feature: true, js: true do +feature 'Users', js: true do let(:user) { create(:user, username: 'user1', name: 'User 1', email: 'user1@gitlab.com') } scenario 'GET /users/sign_in creates a new user account' do diff --git a/spec/finders/access_requests_finder_spec.rb b/spec/finders/access_requests_finder_spec.rb index c7278e971ae..1d0c15392b2 100644 --- a/spec/finders/access_requests_finder_spec.rb +++ b/spec/finders/access_requests_finder_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe AccessRequestsFinder, services: true do +describe AccessRequestsFinder do let(:user) { create(:user) } let(:access_requester) { create(:user) } diff --git a/spec/fixtures/api/schemas/public_api/v4/branch.json b/spec/fixtures/api/schemas/public_api/v4/branch.json new file mode 100644 index 00000000000..a3581178974 --- /dev/null +++ b/spec/fixtures/api/schemas/public_api/v4/branch.json @@ -0,0 +1,20 @@ +{ + "type": "object", + "required" : [ + "name", + "commit", + "merged", + "protected", + "developers_can_push", + "developers_can_merge" + ], + "properties" : { + "name": { "type": "string" }, + "commit": { "$ref": "commit/basic.json" }, + "merged": { "type": "boolean" }, + "protected": { "type": "boolean" }, + "developers_can_push": { "type": "boolean" }, + "developers_can_merge": { "type": "boolean" } + }, + "additionalProperties": false +} diff --git a/spec/fixtures/api/schemas/public_api/v4/branches.json b/spec/fixtures/api/schemas/public_api/v4/branches.json new file mode 100644 index 00000000000..854c902b485 --- /dev/null +++ b/spec/fixtures/api/schemas/public_api/v4/branches.json @@ -0,0 +1,4 @@ +{ + "type": "array", + "items": { "$ref": "branch.json" } +} diff --git a/spec/fixtures/api/schemas/public_api/v4/commit/basic.json b/spec/fixtures/api/schemas/public_api/v4/commit/basic.json new file mode 100644 index 00000000000..9d99628a286 --- /dev/null +++ b/spec/fixtures/api/schemas/public_api/v4/commit/basic.json @@ -0,0 +1,37 @@ +{ + "type": "object", + "required" : [ + "id", + "short_id", + "title", + "created_at", + "parent_ids", + "message", + "author_name", + "author_email", + "authored_date", + "committer_name", + "committer_email", + "committed_date" + ], + "properties" : { + "id": { "type": ["string", "null"] }, + "short_id": { "type": ["string", "null"] }, + "title": { "type": "string" }, + "created_at": { "type": "date" }, + "parent_ids": { + "type": ["array", "null"], + "items": { + "type": "string", + "additionalProperties": false + } + }, + "message": { "type": "string" }, + "author_name": { "type": "string" }, + "author_email": { "type": "string" }, + "authored_date": { "type": "date" }, + "committer_name": { "type": "string" }, + "committer_email": { "type": "string" }, + "committed_date": { "type": "date" } + } +} diff --git a/spec/helpers/diff_helper_spec.rb b/spec/helpers/diff_helper_spec.rb index 0d909e6e140..060c112e20d 100644 --- a/spec/helpers/diff_helper_spec.rb +++ b/spec/helpers/diff_helper_spec.rb @@ -12,19 +12,32 @@ describe DiffHelper do let(:diff_file) { Gitlab::Diff::File.new(diff, diff_refs: diff_refs, repository: repository) } describe 'diff_view' do + it 'uses the view param over the cookie' do + controller.params[:view] = 'parallel' + helper.request.cookies[:diff_view] = 'inline' + + expect(helper.diff_view).to eq :parallel + end + + it 'returns the default value when the view param is invalid' do + controller.params[:view] = 'invalid' + + expect(helper.diff_view).to eq :inline + end + it 'returns a valid value when cookie is set' do helper.request.cookies[:diff_view] = 'parallel' expect(helper.diff_view).to eq :parallel end - it 'returns a default value when cookie is invalid' do + it 'returns the default value when cookie is invalid' do helper.request.cookies[:diff_view] = 'invalid' expect(helper.diff_view).to eq :inline end - it 'returns a default value when cookie is nil' do + it 'returns the default value when cookie is nil' do expect(helper.request.cookies).to be_empty expect(helper.diff_view).to eq :inline diff --git a/spec/helpers/namespaces_helper_spec.rb b/spec/helpers/namespaces_helper_spec.rb index e5143a0263d..8365b3f5538 100644 --- a/spec/helpers/namespaces_helper_spec.rb +++ b/spec/helpers/namespaces_helper_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe NamespacesHelper, type: :helper do +describe NamespacesHelper do let!(:admin) { create(:admin) } let!(:admin_group) { create(:group, :private) } let!(:user) { create(:user) } diff --git a/spec/initializers/6_validations_spec.rb b/spec/initializers/6_validations_spec.rb index 374517fec37..0877770c167 100644 --- a/spec/initializers/6_validations_spec.rb +++ b/spec/initializers/6_validations_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require_relative '../../config/initializers/6_validations.rb' -describe '6_validations', lib: true do +describe '6_validations' do before :all do FileUtils.mkdir_p('tmp/tests/paths/a/b/c/d') FileUtils.mkdir_p('tmp/tests/paths/a/b/c2') diff --git a/spec/initializers/8_metrics_spec.rb b/spec/initializers/8_metrics_spec.rb index d4189f902fd..4e6052a9f80 100644 --- a/spec/initializers/8_metrics_spec.rb +++ b/spec/initializers/8_metrics_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'instrument_classes', lib: true do +describe 'instrument_classes' do let(:config) { double(:config) } let(:unicorn_sampler) { double(:unicorn_sampler) } diff --git a/spec/initializers/secret_token_spec.rb b/spec/initializers/secret_token_spec.rb index 65c97da2efd..84ad55e9f98 100644 --- a/spec/initializers/secret_token_spec.rb +++ b/spec/initializers/secret_token_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require_relative '../../config/initializers/secret_token' -describe 'create_tokens', lib: true do +describe 'create_tokens' do include StubENV let(:secrets) { ActiveSupport::OrderedOptions.new } diff --git a/spec/initializers/settings_spec.rb b/spec/initializers/settings_spec.rb index 47b4e431823..ebdabcf93f1 100644 --- a/spec/initializers/settings_spec.rb +++ b/spec/initializers/settings_spec.rb @@ -1,41 +1,41 @@ require 'spec_helper' require_relative '../../config/initializers/1_settings' -describe Settings, lib: true do +describe Settings do describe '#host_without_www' do context 'URL with protocol' do it 'returns the host' do - expect(Settings.host_without_www('http://foo.com')).to eq 'foo.com' - expect(Settings.host_without_www('http://www.foo.com')).to eq 'foo.com' - expect(Settings.host_without_www('http://secure.foo.com')).to eq 'secure.foo.com' - expect(Settings.host_without_www('http://www.gravatar.com/avatar/%{hash}?s=%{size}&d=identicon')).to eq 'gravatar.com' + expect(described_class.host_without_www('http://foo.com')).to eq 'foo.com' + expect(described_class.host_without_www('http://www.foo.com')).to eq 'foo.com' + expect(described_class.host_without_www('http://secure.foo.com')).to eq 'secure.foo.com' + expect(described_class.host_without_www('http://www.gravatar.com/avatar/%{hash}?s=%{size}&d=identicon')).to eq 'gravatar.com' - expect(Settings.host_without_www('https://foo.com')).to eq 'foo.com' - expect(Settings.host_without_www('https://www.foo.com')).to eq 'foo.com' - expect(Settings.host_without_www('https://secure.foo.com')).to eq 'secure.foo.com' - expect(Settings.host_without_www('https://secure.gravatar.com/avatar/%{hash}?s=%{size}&d=identicon')).to eq 'secure.gravatar.com' + expect(described_class.host_without_www('https://foo.com')).to eq 'foo.com' + expect(described_class.host_without_www('https://www.foo.com')).to eq 'foo.com' + expect(described_class.host_without_www('https://secure.foo.com')).to eq 'secure.foo.com' + expect(described_class.host_without_www('https://secure.gravatar.com/avatar/%{hash}?s=%{size}&d=identicon')).to eq 'secure.gravatar.com' end end context 'URL without protocol' do it 'returns the host' do - expect(Settings.host_without_www('foo.com')).to eq 'foo.com' - expect(Settings.host_without_www('www.foo.com')).to eq 'foo.com' - expect(Settings.host_without_www('secure.foo.com')).to eq 'secure.foo.com' - expect(Settings.host_without_www('www.gravatar.com/avatar/%{hash}?s=%{size}&d=identicon')).to eq 'gravatar.com' + expect(described_class.host_without_www('foo.com')).to eq 'foo.com' + expect(described_class.host_without_www('www.foo.com')).to eq 'foo.com' + expect(described_class.host_without_www('secure.foo.com')).to eq 'secure.foo.com' + expect(described_class.host_without_www('www.gravatar.com/avatar/%{hash}?s=%{size}&d=identicon')).to eq 'gravatar.com' end context 'URL with user/port' do it 'returns the host' do - expect(Settings.host_without_www('bob:pass@foo.com:8080')).to eq 'foo.com' - expect(Settings.host_without_www('bob:pass@www.foo.com:8080')).to eq 'foo.com' - expect(Settings.host_without_www('bob:pass@secure.foo.com:8080')).to eq 'secure.foo.com' - expect(Settings.host_without_www('bob:pass@www.gravatar.com:8080/avatar/%{hash}?s=%{size}&d=identicon')).to eq 'gravatar.com' + expect(described_class.host_without_www('bob:pass@foo.com:8080')).to eq 'foo.com' + expect(described_class.host_without_www('bob:pass@www.foo.com:8080')).to eq 'foo.com' + expect(described_class.host_without_www('bob:pass@secure.foo.com:8080')).to eq 'secure.foo.com' + expect(described_class.host_without_www('bob:pass@www.gravatar.com:8080/avatar/%{hash}?s=%{size}&d=identicon')).to eq 'gravatar.com' - expect(Settings.host_without_www('http://bob:pass@foo.com:8080')).to eq 'foo.com' - expect(Settings.host_without_www('http://bob:pass@www.foo.com:8080')).to eq 'foo.com' - expect(Settings.host_without_www('http://bob:pass@secure.foo.com:8080')).to eq 'secure.foo.com' - expect(Settings.host_without_www('http://bob:pass@www.gravatar.com:8080/avatar/%{hash}?s=%{size}&d=identicon')).to eq 'gravatar.com' + expect(described_class.host_without_www('http://bob:pass@foo.com:8080')).to eq 'foo.com' + expect(described_class.host_without_www('http://bob:pass@www.foo.com:8080')).to eq 'foo.com' + expect(described_class.host_without_www('http://bob:pass@secure.foo.com:8080')).to eq 'secure.foo.com' + expect(described_class.host_without_www('http://bob:pass@www.gravatar.com:8080/avatar/%{hash}?s=%{size}&d=identicon')).to eq 'gravatar.com' end end end diff --git a/spec/initializers/trusted_proxies_spec.rb b/spec/initializers/trusted_proxies_spec.rb index 70a18f31744..02a9446ad7b 100644 --- a/spec/initializers/trusted_proxies_spec.rb +++ b/spec/initializers/trusted_proxies_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'trusted_proxies', lib: true do +describe 'trusted_proxies' do context 'with default config' do before do set_trusted_proxies([]) diff --git a/spec/javascripts/integrations/integration_settings_form_spec.js b/spec/javascripts/integrations/integration_settings_form_spec.js index 45909d4e70e..3daeb91b1e2 100644 --- a/spec/javascripts/integrations/integration_settings_form_spec.js +++ b/spec/javascripts/integrations/integration_settings_form_spec.js @@ -135,10 +135,10 @@ describe('IntegrationSettingsForm', () => { integrationSettingsForm.testSettings(formData); - deferred.resolve({ error: true, message: errorMessage }); + deferred.resolve({ error: true, message: errorMessage, service_response: 'some error' }); const $flashContainer = $('.flash-container'); - expect($flashContainer.find('.flash-text').text()).toEqual(errorMessage); + expect($flashContainer.find('.flash-text').text()).toEqual('Test failed. some error'); expect($flashContainer.find('.flash-action')).toBeDefined(); expect($flashContainer.find('.flash-action').text()).toEqual('Save anyway'); }); diff --git a/spec/lib/banzai/cross_project_reference_spec.rb b/spec/lib/banzai/cross_project_reference_spec.rb index 787212581e2..d70749536b8 100644 --- a/spec/lib/banzai/cross_project_reference_spec.rb +++ b/spec/lib/banzai/cross_project_reference_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Banzai::CrossProjectReference, lib: true do +describe Banzai::CrossProjectReference do include described_class describe '#project_from_ref' do diff --git a/spec/lib/banzai/filter/ascii_doc_post_processing_filter_spec.rb b/spec/lib/banzai/filter/ascii_doc_post_processing_filter_spec.rb index 33b812ef425..34f1657b6d3 100644 --- a/spec/lib/banzai/filter/ascii_doc_post_processing_filter_spec.rb +++ b/spec/lib/banzai/filter/ascii_doc_post_processing_filter_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Banzai::Filter::AsciiDocPostProcessingFilter, lib: true do +describe Banzai::Filter::AsciiDocPostProcessingFilter do include FilterSpecHelper it "adds class for elements with data-math-style" do diff --git a/spec/lib/banzai/filter/autolink_filter_spec.rb b/spec/lib/banzai/filter/autolink_filter_spec.rb index a6d2ea11fcc..b7c2ff03125 100644 --- a/spec/lib/banzai/filter/autolink_filter_spec.rb +++ b/spec/lib/banzai/filter/autolink_filter_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Banzai::Filter::AutolinkFilter, lib: true do +describe Banzai::Filter::AutolinkFilter do include FilterSpecHelper let(:link) { 'http://about.gitlab.com/' } diff --git a/spec/lib/banzai/filter/blockquote_fence_filter_spec.rb b/spec/lib/banzai/filter/blockquote_fence_filter_spec.rb index 2799249ae3e..8224dc5a6b9 100644 --- a/spec/lib/banzai/filter/blockquote_fence_filter_spec.rb +++ b/spec/lib/banzai/filter/blockquote_fence_filter_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe Banzai::Filter::BlockquoteFenceFilter, lib: true do +describe Banzai::Filter::BlockquoteFenceFilter do include FilterSpecHelper it 'converts blockquote fences to blockquote lines' do diff --git a/spec/lib/banzai/filter/commit_range_reference_filter_spec.rb b/spec/lib/banzai/filter/commit_range_reference_filter_spec.rb index 60c27bc0d3c..11d48387544 100644 --- a/spec/lib/banzai/filter/commit_range_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/commit_range_reference_filter_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Banzai::Filter::CommitRangeReferenceFilter, lib: true do +describe Banzai::Filter::CommitRangeReferenceFilter do include FilterSpecHelper let(:project) { create(:project, :public, :repository) } diff --git a/spec/lib/banzai/filter/commit_reference_filter_spec.rb b/spec/lib/banzai/filter/commit_reference_filter_spec.rb index f6893641481..fb2a36d1ba1 100644 --- a/spec/lib/banzai/filter/commit_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/commit_reference_filter_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Banzai::Filter::CommitReferenceFilter, lib: true do +describe Banzai::Filter::CommitReferenceFilter do include FilterSpecHelper let(:project) { create(:project, :public, :repository) } diff --git a/spec/lib/banzai/filter/emoji_filter_spec.rb b/spec/lib/banzai/filter/emoji_filter_spec.rb index 086a006c45f..10910f22d4a 100644 --- a/spec/lib/banzai/filter/emoji_filter_spec.rb +++ b/spec/lib/banzai/filter/emoji_filter_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Banzai::Filter::EmojiFilter, lib: true do +describe Banzai::Filter::EmojiFilter do include FilterSpecHelper before do diff --git a/spec/lib/banzai/filter/external_issue_reference_filter_spec.rb b/spec/lib/banzai/filter/external_issue_reference_filter_spec.rb index fb320e0148a..a0d391d981c 100644 --- a/spec/lib/banzai/filter/external_issue_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/external_issue_reference_filter_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Banzai::Filter::ExternalIssueReferenceFilter, lib: true do +describe Banzai::Filter::ExternalIssueReferenceFilter do include FilterSpecHelper def helper diff --git a/spec/lib/banzai/filter/external_link_filter_spec.rb b/spec/lib/banzai/filter/external_link_filter_spec.rb index 0f8ec8de7a0..2a3c0cd78b8 100644 --- a/spec/lib/banzai/filter/external_link_filter_spec.rb +++ b/spec/lib/banzai/filter/external_link_filter_spec.rb @@ -17,7 +17,7 @@ shared_examples 'an external link with rel attribute' do end end -describe Banzai::Filter::ExternalLinkFilter, lib: true do +describe Banzai::Filter::ExternalLinkFilter do include FilterSpecHelper it 'ignores elements without an href attribute' do diff --git a/spec/lib/banzai/filter/gollum_tags_filter_spec.rb b/spec/lib/banzai/filter/gollum_tags_filter_spec.rb index cbb2808c6bb..663e3514436 100644 --- a/spec/lib/banzai/filter/gollum_tags_filter_spec.rb +++ b/spec/lib/banzai/filter/gollum_tags_filter_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Banzai::Filter::GollumTagsFilter, lib: true do +describe Banzai::Filter::GollumTagsFilter do include FilterSpecHelper let(:project) { create(:empty_project) } diff --git a/spec/lib/banzai/filter/html_entity_filter_spec.rb b/spec/lib/banzai/filter/html_entity_filter_spec.rb index f9e6bd609f0..91e18d876d5 100644 --- a/spec/lib/banzai/filter/html_entity_filter_spec.rb +++ b/spec/lib/banzai/filter/html_entity_filter_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Banzai::Filter::HtmlEntityFilter, lib: true do +describe Banzai::Filter::HtmlEntityFilter do include FilterSpecHelper let(:unescaped) { 'foo <strike attr="foo">&&&</strike>' } diff --git a/spec/lib/banzai/filter/image_link_filter_spec.rb b/spec/lib/banzai/filter/image_link_filter_spec.rb index 294558b3db2..51920869545 100644 --- a/spec/lib/banzai/filter/image_link_filter_spec.rb +++ b/spec/lib/banzai/filter/image_link_filter_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Banzai::Filter::ImageLinkFilter, lib: true do +describe Banzai::Filter::ImageLinkFilter do include FilterSpecHelper def image(path) diff --git a/spec/lib/banzai/filter/inline_diff_filter_spec.rb b/spec/lib/banzai/filter/inline_diff_filter_spec.rb index 9e526371294..63c4ab61b86 100644 --- a/spec/lib/banzai/filter/inline_diff_filter_spec.rb +++ b/spec/lib/banzai/filter/inline_diff_filter_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Banzai::Filter::InlineDiffFilter, lib: true do +describe Banzai::Filter::InlineDiffFilter do include FilterSpecHelper it 'adds inline diff span tags for deletions when using square brackets' do diff --git a/spec/lib/banzai/filter/issuable_state_filter_spec.rb b/spec/lib/banzai/filter/issuable_state_filter_spec.rb index 9c2399815b9..bc7cae1df8d 100644 --- a/spec/lib/banzai/filter/issuable_state_filter_spec.rb +++ b/spec/lib/banzai/filter/issuable_state_filter_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Banzai::Filter::IssuableStateFilter, lib: true do +describe Banzai::Filter::IssuableStateFilter do include ActionView::Helpers::UrlHelper include FilterSpecHelper @@ -107,14 +107,6 @@ describe Banzai::Filter::IssuableStateFilter, lib: true do expect(doc.css('a').last.text).to eq(issue.to_reference) end - it 'ignores reopened issue references' do - issue = create_issue(:reopened) - link = create_link(issue.to_reference, issue: issue.id, reference_type: 'issue') - doc = filter(link, context) - - expect(doc.css('a').last.text).to eq(issue.to_reference) - end - it 'appends state to closed issue references' do link = create_link(closed_issue.to_reference, issue: closed_issue.id, reference_type: 'issue') doc = filter(link, context) @@ -139,7 +131,7 @@ describe Banzai::Filter::IssuableStateFilter, lib: true do end it 'ignores reopened merge request references' do - merge_request = create_merge_request(:reopened) + merge_request = create_merge_request(:opened) link = create_link( merge_request.to_reference, diff --git a/spec/lib/banzai/filter/issue_reference_filter_spec.rb b/spec/lib/banzai/filter/issue_reference_filter_spec.rb index a79d365d6c5..045bf3e0cc9 100644 --- a/spec/lib/banzai/filter/issue_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/issue_reference_filter_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Banzai::Filter::IssueReferenceFilter, lib: true do +describe Banzai::Filter::IssueReferenceFilter do include FilterSpecHelper def helper diff --git a/spec/lib/banzai/filter/label_reference_filter_spec.rb b/spec/lib/banzai/filter/label_reference_filter_spec.rb index 8daef3ca691..1daa6ac7f9e 100644 --- a/spec/lib/banzai/filter/label_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/label_reference_filter_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'html/pipeline' -describe Banzai::Filter::LabelReferenceFilter, lib: true do +describe Banzai::Filter::LabelReferenceFilter do include FilterSpecHelper let(:project) { create(:empty_project, :public, name: 'sample-project') } diff --git a/spec/lib/banzai/filter/markdown_filter_spec.rb b/spec/lib/banzai/filter/markdown_filter_spec.rb index 897288b8ad5..00c407d1b69 100644 --- a/spec/lib/banzai/filter/markdown_filter_spec.rb +++ b/spec/lib/banzai/filter/markdown_filter_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Banzai::Filter::MarkdownFilter, lib: true do +describe Banzai::Filter::MarkdownFilter do include FilterSpecHelper context 'code block' do diff --git a/spec/lib/banzai/filter/math_filter_spec.rb b/spec/lib/banzai/filter/math_filter_spec.rb index 51883782e19..cade8cb409e 100644 --- a/spec/lib/banzai/filter/math_filter_spec.rb +++ b/spec/lib/banzai/filter/math_filter_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Banzai::Filter::MathFilter, lib: true do +describe Banzai::Filter::MathFilter do include FilterSpecHelper it 'leaves regular inline code unchanged' do diff --git a/spec/lib/banzai/filter/merge_request_reference_filter_spec.rb b/spec/lib/banzai/filter/merge_request_reference_filter_spec.rb index 1ad329b6452..683972a3112 100644 --- a/spec/lib/banzai/filter/merge_request_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/merge_request_reference_filter_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Banzai::Filter::MergeRequestReferenceFilter, lib: true do +describe Banzai::Filter::MergeRequestReferenceFilter do include FilterSpecHelper let(:project) { create(:empty_project, :public) } diff --git a/spec/lib/banzai/filter/milestone_reference_filter_spec.rb b/spec/lib/banzai/filter/milestone_reference_filter_spec.rb index 7fab5613afc..8fe05dc2e53 100644 --- a/spec/lib/banzai/filter/milestone_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/milestone_reference_filter_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Banzai::Filter::MilestoneReferenceFilter, lib: true do +describe Banzai::Filter::MilestoneReferenceFilter do include FilterSpecHelper let(:project) { create(:empty_project, :public) } diff --git a/spec/lib/banzai/filter/plantuml_filter_spec.rb b/spec/lib/banzai/filter/plantuml_filter_spec.rb index 9b8ecb201f3..8235c411eb7 100644 --- a/spec/lib/banzai/filter/plantuml_filter_spec.rb +++ b/spec/lib/banzai/filter/plantuml_filter_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Banzai::Filter::PlantumlFilter, lib: true do +describe Banzai::Filter::PlantumlFilter do include FilterSpecHelper it 'should replace plantuml pre tag with img tag' do diff --git a/spec/lib/banzai/filter/redactor_filter_spec.rb b/spec/lib/banzai/filter/redactor_filter_spec.rb index b81cdbb8957..fb6b81d4f10 100644 --- a/spec/lib/banzai/filter/redactor_filter_spec.rb +++ b/spec/lib/banzai/filter/redactor_filter_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Banzai::Filter::RedactorFilter, lib: true do +describe Banzai::Filter::RedactorFilter do include ActionView::Helpers::UrlHelper include FilterSpecHelper diff --git a/spec/lib/banzai/filter/reference_filter_spec.rb b/spec/lib/banzai/filter/reference_filter_spec.rb index ba0fa4a609a..b9ca68e8935 100644 --- a/spec/lib/banzai/filter/reference_filter_spec.rb +++ b/spec/lib/banzai/filter/reference_filter_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Banzai::Filter::ReferenceFilter, lib: true do +describe Banzai::Filter::ReferenceFilter do let(:project) { build(:project) } describe '#each_node' do diff --git a/spec/lib/banzai/filter/relative_link_filter_spec.rb b/spec/lib/banzai/filter/relative_link_filter_spec.rb index 1ce7bd7706e..ddebf2264d9 100644 --- a/spec/lib/banzai/filter/relative_link_filter_spec.rb +++ b/spec/lib/banzai/filter/relative_link_filter_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Banzai::Filter::RelativeLinkFilter, lib: true do +describe Banzai::Filter::RelativeLinkFilter do def filter(doc, contexts = {}) contexts.reverse_merge!({ commit: commit, diff --git a/spec/lib/banzai/filter/sanitization_filter_spec.rb b/spec/lib/banzai/filter/sanitization_filter_spec.rb index a8a0aa6d395..35a32a46eff 100644 --- a/spec/lib/banzai/filter/sanitization_filter_spec.rb +++ b/spec/lib/banzai/filter/sanitization_filter_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Banzai::Filter::SanitizationFilter, lib: true do +describe Banzai::Filter::SanitizationFilter do include FilterSpecHelper describe 'default whitelist' do diff --git a/spec/lib/banzai/filter/snippet_reference_filter_spec.rb b/spec/lib/banzai/filter/snippet_reference_filter_spec.rb index 9704db0c221..5f548888223 100644 --- a/spec/lib/banzai/filter/snippet_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/snippet_reference_filter_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Banzai::Filter::SnippetReferenceFilter, lib: true do +describe Banzai::Filter::SnippetReferenceFilter do include FilterSpecHelper let(:project) { create(:empty_project, :public) } diff --git a/spec/lib/banzai/filter/syntax_highlight_filter_spec.rb b/spec/lib/banzai/filter/syntax_highlight_filter_spec.rb index f61fc8ceb9e..5a23e0e70cc 100644 --- a/spec/lib/banzai/filter/syntax_highlight_filter_spec.rb +++ b/spec/lib/banzai/filter/syntax_highlight_filter_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Banzai::Filter::SyntaxHighlightFilter, lib: true do +describe Banzai::Filter::SyntaxHighlightFilter do include FilterSpecHelper context "when no language is specified" do diff --git a/spec/lib/banzai/filter/table_of_contents_filter_spec.rb b/spec/lib/banzai/filter/table_of_contents_filter_spec.rb index 70b31f3a880..ff6b19459bb 100644 --- a/spec/lib/banzai/filter/table_of_contents_filter_spec.rb +++ b/spec/lib/banzai/filter/table_of_contents_filter_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Banzai::Filter::TableOfContentsFilter, lib: true do +describe Banzai::Filter::TableOfContentsFilter do include FilterSpecHelper def header(level, text) diff --git a/spec/lib/banzai/filter/upload_link_filter_spec.rb b/spec/lib/banzai/filter/upload_link_filter_spec.rb index 6327ca8bbfd..3bc9635b50e 100644 --- a/spec/lib/banzai/filter/upload_link_filter_spec.rb +++ b/spec/lib/banzai/filter/upload_link_filter_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Banzai::Filter::UploadLinkFilter, lib: true do +describe Banzai::Filter::UploadLinkFilter do def filter(doc, contexts = {}) contexts.reverse_merge!({ project: project diff --git a/spec/lib/banzai/filter/user_reference_filter_spec.rb b/spec/lib/banzai/filter/user_reference_filter_spec.rb index 77561e00573..7ea9df5eda5 100644 --- a/spec/lib/banzai/filter/user_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/user_reference_filter_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Banzai::Filter::UserReferenceFilter, lib: true do +describe Banzai::Filter::UserReferenceFilter do include FilterSpecHelper let(:project) { create(:empty_project, :public) } diff --git a/spec/lib/banzai/filter/video_link_filter_spec.rb b/spec/lib/banzai/filter/video_link_filter_spec.rb index 00494f545a3..81dda0687f3 100644 --- a/spec/lib/banzai/filter/video_link_filter_spec.rb +++ b/spec/lib/banzai/filter/video_link_filter_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Banzai::Filter::VideoLinkFilter, lib: true do +describe Banzai::Filter::VideoLinkFilter do def filter(doc, contexts = {}) contexts.reverse_merge!({ project: project diff --git a/spec/lib/banzai/filter/wiki_link_filter_spec.rb b/spec/lib/banzai/filter/wiki_link_filter_spec.rb index 92d88c4172c..ceafd12a68e 100644 --- a/spec/lib/banzai/filter/wiki_link_filter_spec.rb +++ b/spec/lib/banzai/filter/wiki_link_filter_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Banzai::Filter::WikiLinkFilter, lib: true do +describe Banzai::Filter::WikiLinkFilter do include FilterSpecHelper let(:namespace) { build_stubbed(:namespace, name: "wiki_link_ns") } diff --git a/spec/lib/banzai/filter/yaml_front_matter_filter_spec.rb b/spec/lib/banzai/filter/yaml_front_matter_filter_spec.rb index fe70eada7eb..9f1b862ef19 100644 --- a/spec/lib/banzai/filter/yaml_front_matter_filter_spec.rb +++ b/spec/lib/banzai/filter/yaml_front_matter_filter_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe Banzai::Filter::YamlFrontMatterFilter, lib: true do +describe Banzai::Filter::YamlFrontMatterFilter do include FilterSpecHelper it 'allows for `encoding:` before the frontmatter' do diff --git a/spec/lib/banzai/issuable_extractor_spec.rb b/spec/lib/banzai/issuable_extractor_spec.rb index 866297f94a9..728271e757b 100644 --- a/spec/lib/banzai/issuable_extractor_spec.rb +++ b/spec/lib/banzai/issuable_extractor_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Banzai::IssuableExtractor, lib: true do +describe Banzai::IssuableExtractor do let(:project) { create(:empty_project) } let(:user) { create(:user) } let(:extractor) { described_class.new(project, user) } diff --git a/spec/lib/banzai/reference_parser/base_parser_spec.rb b/spec/lib/banzai/reference_parser/base_parser_spec.rb index b444ca05b8e..0bf45329657 100644 --- a/spec/lib/banzai/reference_parser/base_parser_spec.rb +++ b/spec/lib/banzai/reference_parser/base_parser_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Banzai::ReferenceParser::BaseParser, lib: true do +describe Banzai::ReferenceParser::BaseParser do include ReferenceParserHelpers let(:user) { create(:user) } diff --git a/spec/lib/banzai/reference_parser/commit_parser_spec.rb b/spec/lib/banzai/reference_parser/commit_parser_spec.rb index a314a6119cb..69bf28cdf85 100644 --- a/spec/lib/banzai/reference_parser/commit_parser_spec.rb +++ b/spec/lib/banzai/reference_parser/commit_parser_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Banzai::ReferenceParser::CommitParser, lib: true do +describe Banzai::ReferenceParser::CommitParser do include ReferenceParserHelpers let(:project) { create(:empty_project, :public) } diff --git a/spec/lib/banzai/reference_parser/commit_range_parser_spec.rb b/spec/lib/banzai/reference_parser/commit_range_parser_spec.rb index 5dca5e784da..b384a59bfb4 100644 --- a/spec/lib/banzai/reference_parser/commit_range_parser_spec.rb +++ b/spec/lib/banzai/reference_parser/commit_range_parser_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Banzai::ReferenceParser::CommitRangeParser, lib: true do +describe Banzai::ReferenceParser::CommitRangeParser do include ReferenceParserHelpers let(:project) { create(:empty_project, :public) } diff --git a/spec/lib/banzai/reference_parser/external_issue_parser_spec.rb b/spec/lib/banzai/reference_parser/external_issue_parser_spec.rb index d212bbac619..a3256afdbb1 100644 --- a/spec/lib/banzai/reference_parser/external_issue_parser_spec.rb +++ b/spec/lib/banzai/reference_parser/external_issue_parser_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Banzai::ReferenceParser::ExternalIssueParser, lib: true do +describe Banzai::ReferenceParser::ExternalIssueParser do include ReferenceParserHelpers let(:project) { create(:empty_project, :public) } diff --git a/spec/lib/banzai/reference_parser/issue_parser_spec.rb b/spec/lib/banzai/reference_parser/issue_parser_spec.rb index acdd23f81f3..94b989fe91d 100644 --- a/spec/lib/banzai/reference_parser/issue_parser_spec.rb +++ b/spec/lib/banzai/reference_parser/issue_parser_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Banzai::ReferenceParser::IssueParser, lib: true do +describe Banzai::ReferenceParser::IssueParser do include ReferenceParserHelpers let(:project) { create(:empty_project, :public) } diff --git a/spec/lib/banzai/reference_parser/label_parser_spec.rb b/spec/lib/banzai/reference_parser/label_parser_spec.rb index ddd699f3c25..cf1b2a92195 100644 --- a/spec/lib/banzai/reference_parser/label_parser_spec.rb +++ b/spec/lib/banzai/reference_parser/label_parser_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Banzai::ReferenceParser::LabelParser, lib: true do +describe Banzai::ReferenceParser::LabelParser do include ReferenceParserHelpers let(:project) { create(:empty_project, :public) } diff --git a/spec/lib/banzai/reference_parser/merge_request_parser_spec.rb b/spec/lib/banzai/reference_parser/merge_request_parser_spec.rb index cb69ca16800..775749ae3a7 100644 --- a/spec/lib/banzai/reference_parser/merge_request_parser_spec.rb +++ b/spec/lib/banzai/reference_parser/merge_request_parser_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Banzai::ReferenceParser::MergeRequestParser, lib: true do +describe Banzai::ReferenceParser::MergeRequestParser do include ReferenceParserHelpers let(:user) { create(:user) } diff --git a/spec/lib/banzai/reference_parser/milestone_parser_spec.rb b/spec/lib/banzai/reference_parser/milestone_parser_spec.rb index 72d4f3bc18e..2cfcafa8798 100644 --- a/spec/lib/banzai/reference_parser/milestone_parser_spec.rb +++ b/spec/lib/banzai/reference_parser/milestone_parser_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Banzai::ReferenceParser::MilestoneParser, lib: true do +describe Banzai::ReferenceParser::MilestoneParser do include ReferenceParserHelpers let(:project) { create(:empty_project, :public) } diff --git a/spec/lib/banzai/reference_parser/snippet_parser_spec.rb b/spec/lib/banzai/reference_parser/snippet_parser_spec.rb index 620875ece20..c6d0b7be254 100644 --- a/spec/lib/banzai/reference_parser/snippet_parser_spec.rb +++ b/spec/lib/banzai/reference_parser/snippet_parser_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Banzai::ReferenceParser::SnippetParser, lib: true do +describe Banzai::ReferenceParser::SnippetParser do include ReferenceParserHelpers let(:project) { create(:empty_project, :public) } diff --git a/spec/lib/banzai/reference_parser/user_parser_spec.rb b/spec/lib/banzai/reference_parser/user_parser_spec.rb index dfebb971f3a..64f2b607d7c 100644 --- a/spec/lib/banzai/reference_parser/user_parser_spec.rb +++ b/spec/lib/banzai/reference_parser/user_parser_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Banzai::ReferenceParser::UserParser, lib: true do +describe Banzai::ReferenceParser::UserParser do include ReferenceParserHelpers let(:group) { create(:group) } diff --git a/spec/lib/ci/ansi2html_spec.rb b/spec/lib/ci/ansi2html_spec.rb index a5dfb49478a..e49ecadde20 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, lib: true do +describe Ci::Ansi2html do subject { described_class } it "prints non-ansi as-is" do diff --git a/spec/lib/ci/charts_spec.rb b/spec/lib/ci/charts_spec.rb index 51cbfd2a848..8e2d2724426 100644 --- a/spec/lib/ci/charts_spec.rb +++ b/spec/lib/ci/charts_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Ci::Charts, lib: true do +describe Ci::Charts do context "pipeline_times" do let(:project) { create(:empty_project) } let(:chart) { Ci::Charts::PipelineTime.new(project) } diff --git a/spec/lib/ci/mask_secret_spec.rb b/spec/lib/ci/mask_secret_spec.rb index 3101bed20fb..f7b753b022b 100644 --- a/spec/lib/ci/mask_secret_spec.rb +++ b/spec/lib/ci/mask_secret_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Ci::MaskSecret, lib: true do +describe Ci::MaskSecret do subject { described_class } describe '#mask' do diff --git a/spec/lib/constraints/group_url_constrainer_spec.rb b/spec/lib/constraints/group_url_constrainer_spec.rb index db680489a8d..4dab58b26a0 100644 --- a/spec/lib/constraints/group_url_constrainer_spec.rb +++ b/spec/lib/constraints/group_url_constrainer_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe GroupUrlConstrainer, lib: true do +describe GroupUrlConstrainer do let!(:group) { create(:group, path: 'gitlab') } describe '#matches?' do diff --git a/spec/lib/constraints/project_url_constrainer_spec.rb b/spec/lib/constraints/project_url_constrainer_spec.rb index b6884e37aa3..e4b5dfc574a 100644 --- a/spec/lib/constraints/project_url_constrainer_spec.rb +++ b/spec/lib/constraints/project_url_constrainer_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe ProjectUrlConstrainer, lib: true do +describe ProjectUrlConstrainer do let!(:project) { create(:empty_project) } let!(:namespace) { project.namespace } diff --git a/spec/lib/constraints/user_url_constrainer_spec.rb b/spec/lib/constraints/user_url_constrainer_spec.rb index ed69b830979..cb3b4ff1391 100644 --- a/spec/lib/constraints/user_url_constrainer_spec.rb +++ b/spec/lib/constraints/user_url_constrainer_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe UserUrlConstrainer, lib: true do +describe UserUrlConstrainer do let!(:user) { create(:user, username: 'dz') } describe '#matches?' do diff --git a/spec/lib/disable_email_interceptor_spec.rb b/spec/lib/disable_email_interceptor_spec.rb index 8f51474476d..3652d928c43 100644 --- a/spec/lib/disable_email_interceptor_spec.rb +++ b/spec/lib/disable_email_interceptor_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' -describe DisableEmailInterceptor, lib: true do +describe DisableEmailInterceptor do before do - Mail.register_interceptor(DisableEmailInterceptor) + Mail.register_interceptor(described_class) end it 'does not send emails' do @@ -14,7 +14,7 @@ describe DisableEmailInterceptor, lib: true do # Removing interceptor from the list because unregister_interceptor is # implemented in later version of mail gem # See: https://github.com/mikel/mail/pull/705 - Mail.unregister_interceptor(DisableEmailInterceptor) + Mail.unregister_interceptor(described_class) end def deliver_mail diff --git a/spec/lib/event_filter_spec.rb b/spec/lib/event_filter_spec.rb index d70690f589d..b1366e74802 100644 --- a/spec/lib/event_filter_spec.rb +++ b/spec/lib/event_filter_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe EventFilter, lib: true do +describe EventFilter do describe '#apply_filter' do let(:source_user) { create(:user) } let!(:public_project) { create(:empty_project, :public) } @@ -16,42 +16,42 @@ describe EventFilter, lib: true do let!(:left_event) { create(:event, :left, project: public_project, target: public_project, author: source_user) } it 'applies push filter' do - events = EventFilter.new(EventFilter.push).apply_filter(Event.all) + events = described_class.new(described_class.push).apply_filter(Event.all) expect(events).to contain_exactly(push_event) end it 'applies merged filter' do - events = EventFilter.new(EventFilter.merged).apply_filter(Event.all) + events = described_class.new(described_class.merged).apply_filter(Event.all) expect(events).to contain_exactly(merged_event) end it 'applies issue filter' do - events = EventFilter.new(EventFilter.issue).apply_filter(Event.all) + events = described_class.new(described_class.issue).apply_filter(Event.all) expect(events).to contain_exactly(created_event, updated_event, closed_event, reopened_event) end it 'applies comments filter' do - events = EventFilter.new(EventFilter.comments).apply_filter(Event.all) + events = described_class.new(described_class.comments).apply_filter(Event.all) expect(events).to contain_exactly(comments_event) end it 'applies team filter' do - events = EventFilter.new(EventFilter.team).apply_filter(Event.all) + events = described_class.new(described_class.team).apply_filter(Event.all) expect(events).to contain_exactly(joined_event, left_event) end it 'applies all filter' do - events = EventFilter.new(EventFilter.all).apply_filter(Event.all) + events = described_class.new(described_class.all).apply_filter(Event.all) expect(events).to contain_exactly(push_event, merged_event, created_event, updated_event, closed_event, reopened_event, comments_event, joined_event, left_event) end it 'applies no filter' do - events = EventFilter.new(nil).apply_filter(Event.all) + events = described_class.new(nil).apply_filter(Event.all) expect(events).to contain_exactly(push_event, merged_event, created_event, updated_event, closed_event, reopened_event, comments_event, joined_event, left_event) end it 'applies unknown filter' do - events = EventFilter.new('').apply_filter(Event.all) + events = described_class.new('').apply_filter(Event.all) expect(events).to contain_exactly(push_event, merged_event, created_event, updated_event, closed_event, reopened_event, comments_event, joined_event, left_event) end end diff --git a/spec/lib/extracts_path_spec.rb b/spec/lib/extracts_path_spec.rb index dfffef8b9b7..9b89f47ae7e 100644 --- a/spec/lib/extracts_path_spec.rb +++ b/spec/lib/extracts_path_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' -describe ExtractsPath, lib: true do - include ExtractsPath +describe ExtractsPath do + include described_class include RepoHelpers include Gitlab::Routing diff --git a/spec/lib/feature_spec.rb b/spec/lib/feature_spec.rb index 5cc3a3745e4..1076c63b5f2 100644 --- a/spec/lib/feature_spec.rb +++ b/spec/lib/feature_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Feature, lib: true do +describe Feature do describe '.get' do let(:feature) { double(:feature) } let(:key) { 'my_feature' } diff --git a/spec/lib/file_size_validator_spec.rb b/spec/lib/file_size_validator_spec.rb index fda6f9a6c88..49501931dd2 100644 --- a/spec/lib/file_size_validator_spec.rb +++ b/spec/lib/file_size_validator_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' -describe FileSizeValidator, lib: true do - let(:validator) { FileSizeValidator.new(options) } +describe FileSizeValidator do + let(:validator) { described_class.new(options) } let(:attachment) { AttachmentUploader.new } let(:note) { create(:note) } diff --git a/spec/lib/gitlab/asciidoc_spec.rb b/spec/lib/gitlab/asciidoc_spec.rb index 43d52b941ab..f668f78c2b8 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, lib: true do + describe Asciidoc do let(:input) { '<b>ascii</b>' } let(:context) { {} } let(:html) { 'H<sub>2</sub>O' } diff --git a/spec/lib/gitlab/auth/unique_ips_limiter_spec.rb b/spec/lib/gitlab/auth/unique_ips_limiter_spec.rb index 15b3db0ed3d..f29431b937c 100644 --- a/spec/lib/gitlab/auth/unique_ips_limiter_spec.rb +++ b/spec/lib/gitlab/auth/unique_ips_limiter_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::Auth::UniqueIpsLimiter, :clean_gitlab_redis_shared_state, lib: true do +describe Gitlab::Auth::UniqueIpsLimiter, :clean_gitlab_redis_shared_state do include_context 'unique ips sign in limit' let(:user) { create(:user) } diff --git a/spec/lib/gitlab/auth_spec.rb b/spec/lib/gitlab/auth_spec.rb index 55780518230..a9db0d5164d 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, lib: true do +describe Gitlab::Auth do let(:gl_auth) { described_class } describe 'constants' do diff --git a/spec/lib/gitlab/backup/manager_spec.rb b/spec/lib/gitlab/backup/manager_spec.rb index 1c3d2547fec..8772d3d5ada 100644 --- a/spec/lib/gitlab/backup/manager_spec.rb +++ b/spec/lib/gitlab/backup/manager_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Backup::Manager, lib: true do +describe Backup::Manager do include StubENV let(:progress) { StringIO.new } @@ -214,4 +214,56 @@ describe Backup::Manager, lib: true do end end end + + describe '#upload' do + let(:backup_file) { Tempfile.new('backup', Gitlab.config.backup.path) } + let(:backup_filename) { File.basename(backup_file.path) } + + before do + allow(subject).to receive(:tar_file).and_return(backup_filename) + + stub_backup_setting( + upload: { + connection: { + provider: 'AWS', + aws_access_key_id: 'id', + aws_secret_access_key: 'secret' + }, + remote_directory: 'directory', + multipart_chunk_size: 104857600, + encryption: nil, + storage_class: nil + } + ) + + # the Fog mock only knows about directories we create explicitly + Fog.mock! + connection = ::Fog::Storage.new(Gitlab.config.backup.upload.connection.symbolize_keys) + connection.directories.create(key: Gitlab.config.backup.upload.remote_directory) + end + + context 'target path' do + it 'uses the tar filename by default' do + expect_any_instance_of(Fog::Collection).to receive(:create) + .with(hash_including(key: backup_filename)) + .and_return(true) + + Dir.chdir(Gitlab.config.backup.path) do + subject.upload + end + end + + it 'adds the DIRECTORY environment variable if present' do + stub_env('DIRECTORY', 'daily') + + expect_any_instance_of(Fog::Collection).to receive(:create) + .with(hash_including(key: "daily/#{backup_filename}")) + .and_return(true) + + Dir.chdir(Gitlab.config.backup.path) do + subject.upload + end + end + end + end end diff --git a/spec/lib/gitlab/backup/repository_spec.rb b/spec/lib/gitlab/backup/repository_spec.rb index 51c1e9d657b..db860b01ba4 100644 --- a/spec/lib/gitlab/backup/repository_spec.rb +++ b/spec/lib/gitlab/backup/repository_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Backup::Repository, lib: true do +describe Backup::Repository do let(:progress) { StringIO.new } let!(:project) { create(:empty_project) } diff --git a/spec/lib/gitlab/bitbucket_import/importer_spec.rb b/spec/lib/gitlab/bitbucket_import/importer_spec.rb index d8beb05601c..df66a031fec 100644 --- a/spec/lib/gitlab/bitbucket_import/importer_spec.rb +++ b/spec/lib/gitlab/bitbucket_import/importer_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::BitbucketImport::Importer, lib: true do +describe Gitlab::BitbucketImport::Importer do include ImportSpecHelper before do @@ -58,7 +58,7 @@ describe Gitlab::BitbucketImport::Importer, lib: true do ) end - let(:importer) { Gitlab::BitbucketImport::Importer.new(project) } + let(:importer) { described_class.new(project) } let(:issues_statuses_sample_data) do { diff --git a/spec/lib/gitlab/bitbucket_import/project_creator_spec.rb b/spec/lib/gitlab/bitbucket_import/project_creator_spec.rb index 773d0d4d288..d7f7b26740d 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, lib: true do +describe Gitlab::BitbucketImport::ProjectCreator do let(:user) { create(:user) } let(:repo) do @@ -27,7 +27,7 @@ describe Gitlab::BitbucketImport::ProjectCreator, lib: true do it 'creates project' do allow_any_instance_of(Project).to receive(:add_import_job) - project_creator = Gitlab::BitbucketImport::ProjectCreator.new(repo, 'vim', namespace, user, access_params) + project_creator = described_class.new(repo, 'vim', namespace, user, access_params) project = project_creator.execute expect(project.import_url).to eq("ssh://git@bitbucket.org/asd/vim.git") diff --git a/spec/lib/gitlab/blame_spec.rb b/spec/lib/gitlab/blame_spec.rb index 26b1baf75be..7cab04e9fc9 100644 --- a/spec/lib/gitlab/blame_spec.rb +++ b/spec/lib/gitlab/blame_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::Blame, lib: true do +describe Gitlab::Blame do let(:project) { create(:project, :repository) } let(:path) { 'files/ruby/popen.rb' } let(:commit) { project.commit('master') } diff --git a/spec/lib/gitlab/chat_name_token_spec.rb b/spec/lib/gitlab/chat_name_token_spec.rb index 8c1e6efa9db..1e9fb9077fc 100644 --- a/spec/lib/gitlab/chat_name_token_spec.rb +++ b/spec/lib/gitlab/chat_name_token_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::ChatNameToken, lib: true do +describe Gitlab::ChatNameToken do context 'when using unknown token' do let(:token) { } diff --git a/spec/lib/gitlab/checks/change_access_spec.rb b/spec/lib/gitlab/checks/change_access_spec.rb index 643e590438a..6c25b7349e1 100644 --- a/spec/lib/gitlab/checks/change_access_spec.rb +++ b/spec/lib/gitlab/checks/change_access_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::Checks::ChangeAccess, lib: true do +describe Gitlab::Checks::ChangeAccess do describe '#exec' do let(:user) { create(:user) } let(:project) { create(:project, :repository) } diff --git a/spec/lib/gitlab/checks/force_push_spec.rb b/spec/lib/gitlab/checks/force_push_spec.rb index bc66ce83d4a..6c4cfa1203e 100644 --- a/spec/lib/gitlab/checks/force_push_spec.rb +++ b/spec/lib/gitlab/checks/force_push_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::Checks::ForcePush, lib: true do +describe Gitlab::Checks::ForcePush do let(:project) { create(:project, :repository) } context "exit code checking" do diff --git a/spec/lib/gitlab/ci_access_spec.rb b/spec/lib/gitlab/ci_access_spec.rb index eaf8f1d0f1c..75b90e76083 100644 --- a/spec/lib/gitlab/ci_access_spec.rb +++ b/spec/lib/gitlab/ci_access_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' -describe Gitlab::CiAccess, lib: true do - let(:access) { Gitlab::CiAccess.new } +describe Gitlab::CiAccess do + let(:access) { described_class.new } describe '#can_do_action?' do context 'when action is :build_download_code' do diff --git a/spec/lib/gitlab/closing_issue_extractor_spec.rb b/spec/lib/gitlab/closing_issue_extractor_spec.rb index fe988266ae3..8ff6125ada1 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, lib: true do +describe Gitlab::ClosingIssueExtractor do let(:project) { create(:empty_project) } let(:project2) { create(:empty_project) } let(:forked_project) { Projects::ForkService.new(project, project.creator).execute } diff --git a/spec/lib/gitlab/color_schemes_spec.rb b/spec/lib/gitlab/color_schemes_spec.rb index 0a1ec66f199..c7be45dbcd3 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, lib: true do +describe Gitlab::ColorSchemes 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/conflict/file_collection_spec.rb b/spec/lib/gitlab/conflict/file_collection_spec.rb index 27f23ea70dc..a4d7628b03a 100644 --- a/spec/lib/gitlab/conflict/file_collection_spec.rb +++ b/spec/lib/gitlab/conflict/file_collection_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::Conflict::FileCollection, lib: true do +describe Gitlab::Conflict::FileCollection do let(:merge_request) { create(:merge_request, source_branch: 'conflict-resolvable', target_branch: 'conflict-start') } let(:file_collection) { described_class.read_only(merge_request) } diff --git a/spec/lib/gitlab/conflict/file_spec.rb b/spec/lib/gitlab/conflict/file_spec.rb index 585eeb77bd5..5356e9742b4 100644 --- a/spec/lib/gitlab/conflict/file_spec.rb +++ b/spec/lib/gitlab/conflict/file_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::Conflict::File, lib: true do +describe Gitlab::Conflict::File do let(:project) { create(:project, :repository) } let(:repository) { project.repository } let(:rugged) { repository.rugged } @@ -10,7 +10,7 @@ describe Gitlab::Conflict::File, lib: true do let(:index) { rugged.merge_commits(our_commit, their_commit) } let(:conflict) { index.conflicts.last } let(:merge_file_result) { index.merge_file('files/ruby/regex.rb') } - let(:conflict_file) { Gitlab::Conflict::File.new(merge_file_result, conflict, merge_request: merge_request) } + let(:conflict_file) { described_class.new(merge_file_result, conflict, merge_request: merge_request) } describe '#resolve_lines' do let(:section_keys) { conflict_file.sections.map { |section| section[:id] }.compact } @@ -220,7 +220,7 @@ end FILE end - let(:conflict_file) { Gitlab::Conflict::File.new({ data: file }, conflict, merge_request: merge_request) } + let(:conflict_file) { described_class.new({ data: file }, conflict, merge_request: merge_request) } let(:sections) { conflict_file.sections } it 'sets the correct match line headers' do diff --git a/spec/lib/gitlab/conflict/parser_spec.rb b/spec/lib/gitlab/conflict/parser_spec.rb index aed57b75789..fce606a2bb5 100644 --- a/spec/lib/gitlab/conflict/parser_spec.rb +++ b/spec/lib/gitlab/conflict/parser_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' -describe Gitlab::Conflict::Parser, lib: true do - let(:parser) { Gitlab::Conflict::Parser.new } +describe Gitlab::Conflict::Parser do + let(:parser) { described_class.new } describe '#parse' do def parse_text(text) diff --git a/spec/lib/gitlab/cycle_analytics/stage_summary_spec.rb b/spec/lib/gitlab/cycle_analytics/stage_summary_spec.rb index 3dd76ba5b8a..592448aef96 100644 --- a/spec/lib/gitlab/cycle_analytics/stage_summary_spec.rb +++ b/spec/lib/gitlab/cycle_analytics/stage_summary_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::CycleAnalytics::StageSummary, models: true do +describe Gitlab::CycleAnalytics::StageSummary do let(:project) { create(:project, :repository) } let(:from) { 1.day.ago } let(:user) { create(:user, :admin) } diff --git a/spec/lib/gitlab/data_builder/note_spec.rb b/spec/lib/gitlab/data_builder/note_spec.rb index 04ec34492e1..6415e4083d6 100644 --- a/spec/lib/gitlab/data_builder/note_spec.rb +++ b/spec/lib/gitlab/data_builder/note_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::DataBuilder::Note, lib: true do +describe Gitlab::DataBuilder::Note do let(:project) { create(:project, :repository) } let(:user) { create(:user) } let(:data) { described_class.build(note, user) } diff --git a/spec/lib/gitlab/data_builder/push_spec.rb b/spec/lib/gitlab/data_builder/push_spec.rb index 73936969832..cb430b47463 100644 --- a/spec/lib/gitlab/data_builder/push_spec.rb +++ b/spec/lib/gitlab/data_builder/push_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::DataBuilder::Push, lib: true do +describe Gitlab::DataBuilder::Push do let(:project) { create(:project, :repository) } let(:user) { create(:user) } diff --git a/spec/lib/gitlab/database/migration_helpers_spec.rb b/spec/lib/gitlab/database/migration_helpers_spec.rb index a2acd15c8fb..d3dbd82e8ba 100644 --- a/spec/lib/gitlab/database/migration_helpers_spec.rb +++ b/spec/lib/gitlab/database/migration_helpers_spec.rb @@ -1,9 +1,9 @@ require 'spec_helper' -describe Gitlab::Database::MigrationHelpers, lib: true do +describe Gitlab::Database::MigrationHelpers do let(:model) do ActiveRecord::Migration.new.extend( - Gitlab::Database::MigrationHelpers + described_class ) end diff --git a/spec/lib/gitlab/database_spec.rb b/spec/lib/gitlab/database_spec.rb index cbf6c35356e..c5f9aecd867 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, lib: true do +describe Gitlab::Database do before do stub_const('MigrationTest', Class.new { include Gitlab::Database }) end diff --git a/spec/lib/gitlab/dependency_linker/cartfile_linker_spec.rb b/spec/lib/gitlab/dependency_linker/cartfile_linker_spec.rb index df77f4037af..3a93d5e1e97 100644 --- a/spec/lib/gitlab/dependency_linker/cartfile_linker_spec.rb +++ b/spec/lib/gitlab/dependency_linker/cartfile_linker_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe Gitlab::DependencyLinker::CartfileLinker, lib: true do +describe Gitlab::DependencyLinker::CartfileLinker do describe '.support?' do it 'supports Cartfile' do expect(described_class.support?('Cartfile')).to be_truthy diff --git a/spec/lib/gitlab/dependency_linker/composer_json_linker_spec.rb b/spec/lib/gitlab/dependency_linker/composer_json_linker_spec.rb index d7a926e800f..4d222564fd0 100644 --- a/spec/lib/gitlab/dependency_linker/composer_json_linker_spec.rb +++ b/spec/lib/gitlab/dependency_linker/composer_json_linker_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe Gitlab::DependencyLinker::ComposerJsonLinker, lib: true do +describe Gitlab::DependencyLinker::ComposerJsonLinker do describe '.support?' do it 'supports composer.json' do expect(described_class.support?('composer.json')).to be_truthy diff --git a/spec/lib/gitlab/dependency_linker/gemfile_linker_spec.rb b/spec/lib/gitlab/dependency_linker/gemfile_linker_spec.rb index 3f8335f03ea..a97803b119e 100644 --- a/spec/lib/gitlab/dependency_linker/gemfile_linker_spec.rb +++ b/spec/lib/gitlab/dependency_linker/gemfile_linker_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe Gitlab::DependencyLinker::GemfileLinker, lib: true do +describe Gitlab::DependencyLinker::GemfileLinker do describe '.support?' do it 'supports Gemfile' do expect(described_class.support?('Gemfile')).to be_truthy diff --git a/spec/lib/gitlab/dependency_linker/gemspec_linker_spec.rb b/spec/lib/gitlab/dependency_linker/gemspec_linker_spec.rb index d4a71403939..24ad7d12f4c 100644 --- a/spec/lib/gitlab/dependency_linker/gemspec_linker_spec.rb +++ b/spec/lib/gitlab/dependency_linker/gemspec_linker_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe Gitlab::DependencyLinker::GemspecLinker, lib: true do +describe Gitlab::DependencyLinker::GemspecLinker do describe '.support?' do it 'supports *.gemspec' do expect(described_class.support?('gitlab_git.gemspec')).to be_truthy diff --git a/spec/lib/gitlab/dependency_linker/godeps_json_linker_spec.rb b/spec/lib/gitlab/dependency_linker/godeps_json_linker_spec.rb index e279e0c9019..ae5ad39ad11 100644 --- a/spec/lib/gitlab/dependency_linker/godeps_json_linker_spec.rb +++ b/spec/lib/gitlab/dependency_linker/godeps_json_linker_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe Gitlab::DependencyLinker::GodepsJsonLinker, lib: true do +describe Gitlab::DependencyLinker::GodepsJsonLinker do describe '.support?' do it 'supports Godeps.json' do expect(described_class.support?('Godeps.json')).to be_truthy diff --git a/spec/lib/gitlab/dependency_linker/package_json_linker_spec.rb b/spec/lib/gitlab/dependency_linker/package_json_linker_spec.rb index 8c979ae1869..1e8b72afb7b 100644 --- a/spec/lib/gitlab/dependency_linker/package_json_linker_spec.rb +++ b/spec/lib/gitlab/dependency_linker/package_json_linker_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe Gitlab::DependencyLinker::PackageJsonLinker, lib: true do +describe Gitlab::DependencyLinker::PackageJsonLinker do describe '.support?' do it 'supports package.json' do expect(described_class.support?('package.json')).to be_truthy diff --git a/spec/lib/gitlab/dependency_linker/podfile_linker_spec.rb b/spec/lib/gitlab/dependency_linker/podfile_linker_spec.rb index 06007cf97f7..cdfd7ad9826 100644 --- a/spec/lib/gitlab/dependency_linker/podfile_linker_spec.rb +++ b/spec/lib/gitlab/dependency_linker/podfile_linker_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe Gitlab::DependencyLinker::PodfileLinker, lib: true do +describe Gitlab::DependencyLinker::PodfileLinker do describe '.support?' do it 'supports Podfile' do expect(described_class.support?('Podfile')).to be_truthy diff --git a/spec/lib/gitlab/dependency_linker/podspec_json_linker_spec.rb b/spec/lib/gitlab/dependency_linker/podspec_json_linker_spec.rb index d722865264b..d4a398c5948 100644 --- a/spec/lib/gitlab/dependency_linker/podspec_json_linker_spec.rb +++ b/spec/lib/gitlab/dependency_linker/podspec_json_linker_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe Gitlab::DependencyLinker::PodspecJsonLinker, lib: true do +describe Gitlab::DependencyLinker::PodspecJsonLinker do describe '.support?' do it 'supports *.podspec.json' do expect(described_class.support?('Reachability.podspec.json')).to be_truthy diff --git a/spec/lib/gitlab/dependency_linker/podspec_linker_spec.rb b/spec/lib/gitlab/dependency_linker/podspec_linker_spec.rb index dfc366b5817..ed60ab45955 100644 --- a/spec/lib/gitlab/dependency_linker/podspec_linker_spec.rb +++ b/spec/lib/gitlab/dependency_linker/podspec_linker_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe Gitlab::DependencyLinker::PodspecLinker, lib: true do +describe Gitlab::DependencyLinker::PodspecLinker do describe '.support?' do it 'supports *.podspec' do expect(described_class.support?('Reachability.podspec')).to be_truthy diff --git a/spec/lib/gitlab/dependency_linker/requirements_txt_linker_spec.rb b/spec/lib/gitlab/dependency_linker/requirements_txt_linker_spec.rb index 64b233f3e68..ef952b3abd5 100644 --- a/spec/lib/gitlab/dependency_linker/requirements_txt_linker_spec.rb +++ b/spec/lib/gitlab/dependency_linker/requirements_txt_linker_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe Gitlab::DependencyLinker::RequirementsTxtLinker, lib: true do +describe Gitlab::DependencyLinker::RequirementsTxtLinker do describe '.support?' do it 'supports requirements.txt' do expect(described_class.support?('requirements.txt')).to be_truthy diff --git a/spec/lib/gitlab/dependency_linker_spec.rb b/spec/lib/gitlab/dependency_linker_spec.rb index 3d1cfbcfbf7..10d2f701298 100644 --- a/spec/lib/gitlab/dependency_linker_spec.rb +++ b/spec/lib/gitlab/dependency_linker_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe Gitlab::DependencyLinker, lib: true do +describe Gitlab::DependencyLinker do describe '.link' do it 'links using GemfileLinker' do blob_name = 'Gemfile' diff --git a/spec/lib/gitlab/diff/diff_refs_spec.rb b/spec/lib/gitlab/diff/diff_refs_spec.rb index a8173558c00..c73708d90a8 100644 --- a/spec/lib/gitlab/diff/diff_refs_spec.rb +++ b/spec/lib/gitlab/diff/diff_refs_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::Diff::DiffRefs, lib: true do +describe Gitlab::Diff::DiffRefs do let(:project) { create(:project, :repository) } describe '#compare_in' do diff --git a/spec/lib/gitlab/diff/file_spec.rb b/spec/lib/gitlab/diff/file_spec.rb index f289131cc3a..cd2fa98b14c 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, lib: true do +describe Gitlab::Diff::File do include RepoHelpers let(:project) { create(:project, :repository) } diff --git a/spec/lib/gitlab/diff/highlight_spec.rb b/spec/lib/gitlab/diff/highlight_spec.rb index 7d7d4a55e63..cd602ccab8e 100644 --- a/spec/lib/gitlab/diff/highlight_spec.rb +++ b/spec/lib/gitlab/diff/highlight_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::Diff::Highlight, lib: true do +describe Gitlab::Diff::Highlight do include RepoHelpers let(:project) { create(:project, :repository) } @@ -10,7 +10,7 @@ describe Gitlab::Diff::Highlight, lib: true do describe '#highlight' do context "with a diff file" do - let(:subject) { Gitlab::Diff::Highlight.new(diff_file, repository: project.repository).highlight } + let(:subject) { described_class.new(diff_file, repository: project.repository).highlight } it 'returns Gitlab::Diff::Line elements' do expect(subject.first).to be_an_instance_of(Gitlab::Diff::Line) @@ -41,7 +41,7 @@ describe Gitlab::Diff::Highlight, lib: true do end context "with diff lines" do - let(:subject) { Gitlab::Diff::Highlight.new(diff_file.diff_lines, repository: project.repository).highlight } + let(:subject) { described_class.new(diff_file.diff_lines, repository: project.repository).highlight } it 'returns Gitlab::Diff::Line elements' do expect(subject.first).to be_an_instance_of(Gitlab::Diff::Line) diff --git a/spec/lib/gitlab/diff/inline_diff_markdown_marker_spec.rb b/spec/lib/gitlab/diff/inline_diff_markdown_marker_spec.rb index d6e8b8ac4b2..046b096e366 100644 --- a/spec/lib/gitlab/diff/inline_diff_markdown_marker_spec.rb +++ b/spec/lib/gitlab/diff/inline_diff_markdown_marker_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::Diff::InlineDiffMarkdownMarker, lib: true do +describe Gitlab::Diff::InlineDiffMarkdownMarker do describe '#mark' do let(:raw) { "abc 'def'" } let(:inline_diffs) { [2..5] } diff --git a/spec/lib/gitlab/diff/inline_diff_marker_spec.rb b/spec/lib/gitlab/diff/inline_diff_marker_spec.rb index 95da344802d..c3bf34c24ae 100644 --- a/spec/lib/gitlab/diff/inline_diff_marker_spec.rb +++ b/spec/lib/gitlab/diff/inline_diff_marker_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::Diff::InlineDiffMarker, lib: true do +describe Gitlab::Diff::InlineDiffMarker do describe '#mark' do context "when the rich text is html safe" do let(:raw) { "abc 'def'" } diff --git a/spec/lib/gitlab/diff/inline_diff_spec.rb b/spec/lib/gitlab/diff/inline_diff_spec.rb index 8ca3f73509e..15451c2cf99 100644 --- a/spec/lib/gitlab/diff/inline_diff_spec.rb +++ b/spec/lib/gitlab/diff/inline_diff_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::Diff::InlineDiff, lib: true do +describe Gitlab::Diff::InlineDiff do describe '.for_lines' do let(:diff) do <<-EOF.strip_heredoc diff --git a/spec/lib/gitlab/diff/line_mapper_spec.rb b/spec/lib/gitlab/diff/line_mapper_spec.rb index 2c7ecd1907e..42750bf9ea1 100644 --- a/spec/lib/gitlab/diff/line_mapper_spec.rb +++ b/spec/lib/gitlab/diff/line_mapper_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::Diff::LineMapper, lib: true do +describe Gitlab::Diff::LineMapper do include RepoHelpers let(:project) { create(:project, :repository) } diff --git a/spec/lib/gitlab/diff/parallel_diff_spec.rb b/spec/lib/gitlab/diff/parallel_diff_spec.rb index 0f779339c54..e9fc7be366a 100644 --- a/spec/lib/gitlab/diff/parallel_diff_spec.rb +++ b/spec/lib/gitlab/diff/parallel_diff_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::Diff::ParallelDiff, lib: true do +describe Gitlab::Diff::ParallelDiff do include RepoHelpers let(:project) { create(:project, :repository) } diff --git a/spec/lib/gitlab/diff/parser_spec.rb b/spec/lib/gitlab/diff/parser_spec.rb index e76128ecd87..c71568e2a65 100644 --- a/spec/lib/gitlab/diff/parser_spec.rb +++ b/spec/lib/gitlab/diff/parser_spec.rb @@ -1,12 +1,12 @@ require 'spec_helper' -describe Gitlab::Diff::Parser, lib: true do +describe Gitlab::Diff::Parser do include RepoHelpers let(:project) { create(:project) } let(:commit) { project.commit(sample_commit.id) } let(:diff) { commit.raw_diffs.first } - let(:parser) { Gitlab::Diff::Parser.new } + let(:parser) { described_class.new } describe '#parse' do let(:diff) do diff --git a/spec/lib/gitlab/diff/position_spec.rb b/spec/lib/gitlab/diff/position_spec.rb index b3d46e69ccb..d4a2a852c12 100644 --- a/spec/lib/gitlab/diff/position_spec.rb +++ b/spec/lib/gitlab/diff/position_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::Diff::Position, lib: true do +describe Gitlab::Diff::Position do include RepoHelpers let(:project) { create(:project, :repository) } diff --git a/spec/lib/gitlab/diff/position_tracer_spec.rb b/spec/lib/gitlab/diff/position_tracer_spec.rb index 93d30b90937..8beebc10040 100644 --- a/spec/lib/gitlab/diff/position_tracer_spec.rb +++ b/spec/lib/gitlab/diff/position_tracer_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::Diff::PositionTracer, lib: true do +describe Gitlab::Diff::PositionTracer do # Douwe's diary New York City, 2016-06-28 # -------------------------------------------------------------------------- # diff --git a/spec/lib/gitlab/email/attachment_uploader_spec.rb b/spec/lib/gitlab/email/attachment_uploader_spec.rb index 08b2577ecc4..f61dbc67ad1 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, lib: true do +describe Gitlab::Email::AttachmentUploader do describe "#execute" do let(:project) { build(:project) } let(:message_raw) { fixture_file("emails/attachment.eml") } diff --git a/spec/lib/gitlab/email/handler/create_issue_handler_spec.rb b/spec/lib/gitlab/email/handler/create_issue_handler_spec.rb index 4a9c9a7fe34..bd36d1d309d 100644 --- a/spec/lib/gitlab/email/handler/create_issue_handler_spec.rb +++ b/spec/lib/gitlab/email/handler/create_issue_handler_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require_relative '../email_shared_blocks' -describe Gitlab::Email::Handler::CreateIssueHandler, lib: true do +describe Gitlab::Email::Handler::CreateIssueHandler do include_context :email_shared_context it_behaves_like :reply_processing_shared_examples diff --git a/spec/lib/gitlab/email/handler/create_note_handler_spec.rb b/spec/lib/gitlab/email/handler/create_note_handler_spec.rb index cd0309e248d..0127b012c91 100644 --- a/spec/lib/gitlab/email/handler/create_note_handler_spec.rb +++ b/spec/lib/gitlab/email/handler/create_note_handler_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require_relative '../email_shared_blocks' -describe Gitlab::Email::Handler::CreateNoteHandler, lib: true do +describe Gitlab::Email::Handler::CreateNoteHandler do include_context :email_shared_context it_behaves_like :reply_processing_shared_examples diff --git a/spec/lib/gitlab/email/handler/unsubscribe_handler_spec.rb b/spec/lib/gitlab/email/handler/unsubscribe_handler_spec.rb index 0939e6c4514..66c38498e4e 100644 --- a/spec/lib/gitlab/email/handler/unsubscribe_handler_spec.rb +++ b/spec/lib/gitlab/email/handler/unsubscribe_handler_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require_relative '../email_shared_blocks' -describe Gitlab::Email::Handler::UnsubscribeHandler, lib: true do +describe Gitlab::Email::Handler::UnsubscribeHandler do include_context :email_shared_context before do diff --git a/spec/lib/gitlab/email/receiver_spec.rb b/spec/lib/gitlab/email/receiver_spec.rb index c6e3524f743..88565ea5311 100644 --- a/spec/lib/gitlab/email/receiver_spec.rb +++ b/spec/lib/gitlab/email/receiver_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require_relative 'email_shared_blocks' -describe Gitlab::Email::Receiver, lib: true do +describe Gitlab::Email::Receiver do include_context :email_shared_context context "when the email contains a valid email address in a Delivered-To header" do diff --git a/spec/lib/gitlab/email/reply_parser_spec.rb b/spec/lib/gitlab/email/reply_parser_spec.rb index 2ea5e6460a3..e21a998adfe 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, lib: true do +describe Gitlab::Email::ReplyParser 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/exclusive_lease_spec.rb b/spec/lib/gitlab/exclusive_lease_spec.rb index 590d6da4113..c1ed47cf64a 100644 --- a/spec/lib/gitlab/exclusive_lease_spec.rb +++ b/spec/lib/gitlab/exclusive_lease_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::ExclusiveLease, type: :clean_gitlab_redis_shared_state do +describe Gitlab::ExclusiveLease, :clean_gitlab_redis_shared_state do let(:unique_key) { SecureRandom.hex(10) } describe '#try_obtain' do diff --git a/spec/lib/gitlab/file_finder_spec.rb b/spec/lib/gitlab/file_finder_spec.rb index 5a32ffd462c..3fb6315a39a 100644 --- a/spec/lib/gitlab/file_finder_spec.rb +++ b/spec/lib/gitlab/file_finder_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::FileFinder, lib: true do +describe Gitlab::FileFinder do describe '#find' do let(:project) { create(:project, :public, :repository) } let(:finder) { described_class.new(project, project.default_branch) } diff --git a/spec/lib/gitlab/fogbugz_import/client_spec.rb b/spec/lib/gitlab/fogbugz_import/client_spec.rb index 252cd4c55c7..dcd1a2d9813 100644 --- a/spec/lib/gitlab/fogbugz_import/client_spec.rb +++ b/spec/lib/gitlab/fogbugz_import/client_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::FogbugzImport::Client, lib: true do +describe Gitlab::FogbugzImport::Client do let(:client) { described_class.new(uri: '', token: '') } let(:one_user) { { 'people' => { 'person' => { "ixPerson" => "2", "sFullName" => "James" } } } } let(:two_users) { { 'people' => { 'person' => [one_user, { "ixPerson" => "3" }] } } } diff --git a/spec/lib/gitlab/git/hook_spec.rb b/spec/lib/gitlab/git/hook_spec.rb index 19f45ea1cb2..19391a70cf6 100644 --- a/spec/lib/gitlab/git/hook_spec.rb +++ b/spec/lib/gitlab/git/hook_spec.rb @@ -1,11 +1,11 @@ require 'spec_helper' require 'fileutils' -describe Gitlab::Git::Hook, lib: true do +describe Gitlab::Git::Hook do before do # We need this because in the spec/spec_helper.rb we define it like this: # allow_any_instance_of(Gitlab::Git::Hook).to receive(:trigger).and_return([true, nil]) - allow_any_instance_of(Gitlab::Git::Hook).to receive(:trigger).and_call_original + allow_any_instance_of(described_class).to receive(:trigger).and_call_original end describe "#trigger" do @@ -48,7 +48,7 @@ describe Gitlab::Git::Hook, lib: true do it "returns success with no errors" do create_hook(hook_name) - hook = Gitlab::Git::Hook.new(hook_name, project) + hook = described_class.new(hook_name, project) blank = Gitlab::Git::BLANK_SHA ref = Gitlab::Git::BRANCH_REF_PREFIX + 'new_branch' @@ -66,7 +66,7 @@ describe Gitlab::Git::Hook, lib: true do context "when the hook is unsuccessful" do it "returns failure with errors" do create_failing_hook(hook_name) - hook = Gitlab::Git::Hook.new(hook_name, project) + hook = described_class.new(hook_name, project) blank = Gitlab::Git::BLANK_SHA ref = Gitlab::Git::BRANCH_REF_PREFIX + 'new_branch' @@ -80,7 +80,7 @@ describe Gitlab::Git::Hook, lib: true do context "when the hook doesn't exist" do it "returns success with no errors" do - hook = Gitlab::Git::Hook.new('unknown_hook', project) + hook = described_class.new('unknown_hook', project) blank = Gitlab::Git::BLANK_SHA ref = Gitlab::Git::BRANCH_REF_PREFIX + 'new_branch' diff --git a/spec/lib/gitlab/git/repository_spec.rb b/spec/lib/gitlab/git/repository_spec.rb index 83d067b2c31..50736d353ad 100644 --- a/spec/lib/gitlab/git/repository_spec.rb +++ b/spec/lib/gitlab/git/repository_spec.rb @@ -378,144 +378,6 @@ describe Gitlab::Git::Repository, seed_helper: true do end end - describe "#reset" do - change_path = File.join(SEED_STORAGE_PATH, TEST_NORMAL_REPO_PATH, "CHANGELOG") - untracked_path = File.join(SEED_STORAGE_PATH, TEST_NORMAL_REPO_PATH, "UNTRACKED") - tracked_path = File.join(SEED_STORAGE_PATH, TEST_NORMAL_REPO_PATH, "files", "ruby", "popen.rb") - - change_text = "New changelog text" - untracked_text = "This file is untracked" - - reset_commit = SeedRepo::LastCommit::ID - - context "--hard" do - before(:all) do - # Modify a tracked file - File.open(change_path, "w") do |f| - f.write(change_text) - end - - # Add an untracked file to the working directory - File.open(untracked_path, "w") do |f| - f.write(untracked_text) - end - - @normal_repo = Gitlab::Git::Repository.new('default', TEST_NORMAL_REPO_PATH) - @normal_repo.reset("HEAD", :hard) - end - - it "should replace the working directory with the content of the index" do - File.open(change_path, "r") do |f| - expect(f.each_line.first).not_to eq(change_text) - end - - File.open(tracked_path, "r") do |f| - expect(f.each_line.to_a[8]).to include('raise RuntimeError, "System commands') - end - end - - it "should not touch untracked files" do - expect(File.exist?(untracked_path)).to be_truthy - end - - it "should move the HEAD to the correct commit" do - new_head = @normal_repo.rugged.head.target.oid - expect(new_head).to eq(reset_commit) - end - - it "should move the tip of the master branch to the correct commit" do - new_tip = @normal_repo.rugged.references["refs/heads/master"] - .target.oid - - expect(new_tip).to eq(reset_commit) - end - - after(:all) do - # Fast-forward to the original HEAD - FileUtils.rm_rf(TEST_NORMAL_REPO_PATH) - ensure_seeds - end - end - end - - describe "#checkout" do - new_branch = "foo_branch" - - context "-b" do - before(:all) do - @normal_repo = Gitlab::Git::Repository.new('default', TEST_NORMAL_REPO_PATH) - @normal_repo.checkout(new_branch, { b: true }, "origin/feature") - end - - it "should create a new branch" do - expect(@normal_repo.rugged.branches[new_branch]).not_to be_nil - end - - it "should move the HEAD to the correct commit" do - expect(@normal_repo.rugged.head.target.oid).to( - eq(@normal_repo.rugged.branches["origin/feature"].target.oid) - ) - end - - it "should refresh the repo's #heads collection" do - head_names = @normal_repo.branches.map { |h| h.name } - expect(head_names).to include(new_branch) - end - - after(:all) do - FileUtils.rm_rf(TEST_NORMAL_REPO_PATH) - ensure_seeds - end - end - - context "without -b" do - context "and specifying a nonexistent branch" do - it "should not do anything" do - normal_repo = Gitlab::Git::Repository.new('default', TEST_NORMAL_REPO_PATH) - - expect { normal_repo.checkout(new_branch) }.to raise_error(Rugged::ReferenceError) - expect(normal_repo.rugged.branches[new_branch]).to be_nil - expect(normal_repo.rugged.head.target.oid).to( - eq(normal_repo.rugged.branches["master"].target.oid) - ) - - head_names = normal_repo.branches.map { |h| h.name } - expect(head_names).not_to include(new_branch) - end - - after(:all) do - FileUtils.rm_rf(TEST_NORMAL_REPO_PATH) - ensure_seeds - end - end - - context "and with a valid branch" do - before(:all) do - @normal_repo = Gitlab::Git::Repository.new('default', TEST_NORMAL_REPO_PATH) - @normal_repo.rugged.branches.create("feature", "origin/feature") - @normal_repo.checkout("feature") - end - - it "should move the HEAD to the correct commit" do - expect(@normal_repo.rugged.head.target.oid).to( - eq(@normal_repo.rugged.branches["feature"].target.oid) - ) - end - - it "should update the working directory" do - File.open(File.join(SEED_STORAGE_PATH, TEST_NORMAL_REPO_PATH, ".gitignore"), "r") do |f| - expect(f.read.each_line.to_a).not_to include(".DS_Store\n") - end - end - - after(:all) do - FileUtils.rm_rf(SEED_STORAGE_PATH, TEST_NORMAL_REPO_PATH) - ensure_seeds - end - end - end - end - describe "#delete_branch" do before(:all) do @repo = Gitlab::Git::Repository.new('default', TEST_MUTABLE_REPO_PATH) @@ -1049,19 +911,49 @@ describe Gitlab::Git::Repository, seed_helper: true do end end - describe '#branches with deleted branch' do - before(:each) do - ref = double() - allow(ref).to receive(:name) { 'bad-branch' } - allow(ref).to receive(:target) { raise Rugged::ReferenceError } - branches = double() - allow(branches).to receive(:each) { [ref].each } - allow(repository.rugged).to receive(:branches) { branches } + describe '#branches' do + subject { repository.branches } + + context 'with local and remote branches' do + let(:repository) do + Gitlab::Git::Repository.new('default', File.join(TEST_MUTABLE_REPO_PATH, '.git')) + end + + before do + create_remote_branch(repository, 'joe', 'remote_branch', 'master') + repository.create_branch('local_branch', 'master') + end + + after do + FileUtils.rm_rf(TEST_MUTABLE_REPO_PATH) + ensure_seeds + end + + it 'returns the local and remote branches' do + expect(subject.any? { |b| b.name == 'joe/remote_branch' }).to eq(true) + expect(subject.any? { |b| b.name == 'local_branch' }).to eq(true) + end end - it 'should return empty branches' do - expect(repository.branches).to eq([]) + # With Gitaly enabled, Gitaly just doesn't return deleted branches. + context 'with deleted branch with Gitaly disabled' do + before do + allow(Gitlab::GitalyClient).to receive(:feature_enabled?).and_return(false) + end + + it 'returns no results' do + ref = double() + allow(ref).to receive(:name) { 'bad-branch' } + allow(ref).to receive(:target) { raise Rugged::ReferenceError } + branches = double() + allow(branches).to receive(:each) { [ref].each } + allow(repository.rugged).to receive(:branches) { branches } + + expect(subject).to be_empty + end end + + it_behaves_like 'wrapping gRPC errors', Gitlab::GitalyClient::RefService, :branches end describe '#branch_count' do @@ -1208,7 +1100,7 @@ describe Gitlab::Git::Repository, seed_helper: true do end it 'returns the local branches' do - create_remote_branch('joe', 'remote_branch', 'master') + create_remote_branch(@repo, 'joe', 'remote_branch', 'master') @repo.create_branch('local_branch', 'master') expect(@repo.local_branches.any? { |branch| branch.name == 'remote_branch' }).to eq(false) @@ -1235,9 +1127,9 @@ describe Gitlab::Git::Repository, seed_helper: true do end end - def create_remote_branch(remote_name, branch_name, source_branch_name) - source_branch = @repo.branches.find { |branch| branch.name == source_branch_name } - rugged = @repo.rugged + def create_remote_branch(repository, remote_name, branch_name, source_branch_name) + source_branch = repository.branches.find { |branch| branch.name == source_branch_name } + rugged = repository.rugged rugged.references.create("refs/remotes/#{remote_name}/#{branch_name}", source_branch.dereferenced_target.sha) end diff --git a/spec/lib/gitlab/git/rev_list_spec.rb b/spec/lib/gitlab/git/rev_list_spec.rb index 78894ba9409..b051a088171 100644 --- a/spec/lib/gitlab/git/rev_list_spec.rb +++ b/spec/lib/gitlab/git/rev_list_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::Git::RevList, lib: true do +describe Gitlab::Git::RevList do let(:project) { create(:project, :repository) } before do @@ -11,7 +11,7 @@ describe Gitlab::Git::RevList, lib: true do end context "#new_refs" do - let(:rev_list) { Gitlab::Git::RevList.new(newrev: 'newrev', path_to_repo: project.repository.path_to_repo) } + let(:rev_list) { described_class.new(newrev: 'newrev', path_to_repo: project.repository.path_to_repo) } it 'calls out to `popen`' do expect(Gitlab::Popen).to receive(:popen).with([ @@ -33,7 +33,7 @@ describe Gitlab::Git::RevList, lib: true do end context "#missed_ref" do - let(:rev_list) { Gitlab::Git::RevList.new(oldrev: 'oldrev', newrev: 'newrev', path_to_repo: project.repository.path_to_repo) } + let(:rev_list) { described_class.new(oldrev: 'oldrev', newrev: 'newrev', path_to_repo: project.repository.path_to_repo) } it 'calls out to `popen`' do expect(Gitlab::Popen).to receive(:popen).with([ diff --git a/spec/lib/gitlab/git/tag_spec.rb b/spec/lib/gitlab/git/tag_spec.rb index 67a9c974298..78d1e120013 100644 --- a/spec/lib/gitlab/git/tag_spec.rb +++ b/spec/lib/gitlab/git/tag_spec.rb @@ -3,23 +3,33 @@ require "spec_helper" describe Gitlab::Git::Tag, seed_helper: true do let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH) } - describe 'first tag' do - let(:tag) { repository.tags.first } + shared_examples 'Gitlab::Git::Repository#tags' do + describe 'first tag' do + let(:tag) { repository.tags.first } - it { expect(tag.name).to eq("v1.0.0") } - it { expect(tag.target).to eq("f4e6814c3e4e7a0de82a9e7cd20c626cc963a2f8") } - it { expect(tag.dereferenced_target.sha).to eq("6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9") } - it { expect(tag.message).to eq("Release") } - end + it { expect(tag.name).to eq("v1.0.0") } + it { expect(tag.target).to eq("f4e6814c3e4e7a0de82a9e7cd20c626cc963a2f8") } + it { expect(tag.dereferenced_target.sha).to eq("6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9") } + it { expect(tag.message).to eq("Release") } + end + + describe 'last tag' do + let(:tag) { repository.tags.last } - describe 'last tag' do - let(:tag) { repository.tags.last } + it { expect(tag.name).to eq("v1.2.1") } + it { expect(tag.target).to eq("2ac1f24e253e08135507d0830508febaaccf02ee") } + it { expect(tag.dereferenced_target.sha).to eq("fa1b1e6c004a68b7d8763b86455da9e6b23e36d6") } + it { expect(tag.message).to eq("Version 1.2.1") } + end - it { expect(tag.name).to eq("v1.2.1") } - it { expect(tag.target).to eq("2ac1f24e253e08135507d0830508febaaccf02ee") } - it { expect(tag.dereferenced_target.sha).to eq("fa1b1e6c004a68b7d8763b86455da9e6b23e36d6") } - it { expect(tag.message).to eq("Version 1.2.1") } + it { expect(repository.tags.size).to eq(SeedRepo::Repo::TAGS.size) } end - it { expect(repository.tags.size).to eq(SeedRepo::Repo::TAGS.size) } + context 'when Gitaly tags feature is enabled' do + it_behaves_like 'Gitlab::Git::Repository#tags' + end + + context 'when Gitaly tags feature is disabled', skip_gitaly_mock: true do + it_behaves_like 'Gitlab::Git::Repository#tags' + end end diff --git a/spec/lib/gitlab/git_access_spec.rb b/spec/lib/gitlab/git_access_spec.rb index 9a86cfa66e4..2d6ea37d0ac 100644 --- a/spec/lib/gitlab/git_access_spec.rb +++ b/spec/lib/gitlab/git_access_spec.rb @@ -1,9 +1,9 @@ require 'spec_helper' -describe Gitlab::GitAccess, lib: true do +describe Gitlab::GitAccess do let(:pull_access_check) { access.check('git-upload-pack', '_any') } let(:push_access_check) { access.check('git-receive-pack', '_any') } - let(:access) { Gitlab::GitAccess.new(actor, project, protocol, authentication_abilities: authentication_abilities, redirected_path: redirected_path) } + let(:access) { described_class.new(actor, project, protocol, authentication_abilities: authentication_abilities, redirected_path: redirected_path) } let(:project) { create(:project, :repository) } let(:user) { create(:user) } let(:actor) { user } @@ -280,7 +280,7 @@ describe Gitlab::GitAccess, lib: true do context 'when project is public' do let(:public_project) { create(:project, :public, :repository) } - let(:access) { Gitlab::GitAccess.new(nil, public_project, 'web', authentication_abilities: []) } + let(:access) { described_class.new(nil, public_project, 'web', authentication_abilities: []) } context 'when repository is enabled' do it 'give access to download code' do @@ -441,7 +441,7 @@ describe Gitlab::GitAccess, lib: true do end permissions_matrix[role].each do |action, allowed| - context action do + context action.to_s do subject { access.send(:check_push_access!, changes[action]) } it do diff --git a/spec/lib/gitlab/git_access_wiki_spec.rb b/spec/lib/gitlab/git_access_wiki_spec.rb index 797ec8cb23e..0376b4ee783 100644 --- a/spec/lib/gitlab/git_access_wiki_spec.rb +++ b/spec/lib/gitlab/git_access_wiki_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' -describe Gitlab::GitAccessWiki, lib: true do - let(:access) { Gitlab::GitAccessWiki.new(user, project, 'web', authentication_abilities: authentication_abilities, redirected_path: redirected_path) } +describe Gitlab::GitAccessWiki do + let(:access) { described_class.new(user, project, 'web', authentication_abilities: authentication_abilities, redirected_path: redirected_path) } let(:project) { create(:project, :repository) } let(:user) { create(:user) } let(:redirected_path) { nil } diff --git a/spec/lib/gitlab/git_ref_validator_spec.rb b/spec/lib/gitlab/git_ref_validator_spec.rb index cc8daa535d6..e1fa8ae03f8 100644 --- a/spec/lib/gitlab/git_ref_validator_spec.rb +++ b/spec/lib/gitlab/git_ref_validator_spec.rb @@ -1,25 +1,25 @@ require 'spec_helper' -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 } - it { expect(Gitlab::GitRefValidator.validate('#1')).to be_truthy } - it { expect(Gitlab::GitRefValidator.validate('feature/refs/heads/foo')).to be_truthy } - it { expect(Gitlab::GitRefValidator.validate('feature/~new/')).to be_falsey } - it { expect(Gitlab::GitRefValidator.validate('feature/^new/')).to be_falsey } - it { expect(Gitlab::GitRefValidator.validate('feature/:new/')).to be_falsey } - it { expect(Gitlab::GitRefValidator.validate('feature/?new/')).to be_falsey } - it { expect(Gitlab::GitRefValidator.validate('feature/*new/')).to be_falsey } - it { expect(Gitlab::GitRefValidator.validate('feature/[new/')).to be_falsey } - it { expect(Gitlab::GitRefValidator.validate('feature/new/')).to be_falsey } - it { expect(Gitlab::GitRefValidator.validate('feature/new.')).to be_falsey } - it { expect(Gitlab::GitRefValidator.validate('feature\@{')).to be_falsey } - it { expect(Gitlab::GitRefValidator.validate('feature\new')).to be_falsey } - it { expect(Gitlab::GitRefValidator.validate('feature//new')).to be_falsey } - it { expect(Gitlab::GitRefValidator.validate('feature new')).to be_falsey } - it { expect(Gitlab::GitRefValidator.validate('refs/heads/')).to be_falsey } - it { expect(Gitlab::GitRefValidator.validate('refs/remotes/')).to be_falsey } - it { expect(Gitlab::GitRefValidator.validate('refs/heads/feature')).to be_falsey } - it { expect(Gitlab::GitRefValidator.validate('refs/remotes/origin')).to be_falsey } +describe Gitlab::GitRefValidator do + it { expect(described_class.validate('feature/new')).to be_truthy } + it { expect(described_class.validate('implement_@all')).to be_truthy } + it { expect(described_class.validate('my_new_feature')).to be_truthy } + it { expect(described_class.validate('#1')).to be_truthy } + it { expect(described_class.validate('feature/refs/heads/foo')).to be_truthy } + it { expect(described_class.validate('feature/~new/')).to be_falsey } + it { expect(described_class.validate('feature/^new/')).to be_falsey } + it { expect(described_class.validate('feature/:new/')).to be_falsey } + it { expect(described_class.validate('feature/?new/')).to be_falsey } + it { expect(described_class.validate('feature/*new/')).to be_falsey } + it { expect(described_class.validate('feature/[new/')).to be_falsey } + it { expect(described_class.validate('feature/new/')).to be_falsey } + it { expect(described_class.validate('feature/new.')).to be_falsey } + it { expect(described_class.validate('feature\@{')).to be_falsey } + it { expect(described_class.validate('feature\new')).to be_falsey } + it { expect(described_class.validate('feature//new')).to be_falsey } + it { expect(described_class.validate('feature new')).to be_falsey } + it { expect(described_class.validate('refs/heads/')).to be_falsey } + it { expect(described_class.validate('refs/remotes/')).to be_falsey } + it { expect(described_class.validate('refs/heads/feature')).to be_falsey } + it { expect(described_class.validate('refs/remotes/origin')).to be_falsey } end diff --git a/spec/lib/gitlab/git_spec.rb b/spec/lib/gitlab/git_spec.rb index 36f0e6507c8..4702a978f19 100644 --- a/spec/lib/gitlab/git_spec.rb +++ b/spec/lib/gitlab/git_spec.rb @@ -1,12 +1,12 @@ require 'spec_helper' -describe Gitlab::Git, lib: true do +describe Gitlab::Git do let(:committer_email) { 'user@example.org' } let(:committer_name) { 'John Doe' } describe 'committer_hash' do it "returns a hash containing the given email and name" do - committer_hash = Gitlab::Git.committer_hash(email: committer_email, name: committer_name) + committer_hash = described_class.committer_hash(email: committer_email, name: committer_name) expect(committer_hash[:email]).to eq(committer_email) expect(committer_hash[:name]).to eq(committer_name) @@ -15,7 +15,7 @@ describe Gitlab::Git, lib: true do context 'when email is nil' do it "returns nil" do - committer_hash = Gitlab::Git.committer_hash(email: nil, name: committer_name) + committer_hash = described_class.committer_hash(email: nil, name: committer_name) expect(committer_hash).to be_nil end @@ -23,7 +23,7 @@ describe Gitlab::Git, lib: true do context 'when name is nil' do it "returns nil" do - committer_hash = Gitlab::Git.committer_hash(email: committer_email, name: nil) + committer_hash = described_class.committer_hash(email: committer_email, name: nil) expect(committer_hash).to be_nil end diff --git a/spec/lib/gitlab/gitaly_client/diff_spec.rb b/spec/lib/gitlab/gitaly_client/diff_spec.rb index 2960c9a79ad..00a31ac0b96 100644 --- a/spec/lib/gitlab/gitaly_client/diff_spec.rb +++ b/spec/lib/gitlab/gitaly_client/diff_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::GitalyClient::Diff, lib: true do +describe Gitlab::GitalyClient::Diff do let(:diff_fields) do { to_path: ".gitmodules", diff --git a/spec/lib/gitlab/gitaly_client/diff_stitcher_spec.rb b/spec/lib/gitlab/gitaly_client/diff_stitcher_spec.rb index 07650013052..cd3242b9326 100644 --- a/spec/lib/gitlab/gitaly_client/diff_stitcher_spec.rb +++ b/spec/lib/gitlab/gitaly_client/diff_stitcher_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::GitalyClient::DiffStitcher, lib: true do +describe Gitlab::GitalyClient::DiffStitcher do describe 'enumeration' do it 'combines segregated diff messages together' do diff_1 = OpenStruct.new( diff --git a/spec/lib/gitlab/gitaly_client/ref_service_spec.rb b/spec/lib/gitlab/gitaly_client/ref_service_spec.rb index 1e8ed9d645b..0b1c890f956 100644 --- a/spec/lib/gitlab/gitaly_client/ref_service_spec.rb +++ b/spec/lib/gitlab/gitaly_client/ref_service_spec.rb @@ -6,6 +6,17 @@ describe Gitlab::GitalyClient::RefService do let(:relative_path) { project.path_with_namespace + '.git' } let(:client) { described_class.new(project.repository) } + describe '#branches' do + it 'sends a find_all_branches message' do + expect_any_instance_of(Gitaly::RefService::Stub) + .to receive(:find_all_branches) + .with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash)) + .and_return([]) + + client.branches + end + end + describe '#branch_names' do it 'sends a find_all_branch_names message' do expect_any_instance_of(Gitaly::RefService::Stub) diff --git a/spec/lib/gitlab/gitaly_client_spec.rb b/spec/lib/gitlab/gitaly_client_spec.rb index 558ddb3fbd6..921e786a55c 100644 --- a/spec/lib/gitlab/gitaly_client_spec.rb +++ b/spec/lib/gitlab/gitaly_client_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' # We stub Gitaly in `spec/support/gitaly.rb` for other tests. We don't want # those stubs while testing the GitalyClient itself. -describe Gitlab::GitalyClient, lib: true, skip_gitaly_mock: true do +describe Gitlab::GitalyClient, skip_gitaly_mock: true do describe '.stub' do # Notice that this is referring to gRPC "stubs", not rspec stubs before do diff --git a/spec/lib/gitlab/github_import/branch_formatter_spec.rb b/spec/lib/gitlab/github_import/branch_formatter_spec.rb index 3a31f93efa5..426b43f8b51 100644 --- a/spec/lib/gitlab/github_import/branch_formatter_spec.rb +++ b/spec/lib/gitlab/github_import/branch_formatter_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::GithubImport::BranchFormatter, lib: true do +describe Gitlab::GithubImport::BranchFormatter do let(:project) { create(:project, :repository) } let(:commit) { create(:commit, project: project) } let(:repo) { double } diff --git a/spec/lib/gitlab/github_import/client_spec.rb b/spec/lib/gitlab/github_import/client_spec.rb index 21f2a9e225b..66273255b6f 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, lib: true do +describe Gitlab::GithubImport::Client do let(:token) { '123456' } let(:github_provider) { Settingslogic.new('app_id' => 'asd123', 'app_secret' => 'asd123', 'name' => 'github', 'args' => { 'client_options' => {} }) } diff --git a/spec/lib/gitlab/github_import/comment_formatter_spec.rb b/spec/lib/gitlab/github_import/comment_formatter_spec.rb index cc38872e426..ef89634685a 100644 --- a/spec/lib/gitlab/github_import/comment_formatter_spec.rb +++ b/spec/lib/gitlab/github_import/comment_formatter_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::GithubImport::CommentFormatter, lib: true do +describe Gitlab::GithubImport::CommentFormatter do let(:client) { double } let(:project) { create(:empty_project) } let(:octocat) { double(id: 123456, login: 'octocat', email: 'octocat@example.com') } diff --git a/spec/lib/gitlab/github_import/importer_spec.rb b/spec/lib/gitlab/github_import/importer_spec.rb index 9d5e20841b5..d00a2deaf7b 100644 --- a/spec/lib/gitlab/github_import/importer_spec.rb +++ b/spec/lib/gitlab/github_import/importer_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::GithubImport::Importer, lib: true do +describe Gitlab::GithubImport::Importer do shared_examples 'Gitlab::GithubImport::Importer#execute' do let(:expected_not_called) { [] } diff --git a/spec/lib/gitlab/github_import/issuable_formatter_spec.rb b/spec/lib/gitlab/github_import/issuable_formatter_spec.rb index 6bc5f98ed2c..05294d227bd 100644 --- a/spec/lib/gitlab/github_import/issuable_formatter_spec.rb +++ b/spec/lib/gitlab/github_import/issuable_formatter_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::GithubImport::IssuableFormatter, lib: true do +describe Gitlab::GithubImport::IssuableFormatter do let(:raw_data) do double(number: 42) end diff --git a/spec/lib/gitlab/github_import/issue_formatter_spec.rb b/spec/lib/gitlab/github_import/issue_formatter_spec.rb index a4089592cf2..39b15926193 100644 --- a/spec/lib/gitlab/github_import/issue_formatter_spec.rb +++ b/spec/lib/gitlab/github_import/issue_formatter_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::GithubImport::IssueFormatter, lib: true do +describe Gitlab::GithubImport::IssueFormatter do let(:client) { double } let!(:project) { create(:empty_project, namespace: create(:namespace, path: 'octocat')) } let(:octocat) { double(id: 123456, login: 'octocat', email: 'octocat@example.com') } diff --git a/spec/lib/gitlab/github_import/label_formatter_spec.rb b/spec/lib/gitlab/github_import/label_formatter_spec.rb index 565435824fd..2cc7ac0b446 100644 --- a/spec/lib/gitlab/github_import/label_formatter_spec.rb +++ b/spec/lib/gitlab/github_import/label_formatter_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::GithubImport::LabelFormatter, lib: true do +describe Gitlab::GithubImport::LabelFormatter do let(:project) { create(:empty_project) } let(:raw) { double(name: 'improvements', color: 'e6e6e6') } diff --git a/spec/lib/gitlab/github_import/milestone_formatter_spec.rb b/spec/lib/gitlab/github_import/milestone_formatter_spec.rb index 6d38041c468..310e0536fd7 100644 --- a/spec/lib/gitlab/github_import/milestone_formatter_spec.rb +++ b/spec/lib/gitlab/github_import/milestone_formatter_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::GithubImport::MilestoneFormatter, lib: true do +describe Gitlab::GithubImport::MilestoneFormatter do let(:project) { create(:empty_project) } let(:created_at) { DateTime.strptime('2011-01-26T19:01:12Z') } let(:updated_at) { DateTime.strptime('2011-01-27T19:01:12Z') } diff --git a/spec/lib/gitlab/github_import/project_creator_spec.rb b/spec/lib/gitlab/github_import/project_creator_spec.rb index a73b1f4ff5d..948e7469a18 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, lib: true do +describe Gitlab::GithubImport::ProjectCreator do let(:user) { create(:user) } let(:namespace) { create(:group, owner: user) } diff --git a/spec/lib/gitlab/github_import/pull_request_formatter_spec.rb b/spec/lib/gitlab/github_import/pull_request_formatter_spec.rb index b7c59918a76..2e42f6239b7 100644 --- a/spec/lib/gitlab/github_import/pull_request_formatter_spec.rb +++ b/spec/lib/gitlab/github_import/pull_request_formatter_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::GithubImport::PullRequestFormatter, lib: true do +describe Gitlab::GithubImport::PullRequestFormatter do let(:client) { double } let(:project) { create(:project, :repository) } let(:source_sha) { create(:commit, project: project).id } diff --git a/spec/lib/gitlab/github_import/release_formatter_spec.rb b/spec/lib/gitlab/github_import/release_formatter_spec.rb index 13b15e669ab..1357cb636ae 100644 --- a/spec/lib/gitlab/github_import/release_formatter_spec.rb +++ b/spec/lib/gitlab/github_import/release_formatter_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::GithubImport::ReleaseFormatter, lib: true do +describe Gitlab::GithubImport::ReleaseFormatter do let!(:project) { create(:empty_project, namespace: create(:namespace, path: 'octocat')) } let(:octocat) { double(id: 123456, login: 'octocat') } let(:created_at) { DateTime.strptime('2011-01-26T19:01:12Z') } diff --git a/spec/lib/gitlab/github_import/user_formatter_spec.rb b/spec/lib/gitlab/github_import/user_formatter_spec.rb index db792233657..98e3a7c28b9 100644 --- a/spec/lib/gitlab/github_import/user_formatter_spec.rb +++ b/spec/lib/gitlab/github_import/user_formatter_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::GithubImport::UserFormatter, lib: true do +describe Gitlab::GithubImport::UserFormatter do let(:client) { double } let(:octocat) { double(id: 123456, login: 'octocat', email: 'octocat@example.com') } diff --git a/spec/lib/gitlab/github_import/wiki_formatter_spec.rb b/spec/lib/gitlab/github_import/wiki_formatter_spec.rb index 1bd29b8a563..de50265bc14 100644 --- a/spec/lib/gitlab/github_import/wiki_formatter_spec.rb +++ b/spec/lib/gitlab/github_import/wiki_formatter_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::GithubImport::WikiFormatter, lib: true do +describe Gitlab::GithubImport::WikiFormatter do let(:project) do create(:project, namespace: create(:namespace, path: 'gitlabhq'), diff --git a/spec/lib/gitlab/gitlab_import/client_spec.rb b/spec/lib/gitlab/gitlab_import/client_spec.rb index cd8e805466a..50e8d7183ce 100644 --- a/spec/lib/gitlab/gitlab_import/client_spec.rb +++ b/spec/lib/gitlab/gitlab_import/client_spec.rb @@ -1,10 +1,10 @@ require 'spec_helper' -describe Gitlab::GitlabImport::Client, lib: true do +describe Gitlab::GitlabImport::Client do include ImportSpecHelper let(:token) { '123456' } - let(:client) { Gitlab::GitlabImport::Client.new(token) } + let(:client) { described_class.new(token) } before do stub_omniauth_provider('gitlab') diff --git a/spec/lib/gitlab/gitlab_import/importer_spec.rb b/spec/lib/gitlab/gitlab_import/importer_spec.rb index 4f588da0a83..16b14474b89 100644 --- a/spec/lib/gitlab/gitlab_import/importer_spec.rb +++ b/spec/lib/gitlab/gitlab_import/importer_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::GitlabImport::Importer, lib: true do +describe Gitlab::GitlabImport::Importer do include ImportSpecHelper describe '#execute' do diff --git a/spec/lib/gitlab/gitlab_import/project_creator_spec.rb b/spec/lib/gitlab/gitlab_import/project_creator_spec.rb index 483f65cd053..da48d8f0670 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, lib: true do +describe Gitlab::GitlabImport::ProjectCreator do let(:user) { create(:user) } let(:repo) do { @@ -23,7 +23,7 @@ describe Gitlab::GitlabImport::ProjectCreator, lib: true do it 'creates project' do allow_any_instance_of(Project).to receive(:add_import_job) - project_creator = Gitlab::GitlabImport::ProjectCreator.new(repo, namespace, user, access_params) + project_creator = described_class.new(repo, namespace, user, access_params) project = project_creator.execute expect(project.import_url).to eq("https://oauth2:asdffg@gitlab.com/asd/vim.git") diff --git a/spec/lib/gitlab/google_code_import/client_spec.rb b/spec/lib/gitlab/google_code_import/client_spec.rb index 85949ae8dc4..37985c062b4 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, lib: true do +describe Gitlab::GoogleCodeImport::Client 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 622a0f513f4..85f40825005 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, lib: true do +describe Gitlab::GoogleCodeImport::Importer 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 499a896ee76..aad53938d52 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, lib: true do +describe Gitlab::GoogleCodeImport::ProjectCreator do let(:user) { create(:user) } let(:repo) do Gitlab::GoogleCodeImport::Repository.new( @@ -18,7 +18,7 @@ describe Gitlab::GoogleCodeImport::ProjectCreator, lib: true do it 'creates project' do allow_any_instance_of(Project).to receive(:add_import_job) - project_creator = Gitlab::GoogleCodeImport::ProjectCreator.new(repo, namespace, user) + project_creator = described_class.new(repo, namespace, user) project = project_creator.execute expect(project.import_url).to eq("https://vim.googlecode.com/git/") diff --git a/spec/lib/gitlab/gpg/commit_spec.rb b/spec/lib/gitlab/gpg/commit_spec.rb new file mode 100644 index 00000000000..ddb8dd9f0f4 --- /dev/null +++ b/spec/lib/gitlab/gpg/commit_spec.rb @@ -0,0 +1,127 @@ +require 'rails_helper' + +RSpec.describe Gitlab::Gpg::Commit do + describe '#signature' do + let!(:project) { create :project, :repository, path: 'sample-project' } + let!(:commit_sha) { '0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33' } + + context 'unisgned commit' do + it 'returns nil' do + expect(described_class.new(project.commit).signature).to be_nil + end + end + + context 'known and verified public key' do + let!(:gpg_key) do + create :gpg_key, key: GpgHelpers::User1.public_key, user: create(:user, email: GpgHelpers::User1.emails.first) + end + + let!(:commit) do + raw_commit = double(:raw_commit, signature: [ + GpgHelpers::User1.signed_commit_signature, + GpgHelpers::User1.signed_commit_base_data + ], sha: commit_sha) + allow(raw_commit).to receive :save! + + create :commit, git_commit: raw_commit, project: project + end + + it 'returns a valid signature' do + expect(described_class.new(commit).signature).to have_attributes( + commit_sha: commit_sha, + project: project, + gpg_key: gpg_key, + gpg_key_primary_keyid: GpgHelpers::User1.primary_keyid, + gpg_key_user_name: GpgHelpers::User1.names.first, + gpg_key_user_email: GpgHelpers::User1.emails.first, + valid_signature: true + ) + end + + it 'returns the cached signature on second call' do + gpg_commit = described_class.new(commit) + + expect(gpg_commit).to receive(:using_keychain).and_call_original + gpg_commit.signature + + # consecutive call + expect(gpg_commit).not_to receive(:using_keychain).and_call_original + gpg_commit.signature + end + end + + context 'known but unverified public key' do + let!(:gpg_key) { create :gpg_key, key: GpgHelpers::User1.public_key } + + let!(:commit) do + raw_commit = double(:raw_commit, signature: [ + GpgHelpers::User1.signed_commit_signature, + GpgHelpers::User1.signed_commit_base_data + ], sha: commit_sha) + allow(raw_commit).to receive :save! + + create :commit, git_commit: raw_commit, project: project + end + + it 'returns an invalid signature' do + expect(described_class.new(commit).signature).to have_attributes( + commit_sha: commit_sha, + project: project, + gpg_key: gpg_key, + gpg_key_primary_keyid: GpgHelpers::User1.primary_keyid, + gpg_key_user_name: GpgHelpers::User1.names.first, + gpg_key_user_email: GpgHelpers::User1.emails.first, + valid_signature: false + ) + end + + it 'returns the cached signature on second call' do + gpg_commit = described_class.new(commit) + + expect(gpg_commit).to receive(:using_keychain).and_call_original + gpg_commit.signature + + # consecutive call + expect(gpg_commit).not_to receive(:using_keychain).and_call_original + gpg_commit.signature + end + end + + context 'unknown public key' do + let!(:commit) do + raw_commit = double(:raw_commit, signature: [ + GpgHelpers::User1.signed_commit_signature, + GpgHelpers::User1.signed_commit_base_data + ], sha: commit_sha) + allow(raw_commit).to receive :save! + + create :commit, + git_commit: raw_commit, + project: project + end + + it 'returns an invalid signature' do + expect(described_class.new(commit).signature).to have_attributes( + commit_sha: commit_sha, + project: project, + gpg_key: nil, + gpg_key_primary_keyid: GpgHelpers::User1.primary_keyid, + gpg_key_user_name: nil, + gpg_key_user_email: nil, + valid_signature: false + ) + end + + it 'returns the cached signature on second call' do + gpg_commit = described_class.new(commit) + + expect(gpg_commit).to receive(:using_keychain).and_call_original + gpg_commit.signature + + # consecutive call + expect(gpg_commit).not_to receive(:using_keychain).and_call_original + gpg_commit.signature + end + end + end +end diff --git a/spec/lib/gitlab/gpg/invalid_gpg_signature_updater_spec.rb b/spec/lib/gitlab/gpg/invalid_gpg_signature_updater_spec.rb new file mode 100644 index 00000000000..c4e04ee46a2 --- /dev/null +++ b/spec/lib/gitlab/gpg/invalid_gpg_signature_updater_spec.rb @@ -0,0 +1,173 @@ +require 'rails_helper' + +RSpec.describe Gitlab::Gpg::InvalidGpgSignatureUpdater do + describe '#run' do + let!(:commit_sha) { '0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33' } + let!(:project) { create :project, :repository, path: 'sample-project' } + let!(:raw_commit) do + raw_commit = double(:raw_commit, signature: [ + GpgHelpers::User1.signed_commit_signature, + GpgHelpers::User1.signed_commit_base_data + ], sha: commit_sha) + + allow(raw_commit).to receive :save! + + raw_commit + end + + let!(:commit) do + create :commit, git_commit: raw_commit, project: project + end + + before do + allow_any_instance_of(Project).to receive(:commit).and_return(commit) + end + + context 'gpg signature did have an associated gpg key which was removed later' do + let!(:user) { create :user, email: GpgHelpers::User1.emails.first } + + let!(:valid_gpg_signature) do + create :gpg_signature, + project: project, + commit_sha: commit_sha, + gpg_key: nil, + gpg_key_primary_keyid: GpgHelpers::User1.primary_keyid, + valid_signature: true + end + + it 'assigns the gpg key to the signature when the missing gpg key is added' do + # InvalidGpgSignatureUpdater is called by the after_create hook + gpg_key = create :gpg_key, + key: GpgHelpers::User1.public_key, + user: user + + expect(valid_gpg_signature.reload).to have_attributes( + project: project, + commit_sha: commit_sha, + gpg_key: gpg_key, + gpg_key_primary_keyid: GpgHelpers::User1.primary_keyid, + valid_signature: true + ) + end + + it 'does not assign the gpg key when an unrelated gpg key is added' do + # InvalidGpgSignatureUpdater is called by the after_create hook + create :gpg_key, + key: GpgHelpers::User2.public_key, + user: user + + expect(valid_gpg_signature.reload).to have_attributes( + project: project, + commit_sha: commit_sha, + gpg_key: nil, + gpg_key_primary_keyid: GpgHelpers::User1.primary_keyid, + valid_signature: true + ) + end + end + + context 'gpg signature did not have an associated gpg key' do + let!(:user) { create :user, email: GpgHelpers::User1.emails.first } + + let!(:invalid_gpg_signature) do + create :gpg_signature, + project: project, + commit_sha: commit_sha, + gpg_key: nil, + gpg_key_primary_keyid: GpgHelpers::User1.primary_keyid, + valid_signature: false + end + + it 'updates the signature to being valid when the missing gpg key is added' do + # InvalidGpgSignatureUpdater is called by the after_create hook + gpg_key = create :gpg_key, + key: GpgHelpers::User1.public_key, + user: user + + expect(invalid_gpg_signature.reload).to have_attributes( + project: project, + commit_sha: commit_sha, + gpg_key: gpg_key, + gpg_key_primary_keyid: GpgHelpers::User1.primary_keyid, + valid_signature: true + ) + end + + it 'keeps the signature at being invalid when an unrelated gpg key is added' do + # InvalidGpgSignatureUpdater is called by the after_create hook + create :gpg_key, + key: GpgHelpers::User2.public_key, + user: user + + expect(invalid_gpg_signature.reload).to have_attributes( + project: project, + commit_sha: commit_sha, + gpg_key: nil, + gpg_key_primary_keyid: GpgHelpers::User1.primary_keyid, + valid_signature: false + ) + end + end + + context 'gpg signature did have an associated unverified gpg key' do + let!(:user) do + create(:user, email: 'unrelated@example.com').tap do |user| + user.skip_reconfirmation! + end + end + + let!(:invalid_gpg_signature) do + create :gpg_signature, + project: project, + commit_sha: commit_sha, + gpg_key: nil, + gpg_key_primary_keyid: GpgHelpers::User1.primary_keyid, + valid_signature: false + end + + it 'updates the signature to being valid when the user updates the email address' do + gpg_key = create :gpg_key, + key: GpgHelpers::User1.public_key, + user: user + + expect(invalid_gpg_signature.reload.valid_signature).to be_falsey + + # InvalidGpgSignatureUpdater is called by the after_update hook + user.update_attributes!(email: GpgHelpers::User1.emails.first) + + expect(invalid_gpg_signature.reload).to have_attributes( + project: project, + commit_sha: commit_sha, + gpg_key: gpg_key, + gpg_key_primary_keyid: GpgHelpers::User1.primary_keyid, + valid_signature: true + ) + end + + it 'keeps the signature at being invalid when the changed email address is still unrelated' do + gpg_key = create :gpg_key, + key: GpgHelpers::User1.public_key, + user: user + + expect(invalid_gpg_signature.reload).to have_attributes( + project: project, + commit_sha: commit_sha, + gpg_key: gpg_key, + gpg_key_primary_keyid: GpgHelpers::User1.primary_keyid, + valid_signature: false + ) + + # InvalidGpgSignatureUpdater is called by the after_update hook + user.update_attributes!(email: 'still.unrelated@example.com') + + expect(invalid_gpg_signature.reload).to have_attributes( + project: project, + commit_sha: commit_sha, + gpg_key: gpg_key, + gpg_key_primary_keyid: GpgHelpers::User1.primary_keyid, + valid_signature: false + ) + end + end + end +end diff --git a/spec/lib/gitlab/gpg_spec.rb b/spec/lib/gitlab/gpg_spec.rb new file mode 100644 index 00000000000..8041518117d --- /dev/null +++ b/spec/lib/gitlab/gpg_spec.rb @@ -0,0 +1,83 @@ +require 'rails_helper' + +describe Gitlab::Gpg do + describe '.fingerprints_from_key' do + before do + # make sure that each method is using the temporary keychain + expect(described_class).to receive(:using_tmp_keychain).and_call_original + end + + it 'returns CurrentKeyChain.fingerprints_from_key' do + expect(Gitlab::Gpg::CurrentKeyChain).to receive(:fingerprints_from_key).with(GpgHelpers::User1.public_key) + + described_class.fingerprints_from_key(GpgHelpers::User1.public_key) + end + end + + describe '.primary_keyids_from_key' do + it 'returns the keyid' do + expect( + described_class.primary_keyids_from_key(GpgHelpers::User1.public_key) + ).to eq [GpgHelpers::User1.primary_keyid] + end + + it 'returns an empty array when the key is invalid' do + expect( + described_class.primary_keyids_from_key('bogus') + ).to eq [] + end + end + + describe '.user_infos_from_key' do + it 'returns the names and emails' do + user_infos = described_class.user_infos_from_key(GpgHelpers::User1.public_key) + expect(user_infos).to eq([{ + name: GpgHelpers::User1.names.first, + email: GpgHelpers::User1.emails.first + }]) + end + + it 'returns an empty array when the key is invalid' do + expect( + described_class.user_infos_from_key('bogus') + ).to eq [] + end + end +end + +describe Gitlab::Gpg::CurrentKeyChain do + around do |example| + Gitlab::Gpg.using_tmp_keychain do + example.run + end + end + + describe '.add' do + it 'stores the key in the keychain' do + expect(GPGME::Key.find(:public, GpgHelpers::User1.fingerprint)).to eq [] + + described_class.add(GpgHelpers::User1.public_key) + + keys = GPGME::Key.find(:public, GpgHelpers::User1.fingerprint) + expect(keys.count).to eq 1 + expect(keys.first).to have_attributes( + email: GpgHelpers::User1.emails.first, + fingerprint: GpgHelpers::User1.fingerprint + ) + end + end + + describe '.fingerprints_from_key' do + it 'returns the fingerprint' do + expect( + described_class.fingerprints_from_key(GpgHelpers::User1.public_key) + ).to eq [GpgHelpers::User1.fingerprint] + end + + it 'returns an empty array when the key is invalid' do + expect( + described_class.fingerprints_from_key('bogus') + ).to eq [] + end + end +end diff --git a/spec/lib/gitlab/graphs/commits_spec.rb b/spec/lib/gitlab/graphs/commits_spec.rb index abb5a26060f..3f9382a9143 100644 --- a/spec/lib/gitlab/graphs/commits_spec.rb +++ b/spec/lib/gitlab/graphs/commits_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::Graphs::Commits, lib: true do +describe Gitlab::Graphs::Commits do let!(:project) { create(:empty_project, :public) } let!(:commit1) { create(:commit, git_commit: RepoHelpers.sample_commit, project: project, committed_date: Time.now) } diff --git a/spec/lib/gitlab/health_checks/fs_shards_check_spec.rb b/spec/lib/gitlab/health_checks/fs_shards_check_spec.rb index 3de73a9ff65..8abc4320c59 100644 --- a/spec/lib/gitlab/health_checks/fs_shards_check_spec.rb +++ b/spec/lib/gitlab/health_checks/fs_shards_check_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe Gitlab::HealthChecks::FsShardsCheck do def command_exists?(command) _, status = Gitlab::Popen.popen(%W{ #{command} 1 echo }) - status == 0 + status.zero? rescue Errno::ENOENT false end @@ -64,9 +64,7 @@ describe Gitlab::HealthChecks::FsShardsCheck do it 'cleans up files used for testing' do expect(described_class).to receive(:storage_write_test).with(any_args).and_call_original - subject - - expect(Dir.entries(tmp_dir).count).to eq(2) + expect { subject }.not_to change(Dir.entries(tmp_dir), :count) end context 'read test fails' do @@ -88,8 +86,6 @@ describe Gitlab::HealthChecks::FsShardsCheck do end describe '#metrics' do - subject { described_class.metrics } - context 'storage points to not existing folder' do let(:storages_paths) do { @@ -104,14 +100,15 @@ describe Gitlab::HealthChecks::FsShardsCheck do end it 'provides metrics' do - expect(subject).to all(have_attributes(labels: { shard: :default })) - expect(subject).to include(an_object_having_attributes(name: :filesystem_accessible, value: 0)) - expect(subject).to include(an_object_having_attributes(name: :filesystem_readable, value: 0)) - expect(subject).to include(an_object_having_attributes(name: :filesystem_writable, value: 0)) - - expect(subject).to include(an_object_having_attributes(name: :filesystem_access_latency_seconds, value: be >= 0)) - expect(subject).to include(an_object_having_attributes(name: :filesystem_read_latency_seconds, value: be >= 0)) - expect(subject).to include(an_object_having_attributes(name: :filesystem_write_latency_seconds, value: be >= 0)) + metrics = described_class.metrics + + expect(metrics).to all(have_attributes(labels: { shard: :default })) + expect(metrics).to include(an_object_having_attributes(name: :filesystem_accessible, value: 0)) + expect(metrics).to include(an_object_having_attributes(name: :filesystem_readable, value: 0)) + expect(metrics).to include(an_object_having_attributes(name: :filesystem_writable, value: 0)) + expect(metrics).to include(an_object_having_attributes(name: :filesystem_access_latency_seconds, value: be >= 0)) + expect(metrics).to include(an_object_having_attributes(name: :filesystem_read_latency_seconds, value: be >= 0)) + expect(metrics).to include(an_object_having_attributes(name: :filesystem_write_latency_seconds, value: be >= 0)) end end @@ -121,15 +118,19 @@ describe Gitlab::HealthChecks::FsShardsCheck do end it 'provides metrics' do - expect(subject).to all(have_attributes(labels: { shard: :default })) - - expect(subject).to include(an_object_having_attributes(name: :filesystem_accessible, value: 1)) - expect(subject).to include(an_object_having_attributes(name: :filesystem_readable, value: 1)) - expect(subject).to include(an_object_having_attributes(name: :filesystem_writable, value: 1)) + metrics = described_class.metrics + + expect(metrics).to all(have_attributes(labels: { shard: :default })) + expect(metrics).to include(an_object_having_attributes(name: :filesystem_accessible, value: 1)) + expect(metrics).to include(an_object_having_attributes(name: :filesystem_readable, value: 1)) + expect(metrics).to include(an_object_having_attributes(name: :filesystem_writable, value: 1)) + expect(metrics).to include(an_object_having_attributes(name: :filesystem_access_latency_seconds, value: be >= 0)) + expect(metrics).to include(an_object_having_attributes(name: :filesystem_read_latency_seconds, value: be >= 0)) + expect(metrics).to include(an_object_having_attributes(name: :filesystem_write_latency_seconds, value: be >= 0)) + end - expect(subject).to include(an_object_having_attributes(name: :filesystem_access_latency_seconds, value: be >= 0)) - expect(subject).to include(an_object_having_attributes(name: :filesystem_read_latency_seconds, value: be >= 0)) - expect(subject).to include(an_object_having_attributes(name: :filesystem_write_latency_seconds, value: be >= 0)) + it 'cleans up files used for metrics' do + expect { described_class.metrics }.not_to change(Dir.entries(tmp_dir), :count) end end end @@ -150,18 +151,16 @@ describe Gitlab::HealthChecks::FsShardsCheck do end describe '#metrics' do - subject { described_class.metrics } - it 'provides metrics' do - expect(subject).to all(have_attributes(labels: { shard: :default })) - - expect(subject).to include(an_object_having_attributes(name: :filesystem_accessible, value: 0)) - expect(subject).to include(an_object_having_attributes(name: :filesystem_readable, value: 0)) - expect(subject).to include(an_object_having_attributes(name: :filesystem_writable, value: 0)) - - expect(subject).to include(an_object_having_attributes(name: :filesystem_access_latency_seconds, value: be >= 0)) - expect(subject).to include(an_object_having_attributes(name: :filesystem_read_latency_seconds, value: be >= 0)) - expect(subject).to include(an_object_having_attributes(name: :filesystem_write_latency_seconds, value: be >= 0)) + metrics = described_class.metrics + + expect(metrics).to all(have_attributes(labels: { shard: :default })) + expect(metrics).to include(an_object_having_attributes(name: :filesystem_accessible, value: 0)) + expect(metrics).to include(an_object_having_attributes(name: :filesystem_readable, value: 0)) + expect(metrics).to include(an_object_having_attributes(name: :filesystem_writable, value: 0)) + expect(metrics).to include(an_object_having_attributes(name: :filesystem_access_latency_seconds, value: be >= 0)) + expect(metrics).to include(an_object_having_attributes(name: :filesystem_read_latency_seconds, value: be >= 0)) + expect(metrics).to include(an_object_having_attributes(name: :filesystem_write_latency_seconds, value: be >= 0)) end end end diff --git a/spec/lib/gitlab/highlight_spec.rb b/spec/lib/gitlab/highlight_spec.rb index 07687b470c5..29e61d15726 100644 --- a/spec/lib/gitlab/highlight_spec.rb +++ b/spec/lib/gitlab/highlight_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::Highlight, lib: true do +describe Gitlab::Highlight do include RepoHelpers let(:project) { create(:project, :repository) } @@ -12,7 +12,7 @@ describe Gitlab::Highlight, lib: true do let(:blob) { repository.blob_at_branch(branch, path) } let(:highlighter) do - Gitlab::Highlight.new(blob.path, blob.data, repository: repository) + described_class.new(blob.path, blob.data, repository: repository) end before do @@ -42,7 +42,7 @@ describe Gitlab::Highlight, lib: true do let(:path) { 'files/whitespace' } let(:blob) { repository.blob_at_branch(branch, path) } let(:lines) do - Gitlab::Highlight.highlight(blob.path, blob.data, repository: repository).lines + described_class.highlight(blob.path, blob.data, repository: repository).lines end it 'strips extra LFs' do diff --git a/spec/lib/gitlab/i18n_spec.rb b/spec/lib/gitlab/i18n_spec.rb index 0dba4132101..785035d993f 100644 --- a/spec/lib/gitlab/i18n_spec.rb +++ b/spec/lib/gitlab/i18n_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::I18n, lib: true do +describe Gitlab::I18n do let(:user) { create(:user, preferred_language: 'es') } describe '.locale=' do diff --git a/spec/lib/gitlab/import_export/all_models.yml b/spec/lib/gitlab/import_export/all_models.yml index 28df089928f..e6c7f3bdf74 100644 --- a/spec/lib/gitlab/import_export/all_models.yml +++ b/spec/lib/gitlab/import_export/all_models.yml @@ -102,6 +102,7 @@ pipelines: - statuses - builds - trigger_requests +- variables - auto_canceled_by - auto_canceled_pipelines - auto_canceled_jobs @@ -112,6 +113,8 @@ pipelines: - artifacts - pipeline_schedule - merge_requests +pipeline_variables: +- pipeline stages: - project - pipeline diff --git a/spec/lib/gitlab/import_export/attribute_cleaner_spec.rb b/spec/lib/gitlab/import_export/attribute_cleaner_spec.rb index 63bab0f0d0d..574748756bd 100644 --- a/spec/lib/gitlab/import_export/attribute_cleaner_spec.rb +++ b/spec/lib/gitlab/import_export/attribute_cleaner_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::ImportExport::AttributeCleaner, lib: true do +describe Gitlab::ImportExport::AttributeCleaner do let(:relation_class){ double('relation_class').as_null_object } let(:unsafe_hash) do { diff --git a/spec/lib/gitlab/import_export/attribute_configuration_spec.rb b/spec/lib/gitlab/import_export/attribute_configuration_spec.rb index e24d070706a..65f073b2df3 100644 --- a/spec/lib/gitlab/import_export/attribute_configuration_spec.rb +++ b/spec/lib/gitlab/import_export/attribute_configuration_spec.rb @@ -7,7 +7,7 @@ require 'spec_helper' # to be included as part of the export, or blacklist them using the import_export.yml configuration file. # Likewise, new models added to import_export.yml, will need to be added with their correspondent attributes # to this spec. -describe 'Import/Export attribute configuration', lib: true do +describe 'Import/Export attribute configuration' do include ConfigurationHelper let(:config_hash) { YAML.load_file(Gitlab::ImportExport.config_file).deep_stringify_keys } diff --git a/spec/lib/gitlab/import_export/avatar_restorer_spec.rb b/spec/lib/gitlab/import_export/avatar_restorer_spec.rb index 08a42fd27a2..a7b292c8558 100644 --- a/spec/lib/gitlab/import_export/avatar_restorer_spec.rb +++ b/spec/lib/gitlab/import_export/avatar_restorer_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::ImportExport::AvatarRestorer, lib: true do +describe Gitlab::ImportExport::AvatarRestorer do include UploadHelpers let(:shared) { Gitlab::ImportExport::Shared.new(relative_path: 'test') } diff --git a/spec/lib/gitlab/import_export/avatar_saver_spec.rb b/spec/lib/gitlab/import_export/avatar_saver_spec.rb index 579a31ead58..814f85de03b 100644 --- a/spec/lib/gitlab/import_export/avatar_saver_spec.rb +++ b/spec/lib/gitlab/import_export/avatar_saver_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::ImportExport::AvatarSaver, lib: true do +describe Gitlab::ImportExport::AvatarSaver do let(:shared) { Gitlab::ImportExport::Shared.new(relative_path: 'test') } let(:export_path) { "#{Dir.tmpdir}/project_tree_saver_spec" } let(:project_with_avatar) { create(:empty_project, avatar: fixture_file_upload(Rails.root + "spec/fixtures/dk.png", "image/png")) } diff --git a/spec/lib/gitlab/import_export/file_importer_spec.rb b/spec/lib/gitlab/import_export/file_importer_spec.rb index b88b9c18c15..690c7625c52 100644 --- a/spec/lib/gitlab/import_export/file_importer_spec.rb +++ b/spec/lib/gitlab/import_export/file_importer_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::ImportExport::FileImporter, lib: true do +describe Gitlab::ImportExport::FileImporter do let(:shared) { Gitlab::ImportExport::Shared.new(relative_path: 'test') } let(:export_path) { "#{Dir.tmpdir}/file_importer_spec" } let(:valid_file) { "#{shared.export_path}/valid.json" } diff --git a/spec/lib/gitlab/import_export/fork_spec.rb b/spec/lib/gitlab/import_export/fork_spec.rb index 70796781532..08588a76fe6 100644 --- a/spec/lib/gitlab/import_export/fork_spec.rb +++ b/spec/lib/gitlab/import_export/fork_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' -describe 'forked project import', services: true do +describe 'forked project import' do let(:user) { create(:user) } - let!(:project_with_repo) { create(:project, :test_repo, name: 'test-repo-restorer', path: 'test-repo-restorer') } + let!(:project_with_repo) { create(:project, name: 'test-repo-restorer', path: 'test-repo-restorer') } let!(:project) { create(:empty_project, name: 'test-repo-restorer-no-repo', path: 'test-repo-restorer-no-repo') } let(:export_path) { "#{Dir.tmpdir}/project_tree_saver_spec" } let(:shared) { Gitlab::ImportExport::Shared.new(relative_path: project.path_with_namespace) } diff --git a/spec/lib/gitlab/import_export/hash_util_spec.rb b/spec/lib/gitlab/import_export/hash_util_spec.rb index 1c3a0b23ece..366582dece3 100644 --- a/spec/lib/gitlab/import_export/hash_util_spec.rb +++ b/spec/lib/gitlab/import_export/hash_util_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::ImportExport::HashUtil, lib: true do +describe Gitlab::ImportExport::HashUtil do let(:stringified_array) { [{ 'test' => 1 }] } let(:stringified_array_with_date) { [{ 'test_date' => '2016-04-06 06:17:44 +0200' }] } diff --git a/spec/lib/gitlab/import_export/import_export_spec.rb b/spec/lib/gitlab/import_export/import_export_spec.rb index f3fd0d82875..07415d41f93 100644 --- a/spec/lib/gitlab/import_export/import_export_spec.rb +++ b/spec/lib/gitlab/import_export/import_export_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::ImportExport, services: true do +describe Gitlab::ImportExport do describe 'export filename' do let(:group) { create(:group, :nested) } let(:project) { create(:empty_project, :public, path: 'project-path', namespace: group) } diff --git a/spec/lib/gitlab/import_export/members_mapper_spec.rb b/spec/lib/gitlab/import_export/members_mapper_spec.rb index 3e0291c9ae9..f66a2ab7dda 100644 --- a/spec/lib/gitlab/import_export/members_mapper_spec.rb +++ b/spec/lib/gitlab/import_export/members_mapper_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::ImportExport::MembersMapper, services: true do +describe Gitlab::ImportExport::MembersMapper do describe 'map members' do let(:user) { create(:admin) } let(:project) { create(:empty_project, :public, name: 'searchable_project') } diff --git a/spec/lib/gitlab/import_export/merge_request_parser_spec.rb b/spec/lib/gitlab/import_export/merge_request_parser_spec.rb index 349be4596b6..f2b66c4421c 100644 --- a/spec/lib/gitlab/import_export/merge_request_parser_spec.rb +++ b/spec/lib/gitlab/import_export/merge_request_parser_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe Gitlab::ImportExport::MergeRequestParser do let(:user) { create(:user) } - let!(:project) { create(:project, :test_repo, name: 'test-repo-restorer', path: 'test-repo-restorer') } + let!(:project) { create(:project, name: 'test-repo-restorer', path: 'test-repo-restorer') } let(:forked_from_project) { create(:project) } let(:fork_link) { create(:forked_project_link, forked_from_project: project) } diff --git a/spec/lib/gitlab/import_export/model_configuration_spec.rb b/spec/lib/gitlab/import_export/model_configuration_spec.rb index 2ede5cdd2ad..5cb8f2589c8 100644 --- a/spec/lib/gitlab/import_export/model_configuration_spec.rb +++ b/spec/lib/gitlab/import_export/model_configuration_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' # Part of the test security suite for the Import/Export feature # Finds if a new model has been added that can potentially be part of the Import/Export # If it finds a new model, it will show a +failure_message+ with the options available. -describe 'Import/Export model configuration', lib: true do +describe 'Import/Export model configuration' do include ConfigurationHelper let(:config_hash) { YAML.load_file(Gitlab::ImportExport.config_file).deep_stringify_keys } diff --git a/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb b/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb index d50d238ddcd..d1ec0e45bbd 100644 --- a/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb +++ b/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' include ImportExport::CommonUtil -describe Gitlab::ImportExport::ProjectTreeRestorer, services: true do +describe Gitlab::ImportExport::ProjectTreeRestorer do describe 'restore project tree' do before(:context) do @user = create(:user) diff --git a/spec/lib/gitlab/import_export/project_tree_saver_spec.rb b/spec/lib/gitlab/import_export/project_tree_saver_spec.rb index 22a65e24f26..0c7e733b01f 100644 --- a/spec/lib/gitlab/import_export/project_tree_saver_spec.rb +++ b/spec/lib/gitlab/import_export/project_tree_saver_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::ImportExport::ProjectTreeSaver, services: true do +describe Gitlab::ImportExport::ProjectTreeSaver do describe 'saves the project tree into a json object' do let(:shared) { Gitlab::ImportExport::Shared.new(relative_path: project.path_with_namespace) } let(:project_tree_saver) { described_class.new(project: project, current_user: user, shared: shared) } diff --git a/spec/lib/gitlab/import_export/reader_spec.rb b/spec/lib/gitlab/import_export/reader_spec.rb index d700af142be..e9f5273725d 100644 --- a/spec/lib/gitlab/import_export/reader_spec.rb +++ b/spec/lib/gitlab/import_export/reader_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::ImportExport::Reader, lib: true do +describe Gitlab::ImportExport::Reader do let(:shared) { Gitlab::ImportExport::Shared.new(relative_path: '') } let(:test_config) { 'spec/support/import_export/import_export.yml' } let(:project_tree_hash) do diff --git a/spec/lib/gitlab/import_export/relation_factory_spec.rb b/spec/lib/gitlab/import_export/relation_factory_spec.rb index 5417c7534ea..baa90af84f7 100644 --- a/spec/lib/gitlab/import_export/relation_factory_spec.rb +++ b/spec/lib/gitlab/import_export/relation_factory_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::ImportExport::RelationFactory, lib: true do +describe Gitlab::ImportExport::RelationFactory do let(:project) { create(:empty_project) } let(:members_mapper) { double('members_mapper').as_null_object } let(:user) { create(:admin) } diff --git a/spec/lib/gitlab/import_export/repo_restorer_spec.rb b/spec/lib/gitlab/import_export/repo_restorer_spec.rb index 30b6a0d8845..d3be2965bf4 100644 --- a/spec/lib/gitlab/import_export/repo_restorer_spec.rb +++ b/spec/lib/gitlab/import_export/repo_restorer_spec.rb @@ -1,9 +1,9 @@ require 'spec_helper' -describe Gitlab::ImportExport::RepoRestorer, services: true do +describe Gitlab::ImportExport::RepoRestorer do describe 'bundle a project Git repo' do let(:user) { create(:user) } - let!(:project_with_repo) { create(:project, :test_repo, name: 'test-repo-restorer', path: 'test-repo-restorer') } + let!(:project_with_repo) { create(:project, name: 'test-repo-restorer', path: 'test-repo-restorer') } let!(:project) { create(:empty_project) } let(:export_path) { "#{Dir.tmpdir}/project_tree_saver_spec" } let(:shared) { Gitlab::ImportExport::Shared.new(relative_path: project.path_with_namespace) } diff --git a/spec/lib/gitlab/import_export/repo_saver_spec.rb b/spec/lib/gitlab/import_export/repo_saver_spec.rb index a7f4e11271e..87af13e0beb 100644 --- a/spec/lib/gitlab/import_export/repo_saver_spec.rb +++ b/spec/lib/gitlab/import_export/repo_saver_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::ImportExport::RepoSaver, services: true do +describe Gitlab::ImportExport::RepoSaver do describe 'bundle a project Git repo' do let(:user) { create(:user) } let!(:project) { create(:empty_project, :public, name: 'searchable_project') } diff --git a/spec/lib/gitlab/import_export/safe_model_attributes.yml b/spec/lib/gitlab/import_export/safe_model_attributes.yml index 7bbeea06f04..2d5a60fe6b8 100644 --- a/spec/lib/gitlab/import_export/safe_model_attributes.yml +++ b/spec/lib/gitlab/import_export/safe_model_attributes.yml @@ -195,6 +195,7 @@ MergeRequestDiffFile: - a_mode - b_mode - too_large +- binary Ci::Pipeline: - id - project_id @@ -398,6 +399,7 @@ Project: - build_allow_git_fetch - last_repository_updated_at - ci_config_path +- delete_error Author: - name ProjectFeature: diff --git a/spec/lib/gitlab/import_export/version_checker_spec.rb b/spec/lib/gitlab/import_export/version_checker_spec.rb index 2405ac5abfe..e7d50f75682 100644 --- a/spec/lib/gitlab/import_export/version_checker_spec.rb +++ b/spec/lib/gitlab/import_export/version_checker_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' include ImportExport::CommonUtil -describe Gitlab::ImportExport::VersionChecker, services: true do +describe Gitlab::ImportExport::VersionChecker do let(:shared) { Gitlab::ImportExport::Shared.new(relative_path: '') } describe 'bundle a project Git repo' do diff --git a/spec/lib/gitlab/import_export/wiki_repo_saver_spec.rb b/spec/lib/gitlab/import_export/wiki_repo_saver_spec.rb index 071e5fac3f0..78137aeff5e 100644 --- a/spec/lib/gitlab/import_export/wiki_repo_saver_spec.rb +++ b/spec/lib/gitlab/import_export/wiki_repo_saver_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::ImportExport::WikiRepoSaver, services: true do +describe Gitlab::ImportExport::WikiRepoSaver do describe 'bundle a wiki Git repo' do let(:user) { create(:user) } let!(:project) { create(:empty_project, :public, name: 'searchable_project') } diff --git a/spec/lib/gitlab/incoming_email_spec.rb b/spec/lib/gitlab/incoming_email_spec.rb index 698bd72d0f8..c959add7a36 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, lib: true do +describe Gitlab::IncomingEmail do describe "self.enabled?" do context "when reply by email is enabled" do before do diff --git a/spec/lib/gitlab/issuable_metadata_spec.rb b/spec/lib/gitlab/issuable_metadata_spec.rb index f9f4b290dbf..2455969a183 100644 --- a/spec/lib/gitlab/issuable_metadata_spec.rb +++ b/spec/lib/gitlab/issuable_metadata_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::IssuableMetadata, lib: true do +describe Gitlab::IssuableMetadata do let(:user) { create(:user) } let!(:project) { create(:project, :public, :repository, creator: user, namespace: user.namespace) } diff --git a/spec/lib/gitlab/issuable_sorter_spec.rb b/spec/lib/gitlab/issuable_sorter_spec.rb index c9a434b2bcf..aeb32ef96d6 100644 --- a/spec/lib/gitlab/issuable_sorter_spec.rb +++ b/spec/lib/gitlab/issuable_sorter_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::IssuableSorter, lib: true do +describe Gitlab::IssuableSorter do let(:namespace1) { build(:namespace, id: 1) } let(:project1) { build(:project, id: 1, namespace: namespace1) } diff --git a/spec/lib/gitlab/key_fingerprint_spec.rb b/spec/lib/gitlab/key_fingerprint_spec.rb index d09f51f3bfc..d7bebaca675 100644 --- a/spec/lib/gitlab/key_fingerprint_spec.rb +++ b/spec/lib/gitlab/key_fingerprint_spec.rb @@ -1,12 +1,12 @@ require "spec_helper" -describe Gitlab::KeyFingerprint, lib: true do +describe Gitlab::KeyFingerprint 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" } describe "#fingerprint" do it "generates the key's fingerprint" do - expect(Gitlab::KeyFingerprint.new(key).fingerprint).to eq(fingerprint) + expect(described_class.new(key).fingerprint).to eq(fingerprint) end end end diff --git a/spec/lib/gitlab/lazy_spec.rb b/spec/lib/gitlab/lazy_spec.rb index b5ca89dd242..37a3ac74316 100644 --- a/spec/lib/gitlab/lazy_spec.rb +++ b/spec/lib/gitlab/lazy_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::Lazy, lib: true do +describe Gitlab::Lazy do let(:dummy) { double(:dummy) } context 'when not calling any methods' do diff --git a/spec/lib/gitlab/ldap/access_spec.rb b/spec/lib/gitlab/ldap/access_spec.rb index 756fcb0fcaf..6a47350be81 100644 --- a/spec/lib/gitlab/ldap/access_spec.rb +++ b/spec/lib/gitlab/ldap/access_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' -describe Gitlab::LDAP::Access, lib: true do - let(:access) { Gitlab::LDAP::Access.new user } +describe Gitlab::LDAP::Access do + let(:access) { described_class.new user } let(:user) { create(:omniauth_user) } describe '.allowed?' do diff --git a/spec/lib/gitlab/ldap/adapter_spec.rb b/spec/lib/gitlab/ldap/adapter_spec.rb index 9454878b057..d17d440d833 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, lib: true do +describe Gitlab::LDAP::Adapter do include LdapHelpers let(:ldap) { double(:ldap) } @@ -16,7 +16,7 @@ describe Gitlab::LDAP::Adapter, lib: true do expect(adapter).to receive(:ldap_search) do |arg| expect(arg[:filter].to_s).to eq('(uid=johndoe)') expect(arg[:base]).to eq('dc=example,dc=com') - expect(arg[:attributes]).to match(%w{uid cn mail dn}) + expect(arg[:attributes]).to match(%w{uid cn dn uid userid sAMAccountName mail email userPrincipalName}) end.and_return({}) adapter.users('uid', 'johndoe') @@ -26,7 +26,7 @@ describe Gitlab::LDAP::Adapter, lib: true do expect(adapter).to receive(:ldap_search).with( base: 'uid=johndoe,ou=users,dc=example,dc=com', scope: Net::LDAP::SearchScope_BaseObject, - attributes: %w{uid cn mail dn}, + attributes: %w{uid cn dn uid userid sAMAccountName mail email userPrincipalName}, filter: nil ).and_return({}) @@ -63,7 +63,7 @@ describe Gitlab::LDAP::Adapter, lib: true do it 'uses the right uid attribute when non-default' do stub_ldap_config(uid: 'sAMAccountName') expect(adapter).to receive(:ldap_search).with( - hash_including(attributes: %w{sAMAccountName cn mail dn}) + hash_including(attributes: %w{sAMAccountName cn dn uid userid sAMAccountName mail email userPrincipalName}) ).and_return({}) adapter.users('sAMAccountName', 'johndoe') diff --git a/spec/lib/gitlab/ldap/auth_hash_spec.rb b/spec/lib/gitlab/ldap/auth_hash_spec.rb index 7a2f774b948..57a91193004 100644 --- a/spec/lib/gitlab/ldap/auth_hash_spec.rb +++ b/spec/lib/gitlab/ldap/auth_hash_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' -describe Gitlab::LDAP::AuthHash, lib: true do +describe Gitlab::LDAP::AuthHash do let(:auth_hash) do - Gitlab::LDAP::AuthHash.new( + described_class.new( OmniAuth::AuthHash.new( uid: '123456', provider: 'ldapmain', diff --git a/spec/lib/gitlab/ldap/authentication_spec.rb b/spec/lib/gitlab/ldap/authentication_spec.rb index f689b47fec4..01b6282af0c 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, lib: true do +describe Gitlab::LDAP::Authentication 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 cab2e9908ff..292ec064a67 100644 --- a/spec/lib/gitlab/ldap/config_spec.rb +++ b/spec/lib/gitlab/ldap/config_spec.rb @@ -1,13 +1,13 @@ require 'spec_helper' -describe Gitlab::LDAP::Config, lib: true do +describe Gitlab::LDAP::Config do include LdapHelpers - let(:config) { Gitlab::LDAP::Config.new('ldapmain') } + let(:config) { described_class.new('ldapmain') } - describe '#initalize' do + describe '#initialize' do it 'requires a provider' do - expect{ Gitlab::LDAP::Config.new }.to raise_error ArgumentError + expect{ described_class.new }.to raise_error ArgumentError end it 'works' do @@ -15,7 +15,7 @@ describe Gitlab::LDAP::Config, lib: true do end it 'raises an error if a unknown provider is used' do - expect{ Gitlab::LDAP::Config.new 'unknown' }.to raise_error(RuntimeError) + expect{ described_class.new 'unknown' }.to raise_error(RuntimeError) end end @@ -23,9 +23,9 @@ describe Gitlab::LDAP::Config, lib: true do it 'constructs basic options' do stub_ldap_config( options: { - 'host' => 'ldap.example.com', - 'port' => 386, - 'method' => 'plain' + 'host' => 'ldap.example.com', + 'port' => 386, + 'encryption' => 'plain' } ) @@ -39,24 +39,140 @@ describe Gitlab::LDAP::Config, lib: true do it 'includes authentication options when auth is configured' do stub_ldap_config( options: { - 'host' => 'ldap.example.com', - 'port' => 686, - 'method' => 'ssl', - 'bind_dn' => 'uid=admin,dc=example,dc=com', - 'password' => 'super_secret' + 'host' => 'ldap.example.com', + 'port' => 686, + 'encryption' => 'simple_tls', + 'verify_certificates' => true, + 'bind_dn' => 'uid=admin,dc=example,dc=com', + 'password' => 'super_secret' } ) - expect(config.adapter_options).to eq( - host: 'ldap.example.com', - port: 686, - encryption: :simple_tls, + expect(config.adapter_options).to include({ auth: { method: :simple, username: 'uid=admin,dc=example,dc=com', password: 'super_secret' } + }) + end + + it 'sets encryption method to simple_tls when configured as simple_tls' do + stub_ldap_config( + options: { + 'host' => 'ldap.example.com', + 'port' => 686, + 'encryption' => 'simple_tls' + } ) + + expect(config.adapter_options[:encryption]).to include({ method: :simple_tls }) + end + + it 'sets encryption method to start_tls when configured as start_tls' do + stub_ldap_config( + options: { + 'host' => 'ldap.example.com', + 'port' => 686, + 'encryption' => 'start_tls' + } + ) + + expect(config.adapter_options[:encryption]).to include({ method: :start_tls }) + end + + context 'when verify_certificates is enabled' do + it 'sets tls_options to OpenSSL defaults' do + stub_ldap_config( + options: { + 'host' => 'ldap.example.com', + 'port' => 686, + 'encryption' => 'simple_tls', + 'verify_certificates' => true + } + ) + + expect(config.adapter_options[:encryption]).to include({ tls_options: OpenSSL::SSL::SSLContext::DEFAULT_PARAMS }) + end + end + + context 'when verify_certificates is disabled' do + it 'sets verify_mode to OpenSSL VERIFY_NONE' do + stub_ldap_config( + options: { + 'host' => 'ldap.example.com', + 'port' => 686, + 'encryption' => 'simple_tls', + 'verify_certificates' => false + } + ) + + expect(config.adapter_options[:encryption]).to include({ + tls_options: { + verify_mode: OpenSSL::SSL::VERIFY_NONE + } + }) + end + end + + context 'when ca_file is specified' do + it 'passes it through in tls_options' do + stub_ldap_config( + options: { + 'host' => 'ldap.example.com', + 'port' => 686, + 'encryption' => 'simple_tls', + 'ca_file' => '/etc/ca.pem' + } + ) + + expect(config.adapter_options[:encryption][:tls_options]).to include({ ca_file: '/etc/ca.pem' }) + end + end + + context 'when ca_file is a blank string' do + it 'does not add the ca_file key to tls_options' do + stub_ldap_config( + options: { + 'host' => 'ldap.example.com', + 'port' => 686, + 'encryption' => 'simple_tls', + 'ca_file' => ' ' + } + ) + + expect(config.adapter_options[:encryption][:tls_options]).not_to have_key(:ca_file) + end + end + + context 'when ssl_version is specified' do + it 'passes it through in tls_options' do + stub_ldap_config( + options: { + 'host' => 'ldap.example.com', + 'port' => 686, + 'encryption' => 'simple_tls', + 'ssl_version' => 'TLSv1_2' + } + ) + + expect(config.adapter_options[:encryption][:tls_options]).to include({ ssl_version: 'TLSv1_2' }) + end + end + + context 'when ssl_version is a blank string' do + it 'does not add the ssl_version key to tls_options' do + stub_ldap_config( + options: { + 'host' => 'ldap.example.com', + 'port' => 686, + 'encryption' => 'simple_tls', + 'ssl_version' => ' ' + } + ) + + expect(config.adapter_options[:encryption][:tls_options]).not_to have_key(:ssl_version) + end end end @@ -64,11 +180,11 @@ describe Gitlab::LDAP::Config, lib: true do it 'constructs basic options' do stub_ldap_config( options: { - 'host' => 'ldap.example.com', - 'port' => 386, - 'base' => 'ou=users,dc=example,dc=com', - 'method' => 'plain', - 'uid' => 'uid' + 'host' => 'ldap.example.com', + 'port' => 386, + 'base' => 'ou=users,dc=example,dc=com', + 'encryption' => 'plain', + 'uid' => 'uid' } ) @@ -76,7 +192,7 @@ describe Gitlab::LDAP::Config, lib: true do host: 'ldap.example.com', port: 386, base: 'ou=users,dc=example,dc=com', - method: 'plain', + encryption: 'plain', filter: '(uid=%{username})' ) expect(config.omniauth_options.keys).not_to include(:bind_dn, :password) @@ -98,6 +214,100 @@ describe Gitlab::LDAP::Config, lib: true do password: 'super_secret' ) end + + context 'when verify_certificates is enabled' do + it 'specifies disable_verify_certificates as false' do + stub_ldap_config( + options: { + 'host' => 'ldap.example.com', + 'port' => 686, + 'encryption' => 'simple_tls', + 'verify_certificates' => true + } + ) + + expect(config.omniauth_options).to include({ disable_verify_certificates: false }) + end + end + + context 'when verify_certificates is disabled' do + it 'specifies disable_verify_certificates as true' do + stub_ldap_config( + options: { + 'host' => 'ldap.example.com', + 'port' => 686, + 'encryption' => 'simple_tls', + 'verify_certificates' => false + } + ) + + expect(config.omniauth_options).to include({ disable_verify_certificates: true }) + end + end + + context 'when ca_file is present' do + it 'passes it through' do + stub_ldap_config( + options: { + 'host' => 'ldap.example.com', + 'port' => 686, + 'encryption' => 'simple_tls', + 'verify_certificates' => true, + 'ca_file' => '/etc/ca.pem' + } + ) + + expect(config.omniauth_options).to include({ ca_file: '/etc/ca.pem' }) + end + end + + context 'when ca_file is blank' do + it 'does not include the ca_file option' do + stub_ldap_config( + options: { + 'host' => 'ldap.example.com', + 'port' => 686, + 'encryption' => 'simple_tls', + 'verify_certificates' => true, + 'ca_file' => ' ' + } + ) + + expect(config.omniauth_options).not_to have_key(:ca_file) + end + end + + context 'when ssl_version is present' do + it 'passes it through' do + stub_ldap_config( + options: { + 'host' => 'ldap.example.com', + 'port' => 686, + 'encryption' => 'simple_tls', + 'verify_certificates' => true, + 'ssl_version' => 'TLSv1_2' + } + ) + + expect(config.omniauth_options).to include({ ssl_version: 'TLSv1_2' }) + end + end + + context 'when ssl_version is blank' do + it 'does not include the ssl_version option' do + stub_ldap_config( + options: { + 'host' => 'ldap.example.com', + 'port' => 686, + 'encryption' => 'simple_tls', + 'verify_certificates' => true, + 'ssl_version' => ' ' + } + ) + + expect(config.omniauth_options).not_to have_key(:ssl_version) + end + end end describe '#has_auth?' do diff --git a/spec/lib/gitlab/ldap/user_spec.rb b/spec/lib/gitlab/ldap/user_spec.rb index b796d8bf076..175ceec44d7 100644 --- a/spec/lib/gitlab/ldap/user_spec.rb +++ b/spec/lib/gitlab/ldap/user_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' -describe Gitlab::LDAP::User, lib: true do - let(:ldap_user) { Gitlab::LDAP::User.new(auth_hash) } +describe Gitlab::LDAP::User do + let(:ldap_user) { described_class.new(auth_hash) } let(:gl_user) { ldap_user.gl_user } let(:info) do { @@ -13,7 +13,7 @@ describe Gitlab::LDAP::User, lib: true do let(:auth_hash) do OmniAuth::AuthHash.new(uid: 'my-uid', provider: 'ldapmain', info: info) end - let(:ldap_user_upper_case) { Gitlab::LDAP::User.new(auth_hash_upper_case) } + let(:ldap_user_upper_case) { described_class.new(auth_hash_upper_case) } let(:info_upper_case) do { name: 'John', diff --git a/spec/lib/gitlab/lfs_token_spec.rb b/spec/lib/gitlab/lfs_token_spec.rb index e9c1163e22a..3a20dad16d0 100644 --- a/spec/lib/gitlab/lfs_token_spec.rb +++ b/spec/lib/gitlab/lfs_token_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::LfsToken, lib: true do +describe Gitlab::LfsToken do describe '#token' do shared_examples 'an LFS token generator' do it 'returns a randomly generated token' do diff --git a/spec/lib/gitlab/markup_helper_spec.rb b/spec/lib/gitlab/markup_helper_spec.rb index 93b91b849f2..09e518ff989 100644 --- a/spec/lib/gitlab/markup_helper_spec.rb +++ b/spec/lib/gitlab/markup_helper_spec.rb @@ -1,40 +1,40 @@ require 'spec_helper' -describe Gitlab::MarkupHelper, lib: true do +describe Gitlab::MarkupHelper do describe '#markup?' do %w(textile rdoc org creole wiki mediawiki rst adoc ad asciidoc mdown md markdown).each do |type| it "returns true for #{type} files" do - expect(Gitlab::MarkupHelper.markup?("README.#{type}")).to be_truthy + expect(described_class.markup?("README.#{type}")).to be_truthy end end it 'returns false when given a non-markup filename' do - expect(Gitlab::MarkupHelper.markup?('README.rb')).not_to be_truthy + expect(described_class.markup?('README.rb')).not_to be_truthy end end describe '#gitlab_markdown?' do %w(mdown mkd mkdn md markdown).each do |type| it "returns true for #{type} files" do - expect(Gitlab::MarkupHelper.gitlab_markdown?("README.#{type}")).to be_truthy + expect(described_class.gitlab_markdown?("README.#{type}")).to be_truthy end end it 'returns false when given a non-markdown filename' do - expect(Gitlab::MarkupHelper.gitlab_markdown?('README.rb')).not_to be_truthy + expect(described_class.gitlab_markdown?('README.rb')).not_to be_truthy end end describe '#asciidoc?' do %w(adoc ad asciidoc ADOC).each do |type| it "returns true for #{type} files" do - expect(Gitlab::MarkupHelper.asciidoc?("README.#{type}")).to be_truthy + expect(described_class.asciidoc?("README.#{type}")).to be_truthy end end it 'returns false when given a non-asciidoc filename' do - expect(Gitlab::MarkupHelper.asciidoc?('README.rb')).not_to be_truthy + expect(described_class.asciidoc?('README.rb')).not_to be_truthy end end end diff --git a/spec/lib/gitlab/middleware/go_spec.rb b/spec/lib/gitlab/middleware/go_spec.rb index c2ab015d5cb..6af1564da19 100644 --- a/spec/lib/gitlab/middleware/go_spec.rb +++ b/spec/lib/gitlab/middleware/go_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::Middleware::Go, lib: true do +describe Gitlab::Middleware::Go do let(:app) { double(:app) } let(:middleware) { described_class.new(app) } diff --git a/spec/lib/gitlab/o_auth/auth_hash_spec.rb b/spec/lib/gitlab/o_auth/auth_hash_spec.rb index 19ab17419fc..d5f4da3ce36 100644 --- a/spec/lib/gitlab/o_auth/auth_hash_spec.rb +++ b/spec/lib/gitlab/o_auth/auth_hash_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' -describe Gitlab::OAuth::AuthHash, lib: true do +describe Gitlab::OAuth::AuthHash do let(:auth_hash) do - Gitlab::OAuth::AuthHash.new( + described_class.new( OmniAuth::AuthHash.new( provider: provider_ascii, uid: uid_ascii, diff --git a/spec/lib/gitlab/o_auth/provider_spec.rb b/spec/lib/gitlab/o_auth/provider_spec.rb index 1e2a1f8c039..30faf107e3f 100644 --- a/spec/lib/gitlab/o_auth/provider_spec.rb +++ b/spec/lib/gitlab/o_auth/provider_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::OAuth::Provider, lib: true do +describe Gitlab::OAuth::Provider do describe '#config_for' do context 'for an LDAP provider' do context 'when the provider exists' do diff --git a/spec/lib/gitlab/o_auth/user_spec.rb b/spec/lib/gitlab/o_auth/user_spec.rb index ea29cb9caf1..47aa19d5fd9 100644 --- a/spec/lib/gitlab/o_auth/user_spec.rb +++ b/spec/lib/gitlab/o_auth/user_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' -describe Gitlab::OAuth::User, lib: true do - let(:oauth_user) { Gitlab::OAuth::User.new(auth_hash) } +describe Gitlab::OAuth::User do + let(:oauth_user) { described_class.new(auth_hash) } let(:gl_user) { oauth_user.gl_user } let(:uid) { 'my-uid' } let(:provider) { 'my-provider' } diff --git a/spec/lib/gitlab/optimistic_locking_spec.rb b/spec/lib/gitlab/optimistic_locking_spec.rb index acce2be93f2..81f81d4f963 100644 --- a/spec/lib/gitlab/optimistic_locking_spec.rb +++ b/spec/lib/gitlab/optimistic_locking_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::OptimisticLocking, lib: true do +describe Gitlab::OptimisticLocking do let!(:pipeline) { create(:ci_pipeline) } let!(:pipeline2) { Ci::Pipeline.find(pipeline.id) } diff --git a/spec/lib/gitlab/other_markup_spec.rb b/spec/lib/gitlab/other_markup_spec.rb index c0f5fa9dc1f..e26f39e193e 100644 --- a/spec/lib/gitlab/other_markup_spec.rb +++ b/spec/lib/gitlab/other_markup_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::OtherMarkup, lib: true do +describe Gitlab::OtherMarkup do let(:context) { {} } context "XSS Checks" do diff --git a/spec/lib/gitlab/path_regex_spec.rb b/spec/lib/gitlab/path_regex_spec.rb index 20be743d224..2f989397f7e 100644 --- a/spec/lib/gitlab/path_regex_spec.rb +++ b/spec/lib/gitlab/path_regex_spec.rb @@ -1,7 +1,7 @@ # coding: utf-8 require 'spec_helper' -describe Gitlab::PathRegex, lib: true do +describe Gitlab::PathRegex do # Pass in a full path to remove the format segment: # `/ci/lint(.:format)` -> `/ci/lint` def without_format(path) diff --git a/spec/lib/gitlab/polling_interval_spec.rb b/spec/lib/gitlab/polling_interval_spec.rb index 5ea8ecb1c30..eb8e618156b 100644 --- a/spec/lib/gitlab/polling_interval_spec.rb +++ b/spec/lib/gitlab/polling_interval_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::PollingInterval, lib: true do +describe Gitlab::PollingInterval do let(:polling_interval) { described_class } describe '.set_header' do diff --git a/spec/lib/gitlab/popen_spec.rb b/spec/lib/gitlab/popen_spec.rb index af50ecdb2ab..4567f220c11 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', lib: true, no_db: true do +describe 'Gitlab::Popen' 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 3d22784909d..d17b436b910 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, lib: true do +describe Gitlab::ProjectSearchResults do let(:user) { create(:user) } let(:project) { create(:empty_project) } let(:query) { 'hello world' } diff --git a/spec/lib/gitlab/project_transfer_spec.rb b/spec/lib/gitlab/project_transfer_spec.rb index e2d6b1b9ab7..10c5fb148cd 100644 --- a/spec/lib/gitlab/project_transfer_spec.rb +++ b/spec/lib/gitlab/project_transfer_spec.rb @@ -1,9 +1,9 @@ require 'spec_helper' -describe Gitlab::ProjectTransfer, lib: true do +describe Gitlab::ProjectTransfer do before do @root_dir = File.join(Rails.root, "public", "uploads") - @project_transfer = Gitlab::ProjectTransfer.new + @project_transfer = described_class.new allow(@project_transfer).to receive(:root_dir).and_return(@root_dir) @project_path_was = "test_project_was" diff --git a/spec/lib/gitlab/prometheus/additional_metrics_parser_spec.rb b/spec/lib/gitlab/prometheus/additional_metrics_parser_spec.rb index 61d48b05454..d7df4e35c31 100644 --- a/spec/lib/gitlab/prometheus/additional_metrics_parser_spec.rb +++ b/spec/lib/gitlab/prometheus/additional_metrics_parser_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::Prometheus::AdditionalMetricsParser, lib: true do +describe Gitlab::Prometheus::AdditionalMetricsParser do include Prometheus::MetricBuilders let(:parser_error_class) { Gitlab::Prometheus::ParsingError } diff --git a/spec/lib/gitlab/prometheus/queries/additional_metrics_deployment_query_spec.rb b/spec/lib/gitlab/prometheus/queries/additional_metrics_deployment_query_spec.rb index 4909aec5a4d..e42e034f4fb 100644 --- a/spec/lib/gitlab/prometheus/queries/additional_metrics_deployment_query_spec.rb +++ b/spec/lib/gitlab/prometheus/queries/additional_metrics_deployment_query_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::Prometheus::Queries::AdditionalMetricsDeploymentQuery, lib: true do +describe Gitlab::Prometheus::Queries::AdditionalMetricsDeploymentQuery do include Prometheus::MetricBuilders let(:client) { double('prometheus_client') } diff --git a/spec/lib/gitlab/prometheus/queries/additional_metrics_environment_query_spec.rb b/spec/lib/gitlab/prometheus/queries/additional_metrics_environment_query_spec.rb index 8e6e3bb5946..e9fd66d45fe 100644 --- a/spec/lib/gitlab/prometheus/queries/additional_metrics_environment_query_spec.rb +++ b/spec/lib/gitlab/prometheus/queries/additional_metrics_environment_query_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::Prometheus::Queries::AdditionalMetricsEnvironmentQuery, lib: true do +describe Gitlab::Prometheus::Queries::AdditionalMetricsEnvironmentQuery do include Prometheus::MetricBuilders let(:client) { double('prometheus_client') } diff --git a/spec/lib/gitlab/prometheus/queries/deployment_query_spec.rb b/spec/lib/gitlab/prometheus/queries/deployment_query_spec.rb index d957dd932c4..ffe3ad85baa 100644 --- a/spec/lib/gitlab/prometheus/queries/deployment_query_spec.rb +++ b/spec/lib/gitlab/prometheus/queries/deployment_query_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::Prometheus::Queries::DeploymentQuery, lib: true do +describe Gitlab::Prometheus::Queries::DeploymentQuery do let(:environment) { create(:environment, slug: 'environment-slug') } let(:deployment) { create(:deployment, environment: environment) } diff --git a/spec/lib/gitlab/prometheus/queries/matched_metrics_query_spec.rb b/spec/lib/gitlab/prometheus/queries/matched_metrics_query_spec.rb index d2796ab72da..2b488101496 100644 --- a/spec/lib/gitlab/prometheus/queries/matched_metrics_query_spec.rb +++ b/spec/lib/gitlab/prometheus/queries/matched_metrics_query_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::Prometheus::Queries::MatchedMetricsQuery, lib: true do +describe Gitlab::Prometheus::Queries::MatchedMetricsQuery do include Prometheus::MetricBuilders let(:metric_group_class) { Gitlab::Prometheus::MetricGroup } diff --git a/spec/lib/gitlab/prometheus_client_spec.rb b/spec/lib/gitlab/prometheus_client_spec.rb index 46eaadae206..de625324092 100644 --- a/spec/lib/gitlab/prometheus_client_spec.rb +++ b/spec/lib/gitlab/prometheus_client_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::PrometheusClient, lib: true do +describe Gitlab::PrometheusClient do include PrometheusHelpers subject { described_class.new(api_url: 'https://prometheus.example.com') } diff --git a/spec/lib/gitlab/reference_extractor_spec.rb b/spec/lib/gitlab/reference_extractor_spec.rb index 917692e9c6c..1a0357534f2 100644 --- a/spec/lib/gitlab/reference_extractor_spec.rb +++ b/spec/lib/gitlab/reference_extractor_spec.rb @@ -1,13 +1,13 @@ require 'spec_helper' -describe Gitlab::ReferenceExtractor, lib: true do +describe Gitlab::ReferenceExtractor do let(:project) { create(:empty_project) } before do project.team << [project.creator, :developer] end - subject { Gitlab::ReferenceExtractor.new(project, project.creator) } + subject { described_class.new(project, project.creator) } it 'accesses valid user objects' do @u_foo = create(:user, username: 'foo') diff --git a/spec/lib/gitlab/regex_spec.rb b/spec/lib/gitlab/regex_spec.rb index 251f82849bf..68a57826647 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, lib: true do +describe Gitlab::Regex do describe '.project_name_regex' do subject { described_class.project_name_regex } diff --git a/spec/lib/gitlab/request_context_spec.rb b/spec/lib/gitlab/request_context_spec.rb index a91c8655cdd..e272bdb9284 100644 --- a/spec/lib/gitlab/request_context_spec.rb +++ b/spec/lib/gitlab/request_context_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' -describe Gitlab::RequestContext, lib: true do +describe Gitlab::RequestContext do describe '#client_ip' do - subject { Gitlab::RequestContext.client_ip } + subject { described_class.client_ip } let(:app) { -> (env) {} } let(:env) { Hash.new } @@ -16,7 +16,7 @@ describe Gitlab::RequestContext, lib: true do before do allow_any_instance_of(Rack::Request).to receive(:ip).and_return(ip) - Gitlab::RequestContext.new(app).call(env) + described_class.new(app).call(env) end it { is_expected.to eq(ip) } diff --git a/spec/lib/gitlab/request_forgery_protection_spec.rb b/spec/lib/gitlab/request_forgery_protection_spec.rb new file mode 100644 index 00000000000..305de613866 --- /dev/null +++ b/spec/lib/gitlab/request_forgery_protection_spec.rb @@ -0,0 +1,89 @@ +require 'spec_helper' + +describe Gitlab::RequestForgeryProtection, :allow_forgery_protection do + let(:csrf_token) { SecureRandom.base64(ActionController::RequestForgeryProtection::AUTHENTICITY_TOKEN_LENGTH) } + let(:env) do + { + 'rack.input' => '', + 'rack.session' => { + _csrf_token: csrf_token + } + } + end + + describe '.call' do + context 'when the request method is GET' do + before do + env['REQUEST_METHOD'] = 'GET' + end + + it 'does not raise an exception' do + expect { described_class.call(env) }.not_to raise_exception + end + end + + context 'when the request method is POST' do + before do + env['REQUEST_METHOD'] = 'POST' + end + + context 'when the CSRF token is valid' do + before do + env['HTTP_X_CSRF_TOKEN'] = csrf_token + end + + it 'does not raise an exception' do + expect { described_class.call(env) }.not_to raise_exception + end + end + + context 'when the CSRF token is invalid' do + before do + env['HTTP_X_CSRF_TOKEN'] = 'foo' + end + + it 'raises an ActionController::InvalidAuthenticityToken exception' do + expect { described_class.call(env) }.to raise_exception(ActionController::InvalidAuthenticityToken) + end + end + end + end + + describe '.verified?' do + context 'when the request method is GET' do + before do + env['REQUEST_METHOD'] = 'GET' + end + + it 'returns true' do + expect(described_class.verified?(env)).to be_truthy + end + end + + context 'when the request method is POST' do + before do + env['REQUEST_METHOD'] = 'POST' + end + + context 'when the CSRF token is valid' do + before do + env['HTTP_X_CSRF_TOKEN'] = csrf_token + end + + it 'returns true' do + expect(described_class.verified?(env)).to be_truthy + end + end + + context 'when the CSRF token is invalid' do + before do + env['HTTP_X_CSRF_TOKEN'] = 'foo' + end + + it 'returns false' do + expect(described_class.verified?(env)).to be_falsey + end + end + end + end +end diff --git a/spec/lib/gitlab/request_profiler_spec.rb b/spec/lib/gitlab/request_profiler_spec.rb index ae9c06ebb7d..fd8cbf39bce 100644 --- a/spec/lib/gitlab/request_profiler_spec.rb +++ b/spec/lib/gitlab/request_profiler_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::RequestProfiler, lib: true do +describe Gitlab::RequestProfiler do describe '.profile_token' do it 'returns a token' do expect(described_class.profile_token).to be_present diff --git a/spec/lib/gitlab/route_map_spec.rb b/spec/lib/gitlab/route_map_spec.rb index e8feb21e4d7..d672f7b5675 100644 --- a/spec/lib/gitlab/route_map_spec.rb +++ b/spec/lib/gitlab/route_map_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::RouteMap, lib: true do +describe Gitlab::RouteMap do describe '#initialize' do context 'when the data is not YAML' do it 'raises an error' do diff --git a/spec/lib/gitlab/saml/user_spec.rb b/spec/lib/gitlab/saml/user_spec.rb index a4d2367b72a..2827a18515e 100644 --- a/spec/lib/gitlab/saml/user_spec.rb +++ b/spec/lib/gitlab/saml/user_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::Saml::User, lib: true do +describe Gitlab::Saml::User do let(:saml_user) { described_class.new(auth_hash) } let(:gl_user) { saml_user.gl_user } let(:uid) { 'my-uid' } diff --git a/spec/lib/gitlab/shell_spec.rb b/spec/lib/gitlab/shell_spec.rb index 5b1b8f9516a..b90d8dede0f 100644 --- a/spec/lib/gitlab/shell_spec.rb +++ b/spec/lib/gitlab/shell_spec.rb @@ -1,9 +1,9 @@ require 'spec_helper' require 'stringio' -describe Gitlab::Shell, lib: true do +describe Gitlab::Shell do let(:project) { double('Project', id: 7, path: 'diaspora') } - let(:gitlab_shell) { Gitlab::Shell.new } + let(:gitlab_shell) { described_class.new } let(:popen_vars) { { 'GIT_TERMINAL_PROMPT' => ENV['GIT_TERMINAL_PROMPT'] } } before do @@ -30,7 +30,7 @@ describe Gitlab::Shell, lib: true do allow(Gitlab.config.gitlab_shell).to receive(:secret_file).and_return(secret_file) allow(Gitlab.config.gitlab_shell).to receive(:path).and_return('tmp/tests/shell-secret-test') FileUtils.mkdir('tmp/tests/shell-secret-test') - Gitlab::Shell.ensure_secret_token! + described_class.ensure_secret_token! end after do @@ -39,7 +39,7 @@ describe Gitlab::Shell, lib: true do end it 'creates and links the secret token file' do - secret_token = Gitlab::Shell.secret_token + secret_token = described_class.secret_token expect(File.exist?(secret_file)).to be(true) expect(File.read(secret_file).chomp).to eq(secret_token) @@ -59,7 +59,7 @@ describe Gitlab::Shell, lib: true do end end - describe Gitlab::Shell::KeyAdder, lib: true do + describe Gitlab::Shell::KeyAdder do describe '#add_key' do it 'removes trailing garbage' do io = spy(:io) diff --git a/spec/lib/gitlab/sherlock/collection_spec.rb b/spec/lib/gitlab/sherlock/collection_spec.rb index 2ae79b50e77..873ed14f804 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, lib: true do +describe Gitlab::Sherlock::Collection 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 4989d14def3..394421504e0 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, lib: true do +describe Gitlab::Sherlock::FileSample 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 39c6b2a4844..f2f8040fa0b 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, lib: true do +describe Gitlab::Sherlock::LineProfiler 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 f9b61f8684e..5f02f6a3213 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, lib: true do +describe Gitlab::Sherlock::LineSample 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 5739afa6b1e..b295a624b35 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, lib: true do +describe Gitlab::Sherlock::Location 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 b98ab0b14a2..2016023df06 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, lib: true do +describe Gitlab::Sherlock::Middleware 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 d97b5eef573..426071c7f92 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, lib: true do +describe Gitlab::Sherlock::Query 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 6ae1aa20ea7..4a14dfbec56 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, lib: true do +describe Gitlab::Sherlock::Transaction do let(:transaction) { described_class.new('POST', '/cat_pictures') } describe '#id' do diff --git a/spec/lib/gitlab/slash_commands/command_spec.rb b/spec/lib/gitlab/slash_commands/command_spec.rb index 28d7f9858c3..f0ecf59406a 100644 --- a/spec/lib/gitlab/slash_commands/command_spec.rb +++ b/spec/lib/gitlab/slash_commands/command_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::SlashCommands::Command, service: true do +describe Gitlab::SlashCommands::Command do let(:project) { create(:empty_project) } let(:user) { create(:user) } diff --git a/spec/lib/gitlab/slash_commands/deploy_spec.rb b/spec/lib/gitlab/slash_commands/deploy_spec.rb index d919f7260db..e52aaed7328 100644 --- a/spec/lib/gitlab/slash_commands/deploy_spec.rb +++ b/spec/lib/gitlab/slash_commands/deploy_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::SlashCommands::Deploy, service: true do +describe Gitlab::SlashCommands::Deploy do describe '#execute' do let(:project) { create(:empty_project) } let(:user) { create(:user) } diff --git a/spec/lib/gitlab/slash_commands/issue_new_spec.rb b/spec/lib/gitlab/slash_commands/issue_new_spec.rb index 4de50d4a8bb..5dfb1b506bc 100644 --- a/spec/lib/gitlab/slash_commands/issue_new_spec.rb +++ b/spec/lib/gitlab/slash_commands/issue_new_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::SlashCommands::IssueNew, service: true do +describe Gitlab::SlashCommands::IssueNew do describe '#execute' do let(:project) { create(:empty_project) } let(:user) { create(:user) } diff --git a/spec/lib/gitlab/slash_commands/issue_search_spec.rb b/spec/lib/gitlab/slash_commands/issue_search_spec.rb index 06fff0afc50..e5409fe2339 100644 --- a/spec/lib/gitlab/slash_commands/issue_search_spec.rb +++ b/spec/lib/gitlab/slash_commands/issue_search_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::SlashCommands::IssueSearch, service: true do +describe Gitlab::SlashCommands::IssueSearch do describe '#execute' do let!(:issue) { create(:issue, project: project, title: 'find me') } let!(:confidential) { create(:issue, :confidential, project: project, title: 'mepmep find') } diff --git a/spec/lib/gitlab/slash_commands/issue_show_spec.rb b/spec/lib/gitlab/slash_commands/issue_show_spec.rb index 1899f664ccd..f67a17c7922 100644 --- a/spec/lib/gitlab/slash_commands/issue_show_spec.rb +++ b/spec/lib/gitlab/slash_commands/issue_show_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::SlashCommands::IssueShow, service: true do +describe Gitlab::SlashCommands::IssueShow do describe '#execute' do let(:issue) { create(:issue, project: project) } let(:project) { create(:empty_project) } diff --git a/spec/lib/gitlab/sql/glob_spec.rb b/spec/lib/gitlab/sql/glob_spec.rb index 451c583310d..f0bb4294d62 100644 --- a/spec/lib/gitlab/sql/glob_spec.rb +++ b/spec/lib/gitlab/sql/glob_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::SQL::Glob, lib: true do +describe Gitlab::SQL::Glob do describe '.to_like' do it 'matches * as %' do expect(glob('apple', '*')).to be(true) diff --git a/spec/lib/gitlab/sql/union_spec.rb b/spec/lib/gitlab/sql/union_spec.rb index 849edb09476..5346881444d 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, lib: true do +describe Gitlab::SQL::Union do let(:relation_1) { User.where(email: 'alice@example.com').select(:id) } let(:relation_2) { User.where(email: 'bob@example.com').select(:id) } diff --git a/spec/lib/gitlab/string_range_marker_spec.rb b/spec/lib/gitlab/string_range_marker_spec.rb index 7c77772b3f6..abeaa7f0ddb 100644 --- a/spec/lib/gitlab/string_range_marker_spec.rb +++ b/spec/lib/gitlab/string_range_marker_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::StringRangeMarker, lib: true do +describe Gitlab::StringRangeMarker do describe '#mark' do context "when the rich text is html safe" do let(:raw) { "abc <def>" } diff --git a/spec/lib/gitlab/string_regex_marker_spec.rb b/spec/lib/gitlab/string_regex_marker_spec.rb index 2f5cf6c6e3b..d715f9bd641 100644 --- a/spec/lib/gitlab/string_regex_marker_spec.rb +++ b/spec/lib/gitlab/string_regex_marker_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::StringRegexMarker, lib: true do +describe Gitlab::StringRegexMarker do describe '#mark' do let(:raw) { %{"name": "AFNetworking"} } let(:rich) { %{<span class="key">"name"</span><span class="punctuation">: </span><span class="value">"AFNetworking"</span>}.html_safe } diff --git a/spec/lib/gitlab/upgrader_spec.rb b/spec/lib/gitlab/upgrader_spec.rb index fcfd8d58b70..6106f13c774 100644 --- a/spec/lib/gitlab/upgrader_spec.rb +++ b/spec/lib/gitlab/upgrader_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' -describe Gitlab::Upgrader, lib: true do - let(:upgrader) { Gitlab::Upgrader.new } +describe Gitlab::Upgrader do + let(:upgrader) { described_class.new } let(:current_version) { Gitlab::VERSION } describe 'current_version_raw' do diff --git a/spec/lib/gitlab/url_blocker_spec.rb b/spec/lib/gitlab/url_blocker_spec.rb index a504d299307..f5b4882815f 100644 --- a/spec/lib/gitlab/url_blocker_spec.rb +++ b/spec/lib/gitlab/url_blocker_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::UrlBlocker, lib: true do +describe Gitlab::UrlBlocker do describe '#blocked_url?' do it 'allows imports from configured web host and port' do import_url = "http://#{Gitlab.config.gitlab.host}:#{Gitlab.config.gitlab.port}/t.git" diff --git a/spec/lib/gitlab/url_builder_spec.rb b/spec/lib/gitlab/url_builder_spec.rb index e9a6e273516..50422020823 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, lib: true do +describe Gitlab::UrlBuilder do describe '.build' do context 'when passing a Commit' do it 'returns a proper URL' do diff --git a/spec/lib/gitlab/url_sanitizer_spec.rb b/spec/lib/gitlab/url_sanitizer_spec.rb index 6bce724a3f6..308b1a128be 100644 --- a/spec/lib/gitlab/url_sanitizer_spec.rb +++ b/spec/lib/gitlab/url_sanitizer_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::UrlSanitizer, lib: true do +describe Gitlab::UrlSanitizer do let(:credentials) { { user: 'blah', password: 'password' } } let(:url_sanitizer) do described_class.new("https://github.com/me/project.git", credentials: credentials) diff --git a/spec/lib/gitlab/user_access_spec.rb b/spec/lib/gitlab/user_access_spec.rb index 0d87cf25dbb..5ebaf6c1507 100644 --- a/spec/lib/gitlab/user_access_spec.rb +++ b/spec/lib/gitlab/user_access_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' -describe Gitlab::UserAccess, lib: true do - let(:access) { Gitlab::UserAccess.new(user, project: project) } +describe Gitlab::UserAccess do + let(:access) { described_class.new(user, project: project) } let(:project) { create(:project) } let(:user) { create(:user) } @@ -28,7 +28,7 @@ describe Gitlab::UserAccess, lib: true do describe 'push to empty project' do let(:empty_project) { create(:project_empty_repo) } - let(:project_access) { Gitlab::UserAccess.new(user, project: empty_project) } + let(:project_access) { described_class.new(user, project: empty_project) } it 'returns true if user is master' do empty_project.team << [user, :master] diff --git a/spec/lib/gitlab/user_activities_spec.rb b/spec/lib/gitlab/user_activities_spec.rb index a4ea0ac59e9..6bce2ee13cf 100644 --- a/spec/lib/gitlab/user_activities_spec.rb +++ b/spec/lib/gitlab/user_activities_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::UserActivities, :clean_gitlab_redis_shared_state, lib: true do +describe Gitlab::UserActivities, :clean_gitlab_redis_shared_state do let(:now) { Time.now } describe '.record' do diff --git a/spec/lib/gitlab/utils_spec.rb b/spec/lib/gitlab/utils_spec.rb index 00941aec380..111c873f79c 100644 --- a/spec/lib/gitlab/utils_spec.rb +++ b/spec/lib/gitlab/utils_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::Utils, lib: true do +describe Gitlab::Utils do delegate :to_boolean, :boolean_to_yes_no, to: :described_class describe '.to_boolean' do diff --git a/spec/lib/gitlab/version_info_spec.rb b/spec/lib/gitlab/version_info_spec.rb index 706ee9bec58..e7e1a92ae54 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', lib: true, no_db: true do +describe 'Gitlab::VersionInfo' do before do @unknown = Gitlab::VersionInfo.new @v0_0_1 = Gitlab::VersionInfo.new(0, 0, 1) diff --git a/spec/lib/gitlab/visibility_level_spec.rb b/spec/lib/gitlab/visibility_level_spec.rb index db9d2807be6..48a67773de9 100644 --- a/spec/lib/gitlab/visibility_level_spec.rb +++ b/spec/lib/gitlab/visibility_level_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::VisibilityLevel, lib: true do +describe Gitlab::VisibilityLevel do describe '.level_value' do it 'converts "public" to integer value' do expect(described_class.level_value('public')).to eq(Gitlab::VisibilityLevel::PUBLIC) diff --git a/spec/lib/gitlab/workhorse_spec.rb b/spec/lib/gitlab/workhorse_spec.rb index 6ca1edb01b9..654397ccffb 100644 --- a/spec/lib/gitlab/workhorse_spec.rb +++ b/spec/lib/gitlab/workhorse_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::Workhorse, lib: true do +describe Gitlab::Workhorse do let(:project) { create(:project, :repository) } let(:repository) { project.repository } @@ -63,13 +63,13 @@ describe Gitlab::Workhorse, lib: true do end context 'without ca_pem' do - subject { Gitlab::Workhorse.terminal_websocket(terminal) } + subject { described_class.terminal_websocket(terminal) } it { is_expected.to eq(workhorse) } end context 'with ca_pem' do - subject { Gitlab::Workhorse.terminal_websocket(terminal(ca_pem: "foo")) } + subject { described_class.terminal_websocket(terminal(ca_pem: "foo")) } it { is_expected.to eq(workhorse(ca_pem: "foo")) } end diff --git a/spec/lib/gitlab_spec.rb b/spec/lib/gitlab_spec.rb index c4c107c9eea..f97136f0191 100644 --- a/spec/lib/gitlab_spec.rb +++ b/spec/lib/gitlab_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe Gitlab, lib: true do +describe Gitlab do describe '.com?' do it 'is true when on GitLab.com' do stub_config_setting(url: 'https://gitlab.com') diff --git a/spec/lib/repository_cache_spec.rb b/spec/lib/repository_cache_spec.rb index 5892f3481a4..0c15ba22bf2 100644 --- a/spec/lib/repository_cache_spec.rb +++ b/spec/lib/repository_cache_spec.rb @@ -1,9 +1,9 @@ require 'spec_helper' -describe RepositoryCache, lib: true do +describe RepositoryCache do let(:project) { create(:empty_project) } let(:backend) { double('backend').as_null_object } - let(:cache) { RepositoryCache.new('example', project.id, backend) } + let(:cache) { described_class.new('example', project.id, backend) } describe '#cache_key' do it 'includes the namespace' do diff --git a/spec/lib/system_check/simple_executor_spec.rb b/spec/lib/system_check/simple_executor_spec.rb index 795f11ee1f8..025ea2673b4 100644 --- a/spec/lib/system_check/simple_executor_spec.rb +++ b/spec/lib/system_check/simple_executor_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'rake_helper' -describe SystemCheck::SimpleExecutor, lib: true do +describe SystemCheck::SimpleExecutor do class SimpleCheck < SystemCheck::BaseCheck set_name 'my simple check' diff --git a/spec/lib/system_check_spec.rb b/spec/lib/system_check_spec.rb index 23d9beddb08..4d9e17fa6ec 100644 --- a/spec/lib/system_check_spec.rb +++ b/spec/lib/system_check_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'rake_helper' -describe SystemCheck, lib: true do +describe SystemCheck do class SimpleCheck < SystemCheck::BaseCheck def check? true @@ -19,7 +19,7 @@ describe SystemCheck, lib: true do end describe '.run' do - subject { SystemCheck } + subject { described_class } it 'detects execution of SimpleCheck' do is_expected.to execute_check(SimpleCheck) diff --git a/spec/mailers/emails/profile_spec.rb b/spec/mailers/emails/profile_spec.rb index 8c1c9bf135f..09e5094cf84 100644 --- a/spec/mailers/emails/profile_spec.rb +++ b/spec/mailers/emails/profile_spec.rb @@ -91,6 +91,36 @@ describe Emails::Profile do end end + describe 'user added gpg key' do + let(:gpg_key) { create(:gpg_key) } + + subject { Notify.new_gpg_key_email(gpg_key.id) } + + it_behaves_like 'an email sent from GitLab' + it_behaves_like 'it should not have Gmail Actions links' + it_behaves_like 'a user cannot unsubscribe through footer link' + + it 'is sent to the new user' do + is_expected.to deliver_to gpg_key.user.email + end + + it 'has the correct subject' do + is_expected.to have_subject /^GPG key was added to your account$/i + end + + it 'contains the new gpg key title' do + is_expected.to have_body_text /#{gpg_key.fingerprint}/ + end + + it 'includes a link to gpg keys page' do + is_expected.to have_body_text /#{profile_gpg_keys_path}/ + end + + context 'with GPG key that does not exist' do + it { expect { Notify.new_gpg_key_email('foo') }.not_to raise_error } + end + end + describe 'user added email' do let(:email) { create(:email) } diff --git a/spec/models/ability_spec.rb b/spec/models/ability_spec.rb index 58f1a620ab4..aa019288700 100644 --- a/spec/models/ability_spec.rb +++ b/spec/models/ability_spec.rb @@ -1,9 +1,9 @@ require 'spec_helper' -describe Ability, lib: true do +describe Ability do context 'using a nil subject' do it 'has no permissions' do - expect(Ability.policy_for(nil, nil)).to be_banned + expect(described_class.policy_for(nil, nil)).to be_banned end end diff --git a/spec/models/abuse_report_spec.rb b/spec/models/abuse_report_spec.rb index c1bf5551fe0..d4da30b1641 100644 --- a/spec/models/abuse_report_spec.rb +++ b/spec/models/abuse_report_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe AbuseReport, type: :model do +RSpec.describe AbuseReport do subject { create(:abuse_report) } let(:user) { create(:admin) } diff --git a/spec/models/appearance_spec.rb b/spec/models/appearance_spec.rb index 1060bf3cbf4..7cd3a84d592 100644 --- a/spec/models/appearance_spec.rb +++ b/spec/models/appearance_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe Appearance, type: :model do +RSpec.describe Appearance do subject { build(:appearance) } it { is_expected.to be_valid } diff --git a/spec/models/application_setting_spec.rb b/spec/models/application_setting_spec.rb index e600eab6565..359753b600e 100644 --- a/spec/models/application_setting_spec.rb +++ b/spec/models/application_setting_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' -describe ApplicationSetting, models: true do - let(:setting) { ApplicationSetting.create_from_defaults } +describe ApplicationSetting do + let(:setting) { described_class.create_from_defaults } it { expect(setting).to be_valid } it { expect(setting.uuid).to be_present } @@ -159,10 +159,10 @@ describe ApplicationSetting, models: true do context 'redis unavailable' do it 'returns an ApplicationSetting' do allow(Rails.cache).to receive(:fetch).and_call_original - allow(ApplicationSetting).to receive(:last).and_return(:last) + allow(described_class).to receive(:last).and_return(:last) expect(Rails.cache).to receive(:fetch).with(ApplicationSetting::CACHE_KEY).and_raise(ArgumentError) - expect(ApplicationSetting.current).to eq(:last) + expect(described_class.current).to eq(:last) end end end diff --git a/spec/models/award_emoji_spec.rb b/spec/models/award_emoji_spec.rb index 2a9a27752c1..87e60d9c16b 100644 --- a/spec/models/award_emoji_spec.rb +++ b/spec/models/award_emoji_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe AwardEmoji, models: true do +describe AwardEmoji do describe 'Associations' do it { is_expected.to belong_to(:awardable) } it { is_expected.to belong_to(:user) } diff --git a/spec/models/blob_viewer/base_spec.rb b/spec/models/blob_viewer/base_spec.rb index 574438838d8..e3640097dff 100644 --- a/spec/models/blob_viewer/base_spec.rb +++ b/spec/models/blob_viewer/base_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe BlobViewer::Base, model: true do +describe BlobViewer::Base do include FakeBlobHelpers let(:project) { build(:empty_project) } diff --git a/spec/models/blob_viewer/changelog_spec.rb b/spec/models/blob_viewer/changelog_spec.rb index 9066c5a05ac..db41eca0fc8 100644 --- a/spec/models/blob_viewer/changelog_spec.rb +++ b/spec/models/blob_viewer/changelog_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe BlobViewer::Changelog, model: true do +describe BlobViewer::Changelog do include FakeBlobHelpers let(:project) { create(:project, :repository) } diff --git a/spec/models/blob_viewer/composer_json_spec.rb b/spec/models/blob_viewer/composer_json_spec.rb index df4f1f4815c..82f6f7e5046 100644 --- a/spec/models/blob_viewer/composer_json_spec.rb +++ b/spec/models/blob_viewer/composer_json_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe BlobViewer::ComposerJson, model: true do +describe BlobViewer::ComposerJson do include FakeBlobHelpers let(:project) { build(:project) } diff --git a/spec/models/blob_viewer/gemspec_spec.rb b/spec/models/blob_viewer/gemspec_spec.rb index 81e932de290..14cc5f3c0fd 100644 --- a/spec/models/blob_viewer/gemspec_spec.rb +++ b/spec/models/blob_viewer/gemspec_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe BlobViewer::Gemspec, model: true do +describe BlobViewer::Gemspec do include FakeBlobHelpers let(:project) { build(:project) } diff --git a/spec/models/blob_viewer/gitlab_ci_yml_spec.rb b/spec/models/blob_viewer/gitlab_ci_yml_spec.rb index 0c6c24ece21..7a4f9866375 100644 --- a/spec/models/blob_viewer/gitlab_ci_yml_spec.rb +++ b/spec/models/blob_viewer/gitlab_ci_yml_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe BlobViewer::GitlabCiYml, model: true do +describe BlobViewer::GitlabCiYml do include FakeBlobHelpers let(:project) { build(:project) } diff --git a/spec/models/blob_viewer/license_spec.rb b/spec/models/blob_viewer/license_spec.rb index 944ddd32b92..222ed166ee0 100644 --- a/spec/models/blob_viewer/license_spec.rb +++ b/spec/models/blob_viewer/license_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe BlobViewer::License, model: true do +describe BlobViewer::License do include FakeBlobHelpers let(:project) { create(:project, :repository) } diff --git a/spec/models/blob_viewer/package_json_spec.rb b/spec/models/blob_viewer/package_json_spec.rb index 5c9a9c81963..96fb1b08c99 100644 --- a/spec/models/blob_viewer/package_json_spec.rb +++ b/spec/models/blob_viewer/package_json_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe BlobViewer::PackageJson, model: true do +describe BlobViewer::PackageJson do include FakeBlobHelpers let(:project) { build(:project) } diff --git a/spec/models/blob_viewer/podspec_json_spec.rb b/spec/models/blob_viewer/podspec_json_spec.rb index 42a00940bc5..f510077a87b 100644 --- a/spec/models/blob_viewer/podspec_json_spec.rb +++ b/spec/models/blob_viewer/podspec_json_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe BlobViewer::PodspecJson, model: true do +describe BlobViewer::PodspecJson do include FakeBlobHelpers let(:project) { build(:project) } diff --git a/spec/models/blob_viewer/podspec_spec.rb b/spec/models/blob_viewer/podspec_spec.rb index 6c9f0f42d53..7c38083550c 100644 --- a/spec/models/blob_viewer/podspec_spec.rb +++ b/spec/models/blob_viewer/podspec_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe BlobViewer::Podspec, model: true do +describe BlobViewer::Podspec do include FakeBlobHelpers let(:project) { build(:project) } diff --git a/spec/models/blob_viewer/readme_spec.rb b/spec/models/blob_viewer/readme_spec.rb index 02679dbb544..926df21ffda 100644 --- a/spec/models/blob_viewer/readme_spec.rb +++ b/spec/models/blob_viewer/readme_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe BlobViewer::Readme, model: true do +describe BlobViewer::Readme do include FakeBlobHelpers let(:project) { create(:project, :repository) } diff --git a/spec/models/blob_viewer/route_map_spec.rb b/spec/models/blob_viewer/route_map_spec.rb index 4854e0262d9..115731b4970 100644 --- a/spec/models/blob_viewer/route_map_spec.rb +++ b/spec/models/blob_viewer/route_map_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe BlobViewer::RouteMap, model: true do +describe BlobViewer::RouteMap do include FakeBlobHelpers let(:project) { build(:project) } diff --git a/spec/models/blob_viewer/server_side_spec.rb b/spec/models/blob_viewer/server_side_spec.rb index f047953d540..2639eec9e84 100644 --- a/spec/models/blob_viewer/server_side_spec.rb +++ b/spec/models/blob_viewer/server_side_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe BlobViewer::ServerSide, model: true do +describe BlobViewer::ServerSide do include FakeBlobHelpers let(:project) { build(:empty_project) } diff --git a/spec/models/broadcast_message_spec.rb b/spec/models/broadcast_message_spec.rb index 333f4139a96..a8ca1d110e4 100644 --- a/spec/models/broadcast_message_spec.rb +++ b/spec/models/broadcast_message_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe BroadcastMessage, models: true do +describe BroadcastMessage do subject { build(:broadcast_message) } it { is_expected.to be_valid } @@ -24,26 +24,26 @@ describe BroadcastMessage, models: true do it 'returns message if time match' do message = create(:broadcast_message) - expect(BroadcastMessage.current).to include(message) + expect(described_class.current).to include(message) end it 'returns multiple messages if time match' do message1 = create(:broadcast_message) message2 = create(:broadcast_message) - expect(BroadcastMessage.current).to contain_exactly(message1, message2) + expect(described_class.current).to contain_exactly(message1, message2) end it 'returns empty list if time not come' do create(:broadcast_message, :future) - expect(BroadcastMessage.current).to be_empty + expect(described_class.current).to be_empty end it 'returns empty list if time has passed' do create(:broadcast_message, :expired) - expect(BroadcastMessage.current).to be_empty + expect(described_class.current).to be_empty end end diff --git a/spec/models/chat_name_spec.rb b/spec/models/chat_name_spec.rb index b02971cab82..8581bcbb08b 100644 --- a/spec/models/chat_name_spec.rb +++ b/spec/models/chat_name_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe ChatName, models: true do +describe ChatName do subject { create(:chat_name) } it { is_expected.to belong_to(:service) } diff --git a/spec/models/chat_team_spec.rb b/spec/models/chat_team_spec.rb index 5283561a83f..e0e5f73e6fe 100644 --- a/spec/models/chat_team_spec.rb +++ b/spec/models/chat_team_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe ChatTeam, type: :model do +describe ChatTeam do subject { create(:chat_team) } # Associations diff --git a/spec/models/ci/artifact_blob_spec.rb b/spec/models/ci/artifact_blob_spec.rb index 968593d7e9b..a10a8af5303 100644 --- a/spec/models/ci/artifact_blob_spec.rb +++ b/spec/models/ci/artifact_blob_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Ci::ArtifactBlob, models: true do +describe Ci::ArtifactBlob do let(:build) { create(:ci_build, :artifacts) } let(:entry) { build.artifacts_metadata_entry('other_artifacts_0.1.2/another-subdirectory/banana_sample.gif') } diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index 0b521d720f3..86afa856ea7 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Ci::Build, :models do +describe Ci::Build do let(:user) { create(:user) } let(:project) { create(:project, :repository) } let(:build) { create(:ci_build, pipeline: pipeline) } @@ -225,7 +225,7 @@ describe Ci::Build, :models do it 'expects to have retried builds instead the original ones' do project.add_developer(user) - retried_rspec = Ci::Build.retry(rspec_test, user) + retried_rspec = described_class.retry(rspec_test, user) expect(staging.depends_on_builds.map(&:id)) .to contain_exactly(build.id, retried_rspec.id, rubocop_test.id) @@ -620,9 +620,9 @@ describe Ci::Build, :models do describe '#first_pending' do let!(:first) { create(:ci_build, pipeline: pipeline, status: 'pending', created_at: Date.yesterday) } let!(:second) { create(:ci_build, pipeline: pipeline, status: 'pending') } - subject { Ci::Build.first_pending } + subject { described_class.first_pending } - it { is_expected.to be_a(Ci::Build) } + it { is_expected.to be_a(described_class) } it('returns with the first pending build') { is_expected.to eq(first) } end @@ -945,7 +945,7 @@ describe Ci::Build, :models do end context 'when build is retried' do - let!(:new_build) { Ci::Build.retry(build, user) } + let!(:new_build) { described_class.retry(build, user) } it 'does not return any of them' do is_expected.not_to include(build, new_build) @@ -953,7 +953,7 @@ describe Ci::Build, :models do end context 'when other build is retried' do - let!(:retried_build) { Ci::Build.retry(other_build, user) } + let!(:retried_build) { described_class.retry(other_build, user) } before do retried_build.success @@ -1468,6 +1468,12 @@ describe Ci::Build, :models do it { is_expected.to include(predefined_trigger_variable) } end + context 'when pipeline has a variable' do + let!(:pipeline_variable) { create(:ci_pipeline_variable, pipeline: pipeline) } + + it { is_expected.to include(pipeline_variable.to_runner_variable) } + end + context 'when a job was triggered by a pipeline schedule' do let(:pipeline_schedule) { create(:ci_pipeline_schedule, project: project) } diff --git a/spec/models/ci/group_spec.rb b/spec/models/ci/group_spec.rb index 62e15093089..51123e73fe6 100644 --- a/spec/models/ci/group_spec.rb +++ b/spec/models/ci/group_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Ci::Group, models: true do +describe Ci::Group do subject do described_class.new('test', name: 'rspec', jobs: jobs) end diff --git a/spec/models/ci/group_variable_spec.rb b/spec/models/ci/group_variable_spec.rb index 24b914face9..145189e7469 100644 --- a/spec/models/ci/group_variable_spec.rb +++ b/spec/models/ci/group_variable_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Ci::GroupVariable, models: true do +describe Ci::GroupVariable do subject { build(:ci_group_variable) } it { is_expected.to include_module(HasVariable) } diff --git a/spec/models/ci/legacy_stage_spec.rb b/spec/models/ci/legacy_stage_spec.rb index d43c33d3807..0c33c1466b7 100644 --- a/spec/models/ci/legacy_stage_spec.rb +++ b/spec/models/ci/legacy_stage_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Ci::LegacyStage, :models do +describe Ci::LegacyStage do let(:stage) { build(:ci_stage) } let(:pipeline) { stage.pipeline } let(:stage_name) { stage.name } diff --git a/spec/models/ci/pipeline_schedule_spec.rb b/spec/models/ci/pipeline_schedule_spec.rb index 6427deda31e..9a278212efc 100644 --- a/spec/models/ci/pipeline_schedule_spec.rb +++ b/spec/models/ci/pipeline_schedule_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Ci::PipelineSchedule, models: true do +describe Ci::PipelineSchedule do it { is_expected.to belong_to(:project) } it { is_expected.to belong_to(:owner) } @@ -46,7 +46,7 @@ describe Ci::PipelineSchedule, models: true do end it 'updates next_run_at automatically' do - expect(Ci::PipelineSchedule.last.next_run_at).to eq(expected_next_run_at) + expect(described_class.last.next_run_at).to eq(expected_next_run_at) end end @@ -61,7 +61,7 @@ describe Ci::PipelineSchedule, models: true do it 'updates next_run_at automatically' do pipeline_schedule.update!(cron: new_cron) - expect(Ci::PipelineSchedule.last.next_run_at).to eq(expected_next_run_at) + expect(described_class.last.next_run_at).to eq(expected_next_run_at) end end end diff --git a/spec/models/ci/pipeline_schedule_variable_spec.rb b/spec/models/ci/pipeline_schedule_variable_spec.rb index 0de76a57b7f..dc8427f28bc 100644 --- a/spec/models/ci/pipeline_schedule_variable_spec.rb +++ b/spec/models/ci/pipeline_schedule_variable_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Ci::PipelineScheduleVariable, models: true do +describe Ci::PipelineScheduleVariable do subject { build(:ci_pipeline_schedule_variable) } it { is_expected.to include_module(HasVariable) } diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index bbd45f10b1b..b0efa689a07 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Ci::Pipeline, models: true do +describe Ci::Pipeline do include EmailHelpers let(:user) { create(:user) } @@ -17,6 +17,7 @@ describe Ci::Pipeline, models: true do it { is_expected.to have_many(:statuses) } it { is_expected.to have_many(:trigger_requests) } + it { is_expected.to have_many(:variables) } it { is_expected.to have_many(:builds) } it { is_expected.to have_many(:auto_canceled_pipelines) } it { is_expected.to have_many(:auto_canceled_jobs) } diff --git a/spec/models/ci/pipeline_variable_spec.rb b/spec/models/ci/pipeline_variable_spec.rb new file mode 100644 index 00000000000..2ce78e34b0c --- /dev/null +++ b/spec/models/ci/pipeline_variable_spec.rb @@ -0,0 +1,8 @@ +require 'spec_helper' + +describe Ci::PipelineVariable, models: true do + subject { build(:ci_pipeline_variable) } + + it { is_expected.to include_module(HasVariable) } + it { is_expected.to validate_uniqueness_of(:key).scoped_to(:pipeline_id) } +end diff --git a/spec/models/ci/runner_spec.rb b/spec/models/ci/runner_spec.rb index 4b9cce28e0e..8d12a9c09ca 100644 --- a/spec/models/ci/runner_spec.rb +++ b/spec/models/ci/runner_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Ci::Runner, models: true do +describe Ci::Runner do describe 'validation' do context 'when runner is not allowed to pick untagged jobs' do context 'when runner does not have tags' do @@ -50,7 +50,7 @@ describe Ci::Runner, models: true do end describe '.online' do - subject { Ci::Runner.online } + subject { described_class.online } before do @runner1 = FactoryGirl.create(:ci_runner, :shared, contacted_at: 1.year.ago) @@ -352,13 +352,13 @@ describe Ci::Runner, models: true do end context 'does not give owned runner' do - subject { Ci::Runner.assignable_for(project) } + subject { described_class.assignable_for(project) } it { is_expected.to be_empty } end context 'does not give shared runner' do - subject { Ci::Runner.assignable_for(another_project) } + subject { described_class.assignable_for(another_project) } it { is_expected.to be_empty } end @@ -366,13 +366,13 @@ describe Ci::Runner, models: true do context 'with unlocked runner' do context 'does not give owned runner' do - subject { Ci::Runner.assignable_for(project) } + subject { described_class.assignable_for(project) } it { is_expected.to be_empty } end context 'does give a specific runner' do - subject { Ci::Runner.assignable_for(another_project) } + subject { described_class.assignable_for(another_project) } it { is_expected.to contain_exactly(runner) } end @@ -384,13 +384,13 @@ describe Ci::Runner, models: true do end context 'does not give owned runner' do - subject { Ci::Runner.assignable_for(project) } + subject { described_class.assignable_for(project) } it { is_expected.to be_empty } end context 'does not give a locked runner' do - subject { Ci::Runner.assignable_for(another_project) } + subject { described_class.assignable_for(another_project) } it { is_expected.to be_empty } end diff --git a/spec/models/ci/trigger_spec.rb b/spec/models/ci/trigger_spec.rb index 92c15c13c18..de51f4879fd 100644 --- a/spec/models/ci/trigger_spec.rb +++ b/spec/models/ci/trigger_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Ci::Trigger, models: true do +describe Ci::Trigger do let(:project) { create :empty_project } describe 'associations' do diff --git a/spec/models/ci/variable_spec.rb b/spec/models/ci/variable_spec.rb index 890ffaae494..e4ff551151e 100644 --- a/spec/models/ci/variable_spec.rb +++ b/spec/models/ci/variable_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Ci::Variable, models: true do +describe Ci::Variable do subject { build(:ci_variable) } describe 'validations' do diff --git a/spec/models/commit_range_spec.rb b/spec/models/commit_range_spec.rb index ba9c3f66d21..07e10b44938 100644 --- a/spec/models/commit_range_spec.rb +++ b/spec/models/commit_range_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe CommitRange, models: true do +describe CommitRange do describe 'modules' do subject { described_class } diff --git a/spec/models/commit_spec.rb b/spec/models/commit_spec.rb index 528b211c9d6..2285c338599 100644 --- a/spec/models/commit_spec.rb +++ b/spec/models/commit_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Commit, models: true do +describe Commit do let(:project) { create(:project, :public, :repository) } let(:commit) { project.commit } diff --git a/spec/models/commit_status_spec.rb b/spec/models/commit_status_spec.rb index f173e2c142a..4e915d73ced 100644 --- a/spec/models/commit_status_spec.rb +++ b/spec/models/commit_status_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe CommitStatus, :models do +describe CommitStatus do let(:project) { create(:project, :repository) } let(:pipeline) do diff --git a/spec/models/compare_spec.rb b/spec/models/compare_spec.rb index da003dbf794..04f3cecae00 100644 --- a/spec/models/compare_spec.rb +++ b/spec/models/compare_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Compare, models: true do +describe Compare do include RepoHelpers let(:project) { create(:project, :public, :repository) } diff --git a/spec/models/concerns/case_sensitivity_spec.rb b/spec/models/concerns/case_sensitivity_spec.rb index a6fccb668e3..5c0dfaeb4d3 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, models: true do +describe CaseSensitivity do describe '.iwhere' do let(:connection) { ActiveRecord::Base.connection } let(:model) { Class.new { include CaseSensitivity } } diff --git a/spec/models/concerns/discussion_on_diff_spec.rb b/spec/models/concerns/discussion_on_diff_spec.rb index f3e148f95f0..2322eb206fb 100644 --- a/spec/models/concerns/discussion_on_diff_spec.rb +++ b/spec/models/concerns/discussion_on_diff_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe DiscussionOnDiff, model: true do +describe DiscussionOnDiff do subject { create(:diff_note_on_merge_request).to_discussion } describe "#truncated_diff_lines" do diff --git a/spec/models/concerns/noteable_spec.rb b/spec/models/concerns/noteable_spec.rb index bdae742ff1d..485a6e165a1 100644 --- a/spec/models/concerns/noteable_spec.rb +++ b/spec/models/concerns/noteable_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Noteable, model: true do +describe Noteable do let!(:active_diff_note1) { create(:diff_note_on_merge_request) } let(:project) { active_diff_note1.project } subject { active_diff_note1.noteable } diff --git a/spec/models/concerns/participable_spec.rb b/spec/models/concerns/participable_spec.rb index a9f4ef9ee5e..431f1482615 100644 --- a/spec/models/concerns/participable_spec.rb +++ b/spec/models/concerns/participable_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Participable, models: true do +describe Participable do let(:model) do Class.new do include Participable diff --git a/spec/models/concerns/resolvable_discussion_spec.rb b/spec/models/concerns/resolvable_discussion_spec.rb index 3934992c143..1616c2ea985 100644 --- a/spec/models/concerns/resolvable_discussion_spec.rb +++ b/spec/models/concerns/resolvable_discussion_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Discussion, ResolvableDiscussion, models: true do +describe Discussion, ResolvableDiscussion do subject { described_class.new([first_note, second_note, third_note]) } let(:first_note) { create(:discussion_note_on_merge_request) } diff --git a/spec/models/concerns/resolvable_note_spec.rb b/spec/models/concerns/resolvable_note_spec.rb index 1503ccdff11..53eaa6f8461 100644 --- a/spec/models/concerns/resolvable_note_spec.rb +++ b/spec/models/concerns/resolvable_note_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Note, ResolvableNote, models: true do +describe Note, ResolvableNote do let(:project) { create(:project) } let(:merge_request) { create(:merge_request, source_project: project) } subject { create(:discussion_note_on_merge_request, noteable: merge_request, project: project) } diff --git a/spec/models/concerns/uniquify_spec.rb b/spec/models/concerns/uniquify_spec.rb index 83187d732e4..914730718e7 100644 --- a/spec/models/concerns/uniquify_spec.rb +++ b/spec/models/concerns/uniquify_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Uniquify, models: true do +describe Uniquify do let(:uniquify) { described_class.new } describe "#string" do diff --git a/spec/models/cycle_analytics/code_spec.rb b/spec/models/cycle_analytics/code_spec.rb index 9053485939e..f2f1928926c 100644 --- a/spec/models/cycle_analytics/code_spec.rb +++ b/spec/models/cycle_analytics/code_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'CycleAnalytics#code', feature: true do +describe 'CycleAnalytics#code' do extend CycleAnalyticsHelpers::TestGeneration let(:project) { create(:project, :repository) } diff --git a/spec/models/cycle_analytics/issue_spec.rb b/spec/models/cycle_analytics/issue_spec.rb index fc7d18bd40e..985e1bf80be 100644 --- a/spec/models/cycle_analytics/issue_spec.rb +++ b/spec/models/cycle_analytics/issue_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'CycleAnalytics#issue', models: true do +describe 'CycleAnalytics#issue' do extend CycleAnalyticsHelpers::TestGeneration let(:project) { create(:project, :repository) } diff --git a/spec/models/cycle_analytics/plan_spec.rb b/spec/models/cycle_analytics/plan_spec.rb index 4f33f3c6d69..6fbb2a2d102 100644 --- a/spec/models/cycle_analytics/plan_spec.rb +++ b/spec/models/cycle_analytics/plan_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'CycleAnalytics#plan', feature: true do +describe 'CycleAnalytics#plan' do extend CycleAnalyticsHelpers::TestGeneration let(:project) { create(:project, :repository) } diff --git a/spec/models/cycle_analytics/production_spec.rb b/spec/models/cycle_analytics/production_spec.rb index 4744b9e05ea..f8681c0a2f9 100644 --- a/spec/models/cycle_analytics/production_spec.rb +++ b/spec/models/cycle_analytics/production_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'CycleAnalytics#production', feature: true do +describe 'CycleAnalytics#production' do extend CycleAnalyticsHelpers::TestGeneration let(:project) { create(:project, :repository) } diff --git a/spec/models/cycle_analytics/review_spec.rb b/spec/models/cycle_analytics/review_spec.rb index febb18c9884..0ac58695b35 100644 --- a/spec/models/cycle_analytics/review_spec.rb +++ b/spec/models/cycle_analytics/review_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'CycleAnalytics#review', feature: true do +describe 'CycleAnalytics#review' do extend CycleAnalyticsHelpers::TestGeneration let(:project) { create(:project, :repository) } diff --git a/spec/models/cycle_analytics/staging_spec.rb b/spec/models/cycle_analytics/staging_spec.rb index f78d7a23105..b66d5623910 100644 --- a/spec/models/cycle_analytics/staging_spec.rb +++ b/spec/models/cycle_analytics/staging_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'CycleAnalytics#staging', feature: true do +describe 'CycleAnalytics#staging' do extend CycleAnalyticsHelpers::TestGeneration let(:project) { create(:project, :repository) } diff --git a/spec/models/cycle_analytics/test_spec.rb b/spec/models/cycle_analytics/test_spec.rb index fd58bd1d6ad..690c09bc2dc 100644 --- a/spec/models/cycle_analytics/test_spec.rb +++ b/spec/models/cycle_analytics/test_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'CycleAnalytics#test', feature: true do +describe 'CycleAnalytics#test' do extend CycleAnalyticsHelpers::TestGeneration let(:project) { create(:project, :repository) } diff --git a/spec/models/deploy_key_spec.rb b/spec/models/deploy_key_spec.rb index 8ef8218cf74..2aece75b817 100644 --- a/spec/models/deploy_key_spec.rb +++ b/spec/models/deploy_key_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe DeployKey, models: true do +describe DeployKey do include EmailHelpers describe "Associations" do diff --git a/spec/models/deploy_keys_project_spec.rb b/spec/models/deploy_keys_project_spec.rb index aacc178a19e..f10b65ba9d8 100644 --- a/spec/models/deploy_keys_project_spec.rb +++ b/spec/models/deploy_keys_project_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe DeployKeysProject, models: true do +describe DeployKeysProject do describe "Associations" do it { is_expected.to belong_to(:deploy_key) } it { is_expected.to belong_to(:project) } diff --git a/spec/models/deployment_spec.rb b/spec/models/deployment_spec.rb index bb84d3fc13d..6447095078b 100644 --- a/spec/models/deployment_spec.rb +++ b/spec/models/deployment_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Deployment, models: true do +describe Deployment do subject { build(:deployment) } it { is_expected.to belong_to(:project) } diff --git a/spec/models/diff_discussion_spec.rb b/spec/models/diff_discussion_spec.rb index 45b2f6e4beb..2704698f6c9 100644 --- a/spec/models/diff_discussion_spec.rb +++ b/spec/models/diff_discussion_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe DiffDiscussion, model: true do +describe DiffDiscussion do include RepoHelpers subject { described_class.new([diff_note]) } diff --git a/spec/models/diff_note_spec.rb b/spec/models/diff_note_spec.rb index 297c2108dc2..4aa9ec789a3 100644 --- a/spec/models/diff_note_spec.rb +++ b/spec/models/diff_note_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe DiffNote, models: true do +describe DiffNote do include RepoHelpers let(:merge_request) { create(:merge_request) } diff --git a/spec/models/diff_viewer/base_spec.rb b/spec/models/diff_viewer/base_spec.rb index 3755f4a56f3..b26de3f3b97 100644 --- a/spec/models/diff_viewer/base_spec.rb +++ b/spec/models/diff_viewer/base_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe DiffViewer::Base, model: true do +describe DiffViewer::Base do include FakeBlobHelpers let(:project) { create(:project, :repository) } diff --git a/spec/models/diff_viewer/server_side_spec.rb b/spec/models/diff_viewer/server_side_spec.rb index 2d926e06936..92e613f92de 100644 --- a/spec/models/diff_viewer/server_side_spec.rb +++ b/spec/models/diff_viewer/server_side_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe DiffViewer::ServerSide, model: true do +describe DiffViewer::ServerSide do let(:project) { create(:project, :repository) } let(:commit) { project.commit('570e7b2abdd848b95f2f578043fc23bd6f6fd24d') } let(:diff_file) { commit.diffs.diff_file_with_new_path('files/ruby/popen.rb') } diff --git a/spec/models/discussion_spec.rb b/spec/models/discussion_spec.rb index 0221e23ced8..a46f7ed6507 100644 --- a/spec/models/discussion_spec.rb +++ b/spec/models/discussion_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Discussion, model: true do +describe Discussion do subject { described_class.new([first_note, second_note, third_note]) } let(:first_note) { create(:diff_note_on_merge_request) } diff --git a/spec/models/email_spec.rb b/spec/models/email_spec.rb index fe4de1b2afb..1d6fabe48b1 100644 --- a/spec/models/email_spec.rb +++ b/spec/models/email_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Email, models: true do +describe Email do describe 'validations' do it_behaves_like 'an object with email-formated attributes', :email do subject { build(:email) } diff --git a/spec/models/environment_spec.rb b/spec/models/environment_spec.rb index 0a2cd8c2957..ebf2c070116 100644 --- a/spec/models/environment_spec.rb +++ b/spec/models/environment_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Environment, models: true do +describe Environment do set(:project) { create(:empty_project) } subject(:environment) { create(:environment, project: project) } diff --git a/spec/models/event_spec.rb b/spec/models/event_spec.rb index 10b9bf9f43a..4a4b84c9566 100644 --- a/spec/models/event_spec.rb +++ b/spec/models/event_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Event, models: true do +describe Event 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 cd50bda8996..c8748daf46b 100644 --- a/spec/models/external_issue_spec.rb +++ b/spec/models/external_issue_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe ExternalIssue, models: true do +describe ExternalIssue do let(:project) { double('project', id: 1, to_reference: 'namespace1/project1') } let(:issue) { described_class.new('EXT-1234', project) } diff --git a/spec/models/generic_commit_status_spec.rb b/spec/models/generic_commit_status_spec.rb index 152e97e09bf..aedc74deb78 100644 --- a/spec/models/generic_commit_status_spec.rb +++ b/spec/models/generic_commit_status_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe GenericCommitStatus, models: true do +describe GenericCommitStatus do let(:project) { create(:empty_project) } let(:pipeline) { create(:ci_pipeline, project: project) } let(:external_url) { 'http://example.gitlab.com/status' } diff --git a/spec/models/global_milestone_spec.rb b/spec/models/global_milestone_spec.rb index a14efda3eda..5584a1a5a31 100644 --- a/spec/models/global_milestone_spec.rb +++ b/spec/models/global_milestone_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe GlobalMilestone, models: true do +describe GlobalMilestone do let(:user) { create(:user) } let(:user2) { create(:user) } let(:group) { create(:group) } @@ -72,7 +72,7 @@ describe GlobalMilestone, models: true do project3 ] - @global_milestones = GlobalMilestone.build_collection(projects, {}) + @global_milestones = described_class.build_collection(projects, {}) end it 'has all project milestones' do @@ -106,7 +106,7 @@ describe GlobalMilestone, models: true do it 'returns the quantity of global milestones in each possible state' do expected_count = { opened: 1, closed: 2, all: 2 } - count = GlobalMilestone.states_count(Project.all) + count = described_class.states_count(Project.all) expect(count).to eq(expected_count) end @@ -120,7 +120,7 @@ describe GlobalMilestone, models: true do it 'returns 0 as the quantity of global milestones in each state' do expected_count = { opened: 0, closed: 0, all: 0 } - count = GlobalMilestone.states_count(Project.all) + count = described_class.states_count(Project.all) expect(count).to eq(expected_count) end @@ -141,7 +141,7 @@ describe GlobalMilestone, models: true do ] milestones_relation = Milestone.where(id: milestones.map(&:id)) - @global_milestone = GlobalMilestone.new(milestone1_project1.title, milestones_relation) + @global_milestone = described_class.new(milestone1_project1.title, milestones_relation) end it 'has exactly one group milestone' do @@ -157,7 +157,7 @@ describe GlobalMilestone, models: true do let(:milestone) { create(:milestone, title: "git / test", project: project1) } it 'strips out slashes and spaces' do - global_milestone = GlobalMilestone.new(milestone.title, Milestone.where(id: milestone.id)) + global_milestone = described_class.new(milestone.title, Milestone.where(id: milestone.id)) expect(global_milestone.safe_title).to eq('git-test') end @@ -171,7 +171,7 @@ describe GlobalMilestone, models: true do create(:active_milestone, title: title), create(:closed_milestone, title: title) ] - global_milestone = GlobalMilestone.new(title, milestones) + global_milestone = described_class.new(title, milestones) expect(global_milestone.state).to eq('active') end @@ -184,7 +184,7 @@ describe GlobalMilestone, models: true do create(:closed_milestone, title: title), create(:closed_milestone, title: title) ] - global_milestone = GlobalMilestone.new(title, milestones) + global_milestone = described_class.new(title, milestones) expect(global_milestone.state).to eq('closed') end diff --git a/spec/models/gpg_key_spec.rb b/spec/models/gpg_key_spec.rb new file mode 100644 index 00000000000..59c074199db --- /dev/null +++ b/spec/models/gpg_key_spec.rb @@ -0,0 +1,157 @@ +require 'rails_helper' + +describe GpgKey do + describe "associations" do + it { is_expected.to belong_to(:user) } + end + + describe "validation" do + it { is_expected.to validate_presence_of(:user) } + + it { is_expected.to validate_presence_of(:key) } + it { is_expected.to validate_uniqueness_of(:key) } + + it { is_expected.to allow_value("-----BEGIN PGP PUBLIC KEY BLOCK-----\nkey\n-----END PGP PUBLIC KEY BLOCK-----").for(:key) } + + it { is_expected.not_to allow_value("-----BEGIN PGP PUBLIC KEY BLOCK-----\nkey").for(:key) } + it { is_expected.not_to allow_value("-----BEGIN PGP PUBLIC KEY BLOCK-----\nkey\n-----BEGIN PGP PUBLIC KEY BLOCK-----").for(:key) } + it { is_expected.not_to allow_value("-----BEGIN PGP PUBLIC KEY BLOCK----------END PGP PUBLIC KEY BLOCK-----").for(:key) } + it { is_expected.not_to allow_value("-----BEGIN PGP PUBLIC KEY BLOCK-----").for(:key) } + it { is_expected.not_to allow_value("-----END PGP PUBLIC KEY BLOCK-----").for(:key) } + it { is_expected.not_to allow_value("key\n-----END PGP PUBLIC KEY BLOCK-----").for(:key) } + it { is_expected.not_to allow_value('BEGIN PGP').for(:key) } + end + + context 'callbacks' do + describe 'extract_fingerprint' do + it 'extracts the fingerprint from the gpg key' do + gpg_key = described_class.new(key: GpgHelpers::User1.public_key) + gpg_key.valid? + expect(gpg_key.fingerprint).to eq GpgHelpers::User1.fingerprint + end + end + + describe 'extract_primary_keyid' do + it 'extracts the primary keyid from the gpg key' do + gpg_key = described_class.new(key: GpgHelpers::User1.public_key) + gpg_key.valid? + expect(gpg_key.primary_keyid).to eq GpgHelpers::User1.primary_keyid + end + end + end + + describe '#key=' do + it 'strips white spaces' do + key = <<~KEY.strip + -----BEGIN PGP PUBLIC KEY BLOCK----- + Version: GnuPG v1 + + mQENBFMOSOgBCADFCYxmnXFbrDhfvlf03Q/bQuT+nZu46BFGbo7XkUjDowFXJQhP + -----END PGP PUBLIC KEY BLOCK----- + KEY + + expect(described_class.new(key: " #{key} ").key).to eq(key) + end + + it 'does not strip when the key is nil' do + expect(described_class.new(key: nil).key).to be_nil + end + end + + describe '#user_infos' do + it 'returns the user infos from the gpg key' do + gpg_key = create :gpg_key, key: GpgHelpers::User1.public_key + expect(Gitlab::Gpg).to receive(:user_infos_from_key).with(gpg_key.key) + + gpg_key.user_infos + end + end + + describe '#verified_user_infos' do + it 'returns the user infos if it is verified' do + user = create :user, email: GpgHelpers::User1.emails.first + gpg_key = create :gpg_key, key: GpgHelpers::User1.public_key, user: user + + expect(gpg_key.verified_user_infos).to eq([{ + name: GpgHelpers::User1.names.first, + email: GpgHelpers::User1.emails.first + }]) + end + + it 'returns an empty array if the user info is not verified' do + user = create :user, email: 'unrelated@example.com' + gpg_key = create :gpg_key, key: GpgHelpers::User1.public_key, user: user + + expect(gpg_key.verified_user_infos).to eq([]) + end + end + + describe '#emails_with_verified_status' do + it 'email is verified if the user has the matching email' do + user = create :user, email: 'bette.cartwright@example.com' + gpg_key = create :gpg_key, key: GpgHelpers::User2.public_key, user: user + + expect(gpg_key.emails_with_verified_status).to eq( + 'bette.cartwright@example.com' => true, + 'bette.cartwright@example.net' => false + ) + end + end + + describe '#verified?' do + it 'returns true one of the email addresses in the key belongs to the user' do + user = create :user, email: 'bette.cartwright@example.com' + gpg_key = create :gpg_key, key: GpgHelpers::User2.public_key, user: user + + expect(gpg_key.verified?).to be_truthy + end + + it 'returns false if one of the email addresses in the key does not belong to the user' do + user = create :user, email: 'someone.else@example.com' + gpg_key = create :gpg_key, key: GpgHelpers::User2.public_key, user: user + + expect(gpg_key.verified?).to be_falsey + end + end + + describe 'notification' do + include EmailHelpers + + let(:user) { create(:user) } + + it 'sends a notification' do + perform_enqueued_jobs do + create(:gpg_key, user: user) + end + + should_email(user) + end + end + + describe '#revoke' do + it 'invalidates all associated gpg signatures and destroys the key' do + gpg_key = create :gpg_key + gpg_signature = create :gpg_signature, valid_signature: true, gpg_key: gpg_key + + unrelated_gpg_key = create :gpg_key, key: GpgHelpers::User2.public_key + unrelated_gpg_signature = create :gpg_signature, valid_signature: true, gpg_key: unrelated_gpg_key + + gpg_key.revoke + + expect(gpg_signature.reload).to have_attributes( + valid_signature: false, + gpg_key: nil + ) + + expect(gpg_key.destroyed?).to be true + + # unrelated signature is left untouched + expect(unrelated_gpg_signature.reload).to have_attributes( + valid_signature: true, + gpg_key: unrelated_gpg_key + ) + + expect(unrelated_gpg_key.destroyed?).to be false + end + end +end diff --git a/spec/models/gpg_signature_spec.rb b/spec/models/gpg_signature_spec.rb new file mode 100644 index 00000000000..9a9b1900aa5 --- /dev/null +++ b/spec/models/gpg_signature_spec.rb @@ -0,0 +1,28 @@ +require 'rails_helper' + +RSpec.describe GpgSignature do + describe 'associations' do + it { is_expected.to belong_to(:project) } + it { is_expected.to belong_to(:gpg_key) } + end + + describe 'validation' do + subject { described_class.new } + it { is_expected.to validate_presence_of(:commit_sha) } + it { is_expected.to validate_presence_of(:project_id) } + it { is_expected.to validate_presence_of(:gpg_key_primary_keyid) } + end + + describe '#commit' do + it 'fetches the commit through the project' do + commit_sha = '0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33' + project = create :project + commit = create :commit, project: project + gpg_signature = create :gpg_signature, commit_sha: commit_sha + + expect_any_instance_of(Project).to receive(:commit).with(commit_sha).and_return(commit) + + gpg_signature.commit + end + end +end diff --git a/spec/models/group_label_spec.rb b/spec/models/group_label_spec.rb index 555a876daeb..f7828059295 100644 --- a/spec/models/group_label_spec.rb +++ b/spec/models/group_label_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe GroupLabel, models: true do +describe GroupLabel do describe 'relationships' do it { is_expected.to belong_to(:group) } end diff --git a/spec/models/group_milestone_spec.rb b/spec/models/group_milestone_spec.rb index 916afb7aaf5..ac76c927c39 100644 --- a/spec/models/group_milestone_spec.rb +++ b/spec/models/group_milestone_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe GroupMilestone, models: true do +describe GroupMilestone do let(:group) { create(:group) } let(:project) { create(:empty_project, group: group) } let(:project_milestone) do @@ -9,7 +9,7 @@ describe GroupMilestone, models: true do describe '.build' do it 'returns milestone with group assigned' do - milestone = GroupMilestone.build( + milestone = described_class.build( group, [project], project_milestone.title @@ -25,7 +25,7 @@ describe GroupMilestone, models: true do end it 'returns array of milestones, each with group assigned' do - milestones = GroupMilestone.build_collection(group, [project], {}) + milestones = described_class.build_collection(group, [project], {}) expect(milestones).to all(have_attributes(group: group)) end end diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb index d8e868265ed..112bd605a64 100644 --- a/spec/models/group_spec.rb +++ b/spec/models/group_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Group, models: true do +describe Group do let!(:group) { create(:group, :access_requestable) } describe 'associations' do @@ -357,7 +357,7 @@ describe Group, models: true do subject { build(:group, :nested) } it { is_expected.to be_valid } - it { expect(subject.parent).to be_kind_of(Group) } + it { expect(subject.parent).to be_kind_of(described_class) } end describe '#members_with_parents', :nested_groups do diff --git a/spec/models/guest_spec.rb b/spec/models/guest_spec.rb index c60bd7af958..0e9b94aac97 100644 --- a/spec/models/guest_spec.rb +++ b/spec/models/guest_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Guest, lib: true do +describe Guest do let(:public_project) { build_stubbed(:empty_project, :public) } let(:private_project) { build_stubbed(:empty_project, :private) } let(:internal_project) { build_stubbed(:empty_project, :internal) } @@ -8,13 +8,13 @@ describe Guest, lib: true do describe '.can_pull?' do context 'when project is private' do it 'does not allow to pull the repo' do - expect(Guest.can?(:download_code, private_project)).to eq(false) + expect(described_class.can?(:download_code, private_project)).to eq(false) end end context 'when project is internal' do it 'does not allow to pull the repo' do - expect(Guest.can?(:download_code, internal_project)).to eq(false) + expect(described_class.can?(:download_code, internal_project)).to eq(false) end end @@ -23,7 +23,7 @@ describe Guest, lib: true do it 'does not allow to pull the repo' do public_project.project_feature.update_attribute(:repository_access_level, ProjectFeature::DISABLED) - expect(Guest.can?(:download_code, public_project)).to eq(false) + expect(described_class.can?(:download_code, public_project)).to eq(false) end end @@ -31,13 +31,13 @@ describe Guest, lib: true do it 'does not allow to pull the repo' do public_project.project_feature.update_attribute(:repository_access_level, ProjectFeature::PRIVATE) - expect(Guest.can?(:download_code, public_project)).to eq(false) + expect(described_class.can?(:download_code, public_project)).to eq(false) end end context 'when repository is enabled' do it 'allows to pull the repo' do - expect(Guest.can?(:download_code, public_project)).to eq(true) + expect(described_class.can?(:download_code, public_project)).to eq(true) end end end diff --git a/spec/models/hooks/project_hook_spec.rb b/spec/models/hooks/project_hook_spec.rb index 0af270014b5..5dd31b1b5de 100644 --- a/spec/models/hooks/project_hook_spec.rb +++ b/spec/models/hooks/project_hook_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe ProjectHook, models: true do +describe ProjectHook do describe 'associations' do it { is_expected.to belong_to :project } end @@ -13,7 +13,7 @@ describe ProjectHook, models: true do it 'returns hooks for push events only' do hook = create(:project_hook, push_events: true) create(:project_hook, push_events: false) - expect(ProjectHook.push_hooks).to eq([hook]) + expect(described_class.push_hooks).to eq([hook]) end end @@ -21,7 +21,7 @@ describe ProjectHook, models: true do it 'returns hooks for tag push events only' do hook = create(:project_hook, tag_push_events: true) create(:project_hook, tag_push_events: false) - expect(ProjectHook.tag_push_hooks).to eq([hook]) + expect(described_class.tag_push_hooks).to eq([hook]) end end end diff --git a/spec/models/hooks/service_hook_spec.rb b/spec/models/hooks/service_hook_spec.rb index 8e871a41a8c..e32eaafc13f 100644 --- a/spec/models/hooks/service_hook_spec.rb +++ b/spec/models/hooks/service_hook_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe ServiceHook, models: true do +describe ServiceHook 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 559778257fa..eadc232a989 100644 --- a/spec/models/hooks/system_hook_spec.rb +++ b/spec/models/hooks/system_hook_spec.rb @@ -1,6 +1,6 @@ require "spec_helper" -describe SystemHook, models: true do +describe SystemHook do context 'default attributes' do let(:system_hook) { build(:system_hook) } @@ -122,7 +122,7 @@ describe SystemHook, models: true do it 'returns hooks for repository update events only' do hook = create(:system_hook, repository_update_events: true) create(:system_hook, repository_update_events: false) - expect(SystemHook.repository_update_hooks).to eq([hook]) + expect(described_class.repository_update_hooks).to eq([hook]) end end diff --git a/spec/models/hooks/web_hook_log_spec.rb b/spec/models/hooks/web_hook_log_spec.rb index c649cf3b589..19bc88b1333 100644 --- a/spec/models/hooks/web_hook_log_spec.rb +++ b/spec/models/hooks/web_hook_log_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe WebHookLog, models: true do +describe WebHookLog do it { is_expected.to belong_to(:web_hook) } it { is_expected.to serialize(:request_headers).as(Hash) } diff --git a/spec/models/hooks/web_hook_spec.rb b/spec/models/hooks/web_hook_spec.rb index 53157c24477..388120160ab 100644 --- a/spec/models/hooks/web_hook_spec.rb +++ b/spec/models/hooks/web_hook_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe WebHook, models: true do +describe WebHook do let(:hook) { build(:project_hook) } describe 'associations' do diff --git a/spec/models/identity_spec.rb b/spec/models/identity_spec.rb index b3aed66a5b6..4ca6556d0f4 100644 --- a/spec/models/identity_spec.rb +++ b/spec/models/identity_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -RSpec.describe Identity, models: true do +RSpec.describe Identity do describe 'relations' do it { is_expected.to belong_to(:user) } end diff --git a/spec/models/issue/metrics_spec.rb b/spec/models/issue/metrics_spec.rb index 08712f2a768..6ceff7d24d4 100644 --- a/spec/models/issue/metrics_spec.rb +++ b/spec/models/issue/metrics_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Issue::Metrics, models: true do +describe Issue::Metrics do let(:project) { create(:empty_project) } subject { create(:issue, project: project) } diff --git a/spec/models/issue_spec.rb b/spec/models/issue_spec.rb index bf97c6ececd..d72790eefe5 100644 --- a/spec/models/issue_spec.rb +++ b/spec/models/issue_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Issue, models: true do +describe Issue do describe "Associations" do it { is_expected.to belong_to(:milestone) } it { is_expected.to have_many(:assignees) } diff --git a/spec/models/key_spec.rb b/spec/models/key_spec.rb index f27920f9feb..d41717d0223 100644 --- a/spec/models/key_spec.rb +++ b/spec/models/key_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Key, models: true do +describe Key do include EmailHelpers describe "Associations" do diff --git a/spec/models/label_link_spec.rb b/spec/models/label_link_spec.rb index c18ed8574b1..e2b49bc2de7 100644 --- a/spec/models/label_link_spec.rb +++ b/spec/models/label_link_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe LabelLink, models: true do +describe LabelLink do it { expect(build(:label_link)).to be_valid } it { is_expected.to belong_to(:label) } diff --git a/spec/models/label_priority_spec.rb b/spec/models/label_priority_spec.rb index d18c2f7949a..9dcb0f06b20 100644 --- a/spec/models/label_priority_spec.rb +++ b/spec/models/label_priority_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe LabelPriority, models: true do +describe LabelPriority do describe 'relationships' do it { is_expected.to belong_to(:project) } it { is_expected.to belong_to(:label) } diff --git a/spec/models/label_spec.rb b/spec/models/label_spec.rb index 31190fe5685..8914845ea82 100644 --- a/spec/models/label_spec.rb +++ b/spec/models/label_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Label, models: true do +describe Label do describe 'modules' do it { is_expected.to include_module(Referable) } it { is_expected.to include_module(Subscribable) } diff --git a/spec/models/legacy_diff_discussion_spec.rb b/spec/models/legacy_diff_discussion_spec.rb index 6eb4a2aaf39..dae97b69c84 100644 --- a/spec/models/legacy_diff_discussion_spec.rb +++ b/spec/models/legacy_diff_discussion_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe LegacyDiffDiscussion, models: true do +describe LegacyDiffDiscussion do subject { create(:legacy_diff_note_on_merge_request).to_discussion } describe '#reply_attributes' do diff --git a/spec/models/lfs_objects_project_spec.rb b/spec/models/lfs_objects_project_spec.rb index 7bc278e350f..8c74f1f9e86 100644 --- a/spec/models/lfs_objects_project_spec.rb +++ b/spec/models/lfs_objects_project_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe LfsObjectsProject, models: true do +describe LfsObjectsProject do subject { create(:lfs_objects_project, project: project) } let(:project) { create(:empty_project) } diff --git a/spec/models/member_spec.rb b/spec/models/member_spec.rb index 494a88368ba..8bfd70b8d46 100644 --- a/spec/models/member_spec.rb +++ b/spec/models/member_spec.rb @@ -1,12 +1,12 @@ require 'spec_helper' -describe Member, models: true do +describe Member do describe "Associations" do it { is_expected.to belong_to(:user) } end describe "Validation" do - subject { Member.new(access_level: Member::GUEST) } + subject { described_class.new(access_level: Member::GUEST) } it { is_expected.to validate_presence_of(:user) } it { is_expected.to validate_presence_of(:source) } diff --git a/spec/models/members/group_member_spec.rb b/spec/models/members/group_member_spec.rb index 37014268a70..5a3b5b1f517 100644 --- a/spec/models/members/group_member_spec.rb +++ b/spec/models/members/group_member_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe GroupMember, models: true do +describe GroupMember do describe '.access_level_roles' do it 'returns Gitlab::Access.options_with_owner' do expect(described_class.access_level_roles).to eq(Gitlab::Access.options_with_owner) diff --git a/spec/models/members/project_member_spec.rb b/spec/models/members/project_member_spec.rb index cf9c701e8c5..025fb2bf441 100644 --- a/spec/models/members/project_member_spec.rb +++ b/spec/models/members/project_member_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe ProjectMember, models: true do +describe ProjectMember do describe 'associations' do it { is_expected.to belong_to(:project).with_foreign_key(:source_id) } end @@ -139,7 +139,7 @@ describe ProjectMember, models: true do @project_1.team << [@user_1, :developer] @project_2.team << [@user_2, :reporter] - ProjectMember.truncate_teams([@project_1.id, @project_2.id]) + described_class.truncate_teams([@project_1.id, @project_2.id]) end it { expect(@project_1.users).to be_empty } diff --git a/spec/models/merge_request/metrics_spec.rb b/spec/models/merge_request/metrics_spec.rb index 9afed311e27..9353d5c3c8a 100644 --- a/spec/models/merge_request/metrics_spec.rb +++ b/spec/models/merge_request/metrics_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe MergeRequest::Metrics, models: true do +describe MergeRequest::Metrics do subject { create(:merge_request) } describe "when recording the default set of metrics on merge request save" do diff --git a/spec/models/merge_request_diff_commit_spec.rb b/spec/models/merge_request_diff_commit_spec.rb index dbfd1526518..9d4a0ecf8c0 100644 --- a/spec/models/merge_request_diff_commit_spec.rb +++ b/spec/models/merge_request_diff_commit_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe MergeRequestDiffCommit, type: :model do +describe MergeRequestDiffCommit do let(:merge_request) { create(:merge_request) } subject { merge_request.commits.first } diff --git a/spec/models/merge_request_diff_file_spec.rb b/spec/models/merge_request_diff_file_spec.rb index 7276f5b5061..faa47660a74 100644 --- a/spec/models/merge_request_diff_file_spec.rb +++ b/spec/models/merge_request_diff_file_spec.rb @@ -1,8 +1,33 @@ require 'rails_helper' -describe MergeRequestDiffFile, type: :model do +describe MergeRequestDiffFile do + describe '#diff' do + let(:unpacked) { 'unpacked' } + let(:packed) { [unpacked].pack('m0') } + + before do + subject.diff = packed + end + + context 'when the diff is marked as binary' do + before do + subject.binary = true + end + + it 'unpacks from base 64' do + expect(subject.diff).to eq(unpacked) + end + end + + context 'when the diff is not marked as binary' do + it 'returns the raw diff' do + expect(subject.diff).to eq(packed) + end + end + end + describe '#utf8_diff' do - it 'does not raise error when a hash value is in binary' do + it 'does not raise error when the diff is binary' do subject.diff = "\x05\x00\x68\x65\x6c\x6c\x6f" expect { subject.utf8_diff }.not_to raise_error diff --git a/spec/models/merge_request_diff_spec.rb b/spec/models/merge_request_diff_spec.rb index edc2f4bb9f0..0cfaa17676e 100644 --- a/spec/models/merge_request_diff_spec.rb +++ b/spec/models/merge_request_diff_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe MergeRequestDiff, models: true do +describe MergeRequestDiff do describe 'create new record' do subject { create(:merge_request).merge_request_diff } @@ -98,13 +98,22 @@ describe MergeRequestDiff, models: true do end it 'saves empty state' do - allow_any_instance_of(MergeRequestDiff).to receive_message_chain(:compare, :commits) + allow_any_instance_of(described_class).to receive_message_chain(:compare, :commits) .and_return([]) mr_diff = create(:merge_request).merge_request_diff expect(mr_diff.empty?).to be_truthy end + + it 'saves binary diffs correctly' do + path = 'files/images/icn-time-tracking.pdf' + mr_diff = create(:merge_request, source_branch: 'add-pdf-text-binary', target_branch: 'master').merge_request_diff + diff_file = mr_diff.merge_request_diff_files.find_by(new_path: path) + + expect(diff_file).to be_binary + expect(diff_file.diff).to eq(mr_diff.compare.diffs(paths: [path]).to_a.first.diff) + end end describe '#commit_shas' do diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index 6f6a8ac91b8..b2dd02553c1 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe MergeRequest, models: true do +describe MergeRequest do include RepoHelpers subject { create(:merge_request) } diff --git a/spec/models/milestone_spec.rb b/spec/models/milestone_spec.rb index 2649d04bee3..aa376e242e8 100644 --- a/spec/models/milestone_spec.rb +++ b/spec/models/milestone_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Milestone, models: true do +describe Milestone do describe "Validation" do before do allow(subject).to receive(:set_iid).and_return(false) @@ -37,13 +37,13 @@ describe Milestone, models: true do describe "unique milestone title" do context "per project" do it "does not accept the same title in a project twice" do - new_milestone = Milestone.new(project: milestone.project, title: milestone.title) + new_milestone = described_class.new(project: milestone.project, title: milestone.title) expect(new_milestone).not_to be_valid end it "accepts the same title in another project" do project = create(:empty_project) - new_milestone = Milestone.new(project: project, title: milestone.title) + new_milestone = described_class.new(project: project, title: milestone.title) expect(new_milestone).to be_valid end @@ -58,7 +58,7 @@ describe Milestone, models: true do end it "does not accept the same title in a group twice" do - new_milestone = Milestone.new(group: group, title: milestone.title) + new_milestone = described_class.new(group: group, title: milestone.title) expect(new_milestone).not_to be_valid end @@ -66,7 +66,7 @@ describe Milestone, models: true do it "does not accept the same title of a child project milestone" do create(:milestone, project: group.projects.first) - new_milestone = Milestone.new(group: group, title: milestone.title) + new_milestone = described_class.new(group: group, title: milestone.title) expect(new_milestone).not_to be_valid end @@ -214,7 +214,7 @@ describe Milestone, models: true do # The call to `#try` is because this returns a relation with a Postgres DB, # and an array of IDs with a MySQL DB. - let(:milestone_ids) { Milestone.upcoming_ids_by_projects(projects).map { |id| id.try(:id) || id } } + let(:milestone_ids) { described_class.upcoming_ids_by_projects(projects).map { |id| id.try(:id) || id } } it 'returns the next upcoming open milestone ID for each project' do expect(milestone_ids).to contain_exactly(current_milestone_project_1.id, current_milestone_project_2.id) diff --git a/spec/models/namespace_spec.rb b/spec/models/namespace_spec.rb index a4090b37f65..f12fe226e6b 100644 --- a/spec/models/namespace_spec.rb +++ b/spec/models/namespace_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Namespace, models: true do +describe Namespace do let!(:namespace) { create(:namespace) } describe 'associations' do @@ -133,7 +133,7 @@ describe Namespace, models: true do it "sums all project storage counters in the namespace" do project1 project2 - statistics = Namespace.with_statistics.find(namespace.id) + statistics = described_class.with_statistics.find(namespace.id) expect(statistics.storage_size).to eq 666 expect(statistics.repository_size).to eq 111 @@ -142,7 +142,7 @@ describe Namespace, models: true do end it "correctly handles namespaces without projects" do - statistics = Namespace.with_statistics.find(namespace.id) + statistics = described_class.with_statistics.find(namespace.id) expect(statistics.storage_size).to eq 0 expect(statistics.repository_size).to eq 0 @@ -151,7 +151,7 @@ describe Namespace, models: true do end end - describe '#move_dir', repository: true do + describe '#move_dir' do before do @namespace = create :namespace @project = create(:project_empty_repo, namespace: @namespace) @@ -230,7 +230,7 @@ describe Namespace, models: true do end end - describe '#rm_dir', 'callback', repository: true do + describe '#rm_dir', 'callback' do let!(:project) { create(:project_empty_repo, namespace: namespace) } let(:repository_storage_path) { Gitlab.config.repositories.storages.default['path'] } let(:path_in_dir) { File.join(repository_storage_path, namespace.full_path) } @@ -286,9 +286,9 @@ describe Namespace, models: true do @namespace = create(:namespace, name: 'WoW', path: 'woW') end - it { expect(Namespace.find_by_path_or_name('wow')).to eq(@namespace) } - it { expect(Namespace.find_by_path_or_name('WOW')).to eq(@namespace) } - it { expect(Namespace.find_by_path_or_name('unknown')).to eq(nil) } + it { expect(described_class.find_by_path_or_name('wow')).to eq(@namespace) } + it { expect(described_class.find_by_path_or_name('WOW')).to eq(@namespace) } + it { expect(described_class.find_by_path_or_name('unknown')).to eq(nil) } end describe ".clean_path" do @@ -296,8 +296,8 @@ describe Namespace, models: true do let!(:namespace) { create(:namespace, path: "JohnGitLab-etc1") } it "cleans the path and makes sure it's available" do - expect(Namespace.clean_path("-john+gitlab-ETC%.git@gmail.com")).to eq("johngitlab-ETC2") - expect(Namespace.clean_path("--%+--valid_*&%name=.git.%.atom.atom.@email.com")).to eq("valid_name") + expect(described_class.clean_path("-john+gitlab-ETC%.git@gmail.com")).to eq("johngitlab-ETC2") + expect(described_class.clean_path("--%+--valid_*&%name=.git.%.atom.atom.@email.com")).to eq("valid_name") end end diff --git a/spec/models/network/graph_spec.rb b/spec/models/network/graph_spec.rb index 0fe8a591a45..c364dd6643b 100644 --- a/spec/models/network/graph_spec.rb +++ b/spec/models/network/graph_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Network::Graph, models: true do +describe Network::Graph do let(:project) { create(:project, :repository) } let!(:note_on_commit) { create(:note_on_commit, project: project) } diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb index e2b80cb6e61..cbe6d42ef53 100644 --- a/spec/models/note_spec.rb +++ b/spec/models/note_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Note, models: true do +describe Note do include RepoHelpers describe 'associations' do @@ -525,7 +525,7 @@ describe Note, models: true do it "has a discussion id" do # The discussion_id is set in `after_initialize`, so `reload` won't work - reloaded_note = Note.find(note.id) + reloaded_note = described_class.find(note.id) expect(reloaded_note.discussion_id).not_to be_nil expect(reloaded_note.discussion_id).to match(/\A\h{40}\z/) diff --git a/spec/models/notification_setting_spec.rb b/spec/models/notification_setting_spec.rb index 76a7b07949f..07e296424ca 100644 --- a/spec/models/notification_setting_spec.rb +++ b/spec/models/notification_setting_spec.rb @@ -1,13 +1,13 @@ require 'rails_helper' -RSpec.describe NotificationSetting, type: :model do +RSpec.describe NotificationSetting do describe "Associations" do it { is_expected.to belong_to(:user) } it { is_expected.to belong_to(:source) } end describe "Validation" do - subject { NotificationSetting.new(source_id: 1, source_type: 'Project') } + subject { described_class.new(source_id: 1, source_type: 'Project') } it { is_expected.to validate_presence_of(:user) } it { is_expected.to validate_presence_of(:level) } @@ -22,7 +22,7 @@ RSpec.describe NotificationSetting, type: :model do context "events" do let(:user) { create(:user) } - let(:notification_setting) { NotificationSetting.new(source_id: 1, source_type: 'Project', user_id: user.id) } + let(:notification_setting) { described_class.new(source_id: 1, source_type: 'Project', user_id: user.id) } before do notification_setting.level = "custom" diff --git a/spec/models/pages_domain_spec.rb b/spec/models/pages_domain_spec.rb index d4a777a9bd9..7d835511dfb 100644 --- a/spec/models/pages_domain_spec.rb +++ b/spec/models/pages_domain_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe PagesDomain, models: true do +describe PagesDomain do describe 'associations' do it { is_expected.to belong_to(:project) } end diff --git a/spec/models/personal_access_token_spec.rb b/spec/models/personal_access_token_spec.rb index fa781195608..b2f2a3ce914 100644 --- a/spec/models/personal_access_token_spec.rb +++ b/spec/models/personal_access_token_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe PersonalAccessToken, models: true do +describe PersonalAccessToken do describe '.build' do let(:personal_access_token) { build(:personal_access_token) } let(:invalid_personal_access_token) { build(:personal_access_token, :invalid) } diff --git a/spec/models/project_label_spec.rb b/spec/models/project_label_spec.rb index 9cdbfa44e5b..add7e85f388 100644 --- a/spec/models/project_label_spec.rb +++ b/spec/models/project_label_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe ProjectLabel, models: true do +describe ProjectLabel do describe 'relationships' do it { is_expected.to belong_to(:project) } end diff --git a/spec/models/project_services/asana_service_spec.rb b/spec/models/project_services/asana_service_spec.rb index 95c35162d96..4684c970885 100644 --- a/spec/models/project_services/asana_service_spec.rb +++ b/spec/models/project_services/asana_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe AsanaService, models: true do +describe AsanaService do describe 'Associations' do it { is_expected.to belong_to :project } it { is_expected.to have_one :service_hook } @@ -35,7 +35,7 @@ describe AsanaService, models: true do end before do - @asana = AsanaService.new + @asana = described_class.new allow(@asana).to receive_messages( project: project, project_id: project.id, diff --git a/spec/models/project_services/assembla_service_spec.rb b/spec/models/project_services/assembla_service_spec.rb index 96f00af898e..5cb6d63659e 100644 --- a/spec/models/project_services/assembla_service_spec.rb +++ b/spec/models/project_services/assembla_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe AssemblaService, models: true do +describe AssemblaService do describe "Associations" do it { is_expected.to belong_to :project } it { is_expected.to have_one :service_hook } @@ -11,7 +11,7 @@ describe AssemblaService, models: true do let(:project) { create(:project, :repository) } before do - @assembla_service = AssemblaService.new + @assembla_service = described_class.new allow(@assembla_service).to receive_messages( project_id: project.id, project: project, diff --git a/spec/models/project_services/bamboo_service_spec.rb b/spec/models/project_services/bamboo_service_spec.rb index 99190d763f2..82f02126de1 100644 --- a/spec/models/project_services/bamboo_service_spec.rb +++ b/spec/models/project_services/bamboo_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe BambooService, :use_clean_rails_memory_store_caching, models: true do +describe BambooService, :use_clean_rails_memory_store_caching do include ReactiveCachingHelpers let(:bamboo_url) { 'http://gitlab.com/bamboo' } diff --git a/spec/models/project_services/bugzilla_service_spec.rb b/spec/models/project_services/bugzilla_service_spec.rb index 5f17bbde390..43f7bcb1a19 100644 --- a/spec/models/project_services/bugzilla_service_spec.rb +++ b/spec/models/project_services/bugzilla_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe BugzillaService, models: true do +describe BugzillaService 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/buildkite_service_spec.rb b/spec/models/project_services/buildkite_service_spec.rb index b4ee6691e67..3f7eb33e08a 100644 --- a/spec/models/project_services/buildkite_service_spec.rb +++ b/spec/models/project_services/buildkite_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe BuildkiteService, :use_clean_rails_memory_store_caching, models: true do +describe BuildkiteService, :use_clean_rails_memory_store_caching do include ReactiveCachingHelpers let(:project) { create(:empty_project) } diff --git a/spec/models/project_services/campfire_service_spec.rb b/spec/models/project_services/campfire_service_spec.rb index 56ff3596190..ed8347edffd 100644 --- a/spec/models/project_services/campfire_service_spec.rb +++ b/spec/models/project_services/campfire_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe CampfireService, models: true do +describe CampfireService do describe 'Associations' do it { is_expected.to belong_to :project } it { is_expected.to have_one :service_hook } @@ -29,7 +29,7 @@ describe CampfireService, models: true do let(:project) { create(:project, :repository) } before do - @campfire_service = CampfireService.new + @campfire_service = described_class.new allow(@campfire_service).to receive_messages( project_id: project.id, project: project, diff --git a/spec/models/project_services/chat_message/issue_message_spec.rb b/spec/models/project_services/chat_message/issue_message_spec.rb index c159ab00ab1..4bb1db684e6 100644 --- a/spec/models/project_services/chat_message/issue_message_spec.rb +++ b/spec/models/project_services/chat_message/issue_message_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe ChatMessage::IssueMessage, models: true do +describe ChatMessage::IssueMessage do subject { described_class.new(args) } let(:args) do diff --git a/spec/models/project_services/chat_message/merge_message_spec.rb b/spec/models/project_services/chat_message/merge_message_spec.rb index 61f17031172..b600a36f578 100644 --- a/spec/models/project_services/chat_message/merge_message_spec.rb +++ b/spec/models/project_services/chat_message/merge_message_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe ChatMessage::MergeMessage, models: true do +describe ChatMessage::MergeMessage do subject { described_class.new(args) } let(:args) do diff --git a/spec/models/project_services/chat_message/note_message_spec.rb b/spec/models/project_services/chat_message/note_message_spec.rb index 7996536218a..a09c2f9935c 100644 --- a/spec/models/project_services/chat_message/note_message_spec.rb +++ b/spec/models/project_services/chat_message/note_message_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe ChatMessage::NoteMessage, models: true do +describe ChatMessage::NoteMessage do subject { described_class.new(args) } let(:color) { '#345' } diff --git a/spec/models/project_services/chat_message/push_message_spec.rb b/spec/models/project_services/chat_message/push_message_spec.rb index c794f659c41..19c2862264f 100644 --- a/spec/models/project_services/chat_message/push_message_spec.rb +++ b/spec/models/project_services/chat_message/push_message_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe ChatMessage::PushMessage, models: true do +describe ChatMessage::PushMessage do subject { described_class.new(args) } let(:args) do diff --git a/spec/models/project_services/chat_message/wiki_page_message_spec.rb b/spec/models/project_services/chat_message/wiki_page_message_spec.rb index 17355c1e6f1..c4adee4f489 100644 --- a/spec/models/project_services/chat_message/wiki_page_message_spec.rb +++ b/spec/models/project_services/chat_message/wiki_page_message_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe ChatMessage::WikiPageMessage, models: true do +describe ChatMessage::WikiPageMessage do subject { described_class.new(args) } let(:args) do diff --git a/spec/models/project_services/chat_notification_service_spec.rb b/spec/models/project_services/chat_notification_service_spec.rb index 8fbe42248ae..413ceed73bf 100644 --- a/spec/models/project_services/chat_notification_service_spec.rb +++ b/spec/models/project_services/chat_notification_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe ChatNotificationService, models: true do +describe ChatNotificationService do describe 'Associations' do before do allow(subject).to receive(:activated?).and_return(true) diff --git a/spec/models/project_services/custom_issue_tracker_service_spec.rb b/spec/models/project_services/custom_issue_tracker_service_spec.rb index 9e574762232..7e1b1a4f2af 100644 --- a/spec/models/project_services/custom_issue_tracker_service_spec.rb +++ b/spec/models/project_services/custom_issue_tracker_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe CustomIssueTrackerService, models: true do +describe CustomIssueTrackerService 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 c9ac256ff38..5b0f24ce306 100644 --- a/spec/models/project_services/drone_ci_service_spec.rb +++ b/spec/models/project_services/drone_ci_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe DroneCiService, :use_clean_rails_memory_store_caching, models: true do +describe DroneCiService, :use_clean_rails_memory_store_caching do include ReactiveCachingHelpers describe 'associations' do diff --git a/spec/models/project_services/external_wiki_service_spec.rb b/spec/models/project_services/external_wiki_service_spec.rb index ef10df9e092..22cd9d5e31e 100644 --- a/spec/models/project_services/external_wiki_service_spec.rb +++ b/spec/models/project_services/external_wiki_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe ExternalWikiService, models: true do +describe ExternalWikiService do include ExternalWikiHelper describe "Associations" do it { is_expected.to belong_to :project } diff --git a/spec/models/project_services/flowdock_service_spec.rb b/spec/models/project_services/flowdock_service_spec.rb index 56ace04dd58..5e8e880985e 100644 --- a/spec/models/project_services/flowdock_service_spec.rb +++ b/spec/models/project_services/flowdock_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe FlowdockService, models: true do +describe FlowdockService do describe "Associations" do it { is_expected.to belong_to :project } it { is_expected.to have_one :service_hook } @@ -29,7 +29,7 @@ describe FlowdockService, models: true do let(:project) { create(:project, :repository) } before do - @flowdock_service = FlowdockService.new + @flowdock_service = described_class.new allow(@flowdock_service).to receive_messages( project_id: project.id, project: project, diff --git a/spec/models/project_services/gemnasium_service_spec.rb b/spec/models/project_services/gemnasium_service_spec.rb index 65c9e714bd1..4c61bc0af95 100644 --- a/spec/models/project_services/gemnasium_service_spec.rb +++ b/spec/models/project_services/gemnasium_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe GemnasiumService, models: true do +describe GemnasiumService do describe "Associations" do it { is_expected.to belong_to :project } it { is_expected.to have_one :service_hook } @@ -31,7 +31,7 @@ describe GemnasiumService, models: true do let(:project) { create(:project, :repository) } before do - @gemnasium_service = GemnasiumService.new + @gemnasium_service = described_class.new allow(@gemnasium_service).to receive_messages( project_id: project.id, project: project, 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 d45e0a441d4..d19dab8fd39 100644 --- a/spec/models/project_services/gitlab_issue_tracker_service_spec.rb +++ b/spec/models/project_services/gitlab_issue_tracker_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe GitlabIssueTrackerService, models: true do +describe GitlabIssueTrackerService do describe "Associations" do it { is_expected.to belong_to :project } it { is_expected.to have_one :service_hook } @@ -27,7 +27,7 @@ describe GitlabIssueTrackerService, models: true do context 'with absolute urls' do before do - allow(GitlabIssueTrackerService).to receive(:default_url_options).and_return(script_name: "/gitlab/root") + allow(described_class).to receive(:default_url_options).and_return(script_name: "/gitlab/root") end it 'gives the correct path' do @@ -39,7 +39,7 @@ describe GitlabIssueTrackerService, models: true do context 'with relative urls' do before do - allow(GitlabIssueTrackerService).to receive(:default_url_options).and_return(script_name: "/gitlab/root") + allow(described_class).to receive(:default_url_options).and_return(script_name: "/gitlab/root") end it 'gives the correct path' do diff --git a/spec/models/project_services/hipchat_service_spec.rb b/spec/models/project_services/hipchat_service_spec.rb index c7c8e9651ab..7614bb897e8 100644 --- a/spec/models/project_services/hipchat_service_spec.rb +++ b/spec/models/project_services/hipchat_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe HipchatService, models: true do +describe HipchatService do describe "Associations" do it { is_expected.to belong_to :project } it { is_expected.to have_one :service_hook } @@ -25,7 +25,7 @@ describe HipchatService, models: true do end describe "Execute" do - let(:hipchat) { HipchatService.new } + let(:hipchat) { described_class.new } let(:user) { create(:user) } let(:project) { create(:project, :repository) } let(:api_url) { 'https://hipchat.example.com/v2/room/123456/notification?auth_token=verySecret' } diff --git a/spec/models/project_services/irker_service_spec.rb b/spec/models/project_services/irker_service_spec.rb index a5c4938b54e..cb9ca76fc3f 100644 --- a/spec/models/project_services/irker_service_spec.rb +++ b/spec/models/project_services/irker_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' require 'socket' require 'json' -describe IrkerService, models: true do +describe IrkerService do describe 'Associations' do it { is_expected.to belong_to :project } it { is_expected.to have_one :service_hook } @@ -27,7 +27,7 @@ describe IrkerService, models: true do end describe 'Execute' do - let(:irker) { IrkerService.new } + let(:irker) { described_class.new } let(:user) { create(:user) } let(:project) { create(:project, :repository) } let(:sample_data) do diff --git a/spec/models/project_services/issue_tracker_service_spec.rb b/spec/models/project_services/issue_tracker_service_spec.rb index 869b25b933b..e6a1752576b 100644 --- a/spec/models/project_services/issue_tracker_service_spec.rb +++ b/spec/models/project_services/issue_tracker_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe IssueTrackerService, models: true do +describe IssueTrackerService do describe 'Validations' do let(:project) { create :project } diff --git a/spec/models/project_services/jira_service_spec.rb b/spec/models/project_services/jira_service_spec.rb index d7d09808a98..8f34b44930e 100644 --- a/spec/models/project_services/jira_service_spec.rb +++ b/spec/models/project_services/jira_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe JiraService, models: true do +describe JiraService do include Gitlab::Routing describe "Associations" do @@ -78,7 +78,7 @@ describe JiraService, models: true do let(:merge_request) { create(:merge_request) } before do - @jira_service = JiraService.new + @jira_service = described_class.new allow(@jira_service).to receive_messages( project_id: project.id, project: project, @@ -167,7 +167,7 @@ describe JiraService, models: true do stub_config_setting(relative_url_root: '/gitlab') stub_config_setting(url: Settings.send(:build_gitlab_url)) - allow(JiraService).to receive(:default_url_options) do + allow(described_class).to receive(:default_url_options) do { script_name: '/gitlab' } end @@ -197,21 +197,38 @@ describe JiraService, models: true do ) end - def test_settings(api_url) + def test_settings(api_url = nil) + api_url ||= 'jira.example.com' test_url = "http://#{api_url}/rest/api/2/serverInfo" WebMock.stub_request(:get, test_url).with(basic_auth: %w(jira_username jira_password)).to_return(body: { url: 'http://url' }.to_json ) - jira_service.test_settings + jira_service.test(nil) end - it 'tries to get JIRA project with URL when API URL not set' do - test_settings('jira.example.com') + context 'when the test succeeds' do + it 'tries to get JIRA project with URL when API URL not set' do + test_settings('jira.example.com') + end + + it 'returns correct result' do + expect(test_settings).to eq( { success: true, result: { 'url' => 'http://url' } }) + end + + it 'tries to get JIRA project with API URL if set' do + jira_service.update(api_url: 'http://jira.api.com') + test_settings('jira.api.com') + end end - it 'tries to get JIRA project with API URL if set' do - jira_service.update(api_url: 'http://jira.api.com') - test_settings('jira.api.com') + context 'when the test fails' do + it 'returns result with the error' do + test_url = 'http://jira.example.com/rest/api/2/serverInfo' + WebMock.stub_request(:get, test_url).with(basic_auth: %w(jira_username jira_password)) + .to_raise(JIRA::HTTPError.new(double(message: 'Some specific failure.'))) + + expect(jira_service.test(nil)).to eq( { success: false, result: 'Some specific failure.' }) + end end end @@ -220,7 +237,7 @@ describe JiraService, models: true do context "when a password was previously set" do before do - @jira_service = JiraService.create!( + @jira_service = described_class.create!( project: project, properties: { url: 'http://jira.example.com/web', @@ -301,7 +318,7 @@ describe JiraService, models: true do context 'when no password was previously set' do before do - @jira_service = JiraService.create( + @jira_service = described_class.create( project: project, properties: { url: 'http://jira.example.com/rest/api/2', diff --git a/spec/models/project_services/kubernetes_service_spec.rb b/spec/models/project_services/kubernetes_service_spec.rb index b66bb5321ab..55b96a0c12e 100644 --- a/spec/models/project_services/kubernetes_service_spec.rb +++ b/spec/models/project_services/kubernetes_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe KubernetesService, :use_clean_rails_memory_store_caching, models: true do +describe KubernetesService, :use_clean_rails_memory_store_caching do include KubernetesHelpers include ReactiveCachingHelpers diff --git a/spec/models/project_services/mattermost_service_spec.rb b/spec/models/project_services/mattermost_service_spec.rb index 490d6aedffc..10c62ca55a7 100644 --- a/spec/models/project_services/mattermost_service_spec.rb +++ b/spec/models/project_services/mattermost_service_spec.rb @@ -1,5 +1,5 @@ require 'spec_helper' -describe MattermostService, models: true do +describe MattermostService do it_behaves_like "slack or mattermost notifications" end diff --git a/spec/models/project_services/mattermost_slash_commands_service_spec.rb b/spec/models/project_services/mattermost_slash_commands_service_spec.rb index fa38d23e82f..4c21c8b88bd 100644 --- a/spec/models/project_services/mattermost_slash_commands_service_spec.rb +++ b/spec/models/project_services/mattermost_slash_commands_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe MattermostSlashCommandsService, :models do +describe MattermostSlashCommandsService do it_behaves_like "chat slash commands service" context 'Mattermost API' do diff --git a/spec/models/project_services/microsoft_teams_service_spec.rb b/spec/models/project_services/microsoft_teams_service_spec.rb index fb95c4cda35..f89be20ad78 100644 --- a/spec/models/project_services/microsoft_teams_service_spec.rb +++ b/spec/models/project_services/microsoft_teams_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe MicrosoftTeamsService, models: true do +describe MicrosoftTeamsService do let(:chat_service) { described_class.new } let(:webhook_url) { 'https://example.gitlab.com/' } diff --git a/spec/models/project_services/pivotaltracker_service_spec.rb b/spec/models/project_services/pivotaltracker_service_spec.rb index f4c1a9c94b6..f7d2372eca2 100644 --- a/spec/models/project_services/pivotaltracker_service_spec.rb +++ b/spec/models/project_services/pivotaltracker_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe PivotaltrackerService, models: true do +describe PivotaltrackerService do describe 'Associations' do it { is_expected.to belong_to :project } it { is_expected.to have_one :service_hook } @@ -26,7 +26,7 @@ describe PivotaltrackerService, models: true do describe 'Execute' do let(:service) do - PivotaltrackerService.new.tap do |service| + described_class.new.tap do |service| service.token = 'secret_api_token' end end diff --git a/spec/models/project_services/prometheus_service_spec.rb b/spec/models/project_services/prometheus_service_spec.rb index 3fb134ec3b7..bf39e8d7a39 100644 --- a/spec/models/project_services/prometheus_service_spec.rb +++ b/spec/models/project_services/prometheus_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe PrometheusService, :use_clean_rails_memory_store_caching, models: true do +describe PrometheusService, :use_clean_rails_memory_store_caching do include PrometheusHelpers include ReactiveCachingHelpers diff --git a/spec/models/project_services/pushover_service_spec.rb b/spec/models/project_services/pushover_service_spec.rb index 9171d9604ee..54b8c658ff6 100644 --- a/spec/models/project_services/pushover_service_spec.rb +++ b/spec/models/project_services/pushover_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe PushoverService, models: true do +describe PushoverService do describe 'Associations' do it { is_expected.to belong_to :project } it { is_expected.to have_one :service_hook } @@ -29,7 +29,7 @@ describe PushoverService, models: true do end describe 'Execute' do - let(:pushover) { PushoverService.new } + let(:pushover) { described_class.new } let(:user) { create(:user) } let(:project) { create(:project, :repository) } let(:sample_data) do diff --git a/spec/models/project_services/redmine_service_spec.rb b/spec/models/project_services/redmine_service_spec.rb index 441b3f896ca..2ac14eab5e1 100644 --- a/spec/models/project_services/redmine_service_spec.rb +++ b/spec/models/project_services/redmine_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe RedmineService, models: true do +describe RedmineService 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_spec.rb b/spec/models/project_services/slack_service_spec.rb index 9a3ecc66d83..13cf4d1915e 100644 --- a/spec/models/project_services/slack_service_spec.rb +++ b/spec/models/project_services/slack_service_spec.rb @@ -1,5 +1,5 @@ require 'spec_helper' -describe SlackService, models: true do +describe SlackService do it_behaves_like "slack or mattermost notifications" end diff --git a/spec/models/project_services/slack_slash_commands_service_spec.rb b/spec/models/project_services/slack_slash_commands_service_spec.rb index 5766aa340e2..aea674c4f6b 100644 --- a/spec/models/project_services/slack_slash_commands_service_spec.rb +++ b/spec/models/project_services/slack_slash_commands_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe SlackSlashCommandsService, :models do +describe SlackSlashCommandsService do it_behaves_like "chat slash commands service" describe '#trigger' do diff --git a/spec/models/project_services/teamcity_service_spec.rb b/spec/models/project_services/teamcity_service_spec.rb index 3f3a74d0f96..47fd0c79e0b 100644 --- a/spec/models/project_services/teamcity_service_spec.rb +++ b/spec/models/project_services/teamcity_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe TeamcityService, :use_clean_rails_memory_store_caching, models: true do +describe TeamcityService, :use_clean_rails_memory_store_caching do include ReactiveCachingHelpers let(:teamcity_url) { 'http://gitlab.com/teamcity' } diff --git a/spec/models/project_snippet_spec.rb b/spec/models/project_snippet_spec.rb index 5fe4885eeb4..1b439bcfad1 100644 --- a/spec/models/project_snippet_spec.rb +++ b/spec/models/project_snippet_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe ProjectSnippet, models: true do +describe ProjectSnippet 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 8d916b79b13..473b7a88d61 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Project, models: true do +describe Project do describe 'associations' do it { is_expected.to belong_to(:group) } it { is_expected.to belong_to(:namespace) } @@ -77,7 +77,7 @@ describe Project, models: true do context 'after initialized' do it "has a project_feature" do - expect(Project.new.project_feature).to be_present + expect(described_class.new.project_feature).to be_present end end @@ -438,7 +438,7 @@ describe Project, models: true do end it 'returns valid url to repo' do - project = Project.new(path: 'somewhere') + project = described_class.new(path: 'somewhere') expect(project.url_to_repo).to eq(Gitlab.config.gitlab_shell.ssh_path_prefix + 'somewhere.git') end @@ -917,7 +917,7 @@ describe Project, models: true do end describe '.with_shared_runners' do - subject { Project.with_shared_runners } + subject { described_class.with_shared_runners } context 'when shared runners are enabled for project' do let!(:project) { create(:empty_project, shared_runners_enabled: true) } @@ -942,10 +942,10 @@ describe Project, models: true do let!(:project2) { create(:empty_project, :public, group: group) } it 'returns total project count' do - expect(Project).to receive(:count).once.and_call_original + expect(described_class).to receive(:count).once.and_call_original 3.times do - expect(Project.cached_count).to eq(2) + expect(described_class.cached_count).to eq(2) end end end @@ -990,7 +990,7 @@ describe Project, models: true do user1.toggle_star(project1) user2.toggle_star(project2) - expect(Project.starred_by(user1)).to contain_exactly(project1) + expect(described_class.starred_by(user1)).to contain_exactly(project1) end end @@ -2012,7 +2012,7 @@ describe Project, models: true do let!(:path) { project1.namespace.full_path } it 'returns correct project' do - expect(Project.inside_path(path)).to eq([project1]) + expect(described_class.inside_path(path)).to eq([project1]) end end @@ -2216,7 +2216,7 @@ describe Project, models: true do context 'with a user' do let(:projects) do - Project.all.public_or_visible_to_user(user) + described_class.all.public_or_visible_to_user(user) end it 'includes projects the user has access to' do @@ -2230,7 +2230,7 @@ describe Project, models: true do context 'without a user' do it 'only includes public projects' do - projects = Project.all.public_or_visible_to_user + projects = described_class.all.public_or_visible_to_user expect(projects).to eq([public_project]) end diff --git a/spec/models/project_statistics_spec.rb b/spec/models/project_statistics_spec.rb index c5ffbda9821..be1b37730b1 100644 --- a/spec/models/project_statistics_spec.rb +++ b/spec/models/project_statistics_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe ProjectStatistics, models: true do +describe ProjectStatistics do let(:project) { create :empty_project } let(:statistics) { project.statistics } diff --git a/spec/models/project_team_spec.rb b/spec/models/project_team_spec.rb index 49f2f8c0ad1..68228a038a8 100644 --- a/spec/models/project_team_spec.rb +++ b/spec/models/project_team_spec.rb @@ -1,6 +1,6 @@ require "spec_helper" -describe ProjectTeam, models: true do +describe ProjectTeam 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 79ab50c1234..c6ceb092810 100644 --- a/spec/models/project_wiki_spec.rb +++ b/spec/models/project_wiki_spec.rb @@ -1,11 +1,11 @@ require "spec_helper" -describe ProjectWiki, models: true do +describe ProjectWiki do let(:project) { create(:empty_project) } let(:repository) { project.repository } let(:user) { project.owner } let(:gitlab_shell) { Gitlab::Shell.new } - let(:project_wiki) { ProjectWiki.new(project, user) } + let(:project_wiki) { described_class.new(project, user) } subject { project_wiki } @@ -21,7 +21,7 @@ describe ProjectWiki, models: true do describe '#web_url' do it 'returns the full web URL to the wiki' do - expect(subject.web_url).to match("https?://[^\/]+/#{project.path_with_namespace}/wikis/home") + expect(subject.web_url).to eq("#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}/wikis/home") end end diff --git a/spec/models/protectable_dropdown_spec.rb b/spec/models/protectable_dropdown_spec.rb index 4c9bade592b..5c5dcd9f5c9 100644 --- a/spec/models/protectable_dropdown_spec.rb +++ b/spec/models/protectable_dropdown_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe ProtectableDropdown, models: true do +describe ProtectableDropdown do let(:project) { create(:project, :repository) } let(:subject) { described_class.new(project, :branches) } diff --git a/spec/models/protected_branch/merge_access_level_spec.rb b/spec/models/protected_branch/merge_access_level_spec.rb index 1e7242e9fa8..f70503eadbc 100644 --- a/spec/models/protected_branch/merge_access_level_spec.rb +++ b/spec/models/protected_branch/merge_access_level_spec.rb @@ -1,5 +1,5 @@ require 'spec_helper' -describe ProtectedBranch::MergeAccessLevel, :models do +describe ProtectedBranch::MergeAccessLevel do it { is_expected.to validate_inclusion_of(:access_level).in_array([Gitlab::Access::MASTER, Gitlab::Access::DEVELOPER, Gitlab::Access::NO_ACCESS]) } end diff --git a/spec/models/protected_branch/push_access_level_spec.rb b/spec/models/protected_branch/push_access_level_spec.rb index de68351198c..f161f345761 100644 --- a/spec/models/protected_branch/push_access_level_spec.rb +++ b/spec/models/protected_branch/push_access_level_spec.rb @@ -1,5 +1,5 @@ require 'spec_helper' -describe ProtectedBranch::PushAccessLevel, :models do +describe ProtectedBranch::PushAccessLevel do it { is_expected.to validate_inclusion_of(:access_level).in_array([Gitlab::Access::MASTER, Gitlab::Access::DEVELOPER, Gitlab::Access::NO_ACCESS]) } end diff --git a/spec/models/protected_branch_spec.rb b/spec/models/protected_branch_spec.rb index ca347cf92c9..a54af3bfe59 100644 --- a/spec/models/protected_branch_spec.rb +++ b/spec/models/protected_branch_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe ProtectedBranch, models: true do +describe ProtectedBranch do subject { build_stubbed(:protected_branch) } describe 'Associations' do @@ -101,17 +101,17 @@ describe ProtectedBranch, models: true do production = create(:protected_branch, name: "production") staging = create(:protected_branch, name: "staging") - expect(ProtectedBranch.matching("production")).to include(production) - expect(ProtectedBranch.matching("production")).not_to include(staging) + expect(described_class.matching("production")).to include(production) + expect(described_class.matching("production")).not_to include(staging) end it "accepts a list of protected branches to search from, so as to avoid a DB call" do production = build(:protected_branch, name: "production") staging = build(:protected_branch, name: "staging") - expect(ProtectedBranch.matching("production")).to be_empty - expect(ProtectedBranch.matching("production", protected_refs: [production, staging])).to include(production) - expect(ProtectedBranch.matching("production", protected_refs: [production, staging])).not_to include(staging) + expect(described_class.matching("production")).to be_empty + expect(described_class.matching("production", protected_refs: [production, staging])).to include(production) + expect(described_class.matching("production", protected_refs: [production, staging])).not_to include(staging) end end @@ -120,17 +120,17 @@ describe ProtectedBranch, models: true do production = create(:protected_branch, name: "production/*") staging = create(:protected_branch, name: "staging/*") - expect(ProtectedBranch.matching("production/some-branch")).to include(production) - expect(ProtectedBranch.matching("production/some-branch")).not_to include(staging) + expect(described_class.matching("production/some-branch")).to include(production) + expect(described_class.matching("production/some-branch")).not_to include(staging) end it "accepts a list of protected branches to search from, so as to avoid a DB call" do production = build(:protected_branch, name: "production/*") staging = build(:protected_branch, name: "staging/*") - expect(ProtectedBranch.matching("production/some-branch")).to be_empty - expect(ProtectedBranch.matching("production/some-branch", protected_refs: [production, staging])).to include(production) - expect(ProtectedBranch.matching("production/some-branch", protected_refs: [production, staging])).not_to include(staging) + expect(described_class.matching("production/some-branch")).to be_empty + expect(described_class.matching("production/some-branch", protected_refs: [production, staging])).to include(production) + expect(described_class.matching("production/some-branch", protected_refs: [production, staging])).not_to include(staging) end end end @@ -142,23 +142,23 @@ describe ProtectedBranch, models: true do it 'returns true when the branch matches a protected branch via direct match' do create(:protected_branch, project: project, name: "foo") - expect(ProtectedBranch.protected?(project, 'foo')).to eq(true) + expect(described_class.protected?(project, 'foo')).to eq(true) end it 'returns true when the branch matches a protected branch via wildcard match' do create(:protected_branch, project: project, name: "production/*") - expect(ProtectedBranch.protected?(project, 'production/some-branch')).to eq(true) + expect(described_class.protected?(project, 'production/some-branch')).to eq(true) end it 'returns false when the branch does not match a protected branch via direct match' do - expect(ProtectedBranch.protected?(project, 'foo')).to eq(false) + expect(described_class.protected?(project, 'foo')).to eq(false) end it 'returns false when the branch does not match a protected branch via wildcard match' do create(:protected_branch, project: project, name: "production/*") - expect(ProtectedBranch.protected?(project, 'staging/some-branch')).to eq(false) + expect(described_class.protected?(project, 'staging/some-branch')).to eq(false) end end @@ -168,25 +168,25 @@ describe ProtectedBranch, models: true do it 'returns false when default_protected_branch is unprotected' do stub_application_setting(default_branch_protection: Gitlab::Access::PROTECTION_NONE) - expect(ProtectedBranch.protected?(project, 'master')).to be false + expect(described_class.protected?(project, 'master')).to be false end it 'returns false when default_protected_branch lets developers push' do stub_application_setting(default_branch_protection: Gitlab::Access::PROTECTION_DEV_CAN_PUSH) - expect(ProtectedBranch.protected?(project, 'master')).to be false + expect(described_class.protected?(project, 'master')).to be false end it 'returns true when default_branch_protection does not let developers push but let developer merge branches' do stub_application_setting(default_branch_protection: Gitlab::Access::PROTECTION_DEV_CAN_MERGE) - expect(ProtectedBranch.protected?(project, 'master')).to be true + expect(described_class.protected?(project, 'master')).to be true end it 'returns true when default_branch_protection is in full protection' do stub_application_setting(default_branch_protection: Gitlab::Access::PROTECTION_FULL) - expect(ProtectedBranch.protected?(project, 'master')).to be true + expect(described_class.protected?(project, 'master')).to be true end end end diff --git a/spec/models/protected_tag_spec.rb b/spec/models/protected_tag_spec.rb index 51353852a93..e5a0f6ec23f 100644 --- a/spec/models/protected_tag_spec.rb +++ b/spec/models/protected_tag_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe ProtectedTag, models: true do +describe ProtectedTag do describe 'Associations' do it { is_expected.to belong_to(:project) } end diff --git a/spec/models/redirect_route_spec.rb b/spec/models/redirect_route_spec.rb index a97af28cb8e..80943877095 100644 --- a/spec/models/redirect_route_spec.rb +++ b/spec/models/redirect_route_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe RedirectRoute, models: true do +describe RedirectRoute do let(:group) { create(:group) } let!(:redirect_route) { group.redirect_routes.create(path: 'gitlabb') } @@ -21,7 +21,7 @@ describe RedirectRoute, models: true do let!(:redirect5) { group.redirect_routes.create(path: 'gitlabb/test/baz') } it 'returns correct routes' do - expect(RedirectRoute.matching_path_and_descendants('gitlabb/test')).to match_array([redirect2, redirect3, redirect4, redirect5]) + expect(described_class.matching_path_and_descendants('gitlabb/test')).to match_array([redirect2, redirect3, redirect4, redirect5]) end end end diff --git a/spec/models/release_spec.rb b/spec/models/release_spec.rb index 527005b2b69..3f86347c3ae 100644 --- a/spec/models/release_spec.rb +++ b/spec/models/release_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe Release, type: :model do +RSpec.describe Release do let(:release) { create(:release) } it { expect(release).to be_valid } diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index fcda4248446..07ed66e127a 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Repository, models: true do +describe Repository do include RepoHelpers TestBlob = Struct.new(:path) diff --git a/spec/models/route_spec.rb b/spec/models/route_spec.rb index 12f7611fb28..bdacc60fb53 100644 --- a/spec/models/route_spec.rb +++ b/spec/models/route_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Route, models: true do +describe Route do let(:group) { create(:group, path: 'git_lab', name: 'git_lab') } let(:route) { group.route } @@ -34,7 +34,7 @@ describe Route, models: true do context 'after create' do it 'calls #delete_conflicting_redirects' do route.destroy - new_route = Route.new(source: group, path: group.path) + new_route = described_class.new(source: group, path: group.path) expect(new_route).to receive(:delete_conflicting_redirects) new_route.save! end @@ -49,7 +49,7 @@ describe Route, models: true do let!(:another_group_nested) { create(:group, path: 'another', name: 'another', parent: similar_group) } it 'returns correct routes' do - expect(Route.inside_path('git_lab')).to match_array([nested_group.route, deep_nested_group.route]) + expect(described_class.inside_path('git_lab')).to match_array([nested_group.route, deep_nested_group.route]) end end diff --git a/spec/models/sent_notification_spec.rb b/spec/models/sent_notification_spec.rb index 5710edbc9e0..8b6b02916ae 100644 --- a/spec/models/sent_notification_spec.rb +++ b/spec/models/sent_notification_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe SentNotification, model: true do +describe SentNotification do describe 'validation' do describe 'note validity' do context "when the project doesn't match the noteable's project" do @@ -38,7 +38,7 @@ describe SentNotification, model: true do let(:issue) { create(:issue) } it 'creates a new SentNotification' do - expect { described_class.record(issue, user.id) }.to change { SentNotification.count }.by(1) + expect { described_class.record(issue, user.id) }.to change { described_class.count }.by(1) end end @@ -47,7 +47,7 @@ describe SentNotification, model: true do let(:note) { create(:diff_note_on_merge_request) } it 'creates a new SentNotification' do - expect { described_class.record_note(note, user.id) }.to change { SentNotification.count }.by(1) + expect { described_class.record_note(note, user.id) }.to change { described_class.count }.by(1) end end diff --git a/spec/models/service_spec.rb b/spec/models/service_spec.rb index 134882648b9..dba9fc4ac9b 100644 --- a/spec/models/service_spec.rb +++ b/spec/models/service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Service, models: true do +describe Service do describe "Associations" do it { is_expected.to belong_to :project } it { is_expected.to have_one :service_hook } diff --git a/spec/models/snippet_blob_spec.rb b/spec/models/snippet_blob_spec.rb index 120b390586b..7c71c458fcc 100644 --- a/spec/models/snippet_blob_spec.rb +++ b/spec/models/snippet_blob_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe SnippetBlob, models: true do +describe SnippetBlob do let(:snippet) { create(:snippet) } subject { described_class.new(snippet) } diff --git a/spec/models/snippet_spec.rb b/spec/models/snippet_spec.rb index 1e5c96fe593..904bf2c6144 100644 --- a/spec/models/snippet_spec.rb +++ b/spec/models/snippet_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Snippet, models: true do +describe Snippet do describe 'modules' do subject { described_class } diff --git a/spec/models/spam_log_spec.rb b/spec/models/spam_log_spec.rb index 838fba6c92d..0d6b4384ada 100644 --- a/spec/models/spam_log_spec.rb +++ b/spec/models/spam_log_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe SpamLog, models: true do +describe SpamLog do let(:admin) { create(:admin) } describe 'associations' do diff --git a/spec/models/subscription_spec.rb b/spec/models/subscription_spec.rb index 9ab112bb2ee..9e4c2620d82 100644 --- a/spec/models/subscription_spec.rb +++ b/spec/models/subscription_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Subscription, models: true do +describe Subscription do describe 'relationships' do it { is_expected.to belong_to(:project) } it { is_expected.to belong_to(:subscribable) } diff --git a/spec/models/system_note_metadata_spec.rb b/spec/models/system_note_metadata_spec.rb index d238e28209a..1e3f587e460 100644 --- a/spec/models/system_note_metadata_spec.rb +++ b/spec/models/system_note_metadata_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe SystemNoteMetadata, models: true do +describe SystemNoteMetadata do describe 'associations' do it { is_expected.to belong_to(:note) } end diff --git a/spec/models/timelog_spec.rb b/spec/models/timelog_spec.rb index ebc694213b6..6e30798356c 100644 --- a/spec/models/timelog_spec.rb +++ b/spec/models/timelog_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe Timelog, type: :model do +RSpec.describe Timelog do subject { build(:timelog) } let(:issue) { create(:issue) } let(:merge_request) { create(:merge_request) } diff --git a/spec/models/todo_spec.rb b/spec/models/todo_spec.rb index 3f80e1ac534..3e8f3848eca 100644 --- a/spec/models/todo_spec.rb +++ b/spec/models/todo_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Todo, models: true do +describe Todo do let(:issue) { create(:issue) } describe 'relationships' do diff --git a/spec/models/tree_spec.rb b/spec/models/tree_spec.rb index a87983b7492..6bdb62a0864 100644 --- a/spec/models/tree_spec.rb +++ b/spec/models/tree_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Tree, models: true do +describe Tree do let(:repository) { create(:project, :repository).repository } let(:sha) { repository.root_ref } diff --git a/spec/models/upload_spec.rb b/spec/models/upload_spec.rb index 2dea2c6015f..345382ea8c7 100644 --- a/spec/models/upload_spec.rb +++ b/spec/models/upload_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe Upload, type: :model do +describe Upload do describe 'assocations' do it { is_expected.to belong_to(:model) } end diff --git a/spec/models/user_agent_detail_spec.rb b/spec/models/user_agent_detail_spec.rb index a8c25766e73..b4669f8c1c2 100644 --- a/spec/models/user_agent_detail_spec.rb +++ b/spec/models/user_agent_detail_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe UserAgentDetail, type: :model do +describe UserAgentDetail do describe '.submittable?' do it 'is submittable when not already submitted' do detail = build(:user_agent_detail) diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 20bdb7e37da..ec98a3f3498 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe User, models: true do +describe User do include Gitlab::CurrentSettings describe 'modules' do @@ -261,7 +261,7 @@ describe User, models: true do it "returns users with 2fa enabled via OTP" do user_with_2fa = create(:user, :two_factor_via_otp) user_without_2fa = create(:user) - users_with_two_factor = User.with_two_factor.pluck(:id) + users_with_two_factor = described_class.with_two_factor.pluck(:id) expect(users_with_two_factor).to include(user_with_2fa.id) expect(users_with_two_factor).not_to include(user_without_2fa.id) @@ -270,7 +270,7 @@ describe User, models: true do it "returns users with 2fa enabled via U2F" do user_with_2fa = create(:user, :two_factor_via_u2f) user_without_2fa = create(:user) - users_with_two_factor = User.with_two_factor.pluck(:id) + users_with_two_factor = described_class.with_two_factor.pluck(:id) expect(users_with_two_factor).to include(user_with_2fa.id) expect(users_with_two_factor).not_to include(user_without_2fa.id) @@ -279,7 +279,7 @@ describe User, models: true do it "returns users with 2fa enabled via OTP and U2F" do user_with_2fa = create(:user, :two_factor_via_otp, :two_factor_via_u2f) user_without_2fa = create(:user) - users_with_two_factor = User.with_two_factor.pluck(:id) + users_with_two_factor = described_class.with_two_factor.pluck(:id) expect(users_with_two_factor).to eq([user_with_2fa.id]) expect(users_with_two_factor).not_to include(user_without_2fa.id) @@ -290,7 +290,7 @@ describe User, models: true do it "excludes users with 2fa enabled via OTP" do user_with_2fa = create(:user, :two_factor_via_otp) user_without_2fa = create(:user) - users_without_two_factor = User.without_two_factor.pluck(:id) + users_without_two_factor = described_class.without_two_factor.pluck(:id) expect(users_without_two_factor).to include(user_without_2fa.id) expect(users_without_two_factor).not_to include(user_with_2fa.id) @@ -299,7 +299,7 @@ describe User, models: true do it "excludes users with 2fa enabled via U2F" do user_with_2fa = create(:user, :two_factor_via_u2f) user_without_2fa = create(:user) - users_without_two_factor = User.without_two_factor.pluck(:id) + users_without_two_factor = described_class.without_two_factor.pluck(:id) expect(users_without_two_factor).to include(user_without_2fa.id) expect(users_without_two_factor).not_to include(user_with_2fa.id) @@ -308,7 +308,7 @@ describe User, models: true do it "excludes users with 2fa enabled via OTP and U2F" do user_with_2fa = create(:user, :two_factor_via_otp, :two_factor_via_u2f) user_without_2fa = create(:user) - users_without_two_factor = User.without_two_factor.pluck(:id) + users_without_two_factor = described_class.without_two_factor.pluck(:id) expect(users_without_two_factor).to include(user_without_2fa.id) expect(users_without_two_factor).not_to include(user_with_2fa.id) @@ -324,8 +324,8 @@ describe User, models: true do create(:todo, user: current_user, author: user_2, state: :done) create(:todo, user: current_user, author: user_3, state: :pending) - expect(User.todo_authors(current_user.id, 'pending')).to eq [user_3] - expect(User.todo_authors(current_user.id, 'done')).to eq [user_2] + expect(described_class.todo_authors(current_user.id, 'pending')).to eq [user_3] + expect(described_class.todo_authors(current_user.id, 'done')).to eq [user_2] end end end @@ -350,6 +350,26 @@ describe User, models: true do end end + describe 'after update hook' do + describe '.update_invalid_gpg_signatures' do + let(:user) do + create(:user, email: 'tula.torphy@abshire.ca').tap do |user| + user.skip_reconfirmation! + end + end + + it 'does nothing when the name is updated' do + expect(user).not_to receive(:update_invalid_gpg_signatures) + user.update_attributes!(name: 'Bette') + end + + it 'synchronizes the gpg keys when the email is updated' do + expect(user).to receive(:update_invalid_gpg_signatures) + user.update_attributes!(email: 'shawnee.ritchie@denesik.com') + end + end + end + describe '#update_tracked_fields!', :clean_gitlab_redis_shared_state do let(:request) { OpenStruct.new(remote_ip: "127.0.0.1") } let(:user) { create(:user) } @@ -609,39 +629,39 @@ describe User, models: true do let(:user) { double } it 'filters by active users by default' do - expect(User).to receive(:active).and_return([user]) + expect(described_class).to receive(:active).and_return([user]) - expect(User.filter(nil)).to include user + expect(described_class.filter(nil)).to include user end it 'filters by admins' do - expect(User).to receive(:admins).and_return([user]) + expect(described_class).to receive(:admins).and_return([user]) - expect(User.filter('admins')).to include user + expect(described_class.filter('admins')).to include user end it 'filters by blocked' do - expect(User).to receive(:blocked).and_return([user]) + expect(described_class).to receive(:blocked).and_return([user]) - expect(User.filter('blocked')).to include user + expect(described_class.filter('blocked')).to include user end it 'filters by two_factor_disabled' do - expect(User).to receive(:without_two_factor).and_return([user]) + expect(described_class).to receive(:without_two_factor).and_return([user]) - expect(User.filter('two_factor_disabled')).to include user + expect(described_class.filter('two_factor_disabled')).to include user end it 'filters by two_factor_enabled' do - expect(User).to receive(:with_two_factor).and_return([user]) + expect(described_class).to receive(:with_two_factor).and_return([user]) - expect(User.filter('two_factor_enabled')).to include user + expect(described_class.filter('two_factor_enabled')).to include user end it 'filters by wop' do - expect(User).to receive(:without_projects).and_return([user]) + expect(described_class).to receive(:without_projects).and_return([user]) - expect(User.filter('wop')).to include user + expect(described_class.filter('wop')).to include user end end @@ -662,9 +682,9 @@ describe User, models: true do project.request_access(user_without_project2) end - it { expect(User.without_projects).not_to include user } - it { expect(User.without_projects).to include user_without_project } - it { expect(User.without_projects).to include user_without_project2 } + it { expect(described_class.without_projects).not_to include user } + it { expect(described_class.without_projects).to include user_without_project } + it { expect(described_class.without_projects).to include user_without_project2 } end describe 'user creation' do @@ -680,7 +700,7 @@ describe User, models: true do end describe 'with defaults' do - let(:user) { User.new } + let(:user) { described_class.new } it "applies defaults to user" do expect(user.projects_limit).to eq(Gitlab.config.gitlab.default_projects_limit) @@ -690,7 +710,7 @@ describe User, models: true do end describe 'with default overrides' do - let(:user) { User.new(projects_limit: 123, can_create_group: false, can_create_team: true) } + let(:user) { described_class.new(projects_limit: 123, can_create_group: false, can_create_team: true) } it "applies defaults to user" do expect(user.projects_limit).to eq(123) @@ -740,18 +760,18 @@ describe User, models: true do it 'finds by primary email' do user = create(:user, email: 'foo@example.com') - expect(User.find_by_any_email(user.email)).to eq user + expect(described_class.find_by_any_email(user.email)).to eq user end it 'finds by secondary email' do email = create(:email, email: 'foo@example.com') user = email.user - expect(User.find_by_any_email(email.email)).to eq user + expect(described_class.find_by_any_email(email.email)).to eq user end it 'returns nil when nothing found' do - expect(User.find_by_any_email('')).to be_nil + expect(described_class.find_by_any_email('')).to be_nil end end @@ -899,12 +919,12 @@ describe User, models: true do let!(:user) { create(:user, username: username) } it 'gets the correct user' do - expect(User.by_login(user.email.upcase)).to eq user - expect(User.by_login(user.email)).to eq user - expect(User.by_login(username.downcase)).to eq user - expect(User.by_login(username)).to eq user - expect(User.by_login(nil)).to be_nil - expect(User.by_login('')).to be_nil + expect(described_class.by_login(user.email.upcase)).to eq user + expect(described_class.by_login(user.email)).to eq user + expect(described_class.by_login(username.downcase)).to eq user + expect(described_class.by_login(username)).to eq user + expect(described_class.by_login(nil)).to be_nil + expect(described_class.by_login('')).to be_nil end end @@ -938,12 +958,12 @@ describe User, models: true do let!(:route) { user.namespace.route } it 'returns the user' do - expect(User.find_by_full_path(route.path)).to eq(user) + expect(described_class.find_by_full_path(route.path)).to eq(user) end it 'is case-insensitive' do - expect(User.find_by_full_path(route.path.upcase)).to eq(user) - expect(User.find_by_full_path(route.path.downcase)).to eq(user) + expect(described_class.find_by_full_path(route.path.upcase)).to eq(user) + expect(described_class.find_by_full_path(route.path.downcase)).to eq(user) end end @@ -952,18 +972,18 @@ describe User, models: true do context 'without the follow_redirects option' do it 'returns nil' do - expect(User.find_by_full_path(redirect_route.path)).to eq(nil) + expect(described_class.find_by_full_path(redirect_route.path)).to eq(nil) end end context 'with the follow_redirects option set to true' do it 'returns the user' do - expect(User.find_by_full_path(redirect_route.path, follow_redirects: true)).to eq(user) + expect(described_class.find_by_full_path(redirect_route.path, follow_redirects: true)).to eq(user) end it 'is case-insensitive' do - expect(User.find_by_full_path(redirect_route.path.upcase, follow_redirects: true)).to eq(user) - expect(User.find_by_full_path(redirect_route.path.downcase, follow_redirects: true)).to eq(user) + expect(described_class.find_by_full_path(redirect_route.path.upcase, follow_redirects: true)).to eq(user) + expect(described_class.find_by_full_path(redirect_route.path.downcase, follow_redirects: true)).to eq(user) end end end @@ -971,12 +991,12 @@ describe User, models: true do context 'without a route or a redirect route matching the given path' do context 'without the follow_redirects option' do it 'returns nil' do - expect(User.find_by_full_path('unknown')).to eq(nil) + expect(described_class.find_by_full_path('unknown')).to eq(nil) end end context 'with the follow_redirects option set to true' do it 'returns nil' do - expect(User.find_by_full_path('unknown', follow_redirects: true)).to eq(nil) + expect(described_class.find_by_full_path('unknown', follow_redirects: true)).to eq(nil) end end end @@ -986,7 +1006,7 @@ describe User, models: true do let!(:group) { create(:group, path: 'group_path', owner: user) } it 'returns nil' do - expect(User.find_by_full_path('group_path')).to eq(nil) + expect(described_class.find_by_full_path('group_path')).to eq(nil) end end @@ -994,7 +1014,7 @@ describe User, models: true do let!(:group) { create(:group, path: 'group_path') } it 'returns nil' do - expect(User.find_by_full_path('group_path')).to eq(nil) + expect(described_class.find_by_full_path('group_path')).to eq(nil) end end end @@ -1044,7 +1064,7 @@ describe User, models: true do end describe '#requires_ldap_check?' do - let(:user) { User.new } + let(:user) { described_class.new } it 'is false when LDAP is disabled' do # Create a condition which would otherwise cause 'true' to be returned @@ -1215,7 +1235,7 @@ describe User, models: true do describe '#sort' do before do - User.delete_all + described_class.delete_all @user = create :user, created_at: Date.today, last_sign_in_at: Date.today, name: 'Alpha' @user1 = create :user, created_at: Date.today - 1, last_sign_in_at: Date.today - 1, name: 'Omega' @user2 = create :user, created_at: Date.today - 2, last_sign_in_at: nil, name: 'Beta' @@ -1223,34 +1243,34 @@ describe User, models: true do context 'when sort by recent_sign_in' do it 'sorts users by the recent sign-in time' do - expect(User.sort('recent_sign_in').first).to eq(@user) + expect(described_class.sort('recent_sign_in').first).to eq(@user) end it 'pushes users who never signed in to the end' do - expect(User.sort('recent_sign_in').third).to eq(@user2) + expect(described_class.sort('recent_sign_in').third).to eq(@user2) end end context 'when sort by oldest_sign_in' do it 'sorts users by the oldest sign-in time' do - expect(User.sort('oldest_sign_in').first).to eq(@user1) + expect(described_class.sort('oldest_sign_in').first).to eq(@user1) end it 'pushes users who never signed in to the end' do - expect(User.sort('oldest_sign_in').third).to eq(@user2) + expect(described_class.sort('oldest_sign_in').third).to eq(@user2) end end it 'sorts users in descending order by their creation time' do - expect(User.sort('created_desc').first).to eq(@user) + expect(described_class.sort('created_desc').first).to eq(@user) end it 'sorts users in ascending order by their creation time' do - expect(User.sort('created_asc').first).to eq(@user2) + expect(described_class.sort('created_asc').first).to eq(@user2) end it 'sorts users by id in descending order when nil is passed' do - expect(User.sort(nil).first).to eq(@user2) + expect(described_class.sort(nil).first).to eq(@user2) end end @@ -1770,7 +1790,7 @@ describe User, models: true do describe '.ghost' do it "creates a ghost user if one isn't already present" do - ghost = User.ghost + ghost = described_class.ghost expect(ghost).to be_ghost expect(ghost).to be_persisted @@ -1778,16 +1798,16 @@ describe User, models: true do it "does not create a second ghost user if one is already present" do expect do - User.ghost - User.ghost - end.to change { User.count }.by(1) - expect(User.ghost).to eq(User.ghost) + described_class.ghost + described_class.ghost + end.to change { described_class.count }.by(1) + expect(described_class.ghost).to eq(described_class.ghost) end context "when a regular user exists with the username 'ghost'" do it "creates a ghost user with a non-conflicting username" do create(:user, username: 'ghost') - ghost = User.ghost + ghost = described_class.ghost expect(ghost).to be_persisted expect(ghost.username).to eq('ghost1') @@ -1797,7 +1817,7 @@ describe User, models: true do context "when a regular user exists with the email 'ghost@example.com'" do it "creates a ghost user with a non-conflicting email" do create(:user, email: 'ghost@example.com') - ghost = User.ghost + ghost = described_class.ghost expect(ghost).to be_persisted expect(ghost.email).to eq('ghost1@example.com') @@ -1810,7 +1830,7 @@ describe User, models: true do end it 'creates a ghost user' do - expect(User.ghost).to be_persisted + expect(described_class.ghost).to be_persisted end end end @@ -1889,13 +1909,13 @@ describe User, models: true do context '.active' do before do - User.ghost + described_class.ghost create(:user, name: 'user', state: 'active') create(:user, name: 'user', state: 'blocked') end it 'only counts active and non internal users' do - expect(User.active.count).to eq(1) + expect(described_class.active.count).to eq(1) end end diff --git a/spec/models/wiki_directory_spec.rb b/spec/models/wiki_directory_spec.rb index 1caaa557085..fb8575cfe2b 100644 --- a/spec/models/wiki_directory_spec.rb +++ b/spec/models/wiki_directory_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -RSpec.describe WikiDirectory, models: true do +RSpec.describe WikiDirectory do describe 'validations' do subject { build(:wiki_directory) } @@ -10,7 +10,7 @@ RSpec.describe WikiDirectory, models: true do describe '#initialize' do context 'when there are pages' do let(:pages) { [build(:wiki_page)] } - let(:directory) { WikiDirectory.new('/path_up_to/dir', pages) } + let(:directory) { described_class.new('/path_up_to/dir', pages) } it 'sets the slug attribute' do expect(directory.slug).to eq('/path_up_to/dir') @@ -22,7 +22,7 @@ RSpec.describe WikiDirectory, models: true do end context 'when there are no pages' do - let(:directory) { WikiDirectory.new('/path_up_to/dir') } + let(:directory) { described_class.new('/path_up_to/dir') } it 'sets the slug attribute' do expect(directory.slug).to eq('/path_up_to/dir') diff --git a/spec/models/wiki_page_spec.rb b/spec/models/wiki_page_spec.rb index 4a73552b8a6..55d9c4ddd7b 100644 --- a/spec/models/wiki_page_spec.rb +++ b/spec/models/wiki_page_spec.rb @@ -1,17 +1,17 @@ require "spec_helper" -describe WikiPage, models: true do +describe WikiPage do let(:project) { create(:empty_project) } let(:user) { project.owner } let(:wiki) { ProjectWiki.new(project, user) } - subject { WikiPage.new(wiki) } + subject { described_class.new(wiki) } describe '.group_by_directory' do context 'when there are no pages' do it 'returns an empty array' do - expect(WikiPage.group_by_directory(nil)).to eq([]) - expect(WikiPage.group_by_directory([])).to eq([]) + expect(described_class.group_by_directory(nil)).to eq([]) + expect(described_class.group_by_directory([])).to eq([]) end end @@ -39,7 +39,7 @@ describe WikiPage, models: true do it 'returns an array with pages and directories' do expected_grouped_entries = [page_1, dir_1, dir_1_1, dir_2] - grouped_entries = WikiPage.group_by_directory(wiki.pages) + grouped_entries = described_class.group_by_directory(wiki.pages) grouped_entries.each_with_index do |page_or_dir, i| expected_page_or_dir = expected_grouped_entries[i] @@ -56,7 +56,7 @@ describe WikiPage, models: true do expected_order = ['page_1', 'dir_1/page_2', 'dir_1/dir_1_1/page_3', 'dir_2/page_4', 'dir_2/page_5'] - grouped_entries = WikiPage.group_by_directory(wiki.pages) + grouped_entries = described_class.group_by_directory(wiki.pages) actual_order = grouped_entries.map do |page_or_dir| @@ -72,7 +72,7 @@ describe WikiPage, models: true do it 'removes hyphens from a name' do name = 'a-name--with-hyphens' - expect(WikiPage.unhyphenize(name)).to eq('a name with hyphens') + expect(described_class.unhyphenize(name)).to eq('a name with hyphens') end end @@ -81,7 +81,7 @@ describe WikiPage, models: true do before do create_page("test page", "test content") @page = wiki.wiki.paged("test page") - @wiki_page = WikiPage.new(wiki, @page, true) + @wiki_page = described_class.new(wiki, @page, true) end it "sets the slug attribute" do @@ -208,6 +208,18 @@ describe WikiPage, models: true do expect(@page.update("more content")).to be_truthy end end + + context 'with same last commit sha' do + it 'returns true' do + expect(@page.update('more content', last_commit_sha: @page.last_commit_sha)).to be_truthy + end + end + + context 'with different last commit sha' do + it 'raises exception' do + expect { @page.update('more content', last_commit_sha: 'xxx') }.to raise_error(WikiPage::PageChangedError) + end + end end describe "#destroy" do @@ -331,6 +343,30 @@ describe WikiPage, models: true do end end + describe '#last_commit_sha' do + before do + create_page("Update", "content") + @page = wiki.find_page("Update") + end + + after do + destroy_page("Update") + end + + it 'returns commit sha' do + expect(@page.last_commit_sha).to eq @page.commit.sha + end + + it 'is changed after page updated' do + last_commit_sha_before_update = @page.last_commit_sha + + @page.update("new content") + @page = wiki.find_page("Update") + + expect(@page.last_commit_sha).not_to eq last_commit_sha_before_update + end + end + private def remove_temp_repo(path) diff --git a/spec/policies/base_policy_spec.rb b/spec/policies/base_policy_spec.rb index e1963091a72..c03d95b34db 100644 --- a/spec/policies/base_policy_spec.rb +++ b/spec/policies/base_policy_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe BasePolicy, models: true do +describe BasePolicy do describe '.class_for' do it 'detects policy class based on the subject ancestors' do expect(DeclarativePolicy.class_for(GenericCommitStatus.new)).to eq(CommitStatusPolicy) diff --git a/spec/policies/ci/build_policy_spec.rb b/spec/policies/ci/build_policy_spec.rb index e3ea3c960a4..a83a83a7349 100644 --- a/spec/policies/ci/build_policy_spec.rb +++ b/spec/policies/ci/build_policy_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Ci::BuildPolicy, :models do +describe Ci::BuildPolicy do let(:user) { create(:user) } let(:build) { create(:ci_build, pipeline: pipeline) } let(:pipeline) { create(:ci_empty_pipeline, project: project) } diff --git a/spec/policies/ci/trigger_policy_spec.rb b/spec/policies/ci/trigger_policy_spec.rb index ed4010e723b..3d3e3d3755b 100644 --- a/spec/policies/ci/trigger_policy_spec.rb +++ b/spec/policies/ci/trigger_policy_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Ci::TriggerPolicy, :models do +describe Ci::TriggerPolicy do let(:user) { create(:user) } let(:project) { create(:empty_project) } let(:trigger) { create(:ci_trigger, project: project, owner: owner) } diff --git a/spec/policies/deploy_key_policy_spec.rb b/spec/policies/deploy_key_policy_spec.rb index f15f4a11f02..ca7b7fe7ef7 100644 --- a/spec/policies/deploy_key_policy_spec.rb +++ b/spec/policies/deploy_key_policy_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe DeployKeyPolicy, models: true do +describe DeployKeyPolicy do subject { described_class.new(current_user, deploy_key) } describe 'updating a deploy_key' do diff --git a/spec/policies/global_policy_spec.rb b/spec/policies/global_policy_spec.rb index c3e2b603c4b..a6bf70c1e09 100644 --- a/spec/policies/global_policy_spec.rb +++ b/spec/policies/global_policy_spec.rb @@ -1,10 +1,10 @@ require 'spec_helper' -describe GlobalPolicy, models: true do +describe GlobalPolicy do let(:current_user) { create(:user) } let(:user) { create(:user) } - subject { GlobalPolicy.new(current_user, [user]) } + subject { described_class.new(current_user, [user]) } describe "reading the list of users" do context "for a logged in user" do diff --git a/spec/policies/group_policy_spec.rb b/spec/policies/group_policy_spec.rb index 06db0ea56e3..b17a93e3fbe 100644 --- a/spec/policies/group_policy_spec.rb +++ b/spec/policies/group_policy_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe GroupPolicy, models: true do +describe GroupPolicy do let(:guest) { create(:user) } let(:reporter) { create(:user) } let(:developer) { create(:user) } diff --git a/spec/policies/issue_policy_spec.rb b/spec/policies/issue_policy_spec.rb index c978cbd6185..279b96fb2af 100644 --- a/spec/policies/issue_policy_spec.rb +++ b/spec/policies/issue_policy_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe IssuePolicy, models: true do +describe IssuePolicy do let(:guest) { create(:user) } let(:author) { create(:user) } let(:assignee) { create(:user) } diff --git a/spec/policies/personal_snippet_policy_spec.rb b/spec/policies/personal_snippet_policy_spec.rb index 4d6350fc653..b70c8646a3d 100644 --- a/spec/policies/personal_snippet_policy_spec.rb +++ b/spec/policies/personal_snippet_policy_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe PersonalSnippetPolicy, models: true do +describe PersonalSnippetPolicy do let(:regular_user) { create(:user) } let(:external_user) { create(:user, :external) } let(:admin_user) { create(:user, :admin) } diff --git a/spec/policies/project_policy_spec.rb b/spec/policies/project_policy_spec.rb index f244975e597..1f51ced1beb 100644 --- a/spec/policies/project_policy_spec.rb +++ b/spec/policies/project_policy_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe ProjectPolicy, models: true do +describe ProjectPolicy do let(:guest) { create(:user) } let(:reporter) { create(:user) } let(:dev) { create(:user) } diff --git a/spec/policies/project_snippet_policy_spec.rb b/spec/policies/project_snippet_policy_spec.rb index 2799f03fb9b..bae35ee31c6 100644 --- a/spec/policies/project_snippet_policy_spec.rb +++ b/spec/policies/project_snippet_policy_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe ProjectSnippetPolicy, models: true do +describe ProjectSnippetPolicy do let(:regular_user) { create(:user) } let(:external_user) { create(:user, :external) } let(:project) { create(:empty_project, :public) } diff --git a/spec/policies/user_policy_spec.rb b/spec/policies/user_policy_spec.rb index 0251d5dcf1c..6593a6ca3b9 100644 --- a/spec/policies/user_policy_spec.rb +++ b/spec/policies/user_policy_spec.rb @@ -1,10 +1,10 @@ require 'spec_helper' -describe UserPolicy, models: true do +describe UserPolicy do let(:current_user) { create(:user) } let(:user) { create(:user) } - subject { UserPolicy.new(current_user, user) } + subject { described_class.new(current_user, user) } describe "reading a user's information" do it { is_expected.to be_allowed(:read_user) } diff --git a/spec/requests/api/branches_spec.rb b/spec/requests/api/branches_spec.rb index c64499fc8c0..5a2e1b2cf2d 100644 --- a/spec/requests/api/branches_spec.rb +++ b/spec/requests/api/branches_spec.rb @@ -1,25 +1,31 @@ require 'spec_helper' -require 'mime/types' describe API::Branches do let(:user) { create(:user) } - let!(:project) { create(:project, :repository, creator: user) } - let!(:master) { create(:project_member, :master, user: user, project: project) } - let(:guest) { create(:user).tap { |u| create(:project_member, :guest, user: u, project: project) } } - let!(:branch_name) { 'feature' } - let!(:branch_sha) { '0b4bc9a49b562e85de7cc9e834518ea6828729b9' } - let(:branch_with_dot) { CreateBranchService.new(project, user).execute("with.1.2.3", "master")[:branch] } + let(:guest) { create(:user).tap { |u| project.add_guest(u) } } + let(:project) { create(:project, :repository, creator: user, path: 'my.project') } + let(:branch_name) { 'feature' } + let(:branch_sha) { '0b4bc9a49b562e85de7cc9e834518ea6828729b9' } + let(:branch_with_dot) { project.repository.find_branch('ends-with.json') } + let(:branch_with_slash) { project.repository.find_branch('improve/awesome') } + + let(:project_id) { project.id } + let(:current_user) { nil } + + before do + project.add_master(user) + end describe "GET /projects/:id/repository/branches" do - let(:route) { "/projects/#{project.id}/repository/branches" } + let(:route) { "/projects/#{project_id}/repository/branches" } shared_examples_for 'repository branches' do it 'returns the repository branches' do get api(route, current_user), per_page: 100 - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) + expect(response).to match_response_schema('public_api/v4/branches') expect(response).to include_pagination_headers - expect(json_response).to be_an Array branch_names = json_response.map { |x| x['name'] } expect(branch_names).to match_array(project.repository.branch_names) end @@ -34,10 +40,9 @@ describe API::Branches do end context 'when unauthenticated', 'and project is public' do - it_behaves_like 'repository branches' do - let(:project) { create(:project, :public, :repository) } - let(:current_user) { nil } - end + let(:project) { create(:project, :public, :repository) } + + it_behaves_like 'repository branches' end context 'when unauthenticated', 'and project is private' do @@ -47,9 +52,15 @@ describe API::Branches do end end - context 'when authenticated', 'as a developer' do - it_behaves_like 'repository branches' do - let(:current_user) { user } + context 'when authenticated', 'as a master' do + let(:current_user) { user } + + it_behaves_like 'repository branches' + + context 'requesting with the escaped project full path' do + let(:project_id) { CGI.escape(project.full_path) } + + it_behaves_like 'repository branches' end end @@ -61,31 +72,15 @@ describe API::Branches do end describe "GET /projects/:id/repository/branches/:branch" do - let(:route) { "/projects/#{project.id}/repository/branches/#{branch_name}" } + let(:route) { "/projects/#{project_id}/repository/branches/#{branch_name}" } - shared_examples_for 'repository branch' do |merged: false| + shared_examples_for 'repository branch' do it 'returns the repository branch' do get api(route, current_user) - expect(response).to have_http_status(200) - expect(json_response['name']).to eq(branch_name) - expect(json_response['merged']).to eq(merged) - expect(json_response['protected']).to eq(false) - expect(json_response['developers_can_push']).to eq(false) - expect(json_response['developers_can_merge']).to eq(false) - - json_commit = json_response['commit'] - expect(json_commit['id']).to eq(branch_sha) - expect(json_commit).to have_key('short_id') - expect(json_commit).to have_key('title') - expect(json_commit).to have_key('message') - expect(json_commit).to have_key('author_name') - expect(json_commit).to have_key('author_email') - expect(json_commit).to have_key('authored_date') - expect(json_commit).to have_key('committer_name') - expect(json_commit).to have_key('committer_email') - expect(json_commit).to have_key('committed_date') - expect(json_commit).to have_key('parent_ids') + expect(response).to have_gitlab_http_status(200) + expect(response).to match_response_schema('public_api/v4/branch') + expect(json_response['name']).to eq(CGI.unescape(branch_name)) end context 'when branch does not exist' do @@ -107,10 +102,9 @@ describe API::Branches do end context 'when unauthenticated', 'and project is public' do - it_behaves_like 'repository branch' do - let(:project) { create(:project, :public, :repository) } - let(:current_user) { nil } - end + let(:project) { create(:project, :public, :repository) } + + it_behaves_like 'repository branch' end context 'when unauthenticated', 'and project is private' do @@ -120,22 +114,41 @@ describe API::Branches do end end - context 'when authenticated', 'as a developer' do + context 'when authenticated', 'as a master' do let(:current_user) { user } + it_behaves_like 'repository branch' context 'when branch contains a dot' do let(:branch_name) { branch_with_dot.name } - let(:branch_sha) { project.commit('master').sha } it_behaves_like 'repository branch' end - context 'when branch is merged' do - let(:branch_name) { 'merge-test' } - let(:branch_sha) { project.commit('merge-test').sha } + context 'when branch contains a slash' do + let(:branch_name) { branch_with_slash.name } + + it_behaves_like '404 response' do + let(:request) { get api(route, current_user) } + end + end + + context 'when branch contains an escaped slash' do + let(:branch_name) { CGI.escape(branch_with_slash.name) } + + it_behaves_like 'repository branch' + end + + context 'requesting with the escaped project full path' do + let(:project_id) { CGI.escape(project.full_path) } + + it_behaves_like 'repository branch' - it_behaves_like 'repository branch', merged: true + context 'when branch contains a dot' do + let(:branch_name) { branch_with_dot.name } + + it_behaves_like 'repository branch' + end end end @@ -147,268 +160,348 @@ describe API::Branches do end describe 'PUT /projects/:id/repository/branches/:branch/protect' do - context "when a protected branch doesn't already exist" do - it 'protects a single branch' do - put api("/projects/#{project.id}/repository/branches/#{branch_name}/protect", user) + let(:route) { "/projects/#{project_id}/repository/branches/#{branch_name}/protect" } - expect(response).to have_http_status(200) - expect(json_response['name']).to eq(branch_name) - expect(json_response['commit']['id']).to eq(branch_sha) - expect(json_response['protected']).to eq(true) - expect(json_response['developers_can_push']).to eq(false) - expect(json_response['developers_can_merge']).to eq(false) - end - - it "protects a single branch with dots in the name" do - put api("/projects/#{project.id}/repository/branches/#{branch_with_dot.name}/protect", user) + shared_examples_for 'repository new protected branch' do + it 'protects a single branch' do + put api(route, current_user) - expect(response).to have_http_status(200) - expect(json_response['name']).to eq(branch_with_dot.name) + expect(response).to have_gitlab_http_status(200) + expect(response).to match_response_schema('public_api/v4/branch') + expect(json_response['name']).to eq(CGI.unescape(branch_name)) expect(json_response['protected']).to eq(true) end it 'protects a single branch and developers can push' do - put api("/projects/#{project.id}/repository/branches/#{branch_name}/protect", user), - developers_can_push: true + put api(route, current_user), developers_can_push: true - expect(response).to have_http_status(200) - expect(json_response['name']).to eq(branch_name) - expect(json_response['commit']['id']).to eq(branch_sha) + expect(response).to have_gitlab_http_status(200) + expect(response).to match_response_schema('public_api/v4/branch') + expect(json_response['name']).to eq(CGI.unescape(branch_name)) expect(json_response['protected']).to eq(true) expect(json_response['developers_can_push']).to eq(true) expect(json_response['developers_can_merge']).to eq(false) end it 'protects a single branch and developers can merge' do - put api("/projects/#{project.id}/repository/branches/#{branch_name}/protect", user), - developers_can_merge: true + put api(route, current_user), developers_can_merge: true - expect(response).to have_http_status(200) - expect(json_response['name']).to eq(branch_name) - expect(json_response['commit']['id']).to eq(branch_sha) + expect(response).to have_gitlab_http_status(200) + expect(response).to match_response_schema('public_api/v4/branch') + expect(json_response['name']).to eq(CGI.unescape(branch_name)) expect(json_response['protected']).to eq(true) expect(json_response['developers_can_push']).to eq(false) expect(json_response['developers_can_merge']).to eq(true) end it 'protects a single branch and developers can push and merge' do - put api("/projects/#{project.id}/repository/branches/#{branch_name}/protect", user), - developers_can_push: true, developers_can_merge: true + put api(route, current_user), developers_can_push: true, developers_can_merge: true - expect(response).to have_http_status(200) - expect(json_response['name']).to eq(branch_name) - expect(json_response['commit']['id']).to eq(branch_sha) + expect(response).to have_gitlab_http_status(200) + expect(response).to match_response_schema('public_api/v4/branch') + expect(json_response['name']).to eq(CGI.unescape(branch_name)) expect(json_response['protected']).to eq(true) expect(json_response['developers_can_push']).to eq(true) expect(json_response['developers_can_merge']).to eq(true) end + + context 'when branch does not exist' do + let(:branch_name) { 'unknown' } + + it_behaves_like '404 response' do + let(:request) { put api(route, current_user) } + let(:message) { '404 Branch Not Found' } + end + end + + context 'when repository is disabled' do + include_context 'disabled repository' + + it_behaves_like '403 response' do + let(:request) { put api(route, current_user) } + end + end end - context 'for an existing protected branch' do - before do - project.repository.add_branch(user, protected_branch.name, 'master') + context 'when unauthenticated', 'and project is private' do + it_behaves_like '404 response' do + let(:request) { put api(route) } + let(:message) { '404 Project Not Found' } end + end + + context 'when authenticated', 'as a guest' do + it_behaves_like '403 response' do + let(:request) { put api(route, guest) } + end + end + + context 'when authenticated', 'as a master' do + let(:current_user) { user } - context "when developers can push and merge" do - let(:protected_branch) { create(:protected_branch, :developers_can_push, :developers_can_merge, project: project, name: 'protected_branch') } + context "when a protected branch doesn't already exist" do + it_behaves_like 'repository new protected branch' - it 'updates that a developer cannot push or merge' do - put api("/projects/#{project.id}/repository/branches/#{protected_branch.name}/protect", user), - developers_can_push: false, developers_can_merge: false + context 'when branch contains a dot' do + let(:branch_name) { branch_with_dot.name } - expect(response).to have_http_status(200) - expect(json_response['name']).to eq(protected_branch.name) - expect(json_response['protected']).to eq(true) - expect(json_response['developers_can_push']).to eq(false) - expect(json_response['developers_can_merge']).to eq(false) + it_behaves_like 'repository new protected branch' end - it "doesn't result in 0 access levels when 'developers_can_push' is switched off" do - put api("/projects/#{project.id}/repository/branches/#{protected_branch.name}/protect", user), - developers_can_push: false + context 'when branch contains a slash' do + let(:branch_name) { branch_with_slash.name } - expect(response).to have_http_status(200) - expect(json_response['name']).to eq(protected_branch.name) - expect(protected_branch.reload.push_access_levels.first).to be_present - expect(protected_branch.reload.push_access_levels.first.access_level).to eq(Gitlab::Access::MASTER) + it_behaves_like '404 response' do + let(:request) { put api(route, current_user) } + end end - it "doesn't result in 0 access levels when 'developers_can_merge' is switched off" do - put api("/projects/#{project.id}/repository/branches/#{protected_branch.name}/protect", user), - developers_can_merge: false + context 'when branch contains an escaped slash' do + let(:branch_name) { CGI.escape(branch_with_slash.name) } - expect(response).to have_http_status(200) - expect(json_response['name']).to eq(protected_branch.name) - expect(protected_branch.reload.merge_access_levels.first).to be_present - expect(protected_branch.reload.merge_access_levels.first.access_level).to eq(Gitlab::Access::MASTER) + it_behaves_like 'repository new protected branch' + end + + context 'requesting with the escaped project full path' do + let(:project_id) { CGI.escape(project.full_path) } + + it_behaves_like 'repository new protected branch' + + context 'when branch contains a dot' do + let(:branch_name) { branch_with_dot.name } + + it_behaves_like 'repository new protected branch' + end end end - context "when developers cannot push or merge" do - let(:protected_branch) { create(:protected_branch, project: project, name: 'protected_branch') } + context 'when protected branch already exists' do + before do + project.repository.add_branch(user, protected_branch.name, 'master') + end + + context 'when developers can push and merge' do + let(:protected_branch) { create(:protected_branch, :developers_can_push, :developers_can_merge, project: project, name: 'protected_branch') } + + it 'updates that a developer cannot push or merge' do + put api("/projects/#{project.id}/repository/branches/#{protected_branch.name}/protect", user), + developers_can_push: false, developers_can_merge: false + + expect(response).to have_gitlab_http_status(200) + expect(response).to match_response_schema('public_api/v4/branch') + expect(json_response['name']).to eq(protected_branch.name) + expect(json_response['protected']).to eq(true) + expect(json_response['developers_can_push']).to eq(false) + expect(json_response['developers_can_merge']).to eq(false) + expect(protected_branch.reload.push_access_levels.first.access_level).to eq(Gitlab::Access::MASTER) + expect(protected_branch.reload.merge_access_levels.first.access_level).to eq(Gitlab::Access::MASTER) + end + end + + context 'when developers cannot push or merge' do + let(:protected_branch) { create(:protected_branch, project: project, name: 'protected_branch') } - it 'updates that a developer can push and merge' do - put api("/projects/#{project.id}/repository/branches/#{protected_branch.name}/protect", user), - developers_can_push: true, developers_can_merge: true + it 'updates that a developer can push and merge' do + put api("/projects/#{project.id}/repository/branches/#{protected_branch.name}/protect", user), + developers_can_push: true, developers_can_merge: true - expect(response).to have_http_status(200) - expect(json_response['name']).to eq(protected_branch.name) - expect(json_response['protected']).to eq(true) - expect(json_response['developers_can_push']).to eq(true) - expect(json_response['developers_can_merge']).to eq(true) + expect(response).to have_gitlab_http_status(200) + expect(response).to match_response_schema('public_api/v4/branch') + expect(json_response['name']).to eq(protected_branch.name) + expect(json_response['protected']).to eq(true) + expect(json_response['developers_can_push']).to eq(true) + expect(json_response['developers_can_merge']).to eq(true) + end end end end + end - context "multiple API calls" do - it "returns success when `protect` is called twice" do - put api("/projects/#{project.id}/repository/branches/#{branch_name}/protect", user) - put api("/projects/#{project.id}/repository/branches/#{branch_name}/protect", user) + describe 'PUT /projects/:id/repository/branches/:branch/unprotect' do + let(:route) { "/projects/#{project_id}/repository/branches/#{branch_name}/unprotect" } - expect(response).to have_http_status(200) - expect(json_response['name']).to eq(branch_name) - expect(json_response['protected']).to eq(true) - expect(json_response['developers_can_push']).to eq(false) - expect(json_response['developers_can_merge']).to eq(false) + shared_examples_for 'repository unprotected branch' do + it 'unprotects a single branch' do + put api(route, current_user) + + expect(response).to have_gitlab_http_status(200) + expect(response).to match_response_schema('public_api/v4/branch') + expect(json_response['name']).to eq(CGI.unescape(branch_name)) + expect(json_response['protected']).to eq(false) end - it "returns success when `protect` is called twice with `developers_can_push` turned on" do - put api("/projects/#{project.id}/repository/branches/#{branch_name}/protect", user), developers_can_push: true - put api("/projects/#{project.id}/repository/branches/#{branch_name}/protect", user), developers_can_push: true + context 'when branch does not exist' do + let(:branch_name) { 'unknown' } - expect(response).to have_http_status(200) - expect(json_response['name']).to eq(branch_name) - expect(json_response['protected']).to eq(true) - expect(json_response['developers_can_push']).to eq(true) - expect(json_response['developers_can_merge']).to eq(false) + it_behaves_like '404 response' do + let(:request) { put api(route, current_user) } + let(:message) { '404 Branch Not Found' } + end end - it "returns success when `protect` is called twice with `developers_can_merge` turned on" do - put api("/projects/#{project.id}/repository/branches/#{branch_name}/protect", user), developers_can_merge: true - put api("/projects/#{project.id}/repository/branches/#{branch_name}/protect", user), developers_can_merge: true + context 'when repository is disabled' do + include_context 'disabled repository' - expect(response).to have_http_status(200) - expect(json_response['name']).to eq(branch_name) - expect(json_response['protected']).to eq(true) - expect(json_response['developers_can_push']).to eq(false) - expect(json_response['developers_can_merge']).to eq(true) + it_behaves_like '403 response' do + let(:request) { put api(route, current_user) } + end end end - it "returns a 404 error if branch not found" do - put api("/projects/#{project.id}/repository/branches/unknown/protect", user) - expect(response).to have_http_status(404) + context 'when unauthenticated', 'and project is private' do + it_behaves_like '404 response' do + let(:request) { put api(route) } + let(:message) { '404 Project Not Found' } + end end - it "returns a 403 error if guest" do - put api("/projects/#{project.id}/repository/branches/#{branch_name}/protect", guest) - expect(response).to have_http_status(403) + context 'when authenticated', 'as a guest' do + it_behaves_like '403 response' do + let(:request) { put api(route, guest) } + end end - end - describe "PUT /projects/:id/repository/branches/:branch/unprotect" do - it "unprotects a single branch" do - put api("/projects/#{project.id}/repository/branches/#{branch_name}/unprotect", user) - expect(response).to have_http_status(200) + context 'when authenticated', 'as a master' do + let(:current_user) { user } + + context "when a protected branch doesn't already exist" do + it_behaves_like 'repository unprotected branch' + + context 'when branch contains a dot' do + let(:branch_name) { branch_with_dot.name } + + it_behaves_like 'repository unprotected branch' + end + + context 'when branch contains a slash' do + let(:branch_name) { branch_with_slash.name } + + it_behaves_like '404 response' do + let(:request) { put api(route, current_user) } + end + end + + context 'when branch contains an escaped slash' do + let(:branch_name) { CGI.escape(branch_with_slash.name) } - expect(json_response['name']).to eq(branch_name) - expect(json_response['commit']['id']).to eq(branch_sha) - expect(json_response['protected']).to eq(false) + it_behaves_like 'repository unprotected branch' + end + + context 'requesting with the escaped project full path' do + let(:project_id) { CGI.escape(project.full_path) } + + it_behaves_like 'repository unprotected branch' + + context 'when branch contains a dot' do + let(:branch_name) { branch_with_dot.name } + + it_behaves_like 'repository unprotected branch' + end + end + end end + end - it "update branches with dots in branch name" do - put api("/projects/#{project.id}/repository/branches/#{branch_with_dot.name}/unprotect", user) + describe 'POST /projects/:id/repository/branches' do + let(:route) { "/projects/#{project_id}/repository/branches" } - expect(response).to have_http_status(200) - expect(json_response['name']).to eq(branch_with_dot.name) - expect(json_response['protected']).to eq(false) + shared_examples_for 'repository new branch' do + it 'creates a new branch' do + post api(route, current_user), branch: 'feature1', ref: branch_sha + + expect(response).to have_gitlab_http_status(201) + expect(response).to match_response_schema('public_api/v4/branch') + expect(json_response['name']).to eq('feature1') + expect(json_response['commit']['id']).to eq(branch_sha) + end + + context 'when repository is disabled' do + include_context 'disabled repository' + + it_behaves_like '403 response' do + let(:request) { post api(route, current_user) } + end + end end - it "returns success when unprotect branch" do - put api("/projects/#{project.id}/repository/branches/unknown/unprotect", user) - expect(response).to have_http_status(404) + context 'when unauthenticated', 'and project is private' do + it_behaves_like '404 response' do + let(:request) { post api(route) } + let(:message) { '404 Project Not Found' } + end end - it "returns success when unprotect branch again" do - put api("/projects/#{project.id}/repository/branches/#{branch_name}/unprotect", user) - put api("/projects/#{project.id}/repository/branches/#{branch_name}/unprotect", user) - expect(response).to have_http_status(200) + context 'when authenticated', 'as a guest' do + it_behaves_like '403 response' do + let(:request) { post api(route, guest) } + end end - end - describe "POST /projects/:id/repository/branches" do - it "creates a new branch" do - post api("/projects/#{project.id}/repository/branches", user), - branch: 'feature1', - ref: branch_sha + context 'when authenticated', 'as a master' do + let(:current_user) { user } - expect(response).to have_http_status(201) + context "when a protected branch doesn't already exist" do + it_behaves_like 'repository new branch' - expect(json_response['name']).to eq('feature1') - expect(json_response['commit']['id']).to eq(branch_sha) - end + context 'requesting with the escaped project full path' do + let(:project_id) { CGI.escape(project.full_path) } - it "denies for user without push access" do - post api("/projects/#{project.id}/repository/branches", guest), - branch: branch_name, - ref: branch_sha - expect(response).to have_http_status(403) + it_behaves_like 'repository new branch' + end + end end it 'returns 400 if branch name is invalid' do - post api("/projects/#{project.id}/repository/branches", user), - branch: 'new design', - ref: branch_sha - expect(response).to have_http_status(400) + post api(route, user), branch: 'new design', ref: branch_sha + + expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq('Branch name is invalid') end it 'returns 400 if branch already exists' do - post api("/projects/#{project.id}/repository/branches", user), - branch: 'new_design1', - ref: branch_sha - expect(response).to have_http_status(201) - - post api("/projects/#{project.id}/repository/branches", user), - branch: 'new_design1', - ref: branch_sha - expect(response).to have_http_status(400) + post api(route, user), branch: 'new_design1', ref: branch_sha + + expect(response).to have_gitlab_http_status(201) + + post api(route, user), branch: 'new_design1', ref: branch_sha + + expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq('Branch already exists') end it 'returns 400 if ref name is invalid' do - post api("/projects/#{project.id}/repository/branches", user), - branch: 'new_design3', - ref: 'foo' - expect(response).to have_http_status(400) + post api(route, user), branch: 'new_design3', ref: 'foo' + + expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq('Invalid reference name') end end - describe "DELETE /projects/:id/repository/branches/:branch" do + describe 'DELETE /projects/:id/repository/branches/:branch' do before do allow_any_instance_of(Repository).to receive(:rm_branch).and_return(true) end - it "removes branch" do + it 'removes branch' do delete api("/projects/#{project.id}/repository/branches/#{branch_name}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end - it "removes a branch with dots in the branch name" do + it 'removes a branch with dots in the branch name' do delete api("/projects/#{project.id}/repository/branches/#{branch_with_dot.name}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end it 'returns 404 if branch not exists' do delete api("/projects/#{project.id}/repository/branches/foobar", user) - expect(response).to have_http_status(404) + + expect(response).to have_gitlab_http_status(404) end end - describe "DELETE /projects/:id/repository/merged_branches" do + describe 'DELETE /projects/:id/repository/merged_branches' do before do allow_any_instance_of(Repository).to receive(:rm_branch).and_return(true) end @@ -416,13 +509,14 @@ describe API::Branches do it 'returns 202 with json body' do delete api("/projects/#{project.id}/repository/merged_branches", user) - expect(response).to have_http_status(202) + expect(response).to have_gitlab_http_status(202) expect(json_response['message']).to eql('202 Accepted') end it 'returns a 403 error if guest' do delete api("/projects/#{project.id}/repository/merged_branches", guest) - expect(response).to have_http_status(403) + + expect(response).to have_gitlab_http_status(403) end end end diff --git a/spec/requests/api/events_spec.rb b/spec/requests/api/events_spec.rb index a19870a95e8..1754ba66a96 100644 --- a/spec/requests/api/events_spec.rb +++ b/spec/requests/api/events_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe API::Events, api: true do +describe API::Events do include ApiHelpers let(:user) { create(:user) } let(:non_member) { create(:user) } diff --git a/spec/requests/api/groups_spec.rb b/spec/requests/api/groups_spec.rb index 656f098aea8..1d7adc6ac45 100644 --- a/spec/requests/api/groups_spec.rb +++ b/spec/requests/api/groups_spec.rb @@ -510,7 +510,7 @@ describe API::Groups do describe "POST /groups/:id/projects/:project_id" do let(:project) { create(:empty_project) } - let(:project_path) { project.full_path.gsub('/', '%2F') } + let(:project_path) { CGI.escape(project.full_path) } before(:each) do allow_any_instance_of(Projects::TransferService) diff --git a/spec/requests/api/helpers_spec.rb b/spec/requests/api/helpers_spec.rb index 25ec44fa036..7a1bd76af7a 100644 --- a/spec/requests/api/helpers_spec.rb +++ b/spec/requests/api/helpers_spec.rb @@ -10,8 +10,16 @@ describe API::Helpers do let(:key) { create(:key, user: user) } let(:params) { {} } - let(:env) { { 'REQUEST_METHOD' => 'GET' } } - let(:request) { Rack::Request.new(env) } + let(:csrf_token) { SecureRandom.base64(ActionController::RequestForgeryProtection::AUTHENTICITY_TOKEN_LENGTH) } + let(:env) do + { + 'rack.input' => '', + 'rack.session' => { + _csrf_token: csrf_token + }, + 'REQUEST_METHOD' => 'GET' + } + end let(:header) { } before do @@ -58,7 +66,7 @@ describe API::Helpers do describe ".current_user" do subject { current_user } - describe "Warden authentication" do + describe "Warden authentication", :allow_forgery_protection do before do doorkeeper_guard_returns false end @@ -99,7 +107,17 @@ describe API::Helpers do env['REQUEST_METHOD'] = 'PUT' end - it { is_expected.to be_nil } + context 'without CSRF token' do + it { is_expected.to be_nil } + end + + context 'with CSRF token' do + before do + env['HTTP_X_CSRF_TOKEN'] = csrf_token + end + + it { is_expected.to eq(user) } + end end context "POST request" do @@ -107,7 +125,17 @@ describe API::Helpers do env['REQUEST_METHOD'] = 'POST' end - it { is_expected.to be_nil } + context 'without CSRF token' do + it { is_expected.to be_nil } + end + + context 'with CSRF token' do + before do + env['HTTP_X_CSRF_TOKEN'] = csrf_token + end + + it { is_expected.to eq(user) } + end end context "DELETE request" do @@ -115,7 +143,17 @@ describe API::Helpers do env['REQUEST_METHOD'] = 'DELETE' end - it { is_expected.to be_nil } + context 'without CSRF token' do + it { is_expected.to be_nil } + end + + context 'with CSRF token' do + before do + env['HTTP_X_CSRF_TOKEN'] = csrf_token + end + + it { is_expected.to eq(user) } + end end end end diff --git a/spec/requests/api/internal_spec.rb b/spec/requests/api/internal_spec.rb index cab3089c6b1..ce9b9ac1eb3 100644 --- a/spec/requests/api/internal_spec.rb +++ b/spec/requests/api/internal_spec.rb @@ -6,7 +6,7 @@ describe API::Internal do let(:project) { create(:project, :repository) } let(:secret_token) { Gitlab::Shell.secret_token } - describe "GET /internal/check", no_db: true do + describe "GET /internal/check" do it do get api("/internal/check"), secret_token: secret_token diff --git a/spec/requests/api/issues_spec.rb b/spec/requests/api/issues_spec.rb index ff4fc802176..2c44be4e447 100644 --- a/spec/requests/api/issues_spec.rb +++ b/spec/requests/api/issues_spec.rb @@ -71,7 +71,6 @@ describe API::Issues do expect(response).to have_http_status(401) end end - context "when authenticated" do let(:first_issue) { json_response.first } @@ -105,6 +104,42 @@ describe API::Issues do expect(json_response.second['id']).to eq(closed_issue.id) end + it 'returns issues assigned to me' do + issue2 = create(:issue, assignees: [user2], project: project) + + get api('/issues', user2), scope: 'assigned-to-me' + + expect_paginated_array_response(size: 1) + expect(first_issue['id']).to eq(issue2.id) + end + + it 'returns issues authored by the given author id' do + issue2 = create(:issue, author: user2, project: project) + + get api('/issues', user), author_id: user2.id, scope: 'all' + + expect_paginated_array_response(size: 1) + expect(first_issue['id']).to eq(issue2.id) + end + + it 'returns issues assigned to the given assignee id' do + issue2 = create(:issue, assignees: [user2], project: project) + + get api('/issues', user), assignee_id: user2.id, scope: 'all' + + expect_paginated_array_response(size: 1) + expect(first_issue['id']).to eq(issue2.id) + end + + it 'returns issues authored by the given author id and assigned to the given assignee id' do + issue2 = create(:issue, author: user2, assignees: [user2], project: project) + + get api('/issues', user), author_id: user2.id, assignee_id: user2.id, scope: 'all' + + expect_paginated_array_response(size: 1) + expect(first_issue['id']).to eq(issue2.id) + end + it 'returns issues matching given search string for title' do get api("/issues", user), search: issue.title @@ -1224,7 +1259,7 @@ describe API::Issues do put api("/projects/#{project.id}/issues/#{closed_issue.iid}", user), state_event: 'reopen' expect(response).to have_http_status(200) - expect(json_response['state']).to eq 'reopened' + expect(json_response['state']).to eq 'opened' end context 'when an admin or owner makes the request' do diff --git a/spec/requests/api/jobs_spec.rb b/spec/requests/api/jobs_spec.rb index 8d647eb1c7e..f56baf9663d 100644 --- a/spec/requests/api/jobs_spec.rb +++ b/spec/requests/api/jobs_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe API::Jobs, :api do +describe API::Jobs do let!(:project) do create(:project, :repository, public_builds: false) end diff --git a/spec/requests/api/merge_requests_spec.rb b/spec/requests/api/merge_requests_spec.rb index 35b6522ea98..2760c4ffde2 100644 --- a/spec/requests/api/merge_requests_spec.rb +++ b/spec/requests/api/merge_requests_spec.rb @@ -26,6 +26,100 @@ describe API::MergeRequests do project.team << [user, :reporter] end + describe 'GET /merge_requests' do + context 'when unauthenticated' do + it 'returns authentication error' do + get api('/merge_requests') + + expect(response).to have_http_status(401) + end + end + + context 'when authenticated' do + let!(:project2) { create(:empty_project, :public, namespace: user.namespace) } + let!(:merge_request2) { create(:merge_request, :simple, author: user, assignee: user, source_project: project2, target_project: project2) } + let(:user2) { create(:user) } + + it 'returns an array of all merge requests' do + get api('/merge_requests', user), scope: :all + + expect(response).to have_http_status(200) + expect(response).to include_pagination_headers + expect(json_response).to be_an Array + expect(json_response.map { |mr| mr['id'] }) + .to contain_exactly(merge_request.id, merge_request_closed.id, merge_request_merged.id, merge_request2.id) + end + + it 'does not return unauthorized merge requests' do + private_project = create(:empty_project, :private) + merge_request3 = create(:merge_request, :simple, source_project: private_project, target_project: private_project, source_branch: 'other-branch') + + get api('/merge_requests', user), scope: :all + + expect(response).to have_http_status(200) + expect(response).to include_pagination_headers + expect(json_response).to be_an Array + expect(json_response.map { |mr| mr['id'] }) + .not_to include(merge_request3.id) + end + + it 'returns an array of merge requests created by current user if no scope is given' do + merge_request3 = create(:merge_request, :simple, author: user2, assignee: user, source_project: project2, target_project: project2, source_branch: 'other-branch') + + get api('/merge_requests', user2) + + expect(response).to have_http_status(200) + expect(json_response).to be_an Array + expect(json_response.length).to eq(1) + expect(json_response.first['id']).to eq(merge_request3.id) + end + + it 'returns an array of merge requests authored by the given user' do + merge_request3 = create(:merge_request, :simple, author: user2, assignee: user, source_project: project2, target_project: project2, source_branch: 'other-branch') + + get api('/merge_requests', user), author_id: user2.id, scope: :all + + expect(response).to have_http_status(200) + expect(json_response).to be_an Array + expect(json_response.length).to eq(1) + expect(json_response.first['id']).to eq(merge_request3.id) + end + + it 'returns an array of merge requests assigned to the given user' do + merge_request3 = create(:merge_request, :simple, author: user, assignee: user2, source_project: project2, target_project: project2, source_branch: 'other-branch') + + get api('/merge_requests', user), assignee_id: user2.id, scope: :all + + expect(response).to have_http_status(200) + expect(json_response).to be_an Array + expect(json_response.length).to eq(1) + expect(json_response.first['id']).to eq(merge_request3.id) + end + + it 'returns an array of merge requests assigned to me' do + merge_request3 = create(:merge_request, :simple, author: user, assignee: user2, source_project: project2, target_project: project2, source_branch: 'other-branch') + + get api('/merge_requests', user2), scope: 'assigned-to-me' + + expect(response).to have_http_status(200) + expect(json_response).to be_an Array + expect(json_response.length).to eq(1) + expect(json_response.first['id']).to eq(merge_request3.id) + end + + it 'returns an array of merge requests created by me' do + merge_request3 = create(:merge_request, :simple, author: user2, assignee: user, source_project: project2, target_project: project2, source_branch: 'other-branch') + + get api('/merge_requests', user2), scope: 'created-by-me' + + expect(response).to have_http_status(200) + expect(json_response).to be_an Array + expect(json_response.length).to eq(1) + expect(json_response.first['id']).to eq(merge_request3.id) + end + end + end + describe "GET /projects/:id/merge_requests" do context "when unauthenticated" do it "returns authentication error" do diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index 79e7e1a95df..6ed68fcff09 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -768,7 +768,7 @@ describe API::Projects do dot_user = create(:user, username: 'dot.user') project = create(:empty_project, creator_id: dot_user.id, namespace: dot_user.namespace) - get api("/projects/#{dot_user.namespace.name}%2F#{project.path}", dot_user) + get api("/projects/#{CGI.escape(project.full_path)}", dot_user) expect(response).to have_http_status(200) expect(json_response['name']).to eq(project.name) end diff --git a/spec/requests/api/settings_spec.rb b/spec/requests/api/settings_spec.rb index b71ac6c30b5..c3ed5cd8ece 100644 --- a/spec/requests/api/settings_spec.rb +++ b/spec/requests/api/settings_spec.rb @@ -11,7 +11,7 @@ describe API::Settings, 'Settings' do expect(json_response).to be_an Hash expect(json_response['default_projects_limit']).to eq(42) expect(json_response['password_authentication_enabled']).to be_truthy - expect(json_response['repository_storage']).to eq('default') + expect(json_response['repository_storages']).to eq(['default']) expect(json_response['koding_enabled']).to be_falsey expect(json_response['koding_url']).to be_nil expect(json_response['plantuml_enabled']).to be_falsey @@ -33,7 +33,7 @@ describe API::Settings, 'Settings' do put api("/application/settings", admin), default_projects_limit: 3, password_authentication_enabled: false, - repository_storage: 'custom', + repository_storages: ['custom'], koding_enabled: true, koding_url: 'http://koding.example.com', plantuml_enabled: true, @@ -47,7 +47,6 @@ describe API::Settings, 'Settings' do expect(response).to have_http_status(200) expect(json_response['default_projects_limit']).to eq(3) expect(json_response['password_authentication_enabled']).to be_falsey - expect(json_response['repository_storage']).to eq('custom') expect(json_response['repository_storages']).to eq(['custom']) expect(json_response['koding_enabled']).to be_truthy expect(json_response['koding_url']).to eq('http://koding.example.com') diff --git a/spec/requests/api/todos_spec.rb b/spec/requests/api/todos_spec.rb index 92533f4dfea..9fc73c6e092 100644 --- a/spec/requests/api/todos_spec.rb +++ b/spec/requests/api/todos_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe API::Todos do - let(:project_1) { create(:empty_project, :test_repo) } + let(:project_1) { create(:project) } let(:project_2) { create(:empty_project) } let(:author_1) { create(:user) } let(:author_2) { create(:user) } diff --git a/spec/requests/api/triggers_spec.rb b/spec/requests/api/triggers_spec.rb index c2636b6614e..153596c2975 100644 --- a/spec/requests/api/triggers_spec.rb +++ b/spec/requests/api/triggers_spec.rb @@ -22,6 +22,7 @@ describe API::Triggers do before do stub_ci_pipeline_to_return_yaml_file + trigger.update(owner: user) end context 'Handles errors' do @@ -36,12 +37,6 @@ describe API::Triggers do expect(response).to have_http_status(404) end - - it 'returns unauthorized if token is for different project' do - post api("/projects/#{project2.id}/trigger/pipeline"), options.merge(ref: 'master') - - expect(response).to have_http_status(401) - end end context 'Have a commit' do @@ -61,8 +56,7 @@ describe API::Triggers do post api("/projects/#{project.id}/trigger/pipeline"), options.merge(ref: 'other-branch') expect(response).to have_http_status(400) - expect(json_response['message']['base']) - .to contain_exactly('Reference not found') + expect(json_response['message']).to eq('base' => ["Reference not found"]) end context 'Validates variables' do @@ -88,12 +82,18 @@ describe API::Triggers do post api("/projects/#{project.id}/trigger/pipeline"), options.merge(variables: variables, ref: 'master') expect(response).to have_http_status(201) - expect(pipeline.builds.reload.first.trigger_request.variables).to eq(variables) + expect(pipeline.variables.map { |v| { v.key => v.value } }.last).to eq(variables) end end end context 'when triggering a pipeline from a trigger token' do + it 'does not leak the presence of project when token is for different project' do + post api("/projects/#{project2.id}/ref/master/trigger/pipeline?token=#{trigger_token}"), { ref: 'refs/heads/other-branch' } + + expect(response).to have_http_status(404) + end + it 'creates builds from the ref given in the URL, not in the body' do expect do post api("/projects/#{project.id}/ref/master/trigger/pipeline?token=#{trigger_token}"), { ref: 'refs/heads/other-branch' } diff --git a/spec/requests/api/v3/groups_spec.rb b/spec/requests/api/v3/groups_spec.rb index 63c5707b2e4..5cdc528e190 100644 --- a/spec/requests/api/v3/groups_spec.rb +++ b/spec/requests/api/v3/groups_spec.rb @@ -502,7 +502,7 @@ describe API::V3::Groups do describe "POST /groups/:id/projects/:project_id" do let(:project) { create(:empty_project) } - let(:project_path) { "#{project.namespace.path}%2F#{project.path}" } + let(:project_path) { CGI.escape(project.full_path) } before(:each) do allow_any_instance_of(Projects::TransferService) diff --git a/spec/requests/api/v3/issues_spec.rb b/spec/requests/api/v3/issues_spec.rb index cc81922697a..4dff09b6df8 100644 --- a/spec/requests/api/v3/issues_spec.rb +++ b/spec/requests/api/v3/issues_spec.rb @@ -1114,7 +1114,7 @@ describe API::V3::Issues do put v3_api("/projects/#{project.id}/issues/#{closed_issue.id}", user), state_event: 'reopen' expect(response).to have_http_status(200) - expect(json_response['state']).to eq 'reopened' + expect(json_response['state']).to eq 'opened' end context 'when an admin or owner makes the request' do diff --git a/spec/requests/api/v3/project_hooks_spec.rb b/spec/requests/api/v3/project_hooks_spec.rb index 1969d1c7f2b..b0eddbb5dd2 100644 --- a/spec/requests/api/v3/project_hooks_spec.rb +++ b/spec/requests/api/v3/project_hooks_spec.rb @@ -87,7 +87,7 @@ describe API::ProjectHooks, 'ProjectHooks' do it "adds hook to project" do expect do post v3_api("/projects/#{project.id}/hooks", user), - url: "http://example.com", issues_events: true, wiki_page_events: true + url: "http://example.com", issues_events: true, wiki_page_events: true, build_events: true end.to change {project.hooks.count}.by(1) expect(response).to have_http_status(201) @@ -97,7 +97,7 @@ describe API::ProjectHooks, 'ProjectHooks' do expect(json_response['merge_requests_events']).to eq(false) expect(json_response['tag_push_events']).to eq(false) expect(json_response['note_events']).to eq(false) - expect(json_response['build_events']).to eq(false) + expect(json_response['build_events']).to eq(true) expect(json_response['pipeline_events']).to eq(false) expect(json_response['wiki_page_events']).to eq(true) expect(json_response['enable_ssl_verification']).to eq(true) @@ -135,7 +135,7 @@ describe API::ProjectHooks, 'ProjectHooks' do describe "PUT /projects/:id/hooks/:hook_id" do it "updates an existing project hook" do put v3_api("/projects/#{project.id}/hooks/#{hook.id}", user), - url: 'http://example.org', push_events: false + url: 'http://example.org', push_events: false, build_events: true expect(response).to have_http_status(200) expect(json_response['url']).to eq('http://example.org') expect(json_response['issues_events']).to eq(hook.issues_events) diff --git a/spec/requests/api/v3/projects_spec.rb b/spec/requests/api/v3/projects_spec.rb index af44ffa2331..bbfcaab1ea1 100644 --- a/spec/requests/api/v3/projects_spec.rb +++ b/spec/requests/api/v3/projects_spec.rb @@ -720,7 +720,7 @@ describe API::V3::Projects do dot_user = create(:user, username: 'dot.user') project = create(:empty_project, creator_id: dot_user.id, namespace: dot_user.namespace) - get v3_api("/projects/#{dot_user.namespace.name}%2F#{project.path}", dot_user) + get v3_api("/projects/#{CGI.escape(project.full_path)}", dot_user) expect(response).to have_http_status(200) expect(json_response['name']).to eq(project.name) end diff --git a/spec/requests/git_http_spec.rb b/spec/requests/git_http_spec.rb index d043ab2a974..d4a3e8b13e1 100644 --- a/spec/requests/git_http_spec.rb +++ b/spec/requests/git_http_spec.rb @@ -1,6 +1,6 @@ require "spec_helper" -describe 'Git HTTP requests', lib: true do +describe 'Git HTTP requests' do include GitHttpHelpers include WorkhorseHelpers include UserActivitiesHelpers diff --git a/spec/requests/projects/cycle_analytics_events_spec.rb b/spec/requests/projects/cycle_analytics_events_spec.rb index e78d2cfdb33..e5d9d3df5a8 100644 --- a/spec/requests/projects/cycle_analytics_events_spec.rb +++ b/spec/requests/projects/cycle_analytics_events_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'cycle analytics events', api: true do +describe 'cycle analytics events' do let(:user) { create(:user) } let(:project) { create(:project, :repository, public_builds: false) } let(:issue) { create(:issue, project: project, created_at: 2.days.ago) } diff --git a/spec/routing/environments_spec.rb b/spec/routing/environments_spec.rb index 624f3c43f0a..9b70c2a24be 100644 --- a/spec/routing/environments_spec.rb +++ b/spec/routing/environments_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'environments routing', :routing do +describe 'environments routing' do let(:project) { create(:empty_project) } let(:environment) do diff --git a/spec/routing/project_routing_spec.rb b/spec/routing/project_routing_spec.rb index 65314b688a4..c02409b2e0b 100644 --- a/spec/routing/project_routing_spec.rb +++ b/spec/routing/project_routing_spec.rb @@ -610,7 +610,7 @@ describe 'project routing' do end end - describe Projects::Registry::TagsController, :routing do + describe Projects::Registry::TagsController, 'routing' do describe '#destroy' do it 'correctly routes to a destroy action' do expect(delete('/gitlab/gitlabhq/registry/repository/1/tags/rc1')) diff --git a/spec/services/access_token_validation_service_spec.rb b/spec/services/access_token_validation_service_spec.rb index 11225fad18a..38a3f522504 100644 --- a/spec/services/access_token_validation_service_spec.rb +++ b/spec/services/access_token_validation_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe AccessTokenValidationService, services: true do +describe AccessTokenValidationService do describe ".include_any_scope?" do let(:request) { double("request") } diff --git a/spec/services/after_branch_delete_service_spec.rb b/spec/services/after_branch_delete_service_spec.rb index 77ca17bc82c..bc9747d1413 100644 --- a/spec/services/after_branch_delete_service_spec.rb +++ b/spec/services/after_branch_delete_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe AfterBranchDeleteService, services: true do +describe AfterBranchDeleteService do let(:project) { create(:project, :repository) } let(:user) { create(:user) } let(:service) { described_class.new(project, user) } diff --git a/spec/services/auth/container_registry_authentication_service_spec.rb b/spec/services/auth/container_registry_authentication_service_spec.rb index 60cb7a9440f..66a8a93b168 100644 --- a/spec/services/auth/container_registry_authentication_service_spec.rb +++ b/spec/services/auth/container_registry_authentication_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Auth::ContainerRegistryAuthenticationService, services: true do +describe Auth::ContainerRegistryAuthenticationService do let(:current_project) { nil } let(:current_user) { nil } let(:current_params) { {} } diff --git a/spec/services/boards/create_service_spec.rb b/spec/services/boards/create_service_spec.rb index 89615df1692..6e3227303fe 100644 --- a/spec/services/boards/create_service_spec.rb +++ b/spec/services/boards/create_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Boards::CreateService, services: true do +describe Boards::CreateService do describe '#execute' do let(:project) { create(:empty_project) } diff --git a/spec/services/boards/issues/create_service_spec.rb b/spec/services/boards/issues/create_service_spec.rb index 360ee398f77..23ad66e454b 100644 --- a/spec/services/boards/issues/create_service_spec.rb +++ b/spec/services/boards/issues/create_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Boards::Issues::CreateService, services: true do +describe Boards::Issues::CreateService do describe '#execute' do let(:project) { create(:empty_project) } let(:board) { create(:board, project: project) } diff --git a/spec/services/boards/issues/list_service_spec.rb b/spec/services/boards/issues/list_service_spec.rb index a66cc2cd6e9..b1b5d807a78 100644 --- a/spec/services/boards/issues/list_service_spec.rb +++ b/spec/services/boards/issues/list_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Boards::Issues::ListService, services: true do +describe Boards::Issues::ListService do describe '#execute' do let(:user) { create(:user) } let(:project) { create(:empty_project) } @@ -20,7 +20,7 @@ describe Boards::Issues::ListService, services: true do let!(:opened_issue1) { create(:labeled_issue, project: project, labels: [bug]) } let!(:opened_issue2) { create(:labeled_issue, project: project, labels: [p2]) } - let!(:reopened_issue1) { create(:issue, :reopened, project: project) } + let!(:reopened_issue1) { create(:issue, :opened, project: project) } let!(:list1_issue1) { create(:labeled_issue, project: project, labels: [p2, development]) } let!(:list1_issue2) { create(:labeled_issue, project: project, labels: [development]) } diff --git a/spec/services/boards/issues/move_service_spec.rb b/spec/services/boards/issues/move_service_spec.rb index 4ff7ac6bb2f..15a32350ae2 100644 --- a/spec/services/boards/issues/move_service_spec.rb +++ b/spec/services/boards/issues/move_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Boards::Issues::MoveService, services: true do +describe Boards::Issues::MoveService do describe '#execute' do let(:user) { create(:user) } let(:project) { create(:empty_project) } @@ -73,7 +73,7 @@ describe Boards::Issues::MoveService, services: true do issue.reload expect(issue.labels).to contain_exactly(bug, testing) - expect(issue).to be_reopened + expect(issue).to be_opened end end diff --git a/spec/services/boards/list_service_spec.rb b/spec/services/boards/list_service_spec.rb index dff33e4bcbb..a95b12eeaa3 100644 --- a/spec/services/boards/list_service_spec.rb +++ b/spec/services/boards/list_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Boards::ListService, services: true do +describe Boards::ListService do describe '#execute' do let(:project) { create(:empty_project) } diff --git a/spec/services/boards/lists/create_service_spec.rb b/spec/services/boards/lists/create_service_spec.rb index ebac38e68f1..86d3227a78d 100644 --- a/spec/services/boards/lists/create_service_spec.rb +++ b/spec/services/boards/lists/create_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Boards::Lists::CreateService, services: true do +describe Boards::Lists::CreateService do describe '#execute' do let(:project) { create(:empty_project) } let(:board) { create(:board, project: project) } diff --git a/spec/services/boards/lists/destroy_service_spec.rb b/spec/services/boards/lists/destroy_service_spec.rb index af2d7c784bb..ad6ae83286d 100644 --- a/spec/services/boards/lists/destroy_service_spec.rb +++ b/spec/services/boards/lists/destroy_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Boards::Lists::DestroyService, services: true do +describe Boards::Lists::DestroyService do describe '#execute' do let(:project) { create(:empty_project) } let(:board) { create(:board, project: project) } diff --git a/spec/services/boards/lists/generate_service_spec.rb b/spec/services/boards/lists/generate_service_spec.rb index ed0337662af..7dec9f7a4a5 100644 --- a/spec/services/boards/lists/generate_service_spec.rb +++ b/spec/services/boards/lists/generate_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Boards::Lists::GenerateService, services: true do +describe Boards::Lists::GenerateService do describe '#execute' do let(:project) { create(:empty_project) } let(:board) { create(:board, project: project) } diff --git a/spec/services/boards/lists/list_service_spec.rb b/spec/services/boards/lists/list_service_spec.rb index 68140759600..c93788d4516 100644 --- a/spec/services/boards/lists/list_service_spec.rb +++ b/spec/services/boards/lists/list_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Boards::Lists::ListService, services: true do +describe Boards::Lists::ListService do let(:project) { create(:empty_project) } let(:board) { create(:board, project: project) } let(:label) { create(:label, project: project) } diff --git a/spec/services/boards/lists/move_service_spec.rb b/spec/services/boards/lists/move_service_spec.rb index 4b3bdd133f2..43e125a21df 100644 --- a/spec/services/boards/lists/move_service_spec.rb +++ b/spec/services/boards/lists/move_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Boards::Lists::MoveService, services: true do +describe Boards::Lists::MoveService do describe '#execute' do let(:project) { create(:empty_project) } let(:board) { create(:board, project: project) } diff --git a/spec/services/chat_names/authorize_user_service_spec.rb b/spec/services/chat_names/authorize_user_service_spec.rb index d50bfb0492c..d88b2504133 100644 --- a/spec/services/chat_names/authorize_user_service_spec.rb +++ b/spec/services/chat_names/authorize_user_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe ChatNames::AuthorizeUserService, services: true do +describe ChatNames::AuthorizeUserService do describe '#execute' do let(:service) { create(:service) } diff --git a/spec/services/chat_names/find_user_service_spec.rb b/spec/services/chat_names/find_user_service_spec.rb index 0dc96521fa8..79aaac3aeb6 100644 --- a/spec/services/chat_names/find_user_service_spec.rb +++ b/spec/services/chat_names/find_user_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe ChatNames::FindUserService, services: true do +describe ChatNames::FindUserService do describe '#execute' do let(:service) { create(:service) } diff --git a/spec/services/ci/create_pipeline_service_spec.rb b/spec/services/ci/create_pipeline_service_spec.rb index 146d25daba3..4ec495f612e 100644 --- a/spec/services/ci/create_pipeline_service_spec.rb +++ b/spec/services/ci/create_pipeline_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Ci::CreatePipelineService, :services do +describe Ci::CreatePipelineService do let(:project) { create(:project, :repository) } let(:user) { create(:admin) } let(:ref_name) { 'refs/heads/master' } diff --git a/spec/services/ci/create_trigger_request_service_spec.rb b/spec/services/ci/create_trigger_request_service_spec.rb index 37ca9804f56..8295813a1ca 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, services: true do +describe Ci::CreateTriggerRequestService do let(:service) { described_class } let(:project) { create(:project, :repository) } let(:trigger) { create(:ci_trigger, project: project, owner: owner) } diff --git a/spec/services/ci/pipeline_trigger_service_spec.rb b/spec/services/ci/pipeline_trigger_service_spec.rb new file mode 100644 index 00000000000..945a2fe1a6b --- /dev/null +++ b/spec/services/ci/pipeline_trigger_service_spec.rb @@ -0,0 +1,83 @@ +require 'spec_helper' + +describe Ci::PipelineTriggerService, services: true do + let(:project) { create(:project, :repository) } + + before do + stub_ci_pipeline_to_return_yaml_file + end + + describe '#execute' do + let(:user) { create(:user) } + let(:trigger) { create(:ci_trigger, project: project, owner: user) } + let(:result) { described_class.new(project, user, params).execute } + + before do + project.add_developer(user) + end + + context 'when trigger belongs to a different project' do + let(:params) { { token: trigger.token, ref: 'master', variables: nil } } + let(:trigger) { create(:ci_trigger, project: create(:empty_project), owner: user) } + + it 'does nothing' do + expect { result }.not_to change { Ci::Pipeline.count } + end + end + + context 'when params have an existsed trigger token' do + context 'when params have an existsed ref' do + let(:params) { { token: trigger.token, ref: 'master', variables: nil } } + + it 'triggers a pipeline' do + expect { result }.to change { Ci::Pipeline.count }.by(1) + expect(result[:pipeline].ref).to eq('master') + expect(result[:pipeline].project).to eq(project) + expect(result[:pipeline].user).to eq(trigger.owner) + expect(result[:status]).to eq(:success) + end + + context 'when commit message has [ci skip]' do + before do + allow_any_instance_of(Ci::Pipeline).to receive(:git_commit_message) { '[ci skip]' } + end + + it 'ignores [ci skip] and create as general' do + expect { result }.to change { Ci::Pipeline.count }.by(1) + expect(result[:status]).to eq(:success) + end + end + + context 'when params have a variable' do + let(:params) { { token: trigger.token, ref: 'master', variables: variables } } + let(:variables) { { 'AAA' => 'AAA123' } } + + it 'has a variable' do + expect { result }.to change { Ci::PipelineVariable.count }.by(1) + .and change { Ci::TriggerRequest.count }.by(1) + expect(result[:pipeline].variables.map { |v| { v.key => v.value } }.first).to eq(variables) + expect(result[:pipeline].trigger_requests.last.variables).to be_nil + end + end + end + + context 'when params have a non-existsed ref' do + let(:params) { { token: trigger.token, ref: 'invalid-ref', variables: nil } } + + it 'does not trigger a pipeline' do + expect { result }.not_to change { Ci::Pipeline.count } + expect(result[:http_status]).to eq(400) + end + end + end + + context 'when params have a non-existsed trigger token' do + let(:params) { { token: 'invalid-token', ref: nil, variables: nil } } + + it 'does not trigger a pipeline' do + expect { result }.not_to change { Ci::Pipeline.count } + expect(result).to be_nil + end + end + end +end diff --git a/spec/services/ci/play_build_service_spec.rb b/spec/services/ci/play_build_service_spec.rb index ea211de1f82..1ced26ff98d 100644 --- a/spec/services/ci/play_build_service_spec.rb +++ b/spec/services/ci/play_build_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Ci::PlayBuildService, '#execute', :services do +describe Ci::PlayBuildService, '#execute' do let(:user) { create(:user) } let(:project) { create(:empty_project) } let(:pipeline) { create(:ci_pipeline, project: project) } diff --git a/spec/services/ci/process_pipeline_service_spec.rb b/spec/services/ci/process_pipeline_service_spec.rb index 6346f311696..3a702742681 100644 --- a/spec/services/ci/process_pipeline_service_spec.rb +++ b/spec/services/ci/process_pipeline_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Ci::ProcessPipelineService, '#execute', :services do +describe Ci::ProcessPipelineService, '#execute' do let(:user) { create(:user) } let(:project) { create(:empty_project) } diff --git a/spec/services/ci/register_job_service_spec.rb b/spec/services/ci/register_job_service_spec.rb index 62ba0b01339..23c0f715c3e 100644 --- a/spec/services/ci/register_job_service_spec.rb +++ b/spec/services/ci/register_job_service_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' module Ci - describe RegisterJobService, services: true do + describe RegisterJobService do let!(:project) { FactoryGirl.create :empty_project, shared_runners_enabled: false } let!(:pipeline) { FactoryGirl.create :ci_pipeline, project: project } let!(:pending_build) { FactoryGirl.create :ci_build, pipeline: pipeline } diff --git a/spec/services/ci/retry_build_service_spec.rb b/spec/services/ci/retry_build_service_spec.rb index 2cf62b54666..fd8a57d28f0 100644 --- a/spec/services/ci/retry_build_service_spec.rb +++ b/spec/services/ci/retry_build_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Ci::RetryBuildService, :services do +describe Ci::RetryBuildService do let(:user) { create(:user) } let(:project) { create(:empty_project) } let(:pipeline) { create(:ci_pipeline, project: project) } diff --git a/spec/services/ci/retry_pipeline_service_spec.rb b/spec/services/ci/retry_pipeline_service_spec.rb index 7798db3f3b9..90b0c5a4dce 100644 --- a/spec/services/ci/retry_pipeline_service_spec.rb +++ b/spec/services/ci/retry_pipeline_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Ci::RetryPipelineService, '#execute', :services do +describe Ci::RetryPipelineService, '#execute' do let(:user) { create(:user) } let(:project) { create(:empty_project) } let(:pipeline) { create(:ci_pipeline, project: project) } diff --git a/spec/services/ci/stop_environments_service_spec.rb b/spec/services/ci/stop_environments_service_spec.rb index 98044ad232e..e2a9ed27e87 100644 --- a/spec/services/ci/stop_environments_service_spec.rb +++ b/spec/services/ci/stop_environments_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Ci::StopEnvironmentsService, services: true do +describe Ci::StopEnvironmentsService do let(:project) { create(:project, :private, :repository) } let(:user) { create(:user) } diff --git a/spec/services/ci/update_build_queue_service_spec.rb b/spec/services/ci/update_build_queue_service_spec.rb index efefa8e8eca..0da0e57dbcd 100644 --- a/spec/services/ci/update_build_queue_service_spec.rb +++ b/spec/services/ci/update_build_queue_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Ci::UpdateBuildQueueService, :services do +describe Ci::UpdateBuildQueueService do let(:project) { create(:project, :repository) } let(:build) { create(:ci_build, pipeline: pipeline) } let(:pipeline) { create(:ci_pipeline, project: project) } diff --git a/spec/services/ci/update_runner_service_spec.rb b/spec/services/ci/update_runner_service_spec.rb index e429fcfc72f..7cc04c92d27 100644 --- a/spec/services/ci/update_runner_service_spec.rb +++ b/spec/services/ci/update_runner_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Ci::UpdateRunnerService, :services do +describe Ci::UpdateRunnerService do let(:runner) { create(:ci_runner) } describe '#update' do diff --git a/spec/services/compare_service_spec.rb b/spec/services/compare_service_spec.rb index bea7c965233..9e15eae8c13 100644 --- a/spec/services/compare_service_spec.rb +++ b/spec/services/compare_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe CompareService, services: true do +describe CompareService do let(:project) { create(:project, :repository) } let(:user) { create(:user) } let(:service) { described_class.new(project, 'feature') } diff --git a/spec/services/create_branch_service_spec.rb b/spec/services/create_branch_service_spec.rb index 3f548688c20..38096a080a7 100644 --- a/spec/services/create_branch_service_spec.rb +++ b/spec/services/create_branch_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe CreateBranchService, services: true do +describe CreateBranchService do let(:user) { create(:user) } let(:service) { described_class.new(project, user) } diff --git a/spec/services/create_deployment_service_spec.rb b/spec/services/create_deployment_service_spec.rb index 2794721e157..049b082277a 100644 --- a/spec/services/create_deployment_service_spec.rb +++ b/spec/services/create_deployment_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe CreateDeploymentService, services: true do +describe CreateDeploymentService do let(:user) { create(:user) } let(:options) { nil } diff --git a/spec/services/create_release_service_spec.rb b/spec/services/create_release_service_spec.rb index 271ccfe7968..ac0a0458f56 100644 --- a/spec/services/create_release_service_spec.rb +++ b/spec/services/create_release_service_spec.rb @@ -1,11 +1,11 @@ require 'spec_helper' -describe CreateReleaseService, services: true do +describe CreateReleaseService do let(:project) { create(:project, :repository) } let(:user) { create(:user) } let(:tag_name) { project.repository.tag_names.first } let(:description) { 'Awesome release!' } - let(:service) { CreateReleaseService.new(project, user) } + let(:service) { described_class.new(project, user) } it 'creates a new release' do result = service.execute(tag_name, description) diff --git a/spec/services/create_snippet_service_spec.rb b/spec/services/create_snippet_service_spec.rb index d81d0fd76c9..b6ab6b8271c 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, services: true do +describe CreateSnippetService do before do @user = create :user @admin = create :user, admin: true diff --git a/spec/services/delete_branch_service_spec.rb b/spec/services/delete_branch_service_spec.rb index c4685c9aa31..19855c9bee2 100644 --- a/spec/services/delete_branch_service_spec.rb +++ b/spec/services/delete_branch_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe DeleteBranchService, services: true do +describe DeleteBranchService do let(:project) { create(:project, :repository) } let(:repository) { project.repository } let(:user) { create(:user) } diff --git a/spec/services/delete_merged_branches_service_spec.rb b/spec/services/delete_merged_branches_service_spec.rb index fe21ca0b3cb..4b872d667cf 100644 --- a/spec/services/delete_merged_branches_service_spec.rb +++ b/spec/services/delete_merged_branches_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe DeleteMergedBranchesService, services: true do +describe DeleteMergedBranchesService do subject(:service) { described_class.new(project, project.owner) } let(:project) { create(:project, :repository) } @@ -43,7 +43,7 @@ describe DeleteMergedBranchesService, services: true do context 'open merge requests' do it 'does not delete branches from open merge requests' do fork_link = create(:forked_project_link, forked_from_project: project) - create(:merge_request, :reopened, source_project: project, target_project: project, source_branch: 'branch-merged', target_branch: 'master') + create(:merge_request, :opened, source_project: project, target_project: project, source_branch: 'branch-merged', target_branch: 'master') create(:merge_request, :opened, source_project: fork_link.forked_to_project, target_project: project, target_branch: 'improve/awesome', source_branch: 'master') service.execute diff --git a/spec/services/discussions/update_diff_position_service_spec.rb b/spec/services/discussions/update_diff_position_service_spec.rb index 177e32e13bd..c239494298b 100644 --- a/spec/services/discussions/update_diff_position_service_spec.rb +++ b/spec/services/discussions/update_diff_position_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Discussions::UpdateDiffPositionService, services: true do +describe Discussions::UpdateDiffPositionService do let(:project) { create(:project, :repository) } let(:current_user) { project.owner } let(:create_commit) { project.commit("913c66a37b4a45b9769037c55c2d238bd0942d2e") } diff --git a/spec/services/emails/create_service_spec.rb b/spec/services/emails/create_service_spec.rb index c1f477f551e..641d5538de8 100644 --- a/spec/services/emails/create_service_spec.rb +++ b/spec/services/emails/create_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Emails::CreateService, services: true do +describe Emails::CreateService do let(:user) { create(:user) } let(:opts) { { email: 'new@email.com' } } diff --git a/spec/services/emails/destroy_service_spec.rb b/spec/services/emails/destroy_service_spec.rb index 5e7ab4a40af..1f4294dd905 100644 --- a/spec/services/emails/destroy_service_spec.rb +++ b/spec/services/emails/destroy_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Emails::DestroyService, services: true do +describe Emails::DestroyService do let!(:user) { create(:user) } let!(:email) { create(:email, user: user) } diff --git a/spec/services/event_create_service_spec.rb b/spec/services/event_create_service_spec.rb index 8d067c194cc..00104ae1fd9 100644 --- a/spec/services/event_create_service_spec.rb +++ b/spec/services/event_create_service_spec.rb @@ -1,9 +1,9 @@ require 'spec_helper' -describe EventCreateService, services: true do +describe EventCreateService do include UserActivitiesHelpers - let(:service) { EventCreateService.new } + let(:service) { described_class.new } describe 'Issues' do describe '#open_issue' do diff --git a/spec/services/git_hooks_service_spec.rb b/spec/services/git_hooks_service_spec.rb index 213678c27f5..3ce01a995b4 100644 --- a/spec/services/git_hooks_service_spec.rb +++ b/spec/services/git_hooks_service_spec.rb @@ -1,11 +1,11 @@ require 'spec_helper' -describe GitHooksService, services: true do +describe GitHooksService do include RepoHelpers let(:user) { create(:user) } let(:project) { create(:project, :repository) } - let(:service) { GitHooksService.new } + let(:service) { described_class.new } before do @blankrev = Gitlab::Git::BLANK_SHA diff --git a/spec/services/git_push_service_spec.rb b/spec/services/git_push_service_spec.rb index f801506f1b6..3fb677b65be 100644 --- a/spec/services/git_push_service_spec.rb +++ b/spec/services/git_push_service_spec.rb @@ -3,27 +3,24 @@ require 'spec_helper' describe GitPushService, services: true do include RepoHelpers - let(:user) { create(:user) } - let(:project) { create(:project, :repository) } + let(:user) { create(:user) } + let(:project) { create(:project, :repository) } + let(:blankrev) { Gitlab::Git::BLANK_SHA } + let(:oldrev) { sample_commit.parent_id } + let(:newrev) { sample_commit.id } + let(:ref) { 'refs/heads/master' } before do project.team << [user, :master] - @blankrev = Gitlab::Git::BLANK_SHA - @oldrev = sample_commit.parent_id - @newrev = sample_commit.id - @ref = 'refs/heads/master' end describe 'Push branches' do - let(:oldrev) { @oldrev } - let(:newrev) { @newrev } - subject do - execute_service(project, user, oldrev, newrev, @ref ) + execute_service(project, user, oldrev, newrev, ref) end context 'new branch' do - let(:oldrev) { @blankrev } + let(:oldrev) { blankrev } it { is_expected.to be_truthy } @@ -51,7 +48,7 @@ describe GitPushService, services: true do end context 'rm branch' do - let(:newrev) { @blankrev } + let(:newrev) { blankrev } it { is_expected.to be_truthy } @@ -70,24 +67,20 @@ describe GitPushService, services: true do end describe "Git Push Data" do - before do - service = execute_service(project, user, @oldrev, @newrev, @ref ) - @push_data = service.push_data - @commit = project.commit(@newrev) - end + let(:commit) { project.commit(newrev) } - subject { @push_data } + subject { push_data_from_service(project, user, oldrev, newrev, ref) } it { is_expected.to include(object_kind: 'push') } - it { is_expected.to include(before: @oldrev) } - it { is_expected.to include(after: @newrev) } - it { is_expected.to include(ref: @ref) } + it { is_expected.to include(before: oldrev) } + it { is_expected.to include(after: newrev) } + it { is_expected.to include(ref: ref) } it { is_expected.to include(user_id: user.id) } it { is_expected.to include(user_name: user.name) } it { is_expected.to include(project_id: project.id) } context "with repository data" do - subject { @push_data[:repository] } + subject { push_data_from_service(project, user, oldrev, newrev, ref)[:repository] } it { is_expected.to include(name: project.name) } it { is_expected.to include(url: project.url_to_repo) } @@ -96,7 +89,7 @@ describe GitPushService, services: true do end context "with commits" do - subject { @push_data[:commits] } + subject { push_data_from_service(project, user, oldrev, newrev, ref)[:commits] } it { is_expected.to be_an(Array) } it 'has 1 element' do @@ -104,11 +97,11 @@ describe GitPushService, services: true do end context "the commit" do - subject { @push_data[:commits].first } + subject { push_data_from_service(project, user, oldrev, newrev, ref)[:commits].first } - it { is_expected.to include(id: @commit.id) } - it { is_expected.to include(message: @commit.safe_message) } - it { expect(subject[:timestamp].in_time_zone).to eq(@commit.date.in_time_zone) } + it { is_expected.to include(id: commit.id) } + it { is_expected.to include(message: commit.safe_message) } + it { expect(subject[:timestamp].in_time_zone).to eq(commit.date.in_time_zone) } it do is_expected.to include( url: [ @@ -116,23 +109,23 @@ describe GitPushService, services: true do project.namespace.to_param, project.to_param, 'commit', - @commit.id + commit.id ].join('/') ) end context "with a author" do - subject { @push_data[:commits].first[:author] } + subject { push_data_from_service(project, user, oldrev, newrev, ref)[:commits].first[:author] } - it { is_expected.to include(name: @commit.author_name) } - it { is_expected.to include(email: @commit.author_email) } + it { is_expected.to include(name: commit.author_name) } + it { is_expected.to include(email: commit.author_email) } end end end end describe "Pipelines" do - subject { execute_service(project, user, @oldrev, @newrev, @ref) } + subject { execute_service(project, user, oldrev, newrev, ref) } before do stub_ci_pipeline_to_return_yaml_file @@ -145,29 +138,26 @@ describe GitPushService, services: true do end describe "Push Event" do - before do - service = execute_service(project, user, @oldrev, @newrev, @ref ) - @event = Event.find_by_action(Event::PUSHED) - @push_data = service.push_data - end + let!(:push_data) { push_data_from_service(project, user, oldrev, newrev, ref) } + let(:event) { Event.find_by_action(Event::PUSHED) } - it { expect(@event).not_to be_nil } - it { expect(@event.project).to eq(project) } - it { expect(@event.action).to eq(Event::PUSHED) } - it { expect(@event.data).to eq(@push_data) } + it { expect(event).not_to be_nil } + it { expect(event.project).to eq(project) } + it { expect(event.action).to eq(Event::PUSHED) } + it { expect(event.data).to eq(push_data) } context "Updates merge requests" do it "when pushing a new branch for the first time" do expect(UpdateMergeRequestsWorker).to receive(:perform_async) - .with(project.id, user.id, @blankrev, 'newrev', 'refs/heads/master') - execute_service(project, user, @blankrev, 'newrev', 'refs/heads/master' ) + .with(project.id, user.id, blankrev, 'newrev', ref) + execute_service(project, user, blankrev, 'newrev', ref ) end end context "Sends System Push data" do it "when pushing on a branch" do - expect(SystemHookPushWorker).to receive(:perform_async).with(@push_data, :push_hooks) - execute_service(project, user, @oldrev, @newrev, @ref ) + expect(SystemHookPushWorker).to receive(:perform_async).with(push_data, :push_hooks) + execute_service(project, user, oldrev, newrev, ref) end end end @@ -177,13 +167,13 @@ describe GitPushService, services: true do it "calls the copy attributes method for the first push to the default branch" do expect(project.repository).to receive(:copy_gitattributes).with('master') - execute_service(project, user, @blankrev, 'newrev', 'refs/heads/master') + execute_service(project, user, blankrev, 'newrev', ref) end it "calls the copy attributes method for changes to the default branch" do - expect(project.repository).to receive(:copy_gitattributes).with('refs/heads/master') + expect(project.repository).to receive(:copy_gitattributes).with(ref) - execute_service(project, user, 'oldrev', 'newrev', 'refs/heads/master') + execute_service(project, user, 'oldrev', 'newrev', ref) end end @@ -196,7 +186,7 @@ describe GitPushService, services: true do it "does not call copy attributes method" do expect(project.repository).not_to receive(:copy_gitattributes) - execute_service(project, user, @oldrev, @newrev, @ref) + execute_service(project, user, oldrev, newrev, ref) end end end @@ -206,7 +196,7 @@ describe GitPushService, services: true do it "when pushing a branch for the first time" do expect(project).to receive(:execute_hooks) expect(project.default_branch).to eq("master") - execute_service(project, user, @blankrev, 'newrev', 'refs/heads/master' ) + execute_service(project, user, blankrev, 'newrev', ref) expect(project.protected_branches).not_to be_empty expect(project.protected_branches.first.push_access_levels.map(&:access_level)).to eq([Gitlab::Access::MASTER]) expect(project.protected_branches.first.merge_access_levels.map(&:access_level)).to eq([Gitlab::Access::MASTER]) @@ -217,7 +207,7 @@ describe GitPushService, services: true do expect(project).to receive(:execute_hooks) expect(project.default_branch).to eq("master") - execute_service(project, user, @blankrev, 'newrev', 'refs/heads/master' ) + execute_service(project, user, blankrev, 'newrev', ref) expect(project.protected_branches).to be_empty end @@ -227,7 +217,7 @@ describe GitPushService, services: true do expect(project).to receive(:execute_hooks) expect(project.default_branch).to eq("master") - execute_service(project, user, @blankrev, 'newrev', 'refs/heads/master' ) + execute_service(project, user, blankrev, 'newrev', ref) expect(project.protected_branches).not_to be_empty expect(project.protected_branches.last.push_access_levels.map(&:access_level)).to eq([Gitlab::Access::DEVELOPER]) @@ -242,7 +232,7 @@ describe GitPushService, services: true do expect(project.default_branch).to eq("master") expect_any_instance_of(ProtectedBranches::CreateService).not_to receive(:execute) - execute_service(project, user, @blankrev, 'newrev', 'refs/heads/master' ) + execute_service(project, user, blankrev, 'newrev', ref) expect(project.protected_branches).not_to be_empty expect(project.protected_branches.last.push_access_levels.map(&:access_level)).to eq([Gitlab::Access::NO_ACCESS]) @@ -254,7 +244,7 @@ describe GitPushService, services: true do expect(project).to receive(:execute_hooks) expect(project.default_branch).to eq("master") - execute_service(project, user, @blankrev, 'newrev', 'refs/heads/master' ) + execute_service(project, user, blankrev, 'newrev', ref) expect(project.protected_branches).not_to be_empty expect(project.protected_branches.first.push_access_levels.map(&:access_level)).to eq([Gitlab::Access::MASTER]) expect(project.protected_branches.first.merge_access_levels.map(&:access_level)).to eq([Gitlab::Access::DEVELOPER]) @@ -262,7 +252,7 @@ describe GitPushService, services: true do it "when pushing new commits to existing branch" do expect(project).to receive(:execute_hooks) - execute_service(project, user, 'oldrev', 'newrev', 'refs/heads/master' ) + execute_service(project, user, 'oldrev', 'newrev', ref) end end end @@ -292,7 +282,7 @@ describe GitPushService, services: true do it "creates a note if a pushed commit mentions an issue" do expect(SystemNoteService).to receive(:cross_reference).with(issue, commit, commit_author) - execute_service(project, user, @oldrev, @newrev, @ref ) + execute_service(project, user, oldrev, newrev, ref) end it "only creates a cross-reference note if one doesn't already exist" do @@ -300,7 +290,7 @@ describe GitPushService, services: true do expect(SystemNoteService).not_to receive(:cross_reference).with(issue, commit, commit_author) - execute_service(project, user, @oldrev, @newrev, @ref ) + execute_service(project, user, oldrev, newrev, ref) end it "defaults to the pushing user if the commit's author is not known" do @@ -310,16 +300,16 @@ describe GitPushService, services: true do ) expect(SystemNoteService).to receive(:cross_reference).with(issue, commit, user) - execute_service(project, user, @oldrev, @newrev, @ref ) + execute_service(project, user, oldrev, newrev, ref) end it "finds references in the first push to a non-default branch" do - allow(project.repository).to receive(:commits_between).with(@blankrev, @newrev).and_return([]) - allow(project.repository).to receive(:commits_between).with("master", @newrev).and_return([commit]) + allow(project.repository).to receive(:commits_between).with(blankrev, newrev).and_return([]) + allow(project.repository).to receive(:commits_between).with("master", newrev).and_return([commit]) expect(SystemNoteService).to receive(:cross_reference).with(issue, commit, commit_author) - execute_service(project, user, @blankrev, @newrev, 'refs/heads/other' ) + execute_service(project, user, blankrev, newrev, 'refs/heads/other') end end @@ -349,14 +339,14 @@ describe GitPushService, services: true do context "while saving the 'first_mentioned_in_commit_at' metric for an issue" do it 'sets the metric for referenced issues' do - execute_service(project, user, @oldrev, @newrev, @ref) + execute_service(project, user, oldrev, newrev, ref) expect(issue.reload.metrics.first_mentioned_in_commit_at).to be_like_time(commit_time) end it 'does not set the metric for non-referenced issues' do non_referenced_issue = create(:issue, project: project) - execute_service(project, user, @oldrev, @newrev, @ref) + execute_service(project, user, oldrev, newrev, ref) expect(non_referenced_issue.reload.metrics.first_mentioned_in_commit_at).to be_nil end @@ -388,18 +378,18 @@ describe GitPushService, services: true do context "to default branches" do it "closes issues" do - execute_service(project, commit_author, @oldrev, @newrev, @ref ) + execute_service(project, commit_author, oldrev, newrev, ref) expect(Issue.find(issue.id)).to be_closed end it "adds a note indicating that the issue is now closed" do expect(SystemNoteService).to receive(:change_status).with(issue, project, commit_author, "closed", closing_commit) - execute_service(project, commit_author, @oldrev, @newrev, @ref ) + execute_service(project, commit_author, oldrev, newrev, ref) end it "doesn't create additional cross-reference notes" do expect(SystemNoteService).not_to receive(:cross_reference) - execute_service(project, commit_author, @oldrev, @newrev, @ref ) + execute_service(project, commit_author, oldrev, newrev, ref) end end @@ -411,11 +401,11 @@ describe GitPushService, services: true do it "creates cross-reference notes" do expect(SystemNoteService).to receive(:cross_reference).with(issue, closing_commit, commit_author) - execute_service(project, user, @oldrev, @newrev, @ref ) + execute_service(project, user, oldrev, newrev, ref) end it "doesn't close issues" do - execute_service(project, user, @oldrev, @newrev, @ref ) + execute_service(project, user, oldrev, newrev, ref) expect(Issue.find(issue.id)).to be_opened end end @@ -432,11 +422,12 @@ describe GitPushService, services: true do stub_jira_urls("JIRA-1") allow(closing_commit).to receive_messages({ - issue_closing_regex: Regexp.new(Gitlab.config.gitlab.issue_closing_pattern), - safe_message: message, - author_name: commit_author.name, - author_email: commit_author.email - }) + issue_closing_regex: Regexp.new(Gitlab.config.gitlab.issue_closing_pattern), + safe_message: message, + author_name: commit_author.name, + author_email: commit_author.email + }) + allow(JIRA::Resource::Remotelink).to receive(:all).and_return([]) allow(project.repository).to receive_messages(commits_between: [closing_commit]) @@ -450,7 +441,7 @@ describe GitPushService, services: true do let(:message) { "this is some work.\n\nrelated to JIRA-1" } it "initiates one api call to jira server to mention the issue" do - execute_service(project, user, @oldrev, @newrev, @ref) + execute_service(project, user, oldrev, newrev, ref) expect(WebMock).to have_requested(:post, jira_api_comment_url('JIRA-1')).with( body: /mentioned this issue in/ @@ -460,7 +451,11 @@ describe GitPushService, services: true do context "closing an issue" do let(:message) { "this is some work.\n\ncloses JIRA-1" } - let(:comment_body) { { body: "Issue solved with [#{closing_commit.id}|http://#{Gitlab.config.gitlab.host}/#{project.path_with_namespace}/commit/#{closing_commit.id}]." }.to_json } + let(:comment_body) do + { + body: "Issue solved with [#{closing_commit.id}|http://#{Gitlab.config.gitlab.host}/#{project.path_with_namespace}/commit/#{closing_commit.id}]." + }.to_json + end before do open_issue = JIRA::Resource::Issue.new(jira_tracker.client, attrs: { "id" => "JIRA-1" }) @@ -474,13 +469,13 @@ describe GitPushService, services: true do context "using right markdown" do it "initiates one api call to jira server to close the issue" do - execute_service(project, commit_author, @oldrev, @newrev, @ref ) + execute_service(project, commit_author, oldrev, newrev, ref) expect(WebMock).to have_requested(:post, jira_api_transition_url('JIRA-1')).once end it "initiates one api call to jira server to comment on the issue" do - execute_service(project, commit_author, @oldrev, @newrev, @ref ) + execute_service(project, commit_author, oldrev, newrev, ref) expect(WebMock).to have_requested(:post, jira_api_comment_url('JIRA-1')).with( body: comment_body @@ -497,13 +492,13 @@ describe GitPushService, services: true do let(:message) { "this is some work.\n\ncloses #1" } it "does not initiates one api call to jira server to close the issue" do - execute_service(project, commit_author, @oldrev, @newrev, @ref ) + execute_service(project, commit_author, oldrev, newrev, ref) expect(WebMock).not_to have_requested(:post, jira_api_transition_url('JIRA-1')) end it "does not initiates one api call to jira server to comment on the issue" do - execute_service(project, commit_author, @oldrev, @newrev, @ref ) + execute_service(project, commit_author, oldrev, newrev, ref) expect(WebMock).not_to have_requested(:post, jira_api_comment_url('JIRA-1')).with( body: comment_body @@ -516,13 +511,13 @@ describe GitPushService, services: true do let(:message) { "this is some work.\n\ncloses JIRA-1 \n\n closes #{issue.to_reference}" } it "initiates one api call to jira server to close the jira issue" do - execute_service(project, commit_author, @oldrev, @newrev, @ref ) + execute_service(project, commit_author, oldrev, newrev, ref) expect(WebMock).to have_requested(:post, jira_api_transition_url('JIRA-1')).once end it "initiates one api call to jira server to comment on the jira issue" do - execute_service(project, commit_author, @oldrev, @newrev, @ref ) + execute_service(project, commit_author, oldrev, newrev, ref) expect(WebMock).to have_requested(:post, jira_api_comment_url('JIRA-1')).with( body: comment_body @@ -530,14 +525,14 @@ describe GitPushService, services: true do end it "closes the internal issue" do - execute_service(project, commit_author, @oldrev, @newrev, @ref ) + execute_service(project, commit_author, oldrev, newrev, ref) expect(issue.reload).to be_closed end it "adds a note indicating that the issue is now closed" do expect(SystemNoteService).to receive(:change_status) .with(issue, project, commit_author, "closed", closing_commit) - execute_service(project, commit_author, @oldrev, @newrev, @ref ) + execute_service(project, commit_author, oldrev, newrev, ref) end end end @@ -547,7 +542,7 @@ describe GitPushService, services: true do describe "empty project" do let(:project) { create(:project_empty_repo) } - let(:new_ref) { 'refs/heads/feature'} + let(:new_ref) { 'refs/heads/feature' } before do allow(project).to receive(:default_branch).and_return('feature') @@ -555,7 +550,7 @@ describe GitPushService, services: true do end it 'push to first branch updates HEAD' do - execute_service(project, user, @blankrev, @newrev, new_ref ) + execute_service(project, user, blankrev, newrev, new_ref) end end @@ -580,7 +575,7 @@ describe GitPushService, services: true do it 'does not perform housekeeping when not needed' do expect(housekeeping).not_to receive(:execute) - execute_service(project, user, @oldrev, @newrev, @ref) + execute_service(project, user, oldrev, newrev, ref) end context 'when housekeeping is needed' do @@ -591,20 +586,20 @@ describe GitPushService, services: true do it 'performs housekeeping' do expect(housekeeping).to receive(:execute) - execute_service(project, user, @oldrev, @newrev, @ref) + execute_service(project, user, oldrev, newrev, ref) end it 'does not raise an exception' do allow(housekeeping).to receive(:try_obtain_lease).and_return(false) - execute_service(project, user, @oldrev, @newrev, @ref) + execute_service(project, user, oldrev, newrev, ref) end end it 'increments the push counter' do expect(housekeeping).to receive(:increment!) - execute_service(project, user, @oldrev, @newrev, @ref) + execute_service(project, user, oldrev, newrev, ref) end end @@ -612,9 +607,9 @@ describe GitPushService, services: true do let(:service) do described_class.new(project, user, - oldrev: sample_commit.parent_id, - newrev: sample_commit.id, - ref: 'refs/heads/master') + oldrev: oldrev, + newrev: newrev, + ref: ref) end context 'on the default branch' do @@ -657,14 +652,13 @@ describe GitPushService, services: true do let(:service) do described_class.new(project, user, - oldrev: sample_commit.parent_id, - newrev: sample_commit.id, - ref: 'refs/heads/master') + oldrev: oldrev, + newrev: newrev, + ref: ref) end it 'only schedules a limited number of commits' do - allow(service).to receive(:push_commits) - .and_return(Array.new(1000, double(:commit, to_hash: {}, matches_cross_reference_regex?: true))) + service.push_commits = Array.new(1000, double(:commit, to_hash: {}, matches_cross_reference_regex?: true)) expect(ProcessCommitWorker).to receive(:perform_async).exactly(100).times @@ -672,8 +666,7 @@ describe GitPushService, services: true do end it "skips commits which don't include cross-references" do - allow(service).to receive(:push_commits) - .and_return([double(:commit, to_hash: {}, matches_cross_reference_regex?: false)]) + service.push_commits = [double(:commit, to_hash: {}, matches_cross_reference_regex?: false)] expect(ProcessCommitWorker).not_to receive(:perform_async) @@ -681,9 +674,31 @@ describe GitPushService, services: true do end end + describe '#update_signatures' do + let(:service) do + described_class.new( + project, + user, + oldrev: oldrev, + newrev: newrev, + ref: 'refs/heads/master' + ) + end + + it 'calls CreateGpgSignatureWorker.perform_async for each commit' do + expect(CreateGpgSignatureWorker).to receive(:perform_async).with(sample_commit.id, project.id) + + execute_service(project, user, oldrev, newrev, ref) + end + end + def execute_service(project, user, oldrev, newrev, ref) - service = described_class.new(project, user, oldrev: oldrev, newrev: newrev, ref: ref ) + service = described_class.new(project, user, oldrev: oldrev, newrev: newrev, ref: ref) service.execute service end + + def push_data_from_service(project, user, oldrev, newrev, ref) + execute_service(project, user, oldrev, newrev, ref).push_data + end end diff --git a/spec/services/git_tag_push_service_spec.rb b/spec/services/git_tag_push_service_spec.rb index 1fdcb420a8b..f877c145390 100644 --- a/spec/services/git_tag_push_service_spec.rb +++ b/spec/services/git_tag_push_service_spec.rb @@ -1,11 +1,11 @@ require 'spec_helper' -describe GitTagPushService, services: true do +describe GitTagPushService do include RepoHelpers let(:user) { create(:user) } let(:project) { create(:project, :repository) } - let(:service) { GitTagPushService.new(project, user, oldrev: oldrev, newrev: newrev, ref: ref) } + let(:service) { described_class.new(project, user, oldrev: oldrev, newrev: newrev, ref: ref) } let(:oldrev) { Gitlab::Git::BLANK_SHA } let(:newrev) { "8a2a6eb295bb170b34c24c76c49ed0e9b2eaf34b" } # gitlab-test: git rev-parse refs/tags/v1.1.0 @@ -184,7 +184,7 @@ describe GitTagPushService, services: true do describe "Webhooks" do context "execute webhooks" do - let(:service) { GitTagPushService.new(project, user, oldrev: 'oldrev', newrev: 'newrev', ref: 'refs/tags/v1.0.0') } + let(:service) { described_class.new(project, user, oldrev: 'oldrev', newrev: 'newrev', ref: 'refs/tags/v1.0.0') } it "when pushing tags" do expect(project).to receive(:execute_hooks) diff --git a/spec/services/gravatar_service_spec.rb b/spec/services/gravatar_service_spec.rb index 8c4ad8c7a3e..d2cc53fe0ee 100644 --- a/spec/services/gravatar_service_spec.rb +++ b/spec/services/gravatar_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe GravatarService, service: true do +describe GravatarService do describe '#execute' do let(:url) { 'http://example.com/avatar?hash=%{hash}&size=%{size}&email=%{email}&username=%{username}' } diff --git a/spec/services/groups/create_service_spec.rb b/spec/services/groups/create_service_spec.rb index fbd9026640c..b2175717a70 100644 --- a/spec/services/groups/create_service_spec.rb +++ b/spec/services/groups/create_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Groups::CreateService, '#execute', services: true do +describe Groups::CreateService, '#execute' do let!(:user) { create(:user) } let!(:group_params) { { path: "group_path", visibility_level: Gitlab::VisibilityLevel::PUBLIC } } diff --git a/spec/services/groups/destroy_service_spec.rb b/spec/services/groups/destroy_service_spec.rb index d59b37bee36..c18870ea100 100644 --- a/spec/services/groups/destroy_service_spec.rb +++ b/spec/services/groups/destroy_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Groups::DestroyService, services: true do +describe Groups::DestroyService do include DatabaseConnectionHelpers let!(:user) { create(:user) } @@ -35,6 +35,16 @@ describe Groups::DestroyService, services: true do it { expect(NotificationSetting.unscoped.all).not_to include(notification_setting) } end + context 'mattermost team' do + let!(:chat_team) { create(:chat_team, namespace: group) } + + it 'destroys the team too' do + expect_any_instance_of(Mattermost::Team).to receive(:destroy) + + destroy_group(group, user, async) + end + end + context 'file system' do context 'Sidekiq inline' do before do @@ -100,7 +110,7 @@ describe Groups::DestroyService, services: true do # Kick off the initial group destroy in a new thread, so that # it doesn't share this spec's database transaction. - Thread.new { Groups::DestroyService.new(group, user).async_execute }.join(5) + Thread.new { described_class.new(group, user).async_execute }.join(5) group_record = run_with_new_database_connection do |conn| conn.execute("SELECT * FROM namespaces WHERE id = #{group.id}").first diff --git a/spec/services/groups/update_service_spec.rb b/spec/services/groups/update_service_spec.rb index f6ad5cebd2c..9902e1aff8b 100644 --- a/spec/services/groups/update_service_spec.rb +++ b/spec/services/groups/update_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Groups::UpdateService, services: true do +describe Groups::UpdateService do let!(:user) { create(:user) } let!(:private_group) { create(:group, :private) } let!(:internal_group) { create(:group, :internal) } diff --git a/spec/services/import_export_clean_up_service_spec.rb b/spec/services/import_export_clean_up_service_spec.rb index 81b1d327696..1875d0448cd 100644 --- a/spec/services/import_export_clean_up_service_spec.rb +++ b/spec/services/import_export_clean_up_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe ImportExportCleanUpService, services: true do +describe ImportExportCleanUpService do describe '#execute' do let(:service) { described_class.new } diff --git a/spec/services/issuable/bulk_update_service_spec.rb b/spec/services/issuable/bulk_update_service_spec.rb index eb9b1670c71..055aa6156cb 100644 --- a/spec/services/issuable/bulk_update_service_spec.rb +++ b/spec/services/issuable/bulk_update_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Issuable::BulkUpdateService, services: true do +describe Issuable::BulkUpdateService do let(:user) { create(:user) } let(:project) { create(:empty_project, namespace: user.namespace) } diff --git a/spec/services/issues/build_service_spec.rb b/spec/services/issues/build_service_spec.rb index bed25fe7ccf..03f76bd428d 100644 --- a/spec/services/issues/build_service_spec.rb +++ b/spec/services/issues/build_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper.rb' -describe Issues::BuildService, services: true do +describe Issues::BuildService do let(:project) { create(:project, :repository) } let(:user) { create(:user) } diff --git a/spec/services/issues/close_service_spec.rb b/spec/services/issues/close_service_spec.rb index da8b60f1337..a03f68434de 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, services: true do +describe Issues::CloseService do let(:user) { create(:user) } let(:user2) { create(:user) } let(:guest) { create(:user) } diff --git a/spec/services/issues/create_service_spec.rb b/spec/services/issues/create_service_spec.rb index ae9d2b2855d..a48748e274d 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, services: true do +describe Issues::CreateService do let(:project) { create(:empty_project) } let(:user) { create(:user) } diff --git a/spec/services/issues/duplicate_service_spec.rb b/spec/services/issues/duplicate_service_spec.rb index 82daf53b173..ed55664e382 100644 --- a/spec/services/issues/duplicate_service_spec.rb +++ b/spec/services/issues/duplicate_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Issues::DuplicateService, services: true do +describe Issues::DuplicateService do let(:user) { create(:user) } let(:canonical_project) { create(:empty_project) } let(:duplicate_project) { create(:empty_project) } diff --git a/spec/services/issues/move_service_spec.rb b/spec/services/issues/move_service_spec.rb index 36d5038fb95..171fc7334c4 100644 --- a/spec/services/issues/move_service_spec.rb +++ b/spec/services/issues/move_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Issues::MoveService, services: true do +describe Issues::MoveService do let(:user) { create(:user) } let(:author) { create(:user) } let(:title) { 'Some issue' } diff --git a/spec/services/issues/reopen_service_spec.rb b/spec/services/issues/reopen_service_spec.rb index 391ecad303a..1ff988e9b47 100644 --- a/spec/services/issues/reopen_service_spec.rb +++ b/spec/services/issues/reopen_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Issues::ReopenService, services: true do +describe Issues::ReopenService do let(:project) { create(:empty_project) } let(:issue) { create(:issue, :closed, project: project) } diff --git a/spec/services/issues/resolve_discussions_spec.rb b/spec/services/issues/resolve_discussions_spec.rb index 86f218dec12..fac66791ffb 100644 --- a/spec/services/issues/resolve_discussions_spec.rb +++ b/spec/services/issues/resolve_discussions_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper.rb' -describe Issues::ResolveDiscussions, services: true do +describe Issues::ResolveDiscussions do class DummyService < Issues::BaseService include ::Issues::ResolveDiscussions diff --git a/spec/services/issues/update_service_spec.rb b/spec/services/issues/update_service_spec.rb index 064be940a1c..eec2096fa34 100644 --- a/spec/services/issues/update_service_spec.rb +++ b/spec/services/issues/update_service_spec.rb @@ -1,7 +1,7 @@ # coding: utf-8 require 'spec_helper' -describe Issues::UpdateService, services: true do +describe Issues::UpdateService do include EmailHelpers let(:user) { create(:user) } @@ -488,7 +488,7 @@ describe Issues::UpdateService, services: true do context 'updating mentions' do let(:mentionable) { issue } - include_examples 'updating mentions', Issues::UpdateService + include_examples 'updating mentions', described_class end context 'duplicate issue' do diff --git a/spec/services/labels/create_service_spec.rb b/spec/services/labels/create_service_spec.rb index 0ecab0c3475..ecb88653001 100644 --- a/spec/services/labels/create_service_spec.rb +++ b/spec/services/labels/create_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Labels::CreateService, services: true do +describe Labels::CreateService do describe '#execute' do let(:project) { create(:project) } let(:group) { create(:group) } @@ -17,7 +17,7 @@ describe Labels::CreateService, services: true do context 'in a project' do context 'with color in hex-code' do it 'creates a label' do - label = Labels::CreateService.new(params_with(hex_color)).execute(project: project) + label = described_class.new(params_with(hex_color)).execute(project: project) expect(label).to be_persisted expect(label.color).to eq expected_saved_color @@ -26,7 +26,7 @@ describe Labels::CreateService, services: true do context 'with color in allowed name' do it 'creates a label' do - label = Labels::CreateService.new(params_with(named_color)).execute(project: project) + label = described_class.new(params_with(named_color)).execute(project: project) expect(label).to be_persisted expect(label.color).to eq expected_saved_color @@ -35,7 +35,7 @@ describe Labels::CreateService, services: true do context 'with color in up-case allowed name' do it 'creates a label' do - label = Labels::CreateService.new(params_with(upcase_color)).execute(project: project) + label = described_class.new(params_with(upcase_color)).execute(project: project) expect(label).to be_persisted expect(label.color).to eq expected_saved_color @@ -44,7 +44,7 @@ describe Labels::CreateService, services: true do context 'with color surrounded by spaces' do it 'creates a label' do - label = Labels::CreateService.new(params_with(spaced_color)).execute(project: project) + label = described_class.new(params_with(spaced_color)).execute(project: project) expect(label).to be_persisted expect(label.color).to eq expected_saved_color @@ -53,7 +53,7 @@ describe Labels::CreateService, services: true do context 'with unknown color' do it 'doesn\'t create a label' do - label = Labels::CreateService.new(params_with(unknown_color)).execute(project: project) + label = described_class.new(params_with(unknown_color)).execute(project: project) expect(label).not_to be_persisted end @@ -61,7 +61,7 @@ describe Labels::CreateService, services: true do context 'with no color' do it 'doesn\'t create a label' do - label = Labels::CreateService.new(params_with(no_color)).execute(project: project) + label = described_class.new(params_with(no_color)).execute(project: project) expect(label).not_to be_persisted end @@ -71,7 +71,7 @@ describe Labels::CreateService, services: true do context 'in a group' do context 'with color in hex-code' do it 'creates a label' do - label = Labels::CreateService.new(params_with(hex_color)).execute(group: group) + label = described_class.new(params_with(hex_color)).execute(group: group) expect(label).to be_persisted expect(label.color).to eq expected_saved_color @@ -80,7 +80,7 @@ describe Labels::CreateService, services: true do context 'with color in allowed name' do it 'creates a label' do - label = Labels::CreateService.new(params_with(named_color)).execute(group: group) + label = described_class.new(params_with(named_color)).execute(group: group) expect(label).to be_persisted expect(label.color).to eq expected_saved_color @@ -89,7 +89,7 @@ describe Labels::CreateService, services: true do context 'with color in up-case allowed name' do it 'creates a label' do - label = Labels::CreateService.new(params_with(upcase_color)).execute(group: group) + label = described_class.new(params_with(upcase_color)).execute(group: group) expect(label).to be_persisted expect(label.color).to eq expected_saved_color @@ -98,7 +98,7 @@ describe Labels::CreateService, services: true do context 'with color surrounded by spaces' do it 'creates a label' do - label = Labels::CreateService.new(params_with(spaced_color)).execute(group: group) + label = described_class.new(params_with(spaced_color)).execute(group: group) expect(label).to be_persisted expect(label.color).to eq expected_saved_color @@ -107,7 +107,7 @@ describe Labels::CreateService, services: true do context 'with unknown color' do it 'doesn\'t create a label' do - label = Labels::CreateService.new(params_with(unknown_color)).execute(group: group) + label = described_class.new(params_with(unknown_color)).execute(group: group) expect(label).not_to be_persisted end @@ -115,7 +115,7 @@ describe Labels::CreateService, services: true do context 'with no color' do it 'doesn\'t create a label' do - label = Labels::CreateService.new(params_with(no_color)).execute(group: group) + label = described_class.new(params_with(no_color)).execute(group: group) expect(label).not_to be_persisted end @@ -125,7 +125,7 @@ describe Labels::CreateService, services: true do context 'in admin area' do context 'with color in hex-code' do it 'creates a label' do - label = Labels::CreateService.new(params_with(hex_color)).execute(template: true) + label = described_class.new(params_with(hex_color)).execute(template: true) expect(label).to be_persisted expect(label.color).to eq expected_saved_color @@ -134,7 +134,7 @@ describe Labels::CreateService, services: true do context 'with color in allowed name' do it 'creates a label' do - label = Labels::CreateService.new(params_with(named_color)).execute(template: true) + label = described_class.new(params_with(named_color)).execute(template: true) expect(label).to be_persisted expect(label.color).to eq expected_saved_color @@ -143,7 +143,7 @@ describe Labels::CreateService, services: true do context 'with color in up-case allowed name' do it 'creates a label' do - label = Labels::CreateService.new(params_with(upcase_color)).execute(template: true) + label = described_class.new(params_with(upcase_color)).execute(template: true) expect(label).to be_persisted expect(label.color).to eq expected_saved_color @@ -152,7 +152,7 @@ describe Labels::CreateService, services: true do context 'with color surrounded by spaces' do it 'creates a label' do - label = Labels::CreateService.new(params_with(spaced_color)).execute(template: true) + label = described_class.new(params_with(spaced_color)).execute(template: true) expect(label).to be_persisted expect(label.color).to eq expected_saved_color @@ -161,7 +161,7 @@ describe Labels::CreateService, services: true do context 'with unknown color' do it 'doesn\'t create a label' do - label = Labels::CreateService.new(params_with(unknown_color)).execute(template: true) + label = described_class.new(params_with(unknown_color)).execute(template: true) expect(label).not_to be_persisted end @@ -169,7 +169,7 @@ describe Labels::CreateService, services: true do context 'with no color' do it 'doesn\'t create a label' do - label = Labels::CreateService.new(params_with(no_color)).execute(template: true) + label = described_class.new(params_with(no_color)).execute(template: true) expect(label).not_to be_persisted end diff --git a/spec/services/labels/find_or_create_service_spec.rb b/spec/services/labels/find_or_create_service_spec.rb index de8f1827cce..2d3a15a1c11 100644 --- a/spec/services/labels/find_or_create_service_spec.rb +++ b/spec/services/labels/find_or_create_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Labels::FindOrCreateService, services: true do +describe Labels::FindOrCreateService do describe '#execute' do let(:group) { create(:group) } let(:project) { create(:empty_project, namespace: group) } diff --git a/spec/services/labels/promote_service_spec.rb b/spec/services/labels/promote_service_spec.rb index 500afdfb916..7cea877ad88 100644 --- a/spec/services/labels/promote_service_spec.rb +++ b/spec/services/labels/promote_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Labels::PromoteService, services: true do +describe Labels::PromoteService do describe '#execute' do let!(:user) { create(:user) } diff --git a/spec/services/labels/transfer_service_spec.rb b/spec/services/labels/transfer_service_spec.rb index 11d5f1cad5e..f70edd3d16e 100644 --- a/spec/services/labels/transfer_service_spec.rb +++ b/spec/services/labels/transfer_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Labels::TransferService, services: true do +describe Labels::TransferService do describe '#execute' do let(:user) { create(:admin) } let(:group_1) { create(:group) } diff --git a/spec/services/labels/update_service_spec.rb b/spec/services/labels/update_service_spec.rb index f2498ea6990..bb95fe20fbf 100644 --- a/spec/services/labels/update_service_spec.rb +++ b/spec/services/labels/update_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Labels::UpdateService, services: true do +describe Labels::UpdateService do describe '#execute' do let(:project) { create(:project) } @@ -20,7 +20,7 @@ describe Labels::UpdateService, services: true do context 'with color in hex-code' do it 'updates the label' do - label = Labels::UpdateService.new(params_with(hex_color)).execute(@label) + label = described_class.new(params_with(hex_color)).execute(@label) expect(label).to be_valid expect(label.reload.color).to eq expected_saved_color @@ -29,7 +29,7 @@ describe Labels::UpdateService, services: true do context 'with color in allowed name' do it 'updates the label' do - label = Labels::UpdateService.new(params_with(named_color)).execute(@label) + label = described_class.new(params_with(named_color)).execute(@label) expect(label).to be_valid expect(label.reload.color).to eq expected_saved_color @@ -38,7 +38,7 @@ describe Labels::UpdateService, services: true do context 'with color in up-case allowed name' do it 'updates the label' do - label = Labels::UpdateService.new(params_with(upcase_color)).execute(@label) + label = described_class.new(params_with(upcase_color)).execute(@label) expect(label).to be_valid expect(label.reload.color).to eq expected_saved_color @@ -47,7 +47,7 @@ describe Labels::UpdateService, services: true do context 'with color surrounded by spaces' do it 'updates the label' do - label = Labels::UpdateService.new(params_with(spaced_color)).execute(@label) + label = described_class.new(params_with(spaced_color)).execute(@label) expect(label).to be_valid expect(label.reload.color).to eq expected_saved_color @@ -56,7 +56,7 @@ describe Labels::UpdateService, services: true do context 'with unknown color' do it 'doesn\'t update the label' do - label = Labels::UpdateService.new(params_with(unknown_color)).execute(@label) + label = described_class.new(params_with(unknown_color)).execute(@label) expect(label).not_to be_valid end @@ -64,7 +64,7 @@ describe Labels::UpdateService, services: true do context 'with no color' do it 'doesn\'t update the label' do - label = Labels::UpdateService.new(params_with(no_color)).execute(@label) + label = described_class.new(params_with(no_color)).execute(@label) expect(label).not_to be_valid end diff --git a/spec/services/members/approve_access_request_service_spec.rb b/spec/services/members/approve_access_request_service_spec.rb index 7d5a66801db..ddba96b8d03 100644 --- a/spec/services/members/approve_access_request_service_spec.rb +++ b/spec/services/members/approve_access_request_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Members::ApproveAccessRequestService, services: true do +describe Members::ApproveAccessRequestService do let(:user) { create(:user) } let(:access_requester) { create(:user) } let(:project) { create(:empty_project, :public, :access_requestable) } diff --git a/spec/services/members/authorized_destroy_service_spec.rb b/spec/services/members/authorized_destroy_service_spec.rb index f99b11f208c..f0abbc46ca3 100644 --- a/spec/services/members/authorized_destroy_service_spec.rb +++ b/spec/services/members/authorized_destroy_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Members::AuthorizedDestroyService, services: true do +describe Members::AuthorizedDestroyService do let(:member_user) { create(:user) } let(:project) { create(:empty_project, :public) } let(:group) { create(:group, :public) } diff --git a/spec/services/members/create_service_spec.rb b/spec/services/members/create_service_spec.rb index 5a05ab3ea50..c73a229823d 100644 --- a/spec/services/members/create_service_spec.rb +++ b/spec/services/members/create_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Members::CreateService, services: true do +describe Members::CreateService do let(:project) { create(:empty_project) } let(:user) { create(:user) } let(:project_user) { create(:user) } diff --git a/spec/services/members/destroy_service_spec.rb b/spec/services/members/destroy_service_spec.rb index 9ab7839430c..0e30b343eaf 100644 --- a/spec/services/members/destroy_service_spec.rb +++ b/spec/services/members/destroy_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Members::DestroyService, services: true do +describe Members::DestroyService do let(:user) { create(:user) } let(:member_user) { create(:user) } let(:project) { create(:empty_project, :public) } diff --git a/spec/services/members/request_access_service_spec.rb b/spec/services/members/request_access_service_spec.rb index 814c17b9ad0..f39d4f47904 100644 --- a/spec/services/members/request_access_service_spec.rb +++ b/spec/services/members/request_access_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Members::RequestAccessService, services: true do +describe Members::RequestAccessService do let(:user) { create(:user) } shared_examples 'a service raising Gitlab::Access::AccessDeniedError' do diff --git a/spec/services/merge_requests/assign_issues_service_spec.rb b/spec/services/merge_requests/assign_issues_service_spec.rb index d3556020d4d..fcbe0e5985f 100644 --- a/spec/services/merge_requests/assign_issues_service_spec.rb +++ b/spec/services/merge_requests/assign_issues_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe MergeRequests::AssignIssuesService, services: true do +describe MergeRequests::AssignIssuesService do let(:user) { create(:user) } let(:project) { create(:project, :public, :repository) } let(:issue) { create(:issue, project: project) } diff --git a/spec/services/merge_requests/build_service_spec.rb b/spec/services/merge_requests/build_service_spec.rb index a40d4c877bc..ea192e51f89 100644 --- a/spec/services/merge_requests/build_service_spec.rb +++ b/spec/services/merge_requests/build_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe MergeRequests::BuildService, services: true do +describe MergeRequests::BuildService do include RepoHelpers let(:project) { create(:project, :repository) } @@ -19,7 +19,7 @@ describe MergeRequests::BuildService, services: true do let(:commits) { nil } let(:service) do - MergeRequests::BuildService.new(project, user, + described_class.new(project, user, description: description, source_branch: source_branch, target_branch: target_branch, diff --git a/spec/services/merge_requests/close_service_spec.rb b/spec/services/merge_requests/close_service_spec.rb index 074d4672b06..04bf267d167 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, services: true do +describe MergeRequests::CloseService do let(:user) { create(:user) } let(:user2) { create(:user) } let(:guest) { create(:user) } diff --git a/spec/services/merge_requests/create_from_issue_service_spec.rb b/spec/services/merge_requests/create_from_issue_service_spec.rb index 1588d30c394..492b55cdece 100644 --- a/spec/services/merge_requests/create_from_issue_service_spec.rb +++ b/spec/services/merge_requests/create_from_issue_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe MergeRequests::CreateFromIssueService, services: true do +describe MergeRequests::CreateFromIssueService do let(:project) { create(:project, :repository) } let(:user) { create(:user) } let(:issue) { create(:issue, project: project) } diff --git a/spec/services/merge_requests/create_service_spec.rb b/spec/services/merge_requests/create_service_spec.rb index 36a2b672473..8fef480274d 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, services: true do +describe MergeRequests::CreateService do let(:project) { create(:project, :repository) } let(:user) { create(:user) } let(:assignee) { create(:user) } diff --git a/spec/services/merge_requests/get_urls_service_spec.rb b/spec/services/merge_requests/get_urls_service_spec.rb index 4a7d8ab4c6c..672d86e4028 100644 --- a/spec/services/merge_requests/get_urls_service_spec.rb +++ b/spec/services/merge_requests/get_urls_service_spec.rb @@ -78,7 +78,7 @@ describe MergeRequests::GetUrlsService do end context 'pushing to existing branch and merge request is reopened' do - let!(:merge_request) { create(:merge_request, :reopened, source_project: project, source_branch: source_branch) } + let!(:merge_request) { create(:merge_request, :opened, source_project: project, source_branch: source_branch) } let(:changes) { existing_branch_changes } it_behaves_like 'show_merge_request_url' end diff --git a/spec/services/merge_requests/merge_service_spec.rb b/spec/services/merge_requests/merge_service_spec.rb index 19d9e4049fe..e593bfeeaf7 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, services: true do +describe MergeRequests::MergeService do let(:user) { create(:user) } let(:user2) { create(:user) } let(:merge_request) { create(:merge_request, :simple, author: user2, assignee: user2) } @@ -13,7 +13,7 @@ describe MergeRequests::MergeService, services: true do describe '#execute' do context 'valid params' do - let(:service) { MergeRequests::MergeService.new(project, user, commit_message: 'Awesome message') } + let(:service) { described_class.new(project, user, commit_message: 'Awesome message') } before do allow(service).to receive(:execute_hooks) @@ -112,7 +112,7 @@ describe MergeRequests::MergeService, services: true do context 'closes related todos' do let(:merge_request) { create(:merge_request, assignee: user, author: user) } let(:project) { merge_request.project } - let(:service) { MergeRequests::MergeService.new(project, user, commit_message: 'Awesome message') } + let(:service) { described_class.new(project, user, commit_message: 'Awesome message') } let!(:todo) do create(:todo, :assigned, project: project, @@ -136,7 +136,7 @@ describe MergeRequests::MergeService, services: true do context 'source branch removal' do context 'when the source branch is protected' do let(:service) do - MergeRequests::MergeService.new(project, user, should_remove_source_branch: '1') + described_class.new(project, user, should_remove_source_branch: '1') end before do @@ -151,7 +151,7 @@ describe MergeRequests::MergeService, services: true do context 'when the source branch is the default branch' do let(:service) do - MergeRequests::MergeService.new(project, user, should_remove_source_branch: '1') + described_class.new(project, user, should_remove_source_branch: '1') end before do @@ -169,7 +169,7 @@ describe MergeRequests::MergeService, services: true do let(:service) do merge_request.merge_params['force_remove_source_branch'] = '1' merge_request.save! - MergeRequests::MergeService.new(project, user, commit_message: 'Awesome message') + described_class.new(project, user, commit_message: 'Awesome message') end it 'removes the source branch using the author user' do @@ -182,7 +182,7 @@ describe MergeRequests::MergeService, services: true do context 'when MR merger set the source branch to be removed' do let(:service) do - MergeRequests::MergeService.new(project, user, commit_message: 'Awesome message', should_remove_source_branch: '1') + described_class.new(project, user, commit_message: 'Awesome message', should_remove_source_branch: '1') end it 'removes the source branch using the current user' do @@ -196,7 +196,7 @@ describe MergeRequests::MergeService, services: true do end context "error handling" do - let(:service) { MergeRequests::MergeService.new(project, user, commit_message: 'Awesome message') } + let(:service) { described_class.new(project, user, commit_message: 'Awesome message') } before do allow(Rails.logger).to receive(:error) diff --git a/spec/services/merge_requests/post_merge_service_spec.rb b/spec/services/merge_requests/post_merge_service_spec.rb index a20b32eda5f..a37cdab8928 100644 --- a/spec/services/merge_requests/post_merge_service_spec.rb +++ b/spec/services/merge_requests/post_merge_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe MergeRequests::PostMergeService, services: true do +describe MergeRequests::PostMergeService do let(:user) { create(:user) } let(:merge_request) { create(:merge_request, assignee: user) } let(:project) { merge_request.project } diff --git a/spec/services/merge_requests/refresh_service_spec.rb b/spec/services/merge_requests/refresh_service_spec.rb index 74dcf152cb8..2af2485eeed 100644 --- a/spec/services/merge_requests/refresh_service_spec.rb +++ b/spec/services/merge_requests/refresh_service_spec.rb @@ -1,9 +1,9 @@ require 'spec_helper' -describe MergeRequests::RefreshService, services: true do +describe MergeRequests::RefreshService do let(:project) { create(:project, :repository) } let(:user) { create(:user) } - let(:service) { MergeRequests::RefreshService } + let(:service) { described_class } describe '#execute' do before do diff --git a/spec/services/merge_requests/reopen_service_spec.rb b/spec/services/merge_requests/reopen_service_spec.rb index 6cc403bdb7f..f02af0c582e 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, services: true do +describe MergeRequests::ReopenService do let(:user) { create(:user) } let(:user2) { create(:user) } let(:guest) { create(:user) } @@ -28,7 +28,7 @@ describe MergeRequests::ReopenService, services: true do end it { expect(merge_request).to be_valid } - it { expect(merge_request).to be_reopened } + it { expect(merge_request).to be_opened } it 'executes hooks with reopen action' do expect(service).to have_received(:execute_hooks) diff --git a/spec/services/merge_requests/resolved_discussion_notification_service_spec.rb b/spec/services/merge_requests/resolved_discussion_notification_service_spec.rb index 7ddd812e513..e3fd906fe7b 100644 --- a/spec/services/merge_requests/resolved_discussion_notification_service_spec.rb +++ b/spec/services/merge_requests/resolved_discussion_notification_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe MergeRequests::ResolvedDiscussionNotificationService, services: true do +describe MergeRequests::ResolvedDiscussionNotificationService do let(:merge_request) { create(:merge_request) } let(:user) { create(:user) } let(:project) { merge_request.project } diff --git a/spec/services/merge_requests/update_service_spec.rb b/spec/services/merge_requests/update_service_spec.rb index be62584ec0e..dd3ac9c4ac6 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, services: true do +describe MergeRequests::UpdateService do include EmailHelpers let(:project) { create(:project, :repository) } @@ -55,7 +55,7 @@ describe MergeRequests::UpdateService, services: true do } end - let(:service) { MergeRequests::UpdateService.new(project, user, opts) } + let(:service) { described_class.new(project, user, opts) } before do allow(service).to receive(:execute_hooks) @@ -145,7 +145,7 @@ describe MergeRequests::UpdateService, services: true do } end - let(:service) { MergeRequests::UpdateService.new(project, user, opts) } + let(:service) { described_class.new(project, user, opts) } context 'without pipeline' do before do @@ -205,7 +205,7 @@ describe MergeRequests::UpdateService, services: true do context 'with a non-authorised user' do let(:visitor) { create(:user) } - let(:service) { MergeRequests::UpdateService.new(project, visitor, opts) } + let(:service) { described_class.new(project, visitor, opts) } before do merge_request.update_attribute(:merge_error, 'Error') @@ -348,7 +348,7 @@ describe MergeRequests::UpdateService, services: true do opts = { label_ids: [label.id] } perform_enqueued_jobs do - @merge_request = MergeRequests::UpdateService.new(project, user, opts).execute(merge_request) + @merge_request = described_class.new(project, user, opts).execute(merge_request) end should_email(subscriber) @@ -364,7 +364,7 @@ describe MergeRequests::UpdateService, services: true do opts = { label_ids: [label.id, label2.id] } perform_enqueued_jobs do - @merge_request = MergeRequests::UpdateService.new(project, user, opts).execute(merge_request) + @merge_request = described_class.new(project, user, opts).execute(merge_request) end should_not_email(subscriber) @@ -375,7 +375,7 @@ describe MergeRequests::UpdateService, services: true do opts = { label_ids: [label2.id] } perform_enqueued_jobs do - @merge_request = MergeRequests::UpdateService.new(project, user, opts).execute(merge_request) + @merge_request = described_class.new(project, user, opts).execute(merge_request) end should_not_email(subscriber) @@ -386,7 +386,7 @@ describe MergeRequests::UpdateService, services: true do context 'updating mentions' do let(:mentionable) { merge_request } - include_examples 'updating mentions', MergeRequests::UpdateService + include_examples 'updating mentions', described_class end context 'when MergeRequest has tasks' do diff --git a/spec/services/milestones/close_service_spec.rb b/spec/services/milestones/close_service_spec.rb index d581b94ff43..fa0686d8061 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, services: true do +describe Milestones::CloseService do let(:user) { create(:user) } let(:project) { create(:empty_project) } let(:milestone) { create(:milestone, title: "Milestone v1.2", project: project) } @@ -11,7 +11,7 @@ describe Milestones::CloseService, services: true do describe '#execute' do before do - Milestones::CloseService.new(project, user, {}).execute(milestone) + described_class.new(project, user, {}).execute(milestone) end it { expect(milestone).to be_valid } diff --git a/spec/services/milestones/create_service_spec.rb b/spec/services/milestones/create_service_spec.rb index 6d29edb449a..c6fe8e65912 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, services: true do +describe Milestones::CreateService do let(:project) { create(:empty_project) } let(:user) { create(:user) } @@ -14,7 +14,7 @@ describe Milestones::CreateService, services: true do description: 'Patch release to fix security issue' } - @milestone = Milestones::CreateService.new(project, user, opts).execute + @milestone = described_class.new(project, user, opts).execute end it { expect(@milestone).to be_valid } diff --git a/spec/services/milestones/destroy_service_spec.rb b/spec/services/milestones/destroy_service_spec.rb index 8d1fe3ae2c1..5739386dd0d 100644 --- a/spec/services/milestones/destroy_service_spec.rb +++ b/spec/services/milestones/destroy_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Milestones::DestroyService, services: true do +describe Milestones::DestroyService do let(:user) { create(:user) } let(:project) { create(:project) } let(:milestone) { create(:milestone, title: 'Milestone v1.0', project: project) } diff --git a/spec/services/note_summary_spec.rb b/spec/services/note_summary_spec.rb index 39f06f8f8e7..dda579c7080 100644 --- a/spec/services/note_summary_spec.rb +++ b/spec/services/note_summary_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe NoteSummary, services: true do +describe NoteSummary do let(:project) { build(:empty_project) } let(:noteable) { build(:issue) } let(:user) { build(:user) } diff --git a/spec/services/notes/build_service_spec.rb b/spec/services/notes/build_service_spec.rb index 133175769ca..6e1c1fe6c02 100644 --- a/spec/services/notes/build_service_spec.rb +++ b/spec/services/notes/build_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Notes::BuildService, services: true do +describe Notes::BuildService do let(:note) { create(:discussion_note_on_issue) } let(:project) { note.project } let(:author) { note.author } diff --git a/spec/services/notes/create_service_spec.rb b/spec/services/notes/create_service_spec.rb index 152c6d20daa..c08a5a940bb 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, services: true do +describe Notes::CreateService do let(:project) { create(:empty_project) } let(:issue) { create(:issue, project: project) } let(:user) { create(:user) } diff --git a/spec/services/notes/destroy_service_spec.rb b/spec/services/notes/destroy_service_spec.rb index f53f96e0c2b..4330190caaa 100644 --- a/spec/services/notes/destroy_service_spec.rb +++ b/spec/services/notes/destroy_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Notes::DestroyService, services: true do +describe Notes::DestroyService do describe '#execute' do it 'deletes a note' do project = create(:empty_project) diff --git a/spec/services/notes/post_process_service_spec.rb b/spec/services/notes/post_process_service_spec.rb index e33a611929b..bf9320e5fce 100644 --- a/spec/services/notes/post_process_service_spec.rb +++ b/spec/services/notes/post_process_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Notes::PostProcessService, services: true do +describe Notes::PostProcessService do let(:project) { create(:empty_project) } let(:issue) { create(:issue, project: project) } let(:user) { create(:user) } @@ -21,7 +21,7 @@ describe Notes::PostProcessService, services: true do expect(project).to receive(:execute_hooks) expect(project).to receive(:execute_services) - Notes::PostProcessService.new(@note).execute + described_class.new(@note).execute end end end diff --git a/spec/services/notes/quick_actions_service_spec.rb b/spec/services/notes/quick_actions_service_spec.rb index 9a98499826f..fc4cd3dc2b7 100644 --- a/spec/services/notes/quick_actions_service_spec.rb +++ b/spec/services/notes/quick_actions_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Notes::QuickActionsService, services: true do +describe Notes::QuickActionsService do shared_context 'note on noteable' do let(:project) { create(:empty_project) } let(:master) { create(:user).tap { |u| project.team << [u, :master] } } diff --git a/spec/services/notes/update_service_spec.rb b/spec/services/notes/update_service_spec.rb index 905e2f46bde..dea2dc02d00 100644 --- a/spec/services/notes/update_service_spec.rb +++ b/spec/services/notes/update_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Notes::UpdateService, services: true do +describe Notes::UpdateService do let(:project) { create(:empty_project) } let(:user) { create(:user) } let(:user2) { create(:user) } diff --git a/spec/services/notification_recipient_service_spec.rb b/spec/services/notification_recipient_service_spec.rb index dfe1ee7c41e..77233dc1b2f 100644 --- a/spec/services/notification_recipient_service_spec.rb +++ b/spec/services/notification_recipient_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe NotificationRecipientService, services: true do +describe NotificationRecipientService do set(:user) { create(:user) } set(:project) { create(:empty_project, :public) } set(:issue) { create(:issue, project: project) } diff --git a/spec/services/notification_service_spec.rb b/spec/services/notification_service_spec.rb index 4fc5eb0a527..49d6fc7853f 100644 --- a/spec/services/notification_service_spec.rb +++ b/spec/services/notification_service_spec.rb @@ -1,9 +1,9 @@ require 'spec_helper' -describe NotificationService, services: true do +describe NotificationService do include EmailHelpers - let(:notification) { NotificationService.new } + let(:notification) { described_class.new } let(:assignee) { create(:user) } around(:each) do |example| @@ -93,6 +93,18 @@ describe NotificationService, services: true do end end + describe 'GpgKeys' do + describe '#new_gpg_key' do + let!(:key) { create(:gpg_key) } + + it { expect(notification.new_gpg_key(key)).to be_truthy } + + it 'sends email to key owner' do + expect{ notification.new_gpg_key(key) }.to change{ ActionMailer::Base.deliveries.size }.by(1) + end + end + end + describe 'Email' do describe '#new_email' do let!(:email) { create(:email) } diff --git a/spec/services/pages_service_spec.rb b/spec/services/pages_service_spec.rb index cf38c7c75e5..f8db6900a0a 100644 --- a/spec/services/pages_service_spec.rb +++ b/spec/services/pages_service_spec.rb @@ -1,9 +1,9 @@ require 'spec_helper' -describe PagesService, services: true do +describe PagesService do let(:build) { create(:ci_build) } let(:data) { Gitlab::DataBuilder::Build.build(build) } - let(:service) { PagesService.new(data) } + let(:service) { described_class.new(data) } before do allow(Gitlab.config.pages).to receive(:enabled).and_return(true) diff --git a/spec/services/projects/autocomplete_service_spec.rb b/spec/services/projects/autocomplete_service_spec.rb index c198c3eedfc..fc7238862ab 100644 --- a/spec/services/projects/autocomplete_service_spec.rb +++ b/spec/services/projects/autocomplete_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Projects::AutocompleteService, services: true do +describe Projects::AutocompleteService do describe '#issues' do describe 'confidential issues' do let(:author) { create(:user) } diff --git a/spec/services/projects/create_service_spec.rb b/spec/services/projects/create_service_spec.rb index 40298dcb723..b0dc7488b5f 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, '#execute', services: true do +describe Projects::CreateService, '#execute' do let(:user) { create :user } let(:opts) do { diff --git a/spec/services/projects/destroy_service_spec.rb b/spec/services/projects/destroy_service_spec.rb index b399d3402fd..85b05ef6d05 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, services: true do +describe Projects::DestroyService do let!(:user) { create(:user) } let!(:project) { create(:project, :repository, namespace: user.namespace) } let!(:path) { project.repository.path_to_repo } @@ -36,6 +36,27 @@ describe Projects::DestroyService, services: true do end end + shared_examples 'handles errors thrown during async destroy' do |error_message| + it 'does not allow the error to bubble up' do + expect do + Sidekiq::Testing.inline! { destroy_project(project, user, {}) } + end.not_to raise_error + end + + it 'unmarks the project as "pending deletion"' do + Sidekiq::Testing.inline! { destroy_project(project, user, {}) } + + expect(project.reload.pending_delete).to be(false) + end + + it 'stores an error message in `projects.delete_error`' do + Sidekiq::Testing.inline! { destroy_project(project, user, {}) } + + expect(project.reload.delete_error).to be_present + expect(project.delete_error).to include(error_message) + end + end + context 'Sidekiq inline' do before do # Run sidekiq immediatly to check that renamed repository will be removed @@ -60,7 +81,7 @@ describe Projects::DestroyService, services: true do before do new_user = create(:user) project.team.add_user(new_user, Gitlab::Access::DEVELOPER) - allow_any_instance_of(Projects::DestroyService).to receive(:flush_caches).and_raise(::Redis::CannotConnectError) + allow_any_instance_of(described_class).to receive(:flush_caches).and_raise(::Redis::CannotConnectError) end it 'keeps project team intact upon an error' do @@ -89,10 +110,51 @@ describe Projects::DestroyService, services: true do end it_behaves_like 'deleting the project with pipeline and build' - end - context 'with execute' do - it_behaves_like 'deleting the project with pipeline and build' + context 'errors' do + context 'when `remove_legacy_registry_tags` fails' do + before do + expect_any_instance_of(described_class) + .to receive(:remove_legacy_registry_tags).and_return(false) + end + + it_behaves_like 'handles errors thrown during async destroy', "Failed to remove some tags" + end + + context 'when `remove_repository` fails' do + before do + expect_any_instance_of(described_class) + .to receive(:remove_repository).and_return(false) + end + + it_behaves_like 'handles errors thrown during async destroy', "Failed to remove project repository" + end + + context 'when `execute` raises expected error' do + before do + expect_any_instance_of(Project) + .to receive(:destroy!).and_raise(StandardError.new("Other error message")) + end + + it_behaves_like 'handles errors thrown during async destroy', "Other error message" + end + + context 'when `execute` raises unexpected error' do + before do + expect_any_instance_of(Project) + .to receive(:destroy!).and_raise(Exception.new("Other error message")) + end + + it 'allows error to bubble up and rolls back project deletion' do + expect do + Sidekiq::Testing.inline! { destroy_project(project, user, {}) } + end.to raise_error + + expect(project.reload.pending_delete).to be(false) + expect(project.delete_error).to include("Other error message") + end + end + end end describe 'container registry' do @@ -119,8 +181,7 @@ describe Projects::DestroyService, services: true do expect_any_instance_of(ContainerRepository) .to receive(:delete_tags!).and_return(false) - expect{ destroy_project(project, user) } - .to raise_error(ActiveRecord::RecordNotDestroyed) + expect(destroy_project(project, user)).to be false end end end @@ -145,8 +206,7 @@ describe Projects::DestroyService, services: true do expect_any_instance_of(ContainerRepository) .to receive(:delete_tags!).and_return(false) - expect { destroy_project(project, user) } - .to raise_error(Projects::DestroyService::DestroyError) + expect(destroy_project(project, user)).to be false end end end diff --git a/spec/services/projects/download_service_spec.rb b/spec/services/projects/download_service_spec.rb index 33b267c069c..701f6cc8c6a 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, services: true do +describe Projects::DownloadService do describe 'File service' do before do @user = create(:user) diff --git a/spec/services/projects/enable_deploy_key_service_spec.rb b/spec/services/projects/enable_deploy_key_service_spec.rb index 78626fbad4b..9b8c24ba112 100644 --- a/spec/services/projects/enable_deploy_key_service_spec.rb +++ b/spec/services/projects/enable_deploy_key_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Projects::EnableDeployKeyService, services: true do +describe Projects::EnableDeployKeyService do let(:deploy_key) { create(:deploy_key, public: true) } let(:project) { create(:empty_project) } let(:user) { project.creator} diff --git a/spec/services/projects/fork_service_spec.rb b/spec/services/projects/fork_service_spec.rb index 0df81f3abcb..c90536ba346 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, services: true do +describe Projects::ForkService do describe 'fork by user' do before do @from_user = create(:user) diff --git a/spec/services/projects/import_service_spec.rb b/spec/services/projects/import_service_spec.rb index e855de38037..67fe610f92a 100644 --- a/spec/services/projects/import_service_spec.rb +++ b/spec/services/projects/import_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Projects::ImportService, services: true do +describe Projects::ImportService do let!(:project) { create(:empty_project) } let(:user) { project.creator } diff --git a/spec/services/projects/participants_service_spec.rb b/spec/services/projects/participants_service_spec.rb index 3688f6d4e23..8777e63a101 100644 --- a/spec/services/projects/participants_service_spec.rb +++ b/spec/services/projects/participants_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Projects::ParticipantsService, services: true do +describe Projects::ParticipantsService do describe '#groups' do describe 'avatar_url' do let(:project) { create(:empty_project, :public) } diff --git a/spec/services/projects/propagate_service_template_spec.rb b/spec/services/projects/propagate_service_template_spec.rb index a6d43c4f0f1..2763437f184 100644 --- a/spec/services/projects/propagate_service_template_spec.rb +++ b/spec/services/projects/propagate_service_template_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Projects::PropagateServiceTemplate, services: true do +describe Projects::PropagateServiceTemplate do describe '.propagate' do let!(:service_template) do PushoverService.create( diff --git a/spec/services/projects/transfer_service_spec.rb b/spec/services/projects/transfer_service_spec.rb index 441a5276c56..ae32e85b2a7 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, services: true do +describe Projects::TransferService do let(:user) { create(:user) } let(:group) { create(:group) } let(:project) { create(:project, :repository, namespace: user.namespace) } @@ -37,7 +37,7 @@ describe Projects::TransferService, services: true do end it 'executes system hooks' do - expect_any_instance_of(Projects::TransferService).to receive(:execute_system_hooks) + expect_any_instance_of(described_class).to receive(:execute_system_hooks) transfer_project(project, user, group) end @@ -80,7 +80,7 @@ describe Projects::TransferService, services: true do end it "doesn't run system hooks" do - expect_any_instance_of(Projects::TransferService).not_to receive(:execute_system_hooks) + expect_any_instance_of(described_class).not_to receive(:execute_system_hooks) attempt_project_transfer end diff --git a/spec/services/projects/unlink_fork_service_spec.rb b/spec/services/projects/unlink_fork_service_spec.rb index d34652bd7ac..2ae8d5f7c54 100644 --- a/spec/services/projects/unlink_fork_service_spec.rb +++ b/spec/services/projects/unlink_fork_service_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' -describe Projects::UnlinkForkService, services: true do - subject { Projects::UnlinkForkService.new(fork_project, user) } +describe Projects::UnlinkForkService do + subject { described_class.new(fork_project, user) } let(:fork_link) { create(:forked_project_link) } let(:fork_project) { fork_link.forked_to_project } diff --git a/spec/services/projects/update_pages_configuration_service_spec.rb b/spec/services/projects/update_pages_configuration_service_spec.rb index 8b329bc21c3..42925e73978 100644 --- a/spec/services/projects/update_pages_configuration_service_spec.rb +++ b/spec/services/projects/update_pages_configuration_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Projects::UpdatePagesConfigurationService, services: true do +describe Projects::UpdatePagesConfigurationService do let(:project) { create(:empty_project) } subject { described_class.new(project) } diff --git a/spec/services/projects/update_pages_service_spec.rb b/spec/services/projects/update_pages_service_spec.rb index fc0a17296f3..aa6ad6340f5 100644 --- a/spec/services/projects/update_pages_service_spec.rb +++ b/spec/services/projects/update_pages_service_spec.rb @@ -96,6 +96,78 @@ describe Projects::UpdatePagesService do expect(execute).not_to eq(:success) end + describe 'maximum pages artifacts size' do + let(:metadata) { spy('metadata') } + + before do + file = fixture_file_upload(Rails.root + 'spec/fixtures/pages.zip') + metafile = fixture_file_upload(Rails.root + 'spec/fixtures/pages.zip.meta') + + build.update_attributes(artifacts_file: file) + build.update_attributes(artifacts_metadata: metafile) + + allow(build).to receive(:artifacts_metadata_entry) + .and_return(metadata) + end + + shared_examples 'pages size limit exceeded' do + it 'limits the maximum size of gitlab pages' do + subject.execute + + expect(deploy_status.description) + .to match(/artifacts for pages are too large/) + end + end + + context 'when maximum pages size is set to zero' do + before do + stub_application_setting(max_pages_size: 0) + end + + context 'when page size does not exceed internal maximum' do + before do + allow(metadata).to receive(:total_size).and_return(200.megabytes) + end + + it 'updates pages correctly' do + subject.execute + + expect(deploy_status.description).not_to be_present + end + end + + context 'when pages size does exceed internal maximum' do + before do + allow(metadata).to receive(:total_size).and_return(2.terabytes) + end + + it_behaves_like 'pages size limit exceeded' + end + end + + context 'when pages size is greater than max size setting' do + before do + stub_application_setting(max_pages_size: 200) + allow(metadata).to receive(:total_size).and_return(201.megabytes) + end + + it_behaves_like 'pages size limit exceeded' + end + + context 'when max size setting is greater than internal max size' do + before do + stub_application_setting(max_pages_size: 3.terabytes / 1.megabyte) + allow(metadata).to receive(:total_size).and_return(2.terabytes) + end + + it_behaves_like 'pages size limit exceeded' + end + end + + def deploy_status + GenericCommitStatus.find_by(name: 'pages:deploy') + end + def execute subject.execute[:status] end diff --git a/spec/services/projects/update_service_spec.rb b/spec/services/projects/update_service_spec.rb index 3ee834748df..d7b0df9a671 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, '#execute', :services do +describe Projects::UpdateService, '#execute' do let(:user) { create(:user) } let(:admin) { create(:admin) } diff --git a/spec/services/protected_branches/create_service_spec.rb b/spec/services/protected_branches/create_service_spec.rb index 6ea8f309981..592f9b5929e 100644 --- a/spec/services/protected_branches/create_service_spec.rb +++ b/spec/services/protected_branches/create_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe ProtectedBranches::CreateService, services: true do +describe ProtectedBranches::CreateService do let(:project) { create(:empty_project) } let(:user) { project.owner } let(:params) do diff --git a/spec/services/protected_branches/update_service_spec.rb b/spec/services/protected_branches/update_service_spec.rb index 62bdd49a4d7..5698101af54 100644 --- a/spec/services/protected_branches/update_service_spec.rb +++ b/spec/services/protected_branches/update_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe ProtectedBranches::UpdateService, services: true do +describe ProtectedBranches::UpdateService do let(:protected_branch) { create(:protected_branch) } let(:project) { protected_branch.project } let(:user) { project.owner } diff --git a/spec/services/protected_tags/create_service_spec.rb b/spec/services/protected_tags/create_service_spec.rb index d91a58e8de5..3a3cc9c1573 100644 --- a/spec/services/protected_tags/create_service_spec.rb +++ b/spec/services/protected_tags/create_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe ProtectedTags::CreateService, services: true do +describe ProtectedTags::CreateService do let(:project) { create(:empty_project) } let(:user) { project.owner } let(:params) do diff --git a/spec/services/protected_tags/update_service_spec.rb b/spec/services/protected_tags/update_service_spec.rb index e78fde4c48d..d333430088d 100644 --- a/spec/services/protected_tags/update_service_spec.rb +++ b/spec/services/protected_tags/update_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe ProtectedTags::UpdateService, services: true do +describe ProtectedTags::UpdateService do let(:protected_tag) { create(:protected_tag) } let(:project) { protected_tag.project } let(:user) { project.owner } diff --git a/spec/services/quick_actions/interpret_service_spec.rb b/spec/services/quick_actions/interpret_service_spec.rb index 2a2a5c38e4b..42a4a2591ea 100644 --- a/spec/services/quick_actions/interpret_service_spec.rb +++ b/spec/services/quick_actions/interpret_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe QuickActions::InterpretService, services: true do +describe QuickActions::InterpretService do let(:project) { create(:empty_project, :public) } let(:developer) { create(:user) } let(:developer2) { create(:user) } diff --git a/spec/services/repair_ldap_blocked_user_service_spec.rb b/spec/services/repair_ldap_blocked_user_service_spec.rb index 87192457298..bf79cfe74b7 100644 --- a/spec/services/repair_ldap_blocked_user_service_spec.rb +++ b/spec/services/repair_ldap_blocked_user_service_spec.rb @@ -1,9 +1,9 @@ require 'spec_helper' -describe RepairLdapBlockedUserService, services: true do +describe RepairLdapBlockedUserService do let(:user) { create(:omniauth_user, provider: 'ldapmain', state: 'ldap_blocked') } let(:identity) { user.ldap_identity } - subject(:service) { RepairLdapBlockedUserService.new(user) } + subject(:service) { described_class.new(user) } describe '#execute' do it 'changes to normal block after destroying last ldap identity' do diff --git a/spec/services/repository_archive_clean_up_service_spec.rb b/spec/services/repository_archive_clean_up_service_spec.rb index 842585f9e54..2d7fa3f80f7 100644 --- a/spec/services/repository_archive_clean_up_service_spec.rb +++ b/spec/services/repository_archive_clean_up_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe RepositoryArchiveCleanUpService, services: true do +describe RepositoryArchiveCleanUpService do describe '#execute' do subject(:service) { described_class.new } diff --git a/spec/services/search/global_service_spec.rb b/spec/services/search/global_service_spec.rb index cbf4f56213d..de921573b1a 100644 --- a/spec/services/search/global_service_spec.rb +++ b/spec/services/search/global_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Search::GlobalService, services: true do +describe Search::GlobalService do let(:user) { create(:user) } let(:internal_user) { create(:user) } @@ -16,7 +16,7 @@ describe Search::GlobalService, services: true do describe '#execute' do context 'unauthenticated' do it 'returns public projects only' do - results = Search::GlobalService.new(nil, search: "searchable").execute + results = described_class.new(nil, search: "searchable").execute expect(results.objects('projects')).to match_array [public_project] end @@ -24,19 +24,19 @@ describe Search::GlobalService, services: true do context 'authenticated' do it 'returns public, internal and private projects' do - results = Search::GlobalService.new(user, search: "searchable").execute + results = described_class.new(user, search: "searchable").execute expect(results.objects('projects')).to match_array [public_project, found_project, internal_project] end it 'returns only public & internal projects' do - results = Search::GlobalService.new(internal_user, search: "searchable").execute + results = described_class.new(internal_user, search: "searchable").execute expect(results.objects('projects')).to match_array [internal_project, public_project] end it 'namespace name is searchable' do - results = Search::GlobalService.new(user, search: found_project.namespace.path).execute + results = described_class.new(user, search: found_project.namespace.path).execute expect(results.objects('projects')).to match_array [found_project] end diff --git a/spec/services/search/group_service_spec.rb b/spec/services/search/group_service_spec.rb index 38f264f6e7b..cb3f02d2883 100644 --- a/spec/services/search/group_service_spec.rb +++ b/spec/services/search/group_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Search::GroupService, services: true do +describe Search::GroupService do shared_examples_for 'group search' do context 'finding projects by name' do let(:user) { create(:user) } @@ -17,7 +17,7 @@ describe Search::GroupService, services: true do let!(:project2) { create(:empty_project, :internal, namespace: nested_group, name: "Inner #{term} 2") } let!(:project3) { create(:empty_project, :internal, namespace: nested_group.parent, name: "Outer #{term}") } - let(:results) { Search::GroupService.new(user, search_group, search: term).execute } + let(:results) { described_class.new(user, search_group, search: term).execute } subject { results.objects('projects') } context 'in parent group' do diff --git a/spec/services/search/snippet_service_spec.rb b/spec/services/search/snippet_service_spec.rb index 14f3301d9f4..69438a3fa36 100644 --- a/spec/services/search/snippet_service_spec.rb +++ b/spec/services/search/snippet_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Search::SnippetService, services: true do +describe Search::SnippetService do let(:author) { create(:author) } let(:project) { create(:empty_project) } diff --git a/spec/services/search_service_spec.rb b/spec/services/search_service_spec.rb index 5cf989105d0..a6ef7561bc8 100644 --- a/spec/services/search_service_spec.rb +++ b/spec/services/search_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe SearchService, services: true do +describe SearchService do let(:user) { create(:user) } let(:accessible_group) { create(:group, :private) } @@ -22,7 +22,7 @@ describe SearchService, services: true do describe '#project' do context 'when the project is accessible' do it 'returns the project' do - project = SearchService.new(user, project_id: accessible_project.id).project + project = described_class.new(user, project_id: accessible_project.id).project expect(project).to eq accessible_project end @@ -31,7 +31,7 @@ describe SearchService, services: true do search_project = create :empty_project search_project.add_guest(user) - project = SearchService.new(user, project_id: search_project.id).project + project = described_class.new(user, project_id: search_project.id).project expect(project).to eq search_project end @@ -39,7 +39,7 @@ describe SearchService, services: true do context 'when the project is not accessible' do it 'returns nil' do - project = SearchService.new(user, project_id: inaccessible_project.id).project + project = described_class.new(user, project_id: inaccessible_project.id).project expect(project).to be_nil end @@ -47,7 +47,7 @@ describe SearchService, services: true do context 'when there is no project_id' do it 'returns nil' do - project = SearchService.new(user).project + project = described_class.new(user).project expect(project).to be_nil end @@ -57,7 +57,7 @@ describe SearchService, services: true do describe '#group' do context 'when the group is accessible' do it 'returns the group' do - group = SearchService.new(user, group_id: accessible_group.id).group + group = described_class.new(user, group_id: accessible_group.id).group expect(group).to eq accessible_group end @@ -65,7 +65,7 @@ describe SearchService, services: true do context 'when the group is not accessible' do it 'returns nil' do - group = SearchService.new(user, group_id: inaccessible_group.id).group + group = described_class.new(user, group_id: inaccessible_group.id).group expect(group).to be_nil end @@ -73,7 +73,7 @@ describe SearchService, services: true do context 'when there is no group_id' do it 'returns nil' do - group = SearchService.new(user).group + group = described_class.new(user).group expect(group).to be_nil end @@ -83,7 +83,7 @@ describe SearchService, services: true do describe '#show_snippets?' do context 'when :snippets is \'true\'' do it 'returns true' do - show_snippets = SearchService.new(user, snippets: 'true').show_snippets? + show_snippets = described_class.new(user, snippets: 'true').show_snippets? expect(show_snippets).to be_truthy end @@ -91,7 +91,7 @@ describe SearchService, services: true do context 'when :snippets is not \'true\'' do it 'returns false' do - show_snippets = SearchService.new(user, snippets: 'tru').show_snippets? + show_snippets = described_class.new(user, snippets: 'tru').show_snippets? expect(show_snippets).to be_falsey end @@ -99,7 +99,7 @@ describe SearchService, services: true do context 'when :snippets is missing' do it 'returns false' do - show_snippets = SearchService.new(user).show_snippets? + show_snippets = described_class.new(user).show_snippets? expect(show_snippets).to be_falsey end @@ -110,7 +110,7 @@ describe SearchService, services: true do context 'with accessible project_id' do context 'and allowed scope' do it 'returns the specified scope' do - scope = SearchService.new(user, project_id: accessible_project.id, scope: 'notes').scope + scope = described_class.new(user, project_id: accessible_project.id, scope: 'notes').scope expect(scope).to eq 'notes' end @@ -118,7 +118,7 @@ describe SearchService, services: true do context 'and disallowed scope' do it 'returns the default scope' do - scope = SearchService.new(user, project_id: accessible_project.id, scope: 'projects').scope + scope = described_class.new(user, project_id: accessible_project.id, scope: 'projects').scope expect(scope).to eq 'blobs' end @@ -126,7 +126,7 @@ describe SearchService, services: true do context 'and no scope' do it 'returns the default scope' do - scope = SearchService.new(user, project_id: accessible_project.id).scope + scope = described_class.new(user, project_id: accessible_project.id).scope expect(scope).to eq 'blobs' end @@ -136,7 +136,7 @@ describe SearchService, services: true do context 'with \'true\' snippets' do context 'and allowed scope' do it 'returns the specified scope' do - scope = SearchService.new(user, snippets: 'true', scope: 'snippet_titles').scope + scope = described_class.new(user, snippets: 'true', scope: 'snippet_titles').scope expect(scope).to eq 'snippet_titles' end @@ -144,7 +144,7 @@ describe SearchService, services: true do context 'and disallowed scope' do it 'returns the default scope' do - scope = SearchService.new(user, snippets: 'true', scope: 'projects').scope + scope = described_class.new(user, snippets: 'true', scope: 'projects').scope expect(scope).to eq 'snippet_blobs' end @@ -152,7 +152,7 @@ describe SearchService, services: true do context 'and no scope' do it 'returns the default scope' do - scope = SearchService.new(user, snippets: 'true').scope + scope = described_class.new(user, snippets: 'true').scope expect(scope).to eq 'snippet_blobs' end @@ -162,7 +162,7 @@ describe SearchService, services: true do context 'with no project_id, no snippets' do context 'and allowed scope' do it 'returns the specified scope' do - scope = SearchService.new(user, scope: 'issues').scope + scope = described_class.new(user, scope: 'issues').scope expect(scope).to eq 'issues' end @@ -170,7 +170,7 @@ describe SearchService, services: true do context 'and disallowed scope' do it 'returns the default scope' do - scope = SearchService.new(user, scope: 'blobs').scope + scope = described_class.new(user, scope: 'blobs').scope expect(scope).to eq 'projects' end @@ -178,7 +178,7 @@ describe SearchService, services: true do context 'and no scope' do it 'returns the default scope' do - scope = SearchService.new(user).scope + scope = described_class.new(user).scope expect(scope).to eq 'projects' end @@ -189,7 +189,7 @@ describe SearchService, services: true do describe '#search_results' do context 'with accessible project_id' do it 'returns an instance of Gitlab::ProjectSearchResults' do - search_results = SearchService.new( + search_results = described_class.new( user, project_id: accessible_project.id, scope: 'notes', @@ -201,7 +201,7 @@ describe SearchService, services: true do context 'with accessible project_id and \'true\' snippets' do it 'returns an instance of Gitlab::ProjectSearchResults' do - search_results = SearchService.new( + search_results = described_class.new( user, project_id: accessible_project.id, snippets: 'true', @@ -214,7 +214,7 @@ describe SearchService, services: true do context 'with \'true\' snippets' do it 'returns an instance of Gitlab::SnippetSearchResults' do - search_results = SearchService.new( + search_results = described_class.new( user, snippets: 'true', search: snippet.content).search_results @@ -225,7 +225,7 @@ describe SearchService, services: true do context 'with no project_id and no snippets' do it 'returns an instance of Gitlab::SearchResults' do - search_results = SearchService.new( + search_results = described_class.new( user, search: public_project.name).search_results @@ -237,7 +237,7 @@ describe SearchService, services: true do describe '#search_objects' do context 'with accessible project_id' do it 'returns objects in the project' do - search_objects = SearchService.new( + search_objects = described_class.new( user, project_id: accessible_project.id, scope: 'notes', @@ -249,7 +249,7 @@ describe SearchService, services: true do context 'with accessible project_id and \'true\' snippets' do it 'returns objects in the project' do - search_objects = SearchService.new( + search_objects = described_class.new( user, project_id: accessible_project.id, snippets: 'true', @@ -262,7 +262,7 @@ describe SearchService, services: true do context 'with \'true\' snippets' do it 'returns objects in snippets' do - search_objects = SearchService.new( + search_objects = described_class.new( user, snippets: 'true', search: snippet.content).search_objects @@ -273,7 +273,7 @@ describe SearchService, services: true do context 'with accessible group_id' do it 'returns objects in the group' do - search_objects = SearchService.new( + search_objects = described_class.new( user, group_id: accessible_group.id, search: group_project.name).search_objects @@ -284,7 +284,7 @@ describe SearchService, services: true do context 'with no project_id, group_id or snippets' do it 'returns objects in global' do - search_objects = SearchService.new( + search_objects = described_class.new( user, search: public_project.name).search_objects diff --git a/spec/services/spam_service_spec.rb b/spec/services/spam_service_spec.rb index 5e6e43b7a90..46349c3e951 100644 --- a/spec/services/spam_service_spec.rb +++ b/spec/services/spam_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe SpamService, services: true do +describe SpamService do describe '#when_recaptcha_verified' do def check_spam(issue, request, recaptcha_verified) described_class.new(issue, request).when_recaptcha_verified(recaptcha_verified) do diff --git a/spec/services/system_hooks_service_spec.rb b/spec/services/system_hooks_service_spec.rb index 667059f230c..b2d9862e71e 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, services: true do +describe SystemHooksService do let(:user) { create(:user) } let(:project) { create(:empty_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 681b419aedf..cb59493c343 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, services: true do +describe SystemNoteService do include Gitlab::Routing let(:project) { create(:empty_project) } diff --git a/spec/services/tags/create_service_spec.rb b/spec/services/tags/create_service_spec.rb index 9f143cc5667..1b31ce29f7a 100644 --- a/spec/services/tags/create_service_spec.rb +++ b/spec/services/tags/create_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Tags::CreateService, services: true do +describe Tags::CreateService do let(:project) { create(:project, :repository) } let(:repository) { project.repository } let(:user) { create(:user) } diff --git a/spec/services/tags/destroy_service_spec.rb b/spec/services/tags/destroy_service_spec.rb index 28396fc3658..7c8c1dd0d3a 100644 --- a/spec/services/tags/destroy_service_spec.rb +++ b/spec/services/tags/destroy_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Tags::DestroyService, services: true do +describe Tags::DestroyService do let(:project) { create(:project, :repository) } let(:repository) { project.repository } let(:user) { create(:user) } diff --git a/spec/services/todo_service_spec.rb b/spec/services/todo_service_spec.rb index de41cbab14c..230e40de9e0 100644 --- a/spec/services/todo_service_spec.rb +++ b/spec/services/todo_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe TodoService, services: true do +describe TodoService do let(:author) { create(:user) } let(:assignee) { create(:user) } let(:non_member) { create(:user) } @@ -873,21 +873,21 @@ describe TodoService, services: true do create(:todo, :mentioned, user: john_doe, target: issue, project: project) todos = TodosFinder.new(john_doe, {}).execute - expect { TodoService.new.mark_todos_as_done(todos, john_doe) } + expect { described_class.new.mark_todos_as_done(todos, john_doe) } .to change { john_doe.todos.done.count }.from(0).to(1) end it 'marks an array of todos as done' do todo = create(:todo, :mentioned, user: john_doe, target: issue, project: project) - expect { TodoService.new.mark_todos_as_done([todo], john_doe) } + expect { described_class.new.mark_todos_as_done([todo], john_doe) } .to change { todo.reload.state }.from('pending').to('done') end it 'returns the ids of updated todos' do # Needed on API todo = create(:todo, :mentioned, user: john_doe, target: issue, project: project) - expect(TodoService.new.mark_todos_as_done([todo], john_doe)).to eq([todo.id]) + expect(described_class.new.mark_todos_as_done([todo], john_doe)).to eq([todo.id]) end context 'when some of the todos are done already' do @@ -895,23 +895,23 @@ describe TodoService, services: true do let!(:second_todo) { create(:todo, :mentioned, user: john_doe, target: another_issue, project: project) } it 'returns the ids of those still pending' do - TodoService.new.mark_pending_todos_as_done(issue, john_doe) + described_class.new.mark_pending_todos_as_done(issue, john_doe) - expect(TodoService.new.mark_todos_as_done(Todo.all, john_doe)).to eq([second_todo.id]) + expect(described_class.new.mark_todos_as_done(Todo.all, john_doe)).to eq([second_todo.id]) end it 'returns an empty array if all are done' do - TodoService.new.mark_pending_todos_as_done(issue, john_doe) - TodoService.new.mark_pending_todos_as_done(another_issue, john_doe) + described_class.new.mark_pending_todos_as_done(issue, john_doe) + described_class.new.mark_pending_todos_as_done(another_issue, john_doe) - expect(TodoService.new.mark_todos_as_done(Todo.all, john_doe)).to eq([]) + expect(described_class.new.mark_todos_as_done(Todo.all, john_doe)).to eq([]) end end it 'caches the number of todos of a user', :use_clean_rails_memory_store_caching do create(:todo, :mentioned, user: john_doe, target: issue, project: project) todo = create(:todo, :mentioned, user: john_doe, target: issue, project: project) - TodoService.new.mark_todos_as_done([todo], john_doe) + described_class.new.mark_todos_as_done([todo], john_doe) expect_any_instance_of(TodosFinder).not_to receive(:execute) diff --git a/spec/services/update_release_service_spec.rb b/spec/services/update_release_service_spec.rb index 69ed8de9c31..dc2d0e2d47a 100644 --- a/spec/services/update_release_service_spec.rb +++ b/spec/services/update_release_service_spec.rb @@ -1,12 +1,12 @@ require 'spec_helper' -describe UpdateReleaseService, services: true do +describe UpdateReleaseService do let(:project) { create(:project, :repository) } let(:user) { create(:user) } let(:tag_name) { project.repository.tag_names.first } let(:description) { 'Awesome release!' } let(:new_description) { 'The best release!' } - let(:service) { UpdateReleaseService.new(project, user) } + let(:service) { described_class.new(project, user) } context 'with an existing release' do let(:create_service) { CreateReleaseService.new(project, user) } diff --git a/spec/services/update_snippet_service_spec.rb b/spec/services/update_snippet_service_spec.rb index 37c2e861362..ef535c5cf1f 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, services: true do +describe UpdateSnippetService do before do @user = create :user @admin = create :user, admin: true diff --git a/spec/services/upload_service_spec.rb b/spec/services/upload_service_spec.rb index 95ba28dbecd..cf76a18f171 100644 --- a/spec/services/upload_service_spec.rb +++ b/spec/services/upload_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe UploadService, services: true do +describe UploadService do describe 'File service' do before do @user = create(:user) diff --git a/spec/services/users/activity_service_spec.rb b/spec/services/users/activity_service_spec.rb index e5330d1d3e4..fef4da0c76e 100644 --- a/spec/services/users/activity_service_spec.rb +++ b/spec/services/users/activity_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Users::ActivityService, services: true do +describe Users::ActivityService do include UserActivitiesHelpers let(:user) { create(:user) } diff --git a/spec/services/users/build_service_spec.rb b/spec/services/users/build_service_spec.rb index 2a6bfc1b3a0..677d4a622e1 100644 --- a/spec/services/users/build_service_spec.rb +++ b/spec/services/users/build_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Users::BuildService, services: true do +describe Users::BuildService do describe '#execute' do let(:params) do { name: 'John Doe', username: 'jduser', email: 'jd@example.com', password: 'mydummypass' } diff --git a/spec/services/users/create_service_spec.rb b/spec/services/users/create_service_spec.rb index 75746278573..24dac569678 100644 --- a/spec/services/users/create_service_spec.rb +++ b/spec/services/users/create_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Users::CreateService, services: true do +describe Users::CreateService do describe '#execute' do let(:admin_user) { create(:admin) } diff --git a/spec/services/users/destroy_service_spec.rb b/spec/services/users/destroy_service_spec.rb index 5409f67c091..786335120fd 100644 --- a/spec/services/users/destroy_service_spec.rb +++ b/spec/services/users/destroy_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Users::DestroyService, services: true do +describe Users::DestroyService do describe "Deletes a user and all their personal projects" do let!(:user) { create(:user) } let!(:admin) { create(:admin) } diff --git a/spec/services/users/migrate_to_ghost_user_service_spec.rb b/spec/services/users/migrate_to_ghost_user_service_spec.rb index e52ecd6d614..a0030ce8809 100644 --- a/spec/services/users/migrate_to_ghost_user_service_spec.rb +++ b/spec/services/users/migrate_to_ghost_user_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Users::MigrateToGhostUserService, services: true do +describe Users::MigrateToGhostUserService do let!(:user) { create(:user) } let!(:project) { create(:project) } let(:service) { described_class.new(user) } diff --git a/spec/services/users/update_service_spec.rb b/spec/services/users/update_service_spec.rb index 0b2f840c462..343804e3de0 100644 --- a/spec/services/users/update_service_spec.rb +++ b/spec/services/users/update_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Users::UpdateService, services: true do +describe Users::UpdateService do let(:user) { create(:user) } describe '#execute' do diff --git a/spec/services/web_hook_service_spec.rb b/spec/services/web_hook_service_spec.rb index 7ff37c22963..e79c12daa1c 100644 --- a/spec/services/web_hook_service_spec.rb +++ b/spec/services/web_hook_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe WebHookService, services: true do +describe WebHookService do let(:project) { create(:empty_project) } let(:project_hook) { create(:project_hook) } let(:headers) do @@ -12,7 +12,7 @@ describe WebHookService, services: true do let(:data) do { before: 'oldrev', after: 'newrev', ref: 'ref' } end - let(:service_instance) { WebHookService.new(project_hook, data, 'push_hooks') } + let(:service_instance) { described_class.new(project_hook, data, 'push_hooks') } describe '#execute' do before(:each) do @@ -53,7 +53,7 @@ describe WebHookService, services: true do end it 'handles exceptions' do - exceptions = [SocketError, OpenSSL::SSL::SSLError, Errno::ECONNRESET, Errno::ECONNREFUSED, Net::OpenTimeout] + exceptions = [SocketError, OpenSSL::SSL::SSLError, Errno::ECONNRESET, Errno::ECONNREFUSED, Errno::EHOSTUNREACH, Net::OpenTimeout, Net::ReadTimeout] exceptions.each do |exception_class| exception = exception_class.new('Exception message') @@ -114,7 +114,7 @@ describe WebHookService, services: true do context 'should not log ServiceHooks' do let(:service_hook) { create(:service_hook) } - let(:service_instance) { WebHookService.new(service_hook, data, 'service_hook') } + let(:service_instance) { described_class.new(service_hook, data, 'service_hook') } before do WebMock.stub_request(:post, service_hook.url).to_return(status: 200, body: 'Success') @@ -131,7 +131,7 @@ describe WebHookService, services: true do it 'enqueue WebHookWorker' do expect(Sidekiq::Client).to receive(:enqueue).with(WebHookWorker, project_hook.id, data, 'push_hooks') - WebHookService.new(project_hook, data, 'push_hooks').async_execute + described_class.new(project_hook, data, 'push_hooks').async_execute end end end diff --git a/spec/services/wiki_pages/create_service_spec.rb b/spec/services/wiki_pages/create_service_spec.rb index 054e28ae7b0..fa3863e9b30 100644 --- a/spec/services/wiki_pages/create_service_spec.rb +++ b/spec/services/wiki_pages/create_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe WikiPages::CreateService, services: true do +describe WikiPages::CreateService do let(:project) { create(:empty_project) } let(:user) { create(:user) } diff --git a/spec/services/wiki_pages/destroy_service_spec.rb b/spec/services/wiki_pages/destroy_service_spec.rb index 920be4d4c8a..1668cd00ca8 100644 --- a/spec/services/wiki_pages/destroy_service_spec.rb +++ b/spec/services/wiki_pages/destroy_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe WikiPages::DestroyService, services: true do +describe WikiPages::DestroyService do let(:project) { create(:empty_project) } let(:user) { create(:user) } let(:page) { create(:wiki_page) } diff --git a/spec/services/wiki_pages/update_service_spec.rb b/spec/services/wiki_pages/update_service_spec.rb index 5e36ea4cf94..a672c84034b 100644 --- a/spec/services/wiki_pages/update_service_spec.rb +++ b/spec/services/wiki_pages/update_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe WikiPages::UpdateService, services: true do +describe WikiPages::UpdateService do let(:project) { create(:empty_project) } let(:user) { create(:user) } let(:page) { create(:wiki_page) } diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index e7329210896..85335643921 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -59,6 +59,7 @@ RSpec.configure do |config| config.include Gitlab::Routing, type: :routing config.include MigrationsHelpers, :migration config.include StubFeatureFlags + config.include StubENV config.infer_spec_type_from_file_location! diff --git a/spec/support/api/schema_matcher.rb b/spec/support/api/schema_matcher.rb index dff0dfba675..67599f77adb 100644 --- a/spec/support/api/schema_matcher.rb +++ b/spec/support/api/schema_matcher.rb @@ -5,7 +5,14 @@ end RSpec::Matchers.define :match_response_schema do |schema, **options| match do |response| - JSON::Validator.validate!(schema_path(schema), response.body, options) + @errors = JSON::Validator.fully_validate(schema_path(schema), response.body, options) + + @errors.empty? + end + + failure_message do |response| + "didn't match the schema defined by #{schema_path(schema)}" \ + " The validation errors were:\n#{@errors.join("\n")}" end end diff --git a/spec/support/capybara.rb b/spec/support/capybara.rb index 3e5d6cf1364..c45c4a4310d 100644 --- a/spec/support/capybara.rb +++ b/spec/support/capybara.rb @@ -36,7 +36,14 @@ RSpec.configure do |config| $capybara_server_already_started = true end - config.after(:each, :js) do |example| + config.before(:example, :js) do + allow(Gitlab::Application.routes).to receive(:default_url_options).and_return( + host: Capybara.current_session.server.host, + port: Capybara.current_session.server.port, + protocol: 'http') + end + + config.after(:example, :js) do |example| # capybara/rspec already calls Capybara.reset_sessions! in an `after` hook, # but `block_and_wait_for_requests_complete` is called before it so by # calling it explicitely here, we prevent any new requests from being fired diff --git a/spec/support/forgery_protection.rb b/spec/support/forgery_protection.rb new file mode 100644 index 00000000000..a5e7b761651 --- /dev/null +++ b/spec/support/forgery_protection.rb @@ -0,0 +1,11 @@ +RSpec.configure do |config| + config.around(:each, :allow_forgery_protection) do |example| + begin + ActionController::Base.allow_forgery_protection = true + + example.call + ensure + ActionController::Base.allow_forgery_protection = false + end + end +end diff --git a/spec/support/gpg_helpers.rb b/spec/support/gpg_helpers.rb new file mode 100644 index 00000000000..96ea6f28b30 --- /dev/null +++ b/spec/support/gpg_helpers.rb @@ -0,0 +1,202 @@ +module GpgHelpers + module User1 + extend self + + def signed_commit_signature + <<~SIGNATURE + -----BEGIN PGP SIGNATURE----- + Version: GnuPG v1 + + iJwEAAECAAYFAliu264ACgkQzPvhnwCsix1VXgP9F6zwAMb3OXKZzqGxJ4MQIBoL + OdiUSJpL/4sIA9uhFeIv3GIA+uhsG1BHHsG627+sDy7b8W9VWEd7tbcoz4Mvhf3P + 8g0AIt9/KJuStQZDrXwP1uP6Rrl759nDcNpoOKdSQ5EZ1zlRzeDROlZeDp7Ckfvw + GLmN/74Gl3pk0wfgHFY= + =wSgS + -----END PGP SIGNATURE----- + SIGNATURE + end + + def signed_commit_base_data + <<~SIGNEDDATA + tree ed60cfd202644fda1abaf684e7d965052db18c13 + parent caf6a0334a855e12f30205fff3d7333df1f65127 + author Nannie Bernhard <nannie.bernhard@example.com> 1487854510 +0100 + committer Nannie Bernhard <nannie.bernhard@example.com> 1487854510 +0100 + + signed commit, verified key/email + SIGNEDDATA + end + + def secret_key + <<~KEY.strip + -----BEGIN PGP PRIVATE KEY BLOCK----- + Version: GnuPG v1 + + lQHYBFiu1ScBBADUhWsrlWHp5e7ASlI5iMcA0XN43fivhVlGYJJy4Ii3Hr2i4f5s + VffHS8QyhgxxzSnPwe2OKnZWWL9cHzUFbiG3fHalEBTjpB+7pG4HBgU8R/tiDOu8 + vkAR+tfJbkuRs9XeG3dGKBX/8WRhIfRucYnM+04l2Myyo5zIx7thJmxXjwARAQAB + AAP/XUtcqrtfSnDYCK4Xvo4e3msUSAEZxOPDNzP51lhfbBQgp7qSGDj9Fw5ZyNwz + 5llse3nksT5OyMUY7HX+rq2UOs12a/piLqvhtX1okp/oTAETmKXNYkZLenv6t94P + NqLi0o2AnXAvL9ueXa7WUY3l4DkvuLcjT4+9Ut2Y71zIjeECAN7q9ohNL7E8tNkf + Elsbx+8KfyHRQXiSUYaQLlvDRq2lYCKIS7sogTqjZMEgbZx2mRX1fakRlvcmqOwB + QoX34zcCAPQPd+yTteNUV12uvDaj8V9DICktPPhbHdYYaUoHjF8RrIHCTRUPzk9E + KzCL9dUP8eXPPBV/ty+zjUwl69IgCmkB/3pnNZ0D4EJsNgu24UgI0N+c8H/PE1D6 + K+bGQ/jK83uYPMXJUsiojssCHLGNp7eBGHFn1PpEqZphgVI50ZMrZQWhJbQtTmFu + bmllIEJlcm5oYXJkIDxuYW5uaWUuYmVybmhhcmRAZXhhbXBsZS5jb20+iLgEEwEC + ACIFAliu1ScCGwMGCwkIBwMCBhUIAgkKCwQWAgMBAh4BAheAAAoJEMz74Z8ArIsd + p5ID/32hRalvTY+V+QAtzHlGdxugweSBzNgRT3A4UiC9chF6zBOEIw689lqmK6L4 + i3Il9XeKMl87wi9tsVy9TuOMYDTvcFvu1vMAQ5AsDXqZaAEtCUZpFZscNbi7AXG+ + QkoDQbMSxp0Rd6eIRJpk9zis5co87f78xJBZLZua+8awFMS6nQHYBFiu1ScBBADI + XkITf+kKCkD+n8tMsdTLInefu8KrJ8p7YRYCCabEXnWRsDb5zxUAG2VXCVUhYl6Q + XQybkNiBaduS+uxilz7gtYZUMFJvQ09+fV7D2N9B7u/1bGdIYz+cDFJnEJitLY4w + /nju2Sno5CL5Ead8sZuslKetSXPYHR/kbW462EOw5wARAQABAAP+IoZfU1XUdVbr + +RPWp3ny5SekviDPu8co9BZ4ANTh5+8wyfA3oNbGUxTlYthoU07MZYqq+/k63R28 + 6HgVGC3gdvCiRMGmryIQ6roLLRXkfzjXrI7Lgnhx4OtVjo62pAKDqdl45wEa1Q+M + v08CQF6XNpb5R9Xszz4aBC4eV0KjtjkCANlGSQHZ1B81g+iltj1FAhRHkyUFlrc1 + cqLVhNgxtHZ96+R57Uk2A7dIJBsE00eIYaHOfk5X5GD/95s1QvPcQskCAOwUk5xj + NeQ6VV/1+cI91TrWU6VnT2Yj8632fM/JlKKfaS15pp8t5Ha6pNFr3xD4KgQutchq + fPsEOjaU7nwQ/i8B/1rDPTYfNXFpRNt33WAB1XtpgOIHlpmOfaYYqf6lneTlZWBc + TgyO+j+ZsHAvP18ugIRkU8D192NflzgAGwXLryijyYifBBgBAgAJBQJYrtUnAhsM + AAoJEMz74Z8ArIsdlkUEALTl6QUutJsqwVF4ZXKmmw0IEk8PkqW4G+tYRDHJMs6Z + O0nzDS89BG2DL4/UlOs5wRvERnlJYz01TMTxq/ciKaBTEjygFIv9CgIEZh97VacZ + TIqcF40k9SbpJNnh3JLf94xsNxNRJTEhbVC3uruaeILue/IR7pBMEyCs49Gcguwy + =b6UD + -----END PGP PRIVATE KEY BLOCK----- + KEY + end + + def public_key + <<~KEY.strip + -----BEGIN PGP PUBLIC KEY BLOCK----- + Version: GnuPG v1 + + mI0EWK7VJwEEANSFayuVYenl7sBKUjmIxwDRc3jd+K+FWUZgknLgiLcevaLh/mxV + 98dLxDKGDHHNKc/B7Y4qdlZYv1wfNQVuIbd8dqUQFOOkH7ukbgcGBTxH+2IM67y+ + QBH618luS5Gz1d4bd0YoFf/xZGEh9G5xicz7TiXYzLKjnMjHu2EmbFePABEBAAG0 + LU5hbm5pZSBCZXJuaGFyZCA8bmFubmllLmJlcm5oYXJkQGV4YW1wbGUuY29tPoi4 + BBMBAgAiBQJYrtUnAhsDBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAKCRDM++Gf + AKyLHaeSA/99oUWpb02PlfkALcx5RncboMHkgczYEU9wOFIgvXIReswThCMOvPZa + piui+ItyJfV3ijJfO8IvbbFcvU7jjGA073Bb7tbzAEOQLA16mWgBLQlGaRWbHDW4 + uwFxvkJKA0GzEsadEXeniESaZPc4rOXKPO3+/MSQWS2bmvvGsBTEuriNBFiu1ScB + BADIXkITf+kKCkD+n8tMsdTLInefu8KrJ8p7YRYCCabEXnWRsDb5zxUAG2VXCVUh + Yl6QXQybkNiBaduS+uxilz7gtYZUMFJvQ09+fV7D2N9B7u/1bGdIYz+cDFJnEJit + LY4w/nju2Sno5CL5Ead8sZuslKetSXPYHR/kbW462EOw5wARAQABiJ8EGAECAAkF + Aliu1ScCGwwACgkQzPvhnwCsix2WRQQAtOXpBS60myrBUXhlcqabDQgSTw+Spbgb + 61hEMckyzpk7SfMNLz0EbYMvj9SU6znBG8RGeUljPTVMxPGr9yIpoFMSPKAUi/0K + AgRmH3tVpxlMipwXjST1Jukk2eHckt/3jGw3E1ElMSFtULe6u5p4gu578hHukEwT + IKzj0ZyC7DI= + =Ug0r + -----END PGP PUBLIC KEY BLOCK----- + KEY + end + + def primary_keyid + fingerprint[-16..-1] + end + + def fingerprint + '5F7EA3981A5845B141ABD522CCFBE19F00AC8B1D' + end + + def names + ['Nannie Bernhard'] + end + + def emails + ['nannie.bernhard@example.com'] + end + end + + module User2 + extend self + + def private_key + <<~KEY.strip + -----BEGIN PGP PRIVATE KEY BLOCK----- + Version: GnuPG v1 + + lQHYBFiuqioBBADg46jkiATWMy9t1npxFWJ77xibPXdUo36LAZgZ6uGungSzcFL4 + 50bdEyMMGm5RJp6DCYkZlwQDlM//YEqwf0Cmq/AibC5m9bHr7hf5sMxl40ssJ4fj + dzT6odihO0vxD2ARSrtiwkESzFxjJ51mjOfdPvAGf0ucxzgeRfUlCrM3kwARAQAB + AAP8CJlDFnbywR9dWfqBxi19sFMOk/smCObNQanuTcx6CDcu4zHi0Yxx6BoNCQES + cDRCLX5HevnpZngzQB3qa7dga+yqxKzwO8v0P0hliL81B1ZVXUk9TWhBj3NS3m3v + +kf2XeTxuZFb9fj44/4HpfbQ2yazTs/Xa+/ZeMqFPCYSNEECAOtjIbwHdfjkpVWR + uiwphRkNimv5hdObufs63m9uqhpKPdPKmr2IXgahPZg5PooxqE0k9IXaX2pBsJUF + DyuL1dsCAPSVL+YAOviP8ecM1jvdKpkFDd67kR5C+7jEvOGl+c2aX3qLvKt62HPR + +DxvYE0Oy0xfoHT14zNSfqthmlhIPqkB/i4WyJaafQVvkkoA9+A5aXbyihOR+RTx + p+CMNYvaAplFAyey7nv8l5+la/N+Sv86utjaenLZmCf34nDQEZy7rFWny7QvQmV0 + dGUgQ2FydHdyaWdodCA8YmV0dGUuY2FydHdyaWdodEBleGFtcGxlLmNvbT6IuAQT + AQIAIgUCWK6qKgIbAwYLCQgHAwIGFQgCCQoLBBYCAwECHgECF4AACgkQv52SX5Ee + /WVCGwP/QsOLTTyEJ6hl0Yy7DLY3kUxS6xiD9fW1FDoTQlxhiO+8TmghmhdtU3TI + ssP30/Su3pNKW3TkILtE9U8I2krEpsX5NkyMwmI6LXdeZjli2Lvtkx0Fm0Psd4HO + ORYJW5HqTx4jDLzeeIcYjqnobztDpfG8ONDvB0EI0GnCTOZNggG0L0JldHRlIENh + cnR3cmlnaHQgPGJldHRlLmNhcnR3cmlnaHRAZXhhbXBsZS5uZXQ+iLgEEwECACIF + AlivAsUCGwMGCwkIBwMCBhUIAgkKCwQWAgMBAh4BAheAAAoJEL+dkl+RHv1lXOwE + ANh7ce/vUjv6VMkO8o5OZXszhKE5+MSmYO8v/kkHcXNccC5wI6VF4K//r41p8Cyk + 9NzW7Kzjt2+14/BBqWugCx3xjWCuf88KH5PHbuSmfVYbzJmNSy6rfPmusZG5ePqD + xp5l2qQxMdRUX0Z36D/koM4N0ls6PAf6Xrdv9s6IBMMVnQHYBFiuqioBBADe5nUd + VOcbZlnxOjl0KBAT+A5bmyBLUT0BmLPsmA4PuXDSth7WvibPC8wcCdCYVk0IRMYn + eZUiWq/o5c4rthfLR4jg8kruvomQ4E4d4hyI6R0MLxXYZ3XMu67VuScFgbLURw1e + RZ16ANd3Nc1VuFW7ms0vCG0idB8iSZBoULaK8QARAQABAAP5AdCfUT/y2kmi75iF + ZX1ahSkax9LraEWW8TOCuolR6v2b7jFKrr2xX/P1A2DulID2Y1v4/5MJPHR/1G4D + l95Fkw+iGsTvKB5rPG5xye0vOYbbujRa6B9LL6s4Taf486shEegOrdjN9FIweM6f + vuVaDYzIk8Qwv5/sStEBxx8rxIkCAOBftFi56AY0gLniyEMAvVRjyVeOZPPJbS8i + v6L9asJB5wdsGJxJVyUZ/ylar5aCS7sroOcYTN2b1tOPoWuGqIkCAP5RlDRgm3Zg + xL6hXejqZp3G1/DXhKBSI/yUTR/D89H5/qNQe3W7dZqns9mSAJNtqOu+UMZ5UreY + Ond0/dmL5SkCAOO5r6gXM8ZDcNjydlQexCLnH70yVkCL6hG9Va1gOuFyUztRnCd+ + E35YRCEwZREZDr87BRr2Aak5t+lb1EFVqV+nvYifBBgBAgAJBQJYrqoqAhsMAAoJ + EL+dkl+RHv1lQggEANWwQwrlT2BFLWV8Fx+wlg31+mcjkTq0LaWu3oueAluoSl93 + 2B6ToruMh66JoxpSDU44x3JbCaZ/6poiYs5Aff8ZeyEVlfkVaQ7IWd5spjpXaS4i + oCOfkZepmbTuE7TPQWM4iBAtuIfiJGiwcpWWM+KIH281yhfCcbRzzFLsCVQx + =yEqv + -----END PGP PRIVATE KEY BLOCK----- + KEY + end + + def public_key + <<~KEY.strip + -----BEGIN PGP PUBLIC KEY BLOCK----- + Version: GnuPG v1 + + mI0EWK6qKgEEAODjqOSIBNYzL23WenEVYnvvGJs9d1SjfosBmBnq4a6eBLNwUvjn + Rt0TIwwablEmnoMJiRmXBAOUz/9gSrB/QKar8CJsLmb1sevuF/mwzGXjSywnh+N3 + NPqh2KE7S/EPYBFKu2LCQRLMXGMnnWaM590+8AZ/S5zHOB5F9SUKszeTABEBAAG0 + L0JldHRlIENhcnR3cmlnaHQgPGJldHRlLmNhcnR3cmlnaHRAZXhhbXBsZS5jb20+ + iLgEEwECACIFAliuqioCGwMGCwkIBwMCBhUIAgkKCwQWAgMBAh4BAheAAAoJEL+d + kl+RHv1lQhsD/0LDi008hCeoZdGMuwy2N5FMUusYg/X1tRQ6E0JcYYjvvE5oIZoX + bVN0yLLD99P0rt6TSlt05CC7RPVPCNpKxKbF+TZMjMJiOi13XmY5Yti77ZMdBZtD + 7HeBzjkWCVuR6k8eIwy83niHGI6p6G87Q6XxvDjQ7wdBCNBpwkzmTYIBtC9CZXR0 + ZSBDYXJ0d3JpZ2h0IDxiZXR0ZS5jYXJ0d3JpZ2h0QGV4YW1wbGUubmV0Poi4BBMB + AgAiBQJYrwLFAhsDBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAKCRC/nZJfkR79 + ZVzsBADYe3Hv71I7+lTJDvKOTmV7M4ShOfjEpmDvL/5JB3FzXHAucCOlReCv/6+N + afAspPTc1uys47dvtePwQalroAsd8Y1grn/PCh+Tx27kpn1WG8yZjUsuq3z5rrGR + uXj6g8aeZdqkMTHUVF9Gd+g/5KDODdJbOjwH+l63b/bOiATDFbiNBFiuqioBBADe + 5nUdVOcbZlnxOjl0KBAT+A5bmyBLUT0BmLPsmA4PuXDSth7WvibPC8wcCdCYVk0I + RMYneZUiWq/o5c4rthfLR4jg8kruvomQ4E4d4hyI6R0MLxXYZ3XMu67VuScFgbLU + Rw1eRZ16ANd3Nc1VuFW7ms0vCG0idB8iSZBoULaK8QARAQABiJ8EGAECAAkFAliu + qioCGwwACgkQv52SX5Ee/WVCCAQA1bBDCuVPYEUtZXwXH7CWDfX6ZyOROrQtpa7e + i54CW6hKX3fYHpOiu4yHromjGlINTjjHclsJpn/qmiJizkB9/xl7IRWV+RVpDshZ + 3mymOldpLiKgI5+Rl6mZtO4TtM9BYziIEC24h+IkaLBylZYz4ogfbzXKF8JxtHPM + UuwJVDE= + =0vYo + -----END PGP PUBLIC KEY BLOCK----- + KEY + end + + def primary_keyid + fingerprint[-16..-1] + end + + def fingerprint + '6D494CA6FC90C0CAE0910E42BF9D925F911EFD65' + end + + def names + ['Bette Cartwright', 'Bette Cartwright'] + end + + def emails + ['bette.cartwright@example.com', 'bette.cartwright@example.net'] + end + end +end diff --git a/spec/support/json_response_helpers.rb b/spec/support/json_response_helpers.rb index e8d2ef2d7f0..aa235529c56 100644 --- a/spec/support/json_response_helpers.rb +++ b/spec/support/json_response_helpers.rb @@ -3,7 +3,7 @@ shared_context 'JSON response' do end RSpec.configure do |config| - config.include_context 'JSON response', type: :controller + config.include_context 'JSON response' config.include_context 'JSON response', type: :request config.include_context 'JSON response', :api end diff --git a/spec/support/api/status_shared_examples.rb b/spec/support/shared_examples/requests/api/status_shared_examples.rb index 3481749a7f0..226277411d6 100644 --- a/spec/support/api/status_shared_examples.rb +++ b/spec/support/shared_examples/requests/api/status_shared_examples.rb @@ -9,7 +9,7 @@ shared_examples_for '400 response' do end it 'returns 400' do - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -20,7 +20,7 @@ shared_examples_for '403 response' do end it 'returns 403' do - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -32,7 +32,7 @@ shared_examples_for '404 response' do end it 'returns 404' do - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response).to be_an Object if message.present? diff --git a/spec/support/stub_configuration.rb b/spec/support/stub_configuration.rb index 80ecce92dc1..516f8878679 100644 --- a/spec/support/stub_configuration.rb +++ b/spec/support/stub_configuration.rb @@ -4,9 +4,9 @@ module StubConfiguration # Stubbing both of these because we're not yet consistent with how we access # current application settings - allow_any_instance_of(ApplicationSetting).to receive_messages(messages) + allow_any_instance_of(ApplicationSetting).to receive_messages(to_settings(messages)) allow(Gitlab::CurrentSettings.current_application_settings) - .to receive_messages(messages) + .to receive_messages(to_settings(messages)) end def stub_not_protect_default_branch @@ -15,23 +15,27 @@ module StubConfiguration end def stub_config_setting(messages) - allow(Gitlab.config.gitlab).to receive_messages(messages) + allow(Gitlab.config.gitlab).to receive_messages(to_settings(messages)) end def stub_gravatar_setting(messages) - allow(Gitlab.config.gravatar).to receive_messages(messages) + allow(Gitlab.config.gravatar).to receive_messages(to_settings(messages)) end def stub_incoming_email_setting(messages) - allow(Gitlab.config.incoming_email).to receive_messages(messages) + allow(Gitlab.config.incoming_email).to receive_messages(to_settings(messages)) end def stub_mattermost_setting(messages) - allow(Gitlab.config.mattermost).to receive_messages(messages) + allow(Gitlab.config.mattermost).to receive_messages(to_settings(messages)) end def stub_omniauth_setting(messages) - allow(Gitlab.config.omniauth).to receive_messages(messages) + allow(Gitlab.config.omniauth).to receive_messages(to_settings(messages)) + end + + def stub_backup_setting(messages) + allow(Gitlab.config.backup).to receive_messages(to_settings(messages)) end private @@ -54,4 +58,15 @@ module StubConfiguration messages[predicate.to_sym] = messages[key.to_sym] end end + + # Support nested hashes by converting all values into Settingslogic objects + def to_settings(hash) + hash.transform_values do |value| + if value.is_a? Hash + Settingslogic.new(value.deep_stringify_keys) + else + value + end + end + end end diff --git a/spec/support/test_env.rb b/spec/support/test_env.rb index 0a194ca4c90..86f9568c12e 100644 --- a/spec/support/test_env.rb +++ b/spec/support/test_env.rb @@ -5,6 +5,7 @@ module TestEnv # When developing the seed repository, comment out the branch you will modify. BRANCH_SHA = { + 'signed-commits' => '5d4a1cb', 'not-merged-branch' => 'b83d6e3', 'branch-merged' => '498214d', 'empty-branch' => '7efb185', @@ -41,7 +42,8 @@ module TestEnv 'csv' => '3dd0896', 'v1.1.0' => 'b83d6e3', 'add-ipython-files' => '93ee732', - 'add-pdf-file' => 'e774ebd' + 'add-pdf-file' => 'e774ebd', + 'add-pdf-text-binary' => '79faa7b' }.freeze # gitlab-test-fork is a fork of gitlab-fork, but we don't necessarily @@ -145,7 +147,7 @@ module TestEnv gitaly_exec = File.join(gitaly_dir, 'gitaly') gitaly_config = File.join(gitaly_dir, 'config.toml') log_file = Rails.root.join('log/gitaly-test.log').to_s - @gitaly_pid = spawn(gitaly_exec, gitaly_config, [:out, :err] => log_file) + @gitaly_pid = Bundler.with_original_env { spawn(gitaly_exec, gitaly_config, [:out, :err] => log_file) } end def stop_gitaly diff --git a/spec/views/ci/status/_badge.html.haml_spec.rb b/spec/views/ci/status/_badge.html.haml_spec.rb index 6a4738ba443..de0b59f83f8 100644 --- a/spec/views/ci/status/_badge.html.haml_spec.rb +++ b/spec/views/ci/status/_badge.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'ci/status/_badge', :view do +describe 'ci/status/_badge' do let(:user) { create(:user) } let(:project) { create(:empty_project, :private) } let(:pipeline) { create(:ci_pipeline, project: project) } diff --git a/spec/views/projects/_home_panel.html.haml_spec.rb b/spec/views/projects/_home_panel.html.haml_spec.rb index f5381a48207..f8c6cb6b5c6 100644 --- a/spec/views/projects/_home_panel.html.haml_spec.rb +++ b/spec/views/projects/_home_panel.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'projects/_home_panel', :view do +describe 'projects/_home_panel' do let(:project) { create(:empty_project, :public) } let(:notification_settings) do diff --git a/spec/views/projects/blob/_viewer.html.haml_spec.rb b/spec/views/projects/blob/_viewer.html.haml_spec.rb index bbd7f98fa8d..af833168bd9 100644 --- a/spec/views/projects/blob/_viewer.html.haml_spec.rb +++ b/spec/views/projects/blob/_viewer.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'projects/blob/_viewer.html.haml', :view do +describe 'projects/blob/_viewer.html.haml' do include FakeBlobHelpers let(:project) { build(:empty_project) } diff --git a/spec/views/projects/commit/_commit_box.html.haml_spec.rb b/spec/views/projects/commit/_commit_box.html.haml_spec.rb index ab120929c6c..448b925cf34 100644 --- a/spec/views/projects/commit/_commit_box.html.haml_spec.rb +++ b/spec/views/projects/commit/_commit_box.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'projects/commit/_commit_box.html.haml', :view do +describe 'projects/commit/_commit_box.html.haml' do let(:user) { create(:user) } let(:project) { create(:project, :repository) } diff --git a/spec/views/projects/commit/show.html.haml_spec.rb b/spec/views/projects/commit/show.html.haml_spec.rb index 92b4aa12d49..32c95c6bb0d 100644 --- a/spec/views/projects/commit/show.html.haml_spec.rb +++ b/spec/views/projects/commit/show.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'projects/commit/show.html.haml', :view do +describe 'projects/commit/show.html.haml' do let(:project) { create(:project, :repository) } before do diff --git a/spec/views/projects/diffs/_viewer.html.haml_spec.rb b/spec/views/projects/diffs/_viewer.html.haml_spec.rb index 32469202508..8ac32db5585 100644 --- a/spec/views/projects/diffs/_viewer.html.haml_spec.rb +++ b/spec/views/projects/diffs/_viewer.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'projects/diffs/_viewer.html.haml', :view do +describe 'projects/diffs/_viewer.html.haml' do include FakeBlobHelpers let(:project) { create(:project, :repository) } diff --git a/spec/views/projects/jobs/show.html.haml_spec.rb b/spec/views/projects/jobs/show.html.haml_spec.rb index d9a7ba265f8..117f48450e2 100644 --- a/spec/views/projects/jobs/show.html.haml_spec.rb +++ b/spec/views/projects/jobs/show.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'projects/jobs/show', :view do +describe 'projects/jobs/show' do let(:project) { create(:project, :repository) } let(:build) { create(:ci_build, pipeline: pipeline) } diff --git a/spec/views/projects/merge_requests/creations/_new_submit.html.haml_spec.rb b/spec/views/projects/merge_requests/creations/_new_submit.html.haml_spec.rb index 1e9bdf9108f..5770cf92b4e 100644 --- a/spec/views/projects/merge_requests/creations/_new_submit.html.haml_spec.rb +++ b/spec/views/projects/merge_requests/creations/_new_submit.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'projects/merge_requests/creations/_new_submit.html.haml', :view do +describe 'projects/merge_requests/creations/_new_submit.html.haml' do let(:merge_request) { create(:merge_request) } let!(:pipeline) { create(:ci_empty_pipeline) } diff --git a/spec/views/projects/notes/_more_actions_dropdown.html.haml_spec.rb b/spec/views/projects/notes/_more_actions_dropdown.html.haml_spec.rb index e56c0f6be03..37ce7121ccb 100644 --- a/spec/views/projects/notes/_more_actions_dropdown.html.haml_spec.rb +++ b/spec/views/projects/notes/_more_actions_dropdown.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'projects/notes/_more_actions_dropdown', :view do +describe 'projects/notes/_more_actions_dropdown' do let(:author_user) { create(:user) } let(:not_author_user) { create(:user) } diff --git a/spec/views/projects/pipelines/_stage.html.haml_spec.rb b/spec/views/projects/pipelines/_stage.html.haml_spec.rb index 9c91c4e0fbd..e40e16e742b 100644 --- a/spec/views/projects/pipelines/_stage.html.haml_spec.rb +++ b/spec/views/projects/pipelines/_stage.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'projects/pipelines/_stage', :view do +describe 'projects/pipelines/_stage' do let(:project) { create(:project, :repository) } let(:pipeline) { create(:ci_pipeline, project: project) } let(:stage) { build(:ci_stage, pipeline: pipeline) } diff --git a/spec/views/projects/registry/repositories/index.html.haml_spec.rb b/spec/views/projects/registry/repositories/index.html.haml_spec.rb index ceeace3dc8d..f13b657d474 100644 --- a/spec/views/projects/registry/repositories/index.html.haml_spec.rb +++ b/spec/views/projects/registry/repositories/index.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'projects/registry/repositories/index', :view do +describe 'projects/registry/repositories/index' do let(:group) { create(:group, path: 'group') } let(:project) { create(:empty_project, group: group, path: 'test') } diff --git a/spec/views/projects/tags/index.html.haml_spec.rb b/spec/views/projects/tags/index.html.haml_spec.rb index 33122365e9a..f65cd9f398f 100644 --- a/spec/views/projects/tags/index.html.haml_spec.rb +++ b/spec/views/projects/tags/index.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'projects/tags/index', :view do +describe 'projects/tags/index' do let(:project) { create(:project) } before do diff --git a/spec/views/shared/projects/_project.html.haml_spec.rb b/spec/views/shared/projects/_project.html.haml_spec.rb new file mode 100644 index 00000000000..43334c2c236 --- /dev/null +++ b/spec/views/shared/projects/_project.html.haml_spec.rb @@ -0,0 +1,19 @@ +require 'spec_helper' + +describe 'shared/projects/_project.html.haml' do + let(:project) { create(:empty_project) } + + it 'should render creator avatar if project has a creator' do + render 'shared/projects/project', use_creator_avatar: true, project: project + + expect(rendered).to have_selector('img.avatar') + end + + it 'should render a generic avatar if project does not have a creator' do + project.creator = nil + + render 'shared/projects/project', use_creator_avatar: true, project: project + + expect(rendered).to have_selector('.project-avatar') + end +end diff --git a/spec/workers/create_gpg_signature_worker_spec.rb b/spec/workers/create_gpg_signature_worker_spec.rb new file mode 100644 index 00000000000..c6a17d77d73 --- /dev/null +++ b/spec/workers/create_gpg_signature_worker_spec.rb @@ -0,0 +1,47 @@ +require 'spec_helper' + +describe CreateGpgSignatureWorker do + context 'when GpgKey is found' do + it 'calls Commit#signature' do + commit_sha = '0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33' + project = create :project + commit = instance_double(Commit) + + allow(Project).to receive(:find_by).with(id: project.id).and_return(project) + allow(project).to receive(:commit).with(commit_sha).and_return(commit) + + expect(commit).to receive(:signature) + + described_class.new.perform(commit_sha, project.id) + end + end + + context 'when Commit is not found' do + let(:nonexisting_commit_sha) { 'bogus' } + let(:project) { create :project } + + it 'does not raise errors' do + expect { described_class.new.perform(nonexisting_commit_sha, project.id) }.not_to raise_error + end + + it 'does not call Commit#signature' do + expect_any_instance_of(Commit).not_to receive(:signature) + + described_class.new.perform(nonexisting_commit_sha, project.id) + end + end + + context 'when Project is not found' do + let(:nonexisting_project_id) { -1 } + + it 'does not raise errors' do + expect { described_class.new.perform(anything, nonexisting_project_id) }.not_to raise_error + end + + it 'does not call Commit#signature' do + expect_any_instance_of(Commit).not_to receive(:signature) + + described_class.new.perform(anything, nonexisting_project_id) + end + end +end diff --git a/spec/workers/invalid_gpg_signature_update_worker_spec.rb b/spec/workers/invalid_gpg_signature_update_worker_spec.rb new file mode 100644 index 00000000000..5972696515b --- /dev/null +++ b/spec/workers/invalid_gpg_signature_update_worker_spec.rb @@ -0,0 +1,29 @@ +require 'spec_helper' + +describe InvalidGpgSignatureUpdateWorker do + context 'when GpgKey is found' do + it 'calls NotificationService.new.run' do + gpg_key = create(:gpg_key) + invalid_signature_updater = double(:invalid_signature_updater) + + expect(Gitlab::Gpg::InvalidGpgSignatureUpdater).to receive(:new).with(gpg_key).and_return(invalid_signature_updater) + expect(invalid_signature_updater).to receive(:run) + + described_class.new.perform(gpg_key.id) + end + end + + context 'when GpgKey is not found' do + let(:nonexisting_gpg_key_id) { -1 } + + it 'does not raise errors' do + expect { described_class.new.perform(nonexisting_gpg_key_id) }.not_to raise_error + end + + it 'does not call NotificationService.new.run' do + expect(Gitlab::Gpg::InvalidGpgSignatureUpdater).not_to receive(:new) + + described_class.new.perform(nonexisting_gpg_key_id) + end + end +end diff --git a/spec/workers/project_destroy_worker_spec.rb b/spec/workers/project_destroy_worker_spec.rb index 3d135f40c1f..f19c9dff941 100644 --- a/spec/workers/project_destroy_worker_spec.rb +++ b/spec/workers/project_destroy_worker_spec.rb @@ -1,24 +1,36 @@ require 'spec_helper' describe ProjectDestroyWorker do - let(:project) { create(:project, :repository) } + let(:project) { create(:project, :repository, pending_delete: true) } let(:path) { project.repository.path_to_repo } subject { described_class.new } - describe "#perform" do - it "deletes the project" do + describe '#perform' do + it 'deletes the project' do subject.perform(project.id, project.owner.id, {}) expect(Project.all).not_to include(project) expect(Dir.exist?(path)).to be_falsey end - it "deletes the project but skips repo deletion" do + it 'deletes the project but skips repo deletion' do subject.perform(project.id, project.owner.id, { "skip_repo" => true }) expect(Project.all).not_to include(project) expect(Dir.exist?(path)).to be_truthy end + + it 'does not raise error when project could not be found' do + expect do + subject.perform(-1, project.owner.id, {}) + end.not_to raise_error + end + + it 'does not raise error when user could not be found' do + expect do + subject.perform(project.id, -1, {}) + end.not_to raise_error + end end end |