chore: rubocop
chore: fix api test conventions chore: rubocop -A spec/ chore: more rubocop -A fix failing test rubocop fixes removes helper methods that are in my opinion dead code more rubocop fixes rubocop -a --auto-gen-config
This commit is contained in:
parent
f6fb804bbe
commit
fb2b4d8a8a
331 changed files with 4263 additions and 4507 deletions
|
|
@ -1,6 +1,6 @@
|
|||
class CurrentOrders::ArticlesController < ApplicationController
|
||||
before_action :authenticate_orders
|
||||
before_action :find_order_and_order_article, only: [:index, :show]
|
||||
before_action :find_order_and_order_article, only: %i[index show]
|
||||
|
||||
def index
|
||||
# sometimes need to pass id as parameter for forms
|
||||
|
|
@ -26,11 +26,11 @@ class CurrentOrders::ArticlesController < ApplicationController
|
|||
|
||||
def find_order_and_order_article
|
||||
@current_orders = Order.finished_not_closed
|
||||
unless params[:order_id].blank?
|
||||
if params[:order_id].blank?
|
||||
@order_articles = OrderArticle.where(order_id: @current_orders.all.map(&:id))
|
||||
else
|
||||
@order = Order.find(params[:order_id])
|
||||
@order_articles = @order.order_articles
|
||||
else
|
||||
@order_articles = OrderArticle.where(order_id: @current_orders.all.map(&:id))
|
||||
end
|
||||
@q = OrderArticle.ransack(params[:q])
|
||||
@order_articles = @order_articles.ordered.merge(@q.result).includes(:article, :article_price)
|
||||
|
|
|
|||
|
|
@ -4,10 +4,10 @@ class CurrentOrders::GroupOrdersController < ApplicationController
|
|||
|
||||
def index
|
||||
# XXX code duplication lib/foodsoft_current_orders/app/controllers/current_orders/ordergroups_controller.rb
|
||||
@order_ids = Order.where(state: ['open', 'finished']).all.map(&:id)
|
||||
@goas = GroupOrderArticle.includes(:group_order => :ordergroup).includes(:order_article)
|
||||
@order_ids = Order.where(state: %w[open finished]).all.map(&:id)
|
||||
@goas = GroupOrderArticle.includes(group_order: :ordergroup).includes(:order_article)
|
||||
.where(group_orders: { order_id: @order_ids, ordergroup_id: @ordergroup.id }).ordered
|
||||
@articles_grouped_by_category = @goas.includes(:order_article => { :article => :article_category })
|
||||
@articles_grouped_by_category = @goas.includes(order_article: { article: :article_category })
|
||||
.order('articles.name')
|
||||
.group_by { |a| a.order_article.article.article_category.name }
|
||||
.sort { |a, b| a[0] <=> b[0] }
|
||||
|
|
@ -18,8 +18,8 @@ class CurrentOrders::GroupOrdersController < ApplicationController
|
|||
# XXX code duplication from GroupOrdersController
|
||||
def ensure_ordergroup_member
|
||||
@ordergroup = @current_user.ordergroup
|
||||
if @ordergroup.nil?
|
||||
redirect_to root_url, :alert => I18n.t('group_orders.errors.no_member')
|
||||
end
|
||||
return unless @ordergroup.nil?
|
||||
|
||||
redirect_to root_url, alert: I18n.t('group_orders.errors.no_member')
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
class CurrentOrders::OrdergroupsController < ApplicationController
|
||||
before_action :authenticate_orders
|
||||
before_action :find_group_orders, only: [:index, :show]
|
||||
before_action :find_group_orders, only: %i[index show]
|
||||
|
||||
def index
|
||||
# sometimes need to pass id as parameter for forms
|
||||
|
|
@ -34,8 +34,11 @@ class CurrentOrders::OrdergroupsController < ApplicationController
|
|||
@all_ordergroups.sort_by! { |o| @ordered_group_ids.include?(o.id) ? o.name : "ZZZZZ#{o.name}" }
|
||||
|
||||
@ordergroup = Ordergroup.find(params[:id]) unless params[:id].nil?
|
||||
@goas = GroupOrderArticle.includes(:group_order, :order_article => [:article, :article_price])
|
||||
.where(group_orders: { order_id: @order_ids, ordergroup_id: @ordergroup.id }).ordered.all unless @ordergroup.nil?
|
||||
return if @ordergroup.nil?
|
||||
|
||||
@goas = GroupOrderArticle.includes(:group_order, order_article: %i[article article_price])
|
||||
.where(group_orders: { order_id: @order_ids,
|
||||
ordergroup_id: @ordergroup.id }).ordered.all
|
||||
end
|
||||
|
||||
helper_method \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue