summaryrefslogtreecommitdiff
path: root/spec/finders/license_template_finder_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/finders/license_template_finder_spec.rb')
-rw-r--r--spec/finders/license_template_finder_spec.rb43
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