diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 10:34:06 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 10:34:06 +0000 |
commit | 859a6fb938bb9ee2a317c46dfa4fcc1af49608f0 (patch) | |
tree | d7f2700abe6b4ffcb2dcfc80631b2d87d0609239 /spec/finders/license_template_finder_spec.rb | |
parent | 446d496a6d000c73a304be52587cd9bbc7493136 (diff) | |
download | gitlab-ce-859a6fb938bb9ee2a317c46dfa4fcc1af49608f0.tar.gz |
Add latest changes from gitlab-org/gitlab@13-9-stable-eev13.9.0-rc42
Diffstat (limited to 'spec/finders/license_template_finder_spec.rb')
-rw-r--r-- | spec/finders/license_template_finder_spec.rb | 43 |
1 files changed, 37 insertions, 6 deletions
diff --git a/spec/finders/license_template_finder_spec.rb b/spec/finders/license_template_finder_spec.rb index 93f13632b6f..754b92faccc 100644 --- a/spec/finders/license_template_finder_spec.rb +++ b/spec/finders/license_template_finder_spec.rb @@ -3,12 +3,7 @@ require 'spec_helper' RSpec.describe LicenseTemplateFinder do - describe '#execute' do - subject(:result) { described_class.new(nil, params).execute } - - let(:categories) { categorised_licenses.keys } - let(:categorised_licenses) { result.group_by(&:category) } - + RSpec.shared_examples 'filters by popular category' do context 'popular: true' do let(:params) { { popular: true } } @@ -26,6 +21,15 @@ RSpec.describe LicenseTemplateFinder do expect(categorised_licenses[:Other]).to be_present end end + end + + describe '#execute' do + subject(:result) { described_class.new(nil, params).execute } + + let(:categories) { categorised_licenses.keys } + let(:categorised_licenses) { result.group_by(&:category) } + + it_behaves_like 'filters by popular category' context 'popular: nil' do let(:params) { { popular: nil } } @@ -48,4 +52,31 @@ RSpec.describe LicenseTemplateFinder do end end end + + describe '#template_names' do + let(:params) { {} } + + subject(:template_names) { described_class.new(nil, params).template_names } + + let(:categories) { categorised_licenses.keys } + let(:categorised_licenses) { template_names } + + it_behaves_like 'filters by popular category' + + context 'popular: nil' do + let(:params) { { popular: nil } } + + it 'returns all licenses known by the Licensee gem' do + from_licensee = Licensee::License.all.map { |l| l.key } + + expect(template_names.values.flatten.map { |x| x[:key] }).to match_array(from_licensee) + end + end + + context 'template names hash keys' do + it 'has all the expected keys' do + expect(template_names.values.flatten.first.keys).to match_array(%i(id key name project_id)) + end + end + end end |