BigW Consortium Gitlab

Commit ca9a79f6 by Robert Speicher

Use `:empty_project` where possible in service specs

parent d4c99f64
require 'spec_helper'
describe AfterBranchDeleteService, services: true do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
let(:service) { described_class.new(project, user) }
......
require 'spec_helper'
describe Ci::CreatePipelineService, services: true do
let(:project) { FactoryGirl.create(:project) }
let(:project) { create(:project, :repository) }
let(:user) { create(:admin) }
before do
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe Ci::CreateTriggerRequestService, services: true do
let(:service) { described_class.new }
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:trigger) { create(:ci_trigger, project: project) }
before do
......
require 'spec_helper'
describe Ci::StopEnvironmentsService, services: true do
let(:project) { create(:project, :private) }
let(:project) { create(:project, :private, :repository) }
let(:user) { create(:user) }
let(:service) { described_class.new(project, user) }
......
require 'spec_helper'
describe Ci::UpdateBuildQueueService, :services do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:build) { create(:ci_build, pipeline: pipeline) }
let(:pipeline) { create(:ci_pipeline, project: project) }
......
require 'spec_helper'
describe CompareService, services: true do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
let(:service) { described_class.new(project, 'feature') }
......
require 'spec_helper'
describe CreateReleaseService, services: true do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
let(:tag_name) { project.repository.tag_names.first }
let(:description) { 'Awesome release!' }
......
require 'spec_helper'
describe DeleteBranchService, services: true do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:repository) { project.repository }
let(:user) { create(:user) }
let(:service) { described_class.new(project, user) }
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe DeleteMergedBranchesService, services: true do
subject(:service) { described_class.new(project, project.owner) }
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
context '#execute' do
context 'unprotected branches' do
......
......@@ -3,7 +3,7 @@ require "spec_helper"
describe Files::UpdateService do
subject { described_class.new(project, user, commit_params) }
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
let(:file_path) { 'files/ruby/popen.rb' }
let(:new_contents) { 'New Content' }
......
......@@ -3,8 +3,8 @@ require 'spec_helper'
describe GitHooksService, services: true do
include RepoHelpers
let(:user) { create :user }
let(:project) { create :project }
let(:user) { create(:user) }
let(:project) { create(:project, :repository) }
let(:service) { GitHooksService.new }
before do
......
......@@ -3,8 +3,8 @@ require 'spec_helper'
describe GitPushService, services: true do
include RepoHelpers
let(:user) { create :user }
let(:project) { create :project }
let(:user) { create(:user) }
let(:project) { create(:project, :repository) }
before do
project.team << [user, :master]
......
......@@ -3,8 +3,8 @@ require 'spec_helper'
describe GitTagPushService, services: true do
include RepoHelpers
let(:user) { create :user }
let(:project) { create :project }
let(:user) { create(:user) }
let(:project) { create(:project, :repository) }
let(:service) { GitTagPushService.new(project, user, oldrev: oldrev, newrev: newrev, ref: ref) }
let(:oldrev) { Gitlab::Git::BLANK_SHA }
......
......@@ -6,7 +6,7 @@ describe Groups::DestroyService, services: true do
let!(:user) { create(:user) }
let!(:group) { create(:group) }
let!(:nested_group) { create(:group, parent: group) }
let!(:project) { create(:project, namespace: group) }
let!(:project) { create(:empty_project, namespace: group) }
let!(:gitlab_shell) { Gitlab::Shell.new }
let!(:remove_path) { group.path + "+#{group.id}+deleted" }
......
......@@ -13,7 +13,7 @@ describe Groups::UpdateService, services: true do
before do
public_group.add_user(user, Gitlab::Access::MASTER)
create(:project, :public, group: public_group)
create(:empty_project, :public, group: public_group)
end
it "does not change permission level" do
......@@ -27,7 +27,7 @@ describe Groups::UpdateService, services: true do
before do
internal_group.add_user(user, Gitlab::Access::MASTER)
create(:project, :internal, group: internal_group)
create(:empty_project, :internal, group: internal_group)
end
it "does not change permission level" do
......@@ -55,7 +55,7 @@ describe Groups::UpdateService, services: true do
before do
internal_group.add_user(user, Gitlab::Access::MASTER)
create(:project, :internal, group: internal_group)
create(:empty_project, :internal, group: internal_group)
end
it 'returns true' do
......
require 'spec_helper.rb'
describe Issues::BuildService, services: true do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
before do
......
......@@ -5,8 +5,8 @@ describe Issues::MoveService, services: true do
let(:author) { create(:user) }
let(:title) { 'Some issue' }
let(:description) { 'Some issue description' }
let(:old_project) { create(:project) }
let(:new_project) { create(:project) }
let(:old_project) { create(:empty_project) }
let(:new_project) { create(:empty_project) }
let(:milestone1) { create(:milestone, project_id: old_project.id, title: 'v9.0') }
let(:old_issue) do
......
......@@ -10,7 +10,7 @@ class DummyService < Issues::BaseService
end
describe DummyService, services: true do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
before do
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe Labels::FindOrCreateService, services: true do
describe '#execute' do
let(:group) { create(:group) }
let(:project) { create(:project, namespace: group) }
let(:project) { create(:empty_project, namespace: group) }
let(:params) do
{
......
......@@ -6,8 +6,8 @@ describe Labels::TransferService, services: true do
let(:group_1) { create(:group) }
let(:group_2) { create(:group) }
let(:group_3) { create(:group) }
let(:project_1) { create(:project, namespace: group_2) }
let(:project_2) { create(:project, namespace: group_3) }
let(:project_1) { create(:empty_project, namespace: group_2) }
let(:project_2) { create(:empty_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') }
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe Members::DestroyService, services: true do
let(:user) { create(:user) }
let(:member_user) { create(:user) }
let(:project) { create(:project, :public) }
let(:project) { create(:empty_project, :public) }
let(:group) { create(:group, :public) }
shared_examples 'a service raising ActiveRecord::RecordNotFound' do
......
......@@ -29,7 +29,7 @@ describe Members::RequestAccessService, services: true do
end
context 'when current user cannot request access to the project' do
%i[project group].each do |source_type|
%i[empty_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, services: true do
end
context 'when access requests are disabled' do
%i[project group].each do |source_type|
%i[empty_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, services: true do
end
context 'when current user can request access to the project' do
%i[project group].each do |source_type|
%i[empty_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
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe MergeRequests::AddTodoWhenBuildFailsService do
let(:user) { create(:user) }
let(:merge_request) { create(:merge_request) }
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:sha) { '1234567890abcdef1234567890abcdef12345678' }
let(:ref) { merge_request.source_branch }
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe MergeRequests::AssignIssuesService, services: true do
let(:user) { create(:user) }
let(:project) { create(:project, :public) }
let(:project) { create(:project, :public, :repository) }
let(:issue) { create(:issue, project: project) }
let(:merge_request) { create(:merge_request, :simple, source_project: project, author: user, description: "fixes #{issue.to_reference}") }
let(:service) { described_class.new(project, user, merge_request: merge_request) }
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe MergeRequests::BuildService, services: true do
include RepoHelpers
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
let(:issue_confidential) { false }
let(:issue) { create(:issue, project: project, title: 'A bug', confidential: issue_confidential) }
......
require 'spec_helper'
describe MergeRequests::CreateService, services: true do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
let(:assignee) { create(:user) }
......
require "spec_helper"
describe MergeRequests::GetUrlsService do
let(:project) { create(:project, :public) }
let(:project) { create(:project, :public, :repository) }
let(:service) { MergeRequests::GetUrlsService.new(project) }
let(:source_branch) { "my_branch" }
let(:new_merge_request_url) { "http://#{Gitlab.config.gitlab.host}/#{project.namespace.name}/#{project.path}/merge_requests/new?merge_request%5Bsource_branch%5D=#{source_branch}" }
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe MergeRequests::MergeWhenPipelineSucceedsService do
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:mr_merge_if_green_enabled) do
create(:merge_request, merge_when_pipeline_succeeds: true, merge_user: user,
......
require 'spec_helper'
describe MergeRequests::RefreshService, services: true do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
let(:service) { MergeRequests::RefreshService }
......@@ -11,7 +11,7 @@ describe MergeRequests::RefreshService, services: true do
group = create(:group)
group.add_owner(@user)
@project = create(:project, namespace: group)
@project = create(:project, :repository, namespace: group)
@fork_project = Projects::ForkService.new(@project, @user).execute
@merge_request = create(:merge_request,
source_project: @project,
......@@ -252,7 +252,7 @@ describe MergeRequests::RefreshService, services: true do
context 'when the merge request is sourced from a different project' do
it 'creates a `MergeRequestsClosingIssues` record for each issue closed by a commit' do
forked_project = create(:project)
forked_project = create(:project, :repository)
create(:forked_project_link, forked_to_project: forked_project, forked_from_project: @project)
merge_request = create(:merge_request,
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe MergeRequests::ResolveService do
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:fork_project) do
create(:forked_project_with_submodules) do |fork_project|
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe MergeRequests::UpdateService, services: true do
include EmailHelpers
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
let(:user2) { create(:user) }
let(:user3) { create(:user) }
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe Milestones::CloseService, services: true do
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:project) { create(:empty_project) }
let(:milestone) { create(:milestone, title: "Milestone v1.2", project: project) }
before do
......
require 'spec_helper'
describe Notes::DiffPositionUpdateService, services: true do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:create_commit) { project.commit("913c66a37b4a45b9769037c55c2d238bd0942d2e") }
let(:modify_commit) { project.commit("874797c3a73b60d2187ed6e2fcabd289ff75171e") }
let(:edit_commit) { project.commit("570e7b2abdd848b95f2f578043fc23bd6f6fd24d") }
......
......@@ -372,7 +372,7 @@ describe NotificationService, services: true do
end
context 'commit note' do
let(:project) { create(:project, :public) }
let(:project) { create(:project, :public, :repository) }
let(:note) { create(:note_on_commit, project: project) }
before do
......@@ -421,7 +421,7 @@ describe NotificationService, services: true do
end
context "merge request diff note" do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
let(:merge_request) { create(:merge_request, source_project: project, assignee: user) }
let(:note) { create(:diff_note_on_merge_request, project: project, noteable: merge_request) }
......@@ -849,7 +849,7 @@ describe NotificationService, services: true do
describe 'Merge Requests' do
let(:group) { create(:group) }
let(:project) { create(:project, :public, namespace: group) }
let(:project) { create(:project, :public, :repository, namespace: group) }
let(:another_project) { create(:empty_project, :public, namespace: group) }
let(:merge_request) { create :merge_request, source_project: project, assignee: create(:user), description: 'cc @participant' }
......@@ -1161,7 +1161,7 @@ describe NotificationService, services: true do
end
describe 'Projects' do
let(:project) { create :project }
let(:project) { create(:empty_project) }
before do
build_team(project)
......@@ -1206,7 +1206,7 @@ describe NotificationService, services: true do
describe 'ProjectMember' do
describe '#decline_group_invite' do
let(:project) { create(:project) }
let(:project) { create(:empty_project) }
let(:member) { create(:user) }
before(:each) do
......@@ -1280,7 +1280,7 @@ describe NotificationService, services: true do
describe 'Pipelines' do
describe '#pipeline_finished' do
let(:project) { create(:project, :public) }
let(:project) { create(:project, :public, :repository) }
let(:current_user) { create(:user) }
let(:u_member) { create(:user) }
let(:u_other) { create(:user) }
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe Projects::DestroyService, services: true do
let!(:user) { create(:user) }
let!(:project) { create(:project, namespace: user.namespace) }
let!(:project) { create(:project, :repository, namespace: user.namespace) }
let!(:path) { project.repository.path_to_repo }
let!(:remove_path) { path.sub(/\.git\Z/, "+#{project.id}+deleted.git") }
let!(:async) { false } # execute or async_execute
......
......@@ -3,8 +3,8 @@ require 'spec_helper'
describe Projects::DownloadService, services: true do
describe 'File service' do
before do
@user = create :user
@project = create :project, creator_id: @user.id, namespace: @user.namespace
@user = create(:user)
@project = create(:empty_project, creator_id: @user.id, namespace: @user.namespace)
end
context 'for a URL that is not on whitelist' do
......
......@@ -7,6 +7,7 @@ describe Projects::ForkService, services: true do
@from_user = create(:user, namespace: @from_namespace )
avatar = fixture_file_upload(Rails.root + "spec/fixtures/dk.png", "image/png")
@from_project = create(:project,
:repository,
creator_id: @from_user.id,
namespace: @from_namespace,
star_count: 107,
......@@ -54,7 +55,7 @@ describe Projects::ForkService, services: true do
context 'project already exists' do
it "fails due to validation, not transaction failure" do
@existing_project = create(:project, creator_id: @to_user.id, name: @from_project.name, namespace: @to_namespace)
@existing_project = create(:project, :repository, creator_id: @to_user.id, name: @from_project.name, namespace: @to_namespace)
@to_project = fork_project(@from_project, @to_user)
expect(@existing_project).to be_persisted
......@@ -104,9 +105,10 @@ describe Projects::ForkService, services: true do
before do
@group_owner = create(:user)
@developer = create(:user)
@project = create(:project, creator_id: @group_owner.id,
star_count: 777,
description: 'Wow, such a cool project!')
@project = create(:project, :repository,
creator_id: @group_owner.id,
star_count: 777,
description: 'Wow, such a cool project!')
@group = create(:group)
@group.add_user(@group_owner, GroupMember::OWNER)
@group.add_user(@developer, GroupMember::DEVELOPER)
......@@ -139,8 +141,9 @@ describe Projects::ForkService, services: true do
context 'project already exists in group' do
it 'fails due to validation, not transaction failure' do
existing_project = create(:project, name: @project.name,
namespace: @group)
existing_project = create(:project, :repository,
name: @project.name,
namespace: @group)
to_project = fork_project(@project, @group_owner, @opts)
expect(existing_project.persisted?).to be_truthy
expect(to_project.errors[:name]).to eq(['has already been taken'])
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe Projects::HousekeepingService do
subject { Projects::HousekeepingService.new(project) }
let(:project) { create :project }
let(:project) { create(:project, :repository) }
before do
project.reset_pushes_since_gc
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe Projects::TransferService, services: true do
let(:user) { create(:user) }
let(:group) { create(:group) }
let(:project) { create(:project, namespace: user.namespace) }
let(:project) { create(:project, :repository, namespace: user.namespace) }
context 'namespace -> namespace' do
before do
......@@ -58,7 +58,7 @@ describe Projects::TransferService, services: true do
before { internal_group.add_owner(user) }
context 'when namespace visibility level < project visibility level' do
let(:public_project) { create(:project, :public, namespace: user.namespace) }
let(:public_project) { create(:project, :public, :repository, namespace: user.namespace) }
before { transfer_project(public_project, user, internal_group) }
......@@ -66,7 +66,7 @@ describe Projects::TransferService, services: true do
end
context 'when namespace visibility level > project visibility level' do
let(:private_project) { create(:project, :private, namespace: user.namespace) }
let(:private_project) { create(:project, :private, :repository, namespace: user.namespace) }
before { transfer_project(private_project, user, internal_group) }
......
require "spec_helper"
describe Projects::UpdatePagesService do
let(:project) { create :project }
let(:pipeline) { create :ci_pipeline, project: project, sha: project.commit('HEAD').sha }
let(:build) { create :ci_build, pipeline: pipeline, ref: 'HEAD' }
let(:project) { create(:project, :repository) }
let(:pipeline) { create(:ci_pipeline, project: project, sha: project.commit('HEAD').sha) }
let(:build) { create(:ci_build, pipeline: pipeline, ref: 'HEAD') }
let(:invalid_file) { fixture_file_upload(Rails.root + 'spec/fixtures/dk.png') }
subject { described_class.new(project, build) }
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe Projects::UpdateService, services: true do
let(:user) { create(:user) }
let(:admin) { create(:admin) }
let(:project) { create(:project, creator_id: user.id, namespace: user.namespace) }
let(:project) { create(:empty_project, creator_id: user.id, namespace: user.namespace) }
describe 'update_by_user' do
context 'when visibility_level is INTERNAL' do
......@@ -56,7 +56,7 @@ describe Projects::UpdateService, services: true do
end
describe 'visibility_level' do
let(:project) { create(:project, :internal) }
let(:project) { create(:empty_project, :internal) }
let(:forked_project) { create(:forked_project_with_submodules, :internal) }
before do
......
......@@ -3,8 +3,8 @@ require 'spec_helper'
describe Projects::UploadService, services: true do
describe 'File service' do
before do
@user = create :user
@project = create :project, creator_id: @user.id, namespace: @user.namespace
@user = create(:user)
@project = create(:empty_project, creator_id: @user.id, namespace: @user.namespace)
end
context 'for valid gif file' do
......
......@@ -44,7 +44,7 @@ describe 'Search::GlobalService', services: true do
context 'nested group' do
let!(:nested_group) { create(:group, :nested) }
let!(:project) { create(:project, namespace: nested_group) }
let!(:project) { create(:empty_project, namespace: nested_group) }
before { project.add_master(user) }
......
require 'spec_helper'
describe SlashCommands::InterpretService, services: true do
let(:project) { create(:project, :public) }
let(:project) { create(:empty_project, :public) }
let(:developer) { create(:user) }
let(:issue) { create(:issue, project: project) }
let(:milestone) { create(:milestone, project: project, title: '9.10') }
......@@ -260,6 +260,8 @@ describe SlashCommands::InterpretService, services: true do
end
shared_examples 'merge command' do
let(:project) { create(:project, :repository) }
it 'runs merge command if content contains /merge' do
_, updates = service.execute(content, issuable)
......@@ -322,6 +324,7 @@ describe SlashCommands::InterpretService, services: true do
end
context 'when sha is missing' do
let(:project) { create(:project, :repository) }
let(:service) { described_class.new(project, developer, {}) }
it 'precheck passes and returns merge command' do
......@@ -694,7 +697,7 @@ describe SlashCommands::InterpretService, services: true do
end
context '/target_branch command' do
let(:non_empty_project) { create(:project) }
let(:non_empty_project) { create(:project, :repository) }
let(:another_merge_request) { create(:merge_request, author: developer, source_project: non_empty_project) }
let(:service) { described_class.new(non_empty_project, developer)}
......
......@@ -15,7 +15,7 @@ describe SpamService, services: true do
end
context 'when recaptcha was not verified' do
let(:project) { create(:project, :public) }
let(:project) { create(:empty_project, :public) }
let(:issue) { create(:issue, project: project) }
let(:request) { double(:request, env: {}) }
......
require 'spec_helper'
describe SystemHooksService, services: true do
let(:user) { create :user }
let(:project) { create :project }
let(:project_member) { create :project_member }
let(:key) { create(:key, user: user) }
let(:deploy_key) { create(:key) }
let(:group) { create(:group) }
let(:group_member) { create(:group_member) }
let(:user) { create(:user) }
let(:project) { create(:empty_project) }
let(:project_member) { create(:project_member) }
let(:key) { create(:key, user: user) }
let(:deploy_key) { create(:key) }
let(:group) { create(:group) }
let(:group_member) { create(:group_member) }
context 'event data' do
it { expect(event_data(user, :create)).to include(:event_name, :name, :created_at, :updated_at, :email, :user_id, :username) }
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe SystemNoteService, services: true do
include Gitlab::Routing.url_helpers
let(:project) { create(:project) }
let(:project) { create(:empty_project) }
let(:author) { create(:user) }
let(:noteable) { create(:issue, project: project) }
......@@ -32,6 +32,7 @@ describe SystemNoteService, services: true do
describe '.add_commits' do
subject { described_class.add_commits(noteable, project, author, new_commits, old_commits, oldrev) }
let(:project) { create(:project, :repository) }
let(:noteable) { create(:merge_request, source_project: project) }
let(:new_commits) { noteable.commits }
let(:old_commits) { [] }
......@@ -216,6 +217,7 @@ describe SystemNoteService, services: true do
end
describe '.merge_when_pipeline_succeeds' do
let(:project) { create(:project, :repository) }
let(:pipeline) { build(:ci_pipeline_without_jobs )}
let(:noteable) do
create(:merge_request, source_project: project, target_project: project)
......@@ -226,11 +228,12 @@ describe SystemNoteService, services: true do
it_behaves_like 'a system note'
it "posts the 'merge when pipeline succeeds' system note" do
expect(subject.note).to match /enabled an automatic merge when the pipeline for (\w+\/\w+@)?\h{40} succeeds/
expect(subject.note).to match(/enabled an automatic merge when the pipeline for (\w+\/\w+@)?\h{40} succeeds/)
end
end
describe '.cancel_merge_when_pipeline_succeeds' do
let(:project) { create(:project, :repository) }
let(:noteable) do
create(:merge_request, source_project: project, target_project: project)
end
......@@ -273,6 +276,8 @@ describe SystemNoteService, services: true do
describe '.change_branch' do
subject { described_class.change_branch(noteable, project, author, 'target', old_branch, new_branch) }
let(:project) { create(:project, :repository) }
let(:old_branch) { 'old_branch'}
let(:new_branch) { 'new_branch'}
......@@ -288,6 +293,8 @@ describe SystemNoteService, services: true do
describe '.change_branch_presence' do
subject { described_class.change_branch_presence(noteable, project, author, :source, 'feature', :delete) }
let(:project) { create(:project, :repository) }
it_behaves_like 'a system note'
context 'when source branch deleted' do
......@@ -300,11 +307,13 @@ describe SystemNoteService, services: true do
describe '.new_issue_branch' do
subject { described_class.new_issue_branch(noteable, project, author, "1-mepmep") }
let(:project) { create(:project, :repository) }
it_behaves_like 'a system note'
context 'when a branch is created from the new branch button' do
it 'sets the note text' do
expect(subject.note).to match /\Acreated branch [`1-mepmep`]/
expect(subject.note).to start_with("created branch [`1-mepmep`]")
end
end
end
......@@ -333,7 +342,7 @@ describe SystemNoteService, services: true do
describe 'note_body' do
context 'cross-project' do
let(:project2) { create(:project) }
let(:project2) { create(:project, :repository) }
let(:mentioner) { create(:issue, project: project2) }
context 'from Commit' do
......@@ -353,6 +362,7 @@ describe SystemNoteService, services: true do
context 'within the same project' do
context 'from Commit' do
let(:project) { create(:project, :repository) }
let(:mentioner) { project.repository.commit }
it 'references the mentioning commit' do
......@@ -394,6 +404,7 @@ describe SystemNoteService, services: true do
end
context 'when mentioner is a MergeRequest' do
let(:project) { create(:project, :repository) }
let(:mentioner) { create(:merge_request, :simple, source_project: project) }
let(:noteable) { project.commit }
......@@ -421,6 +432,7 @@ describe SystemNoteService, services: true do
end
describe '.cross_reference_exists?' do
let(:project) { create(:project, :repository) }
let(:commit0) { project.commit }
let(:commit1) { project.commit('HEAD~2') }
......@@ -513,7 +525,7 @@ describe SystemNoteService, services: true do
end
describe '.noteable_moved' do
let(:new_project) { create(:project) }
let(:new_project) { create(:empty_project) }
let(:new_noteable) { create(:issue, project: new_project) }
subject do
......@@ -542,7 +554,7 @@ describe SystemNoteService, services: true do
it_behaves_like 'cross project mentionable'
it 'notifies about noteable being moved to' do
expect(subject.note).to match /moved to/
expect(subject.note).to match('moved to')
end
end
......@@ -552,7 +564,7 @@ describe SystemNoteService, services: true do
it_behaves_like 'cross project mentionable'
it 'notifies about noteable being moved from' do
expect(subject.note).to match /moved from/
expect(subject.note).to match('moved from')
end
end
......@@ -574,13 +586,13 @@ describe SystemNoteService, services: true do
end
end
include JiraServiceHelper
describe 'JIRA integration' do
include JiraServiceHelper
let(:project) { create(:jira_project) }
let(:author) { create(:user) }
let(:issue) { create(:issue, project: project) }
let(:merge_request) { create(:merge_request, :simple, target_project: project, source_project: project) }
let(:merge_request) { create(:merge_request, :simple, target_project: project, source_project: project) }
let(:jira_issue) { ExternalIssue.new("JIRA-1", project)}
let(:jira_tracker) { project.jira_service }
let(:commit) { project.commit }
......@@ -809,6 +821,7 @@ describe SystemNoteService, services: true do
end
describe '.add_merge_request_wip_from_commit' do
let(:project) { create(:project, :repository) }
let(:noteable) do
create(:merge_request, source_project: project, target_project: project)
end
......
require 'spec_helper'
describe Tags::CreateService, services: true do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:repository) { project.repository }
let(:user) { create(:user) }
let(:service) { described_class.new(project, user) }
......
require 'spec_helper'
describe Tags::DestroyService, services: true do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:repository) { project.repository }
let(:user) { create(:user) }
let(:service) { described_class.new(project, user) }
......
require 'spec_helper'
describe TestHookService, services: true do
let(:user) { create :user }
let(:project) { create :project }
let(:hook) { create :project_hook, project: project }
let(:user) { create(:user) }
let(:project) { create(:project, :repository) }
let(:hook) { create(:project_hook, project: project) }
describe '#execute' do
it "executes successfully" do
......
......@@ -8,7 +8,7 @@ describe TodoService, services: true do
let(:guest) { create(:user) }
let(:admin) { create(:admin) }
let(:john_doe) { create(:user) }
let(:project) { create(:project) }
let(:project) { create(:empty_project) }
let(:mentions) { 'FYI: ' + [author, assignee, john_doe, member, guest, non_member, admin].map(&:to_reference).join(' ') }
let(:directly_addressed) { [author, assignee, john_doe, member, guest, non_member, admin].map(&:to_reference).join(' ') }
let(:directly_addressed_and_mentioned) { member.to_reference + ", what do you think? cc: " + [guest, admin].map(&:to_reference).join(' ') }
......@@ -99,9 +99,9 @@ describe TodoService, services: true do
end
context 'when a private group is mentioned' do
let(:group) { create :group, :private }
let(:project) { create :project, :private, group: group }
let(:issue) { create :issue, author: author, project: project, description: group.to_reference }
let(:group) { create(:group, :private) }
let(:project) { create(:empty_project, :private, group: group) }
let(:issue) { create(:issue, author: author, project: project, description: group.to_reference) }
before do
group.add_owner(author)
......@@ -422,22 +422,26 @@ describe TodoService, services: true do
should_create_todo(user: john_doe, target: confidential_issue, author: john_doe, action: Todo::DIRECTLY_ADDRESSED, note: addressed_note_on_confidential_issue)
end
it 'creates a todo for each valid mentioned user when leaving a note on commit' do
service.new_note(note_on_commit, john_doe)
context 'on commit' do
let(:project) { create(:project, :repository) }
should_create_todo(user: member, target_id: nil, target_type: 'Commit', commit_id: note_on_commit.commit_id, author: john_doe, action: Todo::MENTIONED, note: note_on_commit)
should_create_todo(user: author, target_id: nil, target_type: 'Commit', commit_id: note_on_commit.commit_id, author: john_doe, action: Todo::MENTIONED, note: note_on_commit)
should_create_todo(user: john_doe, target_id: nil, target_type: 'Commit', commit_id: note_on_commit.commit_id, author: john_doe, action: Todo::MENTIONED, note: note_on_commit)
should_not_create_todo(user: non_member, target_id: nil, target_type: 'Commit', commit_id: note_on_commit.commit_id, author: john_doe, action: Todo::MENTIONED, note: note_on_commit)
end
it 'creates a todo for each valid mentioned user when leaving a note on commit' do
service.new_note(note_on_commit, john_doe)
should_create_todo(user: member, target_id: nil, target_type: 'Commit', commit_id: note_on_commit.commit_id, author: john_doe, action: Todo::MENTIONED, note: note_on_commit)
should_create_todo(user: author, target_id: nil, target_type: 'Commit', commit_id: note_on_commit.commit_id, author: john_doe, action: Todo::MENTIONED, note: note_on_commit)
should_create_todo(user: john_doe, target_id: nil, target_type: 'Commit', commit_id: note_on_commit.commit_id, author: john_doe, action: Todo::MENTIONED, note: note_on_commit)
should_not_create_todo(user: non_member, target_id: nil, target_type: 'Commit', commit_id: note_on_commit.commit_id, author: john_doe, action: Todo::MENTIONED, note: note_on_commit)
end
it 'creates a directly addressed todo for each valid mentioned user when leaving a note on commit' do
service.new_note(addressed_note_on_commit, john_doe)
it 'creates a directly addressed todo for each valid mentioned user when leaving a note on commit' do
service.new_note(addressed_note_on_commit, john_doe)
should_create_todo(user: member, target_id: nil, target_type: 'Commit', commit_id: addressed_note_on_commit.commit_id, author: john_doe, action: Todo::DIRECTLY_ADDRESSED, note: addressed_note_on_commit)
should_create_todo(user: author, target_id: nil, target_type: 'Commit', commit_id: addressed_note_on_commit.commit_id, author: john_doe, action: Todo::DIRECTLY_ADDRESSED, note: addressed_note_on_commit)
should_create_todo(user: john_doe, target_id: nil, target_type: 'Commit', commit_id: addressed_note_on_commit.commit_id, author: john_doe, action: Todo::DIRECTLY_ADDRESSED, note: addressed_note_on_commit)
should_not_create_todo(user: non_member, target_id: nil, target_type: 'Commit', commit_id: addressed_note_on_commit.commit_id, author: john_doe, action: Todo::DIRECTLY_ADDRESSED, note: addressed_note_on_commit)
should_create_todo(user: member, target_id: nil, target_type: 'Commit', commit_id: addressed_note_on_commit.commit_id, author: john_doe, action: Todo::DIRECTLY_ADDRESSED, note: addressed_note_on_commit)
should_create_todo(user: author, target_id: nil, target_type: 'Commit', commit_id: addressed_note_on_commit.commit_id, author: john_doe, action: Todo::DIRECTLY_ADDRESSED, note: addressed_note_on_commit)
should_create_todo(user: john_doe, target_id: nil, target_type: 'Commit', commit_id: addressed_note_on_commit.commit_id, author: john_doe, action: Todo::DIRECTLY_ADDRESSED, note: addressed_note_on_commit)
should_not_create_todo(user: non_member, target_id: nil, target_type: 'Commit', commit_id: addressed_note_on_commit.commit_id, author: john_doe, action: Todo::DIRECTLY_ADDRESSED, note: addressed_note_on_commit)
end
end
it 'does not create todo when leaving a note on snippet' do
......@@ -720,6 +724,7 @@ describe TodoService, services: true do
end
describe '#new_note' do
let(:project) { create(:project, :repository) }
let(:mention) { john_doe.to_reference }
let(:diff_note_on_merge_request) { create(:diff_note_on_merge_request, project: project, noteable: mr_unassigned, author: author, note: "Hey #{mention}") }
let(:addressed_diff_note_on_merge_request) { create(:diff_note_on_merge_request, project: project, noteable: mr_unassigned, author: author, note: "#{mention}, hey!") }
......
require 'spec_helper'
describe UpdateReleaseService, services: true do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
let(:tag_name) { project.repository.tag_names.first }
let(:description) { 'Awesome release!' }
......
......@@ -5,7 +5,7 @@ describe Users::DestroyService, services: true do
let!(:user) { create(:user) }
let!(:admin) { create(:admin) }
let!(:namespace) { create(:namespace, owner: user) }
let!(:project) { create(:project, namespace: namespace) }
let!(:project) { create(:empty_project, namespace: namespace) }
let(:service) { described_class.new(admin) }
context 'no options are given' do
......@@ -25,7 +25,7 @@ describe Users::DestroyService, services: true do
end
context "a deleted user's issues" do
let(:project) { create :project }
let(:project) { create(:project) }
before do
project.add_developer(user)
......
......@@ -152,7 +152,7 @@ describe Users::RefreshAuthorizedProjectsService do
context 'projects of groups the user is a member of' do
let(:group) { create(:group) }
let!(:other_project) { create(:project, group: group) }
let!(:other_project) { create(:empty_project, group: group) }
before do
group.add_owner(user)
......@@ -166,7 +166,7 @@ describe Users::RefreshAuthorizedProjectsService do
context 'projects of subgroups of groups the user is a member of' do
let(:group) { create(:group) }
let(:nested_group) { create(:group, parent: group) }
let!(:other_project) { create(:project, group: nested_group) }
let!(:other_project) { create(:empty_project, group: nested_group) }
before do
group.add_master(user)
......
......@@ -2,7 +2,7 @@
# It can take a `default_params`.
shared_examples 'new issuable record that supports slash commands' do
let!(:project) { create(:project) }
let!(:project) { create(:project, :repository) }
let(:user) { create(:user).tap { |u| project.team << [u, :master] } }
let(:assignee) { create(:user) }
let!(:milestone) { create(:milestone, project: project) }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment