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

foodcoops / foodsoft / 21521827700

30 Jan 2026 03:53PM UTC coverage: 42.78% (-24.3%) from 67.127%
21521827700

Pull #1269

github

lentschi
Remove GitHub deploy workflow
Pull Request #1269: Remove GitHub deploy workflow

3087 of 7216 relevant lines covered (42.78%)

11.86 hits per line

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

25.0
/app/controllers/admin/configs_controller.rb
1
class Admin::ConfigsController < Admin::BaseController
1✔
2
  before_action :get_tabs, only: %i[show list]
1✔
3

4
  def show
1✔
5
    @current_tab = @tabs.include?(params[:tab]) ? params[:tab] : @tabs.first
×
6
    @cfg = FoodsoftConfig
×
7
  end
8

9
  def list
1✔
10
    @current_tab = 'list'
×
11
    @cfg = FoodsoftConfig
×
12
    @dfl = FoodsoftConfig.config
×
13
    @keys = FoodsoftConfig.keys.select { |k| FoodsoftConfig.allowed_key?(k) }.sort
×
14
  end
15

16
  def update
1✔
17
    parse_recurring_selects! params[:config][:order_schedule]
×
18
    ActiveRecord::Base.transaction do
×
19
      # TODO: support nested configuration keys
20
      params[:config].each do |key, val|
×
21
        FoodsoftConfig[key] = convert_config_value val
×
22
      end
23
    end
24
    flash[:notice] = I18n.t('admin.configs.update.notice')
×
25
    redirect_to action: 'show'
×
26
  end
27

28
  protected
1✔
29

30
  # Set configuration tab names as `@tabs`
31
  def get_tabs
1✔
32
    @tabs = %w[foodcoop payment tasks messages layout language security others]
×
33
    # allow engines to modify this list
34
    engines = Rails::Engine.subclasses.map(&:instance).select { |e| e.respond_to?(:configuration) }
×
35
    engines.each { |e| e.configuration(@tabs, self) }
×
36
    @tabs.uniq!
×
37
  end
38

39
  # turn recurring rules into something palatable
40
  def parse_recurring_selects!(config)
1✔
41
    return unless config
×
42

43
    for k in %i[pickup boxfill ends] do
×
44
      if config[k]
×
45
        # allow clearing it using dummy value '{}' ('' would break recurring_select)
46
        if config[k][:recurr].present? && config[k][:recurr] != '{}' && !config[k][:recurr].nil?
×
47
          config[k][:recurr] = ActiveSupport::JSON.decode(config[k][:recurr])
×
48
          date = FoodsoftDateUtil.rule_from(config[k][:recurr])
×
49
          config[k][:recurr] = date.to_ical if date
×
50
        else
51
          config[k][:recurr] = ''
×
52
        end
53
      end
54
    end
55
  end
56

57
  def convert_config_value(value)
1✔
58
    if value.is_a? ActionController::Parameters
×
59
      value.transform_values { |v| convert_config_value(v) }.to_hash
×
60
    else
61
      value
×
62
    end
63
  end
64
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