summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-04-27 07:41:20 +0000
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-04-27 07:41:20 +0000
commit57759c9aeedf6ce4763c0b2cbca6eab2dacb3476 (patch)
tree29b0835b5c9c861eb329ef716f2a6a36e27764a3 /spec
parent6de7f94f00eb790def76b0fea15830180e25a0cb (diff)
parent0cf76a0b70f2a1dba6760263f842d2841dfc0cd9 (diff)
downloadgitlab-ce-57759c9aeedf6ce4763c0b2cbca6eab2dacb3476.tar.gz
Merge branch 'forked-event' into 'master'
Use Projects::CreateService to fork projects so that after-create hooks are run. Makes for cleaner code and less duplication, and causes the "User created project Namespace / Project" event to be posted and system hooks to be run. See merge request !575
Diffstat (limited to 'spec')
-rw-r--r--spec/requests/api/fork_spec.rb1
-rw-r--r--spec/services/projects/fork_service_spec.rb16
2 files changed, 6 insertions, 11 deletions
diff --git a/spec/requests/api/fork_spec.rb b/spec/requests/api/fork_spec.rb
index fb3ff552c8d..7a784796031 100644
--- a/spec/requests/api/fork_spec.rb
+++ b/spec/requests/api/fork_spec.rb
@@ -50,7 +50,6 @@ describe API::API, api: true do
it 'should fail if forked project exists in the user namespace' do
post api("/projects/fork/#{project.id}", user)
expect(response.status).to eq(409)
- expect(json_response['message']['base']).to eq(['Invalid fork destination'])
expect(json_response['message']['name']).to eq(['has already been taken'])
expect(json_response['message']['path']).to eq(['has already been taken'])
end
diff --git a/spec/services/projects/fork_service_spec.rb b/spec/services/projects/fork_service_spec.rb
index c9025bdf133..f158ac87e2b 100644
--- a/spec/services/projects/fork_service_spec.rb
+++ b/spec/services/projects/fork_service_spec.rb
@@ -27,7 +27,7 @@ describe Projects::ForkService do
it "fails due to transaction failure" do
@to_project = fork_project(@from_project, @to_user, false)
expect(@to_project.errors).not_to be_empty
- expect(@to_project.errors[:base]).to include("Fork transaction failed.")
+ expect(@to_project.errors[:base]).to include("Failed to fork repository")
end
end
@@ -36,8 +36,8 @@ describe Projects::ForkService do
@existing_project = create(:project, creator_id: @to_user.id, name: @from_project.name, namespace: @to_namespace)
@to_project = fork_project(@from_project, @to_user)
expect(@existing_project.persisted?).to be_truthy
- expect(@to_project.errors[:base]).to include("Invalid fork destination")
- expect(@to_project.errors[:base]).not_to include("Fork transaction failed.")
+ expect(@to_project.errors[:name]).to eq(['has already been taken'])
+ expect(@to_project.errors[:path]).to eq(['has already been taken'])
end
end
@@ -81,7 +81,7 @@ describe Projects::ForkService do
context 'fork project for group when user not owner' do
it 'group developer should fail to fork project into the group' do
to_project = fork_project(@project, @developer, true, @opts)
- expect(to_project.errors[:namespace]).to eq(['insufficient access rights'])
+ expect(to_project.errors[:namespace]).to eq(['is not valid'])
end
end
@@ -91,7 +91,6 @@ describe Projects::ForkService do
namespace: @group)
to_project = fork_project(@project, @group_owner, true, @opts)
expect(existing_project.persisted?).to be_truthy
- expect(to_project.errors[:base]).to eq(['Invalid fork destination'])
expect(to_project.errors[:name]).to eq(['has already been taken'])
expect(to_project.errors[:path]).to eq(['has already been taken'])
end
@@ -99,10 +98,7 @@ describe Projects::ForkService do
end
def fork_project(from_project, user, fork_success = true, params = {})
- context = Projects::ForkService.new(from_project, user, params)
- shell = double('gitlab_shell')
- shell.stub(fork_repository: fork_success)
- context.stub(gitlab_shell: shell)
- context.execute
+ allow_any_instance_of(Gitlab::Shell).to receive(:fork_repository).and_return(fork_success)
+ Projects::ForkService.new(from_project, user, params).execute
end
end