diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2017-08-07 16:19:28 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2017-08-07 16:19:28 +0800 |
commit | b9a8147333ba3eb6cf4cc83397d61e995b9683e6 (patch) | |
tree | 7d9140693ea29070967439f5648d8dc958deebf0 /spec/services | |
parent | b3e058996c70aeae6f00cad7195bce421e02b39b (diff) | |
parent | 03b816f3e845c9b25d3588336fc1616238465deb (diff) | |
download | gitlab-ce-b9a8147333ba3eb6cf4cc83397d61e995b9683e6.tar.gz |
Merge remote-tracking branch 'upstream/master' into add-star-for-action-scope
* upstream/master: (184 commits)
Fix issues with pdf-js dependencies
fix missing changelog entries for security release on 2017-01-23
Update top bar issues icon
Fix pipeline icon in contextual nav for projects
Since mysql is not a priority anymore, test it less
Fix order of CI lint ace editor loading
Add container registry and spam logs icons
Fix different Markdown styles
Backport to CE for:
Make new dropdown dividers full width
Fix spec
Fix spec
Fix spec
Bump GITLAB_SHELL_VERSION and GITALY_VERSION to support unhiding refs
Add changelog
Install yarn via apt in update guides
Use long curl options
fix
Add a spec for concurrent process
Remove monkey-patched Array.prototype.first() and last() methods
...
Diffstat (limited to 'spec/services')
77 files changed, 207 insertions, 195 deletions
diff --git a/spec/services/auth/container_registry_authentication_service_spec.rb b/spec/services/auth/container_registry_authentication_service_spec.rb index 7ae7f4688a2..0e7d802e336 100644 --- a/spec/services/auth/container_registry_authentication_service_spec.rb +++ b/spec/services/auth/container_registry_authentication_service_spec.rb @@ -102,7 +102,7 @@ describe Auth::ContainerRegistryAuthenticationService do end describe '#full_access_token' do - let(:project) { create(:empty_project) } + let(:project) { create(:project) } let(:token) { described_class.full_access_token(project.full_path) } subject { { token: token } } @@ -118,7 +118,7 @@ describe Auth::ContainerRegistryAuthenticationService do let(:current_user) { create(:user) } context 'for private project' do - let(:project) { create(:empty_project) } + let(:project) { create(:project) } context 'allow to use scope-less authentication' do it_behaves_like 'a valid token' @@ -219,7 +219,7 @@ describe Auth::ContainerRegistryAuthenticationService do end context 'for public project' do - let(:project) { create(:empty_project, :public) } + let(:project) { create(:project, :public) } context 'allow anyone to pull images' do let(:current_params) do @@ -259,7 +259,7 @@ describe Auth::ContainerRegistryAuthenticationService do end context 'for internal project' do - let(:project) { create(:empty_project, :internal) } + let(:project) { create(:project, :internal) } context 'for internal user' do context 'allow anyone to pull images' do @@ -340,7 +340,7 @@ describe Auth::ContainerRegistryAuthenticationService do end context 'build authorized as user' do - let(:current_project) { create(:empty_project) } + let(:current_project) { create(:project) } let(:current_user) { create(:user) } let(:authentication_abilities) do @@ -384,7 +384,7 @@ describe Auth::ContainerRegistryAuthenticationService do end context 'allow for public' do - let(:project) { create(:empty_project, :public) } + let(:project) { create(:project, :public) } it_behaves_like 'a pullable' it_behaves_like 'not a container repository factory' @@ -406,7 +406,7 @@ describe Auth::ContainerRegistryAuthenticationService do end context 'when you are owner' do - let(:project) { create(:empty_project, namespace: current_user.namespace) } + let(:project) { create(:project, namespace: current_user.namespace) } it_behaves_like 'a pullable' it_behaves_like 'not a container repository factory' @@ -414,7 +414,7 @@ describe Auth::ContainerRegistryAuthenticationService do end context 'for private' do - let(:project) { create(:empty_project, :private) } + let(:project) { create(:project, :private) } it_behaves_like 'pullable for being team member' @@ -436,7 +436,7 @@ describe Auth::ContainerRegistryAuthenticationService do end context 'when you are owner' do - let(:project) { create(:empty_project, namespace: current_user.namespace) } + let(:project) { create(:project, namespace: current_user.namespace) } it_behaves_like 'a pullable' it_behaves_like 'not a container repository factory' @@ -452,7 +452,7 @@ describe Auth::ContainerRegistryAuthenticationService do context 'disallow for all' do context 'when you are member' do - let(:project) { create(:empty_project, :public) } + let(:project) { create(:project, :public) } before do project.add_developer(current_user) @@ -463,7 +463,7 @@ describe Auth::ContainerRegistryAuthenticationService do end context 'when you are owner' do - let(:project) { create(:empty_project, :public, namespace: current_user.namespace) } + let(:project) { create(:project, :public, namespace: current_user.namespace) } it_behaves_like 'an inaccessible' it_behaves_like 'not a container repository factory' @@ -473,7 +473,7 @@ describe Auth::ContainerRegistryAuthenticationService do end context 'for project without container registry' do - let(:project) { create(:empty_project, :public, container_registry_enabled: false) } + let(:project) { create(:project, :public, container_registry_enabled: false) } before do project.update(container_registry_enabled: false) @@ -506,7 +506,7 @@ describe Auth::ContainerRegistryAuthenticationService do end context 'for private project' do - let(:project) { create(:empty_project, :private) } + let(:project) { create(:project, :private) } let(:current_params) do { scope: "repository:#{project.full_path}:pull" } @@ -516,7 +516,7 @@ describe Auth::ContainerRegistryAuthenticationService do end context 'for public project' do - let(:project) { create(:empty_project, :public) } + let(:project) { create(:project, :public) } context 'when pulling and pushing' do let(:current_params) do diff --git a/spec/services/boards/create_service_spec.rb b/spec/services/boards/create_service_spec.rb index 6e3227303fe..db51a524e79 100644 --- a/spec/services/boards/create_service_spec.rb +++ b/spec/services/boards/create_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe Boards::CreateService do describe '#execute' do - let(:project) { create(:empty_project) } + let(:project) { create(:project) } subject(:service) { described_class.new(project, double) } diff --git a/spec/services/boards/issues/create_service_spec.rb b/spec/services/boards/issues/create_service_spec.rb index 23ad66e454b..f2ddaa903da 100644 --- a/spec/services/boards/issues/create_service_spec.rb +++ b/spec/services/boards/issues/create_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe Boards::Issues::CreateService do describe '#execute' do - let(:project) { create(:empty_project) } + let(:project) { create(:project) } let(:board) { create(:board, project: project) } let(:user) { create(:user) } let(:label) { create(:label, project: project, name: 'in-progress') } diff --git a/spec/services/boards/issues/list_service_spec.rb b/spec/services/boards/issues/list_service_spec.rb index b1b5d807a78..01ee3856c99 100644 --- a/spec/services/boards/issues/list_service_spec.rb +++ b/spec/services/boards/issues/list_service_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe Boards::Issues::ListService do describe '#execute' do let(:user) { create(:user) } - let(:project) { create(:empty_project) } + let(:project) { create(:project) } let(:board) { create(:board, project: project) } let(:bug) { create(:label, project: project, name: 'Bug') } diff --git a/spec/services/boards/issues/move_service_spec.rb b/spec/services/boards/issues/move_service_spec.rb index 15a32350ae2..63dfe80d672 100644 --- a/spec/services/boards/issues/move_service_spec.rb +++ b/spec/services/boards/issues/move_service_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe Boards::Issues::MoveService do describe '#execute' do let(:user) { create(:user) } - let(:project) { create(:empty_project) } + let(:project) { create(:project) } let(:board1) { create(:board, project: project) } let(:bug) { create(:label, project: project, name: 'Bug') } diff --git a/spec/services/boards/list_service_spec.rb b/spec/services/boards/list_service_spec.rb index a95b12eeaa3..1d0be99fb35 100644 --- a/spec/services/boards/list_service_spec.rb +++ b/spec/services/boards/list_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe Boards::ListService do describe '#execute' do - let(:project) { create(:empty_project) } + let(:project) { create(:project) } subject(:service) { described_class.new(project, double) } diff --git a/spec/services/boards/lists/create_service_spec.rb b/spec/services/boards/lists/create_service_spec.rb index 86d3227a78d..7d0b396cd06 100644 --- a/spec/services/boards/lists/create_service_spec.rb +++ b/spec/services/boards/lists/create_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe Boards::Lists::CreateService do describe '#execute' do - let(:project) { create(:empty_project) } + let(:project) { create(:project) } let(:board) { create(:board, project: project) } let(:user) { create(:user) } let(:label) { create(:label, project: project, name: 'in-progress') } diff --git a/spec/services/boards/lists/destroy_service_spec.rb b/spec/services/boards/lists/destroy_service_spec.rb index ad6ae83286d..bd98625b44f 100644 --- a/spec/services/boards/lists/destroy_service_spec.rb +++ b/spec/services/boards/lists/destroy_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe Boards::Lists::DestroyService do describe '#execute' do - let(:project) { create(:empty_project) } + let(:project) { create(:project) } let(:board) { create(:board, project: project) } let(:user) { create(:user) } diff --git a/spec/services/boards/lists/generate_service_spec.rb b/spec/services/boards/lists/generate_service_spec.rb index 7dec9f7a4a5..592f25059ac 100644 --- a/spec/services/boards/lists/generate_service_spec.rb +++ b/spec/services/boards/lists/generate_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe Boards::Lists::GenerateService do describe '#execute' do - let(:project) { create(:empty_project) } + let(:project) { create(:project) } let(:board) { create(:board, project: project) } let(:user) { create(:user) } diff --git a/spec/services/boards/lists/list_service_spec.rb b/spec/services/boards/lists/list_service_spec.rb index c93788d4516..b189857e4f4 100644 --- a/spec/services/boards/lists/list_service_spec.rb +++ b/spec/services/boards/lists/list_service_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe Boards::Lists::ListService do - let(:project) { create(:empty_project) } + let(:project) { create(:project) } let(:board) { create(:board, project: project) } let(:label) { create(:label, project: project) } let!(:list) { create(:list, board: board, label: label) } diff --git a/spec/services/boards/lists/move_service_spec.rb b/spec/services/boards/lists/move_service_spec.rb index 43e125a21df..a9d218bad49 100644 --- a/spec/services/boards/lists/move_service_spec.rb +++ b/spec/services/boards/lists/move_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe Boards::Lists::MoveService do describe '#execute' do - let(:project) { create(:empty_project) } + let(:project) { create(:project) } let(:board) { create(:board, project: project) } let(:user) { create(:user) } diff --git a/spec/services/ci/create_pipeline_service_spec.rb b/spec/services/ci/create_pipeline_service_spec.rb index 4ec495f612e..730df4e0336 100644 --- a/spec/services/ci/create_pipeline_service_spec.rb +++ b/spec/services/ci/create_pipeline_service_spec.rb @@ -75,7 +75,7 @@ describe Ci::CreatePipelineService do end context 'when merge request target project is different from source project' do - let!(:target_project) { create(:project) } + let!(:target_project) { create(:project, :repository) } let!(:forked_project_link) { create(:forked_project_link, forked_to_project: project, forked_from_project: target_project) } it 'updates head pipeline for merge request' do diff --git a/spec/services/ci/pipeline_trigger_service_spec.rb b/spec/services/ci/pipeline_trigger_service_spec.rb index e9188a83b89..9a6875e448c 100644 --- a/spec/services/ci/pipeline_trigger_service_spec.rb +++ b/spec/services/ci/pipeline_trigger_service_spec.rb @@ -18,7 +18,7 @@ describe Ci::PipelineTriggerService do 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) } + let(:trigger) { create(:ci_trigger, project: create(:project), owner: user) } it 'does nothing' do expect { result }.not_to change { Ci::Pipeline.count } diff --git a/spec/services/ci/play_build_service_spec.rb b/spec/services/ci/play_build_service_spec.rb index 1ced26ff98d..330ec81e87d 100644 --- a/spec/services/ci/play_build_service_spec.rb +++ b/spec/services/ci/play_build_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe Ci::PlayBuildService, '#execute' do let(:user) { create(:user) } - let(:project) { create(:empty_project) } + let(:project) { create(:project) } let(:pipeline) { create(:ci_pipeline, project: project) } let(:build) { create(:ci_build, :manual, pipeline: pipeline) } @@ -11,7 +11,7 @@ describe Ci::PlayBuildService, '#execute' do end context 'when project does not have repository yet' do - let(:project) { create(:empty_project) } + let(:project) { create(:project) } it 'allows user to play build if protected branch rules are met' do project.add_developer(user) @@ -33,7 +33,7 @@ describe Ci::PlayBuildService, '#execute' do end context 'when project has repository' do - let(:project) { create(:project) } + let(:project) { create(:project, :repository) } it 'allows user with developer role to play a build' do project.add_developer(user) diff --git a/spec/services/ci/process_pipeline_service_spec.rb b/spec/services/ci/process_pipeline_service_spec.rb index 3a702742681..214adc9960f 100644 --- a/spec/services/ci/process_pipeline_service_spec.rb +++ b/spec/services/ci/process_pipeline_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe Ci::ProcessPipelineService, '#execute' do let(:user) { create(:user) } - let(:project) { create(:empty_project) } + let(:project) { create(:project) } let(:pipeline) do create(:ci_empty_pipeline, ref: 'master', project: project) diff --git a/spec/services/ci/register_job_service_spec.rb b/spec/services/ci/register_job_service_spec.rb index 23c0f715c3e..8eb0d2d10a4 100644 --- a/spec/services/ci/register_job_service_spec.rb +++ b/spec/services/ci/register_job_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' module Ci describe RegisterJobService do - let!(:project) { FactoryGirl.create :empty_project, shared_runners_enabled: false } + let!(:project) { FactoryGirl.create :project, shared_runners_enabled: false } let!(:pipeline) { FactoryGirl.create :ci_pipeline, project: project } let!(:pending_build) { FactoryGirl.create :ci_build, pipeline: pipeline } let!(:shared_runner) { FactoryGirl.create(:ci_runner, is_shared: true) } @@ -72,9 +72,9 @@ module Ci end context 'for multiple builds' do - let!(:project2) { create :empty_project, shared_runners_enabled: true } + let!(:project2) { create :project, shared_runners_enabled: true } let!(:pipeline2) { create :ci_pipeline, project: project2 } - let!(:project3) { create :empty_project, shared_runners_enabled: true } + let!(:project3) { create :project, shared_runners_enabled: true } let!(:pipeline3) { create :ci_pipeline, project: project3 } let!(:build1_project1) { pending_build } let!(:build2_project1) { 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 fd8a57d28f0..cec667071cc 100644 --- a/spec/services/ci/retry_build_service_spec.rb +++ b/spec/services/ci/retry_build_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe Ci::RetryBuildService do let(:user) { create(:user) } - let(:project) { create(:empty_project) } + let(:project) { create(:project) } let(:pipeline) { create(:ci_pipeline, project: project) } let(:build) { create(:ci_build, pipeline: pipeline) } diff --git a/spec/services/ci/retry_pipeline_service_spec.rb b/spec/services/ci/retry_pipeline_service_spec.rb index 90b0c5a4dce..6ce75c65c8c 100644 --- a/spec/services/ci/retry_pipeline_service_spec.rb +++ b/spec/services/ci/retry_pipeline_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe Ci::RetryPipelineService, '#execute' do let(:user) { create(:user) } - let(:project) { create(:empty_project) } + let(:project) { create(:project) } let(:pipeline) { create(:ci_pipeline, project: project) } let(:service) { described_class.new(project, user) } diff --git a/spec/services/delete_merged_branches_service_spec.rb b/spec/services/delete_merged_branches_service_spec.rb index 4b872d667cf..03c682ae0d7 100644 --- a/spec/services/delete_merged_branches_service_spec.rb +++ b/spec/services/delete_merged_branches_service_spec.rb @@ -32,6 +32,14 @@ describe DeleteMergedBranchesService do expect(project.repository.branch_names).to include('improve/awesome') end + it 'keeps wildcard protected branches' do + create(:protected_branch, project: project, name: 'improve/*') + + service.execute + + expect(project.repository.branch_names).to include('improve/awesome') + end + context 'user without rights' do let(:user) { create(:user) } diff --git a/spec/services/event_create_service_spec.rb b/spec/services/event_create_service_spec.rb index 00104ae1fd9..42adb044190 100644 --- a/spec/services/event_create_service_spec.rb +++ b/spec/services/event_create_service_spec.rb @@ -114,7 +114,7 @@ describe EventCreateService do end describe '#push', :clean_gitlab_redis_shared_state do - let(:project) { create(:empty_project) } + let(:project) { create(:project) } let(:user) { create(:user) } it 'creates a new event' do @@ -128,7 +128,7 @@ describe EventCreateService do describe 'Project' do let(:user) { create :user } - let(:project) { create(:empty_project) } + let(:project) { create(:project) } describe '#join_project' do subject { service.join_project(project, user) } diff --git a/spec/services/groups/destroy_service_spec.rb b/spec/services/groups/destroy_service_spec.rb index c18870ea100..1b2ce3cd03e 100644 --- a/spec/services/groups/destroy_service_spec.rb +++ b/spec/services/groups/destroy_service_spec.rb @@ -6,7 +6,7 @@ describe Groups::DestroyService do let!(:user) { create(:user) } let!(:group) { create(:group) } let!(:nested_group) { create(:group, parent: group) } - let!(:project) { create(:empty_project, namespace: group) } + let!(:project) { create(:project, namespace: group) } let!(:notification_setting) { create(:notification_setting, source: group)} let!(:gitlab_shell) { Gitlab::Shell.new } let!(:remove_path) { group.path + "+#{group.id}+deleted" } diff --git a/spec/services/groups/update_service_spec.rb b/spec/services/groups/update_service_spec.rb index 9902e1aff8b..44f22a3b37b 100644 --- a/spec/services/groups/update_service_spec.rb +++ b/spec/services/groups/update_service_spec.rb @@ -13,7 +13,7 @@ describe Groups::UpdateService do before do public_group.add_user(user, Gitlab::Access::MASTER) - create(:empty_project, :public, group: public_group) + create(:project, :public, group: public_group) end it "does not change permission level" do @@ -27,7 +27,7 @@ describe Groups::UpdateService do before do internal_group.add_user(user, Gitlab::Access::MASTER) - create(:empty_project, :internal, group: internal_group) + create(:project, :internal, group: internal_group) end it "does not change permission level" do @@ -69,7 +69,7 @@ describe Groups::UpdateService do before do internal_group.add_user(user, Gitlab::Access::MASTER) - create(:empty_project, :internal, group: internal_group) + create(:project, :internal, group: internal_group) end it 'returns true' do diff --git a/spec/services/issuable/bulk_update_service_spec.rb b/spec/services/issuable/bulk_update_service_spec.rb index 055aa6156cb..befa65ec0f8 100644 --- a/spec/services/issuable/bulk_update_service_spec.rb +++ b/spec/services/issuable/bulk_update_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe Issuable::BulkUpdateService do let(:user) { create(:user) } - let(:project) { create(:empty_project, namespace: user.namespace) } + let(:project) { create(:project, namespace: user.namespace) } def bulk_update(issuables, extra_params = {}) bulk_update_params = extra_params diff --git a/spec/services/issues/create_service_spec.rb b/spec/services/issues/create_service_spec.rb index a48748e274d..fcbd69fd58b 100644 --- a/spec/services/issues/create_service_spec.rb +++ b/spec/services/issues/create_service_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe Issues::CreateService do - let(:project) { create(:empty_project) } + let(:project) { create(:project) } let(:user) { create(:user) } describe '#execute' do diff --git a/spec/services/issues/duplicate_service_spec.rb b/spec/services/issues/duplicate_service_spec.rb index ed55664e382..089e77cc88b 100644 --- a/spec/services/issues/duplicate_service_spec.rb +++ b/spec/services/issues/duplicate_service_spec.rb @@ -2,8 +2,8 @@ require 'spec_helper' describe Issues::DuplicateService do let(:user) { create(:user) } - let(:canonical_project) { create(:empty_project) } - let(:duplicate_project) { create(:empty_project) } + let(:canonical_project) { create(:project) } + let(:duplicate_project) { create(:project) } let(:canonical_issue) { create(:issue, project: canonical_project) } let(:duplicate_issue) { create(:issue, project: duplicate_project) } diff --git a/spec/services/issues/move_service_spec.rb b/spec/services/issues/move_service_spec.rb index 171fc7334c4..f2b35a8fadf 100644 --- a/spec/services/issues/move_service_spec.rb +++ b/spec/services/issues/move_service_spec.rb @@ -5,8 +5,8 @@ describe Issues::MoveService do let(:author) { create(:user) } let(:title) { 'Some issue' } let(:description) { 'Some issue description' } - let(:old_project) { create(:empty_project) } - let(:new_project) { create(:empty_project) } + let(:old_project) { create(:project) } + let(:new_project) { create(:project) } let(:milestone1) { create(:milestone, project_id: old_project.id, title: 'v9.0') } let(:old_issue) do diff --git a/spec/services/issues/reopen_service_spec.rb b/spec/services/issues/reopen_service_spec.rb index 1ff988e9b47..205e9ebd237 100644 --- a/spec/services/issues/reopen_service_spec.rb +++ b/spec/services/issues/reopen_service_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe Issues::ReopenService do - let(:project) { create(:empty_project) } + let(:project) { create(:project) } let(:issue) { create(:issue, :closed, project: project) } describe '#execute' do diff --git a/spec/services/issues/update_service_spec.rb b/spec/services/issues/update_service_spec.rb index eec2096fa34..814e2cfbed0 100644 --- a/spec/services/issues/update_service_spec.rb +++ b/spec/services/issues/update_service_spec.rb @@ -1,13 +1,11 @@ # coding: utf-8 require 'spec_helper' -describe Issues::UpdateService do - include EmailHelpers - +describe Issues::UpdateService, :mailer do let(:user) { create(:user) } let(:user2) { create(:user) } let(:user3) { create(:user) } - let(:project) { create(:empty_project) } + let(:project) { create(:project) } let(:label) { create(:label, project: project) } let(:label2) { create(:label) } diff --git a/spec/services/labels/create_service_spec.rb b/spec/services/labels/create_service_spec.rb index ecb88653001..438e6dbc628 100644 --- a/spec/services/labels/create_service_spec.rb +++ b/spec/services/labels/create_service_spec.rb @@ -4,7 +4,7 @@ describe Labels::CreateService do describe '#execute' do let(:project) { create(:project) } let(:group) { create(:group) } - + let(:hex_color) { '#FF0000' } let(:named_color) { 'red' } let(:upcase_color) { 'RED' } diff --git a/spec/services/labels/find_or_create_service_spec.rb b/spec/services/labels/find_or_create_service_spec.rb index 2d3a15a1c11..a781fbc7f7d 100644 --- a/spec/services/labels/find_or_create_service_spec.rb +++ b/spec/services/labels/find_or_create_service_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe Labels::FindOrCreateService do describe '#execute' do let(:group) { create(:group) } - let(:project) { create(:empty_project, namespace: group) } + let(:project) { create(:project, namespace: group) } let(:params) do { diff --git a/spec/services/labels/promote_service_spec.rb b/spec/services/labels/promote_service_spec.rb index 7cea877ad88..8809b282127 100644 --- a/spec/services/labels/promote_service_spec.rb +++ b/spec/services/labels/promote_service_spec.rb @@ -5,7 +5,7 @@ describe Labels::PromoteService do let!(:user) { create(:user) } context 'project without group' do - let!(:project_1) { create(:empty_project) } + let!(:project_1) { create(:project) } let!(:project_label_1_1) { create(:label, project: project_1) } @@ -27,10 +27,10 @@ describe Labels::PromoteService do let!(:group_1) { create(:group) } let!(:group_2) { create(:group) } - let!(:project_1) { create(:empty_project, namespace: group_1) } - let!(:project_2) { create(:empty_project, namespace: group_1) } - let!(:project_3) { create(:empty_project, namespace: group_1) } - let!(:project_4) { create(:empty_project, namespace: group_2) } + let!(:project_1) { create(:project, namespace: group_1) } + let!(:project_2) { create(:project, namespace: group_1) } + let!(:project_3) { create(:project, namespace: group_1) } + let!(:project_4) { create(:project, namespace: group_2) } # Labels/issues can't be lazily created so we might as well eager initialize # all other objects too since we use them inside diff --git a/spec/services/labels/transfer_service_spec.rb b/spec/services/labels/transfer_service_spec.rb index f70edd3d16e..ae819c011de 100644 --- a/spec/services/labels/transfer_service_spec.rb +++ b/spec/services/labels/transfer_service_spec.rb @@ -6,8 +6,8 @@ describe Labels::TransferService do let(:group_1) { create(:group) } let(:group_2) { create(:group) } let(:group_3) { create(:group) } - let(:project_1) { create(:empty_project, namespace: group_2) } - let(:project_2) { create(:empty_project, namespace: group_3) } + let(:project_1) { create(:project, namespace: group_2) } + let(:project_2) { create(:project, namespace: group_3) } let(:group_label_1) { create(:group_label, group: group_1, name: 'Group Label 1') } let(:group_label_2) { create(:group_label, group: group_1, name: 'Group Label 2') } diff --git a/spec/services/members/approve_access_request_service_spec.rb b/spec/services/members/approve_access_request_service_spec.rb index ddba96b8d03..302c488d6c6 100644 --- a/spec/services/members/approve_access_request_service_spec.rb +++ b/spec/services/members/approve_access_request_service_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe Members::ApproveAccessRequestService do let(:user) { create(:user) } let(:access_requester) { create(:user) } - let(:project) { create(:empty_project, :public, :access_requestable) } + let(:project) { create(:project, :public, :access_requestable) } let(:group) { create(:group, :public, :access_requestable) } let(:opts) { {} } diff --git a/spec/services/members/authorized_destroy_service_spec.rb b/spec/services/members/authorized_destroy_service_spec.rb index f0abbc46ca3..2d04d824180 100644 --- a/spec/services/members/authorized_destroy_service_spec.rb +++ b/spec/services/members/authorized_destroy_service_spec.rb @@ -2,9 +2,9 @@ require 'spec_helper' describe Members::AuthorizedDestroyService do let(:member_user) { create(:user) } - let(:project) { create(:empty_project, :public) } + let(:project) { create(:project, :public) } let(:group) { create(:group, :public) } - let(:group_project) { create(:empty_project, :public, group: group) } + let(:group_project) { create(:project, :public, group: group) } def number_of_assigned_issuables(user) Issue.assigned_to(user).count + MergeRequest.assigned_to(user).count diff --git a/spec/services/members/create_service_spec.rb b/spec/services/members/create_service_spec.rb index c73a229823d..2a793e0eb4d 100644 --- a/spec/services/members/create_service_spec.rb +++ b/spec/services/members/create_service_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe Members::CreateService do - let(:project) { create(:empty_project) } + let(:project) { create(: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 0e30b343eaf..72f5e27180d 100644 --- a/spec/services/members/destroy_service_spec.rb +++ b/spec/services/members/destroy_service_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe Members::DestroyService do let(:user) { create(:user) } let(:member_user) { create(:user) } - let(:project) { create(:empty_project, :public) } + let(:project) { create(:project, :public) } let(:group) { create(:group, :public) } shared_examples 'a service raising ActiveRecord::RecordNotFound' do diff --git a/spec/services/members/request_access_service_spec.rb b/spec/services/members/request_access_service_spec.rb index f39d4f47904..0a704bba521 100644 --- a/spec/services/members/request_access_service_spec.rb +++ b/spec/services/members/request_access_service_spec.rb @@ -29,7 +29,7 @@ describe Members::RequestAccessService do end context 'when current user cannot request access to the project' do - %i[empty_project group].each do |source_type| + %i[project group].each do |source_type| it_behaves_like 'a service raising Gitlab::Access::AccessDeniedError' do let(:source) { create(source_type, :private) } end @@ -37,7 +37,7 @@ describe Members::RequestAccessService do end context 'when access requests are disabled' do - %i[empty_project group].each do |source_type| + %i[project group].each do |source_type| it_behaves_like 'a service raising Gitlab::Access::AccessDeniedError' do let(:source) { create(source_type, :public) } end @@ -45,7 +45,7 @@ describe Members::RequestAccessService do end context 'when current user can request access to the project' do - %i[empty_project group].each do |source_type| + %i[project group].each do |source_type| it_behaves_like 'a service creating a access request' do let(:source) { create(source_type, :public, :access_requestable) } end diff --git a/spec/services/merge_requests/build_service_spec.rb b/spec/services/merge_requests/build_service_spec.rb index ea192e51f89..b46c419de14 100644 --- a/spec/services/merge_requests/build_service_spec.rb +++ b/spec/services/merge_requests/build_service_spec.rb @@ -264,8 +264,8 @@ describe MergeRequests::BuildService do end context 'upstream project has disabled merge requests' do - let(:upstream_project) { create(:empty_project, :merge_requests_disabled) } - let(:project) { create(:empty_project, forked_from_project: upstream_project) } + let(:upstream_project) { create(:project, :merge_requests_disabled) } + let(:project) { create(:project, forked_from_project: upstream_project) } let(:commits) { Commit.decorate([commit_1], project) } it 'sets target project correctly' do diff --git a/spec/services/merge_requests/update_service_spec.rb b/spec/services/merge_requests/update_service_spec.rb index dd3ac9c4ac6..9368594bc86 100644 --- a/spec/services/merge_requests/update_service_spec.rb +++ b/spec/services/merge_requests/update_service_spec.rb @@ -1,8 +1,6 @@ require 'spec_helper' -describe MergeRequests::UpdateService do - include EmailHelpers - +describe MergeRequests::UpdateService, :mailer do let(:project) { create(:project, :repository) } let(:user) { create(:user) } let(:user2) { create(:user) } diff --git a/spec/services/milestones/close_service_spec.rb b/spec/services/milestones/close_service_spec.rb index fa0686d8061..2bdf224804d 100644 --- a/spec/services/milestones/close_service_spec.rb +++ b/spec/services/milestones/close_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe Milestones::CloseService do let(:user) { create(:user) } - let(:project) { create(:empty_project) } + let(:project) { create(:project) } let(:milestone) { create(:milestone, title: "Milestone v1.2", project: project) } before do diff --git a/spec/services/milestones/create_service_spec.rb b/spec/services/milestones/create_service_spec.rb index c6fe8e65912..8837b91051d 100644 --- a/spec/services/milestones/create_service_spec.rb +++ b/spec/services/milestones/create_service_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe Milestones::CreateService do - let(:project) { create(:empty_project) } + let(:project) { create(:project) } let(:user) { create(:user) } describe '#execute' do diff --git a/spec/services/note_summary_spec.rb b/spec/services/note_summary_spec.rb index dda579c7080..a6cc2251e48 100644 --- a/spec/services/note_summary_spec.rb +++ b/spec/services/note_summary_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe NoteSummary do - let(:project) { build(:empty_project) } + let(:project) { build(:project) } let(:noteable) { build(:issue) } let(:user) { build(:user) } diff --git a/spec/services/notes/create_service_spec.rb b/spec/services/notes/create_service_spec.rb index c08a5a940bb..661d26946e7 100644 --- a/spec/services/notes/create_service_spec.rb +++ b/spec/services/notes/create_service_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe Notes::CreateService do - let(:project) { create(:empty_project) } + let(:project) { create(:project) } let(:issue) { create(:issue, project: project) } let(:user) { create(:user) } let(:opts) do diff --git a/spec/services/notes/destroy_service_spec.rb b/spec/services/notes/destroy_service_spec.rb index 4330190caaa..c9a99a43edb 100644 --- a/spec/services/notes/destroy_service_spec.rb +++ b/spec/services/notes/destroy_service_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe Notes::DestroyService do describe '#execute' do it 'deletes a note' do - project = create(:empty_project) + project = create(:project) issue = create(:issue, project: project) note = create(:note, project: project, noteable: issue) diff --git a/spec/services/notes/post_process_service_spec.rb b/spec/services/notes/post_process_service_spec.rb index bf9320e5fce..a2b3638059f 100644 --- a/spec/services/notes/post_process_service_spec.rb +++ b/spec/services/notes/post_process_service_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe Notes::PostProcessService do - let(:project) { create(:empty_project) } + let(:project) { create(:project) } let(:issue) { create(:issue, project: project) } let(:user) { create(:user) } diff --git a/spec/services/notes/quick_actions_service_spec.rb b/spec/services/notes/quick_actions_service_spec.rb index fc4cd3dc2b7..0280a19098b 100644 --- a/spec/services/notes/quick_actions_service_spec.rb +++ b/spec/services/notes/quick_actions_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe Notes::QuickActionsService do shared_context 'note on noteable' do - let(:project) { create(:empty_project) } + let(:project) { create(:project) } let(:master) { create(:user).tap { |u| project.team << [u, :master] } } let(:assignee) { create(:user) } @@ -225,7 +225,7 @@ describe Notes::QuickActionsService do context 'CE restriction for issue assignees' do describe '/assign' do - let(:project) { create(:empty_project) } + let(:project) { create(:project) } let(:master) { create(:user).tap { |u| project.team << [u, :master] } } let(:assignee) { create(:user) } let(:master) { create(:user) } diff --git a/spec/services/notes/update_service_spec.rb b/spec/services/notes/update_service_spec.rb index dea2dc02d00..3210539f3ee 100644 --- a/spec/services/notes/update_service_spec.rb +++ b/spec/services/notes/update_service_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe Notes::UpdateService do - let(:project) { create(:empty_project) } + let(:project) { create(:project) } let(:user) { create(:user) } let(:user2) { create(:user) } let(:user3) { create(:user) } diff --git a/spec/services/notification_recipient_service_spec.rb b/spec/services/notification_recipient_service_spec.rb deleted file mode 100644 index 77233dc1b2f..00000000000 --- a/spec/services/notification_recipient_service_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -require 'spec_helper' - -describe NotificationRecipientService do - set(:user) { create(:user) } - set(:project) { create(:empty_project, :public) } - set(:issue) { create(:issue, project: project) } - - set(:watcher) do - watcher = create(:user) - setting = watcher.notification_settings_for(project) - setting.level = :watch - setting.save - - watcher - end - - subject { described_class.new(project) } - - describe '#build_recipients' do - it 'does not modify the participants of the target' do - expect { subject.build_recipients(issue, user, action: :new_issue) } - .not_to change { issue.participants(user) } - end - end - - describe '#build_new_note_recipients' do - set(:note) { create(:note_on_issue, noteable: issue, project: project) } - - it 'does not modify the participants of the target' do - expect { subject.build_new_note_recipients(note) } - .not_to change { note.noteable.participants(note.author) } - end - end -end diff --git a/spec/services/notification_service_spec.rb b/spec/services/notification_service_spec.rb index 5b69426cbaa..6af5c79135d 100644 --- a/spec/services/notification_service_spec.rb +++ b/spec/services/notification_service_spec.rb @@ -1,8 +1,6 @@ require 'spec_helper' -describe NotificationService do - include EmailHelpers - +describe NotificationService, :mailer do let(:notification) { described_class.new } let(:assignee) { create(:user) } @@ -14,7 +12,6 @@ describe NotificationService do shared_examples 'notifications for new mentions' do def send_notifications(*new_mentions) - reset_delivered_emails! notification.send(notification_method, mentionable, new_mentions, @u_disabled) end @@ -119,7 +116,7 @@ describe NotificationService do describe 'Notes' do context 'issue note' do - let(:project) { create(:empty_project, :private) } + let(:project) { create(:project, :private) } let(:issue) { create(:issue, project: project, assignees: [assignee]) } let(:mentioned_issue) { create(:issue, assignees: issue.assignees) } let(:note) { create(:note_on_issue, noteable: issue, project_id: issue.project_id, note: '@mention referenced, @outsider also') } @@ -137,12 +134,11 @@ describe NotificationService do describe '#new_note' do it do add_users_with_subscription(note.project, issue) + reset_delivered_emails! # Ensure create SentNotification by noteable = issue 6 times, not noteable = note expect(SentNotification).to receive(:record).with(issue, any_args).exactly(8).times - reset_delivered_emails! - notification.new_note(note) should_email(@u_watcher) @@ -165,9 +161,10 @@ describe NotificationService do it "emails the note author if they've opted into notifications about their activity" do add_users_with_subscription(note.project, issue) - note.author.notified_of_own_activity = true reset_delivered_emails! + note.author.notified_of_own_activity = true + notification.new_note(note) should_email(note.author) @@ -228,7 +225,7 @@ describe NotificationService do end context 'confidential issue note' do - let(:project) { create(:empty_project, :public) } + let(:project) { create(:project, :public) } let(:author) { create(:user) } let(:assignee) { create(:user) } let(:non_member) { create(:user) } @@ -260,7 +257,7 @@ describe NotificationService do end context 'issue note mention' do - let(:project) { create(:empty_project, :public) } + let(:project) { create(:project, :public) } let(:issue) { create(:issue, project: project, assignees: [assignee]) } let(:mentioned_issue) { create(:issue, assignees: issue.assignees) } let(:note) { create(:note_on_issue, noteable: issue, project_id: issue.project_id, note: '@all mentioned') } @@ -303,12 +300,17 @@ describe NotificationService do end context 'project snippet note' do - let(:project) { create(:empty_project, :public) } + let(:project) { create(:project, :public) } let(:snippet) { create(:project_snippet, project: project, author: create(:user)) } let(:note) { create(:note_on_project_snippet, noteable: snippet, project_id: snippet.project.id, note: '@all mentioned') } before do build_team(note.project) + + # make sure these users can read the project snippet! + project.add_guest(@u_guest_watcher) + project.add_guest(@u_guest_custom) + note.project.add_master(note.author) reset_delivered_emails! end @@ -464,8 +466,8 @@ describe NotificationService do describe 'Issues' do let(:group) { create(:group) } - let(:project) { create(:empty_project, :public, namespace: group) } - let(:another_project) { create(:empty_project, :public, namespace: group) } + let(:project) { create(:project, :public, namespace: group) } + let(:another_project) { create(:project, :public, namespace: group) } let(:issue) { create :issue, project: project, assignees: [assignee], description: 'cc @participant' } before do @@ -855,7 +857,7 @@ describe NotificationService do describe 'Merge Requests' do let(:group) { create(:group) } let(:project) { create(:project, :public, :repository, namespace: group) } - let(:another_project) { create(:empty_project, :public, namespace: group) } + let(:another_project) { create(:project, :public, namespace: group) } let(:merge_request) { create :merge_request, source_project: project, assignee: create(:user), description: 'cc @participant' } before do @@ -1150,7 +1152,7 @@ describe NotificationService do end describe 'Projects' do - let(:project) { create(:empty_project) } + let(:project) { create(:project) } before do build_team(project) @@ -1211,7 +1213,7 @@ describe NotificationService do describe 'ProjectMember' do describe '#decline_group_invite' do - let(:project) { create(:empty_project) } + let(:project) { create(:project) } let(:member) { create(:user) } before(:each) do @@ -1229,7 +1231,7 @@ describe NotificationService do end context 'guest user in private project' do - let(:private_project) { create(:empty_project, :private) } + let(:private_project) { create(:project, :private) } let(:guest) { create(:user) } let(:developer) { create(:user) } let(:assignee) { create(:user) } diff --git a/spec/services/preview_markdown_service_spec.rb b/spec/services/preview_markdown_service_spec.rb index 4fd9cb23ae1..64a9559791f 100644 --- a/spec/services/preview_markdown_service_spec.rb +++ b/spec/services/preview_markdown_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe PreviewMarkdownService do let(:user) { create(:user) } - let(:project) { create(:empty_project) } + let(:project) { create(:project) } before do project.add_developer(user) diff --git a/spec/services/projects/autocomplete_service_spec.rb b/spec/services/projects/autocomplete_service_spec.rb index fc7238862ab..c1f098530bf 100644 --- a/spec/services/projects/autocomplete_service_spec.rb +++ b/spec/services/projects/autocomplete_service_spec.rb @@ -8,7 +8,7 @@ describe Projects::AutocompleteService do let(:non_member) { create(:user) } let(:member) { create(:user) } let(:admin) { create(:admin) } - let(:project) { create(:empty_project, :public) } + let(:project) { create(:project, :public) } let!(:issue) { create(:issue, project: project, title: 'Issue 1') } let!(:security_issue_1) { create(:issue, :confidential, project: project, title: 'Security issue 1', author: author) } let!(:security_issue_2) { create(:issue, :confidential, title: 'Security issue 2', project: project, assignees: [assignee]) } diff --git a/spec/services/projects/download_service_spec.rb b/spec/services/projects/download_service_spec.rb index 701f6cc8c6a..da236052ebf 100644 --- a/spec/services/projects/download_service_spec.rb +++ b/spec/services/projects/download_service_spec.rb @@ -4,7 +4,7 @@ describe Projects::DownloadService do describe 'File service' do before do @user = create(:user) - @project = create(:empty_project, creator_id: @user.id, namespace: @user.namespace) + @project = create(:project, creator_id: @user.id, namespace: @user.namespace) end context 'for a URL that is not on whitelist' do diff --git a/spec/services/projects/enable_deploy_key_service_spec.rb b/spec/services/projects/enable_deploy_key_service_spec.rb index 9b8c24ba112..835dae68fcd 100644 --- a/spec/services/projects/enable_deploy_key_service_spec.rb +++ b/spec/services/projects/enable_deploy_key_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe Projects::EnableDeployKeyService do let(:deploy_key) { create(:deploy_key, public: true) } - let(:project) { create(:empty_project) } + let(:project) { create(:project) } let(:user) { project.creator} let!(:params) { { key_id: deploy_key.id } } diff --git a/spec/services/projects/import_service_spec.rb b/spec/services/projects/import_service_spec.rb index c2a6cafa4c8..c0ab1ea704d 100644 --- a/spec/services/projects/import_service_spec.rb +++ b/spec/services/projects/import_service_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe Projects::ImportService do - let!(:project) { create(:empty_project) } + let!(:project) { create(:project) } let(:user) { project.creator } subject { described_class.new(project, user) } diff --git a/spec/services/projects/participants_service_spec.rb b/spec/services/projects/participants_service_spec.rb index 8777e63a101..0d18ceb8ff8 100644 --- a/spec/services/projects/participants_service_spec.rb +++ b/spec/services/projects/participants_service_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe Projects::ParticipantsService do describe '#groups' do describe 'avatar_url' do - let(:project) { create(:empty_project, :public) } + let(:project) { create(:project, :public) } let(:group) { create(:group, avatar: fixture_file_upload(Rails.root + 'spec/fixtures/dk.png')) } let(:user) { create(:user) } let!(:group_member) { create(:group_member, group: group, user: user) } diff --git a/spec/services/projects/propagate_service_template_spec.rb b/spec/services/projects/propagate_service_template_spec.rb index 2763437f184..f4c59735c43 100644 --- a/spec/services/projects/propagate_service_template_spec.rb +++ b/spec/services/projects/propagate_service_template_spec.rb @@ -15,7 +15,7 @@ describe Projects::PropagateServiceTemplate do }) end - let!(:project) { create(:empty_project) } + let!(:project) { create(:project) } it 'creates services for projects' do expect(project.pushover_service).to be_nil @@ -76,7 +76,7 @@ describe Projects::PropagateServiceTemplate do before do stub_const 'Projects::PropagateServiceTemplate::BATCH_SIZE', 3 - project_total.times { create(:empty_project) } + project_total.times { create(:project) } described_class.propagate(service_template) end diff --git a/spec/services/projects/update_pages_configuration_service_spec.rb b/spec/services/projects/update_pages_configuration_service_spec.rb index 42925e73978..e4d4e6ff3dd 100644 --- a/spec/services/projects/update_pages_configuration_service_spec.rb +++ b/spec/services/projects/update_pages_configuration_service_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe Projects::UpdatePagesConfigurationService do - let(:project) { create(:empty_project) } + let(:project) { create(:project) } subject { described_class.new(project) } describe "#update" do diff --git a/spec/services/projects/update_service_spec.rb b/spec/services/projects/update_service_spec.rb index d7b0df9a671..d945e0aa1f0 100644 --- a/spec/services/projects/update_service_spec.rb +++ b/spec/services/projects/update_service_spec.rb @@ -5,7 +5,7 @@ describe Projects::UpdateService, '#execute' do let(:admin) { create(:admin) } let(:project) do - create(:empty_project, creator: user, namespace: user.namespace) + create(:project, creator: user, namespace: user.namespace) end context 'when changing visibility level' do @@ -59,7 +59,7 @@ describe Projects::UpdateService, '#execute' do end describe 'when updating project that has forks' do - let(:project) { create(:empty_project, :internal) } + let(:project) { create(:project, :internal) } let(:forked_project) { create(:forked_project_with_submodules, :internal) } before do diff --git a/spec/services/protected_branches/create_service_spec.rb b/spec/services/protected_branches/create_service_spec.rb index 592f9b5929e..835e83d6dba 100644 --- a/spec/services/protected_branches/create_service_spec.rb +++ b/spec/services/protected_branches/create_service_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe ProtectedBranches::CreateService do - let(:project) { create(:empty_project) } + let(:project) { create(:project) } let(:user) { project.owner } let(:params) do { diff --git a/spec/services/protected_tags/create_service_spec.rb b/spec/services/protected_tags/create_service_spec.rb index 3a3cc9c1573..c3ed95aaebf 100644 --- a/spec/services/protected_tags/create_service_spec.rb +++ b/spec/services/protected_tags/create_service_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe ProtectedTags::CreateService do - let(:project) { create(:empty_project) } + let(:project) { create(:project) } let(:user) { project.owner } let(:params) do { diff --git a/spec/services/quick_actions/interpret_service_spec.rb b/spec/services/quick_actions/interpret_service_spec.rb index 92bde2c92bf..b78ecfb61c4 100644 --- a/spec/services/quick_actions/interpret_service_spec.rb +++ b/spec/services/quick_actions/interpret_service_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe QuickActions::InterpretService do - let(:project) { create(:empty_project, :public) } + let(:project) { create(:project, :public) } let(:developer) { create(:user) } let(:developer2) { create(:user) } let(:issue) { create(:issue, project: project) } @@ -683,7 +683,7 @@ describe QuickActions::InterpretService do context 'cross project references' do it_behaves_like 'duplicate command' do - let(:other_project) { create(:empty_project, :public) } + let(:other_project) { create(:project, :public) } let(:issue_duplicate) { create(:issue, project: other_project) } let(:content) { "/duplicate #{issue_duplicate.to_reference(project)}" } let(:issuable) { issue } @@ -695,7 +695,7 @@ describe QuickActions::InterpretService do end it_behaves_like 'empty command' do - let(:other_project) { create(:empty_project, :private) } + let(:other_project) { create(:project, :private) } let(:issue_duplicate) { create(:issue, project: other_project) } let(:content) { "/duplicate #{issue_duplicate.to_reference(project)}" } diff --git a/spec/services/search/global_service_spec.rb b/spec/services/search/global_service_spec.rb index de921573b1a..1309240b430 100644 --- a/spec/services/search/global_service_spec.rb +++ b/spec/services/search/global_service_spec.rb @@ -4,10 +4,10 @@ describe Search::GlobalService do let(:user) { create(:user) } let(:internal_user) { create(:user) } - let!(:found_project) { create(:empty_project, :private, name: 'searchable_project') } - let!(:unfound_project) { create(:empty_project, :private, name: 'unfound_project') } - let!(:internal_project) { create(:empty_project, :internal, name: 'searchable_internal_project') } - let!(:public_project) { create(:empty_project, :public, name: 'searchable_public_project') } + let!(:found_project) { create(:project, :private, name: 'searchable_project') } + let!(:unfound_project) { create(:project, :private, name: 'unfound_project') } + let!(:internal_project) { create(:project, :internal, name: 'searchable_internal_project') } + let!(:public_project) { create(:project, :public, name: 'searchable_public_project') } before do found_project.add_master(user) diff --git a/spec/services/search/group_service_spec.rb b/spec/services/search/group_service_spec.rb index cb3f02d2883..cbc553a60cf 100644 --- a/spec/services/search/group_service_spec.rb +++ b/spec/services/search/group_service_spec.rb @@ -8,14 +8,14 @@ describe Search::GroupService do let(:nested_group) { create(:group, :nested) } # These projects shouldn't be found - let!(:outside_project) { create(:empty_project, :public, name: "Outside #{term}") } - let!(:private_project) { create(:empty_project, :private, namespace: nested_group, name: "Private #{term}" )} - let!(:other_project) { create(:empty_project, :public, namespace: nested_group, name: term.reverse) } + let!(:outside_project) { create(:project, :public, name: "Outside #{term}") } + let!(:private_project) { create(:project, :private, namespace: nested_group, name: "Private #{term}" )} + let!(:other_project) { create(:project, :public, namespace: nested_group, name: term.reverse) } # These projects should be found - let!(:project1) { create(:empty_project, :internal, namespace: nested_group, name: "Inner #{term} 1") } - 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!(:project1) { create(:project, :internal, namespace: nested_group, name: "Inner #{term} 1") } + let!(:project2) { create(:project, :internal, namespace: nested_group, name: "Inner #{term} 2") } + let!(:project3) { create(:project, :internal, namespace: nested_group.parent, name: "Outer #{term}") } let(:results) { described_class.new(user, search_group, search: term).execute } subject { results.objects('projects') } diff --git a/spec/services/search/snippet_service_spec.rb b/spec/services/search/snippet_service_spec.rb index 69438a3fa36..eae9bd4f5cf 100644 --- a/spec/services/search/snippet_service_spec.rb +++ b/spec/services/search/snippet_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe Search::SnippetService do let(:author) { create(:author) } - let(:project) { create(:empty_project) } + let(:project) { create(:project) } let!(:public_snippet) { create(:snippet, :public, content: 'password: XXX') } let!(:internal_snippet) { create(:snippet, :internal, content: 'password: XXX') } diff --git a/spec/services/search_service_spec.rb b/spec/services/search_service_spec.rb index a6ef7561bc8..02de83a2df8 100644 --- a/spec/services/search_service_spec.rb +++ b/spec/services/search_service_spec.rb @@ -7,13 +7,13 @@ describe SearchService do let(:inaccessible_group) { create(:group, :private) } let!(:group_member) { create(:group_member, group: accessible_group, user: user) } - let!(:accessible_project) { create(:empty_project, :private, name: 'accessible_project') } - let!(:inaccessible_project) { create(:empty_project, :private, name: 'inaccessible_project') } + let!(:accessible_project) { create(:project, :private, name: 'accessible_project') } + let!(:inaccessible_project) { create(:project, :private, name: 'inaccessible_project') } let(:note) { create(:note_on_issue, project: accessible_project) } let(:snippet) { create(:snippet, author: user) } - let(:group_project) { create(:empty_project, group: accessible_group, name: 'group_project') } - let(:public_project) { create(:empty_project, :public, name: 'public_project') } + let(:group_project) { create(:project, group: accessible_group, name: 'group_project') } + let(:public_project) { create(:project, :public, name: 'public_project') } before do accessible_project.add_master(user) @@ -28,7 +28,7 @@ describe SearchService do end it 'returns the project for guests' do - search_project = create :empty_project + search_project = create :project search_project.add_guest(user) project = described_class.new(user, project_id: search_project.id).project diff --git a/spec/services/spam_service_spec.rb b/spec/services/spam_service_spec.rb index 46349c3e951..a14dfa3f01f 100644 --- a/spec/services/spam_service_spec.rb +++ b/spec/services/spam_service_spec.rb @@ -15,7 +15,7 @@ describe SpamService do end context 'when recaptcha was not verified' do - let(:project) { create(:empty_project, :public) } + let(:project) { create(:project, :public) } let(:issue) { create(:issue, project: project) } let(:request) { double(:request, env: {}) } diff --git a/spec/services/system_hooks_service_spec.rb b/spec/services/system_hooks_service_spec.rb index b2d9862e71e..8b5d9187785 100644 --- a/spec/services/system_hooks_service_spec.rb +++ b/spec/services/system_hooks_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe SystemHooksService do let(:user) { create(:user) } - let(:project) { create(:empty_project) } + let(:project) { create(:project) } let(:project_member) { create(:project_member) } let(:key) { create(:key, user: user) } let(:deploy_key) { create(:key) } diff --git a/spec/services/system_note_service_spec.rb b/spec/services/system_note_service_spec.rb index 5c20263a532..e3805160b04 100644 --- a/spec/services/system_note_service_spec.rb +++ b/spec/services/system_note_service_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe SystemNoteService do include Gitlab::Routing - let(:project) { create(:empty_project) } + let(:project) { create(:project) } let(:author) { create(:user) } let(:noteable) { create(:issue, project: project) } let(:issue) { noteable } @@ -648,7 +648,7 @@ describe SystemNoteService do end describe '.noteable_moved' do - let(:new_project) { create(:empty_project) } + let(:new_project) { create(:project) } let(:new_noteable) { create(:issue, project: new_project) } subject do @@ -718,7 +718,7 @@ describe SystemNoteService do describe 'JIRA integration' do include JiraServiceHelper - let(:project) { create(:jira_project) } + let(:project) { create(:jira_project, :repository) } let(:author) { create(:user) } let(:issue) { create(:issue, project: project) } let(:merge_request) { create(:merge_request, :simple, target_project: project, source_project: project) } @@ -1116,7 +1116,7 @@ describe SystemNoteService do end context 'across different projects' do - let(:other_project) { create(:empty_project) } + let(:other_project) { create(:project) } let(:canonical_issue) { create(:issue, project: other_project) } it_behaves_like 'a system note' do @@ -1141,7 +1141,7 @@ describe SystemNoteService do end context 'across different projects' do - let(:other_project) { create(:empty_project) } + let(:other_project) { create(:project) } let(:duplicate_issue) { create(:issue, project: other_project) } it_behaves_like 'a system note' do diff --git a/spec/services/todo_service_spec.rb b/spec/services/todo_service_spec.rb index 230e40de9e0..80d05451e09 100644 --- a/spec/services/todo_service_spec.rb +++ b/spec/services/todo_service_spec.rb @@ -10,7 +10,7 @@ describe TodoService do let(:john_doe) { create(:user) } let(:skipped) { create(:user) } let(:skip_users) { [skipped] } - let(:project) { create(:empty_project) } + let(:project) { create(:project) } let(:mentions) { 'FYI: ' + [author, assignee, john_doe, member, guest, non_member, admin, skipped].map(&:to_reference).join(' ') } let(:directly_addressed) { [author, assignee, john_doe, member, guest, non_member, admin, skipped].map(&:to_reference).join(' ') } let(:directly_addressed_and_mentioned) { member.to_reference + ", what do you think? cc: " + [guest, admin, skipped].map(&:to_reference).join(' ') } @@ -103,7 +103,7 @@ describe TodoService do context 'when a private group is mentioned' do let(:group) { create(:group, :private) } - let(:project) { create(:empty_project, :private, group: group) } + let(:project) { create(:project, :private, group: group) } let(:issue) { create(:issue, author: author, project: project, description: group.to_reference) } before do @@ -336,7 +336,7 @@ describe TodoService do describe '#mark_todos_as_done' do it_behaves_like 'updating todos state', :mark_todos_as_done, :pending, :done do - let(:collection) { [first_todo, second_todo] } + let(:collection) { Todo.all } end end @@ -348,7 +348,7 @@ describe TodoService do describe '#mark_todos_as_pending' do it_behaves_like 'updating todos state', :mark_todos_as_pending, :done, :pending do - let(:collection) { [first_todo, second_todo] } + let(:collection) { Todo.all } end end @@ -880,14 +880,16 @@ describe TodoService do it 'marks an array of todos as done' do todo = create(:todo, :mentioned, user: john_doe, target: issue, project: project) - expect { described_class.new.mark_todos_as_done([todo], john_doe) } + todos = TodosFinder.new(john_doe, {}).execute + expect { described_class.new.mark_todos_as_done(todos, 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(described_class.new.mark_todos_as_done([todo], john_doe)).to eq([todo.id]) + todos = TodosFinder.new(john_doe, {}).execute + expect(described_class.new.mark_todos_as_done(todos, john_doe)).to eq([todo.id]) end context 'when some of the todos are done already' do @@ -907,11 +909,32 @@ describe TodoService do expect(described_class.new.mark_todos_as_done(Todo.all, john_doe)).to eq([]) end end + end + + describe '#mark_todos_as_done_by_ids' do + let(:issue) { create(:issue, project: project, author: author, assignees: [john_doe]) } + let(:another_issue) { create(:issue, project: project, author: author, assignees: [john_doe]) } + + it 'marks an array of todo ids as done' do + todo = create(:todo, :mentioned, user: john_doe, target: issue, project: project) + another_todo = create(:todo, :mentioned, user: john_doe, target: another_issue, project: project) + + expect { described_class.new.mark_todos_as_done_by_ids([todo.id, another_todo.id], john_doe) } + .to change { john_doe.todos.done.count }.from(0).to(2) + end + + it 'marks a single todo id as done' do + todo = create(:todo, :mentioned, user: john_doe, target: issue, project: project) + + expect { described_class.new.mark_todos_as_done_by_ids(todo.id, john_doe) } + .to change { todo.reload.state }.from('pending').to('done') + 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) - described_class.new.mark_todos_as_done([todo], john_doe) + + described_class.new.mark_todos_as_done_by_ids(todo, john_doe) expect_any_instance_of(TodosFinder).not_to receive(:execute) diff --git a/spec/services/upload_service_spec.rb b/spec/services/upload_service_spec.rb index cf76a18f171..24f3a5c5ff0 100644 --- a/spec/services/upload_service_spec.rb +++ b/spec/services/upload_service_spec.rb @@ -4,7 +4,7 @@ describe UploadService do describe 'File service' do before do @user = create(:user) - @project = create(:empty_project, creator_id: @user.id, namespace: @user.namespace) + @project = create(:project, creator_id: @user.id, namespace: @user.namespace) end context 'for valid gif file' do diff --git a/spec/services/users/destroy_service_spec.rb b/spec/services/users/destroy_service_spec.rb index 786335120fd..a82567f6f43 100644 --- a/spec/services/users/destroy_service_spec.rb +++ b/spec/services/users/destroy_service_spec.rb @@ -5,7 +5,7 @@ describe Users::DestroyService do let!(:user) { create(:user) } let!(:admin) { create(:admin) } let!(:namespace) { create(:namespace, owner: user) } - let!(:project) { create(:empty_project, namespace: namespace) } + let!(:project) { create(:project, namespace: namespace) } let(:service) { described_class.new(admin) } context 'no options are given' do @@ -66,7 +66,7 @@ describe Users::DestroyService do end context "a deleted user's merge_requests" do - let(:project) { create(:project) } + let(:project) { create(:project, :repository) } before do project.add_developer(user) 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 a0030ce8809..ac3a8738cac 100644 --- a/spec/services/users/migrate_to_ghost_user_service_spec.rb +++ b/spec/services/users/migrate_to_ghost_user_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe Users::MigrateToGhostUserService do let!(:user) { create(:user) } - let!(:project) { create(:project) } + let!(:project) { create(:project, :repository) } let(:service) { described_class.new(user) } context "migrating a user's associated records to the ghost user" do diff --git a/spec/services/users/refresh_authorized_projects_service_spec.rb b/spec/services/users/refresh_authorized_projects_service_spec.rb index 1c0f55d2965..08fd26d67fd 100644 --- a/spec/services/users/refresh_authorized_projects_service_spec.rb +++ b/spec/services/users/refresh_authorized_projects_service_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe Users::RefreshAuthorizedProjectsService do # We're using let! here so that any expectations for the service class are not # triggered twice. - let!(:project) { create(:empty_project) } + let!(:project) { create(:project) } let(:user) { project.namespace.owner } let(:service) { described_class.new(user) } @@ -28,7 +28,7 @@ describe Users::RefreshAuthorizedProjectsService do end it 'updates the authorized projects of the user' do - project2 = create(:empty_project) + project2 = create(:project) to_remove = user.project_authorizations .create!(project: project2, access_level: Gitlab::Access::MASTER) @@ -109,7 +109,7 @@ describe Users::RefreshAuthorizedProjectsService do end context 'projects the user is a member of' do - let!(:other_project) { create(:empty_project) } + let!(:other_project) { create(:project) } before do other_project.team.add_reporter(user) @@ -122,7 +122,7 @@ describe Users::RefreshAuthorizedProjectsService do context 'projects of groups the user is a member of' do let(:group) { create(:group) } - let!(:other_project) { create(:empty_project, group: group) } + let!(:other_project) { create(:project, group: group) } before do group.add_owner(user) @@ -136,7 +136,7 @@ describe Users::RefreshAuthorizedProjectsService do context 'projects of subgroups of groups the user is a member of', :nested_groups do let(:group) { create(:group) } let(:nested_group) { create(:group, parent: group) } - let!(:other_project) { create(:empty_project, group: nested_group) } + let!(:other_project) { create(:project, group: nested_group) } before do group.add_master(user) @@ -149,7 +149,7 @@ describe Users::RefreshAuthorizedProjectsService do context 'projects shared with groups the user is a member of' do let(:group) { create(:group) } - let(:other_project) { create(:empty_project) } + let(:other_project) { create(:project) } let!(:project_group_link) { create(:project_group_link, project: other_project, group: group, group_access: Gitlab::Access::GUEST) } before do @@ -164,7 +164,7 @@ describe Users::RefreshAuthorizedProjectsService do context 'projects shared with subgroups of groups the user is a member of', :nested_groups do let(:group) { create(:group) } let(:nested_group) { create(:group, parent: group) } - let(:other_project) { create(:empty_project) } + let(:other_project) { create(:project) } let!(:project_group_link) { create(:project_group_link, project: other_project, group: nested_group, group_access: Gitlab::Access::DEVELOPER) } before do diff --git a/spec/services/web_hook_service_spec.rb b/spec/services/web_hook_service_spec.rb index e79c12daa1c..79d90defd78 100644 --- a/spec/services/web_hook_service_spec.rb +++ b/spec/services/web_hook_service_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe WebHookService do - let(:project) { create(:empty_project) } + let(:project) { create(:project) } let(:project_hook) { create(:project_hook) } let(:headers) do { @@ -112,6 +112,23 @@ describe WebHookService do end end + context 'with unsafe response body' do + before do + WebMock.stub_request(:post, project_hook.url).to_return(status: 200, body: "\xBB") + service_instance.execute + end + + it 'log successful execution' do + expect(hook_log.trigger).to eq('push_hooks') + expect(hook_log.url).to eq(project_hook.url) + expect(hook_log.request_headers).to eq(headers) + expect(hook_log.response_body).to eq('') + expect(hook_log.response_status).to eq('200') + expect(hook_log.execution_duration).to be > 0 + expect(hook_log.internal_error_message).to be_nil + end + end + context 'should not log ServiceHooks' do let(:service_hook) { create(:service_hook) } let(:service_instance) { described_class.new(service_hook, data, 'service_hook') } diff --git a/spec/services/wiki_pages/create_service_spec.rb b/spec/services/wiki_pages/create_service_spec.rb index fa3863e9b30..b270194d9b8 100644 --- a/spec/services/wiki_pages/create_service_spec.rb +++ b/spec/services/wiki_pages/create_service_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe WikiPages::CreateService do - let(:project) { create(:empty_project) } + let(:project) { create(:project) } let(:user) { create(:user) } let(:opts) do diff --git a/spec/services/wiki_pages/destroy_service_spec.rb b/spec/services/wiki_pages/destroy_service_spec.rb index 1668cd00ca8..2938126914b 100644 --- a/spec/services/wiki_pages/destroy_service_spec.rb +++ b/spec/services/wiki_pages/destroy_service_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe WikiPages::DestroyService do - let(:project) { create(:empty_project) } + let(:project) { create(: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 a672c84034b..a242bf5a5cc 100644 --- a/spec/services/wiki_pages/update_service_spec.rb +++ b/spec/services/wiki_pages/update_service_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe WikiPages::UpdateService do - let(:project) { create(:empty_project) } + let(:project) { create(:project) } let(:user) { create(:user) } let(:page) { create(:wiki_page) } |