• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

benwbrum / fromthepage / 17387282326

01 Sep 2025 09:13PM UTC coverage: 64.405%. Remained the same
17387282326

push

github

web-flow
4857 - Require rubocop step in CI (#4858)

* 4857 - Require rubocop step in CI

* 4865 - Organize gemfiles

1790 of 3303 branches covered (54.19%)

Branch coverage included in aggregate %.

839 of 1497 new or added lines in 133 files covered. (56.05%)

43 existing lines in 29 files now uncovered.

7928 of 11786 relevant lines covered (67.27%)

103.82 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

44.68
/app/controllers/facets_controller.rb
1
class FacetsController < ApplicationController
1✔
2
  def enable
1✔
UNCOV
3
    @collection = Collection.find(params[:collection_id])
×
4
    @collection.facets_enabled = true
×
5
    @collection.save
×
6

7
    # create metadata_coverages for collections that don't have any.
8
    if @collection.metadata_coverages.empty?
×
9
      @collection.works.each do |w|
×
10
        unless w.original_metadata.nil?
×
11
          om = JSON.parse(w.original_metadata)
×
12

13
          om.each do |m|
×
14
            unless m['label'].blank?
×
15
              label = m['label']
×
16

17
              collection = w.collection
×
18

19
              unless w.collection.nil?
×
20
                mc = collection.metadata_coverages.build
×
21

22
                # check that record exist
23
                test = collection.metadata_coverages.where(key: label).first
×
24

25
                # increment count field if a record is returned
26
                if test
×
27
                  test.count = test.count + 1
×
28
                  test.save
×
29
                end
30

31
                if test.nil?
×
32
                  mc.key = label.to_sym
×
33
                  mc.save
×
34
                  mc.create_facet_config(metadata_coverage_id: mc.collection_id)
×
35
                end
36
              end
37
            end
38
          end
39
        end
40
      end
41
    end
42

43
    redirect_to collection_facets_path(@collection.owner, @collection)
×
44
  end
45

46
  def disable
1✔
47
    @collection = Collection.find(params[:collection_id])
×
48
    @collection.facets_enabled = false
×
49
    @collection.save
×
50
    redirect_to edit_collection_path(@collection.owner, @collection)
×
51
  end
52

53
  def update
1✔
54
    collection = Collection.find(params[:collection_id])
4✔
55
    errors = []
4✔
56
    collection.metadata_coverages.each do |m|
4✔
57
      metadata = params[:metadata][m[:key]]
84✔
58
      unless metadata.nil?
84!
59
        if metadata['order'].present?
84✔
60
          facet_label = metadata['label'].blank? ? m.key : metadata['label']
4!
61
          if m.facet_config.label.nil?
4✔
62
            label_hash = {}
1✔
63
          else
3✔
64
            label_hash = JSON.parse(m.facet_config.label)
3✔
65
          end
66
          label_hash[locale.to_s] = facet_label
4✔
67
          facet_label = label_hash.to_json
4✔
68
        else
80✔
69
          facet_label = nil
80✔
70
        end
71

72
        m.facet_config.update(label: facet_label,
84✔
73
                              input_type: metadata['input_type'],
74
                              order: metadata['order'])
75
      end
76

77
      if m.facet_config.errors.any?
84✔
78
        errors << m.facet_config.errors.full_messages.first
3✔
79
      end
80
    end
81

82
    if errors.empty?
4✔
83
      # renumber down to contiguous 0-indexed values
1✔
84
      collection.facet_configs.where(input_type: 'text').where.not(order: nil).each_with_index do |facet_config, i|
1✔
85
        facet_config.order=i
1✔
86
        facet_config.save!
1✔
87
      end
88
      collection.facet_configs.where(input_type: 'date').where.not(order: nil).each_with_index do |facet_config, i|
1✔
89
        facet_config.order=i
×
90
        facet_config.save!
×
91
      end
92
      FacetConfig.populate_facets(collection)
1✔
93

94
      redirect_to collection_facets_path(collection.owner, collection), notice: t('collection.facets.collection_facets_updated_successfully')
1✔
95
    else
3✔
96
      @metadata_coverages = collection.metadata_coverages
3✔
97
      @errors = errors
3✔
98

99
      render 'collection/facets'
3✔
100
    end
101
  end
102

103

104
  def localize
1✔
105
    render('collection/localize', layout: false)
×
106
  end
107

108
  def update_localization
1✔
109
    facet_params = params[:facets]
×
110
    facet_params.each do |facet_config_id, labels|
×
111
      facet_config = @collection.facet_configs.where(id: facet_config_id).first
×
112
      if facet_config
×
113
        facet_config.label = labels.to_json
×
114
        facet_config.save!
×
115
      end
116
    end
117
    ajax_redirect_to collection_facets_path(@collection.owner, @collection)
×
118
  end
119
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc