mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Fix some more simple rubocop issues
This commit is contained in:
@@ -2,7 +2,7 @@ module Spree
|
||||
module Api
|
||||
module ApiHelpers
|
||||
def required_fields_for(model)
|
||||
required_fields = model._validators.select do |field, validations|
|
||||
required_fields = model._validators.select do |_field, validations|
|
||||
validations.any? { |v| v.is_a?(ActiveModel::Validations::PresenceValidator) }
|
||||
end.map(&:first) # get fields that are invalid
|
||||
# Permalinks presence is validated, but are really automatically generated
|
||||
@@ -87,7 +87,7 @@ module Spree
|
||||
|
||||
def adjustment_attributes
|
||||
[:id, :source_type, :source_id, :adjustable_type, :adjustable_id, :originator_type,
|
||||
:originator_id, :amount, :label, :mandatory, :locked, :eligible, :created_at, :updated_at]
|
||||
:originator_id, :amount, :label, :mandatory, :locked, :eligible, :created_at, :updated_at]
|
||||
end
|
||||
|
||||
def creditcard_attributes
|
||||
@@ -118,4 +118,3 @@ module Spree
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -41,6 +41,6 @@ FactoryBot.modify do
|
||||
factory :shipping_method, parent: :base_shipping_method do
|
||||
distributors { [Enterprise.is_distributor.first || FactoryBot.create(:distributor_enterprise)] }
|
||||
display_on ''
|
||||
zones { |a| [] }
|
||||
zones { [] }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -385,7 +385,7 @@ describe Spree::Order do
|
||||
let(:distributor) { create(:distributor_enterprise) }
|
||||
|
||||
let(:order_cycle) do
|
||||
create(:order_cycle).tap do |record|
|
||||
create(:order_cycle).tap do
|
||||
create(:exchange, variants: [v1], incoming: true)
|
||||
create(:exchange, variants: [v1], incoming: false, receiver: distributor)
|
||||
end
|
||||
|
||||
@@ -1,28 +1,34 @@
|
||||
require 'active_support/all'
|
||||
|
||||
module ControllerHacks
|
||||
def api_get(action, params={}, session=nil, flash=nil)
|
||||
def api_get(action, params = {}, session = nil, flash = nil)
|
||||
api_process(action, params, session, flash, "GET")
|
||||
end
|
||||
|
||||
def api_post(action, params={}, session=nil, flash=nil)
|
||||
def api_post(action, params = {}, session = nil, flash = nil)
|
||||
api_process(action, params, session, flash, "POST")
|
||||
end
|
||||
|
||||
def api_put(action, params={}, session=nil, flash=nil)
|
||||
def api_put(action, params = {}, session = nil, flash = nil)
|
||||
api_process(action, params, session, flash, "PUT")
|
||||
end
|
||||
|
||||
def api_delete(action, params={}, session=nil, flash=nil)
|
||||
def api_delete(action, params = {}, session = nil, flash = nil)
|
||||
api_process(action, params, session, flash, "DELETE")
|
||||
end
|
||||
|
||||
def api_process(action, params={}, session=nil, flash=nil, method="get")
|
||||
def api_process(action, params = {}, session = nil, flash = nil, method = "get")
|
||||
scoping = respond_to?(:resource_scoping) ? resource_scoping : {}
|
||||
process(action, params.merge(scoping).reverse_merge!(:use_route => :spree, :format => :json), session, flash, method)
|
||||
process(action,
|
||||
params.
|
||||
merge(scoping).
|
||||
reverse_merge!(use_route: :spree, format: :json),
|
||||
session,
|
||||
flash,
|
||||
method)
|
||||
end
|
||||
end
|
||||
|
||||
RSpec.configure do |config|
|
||||
config.include ControllerHacks, :type => :controller
|
||||
config.include ControllerHacks, type: :controller
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# From: https://robots.thoughtbot.com/better-tests-through-internationalization
|
||||
|
||||
I18n.exception_handler = lambda do |exception, locale, key, options|
|
||||
I18n.exception_handler = lambda do |_exception, _locale, key, _options|
|
||||
raise "missing translation: #{key}"
|
||||
end
|
||||
|
||||
@@ -11,17 +11,17 @@ module OpenFoodNetwork
|
||||
|
||||
shared_examples "modifying product actions are restricted" do
|
||||
it "cannot create a new product if not an admin" do
|
||||
api_post :create, :product => { :name => "Brand new product!" }
|
||||
api_post :create, product: { name: "Brand new product!" }
|
||||
assert_unauthorized!
|
||||
end
|
||||
|
||||
it "cannot update a product" do
|
||||
api_put :update, :id => product.to_param, :product => { :name => "I hacked your store!" }
|
||||
api_put :update, id: product.to_param, product: { name: "I hacked your store!" }
|
||||
assert_unauthorized!
|
||||
end
|
||||
|
||||
it "cannot delete a product" do
|
||||
api_delete :destroy, :id => product.to_param
|
||||
api_delete :destroy, id: product.to_param
|
||||
assert_unauthorized!
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user