diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-08-25 12:19:52 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-08-25 12:19:52 +0300 |
commit | 2e497d84380907ad61225d358024ac1805da85e1 (patch) | |
tree | 6cb421c79bedf3e92404d52b4115f6b2a9f3fb64 /spec/services | |
parent | 1a9b2a47a139f2e683873c5d46cea15161e35783 (diff) | |
download | gitlab-ce-2e497d84380907ad61225d358024ac1805da85e1.tar.gz |
Prevent project stars duplication when fork project
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'spec/services')
-rw-r--r-- | spec/services/projects/fork_service_spec.rb (renamed from spec/services/fork_service_spec.rb) | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/spec/services/fork_service_spec.rb b/spec/services/projects/fork_service_spec.rb index b6573095dbd..0edc3a8e807 100644 --- a/spec/services/fork_service_spec.rb +++ b/spec/services/projects/fork_service_spec.rb @@ -5,44 +5,40 @@ describe Projects::ForkService do before do @from_namespace = create(:namespace) @from_user = create(:user, namespace: @from_namespace ) - @from_project = create(:project, creator_id: @from_user.id, namespace: @from_namespace) + @from_project = create(:project, creator_id: @from_user.id, + namespace: @from_namespace, star_count: 107, + description: 'wow such project') @to_namespace = create(:namespace) @to_user = create(:user, namespace: @to_namespace) end context 'fork project' do + describe "successfully creates project in the user namespace" do + let(:to_project) { fork_project(@from_project, @to_user) } - it "successfully creates project in the user namespace" do - @to_project = fork_project(@from_project, @to_user) - - @to_project.owner.should == @to_user - @to_project.namespace.should == @to_user.namespace + it { to_project.owner.should == @to_user } + it { to_project.namespace.should == @to_user.namespace } + it { to_project.star_count.should be_zero } + it { to_project.description.should == @from_project.description } end end context 'fork project failure' do - it "fails due to transaction failure" do - # make the mock gitlab-shell fail @to_project = fork_project(@from_project, @to_user, false) - @to_project.errors.should_not be_empty @to_project.errors[:base].should include("Fork transaction failed.") end - end context 'project already exists' do - it "should fail due to validation, not transaction failure" 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) - @existing_project.persisted?.should be_true @to_project.errors[:base].should include("Invalid fork destination") @to_project.errors[:base].should_not include("Fork transaction failed.") end - end end @@ -53,5 +49,4 @@ describe Projects::ForkService do context.stub(gitlab_shell: shell) context.execute end - end |