Merge pull request #6832 from openfoodfoundation/rails-5-upgrade

Rails 5.0 -> master
This commit is contained in:
Matt-Yorkley
2021-03-11 20:20:36 +01:00
committed by GitHub
58 changed files with 408 additions and 1286 deletions

47
Gemfile
View File

@@ -4,38 +4,15 @@ source 'https://rubygems.org'
ruby "2.4.4"
git_source(:github) { |repo_name| "https://github.com/#{repo_name}.git" }
plugin 'bootboot', '~> 0.1.1' unless Bundler.settings[:frozen]
Plugin.__send__(:load_plugin, 'bootboot') if Plugin.installed?('bootboot')
gem 'rails', '~> 5.0.0'
if ENV['DEPENDENCIES_NEXT']
enable_dual_booting if Plugin.installed?('bootboot')
# This will only be loaded when running
# bundler command prefixed with `DEPENDENCIES_NEXT=1
gem 'rails', '> 5.0', '< 5.1'
gem 'activemerchant', '>= 1.78.0'
gem 'angular-rails-templates', '>= 0.3.0', '< 1.1.0'
gem 'awesome_nested_set'
gem 'rails-controller-testing'
gem 'ransack', '2.3.0'
gem 'responders'
else
gem 'rails', '~> 4.2'
gem 'activemerchant', '~> 1.78.0'
gem 'angular-rails-templates', '~> 0.3.0'
gem 'awesome_nested_set', '~> 3.4.0'
gem 'ransack', '~> 1.8.10'
gem 'responders', '~> 2.0'
gem 'db2fog'
gem 'unicorn'
group :test do
gem 'test_after_commit' # needed to test Devise callbacks
end
end
gem 'activemerchant', '>= 1.78.0'
gem 'angular-rails-templates', '>= 0.3.0'
gem 'awesome_nested_set'
gem 'ransack', '2.3.0'
gem 'responders'
gem 'sass', '<= 4.7.1'
gem 'sass-rails', '< 6.0.0'
gem 'i18n'
gem 'i18n-js', '~> 3.8.1'
@@ -43,6 +20,8 @@ gem 'rails-i18n'
gem 'rails_safe_tasks', '~> 1.0'
gem "activerecord-import"
gem "db2fog", github: "openfoodfoundation/db2fog", branch: "rails-5"
gem "fog-aws", ">= 0.6.0"
gem "catalog", path: "./engines/catalog"
gem 'dfc_provider', path: './engines/dfc_provider'
@@ -104,7 +83,7 @@ gem 'roadie-rails', '~> 1.3.0'
gem 'combine_pdf'
gem 'wicked_pdf'
gem 'wkhtmltopdf-binary'
gem 'wkhtmltopdf-binary', '0.12.5' # We need to upgrade our CI before we can bump this :/
gem 'immigrant'
gem 'roo', '~> 2.8.3'
@@ -116,15 +95,12 @@ gem 'test-unit', '~> 3.4'
gem 'coffee-rails', '~> 4.2.2'
gem 'compass-rails'
gem 'libv8', '< 8'
gem 'mini_racer', '0.2.15'
gem 'uglifier', '>= 1.0.3'
gem 'angular_rails_csrf'
gem 'foundation-icons-sass-rails'
gem 'sass', '<= 4.7.1'
gem 'sass-rails', '< 6.0.0'
gem 'foundation-rails', '= 5.5.2.1'
@@ -168,6 +144,7 @@ group :test do
gem 'simplecov', require: false
gem 'test-prof'
gem 'webmock'
gem 'rails-controller-testing'
# See spec/spec_helper.rb for instructions
# gem 'perftools.rb'
end

View File

@@ -4,6 +4,16 @@ GIT
specs:
custom_error_message (1.1.1)
GIT
remote: https://github.com/openfoodfoundation/db2fog.git
revision: 8ceef362c64e6573d62d26db5ebb0c0f33cd3d61
branch: rails-5
specs:
db2fog (0.9.1)
activerecord (>= 3.2.0, < 6.0)
fog-core (~> 1.0)
rails (>= 3.2.0, < 6.0)
GIT
remote: https://github.com/openfoodfoundation/ofn-qz.git
revision: 467f6ea1c44529c7c91cac4c8211bbd863588c0b
@@ -37,46 +47,48 @@ PATH
GEM
remote: https://rubygems.org/
specs:
CFPropertyList (2.3.6)
actionmailer (4.2.11.3)
actionpack (= 4.2.11.3)
actionview (= 4.2.11.3)
activejob (= 4.2.11.3)
actioncable (5.0.7.2)
actionpack (= 5.0.7.2)
nio4r (>= 1.2, < 3.0)
websocket-driver (~> 0.6.1)
actionmailer (5.0.7.2)
actionpack (= 5.0.7.2)
actionview (= 5.0.7.2)
activejob (= 5.0.7.2)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 1.0, >= 1.0.5)
actionpack (4.2.11.3)
actionview (= 4.2.11.3)
activesupport (= 4.2.11.3)
rack (~> 1.6)
rack-test (~> 0.6.2)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-dom-testing (~> 2.0)
actionpack (5.0.7.2)
actionview (= 5.0.7.2)
activesupport (= 5.0.7.2)
rack (~> 2.0)
rack-test (~> 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionpack-action_caching (1.2.1)
actionpack (>= 4.0.0)
actionview (4.2.11.3)
activesupport (= 4.2.11.3)
actionview (5.0.7.2)
activesupport (= 5.0.7.2)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
active_model_serializers (0.8.4)
activemodel (>= 3.0)
activejob (4.2.11.3)
activesupport (= 4.2.11.3)
globalid (>= 0.3.0)
activemerchant (1.78.0)
activesupport (>= 3.2.14, < 6.x)
activejob (5.0.7.2)
activesupport (= 5.0.7.2)
globalid (>= 0.3.6)
activemerchant (1.107.4)
activesupport (>= 4.2)
builder (>= 2.1.2, < 4.0.0)
i18n (>= 0.6.9)
nokogiri (~> 1.4)
activemodel (4.2.11.3)
activesupport (= 4.2.11.3)
builder (~> 3.1)
activerecord (4.2.11.3)
activemodel (= 4.2.11.3)
activesupport (= 4.2.11.3)
arel (~> 6.0)
activerecord-import (1.0.8)
activemodel (5.0.7.2)
activesupport (= 5.0.7.2)
activerecord (5.0.7.2)
activemodel (= 5.0.7.2)
activesupport (= 5.0.7.2)
arel (~> 7.0)
activerecord-import (1.0.7)
activerecord (>= 3.2)
activerecord-postgresql-adapter (0.0.1)
pg
@@ -86,10 +98,10 @@ GEM
multi_json (~> 1.11, >= 1.11.2)
rack (>= 1.5.2, < 3)
railties (>= 4.0)
activesupport (4.2.11.3)
i18n (~> 0.7)
activesupport (5.0.7.2)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
acts-as-taggable-on (4.0.0)
activerecord (>= 4.0)
@@ -97,19 +109,16 @@ GEM
activerecord (>= 3.0)
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
aliyun-sdk (0.8.0)
nokogiri (~> 1.6)
rest-client (~> 2.0)
andand (1.3.3)
angular-rails-templates (0.3.0)
railties (>= 3.1)
sprockets (~> 2.0)
angular-rails-templates (1.1.0)
railties (>= 4.2, < 7)
sprockets (>= 3.0, < 5)
tilt
angular_rails_csrf (4.2.0)
railties (>= 3, < 7)
angularjs-file-upload-rails (2.4.1)
angularjs-rails (1.5.5)
arel (6.0.4)
arel (7.1.4)
ast (2.4.2)
atomic (1.1.101)
awesome_nested_set (3.4.0)
@@ -165,10 +174,8 @@ GEM
sass (>= 3.3.0, < 3.5)
compass-import-once (1.0.5)
sass (>= 3.2, < 3.5)
compass-rails (4.0.0)
compass-rails (2.0.1)
compass (~> 1.0.0)
sass-rails (< 5.1)
sprockets (< 4.0)
concurrent-ruby (1.1.8)
crack (0.4.5)
rexml
@@ -178,10 +185,6 @@ GEM
daemons (1.3.1)
dalli (2.7.11)
database_cleaner (1.99.0)
db2fog (0.9.0)
activerecord (>= 3.2.0, < 5.0)
fog (~> 1.0)
rails (>= 3.2.0, < 5.0)
ddtrace (0.46.0)
msgpack
debugger-linecache (1.2.0)
@@ -207,12 +210,9 @@ GEM
devise (>= 4.0.0, < 5.0.0)
diff-lcs (1.4.4)
docile (1.3.4)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
dry-inflector (0.1.2)
erubis (2.7.0)
eventmachine (1.2.7)
excon (0.78.0)
excon (0.79.0)
execjs (2.7.0)
factory_bot (5.2.0)
activesupport (>= 4.2.0)
@@ -225,153 +225,18 @@ GEM
ffi (1.13.1)
figaro (1.2.0)
thor (>= 0.14.0, < 2)
fission (0.5.0)
CFPropertyList (~> 2.2)
fog (1.41.0)
fog-aliyun (>= 0.1.0)
fog-atmos
fog-aws (>= 0.6.0)
fog-brightbox (~> 0.4)
fog-cloudatcost (~> 0.1.0)
fog-core (~> 1.45)
fog-digitalocean (>= 0.3.0)
fog-dnsimple (~> 1.0)
fog-dynect (~> 0.0.2)
fog-ecloud (~> 0.1)
fog-google (<= 0.1.0)
fog-internet-archive
fog-joyent
fog-json
fog-local
fog-openstack
fog-powerdns (>= 0.1.1)
fog-profitbricks
fog-rackspace
fog-radosgw (>= 0.0.2)
fog-riakcs
fog-sakuracloud (>= 0.0.4)
fog-serverlove
fog-softlayer
fog-storm_on_demand
fog-terremark
fog-vmfusion
fog-voxel
fog-vsphere (>= 0.4.0)
fog-xenserver
fog-xml (~> 0.1.1)
ipaddress (~> 0.5)
json (>= 1.8, < 2.0)
fog-aliyun (0.3.19)
aliyun-sdk (~> 0.8.0)
fog-core
fog-json
ipaddress (~> 0.8)
xml-simple (~> 1.1)
fog-atmos (0.1.0)
fog-core
fog-xml
fog-aws (2.0.1)
fog-core (~> 1.38)
fog-json (~> 1.0)
fog-xml (~> 0.1)
ipaddress (~> 0.8)
fog-brightbox (0.16.1)
dry-inflector
fog-core
fog-json
mime-types
fog-cloudatcost (0.1.2)
fog-core (~> 1.36)
fog-json (~> 1.0)
fog-xml (~> 0.1)
ipaddress (~> 0.8)
fog-core (1.45.0)
builder
excon (~> 0.58)
formatador (~> 0.2)
fog-digitalocean (0.4.0)
fog-core
fog-json
fog-xml
ipaddress (>= 0.5)
fog-dnsimple (1.0.0)
fog-core (~> 1.38)
fog-json (~> 1.0)
fog-dynect (0.0.3)
fog-core
fog-json
fog-xml
fog-ecloud (0.3.0)
fog-core
fog-xml
fog-google (0.1.0)
fog-core
fog-json
fog-xml
fog-internet-archive (0.0.2)
fog-core
fog-json
fog-xml
fog-joyent (0.0.1)
fog-core (~> 1.42)
fog-json (>= 1.0)
fog-json (1.2.0)
fog-core
multi_json (~> 1.10)
fog-local (0.6.0)
fog-core (>= 1.27, < 3.0)
fog-openstack (0.3.10)
fog-core (>= 1.45, <= 2.1.0)
fog-json (>= 1.0)
ipaddress (>= 0.8)
fog-powerdns (0.2.0)
fog-core
fog-json
fog-xml
fog-profitbricks (4.1.1)
fog-core (~> 1.42)
fog-json (~> 1.0)
fog-rackspace (0.1.6)
fog-core (>= 1.35)
fog-json (>= 1.0)
fog-xml (>= 0.1)
ipaddress (>= 0.8)
fog-radosgw (0.0.5)
fog-core (>= 1.21.0)
fog-json
fog-xml (>= 0.0.1)
fog-riakcs (0.1.0)
fog-core
fog-json
fog-xml
fog-sakuracloud (1.7.5)
fog-core
fog-json
fog-serverlove (0.1.2)
fog-core
fog-json
fog-softlayer (1.1.4)
fog-core
fog-json
fog-storm_on_demand (0.1.1)
fog-core
fog-json
fog-terremark (0.1.0)
fog-core
fog-xml
fog-vmfusion (0.1.0)
fission
fog-core
fog-voxel (0.1.0)
fog-core
fog-xml
fog-vsphere (3.4.0)
fog-core
rbvmomi (>= 1.9, < 3)
fog-xenserver (1.0.0)
fog-core
fog-xml
xmlrpc
fog-xml (0.1.3)
fog-core
nokogiri (>= 1.5.11, < 2.0.0)
@@ -399,11 +264,7 @@ GEM
tilt
hashdiff (1.0.1)
highline (2.0.3)
hike (1.2.3)
http-accept (1.7.0)
http-cookie (1.0.3)
domain_name (~> 0.5)
i18n (0.9.5)
i18n (1.8.5)
concurrent-ruby (~> 1.0)
i18n-js (3.8.1)
i18n (>= 0.6.6)
@@ -443,7 +304,7 @@ GEM
addressable (~> 2.3)
letter_opener (1.7.0)
launchy (~> 2.2)
libv8 (7.3.492.27.1)
libv8 (8.4.255.0)
loofah (2.9.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
@@ -452,7 +313,7 @@ GEM
method_source (1.0.0)
mime-types (3.3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2020.0512)
mime-types-data (3.2020.1104)
mini_mime (1.0.2)
mini_portile2 (2.4.0)
mini_racer (0.2.15)
@@ -466,7 +327,9 @@ GEM
multi_json (1.15.0)
multi_xml (0.6.0)
multipart-post (2.1.1)
netrc (0.11.0)
mustermann (1.1.1)
ruby2_keywords (~> 0.0.1)
nio4r (2.5.2)
nokogiri (1.10.10)
mini_portile2 (~> 2.4.0)
oauth2 (1.4.4)
@@ -475,7 +338,6 @@ GEM
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (>= 1.2, < 3)
optimist (3.0.1)
orm_adapter (0.5.0)
paper_trail (10.3.1)
activerecord (>= 4.2)
@@ -497,6 +359,8 @@ GEM
paypal-sdk-merchant (1.117.2)
paypal-sdk-core (~> 0.3.0)
pg (0.21.0)
polyamorous (2.3.0)
activerecord (>= 5.0)
power_assert (2.0.0)
pry (0.13.1)
coderay (~> 1.1)
@@ -505,60 +369,59 @@ GEM
byebug (~> 11.0)
pry (~> 0.13.0)
public_suffix (4.0.6)
rack (1.6.13)
rack (2.2.3)
rack-mini-profiler (2.3.1)
rack (>= 1.2.0)
rack-protection (1.5.5)
rack-protection (2.1.0)
rack
rack-rewrite (1.5.1)
rack-ssl (1.4.1)
rack
rack-test (0.6.3)
rack (>= 1.0)
rails (4.2.11.3)
actionmailer (= 4.2.11.3)
actionpack (= 4.2.11.3)
actionview (= 4.2.11.3)
activejob (= 4.2.11.3)
activemodel (= 4.2.11.3)
activerecord (= 4.2.11.3)
activesupport (= 4.2.11.3)
bundler (>= 1.3.0, < 2.0)
railties (= 4.2.11.3)
sprockets-rails
rails-deprecated_sanitizer (1.0.4)
activesupport (>= 4.2.0.alpha)
rails-dom-testing (1.0.9)
activesupport (>= 4.2.0, < 5.0)
nokogiri (~> 1.6)
rails-deprecated_sanitizer (>= 1.0.1)
rails (5.0.7.2)
actioncable (= 5.0.7.2)
actionmailer (= 5.0.7.2)
actionpack (= 5.0.7.2)
actionview (= 5.0.7.2)
activejob (= 5.0.7.2)
activemodel (= 5.0.7.2)
activerecord (= 5.0.7.2)
activesupport (= 5.0.7.2)
bundler (>= 1.3.0)
railties (= 5.0.7.2)
sprockets-rails (>= 2.0.0)
rails-controller-testing (1.0.5)
actionpack (>= 5.0.1.rc1)
actionview (>= 5.0.1.rc1)
activesupport (>= 5.0.1.rc1)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.3.0)
loofah (~> 2.3)
rails-i18n (4.0.9)
i18n (~> 0.7)
railties (~> 4.0)
rails-i18n (5.1.3)
i18n (>= 0.7, < 2)
railties (>= 5.0, < 6)
rails_safe_tasks (1.0.0)
railties (4.2.11.3)
actionpack (= 4.2.11.3)
activesupport (= 4.2.11.3)
railties (5.0.7.2)
actionpack (= 5.0.7.2)
activesupport (= 5.0.7.2)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rainbow (3.0.0)
raindrops (0.19.1)
rake (13.0.3)
ransack (1.8.10)
actionpack (>= 3.0, < 5.2)
activerecord (>= 3.0, < 5.2)
activesupport (>= 3.0, < 5.2)
ransack (2.3.0)
actionpack (>= 5.0)
activerecord (>= 5.0)
activesupport (>= 5.0)
i18n
polyamorous (= 2.3.0)
rb-fsevent (0.10.4)
rb-inotify (0.10.1)
ffi (~> 1.0)
rbvmomi (2.4.1)
builder (~> 3.0)
json (>= 1.8)
nokogiri (~> 1.5)
optimist (~> 3.0)
redcarpet (3.5.1)
regexp_parser (1.8.2)
request_store (1.5.0)
@@ -566,11 +429,6 @@ GEM
responders (2.4.1)
actionpack (>= 4.2.0, < 6.0)
railties (>= 4.2.0, < 6.0)
rest-client (2.1.0)
http-accept (>= 1.7.0, < 2.0)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
rexml (3.2.4)
roadie (3.5.1)
css_parser (~> 1.4)
@@ -634,6 +492,7 @@ GEM
rubocop (>= 0.90.0, < 2.0)
ruby-progressbar (1.11.0)
ruby-rc4 (0.1.5)
ruby2_keywords (0.0.2)
rubyzip (2.3.0)
sass (3.4.25)
sass-rails (5.0.7)
@@ -654,22 +513,21 @@ GEM
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov-html (0.12.3)
sinatra (1.4.8)
rack (~> 1.5)
rack-protection (~> 1.4)
tilt (>= 1.3, < 3)
sinatra (2.1.0)
mustermann (~> 1.0)
rack (~> 2.2)
rack-protection (= 2.1.0)
tilt (~> 2.0)
spring (2.1.1)
spring-commands-rspec (1.0.4)
spring (>= 0.9.1)
sprockets (2.12.5)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sprockets-rails (2.3.3)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
sprockets (3.7.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.2)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
state_machines (0.5.0)
state_machines-activemodel (0.7.1)
activemodel (>= 4.1)
@@ -683,19 +541,14 @@ GEM
test-prof (0.11.3)
test-unit (3.4.0)
power_assert
test_after_commit (1.2.2)
activerecord (>= 3.2, < 5.0)
thor (0.20.3)
thread_safe (0.3.6)
tilt (1.4.1)
tilt (2.0.10)
timecop (0.9.4)
tzinfo (1.2.9)
thread_safe (~> 0.1)
uglifier (4.2.0)
execjs (>= 0.3.0, < 3)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.7)
unicode-display_width (2.0.0)
unicorn (5.8.0)
kgio (~> 2.6)
@@ -707,8 +560,8 @@ GEM
get_process_mem (~> 0)
unicorn (>= 4, < 6)
uniform_notifier (1.14.1)
warden (1.2.7)
rack (>= 1.0)
warden (1.2.9)
rack (>= 2.0.9)
webdrivers (4.6.0)
nokogiri (~> 1.6)
rubyzip (>= 1.3.0)
@@ -717,13 +570,15 @@ GEM
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
whenever (1.0.0)
chronic (>= 0.6.3)
wicked_pdf (2.1.0)
activesupport
wkhtmltopdf-binary (0.12.5)
xml-simple (1.1.8)
xmlrpc (0.3.0)
xpath (3.2.0)
nokogiri (~> 1.8)
@@ -733,19 +588,19 @@ PLATFORMS
DEPENDENCIES
actionpack-action_caching
active_model_serializers (= 0.8.4)
activemerchant (~> 1.78.0)
activemerchant (>= 1.78.0)
activerecord-import
activerecord-postgresql-adapter
activerecord-session_store
acts-as-taggable-on (~> 4.0)
acts_as_list (= 0.9.19)
andand
angular-rails-templates (~> 0.3.0)
angular-rails-templates (>= 0.3.0)
angular_rails_csrf
angularjs-file-upload-rails (~> 2.4.1)
angularjs-rails (= 1.5.5)
atomic
awesome_nested_set (~> 3.4.0)
awesome_nested_set
awesome_print
aws-sdk (= 1.67.0)
bugsnag
@@ -761,7 +616,7 @@ DEPENDENCIES
daemons
dalli
database_cleaner
db2fog
db2fog!
ddtrace
debugger-linecache
delayed_job_active_record
@@ -774,6 +629,7 @@ DEPENDENCIES
factory_bot_rails (= 5.2.0)
ffaker
figaro
fog-aws (>= 0.6.0)
foundation-icons-sass-rails
foundation-rails (= 5.5.2.1)
fuubar (~> 2.5.1)
@@ -794,7 +650,6 @@ DEPENDENCIES
kaminari (~> 1.2.1)
knapsack
letter_opener (>= 1.4.1)
libv8 (< 8)
mini_racer (= 0.2.15)
monetize (~> 1.10)
oauth2 (~> 1.4.4)
@@ -810,12 +665,13 @@ DEPENDENCIES
rack-mini-profiler (< 3.0.0)
rack-rewrite
rack-ssl
rails (~> 4.2)
rails (~> 5.0.0)
rails-controller-testing
rails-i18n
rails_safe_tasks (~> 1.0)
ransack (~> 1.8.10)
ransack (= 2.3.0)
redcarpet
responders (~> 2.0)
responders
roadie-rails (~> 1.3.0)
roo (~> 2.8.3)
rspec-rails (>= 3.5.2)
@@ -836,10 +692,8 @@ DEPENDENCIES
stripe
test-prof
test-unit (~> 3.4)
test_after_commit
timecop
uglifier (>= 1.0.3)
unicorn
unicorn-rails
unicorn-worker-killer
web!
@@ -847,7 +701,7 @@ DEPENDENCIES
webmock
whenever
wicked_pdf
wkhtmltopdf-binary
wkhtmltopdf-binary (= 0.12.5)
RUBY VERSION
ruby 2.4.4p296

View File

@@ -1,680 +0,0 @@
GIT
remote: https://github.com/jeremydurham/custom-err-msg.git
revision: 3a8ec9dddc7a5b0aab7c69a6060596de300c68f4
specs:
custom_error_message (1.1.1)
GIT
remote: https://github.com/openfoodfoundation/ofn-qz.git
revision: 467f6ea1c44529c7c91cac4c8211bbd863588c0b
branch: ofn-rails-4
specs:
ofn-qz (0.1.0)
PATH
remote: engines/catalog
specs:
catalog (0.0.1)
PATH
remote: engines/dfc_provider
specs:
dfc_provider (0.0.1)
active_model_serializers (~> 0.8.4)
jwt (~> 2.2)
rspec (~> 3.9)
PATH
remote: engines/order_management
specs:
order_management (0.0.1)
PATH
remote: engines/web
specs:
web (0.0.1)
GEM
remote: https://rubygems.org/
specs:
actioncable (5.0.7.2)
actionpack (= 5.0.7.2)
nio4r (>= 1.2, < 3.0)
websocket-driver (~> 0.6.1)
actionmailer (5.0.7.2)
actionpack (= 5.0.7.2)
actionview (= 5.0.7.2)
activejob (= 5.0.7.2)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.0.7.2)
actionview (= 5.0.7.2)
activesupport (= 5.0.7.2)
rack (~> 2.0)
rack-test (~> 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionpack-action_caching (1.2.1)
actionpack (>= 4.0.0)
actionview (5.0.7.2)
activesupport (= 5.0.7.2)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
active_model_serializers (0.8.4)
activemodel (>= 3.0)
activejob (5.0.7.2)
activesupport (= 5.0.7.2)
globalid (>= 0.3.6)
activemerchant (1.107.4)
activesupport (>= 4.2)
builder (>= 2.1.2, < 4.0.0)
i18n (>= 0.6.9)
nokogiri (~> 1.4)
activemodel (5.0.7.2)
activesupport (= 5.0.7.2)
activerecord (5.0.7.2)
activemodel (= 5.0.7.2)
activesupport (= 5.0.7.2)
arel (~> 7.0)
activerecord-import (1.0.7)
activerecord (>= 3.2)
activerecord-postgresql-adapter (0.0.1)
pg
activerecord-session_store (1.1.3)
actionpack (>= 4.0)
activerecord (>= 4.0)
multi_json (~> 1.11, >= 1.11.2)
rack (>= 1.5.2, < 3)
railties (>= 4.0)
activesupport (5.0.7.2)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
acts-as-taggable-on (4.0.0)
activerecord (>= 4.0)
acts_as_list (0.9.19)
activerecord (>= 3.0)
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
andand (1.3.3)
angular-rails-templates (1.0.2)
railties (>= 4.2, < 6)
sprockets (>= 3.0, < 5)
tilt
angular_rails_csrf (4.2.0)
railties (>= 3, < 7)
angularjs-file-upload-rails (2.4.1)
angularjs-rails (1.5.5)
arel (7.1.4)
ast (2.4.1)
atomic (1.1.101)
awesome_nested_set (3.2.1)
activerecord (>= 4.0.0, < 7.0)
awesome_print (1.8.0)
aws-sdk (1.67.0)
aws-sdk-v1 (= 1.67.0)
aws-sdk-v1 (1.67.0)
json (~> 1.4)
nokogiri (~> 1)
bcrypt (3.1.16)
bugsnag (6.18.0)
concurrent-ruby (~> 1.0)
builder (3.2.4)
bullet (6.1.4)
activesupport (>= 3.0.0)
uniform_notifier (~> 1.11)
byebug (11.0.1)
cancancan (1.7.1)
capybara (3.15.0)
addressable
mini_mime (>= 0.1.3)
nokogiri (~> 1.8)
rack (>= 1.6.0)
rack-test (>= 0.6.3)
regexp_parser (~> 1.2)
xpath (~> 3.2)
childprocess (3.0.0)
chronic (0.10.2)
chunky_png (1.3.14)
climate_control (0.2.0)
cocaine (0.5.8)
climate_control (>= 0.0.3, < 1.0)
coderay (1.1.3)
coffee-rails (4.2.2)
coffee-script (>= 2.2.0)
railties (>= 4.0.0)
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.12.2)
combine_pdf (1.0.19)
ruby-rc4 (>= 0.1.5)
compass (1.0.3)
chunky_png (~> 1.2)
compass-core (~> 1.0.2)
compass-import-once (~> 1.0.5)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9)
sass (>= 3.3.13, < 3.5)
compass-core (1.0.3)
multi_json (~> 1.0)
sass (>= 3.3.0, < 3.5)
compass-import-once (1.0.5)
sass (>= 3.2, < 3.5)
compass-rails (2.0.1)
compass (~> 1.0.0)
concurrent-ruby (1.1.8)
crack (0.4.4)
crass (1.0.6)
css_parser (1.7.1)
addressable
daemons (1.3.1)
dalli (2.7.11)
database_cleaner (1.8.5)
ddtrace (0.43.0)
msgpack
debugger-linecache (1.2.0)
delayed_job (4.1.8)
activesupport (>= 3.0, < 6.1)
delayed_job_active_record (4.1.4)
activerecord (>= 3.0, < 6.1)
delayed_job (>= 3.0, < 5)
delayed_job_web (1.4.3)
activerecord (> 3.0.0)
delayed_job (> 2.0.3)
rack-protection (>= 1.5.5)
sinatra (>= 1.4.4)
devise (4.7.3)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0)
responders
warden (~> 1.2.3)
devise-encryptable (0.2.0)
devise (>= 2.1.0)
devise-token_authenticatable (1.1.0)
devise (>= 4.0.0, < 5.0.0)
diff-lcs (1.4.4)
docile (1.3.2)
erubis (2.7.0)
eventmachine (1.2.7)
execjs (2.7.0)
factory_bot (5.2.0)
activesupport (>= 4.2.0)
factory_bot_rails (5.2.0)
factory_bot (~> 5.2.0)
railties (>= 4.2.0)
faraday (1.0.1)
multipart-post (>= 1.2, < 3)
ffaker (2.11.0)
ffi (1.13.1)
figaro (1.2.0)
thor (>= 0.14.0, < 2)
foundation-icons-sass-rails (3.0.0)
railties (>= 3.1.1)
sass-rails (>= 3.1.1)
foundation-rails (5.5.2.1)
railties (>= 3.1.0)
sass (>= 3.3.0, < 3.5)
fuubar (2.5.1)
rspec-core (~> 3.0)
ruby-progressbar (~> 1.4)
geocoder (1.6.4)
get_process_mem (0.2.7)
ffi (~> 1.0)
globalid (0.4.2)
activesupport (>= 4.2.0)
gmaps4rails (2.1.2)
good_migrations (0.0.2)
activerecord (>= 3.1)
railties (>= 3.1)
haml (5.2.0)
temple (>= 0.8.0)
tilt
hashdiff (1.0.1)
highline (2.0.3)
i18n (1.8.7)
concurrent-ruby (~> 1.0)
i18n-js (3.8.0)
i18n (>= 0.6.6)
immigrant (0.3.6)
activerecord (>= 3.0)
jaro_winkler (1.5.4)
jquery-migrate-rails (1.2.1)
jquery-rails (4.4.0)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
jquery-ui-rails (4.2.1)
railties (>= 3.2.16)
json (1.8.6)
json-schema (2.8.1)
addressable (>= 2.4)
json_spec (1.1.5)
multi_json (~> 1.0)
rspec (>= 2.0, < 4.0)
jwt (2.2.2)
kaminari (1.2.1)
activesupport (>= 4.1.0)
kaminari-actionview (= 1.2.1)
kaminari-activerecord (= 1.2.1)
kaminari-core (= 1.2.1)
kaminari-actionview (1.2.1)
actionview
kaminari-core (= 1.2.1)
kaminari-activerecord (1.2.1)
activerecord
kaminari-core (= 1.2.1)
kaminari-core (1.2.1)
kgio (2.11.3)
knapsack (1.20.0)
rake
launchy (2.4.3)
addressable (~> 2.3)
letter_opener (1.7.0)
launchy (~> 2.2)
libv8 (7.3.492.27.1)
loofah (2.9.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.1)
mini_mime (>= 0.1.1)
method_source (1.0.0)
mime-types (3.3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2020.1104)
mini_mime (1.0.2)
mini_portile2 (2.4.0)
mini_racer (0.2.15)
libv8 (> 7.3)
minitest (5.14.3)
monetize (1.10.0)
money (~> 6.12)
money (6.14.0)
i18n (>= 0.6.4, <= 2)
msgpack (1.3.3)
multi_json (1.15.0)
multi_xml (0.6.0)
multipart-post (2.1.1)
mustermann (1.1.1)
ruby2_keywords (~> 0.0.1)
nio4r (2.5.2)
nokogiri (1.10.10)
mini_portile2 (~> 2.4.0)
oauth2 (1.4.4)
faraday (>= 0.8, < 2.0)
jwt (>= 1.0, < 3.0)
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (>= 1.2, < 3)
orm_adapter (0.5.0)
paper_trail (10.3.1)
activerecord (>= 4.2)
request_store (~> 1.1)
paperclip (3.4.2)
activemodel (>= 3.0.0)
activerecord (>= 3.0.0)
activesupport (>= 3.0.0)
cocaine (~> 0.5.0)
mime-types
parallel (1.19.2)
paranoia (2.4.2)
activerecord (>= 4.0, < 6.1)
parser (2.7.2.0)
ast (~> 2.4.1)
paypal-sdk-core (0.3.4)
multi_json (~> 1.0)
xml-simple
paypal-sdk-merchant (1.117.2)
paypal-sdk-core (~> 0.3.0)
pg (0.21.0)
polyamorous (2.3.0)
activerecord (>= 5.0)
power_assert (1.2.0)
pry (0.13.1)
coderay (~> 1.1)
method_source (~> 1.0)
pry-byebug (3.9.0)
byebug (~> 11.0)
pry (~> 0.13.0)
public_suffix (4.0.6)
rack (2.2.3)
rack-mini-profiler (2.0.2)
rack (>= 1.2.0)
rack-protection (2.1.0)
rack
rack-rewrite (1.5.1)
rack-ssl (1.4.1)
rack
rack-test (0.6.3)
rack (>= 1.0)
rails (5.0.7.2)
actioncable (= 5.0.7.2)
actionmailer (= 5.0.7.2)
actionpack (= 5.0.7.2)
actionview (= 5.0.7.2)
activejob (= 5.0.7.2)
activemodel (= 5.0.7.2)
activerecord (= 5.0.7.2)
activesupport (= 5.0.7.2)
bundler (>= 1.3.0)
railties (= 5.0.7.2)
sprockets-rails (>= 2.0.0)
rails-controller-testing (1.0.5)
actionpack (>= 5.0.1.rc1)
actionview (>= 5.0.1.rc1)
activesupport (>= 5.0.1.rc1)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.3.0)
loofah (~> 2.3)
rails-i18n (5.1.3)
i18n (>= 0.7, < 2)
railties (>= 5.0, < 6)
rails_safe_tasks (1.0.0)
railties (5.0.7.2)
actionpack (= 5.0.7.2)
activesupport (= 5.0.7.2)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rainbow (3.0.0)
raindrops (0.19.1)
rake (13.0.3)
ransack (2.3.0)
actionpack (>= 5.0)
activerecord (>= 5.0)
activesupport (>= 5.0)
i18n
polyamorous (= 2.3.0)
rb-fsevent (0.10.4)
rb-inotify (0.10.1)
ffi (~> 1.0)
redcarpet (3.5.0)
regexp_parser (1.8.2)
request_store (1.5.0)
rack (>= 1.4)
responders (2.4.1)
actionpack (>= 4.2.0, < 6.0)
railties (>= 4.2.0, < 6.0)
rexml (3.2.4)
roadie (3.5.1)
css_parser (~> 1.4)
nokogiri (~> 1.8)
roadie-rails (1.3.0)
railties (>= 3.0, < 5.3)
roadie (~> 3.1)
roo (2.8.3)
nokogiri (~> 1)
rubyzip (>= 1.3.0, < 3.0.0)
rspec (3.10.0)
rspec-core (~> 3.10.0)
rspec-expectations (~> 3.10.0)
rspec-mocks (~> 3.10.0)
rspec-core (3.10.0)
rspec-support (~> 3.10.0)
rspec-expectations (3.10.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-mocks (3.10.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-rails (4.0.1)
actionpack (>= 4.2)
activesupport (>= 4.2)
railties (>= 4.2)
rspec-core (~> 3.9)
rspec-expectations (~> 3.9)
rspec-mocks (~> 3.9)
rspec-support (~> 3.9)
rspec-retry (0.6.2)
rspec-core (> 3.3)
rspec-support (3.10.0)
rswag (2.3.1)
rswag-api (= 2.3.1)
rswag-specs (= 2.3.1)
rswag-ui (= 2.3.1)
rswag-api (2.3.1)
railties (>= 3.1, < 7.0)
rswag-specs (2.3.1)
activesupport (>= 3.1, < 7.0)
json-schema (~> 2.2)
railties (>= 3.1, < 7.0)
rswag-ui (2.3.1)
actionpack (>= 3.1, < 7.0)
railties (>= 3.1, < 7.0)
rubocop (0.81.0)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
parser (>= 2.7.0.1)
rainbow (>= 2.2.2, < 4.0)
rexml
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 2.0)
rubocop-rails (2.5.2)
activesupport
rack (>= 1.1)
rubocop (>= 0.72.0)
ruby-progressbar (1.10.1)
ruby-rc4 (0.1.5)
ruby2_keywords (0.0.2)
rubyzip (1.3.0)
sass (3.4.25)
sass-rails (5.0.7)
railties (>= 4.0.0, < 6)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
select2-rails (3.4.9)
sass-rails
thor (~> 0.14)
selenium-webdriver (3.142.7)
childprocess (>= 0.5, < 4.0)
rubyzip (>= 1.2.2)
shoulda-matchers (4.0.1)
activesupport (>= 4.2.0)
simplecov (0.17.1)
docile (~> 1.1)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.2)
sinatra (2.1.0)
mustermann (~> 1.0)
rack (~> 2.2)
rack-protection (= 2.1.0)
tilt (~> 2.0)
spring (2.0.2)
activesupport (>= 4.2)
spring-commands-rspec (1.0.4)
spring (>= 0.9.1)
sprockets (3.7.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.2)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
state_machines (0.5.0)
state_machines-activemodel (0.7.1)
activemodel (>= 4.1)
state_machines (>= 0.5.0)
state_machines-activerecord (0.6.0)
activerecord (>= 4.1)
state_machines-activemodel (>= 0.5.0)
stringex (2.8.5)
stripe (5.28.0)
temple (0.8.2)
test-prof (0.7.5)
test-unit (3.3.7)
power_assert
thor (0.20.3)
thread_safe (0.3.6)
tilt (2.0.10)
timecop (0.9.2)
tzinfo (1.2.9)
thread_safe (~> 0.1)
uglifier (4.2.0)
execjs (>= 0.3.0, < 3)
unicode-display_width (1.7.0)
unicorn (5.7.0)
kgio (~> 2.6)
raindrops (~> 0.7)
unicorn-rails (2.2.1)
rack
unicorn
unicorn-worker-killer (0.4.4)
get_process_mem (~> 0)
unicorn (>= 4, < 6)
uniform_notifier (1.14.1)
warden (1.2.9)
rack (>= 2.0.9)
webdrivers (4.2.0)
nokogiri (~> 1.6)
rubyzip (>= 1.3.0)
selenium-webdriver (>= 3.0, < 4.0)
webmock (3.10.0)
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
whenever (1.0.0)
chronic (>= 0.6.3)
wicked_pdf (2.1.0)
activesupport
wkhtmltopdf-binary (0.12.6.5)
xml-simple (1.1.8)
xpath (3.2.0)
nokogiri (~> 1.8)
PLATFORMS
ruby
DEPENDENCIES
actionpack-action_caching
active_model_serializers (= 0.8.4)
activemerchant (>= 1.78.0)
activerecord-import
activerecord-postgresql-adapter
activerecord-session_store
acts-as-taggable-on (~> 4.0)
acts_as_list (= 0.9.19)
andand
angular-rails-templates (>= 0.3.0, < 1.1.0)
angular_rails_csrf
angularjs-file-upload-rails (~> 2.4.1)
angularjs-rails (= 1.5.5)
atomic
awesome_nested_set
awesome_print
aws-sdk (= 1.67.0)
bugsnag
bullet
byebug
cancancan (~> 1.7.0)
capybara
catalog!
coffee-rails (~> 4.2.2)
combine_pdf
compass-rails
custom_error_message!
daemons
dalli
database_cleaner
ddtrace
debugger-linecache
delayed_job_active_record
delayed_job_web
devise
devise-encryptable
devise-token_authenticatable
dfc_provider!
eventmachine (>= 1.2.3)
factory_bot_rails (= 5.2.0)
ffaker
figaro
foundation-icons-sass-rails
foundation-rails (= 5.5.2.1)
fuubar (~> 2.5.1)
geocoder
gmaps4rails
good_migrations
haml
highline (= 2.0.3)
i18n
i18n-js (~> 3.8.0)
immigrant
jquery-migrate-rails
jquery-rails (= 4.4.0)
jquery-ui-rails (~> 4.2)
json
json_spec (~> 1.1.4)
jwt (~> 2.2)
kaminari (~> 1.2.1)
knapsack
letter_opener (>= 1.4.1)
libv8 (< 8)
mini_racer (= 0.2.15)
monetize (~> 1.10)
oauth2 (~> 1.4.4)
ofn-qz!
order_management!
paper_trail (~> 10.3.1)
paperclip (~> 3.4.1)
paranoia (~> 2.4)
paypal-sdk-merchant (= 1.117.2)
pg (~> 0.21.0)
pry
pry-byebug
rack-mini-profiler (< 3.0.0)
rack-rewrite
rack-ssl
rails (> 5.0, < 5.1)
rails-controller-testing
rails-i18n
rails_safe_tasks (~> 1.0)
ransack (= 2.3.0)
redcarpet
responders
roadie-rails (~> 1.3.0)
roo (~> 2.8.3)
rspec-rails (>= 3.5.2)
rspec-retry
rswag
rubocop
rubocop-rails
sass (<= 4.7.1)
sass-rails (< 6.0.0)
select2-rails (~> 3.4.7)
selenium-webdriver
shoulda-matchers
simplecov
spring
spring-commands-rspec
state_machines-activerecord
stringex (~> 2.8.5)
stripe
test-prof
test-unit (~> 3.3)
timecop
uglifier (>= 1.0.3)
unicorn-rails
unicorn-worker-killer
web!
webdrivers
webmock
whenever
wicked_pdf
wkhtmltopdf-binary
RUBY VERSION
ruby 2.4.4p296
BUNDLED WITH
1.17.3

View File

@@ -10,6 +10,8 @@ module Admin
blank_enterprise_fee = EnterpriseFee.new
blank_enterprise_fee.enterprise = current_enterprise
@collection = @collection.to_a
3.times { @collection << blank_enterprise_fee }
respond_to do |format|

View File

@@ -247,31 +247,31 @@ module Admin
def check_can_change_sells
unless spree_current_user.admin? || spree_current_user == @enterprise.owner
params[:enterprise].delete :sells
enterprise_params.delete :sells
end
end
def override_owner
params[:enterprise][:owner_id] = spree_current_user.id unless spree_current_user.admin?
enterprise_params[:owner_id] = spree_current_user.id unless spree_current_user.admin?
end
def override_sells
unless spree_current_user.admin?
has_hub = spree_current_user.owned_enterprises.is_hub.any?
new_enterprise_is_producer = Enterprise.new(enterprise_params).is_primary_producer
params[:enterprise][:sells] = has_hub && !new_enterprise_is_producer ? 'any' : 'none'
enterprise_params[:sells] = has_hub && !new_enterprise_is_producer ? 'any' : 'none'
end
end
def check_can_change_owner
unless ( spree_current_user == @enterprise.owner ) || spree_current_user.admin?
params[:enterprise].delete :owner_id
enterprise_params.delete :owner_id
end
end
def check_can_change_bulk_owner
unless spree_current_user.admin?
params[:sets_enterprise_set][:collection_attributes].each do |_i, enterprise_params|
bulk_params[:collection_attributes].each do |_i, enterprise_params|
enterprise_params.delete :owner_id
end
end
@@ -279,15 +279,15 @@ module Admin
def check_can_change_managers
unless ( spree_current_user == @enterprise.owner ) || spree_current_user.admin?
params[:enterprise].delete :user_ids
enterprise_params.delete :user_ids
end
end
def strip_new_properties
unless spree_current_user.admin? || params[:enterprise][:producer_properties_attributes].nil?
unless spree_current_user.admin? || params.dig(:enterprise, :producer_properties_attributes).nil?
names = Spree::Property.pluck(:name)
params[:enterprise][:producer_properties_attributes].each do |key, property|
params[:enterprise][:producer_properties_attributes].delete key unless names.include? property[:property_name]
enterprise_params[:producer_properties_attributes].each do |key, property|
enterprise_params[:producer_properties_attributes].delete key unless names.include? property[:property_name]
end
end
end
@@ -319,13 +319,14 @@ module Admin
end
def enterprise_params
PermittedAttributes::Enterprise.new(params).call
@enterprise_params ||= PermittedAttributes::Enterprise.new(params).call.
to_h.with_indifferent_access
end
def bulk_params
params.require(:sets_enterprise_set).permit(
@bulk_params ||= params.require(:sets_enterprise_set).permit(
collection_attributes: PermittedAttributes::Enterprise.attributes
)
).to_h.with_indifferent_access
end
# Used in Admin::ResourceController#create

View File

@@ -101,7 +101,7 @@ module Admin
def collection
return Enterprise.where("1=0") unless json_request?
return order_cycles_from_set if params[:order_cycle_set]
return order_cycles_from_set if params[:order_cycle_set].present?
ocs = order_cycles
ocs.undated | ocs.soonest_closing | ocs.soonest_opening | ocs.closed
@@ -126,7 +126,7 @@ module Admin
def order_cycles_as_distributor
OrderCycle.
preload(:schedules).
ransack(params[:q]).
ransack(raw_params[:q]).
result.
involving_managed_distributors_of(spree_current_user).
order('updated_at DESC')
@@ -135,7 +135,7 @@ module Admin
def order_cycles_as_producer
OrderCycle.
preload(:schedules).
ransack(params[:q]).
ransack(raw_params[:q]).
result.
involving_managed_producers_of(spree_current_user).
order('updated_at DESC')
@@ -144,7 +144,7 @@ module Admin
def order_cycles_as_both
OrderCycle.
preload(:schedules).
ransack(params[:q]).
ransack(raw_params[:q]).
result.
visible_by(spree_current_user)
end
@@ -153,9 +153,9 @@ module Admin
if json_request?
# Split ransack params into all those that currently exist and new ones
# to limit returned ocs to recent or undated
orders_close_at_gt = params[:q].andand.delete(:orders_close_at_gt) || 31.days.ago
params[:q] = {
g: [params.delete(:q) || {}, { m: 'or',
orders_close_at_gt = raw_params[:q].andand.delete(:orders_close_at_gt) || 31.days.ago
raw_params[:q] = {
g: [raw_params.delete(:q) || {}, { m: 'or',
orders_close_at_gt: orders_close_at_gt,
orders_close_at_null: true }]
}
@@ -199,27 +199,30 @@ module Admin
end
def remove_protected_attrs
params[:order_cycle].delete :coordinator_id
return if order_cycle_params.blank?
order_cycle_params.delete :coordinator_id
unless Enterprise.managed_by(spree_current_user).include?(@order_cycle.coordinator)
params[:order_cycle].delete_if do |k, _v|
order_cycle_params.delete_if do |k, _v|
[:name, :orders_open_at, :orders_close_at].include? k.to_sym
end
end
end
def remove_unauthorized_bulk_attrs
params[:order_cycle_set][:collection_attributes].each do |i, hash|
def authorized_order_cycles
managed_ids = managed_enterprises.map(&:id)
(order_cycle_bulk_params[:collection_attributes] || []).keep_if do |_index, hash|
order_cycle = OrderCycle.find(hash[:id])
unless Enterprise.managed_by(spree_current_user).include?(order_cycle.andand.coordinator)
params[:order_cycle_set][:collection_attributes].delete i
end
managed_ids.include?(order_cycle.andand.coordinator_id)
end
end
def order_cycles_from_set
remove_unauthorized_bulk_attrs
OrderCycle.where(id: params[:order_cycle_set][:collection_attributes].map{ |_k, v| v[:id] })
return if authorized_order_cycles.blank?
OrderCycle.where(id: authorized_order_cycles.map{ |_k, v| v[:id] })
end
def order_cycle_set
@@ -227,7 +230,7 @@ module Admin
end
def require_order_cycle_set_params
return if params[:order_cycle_set]
return if params[:order_cycle_set].present?
render json: { errors: t('admin.order_cycles.bulk_update.no_data') },
status: :unprocessable_entity
@@ -238,13 +241,14 @@ module Admin
end
def order_cycle_params
PermittedAttributes::OrderCycle.new(params).call
@order_cycle_params ||= PermittedAttributes::OrderCycle.new(params).call.
to_h.with_indifferent_access
end
def order_cycle_bulk_params
params.require(:order_cycle_set).permit(
collection_attributes: [:id] + PermittedAttributes::OrderCycle.basic_attributes
)
).to_h.with_indifferent_access
end
end
end

View File

@@ -57,14 +57,13 @@ module Admin
end
def unpause
params[:subscription][:paused_at] = nil
save_form_and_render
save_form_and_render(true, unpause: true)
end
private
def save_form_and_render(render_issues = true)
form = OrderManagement::Subscriptions::Form.new(@subscription, subscription_params)
def save_form_and_render(render_issues = true, options = {})
form = OrderManagement::Subscriptions::Form.new(@subscription, subscription_params, options)
unless form.save
render json: { errors: form.json_errors }, status: :unprocessable_entity
return
@@ -106,22 +105,22 @@ module Admin
# Wrap :subscription_line_items_attributes in :subscription root
def wrap_nested_attrs
if params[:subscription_line_items].is_a? Array
attributes = params[:subscription_line_items].map do |sli|
if raw_params[:subscription_line_items].is_a? Array
attributes = raw_params[:subscription_line_items].map do |sli|
sli.slice(*SubscriptionLineItem.attribute_names + ["_destroy"])
end
params[:subscription][:subscription_line_items_attributes] = attributes
subscription_params[:subscription_line_items_attributes] = attributes
end
wrap_bill_address_attrs if params[:bill_address]
wrap_ship_address_attrs if params[:ship_address]
end
def wrap_bill_address_attrs
params[:subscription][:bill_address_attributes] = params[:bill_address].slice(*Spree::Address.attribute_names)
subscription_params[:bill_address_attributes] = raw_params[:bill_address].slice(*Spree::Address.attribute_names)
end
def wrap_ship_address_attrs
params[:subscription][:ship_address_attributes] = params[:ship_address].slice(*Spree::Address.attribute_names)
subscription_params[:ship_address_attributes] = raw_params[:ship_address].slice(*Spree::Address.attribute_names)
end
def check_for_open_orders
@@ -141,8 +140,8 @@ module Admin
end
def strip_banned_attrs
params[:subscription].delete :schedule_id
params[:subscription].delete :customer_id
subscription_params.delete :schedule_id
subscription_params.delete :customer_id
end
# Overriding Spree method to load data from params here so that
@@ -156,7 +155,8 @@ module Admin
end
def subscription_params
PermittedAttributes::Subscription.new(params).call
@subscription_params ||= PermittedAttributes::Subscription.new(params).call.
to_h.with_indifferent_access
end
end
end

View File

@@ -103,13 +103,13 @@ module Admin
end
def variant_overrides_params
params.require(:variant_overrides).map do |variant_override|
variant_override.permit(
params.permit(
variant_overrides: [
:id, :variant_id, :hub_id,
:price, :count_on_hand, :sku, :on_demand,
:default_stock, :resettable, :tag_list
)
end
]
).to_h[:variant_overrides]
end
end
end

View File

@@ -4,6 +4,7 @@ require "spree/core/controller_helpers/ssl"
module Api
class BaseController < ActionController::Metal
include RawParams
include ActionController::StrongParameters
include ActionController::RespondWith
include Spree::Api::ControllerSetup

View File

@@ -11,7 +11,7 @@ module Api
# params[:user_ids] breaks the enterprise creation
# We remove them from params and save them after creating the enterprise
user_ids = params[:enterprise].delete(:user_ids)
user_ids = enterprise_params.delete(:user_ids)
@enterprise = Enterprise.new(enterprise_params)
if @enterprise.save
@enterprise.user_ids = user_ids
@@ -48,30 +48,31 @@ module Api
private
def override_owner
params[:enterprise][:owner_id] = current_api_user.id
enterprise_params[:owner_id] = current_api_user.id
end
def check_type
params[:enterprise].delete :type unless current_api_user.admin?
enterprise_params.delete :type unless current_api_user.admin?
end
def override_sells
has_hub = current_api_user.owned_enterprises.is_hub.any?
new_enterprise_is_producer = !!params[:enterprise][:is_primary_producer]
new_enterprise_is_producer = !!enterprise_params[:is_primary_producer]
params[:enterprise][:sells] = if has_hub && !new_enterprise_is_producer
'any'
else
'unspecified'
end
enterprise_params[:sells] = if has_hub && !new_enterprise_is_producer
'any'
else
'unspecified'
end
end
def override_visible
params[:enterprise][:visible] = false
enterprise_params[:visible] = false
end
def enterprise_params
PermittedAttributes::Enterprise.new(params).call
@enterprise_params ||= PermittedAttributes::Enterprise.new(params).call.
to_h.with_indifferent_access
end
end
end

View File

@@ -18,7 +18,7 @@ module Api
# In this case parameters are: enterprise_id, order_cycle_id and incoming
# (order_cycle_id is not necessary for incoming exchanges)
def index
if params[:exchange_id].present?
if exchange_params[:exchange_id].present?
load_data_from_exchange
else
load_data_from_other_params
@@ -59,7 +59,7 @@ module Api
end
def load_data_from_exchange
exchange = Exchange.find_by(id: params[:exchange_id])
exchange = Exchange.find_by(id: exchange_params[:exchange_id])
@order_cycle = exchange.order_cycle
@incoming = exchange.incoming
@@ -67,14 +67,16 @@ module Api
end
def load_data_from_other_params
@enterprise = Enterprise.find_by(id: params[:enterprise_id])
@enterprise = Enterprise.find_by(id: exchange_params[:enterprise_id])
if params[:order_cycle_id]
@order_cycle = OrderCycle.find_by(id: params[:order_cycle_id])
elsif !params[:incoming]
# This will be a string (eg "true") when it arrives via params, but we want a boolean
@incoming = ActiveModel::Type::Boolean.new.cast exchange_params[:incoming]
if exchange_params[:order_cycle_id]
@order_cycle = OrderCycle.find_by(id: exchange_params[:order_cycle_id])
elsif !@incoming
raise "order_cycle_id is required to list products for new outgoing exchange"
end
@incoming = params[:incoming]
end
def render_paginated_products(paginated_products)
@@ -89,5 +91,10 @@ module Api
pagination: pagination_data(paginated_products)
}
end
def exchange_params
params.permit(:enterprise_id, :exchange_id, :order_cycle_id, :incoming).
to_h.with_indifferent_access
end
end
end

View File

@@ -7,6 +7,8 @@ module Api
respond_to :json
DEFAULT_PER_PAGE = 15
before_action :set_default_available_on, only: :create
skip_authorization_check only: [:show, :bulk_products, :overridable]
def show
@@ -16,8 +18,8 @@ module Api
def create
authorize! :create, Spree::Product
params[:product][:available_on] ||= Time.zone.now
@product = Spree::Product.new(product_params)
begin
if @product.save
render json: @product, serializer: Api::Admin::ProductSerializer, status: :created
@@ -146,7 +148,12 @@ module Api
end
def product_params
params.require(:product).permit PermittedAttributes::Product.attributes
@product_params ||=
params.permit(product: PermittedAttributes::Product.attributes)[:product].to_h
end
def set_default_available_on
product_params[:available_on] ||= Time.zone.now
end
end
end

View File

@@ -8,9 +8,9 @@ module Api
@taxons = if taxonomy
taxonomy.root.children
elsif params[:ids]
Spree::Taxon.where(id: params[:ids].split(","))
Spree::Taxon.where(id: raw_params[:ids].split(","))
else
Spree::Taxon.ransack(params[:q]).result
Spree::Taxon.ransack(raw_params[:q]).result
end
render json: @taxons, each_serializer: Api::TaxonSerializer
end

View File

@@ -50,7 +50,8 @@ class CartController < BaseController
def populate_variant_attributes_from_variant(order)
params[:variant_attributes].each do |variant_id, attributes|
order.set_variant_attributes(Spree::Variant.find(variant_id), attributes)
permitted = attributes.permit(:quantity, :max_quantity).to_h.with_indifferent_access
order.set_variant_attributes(Spree::Variant.find(variant_id), permitted)
end
end

View File

@@ -46,7 +46,7 @@ class CheckoutController < ::BaseController
def update
params_adapter = Checkout::FormDataAdapter.new(permitted_params, @order, spree_current_user)
return action_failed unless @order.update(params_adapter.params[:order])
return action_failed unless @order.update(params_adapter.params[:order] || {})
checkout_workflow(params_adapter.shipping_method_id)
rescue Spree::Core::GatewayError => e

View File

@@ -19,7 +19,7 @@ module Spree
end
def create
@url_filters = ::ProductFilters.new.extract(params)
@url_filters = ::ProductFilters.new.extract(request.query_parameters)
set_viewable
@object.attributes = permitted_resource_params
@@ -36,7 +36,7 @@ module Spree
end
def update
@url_filters = ::ProductFilters.new.extract(params)
@url_filters = ::ProductFilters.new.extract(request.query_parameters)
set_viewable
if @object.update(permitted_resource_params)

View File

@@ -54,7 +54,7 @@ module Spree
end
def edit
@url_filters = ::ProductFilters.new.extract(params)
@url_filters = ::ProductFilters.new.extract(request.query_parameters)
end
def update
@@ -75,12 +75,12 @@ module Spree
end
def bulk_update
product_set = product_set_from_params(params)
product_set = product_set_from_params
product_set.collection.each { |p| authorize! :update, p }
if product_set.save
redirect_to main_app.bulk_products_api_products_path( bulk_index_query(params) )
redirect_to main_app.bulk_products_api_products_path(bulk_index_query)
elsif product_set.errors.present?
render json: { errors: product_set.errors }, status: :bad_request
else
@@ -161,15 +161,14 @@ module Spree
private
def product_set_from_params(_params)
collection_hash = Hash[products_params.each_with_index.map { |p, i| [i, p] }]
def product_set_from_params
collection_hash = Hash[products_bulk_params[:products].each_with_index.map { |p, i| [i, p] }]
Sets::ProductSet.new(collection_attributes: collection_hash)
end
def products_params
params.require(:products).map do |product|
product.permit(::PermittedAttributes::Product.attributes)
end
def products_bulk_params
params.permit(products: ::PermittedAttributes::Product.attributes).
to_h.with_indifferent_access
end
def permitted_resource_params
@@ -178,8 +177,8 @@ module Spree
params.require(:product).permit(::PermittedAttributes::Product.attributes)
end
def bulk_index_query(params)
(params[:filters] || {}).merge(page: params[:page], per_page: params[:per_page])
def bulk_index_query
(raw_params[:filters] || {}).merge(page: raw_params[:page], per_page: raw_params[:per_page])
end
def load_form_data

View File

@@ -46,19 +46,19 @@ module Spree
def customers
@report_types = report_types[:customers]
@report_type = params[:report_type]
@report = OpenFoodNetwork::CustomersReport.new spree_current_user, params, render_content?
@report = OpenFoodNetwork::CustomersReport.new spree_current_user, raw_params, render_content?
render_report(@report.header, @report.table, params[:csv], "customers_#{timestamp}.csv")
end
def order_cycle_management
params[:q] ||= {}
raw_params[:q] ||= {}
@report_types = report_types[:order_cycle_management]
@report_type = params[:report_type]
# -- Build Report with Order Grouper
@report = OpenFoodNetwork::OrderCycleManagementReport.new spree_current_user,
params,
raw_params,
render_content?
@table = @report.table_items
@@ -67,13 +67,13 @@ module Spree
end
def packing
params[:q] ||= {}
raw_params[:q] ||= {}
@report_types = report_types[:packing]
@report_type = params[:report_type]
# -- Build Report with Order Grouper
@report = OpenFoodNetwork::PackingReport.new spree_current_user, params, render_content?
@report = OpenFoodNetwork::PackingReport.new spree_current_user, raw_params, render_content?
@table = order_grouper_table
render_report(@report.header, @table, params[:csv], "packing_#{timestamp}.csv")
@@ -81,7 +81,7 @@ module Spree
def orders_and_distributors
@report = OpenFoodNetwork::OrderAndDistributorReport.new spree_current_user,
params,
raw_params,
render_content?
@search = @report.search
csv_file_name = "orders_and_distributors_#{timestamp}.csv"
@@ -91,7 +91,7 @@ module Spree
def sales_tax
@distributors = my_distributors
@report_type = params[:report_type]
@report = OpenFoodNetwork::SalesTaxReport.new spree_current_user, params, render_content?
@report = OpenFoodNetwork::SalesTaxReport.new spree_current_user, raw_params, render_content?
render_report(@report.header, @report.table, params[:csv], "sales_tax.csv")
end
@@ -101,7 +101,7 @@ module Spree
@report_type = params[:report_type]
# -- Build Report with Order Grouper
@report = OpenFoodNetwork::PaymentsReport.new spree_current_user, params, render_content?
@report = OpenFoodNetwork::PaymentsReport.new spree_current_user, raw_params, render_content?
@table = order_grouper_table
csv_file_name = "payments_#{timestamp}.csv"
@@ -109,7 +109,7 @@ module Spree
end
def orders_and_fulfillment
params[:q] ||= orders_and_fulfillment_default_filters
raw_params[:q] ||= orders_and_fulfillment_default_filters
# -- Prepare Form Options
permissions = OpenFoodNetwork::Permissions.new(spree_current_user)
@@ -127,7 +127,7 @@ module Spree
# -- Build Report with Order Grouper
@report = OpenFoodNetwork::OrdersAndFulfillmentsReport.new spree_current_user,
params,
raw_params,
render_content?
@table = order_grouper_table
csv_file_name = "#{params[:report_type]}_#{timestamp}.csv"
@@ -139,11 +139,11 @@ module Spree
@report_types = report_types[:products_and_inventory]
@report = if params[:report_type] != 'lettuce_share'
OpenFoodNetwork::ProductsAndInventoryReport.new spree_current_user,
params,
raw_params,
render_content?
else
OpenFoodNetwork::LettuceShareReport.new spree_current_user,
params,
raw_params,
render_content?
end
@@ -154,19 +154,19 @@ module Spree
end
def users_and_enterprises
@report = OpenFoodNetwork::UsersAndEnterprisesReport.new params, render_content?
@report = OpenFoodNetwork::UsersAndEnterprisesReport.new raw_params, render_content?
render_report(@report.header, @report.table, params[:csv],
"users_and_enterprises_#{timestamp}.csv")
end
def xero_invoices
params[:q] ||= {}
raw_params[:q] ||= {}
@distributors = my_distributors
@order_cycles = my_order_cycles
@report = OpenFoodNetwork::XeroInvoicesReport.new(spree_current_user,
params,
raw_params,
render_content?)
render_report(@report.header, @report.table, params[:csv], "xero_invoices_#{timestamp}.csv")
end
@@ -198,7 +198,7 @@ module Spree
:invoice_date,
:due_date
]
@searching = search_keys.any? { |key| params.key? key }
@searching = search_keys.any? { |key| raw_params.key? key }
end
# We don't want to render data unless search params are supplied.

View File

@@ -6,7 +6,7 @@ module Spree
respond_to :json
def known_users
@users = if exact_match = Spree.user_class.find_by(email: params[:q])
@users = if exact_match = Spree.user_class.find_by(email: search_params[:q])
[exact_match]
else
spree_current_user.known_users.ransack(ransack_hash).result.limit(10)
@@ -17,11 +17,11 @@ module Spree
def customers
@customers = []
if spree_current_user.enterprises.pluck(:id).include? params[:distributor_id].to_i
if spree_current_user.enterprises.pluck(:id).include? search_params[:distributor_id].to_i
@customers = Customer.
ransack(m: 'or', email_start: params[:q], name_start: params[:q]).
ransack(m: 'or', email_start: search_params[:q], name_start: search_params[:q]).
result.
where(enterprise_id: params[:distributor_id])
where(enterprise_id: search_params[:distributor_id].to_i)
end
render json: @customers, each_serializer: ::Api::Admin::CustomerSerializer
end
@@ -31,13 +31,17 @@ module Spree
def ransack_hash
{
m: 'or',
email_start: params[:q],
ship_address_firstname_start: params[:q],
ship_address_lastname_start: params[:q],
bill_address_firstname_start: params[:q],
bill_address_lastname_start: params[:q]
email_start: search_params[:q],
ship_address_firstname_start: search_params[:q],
ship_address_lastname_start: search_params[:q],
bill_address_firstname_start: search_params[:q],
bill_address_lastname_start: search_params[:q]
}
end
def search_params
params.permit(:q, :distributor_id).to_h.with_indifferent_access
end
end
end
end

View File

@@ -18,7 +18,7 @@ module Spree
end
def included_changed?
ActiveRecord::Type::Boolean.new.type_cast_from_user(
ActiveRecord::Type::Boolean.new.cast(
permitted_resource_params[:included_in_price]
) != @tax_rate.included_in_price
end

View File

@@ -54,7 +54,7 @@ module Spree
end
def search
scoper = OpenFoodNetwork::ScopeVariantsForSearch.new(params)
scoper = OpenFoodNetwork::ScopeVariantsForSearch.new(variant_search_params)
@variants = scoper.search
render json: @variants, each_serializer: ::Api::Admin::VariantSerializer
end
@@ -109,6 +109,12 @@ module Spree
def permitted_resource_params
variant_params
end
def variant_search_params
params.permit(
:q, :distributor_id, :order_cycle_id, :schedule_id, :eligible_for_subscriptions
).to_h.with_indifferent_access
end
end
end
end

View File

@@ -25,7 +25,7 @@ module Spree
# respond_with resource, :location => spree.login_path
#
def create
self.resource = resource_class.send_reset_password_instructions(params[resource_name])
self.resource = resource_class.send_reset_password_instructions(raw_params[resource_name])
if resource.errors.empty?
set_flash_message(:notice, :send_instructions) if is_navigational_format?

View File

@@ -6,7 +6,7 @@ class UserPasswordsController < Spree::UserPasswordsController
def create
render_unconfirmed_response && return if user_unconfirmed?
self.resource = resource_class.send_reset_password_instructions(params[resource_name])
self.resource = resource_class.send_reset_password_instructions(raw_params[resource_name])
if resource.errors.empty?
set_flash_message(:success, :send_instructions) if is_navigational_format?

View File

@@ -1,4 +1,6 @@
module ApplicationHelper
include RawParams
def feature?(feature, user = nil)
OpenFoodNetwork::FeatureToggle.enabled?(feature, user)
end

View File

@@ -13,8 +13,8 @@ class OrderCycle < ActiveRecord::Base
has_many :cached_incoming_exchanges, -> { where incoming: true }, class_name: "Exchange"
has_many :cached_outgoing_exchanges, -> { where incoming: false }, class_name: "Exchange"
has_many :suppliers, -> { uniq }, source: :sender, through: :cached_incoming_exchanges
has_many :distributors, -> { uniq }, source: :receiver, through: :cached_outgoing_exchanges
has_many :suppliers, -> { distinct }, source: :sender, through: :cached_incoming_exchanges
has_many :distributors, -> { distinct }, source: :receiver, through: :cached_outgoing_exchanges
has_many :schedules, through: :order_cycle_schedules
has_many :order_cycle_schedules

View File

@@ -199,8 +199,7 @@ module Spree
end
def update_order
order.payments.reload
order.update!
order.reload.update!
end
# Necessary because some payment gateways will refuse payments with

View File

@@ -337,7 +337,7 @@ module Spree
end
def update_order
order.update!
order.reload.update!
end
end
end

View File

@@ -6,7 +6,7 @@ module Checkout
attr_reader :params, :shipping_method_id
def initialize(params, order, current_user)
@params = params.dup
@params = params.deep_dup.to_h.with_indifferent_access
@order = order
@current_user = current_user
@@ -16,9 +16,9 @@ module Checkout
set_amount_in_payments_attributes
construct_saved_card_attributes if @params[:order][:existing_card_id]
construct_saved_card_attributes if @params.dig(:order, :existing_card_id)
@shipping_method_id = @params[:order].delete(:shipping_method_id)
@shipping_method_id = @params[:order]&.delete(:shipping_method_id)
end
private
@@ -30,7 +30,7 @@ module Checkout
return unless @params[:payment_source].present? &&
payment_source_params = delete_payment_source_params!
@params[:order][:payments_attributes].first[:source_attributes] = payment_source_params
@params.dig(:order, :payments_attributes).first[:source_attributes] = payment_source_params
end
# Ensures cc_type is always passed to the model by inferring the type when
@@ -45,7 +45,7 @@ module Checkout
def payment_source_attributes
@payment_source_attributes ||=
params[:order][:payments_attributes]&.first&.dig(:source_attributes)
@params.dig(:order, :payments_attributes)&.first&.dig(:source_attributes)
end
def card_brand(number)
@@ -54,14 +54,14 @@ module Checkout
def delete_payment_source_params!
@params.delete(:payment_source)[
@params[:order][:payments_attributes].first[:payment_method_id].underscore
@params.dig(:order, :payments_attributes).first[:payment_method_id].underscore
]
end
def set_amount_in_payments_attributes
return unless @params[:order][:payments_attributes]
return unless @params.dig(:order, :payments_attributes)
@params[:order][:payments_attributes].first[:amount] = @order.total
@params.dig(:order, :payments_attributes).first[:amount] = @order.total
end
def construct_saved_card_attributes
@@ -70,7 +70,7 @@ module Checkout
add_to_payment_attributes(existing_card_id)
@params[:order][:payments_attributes].first.delete :source_attributes
@params.dig(:order, :payments_attributes).first.delete :source_attributes
end
def add_to_payment_attributes(existing_card_id)
@@ -79,7 +79,7 @@ module Checkout
raise Spree::Core::GatewayError, I18n.t(:invalid_credit_card)
end
@params[:order][:payments_attributes].first[:source] = credit_card
@params.dig(:order, :payments_attributes).first[:source] = credit_card
end
end
end

View File

@@ -63,36 +63,28 @@ module Permissions
# Any orders placed through any hub that I manage
def managed_orders_where_values
query = Spree::Order.
where(distributor_id: @permissions.managed_enterprises.select("enterprises.id"))
apply_where_clause(query).reduce(:and)
Spree::Order.
where(distributor_id: @permissions.managed_enterprises.select("enterprises.id")).
where_clause.__send__(:predicates).
reduce(:and)
end
# Any order that is placed through an order cycle one of my managed enterprises coordinates
def coordinated_orders_where_values
query = Spree::Order.
where(order_cycle_id: @permissions.coordinated_order_cycles.select(:id))
apply_where_clause(query).reduce(:and)
Spree::Order.
where(order_cycle_id: @permissions.coordinated_order_cycles.select(:id)).
where_clause.__send__(:predicates).
reduce(:and)
end
def produced_orders_where_values
query = Spree::Order.with_line_items_variants_and_products_outer.
Spree::Order.with_line_items_variants_and_products_outer.
where(
distributor_id: granted_distributor_ids,
spree_products: { supplier_id: enterprises_with_associated_orders }
)
apply_where_clause(query).reduce(:and)
end
def apply_where_clause(query)
if ENV['DEPENDENCIES_NEXT']
query.where_clause.__send__(:predicates)
else
query.where_values
end
).
where_clause.__send__(:predicates).
reduce(:and)
end
def enterprises_with_associated_orders

View File

@@ -13,6 +13,7 @@ module Sets
# Set here first, to ensure that we apply collection_attributes to the right collection
@collection = attributes[:collection] if attributes[:collection]
@collection = @collection.to_a
attributes.each do |name, value|
public_send("#{name}=", value)

View File

@@ -26,4 +26,4 @@
var shipments = [];
- @order.shipments.each do |shipment|
shipments.push(#{shipment.to_json(:root => false, :include => [:inventory_units, :stock_location]).html_safe});
= render :partial => 'spree/admin/shared/update_order_state', :handlers => [:js]
= render :partial => 'spree/admin/shared/update_order_state', :handlers => [:erb]

View File

@@ -1 +0,0 @@
require "action_dispatch/request" unless ENV['DEPENDENCIES_NEXT']

View File

@@ -1,17 +1,15 @@
unless ENV['DEPENDENCIES_NEXT']
require_relative 'spree'
require_relative 'spree'
# See: https://github.com/itbeaver/db2fog
DB2Fog.config = {
:aws_access_key_id => Spree::Config[:s3_access_key],
:aws_secret_access_key => Spree::Config[:s3_secret],
:directory => ENV['S3_BACKUPS_BUCKET'],
:provider => 'AWS'
}
# See: https://github.com/itbeaver/db2fog
DB2Fog.config = {
:aws_access_key_id => Spree::Config[:s3_access_key],
:aws_secret_access_key => Spree::Config[:s3_secret],
:directory => ENV['S3_BACKUPS_BUCKET'],
:provider => 'AWS'
}
region = ENV['S3_BACKUPS_REGION'] || ENV['S3_REGION']
region = ENV['S3_BACKUPS_REGION'] || ENV['S3_REGION']
# If no region is defined we leave this config key undefined (instead of nil),
# so that db2fog correctly applies it's default
DB2Fog.config[:region] = region if region
end
# If no region is defined we leave this config key undefined (instead of nil),
# so that db2fog correctly applies it's default
DB2Fog.config[:region] = region if region

View File

@@ -1,14 +1,14 @@
# Make helpers (#t in particular) available to javascript templates
# https://github.com/pitr/angular-rails-templates/issues/45#issuecomment-43229086
if ENV['DEPENDENCIES_NEXT']
# if ENV['DEPENDENCIES_NEXT']
Rails.application.config.assets.configure do |env|
env.context_class.class_eval do
include ActionView::Helpers::TranslationHelper
end
end
else
Rails.application.assets.context_class.class_eval do
include ActionView::Helpers::TranslationHelper
end
end
# else
# Rails.application.assets.context_class.class_eval do
# include ActionView::Helpers::TranslationHelper
# end
# end

View File

@@ -11,19 +11,21 @@ module OrderManagement
delegate :json_errors, :valid?, to: :validator
delegate :order_update_issues, to: :order_syncer
def initialize(subscription, subscription_params = {})
def initialize(subscription, subscription_params = {}, options = {})
@subscription = subscription
@subscription_params = subscription_params
@options = options
@estimator = OrderManagement::Subscriptions::Estimator.new(subscription)
@validator = OrderManagement::Subscriptions::Validator.new(subscription)
@order_syncer = OrderSyncer.new(subscription)
end
def save
subscription.assign_attributes(subscription_params)
subscription.assign_attributes(subscription_params.to_h)
return false unless valid?
subscription.transaction do
subscription.paused_at = nil if @options[:unpause]
estimator.estimate!
proxy_order_syncer.sync!
order_syncer.sync!

View File

@@ -12,7 +12,7 @@ describe OrderManagement::Reports::EnterpriseFeeSummary::Renderers::CsvRenderer
# Context which will be passed to the renderer. The response object is not automatically prepared,
# so this has to be assigned explicitly.
let!(:response) { ActionController::TestResponse.new }
let!(:response) { ActionDispatch::TestResponse.new }
let!(:controller) do
ActionController::Base.new.tap do |controller_mock|
controller_mock.instance_variable_set(:@_response, response)

View File

@@ -1,69 +0,0 @@
# frozen_string_literal: true
# This patch fixes the Rails issue where ActionDispatch::Request#deep_munge was converting empty
# array paramters into nils, see https://github.com/rails/rails/issues/13420
#
# Before this patch:
#
# | JSON | Hash |
# |----------------------------------|-------------------------|
# | { "person": [] } | { 'person' => nil } |
#
# After patch:
#
# | JSON | Hash |
# |----------------------------------|-------------------------|
# | { "person": [] } | { 'person' => [] } |
#
# The issue started in Rails v4.0.0.beta1:
#
# https://github.com/rails/rails/commit/8e577fe560d5756fcc67840ba304d79ada6804e4
#
# This patch can be removed on or after Rails v5.0.0.beta1 when the issue was fixed:
#
# https://github.com/rails/rails/commit/8f8ccb9901cab457c6e1d52bdb25acf658fd5777
#
# Credit:
#
# https://gist.github.com/victorblasco/f675b4cbaf9c0bc19f81
module ActionDispatch
class Request < Rack::Request
class Utils # :nodoc:
mattr_accessor :perform_deep_munge
self.perform_deep_munge = true
class << self
# Remove nils from the params hash
def deep_munge(hash, keys = [])
return hash unless perform_deep_munge
hash.each do |key, value|
deep_munge_value(key, value, keys)
end
hash
end
def deep_munge_value(key, value, keys)
keys << key
case value
when Array
value.grep(Hash) { |x| deep_munge(x, keys) }
value.compact!
# This patch removes the following lines
# if v.empty?
# hash[k] = nil
# ActiveSupport::Notifications.instrument("deep_munge.action_controller",
# keys: keys)
# end
when Hash
deep_munge(value, keys)
end
keys.pop
end
end
end
end
end

View File

@@ -122,7 +122,7 @@ module OpenFoodNetwork
end
def to_bool(value)
ActiveRecord::Type::Boolean.new.type_cast_from_database(value)
ActiveRecord::Type::Boolean.new.cast(value)
end
def to_local_datetime(date)

View File

@@ -207,7 +207,7 @@ module Admin
let!(:outgoing_exchange) { create(:exchange, order_cycle: order_cycle, sender: coordinator, receiver: hub, incoming: false, variants: [v]) }
let(:allowed) { { incoming_exchanges: [], outgoing_exchanges: [] } }
let(:restricted) { { name: 'some name', orders_open_at: 1.day.from_now, orders_close_at: 1.day.ago } }
let(:restricted) { { name: 'some name', orders_open_at: 1.day.from_now.to_s, orders_close_at: 1.day.ago.to_s } }
let(:params) { { format: :json, id: order_cycle.id, order_cycle: allowed.merge(restricted) } }
let(:form_mock) { instance_double(OrderCycleForm, save: true) }
@@ -267,8 +267,13 @@ module Admin
end
context "when a validation error occurs" do
before do
params[:order_cycle_set][:collection_attributes]['0'][:orders_open_at] = Date.current + 25.days
let(:params) do
{ format: :json, order_cycle_set: { collection_attributes: { '0' => {
id: oc.id,
name: "Updated Order Cycle",
orders_open_at: Date.current + 25.days,
orders_close_at: Date.current + 21.days,
} } } }
end
it "returns an error message" do

View File

@@ -96,7 +96,9 @@ describe Admin::SchedulesController, type: :controller do
expect(syncer_mock).to receive(:sync!).exactly(2).times
spree_put :update, format: :json, id: coordinated_schedule.id, order_cycle_ids: [coordinated_order_cycle.id, coordinated_order_cycle2.id]
reset_controller_environment
spree_put :update, format: :json, id: coordinated_schedule.id, order_cycle_ids: [coordinated_order_cycle.id]
reset_controller_environment
spree_put :update, format: :json, id: coordinated_schedule.id, order_cycle_ids: [coordinated_order_cycle.id]
end
end

View File

@@ -33,14 +33,14 @@ module Api
end
it "paginates when page parameter is passed through" do
expect(@scope).to receive(:page).with(1).and_return(@scope)
expect(@scope).to receive(:page).with("1").and_return(@scope)
expect(@scope).to receive(:per).with(nil)
api_get :index, page: 1
end
it "paginates when per_page parameter is passed through" do
expect(@scope).to receive(:page).with(nil).and_return(@scope)
expect(@scope).to receive(:per).with(25)
expect(@scope).to receive(:per).with("25")
api_get :index, per_page: 25
end
end

View File

@@ -110,11 +110,11 @@ describe CartController, type: :controller do
order = subject.current_order(true)
allow(order).to receive(:distributor) { distributor }
allow(order).to receive(:order_cycle) { order_cycle }
expect(order).to receive(:set_variant_attributes).with(variant, max_quantity: '3')
expect(order).to receive(:set_variant_attributes).with(variant, max_quantity: "3")
allow(controller).to receive(:current_order).and_return(order)
expect do
spree_post :populate, variants: { variant.id => 1 }, variant_attributes: { variant.id => { max_quantity: 3 } }
spree_post :populate, variants: { variant.id => 1 }, variant_attributes: { variant.id => { max_quantity: "3" } }
end.to change(Spree::LineItem, :count).by(1)
end
end

View File

@@ -44,7 +44,10 @@ describe CheckoutController, concurrency: true, type: :controller do
allow(controller).to receive(:current_order_cycle).and_return(order.order_cycle)
end
it "handles two concurrent orders successfully" do
# This spec does not seem to be running in two threads in Rails 5. There are errors for the
# same response headers being set twice, possibly indicating that there is only one response
# as opposed to two separate requests in two threads?
xit "handles two concurrent orders successfully" do
# New threads start running straight away. The breakpoint is after loading
# the order and before advancing the order's state and making payments.
breakpoint.lock

View File

@@ -227,7 +227,9 @@ describe Spree::Admin::ReportsController, type: :controller do
it "creates a ProductAndInventoryReport" do
expect(OpenFoodNetwork::ProductsAndInventoryReport).to receive(:new)
.with(@admin_user, { "test" => "foo", "controller" => "spree/admin/reports", "action" => "products_and_inventory" }, false)
.with(@admin_user,
{ "test" => "foo", "controller" => "spree/admin/reports", "report" => {},
"action" => "products_and_inventory", "use_route" => "main_app" }, false)
.and_return(report = double(:report))
allow(report).to receive(:header).and_return []
allow(report).to receive(:table).and_return []
@@ -278,7 +280,9 @@ describe Spree::Admin::ReportsController, type: :controller do
it "creates a CustomersReport" do
expect(OpenFoodNetwork::CustomersReport).to receive(:new)
.with(@admin_user, { "test" => "foo", "controller" => "spree/admin/reports", "action" => "customers" }, false)
.with(@admin_user, { "test" => "foo", "controller" => "spree/admin/reports",
"action" => "customers", "use_route" => "main_app",
"report" => {} }, false)
.and_return(report = double(:report))
allow(report).to receive(:header).and_return []
allow(report).to receive(:table).and_return []

View File

@@ -33,6 +33,9 @@ module Spree
expect(return_authorization.amount.to_s).to eq "20.2"
expect(return_authorization.reason.to_s).to eq "broken"
# Reset the test controller between requests
reset_controller_environment
# Update return authorization
spree_put :update, id: return_authorization.id,
return_authorization: { amount: "10.2", reason: "half broken" }

View File

@@ -218,6 +218,7 @@ FactoryBot.define do
order.reload
while !order.completed? do break unless order.next! end
order.reload
end
end
end

View File

@@ -73,7 +73,7 @@ feature "Shops caching", js: true, caching: true do
expect(page).to have_content taxon.name
expect(page).to have_content property.presentation
product.update_attribute(:taxons, [taxon2])
product.taxons << taxon2
product.update_attribute(:primary_taxon, taxon2)
product.update_attribute(:properties, [property2])

View File

@@ -338,6 +338,10 @@ feature "As a consumer I want to check out my cart", js: true do
order = Spree::Order.complete.first
expect(order.special_instructions).to eq "SpEcIaL NoTeS"
# Shipment and payments states should be set
expect(order.payment_state).to eq "balance_due"
expect(order.shipment_state).to eq "pending"
# And the Spree tax summary should not be displayed
expect(page).not_to have_content product.tax_category.name

View File

@@ -4,6 +4,11 @@ require 'spec_helper'
describe I18nHelper, type: :helper do
let(:user) { create(:user) }
let(:cookies) { {} }
before do
allow(helper).to receive(:cookies) { cookies }
end
# In the real world, the helper is called in every request and sets
# I18n.locale to the chosen locale or the default. For testing purposes we
@@ -134,7 +139,7 @@ describe I18nHelper, type: :helper do
it "remembers the chosen locale on another computer" do
allow(helper).to receive(:params) { { locale: "es" } }
helper.set_locale
expect(cookies[:locale]).to eq "es"
expect(cookies.fetch(:locale)).to eq "es"
# switch computer / browser or loose cookies
cookies.delete :locale

View File

@@ -164,11 +164,9 @@ module OpenFoodNetwork
let!(:order) do
create(
:order,
:completed_order_with_totals,
distributor: distributor,
completed_at: 1.day.ago,
state: 'complete',
total: 10.0
completed_at: 1.day.ago
)
end
@@ -180,50 +178,37 @@ module OpenFoodNetwork
'',
order.email,
order.billing_address.phone,
order.shipment.shipping_method.name,
nil,
nil,
nil,
-10.0
-order.total
]])
end
end
context 'when the report type is not payment_methods' do
let(:params) { {} }
let(:shipping_method) { create(:shipping_method) }
let(:shipment) { create(:shipment_with, :shipping_method, shipping_method: shipping_method) }
let!(:order) do
create(
:order,
:completed_order_with_totals,
distributor: distributor,
completed_at: 1.day.ago,
shipments: [shipment]
completed_at: 1.day.ago
)
end
before do
line_item = create(:line_item, order: order, price: 10.0, quantity: 1)
order.state = 'complete'
order.ship_address = order.address_from_distributor
order.save!
end
it 'returns rows with delivery information' do
expect(subject.table_items).to eq([[
order.ship_address.firstname,
order.ship_address.lastname,
order.distributor.name,
nil,
"",
"#{order.ship_address.address1} #{order.ship_address.address2} #{order.ship_address.city}",
order.ship_address.zipcode,
order.ship_address.phone,
shipping_method.name,
order.shipment.shipping_method.name,
nil,
nil,
-10.0,
-order.total,
false,
order.special_instructions
]])

View File

@@ -16,7 +16,6 @@ describe Enterprise do
let(:producer_property) { enterprise.producer_properties.last }
before do
pp enterprise.updated_at
product.set_property 'Organic', 'NASAA 12345'
enterprise.set_producer_property 'Biodynamic', 'ASDF 4321'
end

View File

@@ -1202,20 +1202,11 @@ describe Spree::Order do
expect { order.next! }.to change { order.state }.from("delivery").to("payment")
end
it "advances to complete state despite error" do
# Regression test for https://github.com/openfoodfoundation/openfoodnetwork/issues/3924
it "advances to complete state without error" do
advance_to_delivery_state(order)
# advance to payment state
order.next!
create(:payment, order: order)
# https://github.com/openfoodfoundation/openfoodnetwork/issues/3924
observed_error = ActiveRecord::RecordNotUnique.new(
"PG::UniqueViolation",
StandardError.new
)
expect(order.shipment).to receive(:save).and_call_original
expect(order.shipment).to receive(:save).and_call_original
expect(order.shipment).to receive(:save).and_raise(observed_error)
expect { order.next! }.to change { order.state }.from("payment").to("complete")
end

View File

@@ -425,7 +425,7 @@ describe Spree::Shipment do
context "update_order" do
it "should update order" do
expect(order).to receive(:update!)
expect(order).to receive_message_chain(:reload, :update!)
shipment.__send__(:update_order)
end
end

View File

@@ -4,23 +4,23 @@ require 'spec_helper'
describe Checkout::FormDataAdapter do
describe '#params' do
let(:params) { { order: { order_id: "123" } } }
let(:params) { { "order" => { "order_id" => "123" } } }
let(:order) { create(:order) }
let(:user) { create(:user) }
let(:adapter) { Checkout::FormDataAdapter.new(params, order, user) }
it "returns the :order item in the params provided" do
expect(adapter.params[:order]).to eq params[:order]
expect(adapter.params[:order]).to eq params["order"]
end
describe "when payment_attributes are provided" do
before { params[:order][:payments_attributes] = [{ payment_method_id: "123" }] }
before { params["order"]["payments_attributes"] = [{ "payment_method_id" => "123" }] }
describe "and source attributes are provided" do
let(:source_attributes) { { payment_method_name: "Pay at the farm" } }
let(:source_attributes) { { "payment_method_name" => "Pay at the farm" } }
before { params[:payment_source] = { "123" => source_attributes } }
before { params["payment_source"] = { "123" => source_attributes } }
it "moves payment source attributes to the order payment attributes" do
expect(adapter.params[:order][:payments_attributes].
@@ -38,7 +38,8 @@ describe Checkout::FormDataAdapter do
describe "and a credit card is provided" do
before do
params[:order][:payments_attributes].first[:source_attributes] = { number: "4444333322221111" }
params["order"]["payments_attributes"].first["source_attributes"] =
{ "number" => "4444333322221111" }
end
it "fills in missing credit card brand" do
@@ -46,23 +47,23 @@ describe Checkout::FormDataAdapter do
end
it "leaves an existing credit card brand" do
params[:order][:payments_attributes].first[:source_attributes][:cc_type] = "test"
params["order"]["payments_attributes"].first["source_attributes"]["cc_type"] = "test"
expect(adapter.params[:order][:payments_attributes].first[:source_attributes][:cc_type]).to eq "test"
end
it "doesn't touch the credit card brand without a number" do
params[:order][:payments_attributes].first[:source_attributes][:number] = ""
params["order"]["payments_attributes"].first["source_attributes"]["number"] = ""
expect(adapter.params[:order][:payments_attributes].first[:source_attributes].key?(:cc_type)).to eq false
end
end
describe "and existing credit card is provided" do
before { params[:order][:existing_card_id] = credit_card.id }
before { params["order"]["existing_card_id"] = credit_card.id }
describe "and credit card is owned by current user" do
let(:credit_card) { create(:credit_card, user_id: user.id) }
before { params[:order][:existing_card_id] = credit_card.id }
before { params["order"]["existing_card_id"] = credit_card.id }
it "adds card details to payment attributes" do
expect(adapter.params[:order][:payments_attributes].first[:source][:id]).to eq credit_card.id

View File

@@ -6,8 +6,8 @@ describe EmbeddedPageService do
let(:enterprise_slug) { 'test-enterprise' }
let(:params) { { controller: 'enterprises', action: 'shop', id: enterprise_slug, embedded_shopfront: true } }
let(:session) { {} }
let(:request) { ActionController::TestRequest.new('HTTP_HOST' => 'ofn-instance.com', 'HTTP_REFERER' => 'https://embedding-enterprise.com') }
let(:response) { ActionController::TestResponse.new(200, 'X-Frame-Options' => 'DENY', 'Content-Security-Policy' => "frame-ancestors 'none'") }
let(:request) { ActionController::TestRequest.new({'HTTP_HOST' => 'ofn-instance.com', 'HTTP_REFERER' => 'https://embedding-enterprise.com'}, nil) }
let(:response) { ActionDispatch::TestResponse.new(200, 'X-Frame-Options' => 'DENY', 'Content-Security-Policy' => "frame-ancestors 'none'") }
let(:service) { EmbeddedPageService.new(params, session, request, response) }
before do
@@ -23,7 +23,7 @@ describe EmbeddedPageService do
it "sets the response headers to enables embedding requests from the embedding site" do
expect(response.headers).to_not include 'X-Frame-Options' => 'DENY'
expect(response.headers).to include 'Content-Security-Policy' => "frame-ancestors 'self' embedding-enterprise.com"
expect(response.headers).to eq 'Content-Security-Policy' => "frame-ancestors 'self' embedding-enterprise.com"
end
it "sets session variables" do
@@ -63,7 +63,7 @@ describe EmbeddedPageService do
end
context "when the request's referer is malformed" do
let(:request) { ActionController::TestRequest.new('HTTP_HOST' => 'ofn-instance.com', 'HTTP_REFERER' => 'hello') }
let(:request) { ActionController::TestRequest.new({'HTTP_HOST' => 'ofn-instance.com', 'HTTP_REFERER' => 'hello'}, nil) }
before do
service.embed!
end

View File

@@ -143,6 +143,9 @@ RSpec.configure do |config|
ActionController::Base.perform_caching = caching
end
# Fix encoding issue in Rails 5.0; allows passing empty arrays or hashes as params.
config.before(:each, type: :controller) { @request.env["CONTENT_TYPE"] = 'application/json' }
# Show javascript errors in test output with `js_debug: true`
config.after(:each, :js_debug) do
errors = page.driver.browser.manage.logs.get(:browser)

View File

@@ -24,5 +24,13 @@ module OpenFoodNetwork
allow(controller).to receive_messages(spree_current_user: @enterprise_user)
end
def reset_controller_environment
# Rails 5.0 introduced a bug in controller tests (fixed in 5.2) where the controller's
# environment is essentially cached if multiple requests are made in the same `it` block,
# meaning subsequent requests will not be handled well. This resets the environment.
# This edge case is quite rare though; normally we only do one request per test.
@request.env.delete("RAW_POST_DATA")
end
end
end