diff options
author | Nick Thomas <nick@gitlab.com> | 2018-08-14 22:30:32 +0100 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2018-08-15 07:38:18 +0100 |
commit | 40d1fc1cd7180f5ab900ae9cab9fbf1548e35c51 (patch) | |
tree | bc518ffe8ed4121e077e38500fe2ac75a1cb7fb3 | |
parent | d3490f6998b13a6f74af9b6f35a28c115a25143e (diff) | |
download | gitlab-ce-40d1fc1cd7180f5ab900ae9cab9fbf1548e35c51.tar.gz |
Convert BlobHelper#licenses_for_select to use the new LicenseTemplateFinder
-rw-r--r-- | app/helpers/blob_helper.rb | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb index 7eb45ddd117..b61cbd5418a 100644 --- a/app/helpers/blob_helper.rb +++ b/app/helpers/blob_helper.rb @@ -182,12 +182,14 @@ module BlobHelper def licenses_for_select return @licenses_for_select if defined?(@licenses_for_select) - licenses = Licensee::License.all + grouped_licenses = LicenseTemplateFinder.new.execute.group_by(&:category) + categories = grouped_licenses.keys - @licenses_for_select = { - Popular: licenses.select(&:featured).map { |license| { name: license.name, id: license.key } }, - Other: licenses.reject(&:featured).map { |license| { name: license.name, id: license.key } } - } + @licenses_for_select = categories.each_with_object({}) do |category, hash| + hash[category] = grouped_licenses[category].map do |license| + { name: license.name, id: license.id } + end + end end def ref_project |