• 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

43.18
/app/controllers/order_articles_controller.rb
1
class OrderArticlesController < ApplicationController
1✔
2
  before_action :fetch_order, except: :destroy
1✔
3
  before_action :authenticate_finance_or_invoices, except: %i[new create]
1✔
4
  before_action :authenticate_finance_orders_or_pickup, except: %i[edit update destroy]
1✔
5
  before_action :load_order_article, only: %i[edit update]
1✔
6
  before_action :load_article_units, only: %i[edit update]
1✔
7
  before_action :new_empty_article_ratio, only: %i[edit update]
1✔
8

9
  layout false # We only use this controller to serve js snippets, no need for layout rendering
1✔
10

11
  def new
1✔
12
    @order_article = @order.order_articles.build(params[:order_article])
×
13
  end
14

15
  def edit; end
1✔
16

17
  def create
1✔
18
    # The article may be ordered with zero units - in that case do not complain.
19
    #   If order_article is ordered and a new order_article is created, an error message will be
20
    #   given mentioning that the article already exists, which is desired.
21
    @order_article = @order.order_articles.where(article_version_id: params[:order_article][:article_version_id]).first
×
22
    @order_article = @order.order_articles.build(params[:order_article]) unless @order_article && @order_article.units_to_order == 0
×
23
    @order_article.save!
×
24
  rescue StandardError
25
    render action: :new
×
26
  end
27

28
  def update
1✔
29
    version_params = params.require(:article_version).permit(:id, :unit, :supplier_order_unit, :minimum_order_quantity,
×
30
                                                             :billing_unit, :group_order_granularity, :group_order_unit, :price, :price_unit, :tax, :deposit, article_unit_ratios_attributes: %i[id sort quantity unit _destroy])
31
    @order_article.update_handling_versioning!(params[:order_article], version_params)
×
32
  rescue StandardError
33
    render action: :edit
×
34
  end
35

36
  def destroy
1✔
37
    @order_article = OrderArticle.find(params[:id])
×
38
    # only destroy if there are no associated GroupOrders; if we would, the requested
39
    # quantity and tolerance would be gone. Instead of destroying, we set all result
40
    # quantities to zero.
41
    if @order_article.group_order_articles.count == 0
×
42
      @order_article.destroy
×
43
    else
44
      @order_article.group_order_articles.each { |goa| goa.update_attribute(:result, 0) }
×
45
      @order_article.update_results!
×
46
    end
47
  end
48

49
  private
1✔
50

51
  def fetch_order
1✔
52
    @order = Order.find(params[:order_id])
×
53
  end
54

55
  def authenticate_finance_orders_or_pickup
1✔
56
    return if current_user.role_finance? || current_user.role_orders?
×
57

58
    return if current_user.role_pickups? && !@order.nil? && @order.state == 'finished'
×
59

60
    deny_access
×
61
  end
62

63
  def load_order_article
1✔
64
    @order_article = OrderArticle.includes(article_version: :article_unit_ratios).find(params[:id])
×
65
  end
66

67
  def load_article_units
1✔
68
    article = @order_article&.article_version&.article
×
69
    additional_units = article.nil? ? [] : article.current_article_units
×
70
    @article_units = ArticleUnit.as_options(additional_units: additional_units)
×
71
    @all_units = ArticleUnit.as_hash(additional_units: additional_units)
×
72
  end
73

74
  def new_empty_article_ratio
1✔
75
    @empty_article_unit_ratio = ArticleUnitRatio.new
×
76
    @empty_article_unit_ratio.article_version = @order_article.price
×
77
    @empty_article_unit_ratio.sort = -1
×
78
  end
79
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