diff options
author | Z.J. van de Weg <git@zjvandeweg.nl> | 2017-07-26 15:21:53 +0300 |
---|---|---|
committer | Z.J. van de Weg <git@zjvandeweg.nl> | 2017-07-28 12:32:46 +0300 |
commit | 1d3815f89b9b9f5ecfd6dd15158a2988603b9ed8 (patch) | |
tree | a694e1e05f58fc3fe5ae00135d4a439eef7c8150 /spec/lib/gitlab/project_template_spec.rb | |
parent | d964816b9fe56679ffc0b331e701f7b24db5c6a9 (diff) |
Allow projects to be started from a template
Started implementation for the first iteration of
gitlab-org/gitlab-ce#32420. This will allow users to select a template
to start with, instead of an empty repository in the project just
created.
Internally this is basically a small extension of the ImportExport
GitLab projects we already support. We just import a certain import
tar archive. This commits includes the first one: Ruby on Rails. In the
future more will be added.
Diffstat (limited to 'spec/lib/gitlab/project_template_spec.rb')
-rw-r--r-- | spec/lib/gitlab/project_template_spec.rb | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/spec/lib/gitlab/project_template_spec.rb b/spec/lib/gitlab/project_template_spec.rb new file mode 100644 index 00000000000..5dc6059b49c --- /dev/null +++ b/spec/lib/gitlab/project_template_spec.rb @@ -0,0 +1,48 @@ +require 'spec_helper' + +describe Gitlab::ProjectTemplate do + describe '.all' do + it 'returns a all templates' do + expected = [ + described_class.new('rails', 'Ruby on Rails') + ] + + expect(described_class.all).to be_an(Array) + expect(described_class.all).to eq(expected) + end + end + + describe '.find' do + subject { described_class.find(query) } + + context 'when there is a match' do + let(:query) { :rails } + + it { is_expected.to be_a(described_class) } + end + + context 'when there is no match' do + let(:query) { 'no-match' } + + it { is_expected.to be(nil) } + end + end + + describe 'instance methods' do + subject { described_class.new('phoenix', 'Phoenix Framework') } + + it { is_expected.to respond_to(:logo_path, :file, :template_archive) } + end + + describe 'validate all templates' do + described_class.all.each do |template| + it "#{template.name} has a valid archive" do + archive = template.template_archive + logo = Rails.root.join("app/assets/images/#{template.logo_path}") + + expect(File.exist?(archive)).to be(true) + expect(File.exist?(logo)).to be(true) + end + end + end +end |