Commit 14f78d06 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Modify specs for new project transfer code

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 900d3079
......@@ -147,7 +147,7 @@ describe API::API, api: true do
describe "POST /groups/:id/projects/:project_id" do
let(:project) { create(:project) }
before(:each) do
project.stub(:transfer).and_return(true)
Projects::TransferService.any_instance.stub(execute: true)
Project.stub(:find).and_return(project)
end
......@@ -160,8 +160,8 @@ describe API::API, api: true do
context "when authenticated as admin" do
it "should transfer project to group" do
project.should_receive(:transfer)
post api("/groups/#{group1.id}/projects/#{project.id}", admin)
response.status.should == 201
end
end
end
......
require 'spec_helper'
describe ProjectTransferService do
describe Projects::TransferService do
before(:each) { enable_observers }
after(:each) {disable_observers}
context 'namespace -> namespace' do
let(:user) { create(:user) }
let(:group) { create(:group) }
let(:project) { create(:project, namespace: user.namespace) }
let(:user) { create(:user) }
let(:group) { create(:group) }
let(:group2) { create(:group) }
let(:project) { create(:project, namespace: user.namespace) }
context 'namespace -> namespace' do
before do
@result = service.transfer(project, group)
group.add_owner(user)
@service = Projects::TransferService.new(project, user, namespace_id: group.id)
@service.gitlab_shell.stub(mv_repository: true)
@result = @service.execute
end
it { @result.should be_true }
......@@ -18,16 +22,25 @@ describe ProjectTransferService do
end
context 'namespace -> no namespace' do
let(:user) { create(:user) }
let(:project) { create(:project, namespace: user.namespace) }
before do
group.add_owner(user)
@service = Projects::TransferService.new(project, user, namespace_id: nil)
@service.gitlab_shell.stub(mv_repository: true)
@result = @service.execute
end
it { lambda{service.transfer(project, nil)}.should raise_error(ActiveRecord::RecordInvalid) }
it { @result.should be_false }
it { project.namespace.should == user.namespace }
end
def service
service = ProjectTransferService.new
service.gitlab_shell.stub(mv_repository: true)
service
context 'namespace -> not allowed namespace' do
before do
@service = Projects::TransferService.new(project, user, namespace_id: group2.id)
@service.gitlab_shell.stub(mv_repository: true)
@result = @service.execute
end
it { @result.should be_false }
it { project.namespace.should == user.namespace }
end
end
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