Welcome to mirror list, hosted at ThFree Co, Russian Federation.

create_project_service_spec.rb « services « ci « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 31614968d55196088509fadc4d7d37ec1a98c32c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
require 'spec_helper'

describe CreateProjectService do
  let(:service) { CreateProjectService.new }
  let(:current_user) { double.as_null_object }
  let(:project_dump) { YAML.load File.read(Rails.root.join('spec/support/gitlab_stubs/raw_project.yml')) }

  before { Network.any_instance.stub(enable_ci: true) }

  describe :execute do
    context 'valid params' do
      let(:project) { service.execute(current_user, project_dump, 'http://localhost/projects/:project_id') }

      it { project.should be_kind_of(Project) }
      it { project.should be_persisted }
    end

    context 'without project dump' do
      it 'should raise exception' do
        expect { service.execute(current_user, '', '') }.to raise_error
      end
    end

    context "forking" do
      it "uses project as a template for settings and jobs" do
        origin_project = FactoryGirl.create(:project)
        origin_project.shared_runners_enabled = true
        origin_project.public = true
        origin_project.allow_git_fetch = true
        origin_project.save!

        project = service.execute(current_user, project_dump, 'http://localhost/projects/:project_id', origin_project)

        project.shared_runners_enabled.should be_true
        project.public.should be_true
        project.allow_git_fetch.should be_true
      end
    end
  end
end