From ece3e7aa695c182553588b48d8004158bded6a56 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Tue, 3 Nov 2020 23:17:11 +0000 Subject: [PATCH 01/58] Update gems to Rails 4.2 --- Gemfile | 10 +-- Gemfile.lock | 218 +++++++++++++++++++++++++++++++-------------------- 2 files changed, 136 insertions(+), 92 deletions(-) diff --git a/Gemfile b/Gemfile index 17c5f9d6e2..ff1e3682b2 100644 --- a/Gemfile +++ b/Gemfile @@ -2,10 +2,10 @@ source 'https://rubygems.org' ruby "2.3.7" git_source(:github) { |repo_name| "https://github.com/#{repo_name}.git" } -gem 'i18n', '~> 0.6.11' +gem 'i18n' gem 'i18n-js', '~> 3.8.0' -gem 'rails', '~> 4.1.16' -gem 'rails-i18n', '~> 4.0' +gem 'rails', '~> 4.2' +gem 'rails-i18n' gem 'rails_safe_tasks', '~> 1.0' gem "activerecord-import" @@ -23,8 +23,8 @@ gem 'awesome_nested_set', '~> 3.2.1' gem 'cancan', '~> 1.6.10' gem 'ffaker', '~> 1.16' gem 'highline', '2.0.3' # Necessary for the install generator -gem 'json', '>= 1.7.7' -gem 'money', '5.1.1' +gem 'json' +gem 'money', '< 6.1.0' gem 'paranoia', '~> 2.0' gem 'ransack', '~> 1.8.10' gem 'state_machine', '1.2.0' diff --git a/Gemfile.lock b/Gemfile.lock index baca3a8878..005099747d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -55,35 +55,44 @@ GEM remote: https://rubygems.org/ specs: CFPropertyList (2.3.6) - actionmailer (4.1.16) - actionpack (= 4.1.16) - actionview (= 4.1.16) + actionmailer (4.2.11.3) + actionpack (= 4.2.11.3) + actionview (= 4.2.11.3) + activejob (= 4.2.11.3) mail (~> 2.5, >= 2.5.4) - actionpack (4.1.16) - actionview (= 4.1.16) - activesupport (= 4.1.16) - rack (~> 1.5.2) + 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-html-sanitizer (~> 1.0, >= 1.0.2) actionpack-action_caching (1.2.1) actionpack (>= 4.0.0) - actionview (4.1.16) - activesupport (= 4.1.16) + actionview (4.2.11.3) + activesupport (= 4.2.11.3) builder (~> 3.1) erubis (~> 2.7.0) + rails-dom-testing (~> 1.0, >= 1.0.5) + 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) builder (>= 2.1.2, < 4.0.0) i18n (>= 0.6.9) nokogiri (~> 1.4) - activemodel (4.1.16) - activesupport (= 4.1.16) + activemodel (4.2.11.3) + activesupport (= 4.2.11.3) builder (~> 3.1) - activerecord (4.1.16) - activemodel (= 4.1.16) - activesupport (= 4.1.16) - arel (~> 5.0.0) + activerecord (4.2.11.3) + activemodel (= 4.2.11.3) + activesupport (= 4.2.11.3) + arel (~> 6.0) activerecord-import (1.0.7) activerecord (>= 3.2) activerecord-postgresql-adapter (0.0.1) @@ -94,11 +103,10 @@ GEM multi_json (~> 1.11, >= 1.11.2) rack (>= 1.5.2, < 3) railties (>= 4.0) - activesupport (4.1.16) - i18n (~> 0.6, >= 0.6.9) - json (~> 1.7, >= 1.7.7) + activesupport (4.2.11.3) + i18n (~> 0.7) minitest (~> 5.1) - thread_safe (~> 0.1) + thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) acts-as-taggable-on (4.0.0) activerecord (>= 4.0) @@ -106,6 +114,9 @@ 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) @@ -113,7 +124,7 @@ GEM tilt angularjs-file-upload-rails (2.4.1) angularjs-rails (1.5.5) - arel (5.0.1.20140414130214) + arel (6.0.4) ast (2.4.0) atomic (1.1.101) awesome_nested_set (3.2.1) @@ -124,7 +135,7 @@ GEM aws-sdk-v1 (1.67.0) json (~> 1.4) nokogiri (~> 1) - bcrypt (3.1.13) + bcrypt (3.1.16) bugsnag (6.18.0) concurrent-ruby (~> 1.0) builder (3.2.4) @@ -139,7 +150,7 @@ GEM xpath (>= 2.0, < 4.0) childprocess (3.0.0) chronic (0.10.2) - chunky_png (1.3.11) + chunky_png (1.3.14) climate_control (0.2.0) cocaine (0.5.8) climate_control (>= 0.0.3, < 1.0) @@ -171,6 +182,7 @@ GEM sprockets (< 4.0) concurrent-ruby (1.1.7) crack (0.4.4) + crass (1.0.6) css_parser (1.7.1) addressable daemons (1.3.1) @@ -204,24 +216,26 @@ GEM devise (>= 2.1.0) devise-token_authenticatable (0.4.10) devise (>= 3.5.2, < 4.0.0) - diff-lcs (1.3) + diff-lcs (1.4.4) docile (1.3.2) + 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.71.1) + excon (0.78.0) execjs (2.7.0) factory_bot (4.10.0) activesupport (>= 3.0.0) factory_bot_rails (4.10.0) factory_bot (~> 4.10.0) railties (>= 3.0.0) - faraday (1.0.0) + faraday (1.0.1) multipart-post (>= 1.2, < 3) ffaker (1.32.1) - ffi (1.12.2) - figaro (1.1.1) - thor (~> 0.14) + ffi (1.13.1) + figaro (1.2.0) + thor (>= 0.14.0, < 2) fission (0.5.0) CFPropertyList (~> 2.2) fog (1.41.0) @@ -258,7 +272,8 @@ GEM fog-xml (~> 0.1.1) ipaddress (~> 0.5) json (>= 1.8, < 2.0) - fog-aliyun (0.3.5) + fog-aliyun (0.3.19) + aliyun-sdk (~> 0.8.0) fog-core fog-json ipaddress (~> 0.8) @@ -304,7 +319,7 @@ GEM fog-core fog-json fog-xml - fog-internet-archive (0.0.1) + fog-internet-archive (0.0.2) fog-core fog-json fog-xml @@ -361,7 +376,7 @@ GEM fog-voxel (0.1.0) fog-core fog-xml - fog-vsphere (3.2.1) + fog-vsphere (3.4.0) fog-core rbvmomi (>= 1.9, < 3) fog-xenserver (1.0.0) @@ -384,8 +399,10 @@ GEM rspec-core (~> 3.0) ruby-progressbar (~> 1.4) geocoder (1.6.4) - get_process_mem (0.2.5) + get_process_mem (0.2.7) ffi (~> 1.0) + globalid (0.4.2) + activesupport (>= 4.2.0) gmaps4rails (2.1.2) haml (5.2.0) temple (>= 0.8.0) @@ -393,7 +410,11 @@ GEM hashdiff (1.0.1) highline (2.0.3) hike (1.2.3) - i18n (0.6.11) + http-accept (1.7.0) + http-cookie (1.0.3) + domain_name (~> 0.5) + i18n (0.9.5) + concurrent-ruby (~> 1.0) i18n-js (3.8.0) i18n (>= 0.6.6) immigrant (0.3.6) @@ -424,6 +445,9 @@ GEM letter_opener (1.7.0) launchy (~> 2.2) libv8 (7.3.492.27.1) + loofah (2.7.0) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) mail (2.7.1) mini_mime (>= 0.1.1) method_source (0.9.2) @@ -435,14 +459,16 @@ GEM mini_racer (0.2.15) libv8 (> 7.3) minitest (5.14.2) - money (5.1.1) - i18n (~> 0.6.0) + money (5.0.0) + i18n (~> 0.4) + json msgpack (1.3.3) multi_json (1.15.0) multi_xml (0.6.0) multipart-post (2.1.1) + netrc (0.11.0) newrelic_rpm (3.18.1.330) - nokogiri (1.10.9) + nokogiri (1.10.10) mini_portile2 (~> 2.4.0) oauth2 (1.4.4) faraday (>= 0.8, < 2.0) @@ -451,7 +477,7 @@ GEM multi_xml (~> 0.5) rack (>= 1.2, < 3) oj (3.10.8) - optimist (3.0.0) + optimist (3.0.1) orm_adapter (0.5.0) paper_trail (7.1.3) activerecord (>= 4.0, < 5.2) @@ -481,7 +507,7 @@ GEM byebug (~> 11.0) pry (~> 0.10) public_suffix (4.0.6) - rack (1.5.5) + rack (1.6.13) rack-mini-profiler (2.0.2) rack (>= 1.2.0) rack-protection (1.5.5) @@ -491,23 +517,32 @@ GEM rack rack-test (0.6.3) rack (>= 1.0) - rails (4.1.16) - actionmailer (= 4.1.16) - actionpack (= 4.1.16) - actionview (= 4.1.16) - activemodel (= 4.1.16) - activerecord (= 4.1.16) - activesupport (= 4.1.16) + 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.1.16) - sprockets-rails (~> 2.0) - rails-i18n (4.0.5) - i18n (~> 0.6) + railties (= 4.2.11.3) + sprockets-rails + rails-deprecated_sanitizer (1.0.3) + 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-html-sanitizer (1.3.0) + loofah (~> 2.3) + rails-i18n (4.0.9) + i18n (~> 0.7) railties (~> 4.0) rails_safe_tasks (1.0.0) - railties (4.1.16) - actionpack (= 4.1.16) - activesupport (= 4.1.16) + railties (4.2.11.3) + actionpack (= 4.2.11.3) + activesupport (= 4.2.11.3) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rainbow (3.0.0) @@ -518,10 +553,10 @@ GEM activerecord (>= 3.0, < 5.2) activesupport (>= 3.0, < 5.2) i18n - rb-fsevent (0.10.3) + rb-fsevent (0.10.4) rb-inotify (0.10.1) ffi (~> 1.0) - rbvmomi (2.2.0) + rbvmomi (2.4.1) builder (~> 3.0) json (>= 1.8) nokogiri (~> 1.5) @@ -529,41 +564,47 @@ GEM redcarpet (3.5.0) request_store (1.5.0) rack (>= 1.4) - responders (1.1.2) - railties (>= 3.2, < 4.2) + 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.4.0) + roadie (3.5.1) css_parser (~> 1.4) - nokogiri (~> 1.5) + 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.9.0) - rspec-core (~> 3.9.0) - rspec-expectations (~> 3.9.0) - rspec-mocks (~> 3.9.0) - rspec-core (3.9.1) - rspec-support (~> 3.9.1) - rspec-expectations (3.9.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.9.0) - rspec-mocks (3.9.1) + rspec-support (~> 3.10.0) + rspec-mocks (3.10.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.9.0) - rspec-rails (3.9.1) - actionpack (>= 3.0) - activesupport (>= 3.0) - railties (>= 3.0) - rspec-core (~> 3.9.0) - rspec-expectations (~> 3.9.0) - rspec-mocks (~> 3.9.0) - rspec-support (~> 3.9.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.9.2) + rspec-support (3.10.0) rswag (2.3.1) rswag-api (= 2.3.1) rswag-specs (= 2.3.1) @@ -605,8 +646,8 @@ GEM selenium-webdriver (3.142.7) childprocess (>= 0.5, < 4.0) rubyzip (>= 1.2.2) - shoulda-matchers (3.1.3) - activesupport (>= 4.0.0) + shoulda-matchers (4.0.1) + activesupport (>= 4.2.0) simplecov (0.17.1) docile (~> 1.1) json (>= 1.8, < 3) @@ -630,7 +671,7 @@ GEM sprockets (>= 2.8, < 4.0) state_machine (1.2.0) stringex (1.5.1) - stripe (5.25.0) + stripe (5.28.0) temple (0.8.2) test-prof (0.7.5) test-unit (3.3.6) @@ -643,6 +684,9 @@ GEM 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 (1.7.0) unicorn (5.7.0) kgio (~> 2.6) @@ -670,8 +714,8 @@ GEM wkhtmltopdf-binary (0.12.5) xml-simple (1.1.5) xmlrpc (0.3.0) - xpath (2.1.0) - nokogiri (~> 1.3) + xpath (3.2.0) + nokogiri (~> 1.8) PLATFORMS ruby @@ -726,20 +770,20 @@ DEPENDENCIES gmaps4rails haml highline (= 2.0.3) - i18n (~> 0.6.11) + i18n i18n-js (~> 3.8.0) immigrant jquery-migrate-rails jquery-rails (= 3.1.5) jquery-ui-rails (~> 4.2) - json (>= 1.7.7) + json json_spec (~> 1.1.4) jwt (~> 2.2) kaminari (~> 0.17.0) knapsack letter_opener (>= 1.4.1) mini_racer (= 0.2.15) - money (= 5.1.1) + money (< 6.1.0) newrelic_rpm (~> 3.0) oauth2 (~> 1.4.4) ofn-qz! @@ -754,8 +798,8 @@ DEPENDENCIES rack-mini-profiler (< 3.0.0) rack-rewrite rack-ssl - rails (~> 4.1.16) - rails-i18n (~> 4.0) + rails (~> 4.2) + rails-i18n rails_safe_tasks (~> 1.0) ransack (~> 1.8.10) redcarpet From 25dd47e511a3a8887bfdd3f5698cedc46dfa787d Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Tue, 3 Nov 2020 23:48:13 +0000 Subject: [PATCH 02/58] Add responders gem https://guides.rubyonrails.org/upgrading_ruby_on_rails.html#responders --- Gemfile | 1 + Gemfile.lock | 1 + 2 files changed, 2 insertions(+) diff --git a/Gemfile b/Gemfile index ff1e3682b2..23b2900d34 100644 --- a/Gemfile +++ b/Gemfile @@ -9,6 +9,7 @@ gem 'rails-i18n' gem 'rails_safe_tasks', '~> 1.0' gem "activerecord-import" +gem 'responders', '~> 2.0' gem "catalog", path: "./engines/catalog" gem 'dfc_provider', path: './engines/dfc_provider' diff --git a/Gemfile.lock b/Gemfile.lock index 005099747d..b9cdbb18c2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -803,6 +803,7 @@ DEPENDENCIES rails_safe_tasks (~> 1.0) ransack (~> 1.8.10) redcarpet + responders (~> 2.0) roadie-rails (~> 1.3.0) roo (~> 2.8.3) rspec-rails (>= 3.5.2) From ff9f6c3317ae5b924445b7855a25283598e9d0db Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Wed, 4 Nov 2020 00:47:11 +0000 Subject: [PATCH 03/58] Remove foreigner gem https://guides.rubyonrails.org/upgrading_ruby_on_rails.html#foreign-key-support --- Gemfile | 1 - Gemfile.lock | 3 --- 2 files changed, 4 deletions(-) diff --git a/Gemfile b/Gemfile index 23b2900d34..02318308f9 100644 --- a/Gemfile +++ b/Gemfile @@ -91,7 +91,6 @@ gem 'combine_pdf' gem 'wicked_pdf' gem 'wkhtmltopdf-binary' -gem 'foreigner' gem 'immigrant' gem 'roo', '~> 2.8.3' diff --git a/Gemfile.lock b/Gemfile.lock index b9cdbb18c2..2a4e82502f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -386,8 +386,6 @@ GEM fog-xml (0.1.3) fog-core nokogiri (>= 1.5.11, < 2.0.0) - foreigner (1.7.4) - activerecord (>= 3.0.0) formatador (0.2.5) foundation-icons-sass-rails (3.0.0) railties (>= 3.1.1) @@ -762,7 +760,6 @@ DEPENDENCIES factory_bot_rails (= 4.10.0) ffaker (~> 1.16) figaro - foreigner foundation-icons-sass-rails foundation-rails (= 5.5.2.1) fuubar (~> 2.5.0) From 9205c85d4dec41aaa4f64e398ad5f455d08a1395 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Wed, 4 Nov 2020 00:47:53 +0000 Subject: [PATCH 04/58] Run rake db:migrate --- db/schema.rb | 1185 ++++++++++++++++++++++++-------------------------- 1 file changed, 568 insertions(+), 617 deletions(-) diff --git a/db/schema.rb b/db/schema.rb index 50d6f271f4..e71191e567 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -16,29 +16,29 @@ ActiveRecord::Schema.define(version: 20201113163227) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" - create_table "adjustment_metadata", force: true do |t| + create_table "adjustment_metadata", force: :cascade do |t| t.integer "adjustment_id" t.integer "enterprise_id" - t.string "fee_name" - t.string "fee_type" - t.string "enterprise_role" + t.string "fee_name", limit: 255 + t.string "fee_type", limit: 255 + t.string "enterprise_role", limit: 255 end add_index "adjustment_metadata", ["adjustment_id"], name: "index_adjustment_metadata_on_adjustment_id", using: :btree add_index "adjustment_metadata", ["enterprise_id"], name: "index_adjustment_metadata_on_enterprise_id", using: :btree - create_table "column_preferences", force: true do |t| - t.integer "user_id", null: false - t.string "action_name", null: false - t.string "column_name", null: false - t.boolean "visible", null: false - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + create_table "column_preferences", force: :cascade do |t| + t.integer "user_id", null: false + t.string "action_name", limit: 255, null: false + t.string "column_name", limit: 255, null: false + t.boolean "visible", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end add_index "column_preferences", ["user_id", "action_name", "column_name"], name: "index_column_prefs_on_user_id_and_action_name_and_column_name", unique: true, using: :btree - create_table "coordinator_fees", force: true do |t| + create_table "coordinator_fees", force: :cascade do |t| t.integer "order_cycle_id" t.integer "enterprise_fee_id" end @@ -46,17 +46,17 @@ ActiveRecord::Schema.define(version: 20201113163227) do add_index "coordinator_fees", ["enterprise_fee_id"], name: "index_coordinator_fees_on_enterprise_fee_id", using: :btree add_index "coordinator_fees", ["order_cycle_id"], name: "index_coordinator_fees_on_order_cycle_id", using: :btree - create_table "customers", force: true do |t| - t.string "email", null: false - t.integer "enterprise_id", null: false - t.string "code" + create_table "customers", force: :cascade do |t| + t.string "email", limit: 255, null: false + t.integer "enterprise_id", null: false + t.string "code", limit: 255 t.integer "user_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.integer "bill_address_id" t.integer "ship_address_id" - t.string "name" - t.boolean "allow_charges", default: false, null: false + t.string "name", limit: 255 + t.boolean "allow_charges", default: false, null: false t.datetime "terms_and_conditions_accepted_at" end @@ -66,23 +66,23 @@ ActiveRecord::Schema.define(version: 20201113163227) do add_index "customers", ["ship_address_id"], name: "index_customers_on_ship_address_id", using: :btree add_index "customers", ["user_id"], name: "index_customers_on_user_id", using: :btree - create_table "delayed_jobs", force: true do |t| - t.integer "priority", default: 0, null: false - t.integer "attempts", default: 0, null: false - t.text "handler", null: false + create_table "delayed_jobs", force: :cascade do |t| + t.integer "priority", default: 0, null: false + t.integer "attempts", default: 0, null: false + t.text "handler", null: false t.text "last_error" t.datetime "run_at" t.datetime "locked_at" t.datetime "failed_at" - t.string "locked_by" - t.string "queue" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.string "locked_by", limit: 255 + t.string "queue", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end add_index "delayed_jobs", ["priority", "run_at"], name: "delayed_jobs_priority", using: :btree - create_table "distributors_payment_methods", id: false, force: true do |t| + create_table "distributors_payment_methods", id: false, force: :cascade do |t| t.integer "distributor_id" t.integer "payment_method_id" end @@ -90,7 +90,7 @@ ActiveRecord::Schema.define(version: 20201113163227) do add_index "distributors_payment_methods", ["distributor_id"], name: "index_distributors_payment_methods_on_distributor_id", using: :btree add_index "distributors_payment_methods", ["payment_method_id"], name: "index_distributors_payment_methods_on_payment_method_id", using: :btree - create_table "distributors_shipping_methods", force: true do |t| + create_table "distributors_shipping_methods", force: :cascade do |t| t.integer "distributor_id" t.integer "shipping_method_id" t.datetime "created_at", null: false @@ -100,49 +100,49 @@ ActiveRecord::Schema.define(version: 20201113163227) do add_index "distributors_shipping_methods", ["distributor_id"], name: "index_distributors_shipping_methods_on_distributor_id", using: :btree add_index "distributors_shipping_methods", ["shipping_method_id"], name: "index_distributors_shipping_methods_on_shipping_method_id", using: :btree - create_table "enterprise_fees", force: true do |t| + create_table "enterprise_fees", force: :cascade do |t| t.integer "enterprise_id" - t.string "fee_type" - t.string "name" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.string "fee_type", limit: 255 + t.string "name", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.integer "tax_category_id" - t.boolean "inherits_tax_category", default: false, null: false + t.boolean "inherits_tax_category", default: false, null: false end add_index "enterprise_fees", ["enterprise_id"], name: "index_enterprise_fees_on_enterprise_id", using: :btree add_index "enterprise_fees", ["tax_category_id"], name: "index_enterprise_fees_on_tax_category_id", using: :btree - create_table "enterprise_groups", force: true do |t| - t.string "name" + create_table "enterprise_groups", force: :cascade do |t| + t.string "name", limit: 255 t.boolean "on_front_page" t.integer "position" - t.string "promo_image_file_name" - t.string "promo_image_content_type" + t.string "promo_image_file_name", limit: 255 + t.string "promo_image_content_type", limit: 255 t.integer "promo_image_file_size" t.datetime "promo_image_updated_at" t.text "description" t.text "long_description" - t.string "logo_file_name" - t.string "logo_content_type" + t.string "logo_file_name", limit: 255 + t.string "logo_content_type", limit: 255 t.integer "logo_file_size" t.datetime "logo_updated_at" t.integer "address_id" - t.string "email", default: "", null: false - t.string "website", default: "", null: false - t.string "facebook", default: "", null: false - t.string "instagram", default: "", null: false - t.string "linkedin", default: "", null: false - t.string "twitter", default: "", null: false + t.string "email", limit: 255, default: "", null: false + t.string "website", limit: 255, default: "", null: false + t.string "facebook", limit: 255, default: "", null: false + t.string "instagram", limit: 255, default: "", null: false + t.string "linkedin", limit: 255, default: "", null: false + t.string "twitter", limit: 255, default: "", null: false t.integer "owner_id" - t.string "permalink", null: false + t.string "permalink", limit: 255, null: false end add_index "enterprise_groups", ["address_id"], name: "index_enterprise_groups_on_address_id", using: :btree add_index "enterprise_groups", ["owner_id"], name: "index_enterprise_groups_on_owner_id", using: :btree add_index "enterprise_groups", ["permalink"], name: "index_enterprise_groups_on_permalink", unique: true, using: :btree - create_table "enterprise_groups_enterprises", id: false, force: true do |t| + create_table "enterprise_groups_enterprises", id: false, force: :cascade do |t| t.integer "enterprise_group_id" t.integer "enterprise_id" end @@ -150,14 +150,14 @@ ActiveRecord::Schema.define(version: 20201113163227) do add_index "enterprise_groups_enterprises", ["enterprise_group_id"], name: "index_enterprise_groups_enterprises_on_enterprise_group_id", using: :btree add_index "enterprise_groups_enterprises", ["enterprise_id"], name: "index_enterprise_groups_enterprises_on_enterprise_id", using: :btree - create_table "enterprise_relationship_permissions", force: true do |t| + create_table "enterprise_relationship_permissions", force: :cascade do |t| t.integer "enterprise_relationship_id" - t.string "name", null: false + t.string "name", limit: 255, null: false end add_index "enterprise_relationship_permissions", ["enterprise_relationship_id"], name: "index_erp_on_erid", using: :btree - create_table "enterprise_relationships", force: true do |t| + create_table "enterprise_relationships", force: :cascade do |t| t.integer "parent_id" t.integer "child_id" end @@ -166,7 +166,7 @@ ActiveRecord::Schema.define(version: 20201113163227) do add_index "enterprise_relationships", ["parent_id", "child_id"], name: "index_enterprise_relationships_on_parent_id_and_child_id", unique: true, using: :btree add_index "enterprise_relationships", ["parent_id"], name: "index_enterprise_relationships_on_parent_id", using: :btree - create_table "enterprise_roles", force: true do |t| + create_table "enterprise_roles", force: :cascade do |t| t.integer "user_id" t.integer "enterprise_id" t.boolean "receives_notifications", default: false @@ -177,49 +177,49 @@ ActiveRecord::Schema.define(version: 20201113163227) do add_index "enterprise_roles", ["user_id", "enterprise_id"], name: "index_enterprise_roles_on_user_id_and_enterprise_id", unique: true, using: :btree add_index "enterprise_roles", ["user_id"], name: "index_enterprise_roles_on_user_id", using: :btree - create_table "enterprises", force: true do |t| - t.string "name" + create_table "enterprises", force: :cascade do |t| + t.string "name", limit: 255 t.text "description" t.text "long_description" t.boolean "is_primary_producer" - t.string "contact_name" - t.string "phone" - t.string "website" - t.string "twitter" - t.string "abn" - t.string "acn" + t.string "contact_name", limit: 255 + t.string "phone", limit: 255 + t.string "website", limit: 255 + t.string "twitter", limit: 255 + t.string "abn", limit: 255 + t.string "acn", limit: 255 t.integer "address_id" t.text "pickup_times" - t.string "next_collection_at" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.string "next_collection_at", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.text "distributor_info" - t.string "logo_file_name" - t.string "logo_content_type" + t.string "logo_file_name", limit: 255 + t.string "logo_content_type", limit: 255 t.integer "logo_file_size" t.datetime "logo_updated_at" - t.string "promo_image_file_name" - t.string "promo_image_content_type" + t.string "promo_image_file_name", limit: 255 + t.string "promo_image_content_type", limit: 255 t.integer "promo_image_file_size" t.datetime "promo_image_updated_at" - t.boolean "visible", default: true - t.string "facebook" - t.string "instagram" - t.string "linkedin" - t.integer "owner_id", null: false - t.string "sells", default: "none", null: false - t.boolean "producer_profile_only", default: false - t.string "permalink", null: false - t.boolean "charges_sales_tax", default: false, null: false - t.string "email_address" - t.boolean "require_login", default: false, null: false - t.boolean "allow_guest_orders", default: true, null: false + t.boolean "visible", default: true + t.string "facebook", limit: 255 + t.string "instagram", limit: 255 + t.string "linkedin", limit: 255 + t.integer "owner_id", null: false + t.string "sells", limit: 255, default: "none", null: false + t.boolean "producer_profile_only", default: false + t.string "permalink", limit: 255, null: false + t.boolean "charges_sales_tax", default: false, null: false + t.string "email_address", limit: 255 + t.boolean "require_login", default: false, null: false + t.boolean "allow_guest_orders", default: true, null: false t.text "invoice_text" - t.boolean "display_invoice_logo", default: false - t.boolean "allow_order_changes", default: false, null: false - t.boolean "enable_subscriptions", default: false, null: false - t.string "terms_and_conditions_file_name" - t.string "terms_and_conditions_content_type" + t.boolean "display_invoice_logo", default: false + t.boolean "allow_order_changes", default: false, null: false + t.boolean "enable_subscriptions", default: false, null: false + t.string "terms_and_conditions_file_name", limit: 255 + t.string "terms_and_conditions_content_type", limit: 255 t.integer "terms_and_conditions_file_size" t.datetime "terms_and_conditions_updated_at" end @@ -231,7 +231,7 @@ ActiveRecord::Schema.define(version: 20201113163227) do add_index "enterprises", ["permalink"], name: "index_enterprises_on_permalink", unique: true, using: :btree add_index "enterprises", ["sells"], name: "index_enterprises_on_sells", using: :btree - create_table "exchange_fees", force: true do |t| + create_table "exchange_fees", force: :cascade do |t| t.integer "exchange_id" t.integer "enterprise_fee_id" t.datetime "created_at", null: false @@ -241,7 +241,7 @@ ActiveRecord::Schema.define(version: 20201113163227) do add_index "exchange_fees", ["enterprise_fee_id"], name: "index_exchange_fees_on_enterprise_fee_id", using: :btree add_index "exchange_fees", ["exchange_id"], name: "index_exchange_fees_on_exchange_id", using: :btree - create_table "exchange_variants", force: true do |t| + create_table "exchange_variants", force: :cascade do |t| t.integer "exchange_id" t.integer "variant_id" t.datetime "created_at", null: false @@ -251,7 +251,7 @@ ActiveRecord::Schema.define(version: 20201113163227) do add_index "exchange_variants", ["exchange_id"], name: "index_exchange_variants_on_exchange_id", using: :btree add_index "exchange_variants", ["variant_id"], name: "index_exchange_variants_on_variant_id", using: :btree - create_table "exchanges", force: true do |t| + create_table "exchanges", force: :cascade do |t| t.integer "order_cycle_id" t.integer "sender_id" t.integer "receiver_id" @@ -267,7 +267,7 @@ ActiveRecord::Schema.define(version: 20201113163227) do add_index "exchanges", ["receiver_id"], name: "index_exchanges_on_receiver_id", using: :btree add_index "exchanges", ["sender_id"], name: "index_exchanges_on_sender_id", using: :btree - create_table "inventory_items", force: true do |t| + create_table "inventory_items", force: :cascade do |t| t.integer "enterprise_id", null: false t.integer "variant_id", null: false t.boolean "visible", default: true, null: false @@ -277,7 +277,7 @@ ActiveRecord::Schema.define(version: 20201113163227) do add_index "inventory_items", ["enterprise_id", "variant_id"], name: "index_inventory_items_on_enterprise_id_and_variant_id", unique: true, using: :btree - create_table "order_cycle_schedules", force: true do |t| + create_table "order_cycle_schedules", force: :cascade do |t| t.integer "order_cycle_id", null: false t.integer "schedule_id", null: false t.datetime "created_at", null: false @@ -287,29 +287,29 @@ ActiveRecord::Schema.define(version: 20201113163227) do add_index "order_cycle_schedules", ["order_cycle_id"], name: "index_order_cycle_schedules_on_order_cycle_id", using: :btree add_index "order_cycle_schedules", ["schedule_id"], name: "index_order_cycle_schedules_on_schedule_id", using: :btree - create_table "order_cycles", force: true do |t| - t.string "name" + create_table "order_cycles", force: :cascade do |t| + t.string "name", limit: 255 t.datetime "orders_open_at" t.datetime "orders_close_at" t.integer "coordinator_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "producer_properties", force: true do |t| - t.string "value" + create_table "producer_properties", force: :cascade do |t| + t.string "value", limit: 255 t.integer "producer_id" t.integer "property_id" - t.integer "position", default: 0, null: false - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.integer "position", default: 0, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end add_index "producer_properties", ["position"], name: "index_producer_properties_on_position", using: :btree add_index "producer_properties", ["producer_id"], name: "index_producer_properties_on_producer_id", using: :btree add_index "producer_properties", ["property_id"], name: "index_producer_properties_on_property_id", using: :btree - create_table "proxy_orders", force: true do |t| + create_table "proxy_orders", force: :cascade do |t| t.integer "subscription_id", null: false t.integer "order_id" t.datetime "canceled_at" @@ -324,53 +324,53 @@ ActiveRecord::Schema.define(version: 20201113163227) do add_index "proxy_orders", ["order_id"], name: "index_proxy_orders_on_order_id", unique: true, using: :btree add_index "proxy_orders", ["subscription_id"], name: "index_proxy_orders_on_subscription_id", using: :btree - create_table "schedules", force: true do |t| - t.string "name", null: false - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + create_table "schedules", force: :cascade do |t| + t.string "name", limit: 255, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "sessions", force: true do |t| - t.string "session_id", null: false + create_table "sessions", force: :cascade do |t| + t.string "session_id", limit: 255, null: false t.text "data" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end add_index "sessions", ["session_id"], name: "index_sessions_on_session_id", using: :btree add_index "sessions", ["updated_at"], name: "index_sessions_on_updated_at", using: :btree - create_table "spree_activators", force: true do |t| - t.string "description" + create_table "spree_activators", force: :cascade do |t| + t.string "description", limit: 255 t.datetime "expires_at" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.datetime "starts_at" - t.string "name" - t.string "event_name" - t.string "type" + t.string "name", limit: 255 + t.string "event_name", limit: 255 + t.string "type", limit: 255 t.integer "usage_limit" - t.string "match_policy", default: "all" - t.string "code" - t.boolean "advertise", default: false - t.string "path" + t.string "match_policy", limit: 255, default: "all" + t.string "code", limit: 255 + t.boolean "advertise", default: false + t.string "path", limit: 255 end - create_table "spree_addresses", force: true do |t| - t.string "firstname" - t.string "lastname" - t.string "address1" - t.string "address2" - t.string "city" - t.string "zipcode" - t.string "phone" - t.string "state_name" - t.string "alternative_phone" + create_table "spree_addresses", force: :cascade do |t| + t.string "firstname", limit: 255 + t.string "lastname", limit: 255 + t.string "address1", limit: 255 + t.string "address2", limit: 255 + t.string "city", limit: 255 + t.string "zipcode", limit: 255 + t.string "phone", limit: 255 + t.string "state_name", limit: 255 + t.string "alternative_phone", limit: 255 t.integer "state_id" t.integer "country_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.string "company" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "company", limit: 255 t.float "latitude" t.float "longitude" end @@ -378,34 +378,34 @@ ActiveRecord::Schema.define(version: 20201113163227) do add_index "spree_addresses", ["firstname"], name: "index_addresses_on_firstname", using: :btree add_index "spree_addresses", ["lastname"], name: "index_addresses_on_lastname", using: :btree - create_table "spree_adjustments", force: true do |t| + create_table "spree_adjustments", force: :cascade do |t| t.integer "source_id" - t.decimal "amount", precision: 10, scale: 2 - t.string "label" - t.string "source_type" + t.decimal "amount", precision: 10, scale: 2 + t.string "label", limit: 255 + t.string "source_type", limit: 255 t.integer "adjustable_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.boolean "mandatory" t.integer "originator_id" - t.string "originator_type" - t.boolean "eligible", default: true - t.string "adjustable_type" - t.decimal "included_tax", precision: 10, scale: 2, default: 0.0, null: false - t.string "state" + t.string "originator_type", limit: 255 + t.boolean "eligible", default: true + t.string "adjustable_type", limit: 255 + t.decimal "included_tax", precision: 10, scale: 2, default: 0.0, null: false + t.string "state", limit: 255 end add_index "spree_adjustments", ["adjustable_id"], name: "index_adjustments_on_order_id", using: :btree - create_table "spree_assets", force: true do |t| + create_table "spree_assets", force: :cascade do |t| t.integer "viewable_id" t.integer "attachment_width" t.integer "attachment_height" t.integer "attachment_file_size" t.integer "position" t.string "viewable_type", limit: 50 - t.string "attachment_content_type" - t.string "attachment_file_name" + t.string "attachment_content_type", limit: 255 + t.string "attachment_file_name", limit: 255 t.string "type", limit: 75 t.datetime "attachment_updated_at" t.text "alt" @@ -414,109 +414,109 @@ ActiveRecord::Schema.define(version: 20201113163227) do add_index "spree_assets", ["viewable_id"], name: "index_assets_on_viewable_id", using: :btree add_index "spree_assets", ["viewable_type", "type"], name: "index_assets_on_viewable_type_and_type", using: :btree - create_table "spree_calculators", force: true do |t| - t.string "type" - t.integer "calculable_id", null: false - t.string "calculable_type", null: false - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + create_table "spree_calculators", force: :cascade do |t| + t.string "type", limit: 255 + t.integer "calculable_id", null: false + t.string "calculable_type", limit: 255, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "spree_configurations", force: true do |t| - t.string "name" + create_table "spree_configurations", force: :cascade do |t| + t.string "name", limit: 255 t.string "type", limit: 50 - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end add_index "spree_configurations", ["name", "type"], name: "index_configurations_on_name_and_type", using: :btree - create_table "spree_countries", force: true do |t| - t.string "iso_name" - t.string "iso" - t.string "iso3" - t.string "name" + create_table "spree_countries", force: :cascade do |t| + t.string "iso_name", limit: 255 + t.string "iso", limit: 255 + t.string "iso3", limit: 255 + t.string "name", limit: 255 t.integer "numcode" - t.boolean "states_required", default: true + t.boolean "states_required", default: true end - create_table "spree_credit_cards", force: true do |t| - t.string "month" - t.string "year" - t.string "cc_type" - t.string "last_digits" - t.string "first_name" - t.string "last_name" - t.string "start_month" - t.string "start_year" - t.string "issue_number" + create_table "spree_credit_cards", force: :cascade do |t| + t.string "month", limit: 255 + t.string "year", limit: 255 + t.string "cc_type", limit: 255 + t.string "last_digits", limit: 255 + t.string "first_name", limit: 255 + t.string "last_name", limit: 255 + t.string "start_month", limit: 255 + t.string "start_year", limit: 255 + t.string "issue_number", limit: 255 t.integer "address_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.string "gateway_customer_profile_id" - t.string "gateway_payment_profile_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "gateway_customer_profile_id", limit: 255 + t.string "gateway_payment_profile_id", limit: 255 t.integer "user_id" t.integer "payment_method_id" - t.boolean "is_default", default: false + t.boolean "is_default", default: false end add_index "spree_credit_cards", ["payment_method_id"], name: "index_spree_credit_cards_on_payment_method_id", using: :btree add_index "spree_credit_cards", ["user_id"], name: "index_spree_credit_cards_on_user_id", using: :btree - create_table "spree_gateways", force: true do |t| - t.string "type" - t.string "name" + create_table "spree_gateways", force: :cascade do |t| + t.string "type", limit: 255 + t.string "name", limit: 255 t.text "description" - t.boolean "active", default: true - t.string "environment", default: "development" - t.string "server", default: "test" - t.boolean "test_mode", default: true - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.boolean "active", default: true + t.string "environment", limit: 255, default: "development" + t.string "server", limit: 255, default: "test" + t.boolean "test_mode", default: true + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "spree_inventory_units", force: true do |t| - t.string "state" + create_table "spree_inventory_units", force: :cascade do |t| + t.string "state", limit: 255 t.integer "variant_id" t.integer "order_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.integer "shipment_id" t.integer "return_authorization_id" - t.boolean "pending", default: true + t.boolean "pending", default: true end add_index "spree_inventory_units", ["order_id"], name: "index_inventory_units_on_order_id", using: :btree add_index "spree_inventory_units", ["shipment_id"], name: "index_inventory_units_on_shipment_id", using: :btree add_index "spree_inventory_units", ["variant_id"], name: "index_inventory_units_on_variant_id", using: :btree - create_table "spree_line_items", force: true do |t| + create_table "spree_line_items", force: :cascade do |t| t.integer "order_id" t.integer "variant_id" - t.integer "quantity", null: false - t.decimal "price", precision: 8, scale: 2, null: false - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.integer "quantity", null: false + t.decimal "price", precision: 8, scale: 2, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.integer "max_quantity" - t.string "currency" - t.decimal "distribution_fee", precision: 10, scale: 2 - t.decimal "final_weight_volume", precision: 10, scale: 2 - t.decimal "cost_price", precision: 8, scale: 2 + t.string "currency", limit: 255 + t.decimal "distribution_fee", precision: 10, scale: 2 + t.decimal "final_weight_volume", precision: 10, scale: 2 + t.decimal "cost_price", precision: 8, scale: 2 t.integer "tax_category_id" end add_index "spree_line_items", ["order_id"], name: "index_line_items_on_order_id", using: :btree add_index "spree_line_items", ["variant_id"], name: "index_line_items_on_variant_id", using: :btree - create_table "spree_log_entries", force: true do |t| + create_table "spree_log_entries", force: :cascade do |t| t.integer "source_id" - t.string "source_type" + t.string "source_type", limit: 255 t.text "details" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "spree_option_types", force: true do |t| + create_table "spree_option_types", force: :cascade do |t| t.string "name", limit: 100 t.string "presentation", limit: 100 t.datetime "created_at", null: false @@ -524,23 +524,23 @@ ActiveRecord::Schema.define(version: 20201113163227) do t.integer "position", default: 0, null: false end - create_table "spree_option_values", force: true do |t| + create_table "spree_option_values", force: :cascade do |t| t.integer "position" - t.string "name" - t.string "presentation" + t.string "name", limit: 255 + t.string "presentation", limit: 255 t.integer "option_type_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "spree_option_values_line_items", id: false, force: true do |t| + create_table "spree_option_values_line_items", id: false, force: :cascade do |t| t.integer "line_item_id" t.integer "option_value_id" end add_index "spree_option_values_line_items", ["line_item_id"], name: "index_option_values_line_items_on_line_item_id", using: :btree - create_table "spree_option_values_variants", id: false, force: true do |t| + create_table "spree_option_values_variants", id: false, force: :cascade do |t| t.integer "variant_id" t.integer "option_value_id" end @@ -548,27 +548,27 @@ ActiveRecord::Schema.define(version: 20201113163227) do add_index "spree_option_values_variants", ["variant_id", "option_value_id"], name: "index_option_values_variants_on_variant_id_and_option_value_id", using: :btree add_index "spree_option_values_variants", ["variant_id"], name: "index_option_values_variants_on_variant_id", using: :btree - create_table "spree_orders", force: true do |t| + create_table "spree_orders", force: :cascade do |t| t.string "number", limit: 15 - t.decimal "item_total", precision: 10, scale: 2, default: 0.0, null: false - t.decimal "total", precision: 10, scale: 2, default: 0.0, null: false - t.string "state" - t.decimal "adjustment_total", precision: 10, scale: 2, default: 0.0, null: false + t.decimal "item_total", precision: 10, scale: 2, default: 0.0, null: false + t.decimal "total", precision: 10, scale: 2, default: 0.0, null: false + t.string "state", limit: 255 + t.decimal "adjustment_total", precision: 10, scale: 2, default: 0.0, null: false t.integer "user_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.datetime "completed_at" t.integer "bill_address_id" t.integer "ship_address_id" - t.decimal "payment_total", precision: 10, scale: 2, default: 0.0 - t.string "shipment_state" - t.string "payment_state" - t.string "email" + t.decimal "payment_total", precision: 10, scale: 2, default: 0.0 + t.string "shipment_state", limit: 255 + t.string "payment_state", limit: 255 + t.string "email", limit: 255 t.text "special_instructions" t.integer "distributor_id" t.integer "order_cycle_id" - t.string "currency" - t.string "last_ip_address" + t.string "currency", limit: 255 + t.string "last_ip_address", limit: 255 t.integer "customer_id" t.integer "created_by_id" end @@ -580,57 +580,57 @@ ActiveRecord::Schema.define(version: 20201113163227) do add_index "spree_orders", ["order_cycle_id"], name: "index_spree_orders_on_order_cycle_id", using: :btree add_index "spree_orders", ["user_id"], name: "index_spree_orders_on_user_id", using: :btree - create_table "spree_payment_methods", force: true do |t| - t.string "type" - t.string "name" + create_table "spree_payment_methods", force: :cascade do |t| + t.string "type", limit: 255 + t.string "name", limit: 255 t.text "description" - t.boolean "active", default: true - t.string "environment", default: "development" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.boolean "active", default: true + t.string "environment", limit: 255, default: "development" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.datetime "deleted_at" - t.string "display_on" + t.string "display_on", limit: 255 end - create_table "spree_payments", force: true do |t| - t.decimal "amount", precision: 10, scale: 2, default: 0.0, null: false + create_table "spree_payments", force: :cascade do |t| + t.decimal "amount", precision: 10, scale: 2, default: 0.0, null: false t.integer "order_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.integer "source_id" - t.string "source_type" + t.string "source_type", limit: 255 t.integer "payment_method_id" - t.string "state" - t.string "response_code" - t.string "avs_response" - t.string "identifier" - t.string "cvv_response_code" + t.string "state", limit: 255 + t.string "response_code", limit: 255 + t.string "avs_response", limit: 255 + t.string "identifier", limit: 255 + t.string "cvv_response_code", limit: 255 t.text "cvv_response_message" end add_index "spree_payments", ["order_id"], name: "index_spree_payments_on_order_id", using: :btree - create_table "spree_paypal_accounts", force: true do |t| - t.string "email" - t.string "payer_id" - t.string "payer_country" - t.string "payer_status" + create_table "spree_paypal_accounts", force: :cascade do |t| + t.string "email", limit: 255 + t.string "payer_id", limit: 255 + t.string "payer_country", limit: 255 + t.string "payer_status", limit: 255 end - create_table "spree_paypal_express_checkouts", force: true do |t| - t.string "token" - t.string "payer_id" - t.string "transaction_id" - t.string "state", default: "complete" - t.string "refund_transaction_id" + create_table "spree_paypal_express_checkouts", force: :cascade do |t| + t.string "token", limit: 255 + t.string "payer_id", limit: 255 + t.string "transaction_id", limit: 255 + t.string "state", limit: 255, default: "complete" + t.string "refund_transaction_id", limit: 255 t.datetime "refunded_at" - t.string "refund_type" + t.string "refund_type", limit: 255 t.datetime "created_at" end add_index "spree_paypal_express_checkouts", ["transaction_id"], name: "index_spree_paypal_express_checkouts_on_transaction_id", using: :btree - create_table "spree_pending_promotions", force: true do |t| + create_table "spree_pending_promotions", force: :cascade do |t| t.integer "user_id" t.integer "promotion_id" end @@ -638,40 +638,40 @@ ActiveRecord::Schema.define(version: 20201113163227) do add_index "spree_pending_promotions", ["promotion_id"], name: "index_spree_pending_promotions_on_promotion_id", using: :btree add_index "spree_pending_promotions", ["user_id"], name: "index_spree_pending_promotions_on_user_id", using: :btree - create_table "spree_preferences", force: true do |t| + create_table "spree_preferences", force: :cascade do |t| t.text "value" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.string "key" - t.string "value_type" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "key", limit: 255 + t.string "value_type", limit: 255 end add_index "spree_preferences", ["key"], name: "index_spree_preferences_on_key", unique: true, using: :btree - create_table "spree_prices", force: true do |t| - t.integer "variant_id", null: false - t.decimal "amount", precision: 8, scale: 2 - t.string "currency" + create_table "spree_prices", force: :cascade do |t| + t.integer "variant_id", null: false + t.decimal "amount", precision: 8, scale: 2 + t.string "currency", limit: 255 t.datetime "deleted_at" end add_index "spree_prices", ["variant_id"], name: "index_spree_prices_on_variant_id", using: :btree - create_table "spree_product_groups", force: true do |t| - t.string "name" - t.string "permalink" - t.string "order" + create_table "spree_product_groups", force: :cascade do |t| + t.string "name", limit: 255 + t.string "permalink", limit: 255 + t.string "order", limit: 255 end add_index "spree_product_groups", ["name"], name: "index_product_groups_on_name", using: :btree add_index "spree_product_groups", ["permalink"], name: "index_product_groups_on_permalink", using: :btree - create_table "spree_product_groups_products", id: false, force: true do |t| + create_table "spree_product_groups_products", id: false, force: :cascade do |t| t.integer "product_id" t.integer "product_group_id" end - create_table "spree_product_option_types", force: true do |t| + create_table "spree_product_option_types", force: :cascade do |t| t.integer "position" t.integer "product_id" t.integer "option_type_id" @@ -679,19 +679,19 @@ ActiveRecord::Schema.define(version: 20201113163227) do t.datetime "updated_at", null: false end - create_table "spree_product_properties", force: true do |t| - t.string "value" + create_table "spree_product_properties", force: :cascade do |t| + t.string "value", limit: 255 t.integer "product_id" t.integer "property_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.integer "position", default: 0 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.integer "position", default: 0 end add_index "spree_product_properties", ["product_id"], name: "index_product_properties_on_product_id", using: :btree - create_table "spree_product_scopes", force: true do |t| - t.string "name" + create_table "spree_product_scopes", force: :cascade do |t| + t.string "name", limit: 255 t.text "arguments" t.integer "product_group_id" end @@ -699,27 +699,27 @@ ActiveRecord::Schema.define(version: 20201113163227) do add_index "spree_product_scopes", ["name"], name: "index_product_scopes_on_name", using: :btree add_index "spree_product_scopes", ["product_group_id"], name: "index_product_scopes_on_product_group_id", using: :btree - create_table "spree_products", force: true do |t| - t.string "name", default: "", null: false + create_table "spree_products", force: :cascade do |t| + t.string "name", limit: 255, default: "", null: false t.text "description" t.datetime "available_on" t.datetime "deleted_at" - t.string "permalink" + t.string "permalink", limit: 255 t.text "meta_description" - t.string "meta_keywords" + t.string "meta_keywords", limit: 255 t.integer "tax_category_id" t.integer "shipping_category_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.integer "supplier_id" t.boolean "group_buy" t.float "group_buy_unit_size" - t.string "variant_unit" + t.string "variant_unit", limit: 255 t.float "variant_unit_scale" - t.string "variant_unit_name" + t.string "variant_unit_name", limit: 255 t.text "notes" - t.integer "primary_taxon_id", null: false - t.boolean "inherits_properties", default: true, null: false + t.integer "primary_taxon_id", null: false + t.boolean "inherits_properties", default: true, null: false end add_index "spree_products", ["available_on"], name: "index_products_on_available_on", using: :btree @@ -730,7 +730,7 @@ ActiveRecord::Schema.define(version: 20201113163227) do add_index "spree_products", ["primary_taxon_id"], name: "index_spree_products_on_primary_taxon_id", using: :btree add_index "spree_products", ["supplier_id"], name: "index_spree_products_on_supplier_id", using: :btree - create_table "spree_products_promotion_rules", id: false, force: true do |t| + create_table "spree_products_promotion_rules", id: false, force: :cascade do |t| t.integer "product_id" t.integer "promotion_rule_id" end @@ -738,7 +738,7 @@ ActiveRecord::Schema.define(version: 20201113163227) do add_index "spree_products_promotion_rules", ["product_id"], name: "index_products_promotion_rules_on_product_id", using: :btree add_index "spree_products_promotion_rules", ["promotion_rule_id"], name: "index_products_promotion_rules_on_promotion_rule_id", using: :btree - create_table "spree_products_taxons", force: true do |t| + create_table "spree_products_taxons", force: :cascade do |t| t.integer "product_id" t.integer "taxon_id" end @@ -746,31 +746,31 @@ ActiveRecord::Schema.define(version: 20201113163227) do add_index "spree_products_taxons", ["product_id"], name: "index_products_taxons_on_product_id", using: :btree add_index "spree_products_taxons", ["taxon_id"], name: "index_products_taxons_on_taxon_id", using: :btree - create_table "spree_promotion_action_line_items", force: true do |t| + create_table "spree_promotion_action_line_items", force: :cascade do |t| t.integer "promotion_action_id" t.integer "variant_id" t.integer "quantity", default: 1 end - create_table "spree_promotion_actions", force: true do |t| + create_table "spree_promotion_actions", force: :cascade do |t| t.integer "activator_id" t.integer "position" - t.string "type" + t.string "type", limit: 255 end - create_table "spree_promotion_rules", force: true do |t| + create_table "spree_promotion_rules", force: :cascade do |t| t.integer "activator_id" t.integer "user_id" t.integer "product_group_id" - t.string "type" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.string "type", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end add_index "spree_promotion_rules", ["product_group_id"], name: "index_promotion_rules_on_product_group_id", using: :btree add_index "spree_promotion_rules", ["user_id"], name: "index_promotion_rules_on_user_id", using: :btree - create_table "spree_promotion_rules_users", id: false, force: true do |t| + create_table "spree_promotion_rules_users", id: false, force: :cascade do |t| t.integer "user_id" t.integer "promotion_rule_id" end @@ -778,29 +778,29 @@ ActiveRecord::Schema.define(version: 20201113163227) do add_index "spree_promotion_rules_users", ["promotion_rule_id"], name: "index_promotion_rules_users_on_promotion_rule_id", using: :btree add_index "spree_promotion_rules_users", ["user_id"], name: "index_promotion_rules_users_on_user_id", using: :btree - create_table "spree_properties", force: true do |t| - t.string "name" - t.string "presentation", null: false - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + create_table "spree_properties", force: :cascade do |t| + t.string "name", limit: 255 + t.string "presentation", limit: 255, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "spree_return_authorizations", force: true do |t| - t.string "number" - t.string "state" - t.decimal "amount", precision: 10, scale: 2, default: 0.0, null: false + create_table "spree_return_authorizations", force: :cascade do |t| + t.string "number", limit: 255 + t.string "state", limit: 255 + t.decimal "amount", precision: 10, scale: 2, default: 0.0, null: false t.integer "order_id" t.text "reason" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.integer "stock_location_id" end - create_table "spree_roles", force: true do |t| - t.string "name" + create_table "spree_roles", force: :cascade do |t| + t.string "name", limit: 255 end - create_table "spree_roles_users", id: false, force: true do |t| + create_table "spree_roles_users", id: false, force: :cascade do |t| t.integer "role_id" t.integer "user_id" end @@ -808,30 +808,30 @@ ActiveRecord::Schema.define(version: 20201113163227) do add_index "spree_roles_users", ["role_id"], name: "index_roles_users_on_role_id", using: :btree add_index "spree_roles_users", ["user_id"], name: "index_roles_users_on_user_id", using: :btree - create_table "spree_shipments", force: true do |t| - t.string "tracking" - t.string "number" - t.decimal "cost", precision: 8, scale: 2 + create_table "spree_shipments", force: :cascade do |t| + t.string "tracking", limit: 255 + t.string "number", limit: 255 + t.decimal "cost", precision: 8, scale: 2 t.datetime "shipped_at" t.integer "order_id" t.integer "address_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.string "state" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "state", limit: 255 t.integer "stock_location_id" end add_index "spree_shipments", ["number"], name: "index_shipments_on_number", using: :btree add_index "spree_shipments", ["order_id"], name: "index_spree_shipments_on_order_id", unique: true, using: :btree - create_table "spree_shipping_categories", force: true do |t| - t.string "name" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.boolean "temperature_controlled", default: false, null: false + create_table "spree_shipping_categories", force: :cascade do |t| + t.string "name", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.boolean "temperature_controlled", default: false, null: false end - create_table "spree_shipping_method_categories", force: true do |t| + create_table "spree_shipping_method_categories", force: :cascade do |t| t.integer "shipping_method_id", null: false t.integer "shipping_category_id", null: false t.datetime "created_at", null: false @@ -841,23 +841,23 @@ ActiveRecord::Schema.define(version: 20201113163227) do add_index "spree_shipping_method_categories", ["shipping_category_id"], name: "index_spree_shipping_method_categories_on_shipping_category_id", using: :btree add_index "spree_shipping_method_categories", ["shipping_method_id"], name: "index_spree_shipping_method_categories_on_shipping_method_id", using: :btree - create_table "spree_shipping_methods", force: true do |t| - t.string "name" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.string "display_on" + create_table "spree_shipping_methods", force: :cascade do |t| + t.string "name", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "display_on", limit: 255 t.datetime "deleted_at" - t.boolean "require_ship_address", default: true + t.boolean "require_ship_address", default: true t.text "description" - t.string "tracking_url" + t.string "tracking_url", limit: 255 end - create_table "spree_shipping_methods_zones", id: false, force: true do |t| + create_table "spree_shipping_methods_zones", id: false, force: :cascade do |t| t.integer "shipping_method_id" t.integer "zone_id" end - create_table "spree_shipping_rates", force: true do |t| + create_table "spree_shipping_rates", force: :cascade do |t| t.integer "shipment_id" t.integer "shipping_method_id" t.boolean "selected", default: false @@ -868,37 +868,37 @@ ActiveRecord::Schema.define(version: 20201113163227) do add_index "spree_shipping_rates", ["shipment_id", "shipping_method_id"], name: "spree_shipping_rates_join_index", unique: true, using: :btree - create_table "spree_skrill_transactions", force: true do |t| - t.string "email" + create_table "spree_skrill_transactions", force: :cascade do |t| + t.string "email", limit: 255 t.float "amount" - t.string "currency" + t.string "currency", limit: 255 t.integer "transaction_id" t.integer "customer_id" - t.string "payment_type" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.string "payment_type", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "spree_state_changes", force: true do |t| - t.string "name" - t.string "previous_state" + create_table "spree_state_changes", force: :cascade do |t| + t.string "name", limit: 255 + t.string "previous_state", limit: 255 t.integer "stateful_id" t.integer "user_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.string "stateful_type" - t.string "next_state" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "stateful_type", limit: 255 + t.string "next_state", limit: 255 end add_index "spree_state_changes", ["stateful_id"], name: "index_spree_state_changes_on_stateful_id", using: :btree - create_table "spree_states", force: true do |t| - t.string "name" - t.string "abbr" + create_table "spree_states", force: :cascade do |t| + t.string "name", limit: 255 + t.string "abbr", limit: 255 t.integer "country_id" end - create_table "spree_stock_items", force: true do |t| + create_table "spree_stock_items", force: :cascade do |t| t.integer "stock_location_id" t.integer "variant_id" t.integer "count_on_hand", default: 0, null: false @@ -913,200 +913,200 @@ ActiveRecord::Schema.define(version: 20201113163227) do add_index "spree_stock_items", ["stock_location_id"], name: "index_spree_stock_items_on_stock_location_id", using: :btree add_index "spree_stock_items", ["variant_id"], name: "index_spree_stock_items_on_variant_id", unique: true, using: :btree - create_table "spree_stock_locations", force: true do |t| - t.string "name" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.string "address1" - t.string "address2" - t.string "city" + create_table "spree_stock_locations", force: :cascade do |t| + t.string "name", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "address1", limit: 255 + t.string "address2", limit: 255 + t.string "city", limit: 255 t.integer "state_id" - t.string "state_name" + t.string "state_name", limit: 255 t.integer "country_id" - t.string "zipcode" - t.string "phone" - t.boolean "active", default: true - t.boolean "backorderable_default", default: false - t.boolean "propagate_all_variants", default: true + t.string "zipcode", limit: 255 + t.string "phone", limit: 255 + t.boolean "active", default: true + t.boolean "backorderable_default", default: false + t.boolean "propagate_all_variants", default: true end - create_table "spree_stock_movements", force: true do |t| + create_table "spree_stock_movements", force: :cascade do |t| t.integer "stock_item_id" - t.integer "quantity", default: 0 - t.string "action" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.integer "quantity", default: 0 + t.string "action", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.integer "originator_id" - t.string "originator_type" + t.string "originator_type", limit: 255 end add_index "spree_stock_movements", ["stock_item_id"], name: "index_spree_stock_movements_on_stock_item_id", using: :btree - create_table "spree_stock_transfers", force: true do |t| - t.string "type" - t.string "reference" + create_table "spree_stock_transfers", force: :cascade do |t| + t.string "type", limit: 255 + t.string "reference", limit: 255 t.integer "source_location_id" t.integer "destination_location_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.string "number" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "number", limit: 255 end add_index "spree_stock_transfers", ["destination_location_id"], name: "index_spree_stock_transfers_on_destination_location_id", using: :btree add_index "spree_stock_transfers", ["number"], name: "index_spree_stock_transfers_on_number", using: :btree add_index "spree_stock_transfers", ["source_location_id"], name: "index_spree_stock_transfers_on_source_location_id", using: :btree - create_table "spree_tax_categories", force: true do |t| - t.string "name" - t.string "description" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.boolean "is_default", default: false + create_table "spree_tax_categories", force: :cascade do |t| + t.string "name", limit: 255 + t.string "description", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.boolean "is_default", default: false t.datetime "deleted_at" end - create_table "spree_tax_rates", force: true do |t| - t.decimal "amount", precision: 8, scale: 5 + create_table "spree_tax_rates", force: :cascade do |t| + t.decimal "amount", precision: 8, scale: 5 t.integer "zone_id" t.integer "tax_category_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.boolean "included_in_price", default: false - t.string "name" - t.boolean "show_rate_in_label", default: true + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.boolean "included_in_price", default: false + t.string "name", limit: 255 + t.boolean "show_rate_in_label", default: true t.datetime "deleted_at" end - create_table "spree_taxonomies", force: true do |t| - t.string "name", null: false - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.integer "position", default: 0 + create_table "spree_taxonomies", force: :cascade do |t| + t.string "name", limit: 255, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.integer "position", default: 0 end - create_table "spree_taxons", force: true do |t| + create_table "spree_taxons", force: :cascade do |t| t.integer "parent_id" - t.integer "position", default: 0 - t.string "name", null: false - t.string "permalink" + t.integer "position", default: 0 + t.string "name", limit: 255, null: false + t.string "permalink", limit: 255 t.integer "taxonomy_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.integer "lft" t.integer "rgt" - t.string "icon_file_name" - t.string "icon_content_type" + t.string "icon_file_name", limit: 255 + t.string "icon_content_type", limit: 255 t.integer "icon_file_size" t.datetime "icon_updated_at" t.text "description" - t.string "meta_title" - t.string "meta_description" - t.string "meta_keywords" + t.string "meta_title", limit: 255 + t.string "meta_description", limit: 255 + t.string "meta_keywords", limit: 255 end add_index "spree_taxons", ["parent_id"], name: "index_taxons_on_parent_id", using: :btree add_index "spree_taxons", ["permalink"], name: "index_taxons_on_permalink", using: :btree add_index "spree_taxons", ["taxonomy_id"], name: "index_taxons_on_taxonomy_id", using: :btree - create_table "spree_tokenized_permissions", force: true do |t| + create_table "spree_tokenized_permissions", force: :cascade do |t| t.integer "permissable_id" - t.string "permissable_type" - t.string "token" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.string "permissable_type", limit: 255 + t.string "token", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end add_index "spree_tokenized_permissions", ["permissable_id", "permissable_type"], name: "index_tokenized_name_and_type", using: :btree - create_table "spree_users", force: true do |t| - t.string "encrypted_password" - t.string "password_salt" - t.string "email" - t.string "remember_token" - t.string "persistence_token" - t.string "reset_password_token" - t.string "perishable_token" - t.integer "sign_in_count", default: 0, null: false - t.integer "failed_attempts", default: 0, null: false + create_table "spree_users", force: :cascade do |t| + t.string "encrypted_password", limit: 255 + t.string "password_salt", limit: 255 + t.string "email", limit: 255 + t.string "remember_token", limit: 255 + t.string "persistence_token", limit: 255 + t.string "reset_password_token", limit: 255 + t.string "perishable_token", limit: 255 + t.integer "sign_in_count", default: 0, null: false + t.integer "failed_attempts", default: 0, null: false t.datetime "last_request_at" t.datetime "current_sign_in_at" t.datetime "last_sign_in_at" - t.string "current_sign_in_ip" - t.string "last_sign_in_ip" - t.string "login" + t.string "current_sign_in_ip", limit: 255 + t.string "last_sign_in_ip", limit: 255 + t.string "login", limit: 255 t.integer "ship_address_id" t.integer "bill_address_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.string "authentication_token" - t.string "unlock_token" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "authentication_token", limit: 255 + t.string "unlock_token", limit: 255 t.datetime "locked_at" t.datetime "remember_created_at" t.string "spree_api_key", limit: 48 t.datetime "reset_password_sent_at" t.string "api_key", limit: 40 - t.integer "enterprise_limit", default: 5, null: false + t.integer "enterprise_limit", default: 5, null: false t.string "locale", limit: 6 - t.string "confirmation_token" + t.string "confirmation_token", limit: 255 t.datetime "confirmed_at" t.datetime "confirmation_sent_at" - t.string "unconfirmed_email" + t.string "unconfirmed_email", limit: 255 end add_index "spree_users", ["confirmation_token"], name: "index_spree_users_on_confirmation_token", unique: true, using: :btree add_index "spree_users", ["email"], name: "email_idx_unique", unique: true, using: :btree add_index "spree_users", ["persistence_token"], name: "index_users_on_persistence_token", using: :btree - create_table "spree_variants", force: true do |t| - t.string "sku", default: "", null: false - t.decimal "weight", precision: 8, scale: 2 - t.decimal "height", precision: 8, scale: 2 - t.decimal "width", precision: 8, scale: 2 - t.decimal "depth", precision: 8, scale: 2 + create_table "spree_variants", force: :cascade do |t| + t.string "sku", limit: 255, default: "", null: false + t.decimal "weight", precision: 8, scale: 2 + t.decimal "height", precision: 8, scale: 2 + t.decimal "width", precision: 8, scale: 2 + t.decimal "depth", precision: 8, scale: 2 t.datetime "deleted_at" - t.boolean "is_master", default: false + t.boolean "is_master", default: false t.integer "product_id" - t.decimal "cost_price", precision: 8, scale: 2 + t.decimal "cost_price", precision: 8, scale: 2 t.integer "position" - t.string "cost_currency" + t.string "cost_currency", limit: 255 t.float "unit_value" - t.string "unit_description", default: "" - t.string "display_name" - t.string "display_as" + t.string "unit_description", limit: 255, default: "" + t.string "display_name", limit: 255 + t.string "display_as", limit: 255 t.datetime "import_date" end add_index "spree_variants", ["product_id"], name: "index_variants_on_product_id", using: :btree add_index "spree_variants", ["sku"], name: "index_spree_variants_on_sku", using: :btree - create_table "spree_zone_members", force: true do |t| + create_table "spree_zone_members", force: :cascade do |t| t.integer "zoneable_id" - t.string "zoneable_type" + t.string "zoneable_type", limit: 255 t.integer "zone_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "spree_zones", force: true do |t| - t.string "name" - t.string "description" + create_table "spree_zones", force: :cascade do |t| + t.string "name", limit: 255 + t.string "description", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.boolean "default_tax", default: false + t.integer "zone_members_count", default: 0 + end + + create_table "stripe_accounts", force: :cascade do |t| + t.string "stripe_user_id", limit: 255 + t.string "stripe_publishable_key", limit: 255 t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.boolean "default_tax", default: false - t.integer "zone_members_count", default: 0 - end - - create_table "stripe_accounts", force: true do |t| - t.string "stripe_user_id" - t.string "stripe_publishable_key" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false t.integer "enterprise_id" end add_index "stripe_accounts", ["enterprise_id"], name: "index_stripe_accounts_on_enterprise_id", unique: true, using: :btree - create_table "subscription_line_items", force: true do |t| + create_table "subscription_line_items", force: :cascade do |t| t.integer "subscription_id", null: false t.integer "variant_id", null: false t.integer "quantity", null: false @@ -1118,7 +1118,7 @@ ActiveRecord::Schema.define(version: 20201113163227) do add_index "subscription_line_items", ["subscription_id"], name: "index_subscription_line_items_on_subscription_id", using: :btree add_index "subscription_line_items", ["variant_id"], name: "index_subscription_line_items_on_variant_id", using: :btree - create_table "subscriptions", force: true do |t| + create_table "subscriptions", force: :cascade do |t| t.integer "shop_id", null: false t.integer "customer_id", null: false t.integer "schedule_id", null: false @@ -1144,29 +1144,29 @@ ActiveRecord::Schema.define(version: 20201113163227) do add_index "subscriptions", ["shipping_method_id"], name: "index_subscriptions_on_shipping_method_id", using: :btree add_index "subscriptions", ["shop_id"], name: "index_subscriptions_on_shop_id", using: :btree - create_table "suburbs", force: true do |t| - t.string "name" - t.string "postcode" + create_table "suburbs", force: :cascade do |t| + t.string "name", limit: 255 + t.string "postcode", limit: 255 t.float "latitude" t.float "longitude" t.integer "state_id" end - create_table "tag_rules", force: true do |t| - t.integer "enterprise_id", null: false - t.string "type", null: false - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.boolean "is_default", default: false, null: false - t.integer "priority", default: 99, null: false + create_table "tag_rules", force: :cascade do |t| + t.integer "enterprise_id", null: false + t.string "type", limit: 255, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.boolean "is_default", default: false, null: false + t.integer "priority", default: 99, null: false end - create_table "taggings", force: true do |t| + create_table "taggings", force: :cascade do |t| t.integer "tag_id" t.integer "taggable_id" - t.string "taggable_type" + t.string "taggable_type", limit: 255 t.integer "tagger_id" - t.string "tagger_type" + t.string "tagger_type", limit: 255 t.string "context", limit: 128 t.datetime "created_at" end @@ -1174,21 +1174,21 @@ ActiveRecord::Schema.define(version: 20201113163227) do add_index "taggings", ["tag_id", "taggable_id", "taggable_type", "context", "tagger_id", "tagger_type"], name: "taggings_idx", unique: true, using: :btree add_index "taggings", ["taggable_id", "taggable_type", "context"], name: "index_taggings_on_taggable_id_and_taggable_type_and_context", using: :btree - create_table "tags", force: true do |t| - t.string "name" - t.integer "taggings_count", default: 0 + create_table "tags", force: :cascade do |t| + t.string "name", limit: 255 + t.integer "taggings_count", default: 0 end add_index "tags", ["name"], name: "index_tags_on_name", unique: true, using: :btree - create_table "variant_overrides", force: true do |t| - t.integer "variant_id", null: false - t.integer "hub_id", null: false - t.decimal "price", precision: 8, scale: 2 + create_table "variant_overrides", force: :cascade do |t| + t.integer "variant_id", null: false + t.integer "hub_id", null: false + t.decimal "price", precision: 8, scale: 2 t.integer "count_on_hand" t.integer "default_stock" t.boolean "resettable" - t.string "sku" + t.string "sku", limit: 255 t.boolean "on_demand" t.datetime "permission_revoked_at" t.datetime "import_date" @@ -1196,11 +1196,11 @@ ActiveRecord::Schema.define(version: 20201113163227) do add_index "variant_overrides", ["variant_id", "hub_id"], name: "index_variant_overrides_on_variant_id_and_hub_id", using: :btree - create_table "versions", force: true do |t| - t.string "item_type", null: false - t.integer "item_id", null: false - t.string "event", null: false - t.string "whodunnit" + create_table "versions", force: :cascade do |t| + t.string "item_type", limit: 255, null: false + t.integer "item_id", null: false + t.string "event", limit: 255, null: false + t.string "whodunnit", limit: 255 t.text "object" t.datetime "created_at" t.text "custom_data" @@ -1209,155 +1209,106 @@ ActiveRecord::Schema.define(version: 20201113163227) do add_index "versions", ["item_type", "item_id"], name: "index_versions_on_item_type_and_item_id", using: :btree add_foreign_key "adjustment_metadata", "enterprises", name: "adjustment_metadata_enterprise_id_fk" - add_foreign_key "adjustment_metadata", "spree_adjustments", name: "adjustment_metadata_adjustment_id_fk", column: "adjustment_id", dependent: :delete - + add_foreign_key "adjustment_metadata", "spree_adjustments", column: "adjustment_id", name: "adjustment_metadata_adjustment_id_fk", on_delete: :cascade add_foreign_key "coordinator_fees", "enterprise_fees", name: "coordinator_fees_enterprise_fee_id_fk" add_foreign_key "coordinator_fees", "order_cycles", name: "coordinator_fees_order_cycle_id_fk" - add_foreign_key "customers", "enterprises", name: "customers_enterprise_id_fk" - add_foreign_key "customers", "spree_addresses", name: "customers_bill_address_id_fk", column: "bill_address_id" - add_foreign_key "customers", "spree_addresses", name: "customers_ship_address_id_fk", column: "ship_address_id" - add_foreign_key "customers", "spree_users", name: "customers_user_id_fk", column: "user_id" - - add_foreign_key "distributors_payment_methods", "enterprises", name: "distributors_payment_methods_distributor_id_fk", column: "distributor_id" - add_foreign_key "distributors_payment_methods", "spree_payment_methods", name: "distributors_payment_methods_payment_method_id_fk", column: "payment_method_id" - - add_foreign_key "distributors_shipping_methods", "enterprises", name: "distributors_shipping_methods_distributor_id_fk", column: "distributor_id" - add_foreign_key "distributors_shipping_methods", "spree_shipping_methods", name: "distributors_shipping_methods_shipping_method_id_fk", column: "shipping_method_id" - + add_foreign_key "customers", "spree_addresses", column: "bill_address_id", name: "customers_bill_address_id_fk" + add_foreign_key "customers", "spree_addresses", column: "ship_address_id", name: "customers_ship_address_id_fk" + add_foreign_key "customers", "spree_users", column: "user_id", name: "customers_user_id_fk" + add_foreign_key "distributors_payment_methods", "enterprises", column: "distributor_id", name: "distributors_payment_methods_distributor_id_fk" + add_foreign_key "distributors_payment_methods", "spree_payment_methods", column: "payment_method_id", name: "distributors_payment_methods_payment_method_id_fk" + add_foreign_key "distributors_shipping_methods", "enterprises", column: "distributor_id", name: "distributors_shipping_methods_distributor_id_fk" + add_foreign_key "distributors_shipping_methods", "spree_shipping_methods", column: "shipping_method_id", name: "distributors_shipping_methods_shipping_method_id_fk" add_foreign_key "enterprise_fees", "enterprises", name: "enterprise_fees_enterprise_id_fk" - add_foreign_key "enterprise_fees", "spree_tax_categories", name: "enterprise_fees_tax_category_id_fk", column: "tax_category_id" - - add_foreign_key "enterprise_groups", "spree_addresses", name: "enterprise_groups_address_id_fk", column: "address_id" - add_foreign_key "enterprise_groups", "spree_users", name: "enterprise_groups_owner_id_fk", column: "owner_id" - + add_foreign_key "enterprise_fees", "spree_tax_categories", column: "tax_category_id", name: "enterprise_fees_tax_category_id_fk" + add_foreign_key "enterprise_groups", "spree_addresses", column: "address_id", name: "enterprise_groups_address_id_fk" + add_foreign_key "enterprise_groups", "spree_users", column: "owner_id", name: "enterprise_groups_owner_id_fk" add_foreign_key "enterprise_groups_enterprises", "enterprise_groups", name: "enterprise_groups_enterprises_enterprise_group_id_fk" add_foreign_key "enterprise_groups_enterprises", "enterprises", name: "enterprise_groups_enterprises_enterprise_id_fk" - add_foreign_key "enterprise_relationship_permissions", "enterprise_relationships", name: "erp_enterprise_relationship_id_fk" - - add_foreign_key "enterprise_relationships", "enterprises", name: "enterprise_relationships_child_id_fk", column: "child_id" - add_foreign_key "enterprise_relationships", "enterprises", name: "enterprise_relationships_parent_id_fk", column: "parent_id" - + add_foreign_key "enterprise_relationships", "enterprises", column: "child_id", name: "enterprise_relationships_child_id_fk" + add_foreign_key "enterprise_relationships", "enterprises", column: "parent_id", name: "enterprise_relationships_parent_id_fk" add_foreign_key "enterprise_roles", "enterprises", name: "enterprise_roles_enterprise_id_fk" - add_foreign_key "enterprise_roles", "spree_users", name: "enterprise_roles_user_id_fk", column: "user_id" - - add_foreign_key "enterprises", "spree_addresses", name: "enterprises_address_id_fk", column: "address_id" - add_foreign_key "enterprises", "spree_users", name: "enterprises_owner_id_fk", column: "owner_id" - + add_foreign_key "enterprise_roles", "spree_users", column: "user_id", name: "enterprise_roles_user_id_fk" + add_foreign_key "enterprises", "spree_addresses", column: "address_id", name: "enterprises_address_id_fk" + add_foreign_key "enterprises", "spree_users", column: "owner_id", name: "enterprises_owner_id_fk" add_foreign_key "exchange_fees", "enterprise_fees", name: "exchange_fees_enterprise_fee_id_fk" add_foreign_key "exchange_fees", "exchanges", name: "exchange_fees_exchange_id_fk" - add_foreign_key "exchange_variants", "exchanges", name: "exchange_variants_exchange_id_fk" - add_foreign_key "exchange_variants", "spree_variants", name: "exchange_variants_variant_id_fk", column: "variant_id" - - add_foreign_key "exchanges", "enterprises", name: "exchanges_receiver_id_fk", column: "receiver_id" - add_foreign_key "exchanges", "enterprises", name: "exchanges_sender_id_fk", column: "sender_id" + add_foreign_key "exchange_variants", "spree_variants", column: "variant_id", name: "exchange_variants_variant_id_fk" + add_foreign_key "exchanges", "enterprises", column: "receiver_id", name: "exchanges_receiver_id_fk" + add_foreign_key "exchanges", "enterprises", column: "sender_id", name: "exchanges_sender_id_fk" add_foreign_key "exchanges", "order_cycles", name: "exchanges_order_cycle_id_fk" - add_foreign_key "order_cycle_schedules", "order_cycles", name: "oc_schedules_order_cycle_id_fk" add_foreign_key "order_cycle_schedules", "schedules", name: "oc_schedules_schedule_id_fk" - - add_foreign_key "order_cycles", "enterprises", name: "order_cycles_coordinator_id_fk", column: "coordinator_id" - - add_foreign_key "producer_properties", "enterprises", name: "producer_properties_producer_id_fk", column: "producer_id" - add_foreign_key "producer_properties", "spree_properties", name: "producer_properties_property_id_fk", column: "property_id" - + add_foreign_key "order_cycles", "enterprises", column: "coordinator_id", name: "order_cycles_coordinator_id_fk" + add_foreign_key "producer_properties", "enterprises", column: "producer_id", name: "producer_properties_producer_id_fk" + add_foreign_key "producer_properties", "spree_properties", column: "property_id", name: "producer_properties_property_id_fk" add_foreign_key "proxy_orders", "order_cycles", name: "proxy_orders_order_cycle_id_fk" - add_foreign_key "proxy_orders", "spree_orders", name: "order_id_fk", column: "order_id" + add_foreign_key "proxy_orders", "spree_orders", column: "order_id", name: "order_id_fk" add_foreign_key "proxy_orders", "subscriptions", name: "proxy_orders_subscription_id_fk" - - add_foreign_key "spree_addresses", "spree_countries", name: "spree_addresses_country_id_fk", column: "country_id" - add_foreign_key "spree_addresses", "spree_states", name: "spree_addresses_state_id_fk", column: "state_id" - - add_foreign_key "spree_inventory_units", "spree_orders", name: "spree_inventory_units_order_id_fk", column: "order_id" - add_foreign_key "spree_inventory_units", "spree_return_authorizations", name: "spree_inventory_units_return_authorization_id_fk", column: "return_authorization_id" - add_foreign_key "spree_inventory_units", "spree_shipments", name: "spree_inventory_units_shipment_id_fk", column: "shipment_id" - add_foreign_key "spree_inventory_units", "spree_variants", name: "spree_inventory_units_variant_id_fk", column: "variant_id" - - add_foreign_key "spree_line_items", "spree_orders", name: "spree_line_items_order_id_fk", column: "order_id" - add_foreign_key "spree_line_items", "spree_variants", name: "spree_line_items_variant_id_fk", column: "variant_id" - - add_foreign_key "spree_option_values", "spree_option_types", name: "spree_option_values_option_type_id_fk", column: "option_type_id" - - add_foreign_key "spree_option_values_variants", "spree_option_values", name: "spree_option_values_variants_option_value_id_fk", column: "option_value_id" - add_foreign_key "spree_option_values_variants", "spree_variants", name: "spree_option_values_variants_variant_id_fk", column: "variant_id" - + add_foreign_key "spree_addresses", "spree_countries", column: "country_id", name: "spree_addresses_country_id_fk" + add_foreign_key "spree_addresses", "spree_states", column: "state_id", name: "spree_addresses_state_id_fk" + add_foreign_key "spree_inventory_units", "spree_orders", column: "order_id", name: "spree_inventory_units_order_id_fk" + add_foreign_key "spree_inventory_units", "spree_return_authorizations", column: "return_authorization_id", name: "spree_inventory_units_return_authorization_id_fk" + add_foreign_key "spree_inventory_units", "spree_shipments", column: "shipment_id", name: "spree_inventory_units_shipment_id_fk" + add_foreign_key "spree_inventory_units", "spree_variants", column: "variant_id", name: "spree_inventory_units_variant_id_fk" + add_foreign_key "spree_line_items", "spree_orders", column: "order_id", name: "spree_line_items_order_id_fk" + add_foreign_key "spree_line_items", "spree_variants", column: "variant_id", name: "spree_line_items_variant_id_fk" + add_foreign_key "spree_option_values", "spree_option_types", column: "option_type_id", name: "spree_option_values_option_type_id_fk" + add_foreign_key "spree_option_values_variants", "spree_option_values", column: "option_value_id", name: "spree_option_values_variants_option_value_id_fk" + add_foreign_key "spree_option_values_variants", "spree_variants", column: "variant_id", name: "spree_option_values_variants_variant_id_fk" add_foreign_key "spree_orders", "customers", name: "spree_orders_customer_id_fk" - add_foreign_key "spree_orders", "enterprises", name: "spree_orders_distributor_id_fk", column: "distributor_id" + add_foreign_key "spree_orders", "enterprises", column: "distributor_id", name: "spree_orders_distributor_id_fk" add_foreign_key "spree_orders", "order_cycles", name: "spree_orders_order_cycle_id_fk" - add_foreign_key "spree_orders", "spree_addresses", name: "spree_orders_bill_address_id_fk", column: "bill_address_id" - add_foreign_key "spree_orders", "spree_addresses", name: "spree_orders_ship_address_id_fk", column: "ship_address_id" - add_foreign_key "spree_orders", "spree_users", name: "spree_orders_user_id_fk", column: "user_id" - - add_foreign_key "spree_payments", "spree_orders", name: "spree_payments_order_id_fk", column: "order_id" - add_foreign_key "spree_payments", "spree_payment_methods", name: "spree_payments_payment_method_id_fk", column: "payment_method_id" - - add_foreign_key "spree_prices", "spree_variants", name: "spree_prices_variant_id_fk", column: "variant_id" - - add_foreign_key "spree_product_option_types", "spree_option_types", name: "spree_product_option_types_option_type_id_fk", column: "option_type_id" - add_foreign_key "spree_product_option_types", "spree_products", name: "spree_product_option_types_product_id_fk", column: "product_id" - - add_foreign_key "spree_product_properties", "spree_products", name: "spree_product_properties_product_id_fk", column: "product_id" - add_foreign_key "spree_product_properties", "spree_properties", name: "spree_product_properties_property_id_fk", column: "property_id" - - add_foreign_key "spree_products", "enterprises", name: "spree_products_supplier_id_fk", column: "supplier_id" - add_foreign_key "spree_products", "spree_shipping_categories", name: "spree_products_shipping_category_id_fk", column: "shipping_category_id" - add_foreign_key "spree_products", "spree_tax_categories", name: "spree_products_tax_category_id_fk", column: "tax_category_id" - add_foreign_key "spree_products", "spree_taxons", name: "spree_products_primary_taxon_id_fk", column: "primary_taxon_id" - - add_foreign_key "spree_products_promotion_rules", "spree_products", name: "spree_products_promotion_rules_product_id_fk", column: "product_id" - add_foreign_key "spree_products_promotion_rules", "spree_promotion_rules", name: "spree_products_promotion_rules_promotion_rule_id_fk", column: "promotion_rule_id" - - add_foreign_key "spree_products_taxons", "spree_products", name: "spree_products_taxons_product_id_fk", column: "product_id", dependent: :delete - add_foreign_key "spree_products_taxons", "spree_taxons", name: "spree_products_taxons_taxon_id_fk", column: "taxon_id", dependent: :delete - - add_foreign_key "spree_promotion_action_line_items", "spree_promotion_actions", name: "spree_promotion_action_line_items_promotion_action_id_fk", column: "promotion_action_id" - add_foreign_key "spree_promotion_action_line_items", "spree_variants", name: "spree_promotion_action_line_items_variant_id_fk", column: "variant_id" - - add_foreign_key "spree_promotion_actions", "spree_activators", name: "spree_promotion_actions_activator_id_fk", column: "activator_id" - - add_foreign_key "spree_promotion_rules", "spree_activators", name: "spree_promotion_rules_activator_id_fk", column: "activator_id" - - add_foreign_key "spree_return_authorizations", "spree_orders", name: "spree_return_authorizations_order_id_fk", column: "order_id" - - add_foreign_key "spree_roles_users", "spree_roles", name: "spree_roles_users_role_id_fk", column: "role_id" - add_foreign_key "spree_roles_users", "spree_users", name: "spree_roles_users_user_id_fk", column: "user_id" - - add_foreign_key "spree_shipments", "spree_addresses", name: "spree_shipments_address_id_fk", column: "address_id" - add_foreign_key "spree_shipments", "spree_orders", name: "spree_shipments_order_id_fk", column: "order_id" - - add_foreign_key "spree_state_changes", "spree_users", name: "spree_state_changes_user_id_fk", column: "user_id" - - add_foreign_key "spree_states", "spree_countries", name: "spree_states_country_id_fk", column: "country_id" - - add_foreign_key "spree_tax_rates", "spree_tax_categories", name: "spree_tax_rates_tax_category_id_fk", column: "tax_category_id" - add_foreign_key "spree_tax_rates", "spree_zones", name: "spree_tax_rates_zone_id_fk", column: "zone_id" - - add_foreign_key "spree_taxons", "spree_taxonomies", name: "spree_taxons_taxonomy_id_fk", column: "taxonomy_id" - add_foreign_key "spree_taxons", "spree_taxons", name: "spree_taxons_parent_id_fk", column: "parent_id" - - add_foreign_key "spree_users", "spree_addresses", name: "spree_users_bill_address_id_fk", column: "bill_address_id" - add_foreign_key "spree_users", "spree_addresses", name: "spree_users_ship_address_id_fk", column: "ship_address_id" - - add_foreign_key "spree_variants", "spree_products", name: "spree_variants_product_id_fk", column: "product_id" - - add_foreign_key "spree_zone_members", "spree_zones", name: "spree_zone_members_zone_id_fk", column: "zone_id" - - add_foreign_key "subscription_line_items", "spree_variants", name: "subscription_line_items_variant_id_fk", column: "variant_id" + add_foreign_key "spree_orders", "spree_addresses", column: "bill_address_id", name: "spree_orders_bill_address_id_fk" + add_foreign_key "spree_orders", "spree_addresses", column: "ship_address_id", name: "spree_orders_ship_address_id_fk" + add_foreign_key "spree_orders", "spree_users", column: "user_id", name: "spree_orders_user_id_fk" + add_foreign_key "spree_payments", "spree_orders", column: "order_id", name: "spree_payments_order_id_fk" + add_foreign_key "spree_payments", "spree_payment_methods", column: "payment_method_id", name: "spree_payments_payment_method_id_fk" + add_foreign_key "spree_prices", "spree_variants", column: "variant_id", name: "spree_prices_variant_id_fk" + add_foreign_key "spree_product_option_types", "spree_option_types", column: "option_type_id", name: "spree_product_option_types_option_type_id_fk" + add_foreign_key "spree_product_option_types", "spree_products", column: "product_id", name: "spree_product_option_types_product_id_fk" + add_foreign_key "spree_product_properties", "spree_products", column: "product_id", name: "spree_product_properties_product_id_fk" + add_foreign_key "spree_product_properties", "spree_properties", column: "property_id", name: "spree_product_properties_property_id_fk" + add_foreign_key "spree_products", "enterprises", column: "supplier_id", name: "spree_products_supplier_id_fk" + add_foreign_key "spree_products", "spree_shipping_categories", column: "shipping_category_id", name: "spree_products_shipping_category_id_fk" + add_foreign_key "spree_products", "spree_tax_categories", column: "tax_category_id", name: "spree_products_tax_category_id_fk" + add_foreign_key "spree_products", "spree_taxons", column: "primary_taxon_id", name: "spree_products_primary_taxon_id_fk" + add_foreign_key "spree_products_promotion_rules", "spree_products", column: "product_id", name: "spree_products_promotion_rules_product_id_fk" + add_foreign_key "spree_products_promotion_rules", "spree_promotion_rules", column: "promotion_rule_id", name: "spree_products_promotion_rules_promotion_rule_id_fk" + add_foreign_key "spree_products_taxons", "spree_products", column: "product_id", name: "spree_products_taxons_product_id_fk", on_delete: :cascade + add_foreign_key "spree_products_taxons", "spree_taxons", column: "taxon_id", name: "spree_products_taxons_taxon_id_fk", on_delete: :cascade + add_foreign_key "spree_promotion_action_line_items", "spree_promotion_actions", column: "promotion_action_id", name: "spree_promotion_action_line_items_promotion_action_id_fk" + add_foreign_key "spree_promotion_action_line_items", "spree_variants", column: "variant_id", name: "spree_promotion_action_line_items_variant_id_fk" + add_foreign_key "spree_promotion_actions", "spree_activators", column: "activator_id", name: "spree_promotion_actions_activator_id_fk" + add_foreign_key "spree_promotion_rules", "spree_activators", column: "activator_id", name: "spree_promotion_rules_activator_id_fk" + add_foreign_key "spree_return_authorizations", "spree_orders", column: "order_id", name: "spree_return_authorizations_order_id_fk" + add_foreign_key "spree_roles_users", "spree_roles", column: "role_id", name: "spree_roles_users_role_id_fk" + add_foreign_key "spree_roles_users", "spree_users", column: "user_id", name: "spree_roles_users_user_id_fk" + add_foreign_key "spree_shipments", "spree_addresses", column: "address_id", name: "spree_shipments_address_id_fk" + add_foreign_key "spree_shipments", "spree_orders", column: "order_id", name: "spree_shipments_order_id_fk" + add_foreign_key "spree_state_changes", "spree_users", column: "user_id", name: "spree_state_changes_user_id_fk" + add_foreign_key "spree_states", "spree_countries", column: "country_id", name: "spree_states_country_id_fk" + add_foreign_key "spree_tax_rates", "spree_tax_categories", column: "tax_category_id", name: "spree_tax_rates_tax_category_id_fk" + add_foreign_key "spree_tax_rates", "spree_zones", column: "zone_id", name: "spree_tax_rates_zone_id_fk" + add_foreign_key "spree_taxons", "spree_taxonomies", column: "taxonomy_id", name: "spree_taxons_taxonomy_id_fk" + add_foreign_key "spree_taxons", "spree_taxons", column: "parent_id", name: "spree_taxons_parent_id_fk" + add_foreign_key "spree_users", "spree_addresses", column: "bill_address_id", name: "spree_users_bill_address_id_fk" + add_foreign_key "spree_users", "spree_addresses", column: "ship_address_id", name: "spree_users_ship_address_id_fk" + add_foreign_key "spree_variants", "spree_products", column: "product_id", name: "spree_variants_product_id_fk" + add_foreign_key "spree_zone_members", "spree_zones", column: "zone_id", name: "spree_zone_members_zone_id_fk" + add_foreign_key "subscription_line_items", "spree_variants", column: "variant_id", name: "subscription_line_items_variant_id_fk" add_foreign_key "subscription_line_items", "subscriptions", name: "subscription_line_items_subscription_id_fk" - add_foreign_key "subscriptions", "customers", name: "subscriptions_customer_id_fk" - add_foreign_key "subscriptions", "enterprises", name: "subscriptions_shop_id_fk", column: "shop_id" + add_foreign_key "subscriptions", "enterprises", column: "shop_id", name: "subscriptions_shop_id_fk" add_foreign_key "subscriptions", "schedules", name: "subscriptions_schedule_id_fk" - add_foreign_key "subscriptions", "spree_addresses", name: "subscriptions_bill_address_id_fk", column: "bill_address_id" - add_foreign_key "subscriptions", "spree_addresses", name: "subscriptions_ship_address_id_fk", column: "ship_address_id" - add_foreign_key "subscriptions", "spree_payment_methods", name: "subscriptions_payment_method_id_fk", column: "payment_method_id" - add_foreign_key "subscriptions", "spree_shipping_methods", name: "subscriptions_shipping_method_id_fk", column: "shipping_method_id" - - add_foreign_key "suburbs", "spree_states", name: "suburbs_state_id_fk", column: "state_id" - - add_foreign_key "variant_overrides", "enterprises", name: "variant_overrides_hub_id_fk", column: "hub_id" - add_foreign_key "variant_overrides", "spree_variants", name: "variant_overrides_variant_id_fk", column: "variant_id" - + add_foreign_key "subscriptions", "spree_addresses", column: "bill_address_id", name: "subscriptions_bill_address_id_fk" + add_foreign_key "subscriptions", "spree_addresses", column: "ship_address_id", name: "subscriptions_ship_address_id_fk" + add_foreign_key "subscriptions", "spree_payment_methods", column: "payment_method_id", name: "subscriptions_payment_method_id_fk" + add_foreign_key "subscriptions", "spree_shipping_methods", column: "shipping_method_id", name: "subscriptions_shipping_method_id_fk" + add_foreign_key "suburbs", "spree_states", column: "state_id", name: "suburbs_state_id_fk" + add_foreign_key "variant_overrides", "enterprises", column: "hub_id", name: "variant_overrides_hub_id_fk" + add_foreign_key "variant_overrides", "spree_variants", column: "variant_id", name: "variant_overrides_variant_id_fk" end From 3090cfa9099376779b9f1e799e7d94a71a9a14ff Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Wed, 4 Nov 2020 01:14:50 +0000 Subject: [PATCH 05/58] Add setup for responders gem --- app/controllers/application_controller.rb | 4 ++++ lib/application_responder.rb | 8 ++++++++ 2 files changed, 12 insertions(+) create mode 100644 lib/application_responder.rb diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index f3ddff301c..4181c9c1de 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,7 +1,11 @@ +require "application_responder" require 'open_food_network/referer_parser' require_dependency 'spree/authentication_helpers' class ApplicationController < ActionController::Base + self.responder = ApplicationResponder + respond_to :html + protect_from_forgery prepend_before_action :restrict_iframes diff --git a/lib/application_responder.rb b/lib/application_responder.rb new file mode 100644 index 0000000000..cc3e588853 --- /dev/null +++ b/lib/application_responder.rb @@ -0,0 +1,8 @@ +class ApplicationResponder < ActionController::Responder + include Responders::FlashResponder + include Responders::HttpCacheResponder + + # Redirects resources to the collection path (index action) instead + # of the resource path (show action) for POST/PUT/DELETE requests. + # include Responders::CollectionResponder +end From fb333c37e78a309f61d26e7588b0f509e3f12c29 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Wed, 4 Nov 2020 01:42:41 +0000 Subject: [PATCH 06/58] Fix Api controller setup for responders gem --- app/controllers/api/base_controller.rb | 2 ++ lib/spree/api/controller_setup.rb | 3 --- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/controllers/api/base_controller.rb b/app/controllers/api/base_controller.rb index 2641cdaf44..34f43f81c8 100644 --- a/app/controllers/api/base_controller.rb +++ b/app/controllers/api/base_controller.rb @@ -1,10 +1,12 @@ # Base controller for OFN's API require_dependency 'spree/api/controller_setup' require "spree/core/controller_helpers/ssl" +require "application_responder" module Api class BaseController < ActionController::Metal include ActionController::StrongParameters + include ActionController::RespondWith include Spree::Api::ControllerSetup include Spree::Core::ControllerHelpers::SSL include ::ActionController::Head diff --git a/lib/spree/api/controller_setup.rb b/lib/spree/api/controller_setup.rb index d1ffdb4a1e..7d9215a332 100644 --- a/lib/spree/api/controller_setup.rb +++ b/lib/spree/api/controller_setup.rb @@ -13,7 +13,6 @@ module Spree include ActionController::Rendering include ActionController::ImplicitRender include ActionController::Rescue - include ActionController::MimeResponds include ActionController::Head include CanCan::ControllerAdditions @@ -21,8 +20,6 @@ module Spree prepend_view_path Rails.root + "app/views" append_view_path File.expand_path("../../../app/views", File.dirname(__FILE__)) - - respond_to :json end end end From 6b45208cf17e83c20bae7232559170aba3082d6a Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Wed, 4 Nov 2020 01:57:56 +0000 Subject: [PATCH 07/58] Define Capybara server The server type now has to be set explicitly for Capybara --- spec/spec_helper.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 40551b096e..dfbc595eb9 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -49,6 +49,7 @@ require 'support/api_helper' # Capybara config require 'selenium-webdriver' Capybara.javascript_driver = :chrome +Capybara.server = :webrick Capybara.register_driver :chrome do |app| options = Selenium::WebDriver::Chrome::Options.new( From 91908a0e4c3e4c2810a0e6c88942ad54930e2bdb Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Wed, 4 Nov 2020 10:24:19 +0000 Subject: [PATCH 08/58] Switch from state_machine to state_machines gem The old version is completely unmaintained and does not work with Rails 4.2 --- Gemfile | 2 +- Gemfile.lock | 10 ++++++++-- app/models/spree/order/checkout.rb | 2 +- config/initializers/state_machine_patch.rb | 11 ----------- lib/spree/core.rb | 2 +- spec/models/spree/order/checkout_spec.rb | 6 +++--- spec/models/spree/order_spec.rb | 2 +- spec/services/order_checkout_restart_spec.rb | 2 +- spec/services/order_workflow_spec.rb | 2 +- 9 files changed, 17 insertions(+), 22 deletions(-) delete mode 100644 config/initializers/state_machine_patch.rb diff --git a/Gemfile b/Gemfile index 02318308f9..59b5dcf62a 100644 --- a/Gemfile +++ b/Gemfile @@ -28,7 +28,7 @@ gem 'json' gem 'money', '< 6.1.0' gem 'paranoia', '~> 2.0' gem 'ransack', '~> 1.8.10' -gem 'state_machine', '1.2.0' +gem 'state_machines-activerecord' gem 'stringex', '~> 1.5.1' gem 'spree_i18n', github: 'openfoodfoundation/spree_i18n', branch: '1-3-stable' diff --git a/Gemfile.lock b/Gemfile.lock index 2a4e82502f..05ead18e7f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -667,7 +667,13 @@ GEM actionpack (>= 3.0) activesupport (>= 3.0) sprockets (>= 2.8, < 4.0) - state_machine (1.2.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 (1.5.1) stripe (5.28.0) temple (0.8.2) @@ -818,7 +824,7 @@ DEPENDENCIES spree_paypal_express! spring spring-commands-rspec - state_machine (= 1.2.0) + state_machines-activerecord stringex (~> 1.5.1) stripe test-prof diff --git a/app/models/spree/order/checkout.rb b/app/models/spree/order/checkout.rb index 82efef81e7..39992a5701 100644 --- a/app/models/spree/order/checkout.rb +++ b/app/models/spree/order/checkout.rb @@ -34,7 +34,7 @@ module Spree klass = self # To avoid a ton of warnings when the state machine is re-defined - StateMachine::Machine.ignore_method_conflicts = true + StateMachines::Machine.ignore_method_conflicts = true # To avoid multiple occurrences of the same transition being defined # On first definition, state_machines will not be defined state_machines.clear if respond_to?(:state_machines) diff --git a/config/initializers/state_machine_patch.rb b/config/initializers/state_machine_patch.rb deleted file mode 100644 index 76e984526a..0000000000 --- a/config/initializers/state_machine_patch.rb +++ /dev/null @@ -1,11 +0,0 @@ -module StateMachine - module Integrations - module ActiveModel - public :around_validation - end - - module ActiveRecord - public :around_save - end - end -end diff --git a/lib/spree/core.rb b/lib/spree/core.rb index e3ef713db7..cdf1ff4b2a 100644 --- a/lib/spree/core.rb +++ b/lib/spree/core.rb @@ -10,7 +10,7 @@ require 'mail' require 'paperclip' require 'paranoia' require 'ransack' -require 'state_machine' +require 'state_machines' module Spree mattr_accessor :user_class diff --git a/spec/models/spree/order/checkout_spec.rb b/spec/models/spree/order/checkout_spec.rb index 3fadb6b8e0..27a35c8023 100644 --- a/spec/models/spree/order/checkout_spec.rb +++ b/spec/models/spree/order/checkout_spec.rb @@ -59,7 +59,7 @@ describe Spree::Order::Checkout do it "cannot transition to address without any line items" do expect(order.line_items).to be_blank - expect(lambda { order.next! }).to raise_error(StateMachine::InvalidTransition, + expect(lambda { order.next! }).to raise_error(StateMachines::InvalidTransition, /#{Spree.t(:there_are_no_items_for_this_order)}/) end @@ -82,7 +82,7 @@ describe Spree::Order::Checkout do context "if there are no shipping rates for any shipment" do specify do transition = lambda { order.next! } - expect(transition).to raise_error(StateMachine::InvalidTransition, + expect(transition).to raise_error(StateMachines::InvalidTransition, /#{Spree.t(:items_cannot_be_shipped)}/) end end @@ -167,7 +167,7 @@ describe Spree::Order::Checkout do it 'raises' do expect { order.restart_checkout! } .to raise_error( - StateMachine::InvalidTransition, + StateMachines::InvalidTransition, /Cannot transition state via :restart_checkout/ ) end diff --git a/spec/models/spree/order_spec.rb b/spec/models/spree/order_spec.rb index 17c0d6e18f..958ece8e52 100644 --- a/spec/models/spree/order_spec.rb +++ b/spec/models/spree/order_spec.rb @@ -1321,7 +1321,7 @@ describe Spree::Order do it 'raises' do expect { order.restart_checkout! } - .to raise_error(StateMachine::InvalidTransition) + .to raise_error(StateMachines::InvalidTransition) end end diff --git a/spec/services/order_checkout_restart_spec.rb b/spec/services/order_checkout_restart_spec.rb index f74a427c02..a5b7258e74 100644 --- a/spec/services/order_checkout_restart_spec.rb +++ b/spec/services/order_checkout_restart_spec.rb @@ -49,7 +49,7 @@ describe OrderCheckoutRestart do it "does not reset the order state nor clears incomplete shipments and payments" do expect do OrderCheckoutRestart.new(order).call - end.to raise_error(StateMachine::InvalidTransition) + end.to raise_error(StateMachines::InvalidTransition) expect(order.state).to eq 'payment' expect(order.shipments.count).to eq 1 diff --git a/spec/services/order_workflow_spec.rb b/spec/services/order_workflow_spec.rb index 5b2b6f0bf5..bed3a7b0c9 100644 --- a/spec/services/order_workflow_spec.rb +++ b/spec/services/order_workflow_spec.rb @@ -49,7 +49,7 @@ describe OrderWorkflow do end it "raises error" do - expect { service.complete! }.to raise_error(StateMachine::InvalidTransition) + expect { service.complete! }.to raise_error(StateMachines::InvalidTransition) end end end From ccaff089288631b9c5300de076990dc76cc77724 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Wed, 4 Nov 2020 11:27:20 +0000 Subject: [PATCH 09/58] Re-add ForbiddenAttributesError debugging helper --- app/controllers/application_controller.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 4181c9c1de..56a9682559 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -14,6 +14,12 @@ class ApplicationController < ActionController::Base include EnterprisesHelper include Spree::AuthenticationHelpers + # Helper for debugging strong_parameters + rescue_from ActiveModel::ForbiddenAttributesError, with: :print_params + def print_params + raise ActiveModel::ForbiddenAttributesError, params.to_s + end + def redirect_to(options = {}, response_status = {}) ::Rails.logger.error("Redirected by #{begin caller(1).first From 16cc0afe8fb42d75a5b6b81cab26b38fb3fae1ea Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Wed, 4 Nov 2020 12:30:27 +0000 Subject: [PATCH 10/58] Replace removed method #retrieve_collector_from_mimes https://apidock.com/rails/v4.1.8/ActionController/MimeResponds/retrieve_collector_from_mimes --- .../core/controller_helpers/respond_with.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/spree/core/controller_helpers/respond_with.rb b/lib/spree/core/controller_helpers/respond_with.rb index 0e3e7ef56b..5fcd4bc2cb 100644 --- a/lib/spree/core/controller_helpers/respond_with.rb +++ b/lib/spree/core/controller_helpers/respond_with.rb @@ -30,6 +30,22 @@ module ActionController (options.delete(:responder) || Spree::Responder).call(self, resources, options) end end + + private + + def retrieve_collector_from_mimes(mimes = nil, &block) + mimes ||= collect_mimes_from_class_level + collector = Collector.new(mimes, request.variant) + block.call(collector) if block_given? + format = collector.negotiate_format(request) + + if format + _process_format(format) + collector + else + raise ActionController::UnknownFormat + end + end end end From 34bfd877cc2584e6188b2731069d2505302a095e Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Wed, 4 Nov 2020 12:35:05 +0000 Subject: [PATCH 11/58] Fix #bulk_update in EnterprisesController --- .../admin/enterprises_controller.rb | 8 +++++++- .../permitted_attributes/enterprise.rb | 20 +++++++++---------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/app/controllers/admin/enterprises_controller.rb b/app/controllers/admin/enterprises_controller.rb index 93e893b6e3..d634b4e3fc 100644 --- a/app/controllers/admin/enterprises_controller.rb +++ b/app/controllers/admin/enterprises_controller.rb @@ -81,7 +81,7 @@ module Admin end def bulk_update - @enterprise_set = EnterpriseSet.new(collection, params[:enterprise_set]) + @enterprise_set = EnterpriseSet.new(collection, bulk_params) if @enterprise_set.save flash[:success] = I18n.t(:enterprise_bulk_update_success_notice) @@ -319,6 +319,12 @@ module Admin PermittedAttributes::Enterprise.new(params).call end + def bulk_params + params.require(:enterprise_set).permit( + collection_attributes: PermittedAttributes::Enterprise.attributes + ) + end + # Used in ResourceController#create def permitted_resource_params enterprise_params diff --git a/app/services/permitted_attributes/enterprise.rb b/app/services/permitted_attributes/enterprise.rb index 0516c9fe3e..1f20a62b13 100644 --- a/app/services/permitted_attributes/enterprise.rb +++ b/app/services/permitted_attributes/enterprise.rb @@ -9,19 +9,19 @@ module PermittedAttributes def call return @params[:enterprise] if @params[:enterprise].blank? - @params.require(:enterprise).permit( - basic_permitted_attributes + [ - group_ids: [], user_ids: [], - shipping_method_ids: [], payment_method_ids: [], - address_attributes: PermittedAttributes::Address.attributes, - producer_properties_attributes: [:id, :property_name, :value, :_destroy] - ] - ) + @params.require(:enterprise).permit(self.class.attributes) end - private + def self.attributes + basic_permitted_attributes + [ + group_ids: [], user_ids: [], + shipping_method_ids: [], payment_method_ids: [], + address_attributes: PermittedAttributes::Address.attributes, + producer_properties_attributes: [:id, :property_name, :value, :_destroy] + ] + end - def basic_permitted_attributes + def self.basic_permitted_attributes [ :id, :name, :visible, :permalink, :owner_id, :contact_name, :email_address, :phone, :is_primary_producer, :sells, :website, :facebook, :instagram, :linkedin, :twitter, From 54a4952dc58fca9c36ee72a492077a356bbaf21f Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Wed, 4 Nov 2020 13:03:45 +0000 Subject: [PATCH 12/58] Fix ForbiddenAttributesError on tag rules --- app/controllers/admin/enterprises_controller.rb | 3 ++- app/services/permitted_attributes/tag_rules.rb | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 app/services/permitted_attributes/tag_rules.rb diff --git a/app/controllers/admin/enterprises_controller.rb b/app/controllers/admin/enterprises_controller.rb index d634b4e3fc..dc741f1a8e 100644 --- a/app/controllers/admin/enterprises_controller.rb +++ b/app/controllers/admin/enterprises_controller.rb @@ -214,7 +214,8 @@ module Admin rule = @object.tag_rules.find_by(id: attrs.delete(:id)) || attrs[:type].constantize.new(enterprise: @object) create_calculator_for(rule, attrs) if rule.type == "TagRule::DiscountOrder" && rule.calculator.nil? - rule.update(attrs) + + rule.update(attrs.permit(PermittedAttributes::TagRules.attributes)) end end end diff --git a/app/services/permitted_attributes/tag_rules.rb b/app/services/permitted_attributes/tag_rules.rb new file mode 100644 index 0000000000..ce6bd879e0 --- /dev/null +++ b/app/services/permitted_attributes/tag_rules.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module PermittedAttributes + class TagRules + def self.attributes + [ + :id, :type, :preferred_customer_tags, :calculator_type, + { calculator_attributes: [:id, :preferred_flat_percent] } + ] + end + end +end From 58350ed3382e8bb476f492cee89ab531757440ca Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Wed, 4 Nov 2020 17:33:34 +0000 Subject: [PATCH 13/58] Set ActiveJob configs and convert WelcomeEnterpriseJob to new format This needs to be done for all jobs. Docs: https://guides.rubyonrails.org/v4.2/active_job_basics.html --- app/jobs/welcome_enterprise_job.rb | 4 ++-- app/models/enterprise.rb | 2 +- config/application.rb | 2 ++ config/environments/test.rb | 2 ++ spec/jobs/welcome_enterprise_job_spec.rb | 2 +- 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/jobs/welcome_enterprise_job.rb b/app/jobs/welcome_enterprise_job.rb index 6665af9d5a..a936514ef9 100644 --- a/app/jobs/welcome_enterprise_job.rb +++ b/app/jobs/welcome_enterprise_job.rb @@ -1,5 +1,5 @@ -WelcomeEnterpriseJob = Struct.new(:enterprise_id) do - def perform +class WelcomeEnterpriseJob < ActiveJob::Base + def perform(enterprise_id) enterprise = Enterprise.find enterprise_id EnterpriseMailer.welcome(enterprise).deliver end diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index 5e55dd0f9a..7d64eccac6 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -400,7 +400,7 @@ class Enterprise < ActiveRecord::Base end def send_welcome_email - Delayed::Job.enqueue WelcomeEnterpriseJob.new(id) + WelcomeEnterpriseJob.perform_later(id) end def strip_url(url) diff --git a/config/application.rb b/config/application.rb index 9377984296..b0de90dfb4 100644 --- a/config/application.rb +++ b/config/application.rb @@ -199,5 +199,7 @@ module Openfoodnetwork config.assets.precompile += ['*.jpg', '*.jpeg', '*.png', '*.gif' '*.svg'] config.active_support.escape_html_entities_in_json = true + + config.active_job.queue_adapter = :delayed_job end end diff --git a/config/environments/test.rb b/config/environments/test.rb index d6ea342589..f84b7f5f7f 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -51,6 +51,8 @@ Openfoodnetwork::Application.configure do require 'open_food_network/rack_request_blocker' # Make sure the middleware is inserted first in middleware chain config.middleware.insert_before('ActionDispatch::Static', 'RackRequestBlocker') + + config.active_job.queue_adapter = :test end # Allows us to use _url helpers in Rspec diff --git a/spec/jobs/welcome_enterprise_job_spec.rb b/spec/jobs/welcome_enterprise_job_spec.rb index a41322d185..6cdb295e49 100644 --- a/spec/jobs/welcome_enterprise_job_spec.rb +++ b/spec/jobs/welcome_enterprise_job_spec.rb @@ -8,6 +8,6 @@ describe WelcomeEnterpriseJob do expect(EnterpriseMailer).to receive(:welcome).with(enterprise).and_return(mail) expect(mail).to receive(:deliver) - run_job WelcomeEnterpriseJob.new(enterprise.id) + WelcomeEnterpriseJob.perform_now(enterprise.id) end end From 3cba9a16aab0d99412974abe899fdf5a175025ce Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Wed, 4 Nov 2020 18:38:32 +0000 Subject: [PATCH 14/58] Use ActionController::Base for Api::BaseController It looks like ActionController::Metal does not play nicely with the big changes to controller responders: https://guides.rubyonrails.org/upgrading_ruby_on_rails.html#responders --- app/controllers/api/base_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/api/base_controller.rb b/app/controllers/api/base_controller.rb index 34f43f81c8..540c7b1fea 100644 --- a/app/controllers/api/base_controller.rb +++ b/app/controllers/api/base_controller.rb @@ -11,6 +11,7 @@ module Api include Spree::Core::ControllerHelpers::SSL include ::ActionController::Head + self.responder = ApplicationResponder respond_to :json attr_accessor :current_api_user From 3c0172c5077519d45ddca9c63bc8354e7f75007f Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Thu, 5 Nov 2020 10:45:03 +0000 Subject: [PATCH 15/58] Fix Spree::Preferences cache issue In some cases this method was trying to delete a Rails.cache entry with `nil` as the key, leading to lots of errors. --- app/models/spree/preferences/store.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/models/spree/preferences/store.rb b/app/models/spree/preferences/store.rb index cb30d31eaa..5940fdf4a3 100644 --- a/app/models/spree/preferences/store.rb +++ b/app/models/spree/preferences/store.rb @@ -61,6 +61,8 @@ module Spree end def delete(key) + return if key.nil? + @cache.delete(key) destroy(key) end From e155b00ab9b2b68372b46f541fea1b6d8b66a386 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Thu, 5 Nov 2020 10:55:33 +0000 Subject: [PATCH 16/58] Fix undefined constant Spree::Responder --- lib/spree/core/controller_helpers/respond_with.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/spree/core/controller_helpers/respond_with.rb b/lib/spree/core/controller_helpers/respond_with.rb index 5fcd4bc2cb..5961a8dfc9 100644 --- a/lib/spree/core/controller_helpers/respond_with.rb +++ b/lib/spree/core/controller_helpers/respond_with.rb @@ -27,7 +27,7 @@ module ActionController # The action name is needed for processing options[:action_name] = action_name.to_sym # If responder is not specified then pass in Spree::Responder - (options.delete(:responder) || Spree::Responder).call(self, resources, options) + (options.delete(:responder) || ::Spree::Responder).call(self, resources, options) end end From 31415d00e625bda377122f0cf85d6858692b971f Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Thu, 5 Nov 2020 13:45:55 +0000 Subject: [PATCH 17/58] TEMP - Fix deprecated cache store naming --- config/environments/production.rb | 2 +- config/environments/staging.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index 9c61ebaab0..7541e78ae1 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -44,7 +44,7 @@ Openfoodnetwork::Application.configure do # Use a different cache store in production memcached_value_max_megabytes = ENV.fetch("MEMCACHED_VALUE_MAX_MEGABYTES", 1).to_i memcached_value_max_bytes = memcached_value_max_megabytes * 1024 * 1024 - config.cache_store = :dalli_store, { value_max_bytes: memcached_value_max_bytes } + config.cache_store = :mem_cache_store, { value_max_bytes: memcached_value_max_bytes } # Enable serving of images, stylesheets, and JavaScripts from an asset server # config.action_controller.asset_host = "http://assets.example.com" diff --git a/config/environments/staging.rb b/config/environments/staging.rb index 9c61ebaab0..7541e78ae1 100644 --- a/config/environments/staging.rb +++ b/config/environments/staging.rb @@ -44,7 +44,7 @@ Openfoodnetwork::Application.configure do # Use a different cache store in production memcached_value_max_megabytes = ENV.fetch("MEMCACHED_VALUE_MAX_MEGABYTES", 1).to_i memcached_value_max_bytes = memcached_value_max_megabytes * 1024 * 1024 - config.cache_store = :dalli_store, { value_max_bytes: memcached_value_max_bytes } + config.cache_store = :mem_cache_store, { value_max_bytes: memcached_value_max_bytes } # Enable serving of images, stylesheets, and JavaScripts from an asset server # config.action_controller.asset_host = "http://assets.example.com" From 6b3da4ac899a0a8cf0f05adce4792f7c21786bd9 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Thu, 5 Nov 2020 14:01:29 +0000 Subject: [PATCH 18/58] Fix "PG::ProtocolViolation: ERROR: bind message supplies 0 parameters" errors --- app/models/enterprise.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index 7d64eccac6..4c7aa40bd8 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -132,7 +132,7 @@ class Enterprise < ActiveRecord::Base where(nil) end } - scope :is_primary_producer, -> { where(is_primary_producer: true) } + scope :is_primary_producer, -> { where("enterprises.is_primary_producer IS TRUE") } scope :is_distributor, -> { where('sells != ?', 'none') } scope :is_hub, -> { where(sells: 'any') } scope :supplying_variant_in, lambda { |variants| From 56f2d38714fc9abc53440329dbfa02626d82779d Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Fri, 6 Nov 2020 00:03:00 +0000 Subject: [PATCH 19/58] Use "raise_in_transactional_callbacks" https://guides.rubyonrails.org/upgrading_ruby_on_rails.html#error-handling-in-transaction-callbacks --- config/application.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/application.rb b/config/application.rb index b0de90dfb4..d69b4cdf34 100644 --- a/config/application.rb +++ b/config/application.rb @@ -201,5 +201,7 @@ module Openfoodnetwork config.active_support.escape_html_entities_in_json = true config.active_job.queue_adapter = :delayed_job + + config.active_record.raise_in_transactional_callbacks = true end end From 9e334a4c1e54aa1d82ea43616caf7584923bff08 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Fri, 6 Nov 2020 02:05:10 +0000 Subject: [PATCH 20/58] Convert ConfirmOrderJob to ActiveJob --- app/jobs/confirm_order_job.rb | 4 ++-- app/models/spree/order.rb | 2 +- spec/jobs/confirm_order_job_spec.rb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/jobs/confirm_order_job.rb b/app/jobs/confirm_order_job.rb index e16df2d99a..3598cbdcfb 100644 --- a/app/jobs/confirm_order_job.rb +++ b/app/jobs/confirm_order_job.rb @@ -1,5 +1,5 @@ -ConfirmOrderJob = Struct.new(:order_id) do - def perform +class ConfirmOrderJob < ActiveJob::Base + def perform(order_id) Spree::OrderMailer.confirm_email_for_customer(order_id).deliver Spree::OrderMailer.confirm_email_for_shop(order_id).deliver end diff --git a/app/models/spree/order.rb b/app/models/spree/order.rb index 3d844aa8e7..029f5bb602 100644 --- a/app/models/spree/order.rb +++ b/app/models/spree/order.rb @@ -466,7 +466,7 @@ module Spree def deliver_order_confirmation_email return if subscription.present? - Delayed::Job.enqueue ConfirmOrderJob.new(id) + ConfirmOrderJob.perform_later(id) end # Helper methods for checkout steps diff --git a/spec/jobs/confirm_order_job_spec.rb b/spec/jobs/confirm_order_job_spec.rb index e3138620e3..61e34f0257 100644 --- a/spec/jobs/confirm_order_job_spec.rb +++ b/spec/jobs/confirm_order_job_spec.rb @@ -11,6 +11,6 @@ describe ConfirmOrderJob do expect(customer_confirm_fake).to receive :deliver expect(shop_confirm_fake).to receive :deliver - run_job ConfirmOrderJob.new order.id + ConfirmOrderJob.perform_now order.id end end From aaf7a90f8b735e1b5d0853c29f3ac7d18ca8992d Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Fri, 6 Nov 2020 02:08:37 +0000 Subject: [PATCH 21/58] Convert OrderCycleNotificationJob to ActiveJob --- app/controllers/admin/order_cycles_controller.rb | 2 +- app/jobs/order_cycle_notification_job.rb | 4 ++-- spec/jobs/order_cycle_notification_job_spec.rb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/admin/order_cycles_controller.rb b/app/controllers/admin/order_cycles_controller.rb index a28060ea5b..3900ee0d7c 100644 --- a/app/controllers/admin/order_cycles_controller.rb +++ b/app/controllers/admin/order_cycles_controller.rb @@ -91,7 +91,7 @@ module Admin # Send notifications to all producers who are part of the order cycle def notify_producers - Delayed::Job.enqueue OrderCycleNotificationJob.new(params[:id].to_i) + OrderCycleNotificationJob.perform_later params[:id].to_i redirect_to main_app.admin_order_cycles_path, notice: I18n.t(:order_cycles_email_to_producers_notice) diff --git a/app/jobs/order_cycle_notification_job.rb b/app/jobs/order_cycle_notification_job.rb index d4efa6de13..b6ab117320 100644 --- a/app/jobs/order_cycle_notification_job.rb +++ b/app/jobs/order_cycle_notification_job.rb @@ -1,6 +1,6 @@ # Delivers an email with a report of the order cycle to each of its suppliers -OrderCycleNotificationJob = Struct.new(:order_cycle_id) do - def perform +class OrderCycleNotificationJob < ActiveJob::Base + def perform(order_cycle_id) order_cycle = OrderCycle.find(order_cycle_id) order_cycle.suppliers.each do |supplier| ProducerMailer.order_cycle_report(supplier, order_cycle).deliver diff --git a/spec/jobs/order_cycle_notification_job_spec.rb b/spec/jobs/order_cycle_notification_job_spec.rb index aa2eb2b2b4..06092433ee 100644 --- a/spec/jobs/order_cycle_notification_job_spec.rb +++ b/spec/jobs/order_cycle_notification_job_spec.rb @@ -9,7 +9,7 @@ describe OrderCycleNotificationJob do end it 'sends a mail to each supplier' do - run_job OrderCycleNotificationJob.new(order_cycle.id) + OrderCycleNotificationJob.perform_now order_cycle.id expect(ProducerMailer).to have_received(:order_cycle_report).twice end end From b36b0eddeee935a80fb4bc286a5666879012c2ab Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Fri, 6 Nov 2020 12:52:38 +0000 Subject: [PATCH 22/58] Fix Rubocop issues --- app/helpers/checkout_helper.rb | 4 +++- app/jobs/confirm_order_job.rb | 2 ++ app/jobs/order_cycle_notification_job.rb | 2 ++ app/jobs/welcome_enterprise_job.rb | 2 ++ lib/open_food_network/payments_report.rb | 18 ++++++++++++++++-- 5 files changed, 25 insertions(+), 3 deletions(-) diff --git a/app/helpers/checkout_helper.rb b/app/helpers/checkout_helper.rb index 72779dd4ec..8e54913dc5 100644 --- a/app/helpers/checkout_helper.rb +++ b/app/helpers/checkout_helper.rb @@ -18,7 +18,9 @@ module CheckoutHelper enterprise_fee_adjustments = adjustments.select { |a| a.originator_type == 'EnterpriseFee' && a.source_type != 'Spree::LineItem' } adjustments.reject! { |a| a.originator_type == 'EnterpriseFee' && a.source_type != 'Spree::LineItem' } unless exclude.include? :admin_and_handling - adjustments << Spree::Adjustment.new(label: I18n.t(:orders_form_admin), amount: enterprise_fee_adjustments.sum(:amount)) + adjustments << Spree::Adjustment.new( + label: I18n.t(:orders_form_admin), amount: enterprise_fee_adjustments.sum(:amount) + ) end adjustments diff --git a/app/jobs/confirm_order_job.rb b/app/jobs/confirm_order_job.rb index 3598cbdcfb..1a42b3041b 100644 --- a/app/jobs/confirm_order_job.rb +++ b/app/jobs/confirm_order_job.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ConfirmOrderJob < ActiveJob::Base def perform(order_id) Spree::OrderMailer.confirm_email_for_customer(order_id).deliver diff --git a/app/jobs/order_cycle_notification_job.rb b/app/jobs/order_cycle_notification_job.rb index b6ab117320..e3a2f4d8ac 100644 --- a/app/jobs/order_cycle_notification_job.rb +++ b/app/jobs/order_cycle_notification_job.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Delivers an email with a report of the order cycle to each of its suppliers class OrderCycleNotificationJob < ActiveJob::Base def perform(order_cycle_id) diff --git a/app/jobs/welcome_enterprise_job.rb b/app/jobs/welcome_enterprise_job.rb index a936514ef9..26bd581b88 100644 --- a/app/jobs/welcome_enterprise_job.rb +++ b/app/jobs/welcome_enterprise_job.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class WelcomeEnterpriseJob < ActiveJob::Base def perform(enterprise_id) enterprise = Enterprise.find enterprise_id diff --git a/lib/open_food_network/payments_report.rb b/lib/open_food_network/payments_report.rb index 7cfc6342f4..ec92d497ef 100644 --- a/lib/open_food_network/payments_report.rb +++ b/lib/open_food_network/payments_report.rb @@ -106,8 +106,22 @@ module OpenFoodNetwork proc { |orders| orders.sum(:item_total) }, proc { |orders| orders.sum(&:ship_total) }, proc { |orders| orders.sum(:total) }, - proc { |orders| orders.sum { |o| o.payments.select { |payment| payment.completed? && (payment.payment_method.name.to_s.include? "EFT") }.sum(:amount) } }, - proc { |orders| orders.sum { |o| o.payments.select { |payment| payment.completed? && (payment.payment_method.name.to_s.include? "PayPal") }.sum(:amount) } }, + proc { |orders| + orders.sum { |o| + o.payments.select { |payment| + payment.completed? && + (payment.payment_method.name.to_s.include? "EFT") + } .sum(:amount) + } + }, + proc { |orders| + orders.sum { |o| + o.payments.select { |payment| + payment.completed? && + (payment.payment_method.name.to_s.include? "PayPal") + } .sum(:amount) + } + }, proc { |orders| orders.sum(&:outstanding_balance) }] else [proc { |payments| payments.first.order.payment_state }, From eb040de422e0908a8cecd6b086dd8a6585fa7654 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Fri, 6 Nov 2020 14:44:21 +0000 Subject: [PATCH 23/58] Fix expectation in base_helper_spec The attribute on this element are now rendered in alphabetical order --- spec/helpers/spree/admin/base_helper_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/helpers/spree/admin/base_helper_spec.rb b/spec/helpers/spree/admin/base_helper_spec.rb index db15d2a283..0b273e240e 100644 --- a/spec/helpers/spree/admin/base_helper_spec.rb +++ b/spec/helpers/spree/admin/base_helper_spec.rb @@ -9,7 +9,7 @@ describe Spree::BaseHelper, type: :helper do subject { helper.link_to_remove_fields(name, form, options) } it 'returns an `a` tag followed by a hidden `input` tag' do - expect(subject).to eq("Hola<input type="hidden" name="_method" value="destroy">") + expect(subject).to eq("Hola<input type="hidden" name="_method" value="destroy">") end end end From 62b80043ba969609495cd14970fceb4ef2e85ea5 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Fri, 6 Nov 2020 15:21:00 +0000 Subject: [PATCH 24/58] Fix mailer specs These methods are not actually called now until the email is being delivered. --- spec/mailers/order_mailer_spec.rb | 4 ++-- spec/mailers/shipment_mailer_spec.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/mailers/order_mailer_spec.rb b/spec/mailers/order_mailer_spec.rb index 516c7f1d12..f94b573c90 100644 --- a/spec/mailers/order_mailer_spec.rb +++ b/spec/mailers/order_mailer_spec.rb @@ -23,14 +23,14 @@ describe Spree::OrderMailer do it "confirm_email_for_customer accepts an order id as an alternative to an Order object" do expect(Spree::Order).to receive(:find).with(order.id).and_return(order) expect { - confirmation_email = Spree::OrderMailer.confirm_email_for_customer(order.id) + Spree::OrderMailer.confirm_email_for_customer(order.id).deliver }.to_not raise_error end it "cancel_email accepts an order id as an alternative to an Order object" do expect(Spree::Order).to receive(:find).with(order.id).and_return(order) expect { - cancel_email = Spree::OrderMailer.cancel_email(order.id) + Spree::OrderMailer.cancel_email(order.id).deliver }.to_not raise_error end end diff --git a/spec/mailers/shipment_mailer_spec.rb b/spec/mailers/shipment_mailer_spec.rb index e952536130..c1d8f046b4 100644 --- a/spec/mailers/shipment_mailer_spec.rb +++ b/spec/mailers/shipment_mailer_spec.rb @@ -30,7 +30,7 @@ describe Spree::ShipmentMailer do it "shipment_email accepts an shipment id as an alternative to an Shipment object" do expect(Spree::Shipment).to receive(:find).with(shipment.id).and_return(shipment) expect { - shipped_email = Spree::ShipmentMailer.shipped_email(shipment.id) + Spree::ShipmentMailer.shipped_email(shipment.id).deliver }.to_not raise_error end end From a5472d6b64e5b04e061bba89472942cacc8cdf32 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Fri, 6 Nov 2020 17:03:57 +0000 Subject: [PATCH 25/58] Convert ConfirmSignupJob to ActiveJob --- app/jobs/confirm_signup_job.rb | 6 ++++-- app/models/spree/user.rb | 2 +- spec/jobs/confirm_signup_job_spec.rb | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/jobs/confirm_signup_job.rb b/app/jobs/confirm_signup_job.rb index d16aee714c..bcb70c1f8c 100644 --- a/app/jobs/confirm_signup_job.rb +++ b/app/jobs/confirm_signup_job.rb @@ -1,5 +1,7 @@ -ConfirmSignupJob = Struct.new(:user_id) do - def perform +# frozen_string_literal: true + +class ConfirmSignupJob < ActiveJob::Base + def perform(user_id) user = Spree::User.find user_id Spree::UserMailer.signup_confirmation(user).deliver end diff --git a/app/models/spree/user.rb b/app/models/spree/user.rb index 717698e7b8..b05413dd78 100644 --- a/app/models/spree/user.rb +++ b/app/models/spree/user.rb @@ -101,7 +101,7 @@ module Spree end def send_signup_confirmation - Delayed::Job.enqueue ConfirmSignupJob.new(id) + ConfirmSignupJob.perform_later(id) end def associate_customers diff --git a/spec/jobs/confirm_signup_job_spec.rb b/spec/jobs/confirm_signup_job_spec.rb index 59624b9a87..aafbcb016a 100644 --- a/spec/jobs/confirm_signup_job_spec.rb +++ b/spec/jobs/confirm_signup_job_spec.rb @@ -8,6 +8,6 @@ describe ConfirmSignupJob do expect(Spree::UserMailer).to receive(:signup_confirmation).with(user).and_return(mail) expect(mail).to receive(:deliver) - run_job ConfirmSignupJob.new user.id + ConfirmSignupJob.perform_now(user.id) end end From 49081e171ed5e9ffb1426d12bc9c15e8ea4bd517 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Fri, 6 Nov 2020 17:11:42 +0000 Subject: [PATCH 26/58] Fix PG::UndefinedTable errors The logic of #includes has changed slightly in Rails 4.2 and now usually needs the #references method as well. PG::UndefinedTable: # ERROR: missing FROM-clause entry for table "enterprises" # LINE 1: SELECT "spree_users".* FROM "spree_users" WHERE (enterprises... # ^ # ./spec/models/spree/user_spec.rb:125:in `block (4 levels) in ' --- lib/open_food_network/customers_report.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/open_food_network/customers_report.rb b/lib/open_food_network/customers_report.rb index 96cbd0fd4e..b49690eb48 100644 --- a/lib/open_food_network/customers_report.rb +++ b/lib/open_food_network/customers_report.rb @@ -60,7 +60,10 @@ module OpenFoodNetwork def filter_to_supplier(orders) if params[:supplier_id].to_i > 0 orders.select do |order| - order.line_items.includes(:product).references(:product).where("spree_products.supplier_id = ?", params[:supplier_id].to_i).count > 0 + order.line_items.includes(:product) + .where("spree_products.supplier_id = ?", params[:supplier_id].to_i) + .references(:product) + .count > 0 end else orders From 1a4e292178695bdb3aa1703152f6c6ff9dfce25b Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Fri, 6 Nov 2020 17:23:29 +0000 Subject: [PATCH 27/58] Fix json "empty body" expectations --- spec/controllers/admin/bulk_line_items_controller_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/controllers/admin/bulk_line_items_controller_spec.rb b/spec/controllers/admin/bulk_line_items_controller_spec.rb index da05149079..bd68266792 100644 --- a/spec/controllers/admin/bulk_line_items_controller_spec.rb +++ b/spec/controllers/admin/bulk_line_items_controller_spec.rb @@ -195,7 +195,7 @@ describe Admin::BulkLineItemsController, type: :controller do it "returns an empty JSON response" do spree_put :update, params - expect(response.body).to eq ' ' + expect(response.body).to eq "" end it 'returns a 204 response' do @@ -273,7 +273,7 @@ describe Admin::BulkLineItemsController, type: :controller do it 'returns an empty JSON response' do spree_delete :destroy, params - expect(response.body).to eq ' ' + expect(response.body).to eq "" end it 'returns a 204 response' do From 1e8d400534b2e5aff530f207f70e44cde98e170e Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Fri, 6 Nov 2020 17:42:02 +0000 Subject: [PATCH 28/58] Add Paranoia#delete (original) --- config/initializers/paranoia.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 config/initializers/paranoia.rb diff --git a/config/initializers/paranoia.rb b/config/initializers/paranoia.rb new file mode 100644 index 0000000000..f0e5cf8ea1 --- /dev/null +++ b/config/initializers/paranoia.rb @@ -0,0 +1,15 @@ +module Paranoia + def paranoia_delete + raise ActiveRecord::ReadOnlyRecord, "#{self.class} is marked as readonly" if readonly? + if persisted? + # if a transaction exists, add the record so that after_commit + # callbacks can be run + add_to_transaction + update_columns(paranoia_destroy_attributes) + elsif !frozen? + assign_attributes(paranoia_destroy_attributes) + end + self + end + alias_method :delete, :paranoia_delete +end From 1ab62fddcb83cdc2f71c701ad9ba34406e8936da Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Fri, 6 Nov 2020 17:55:09 +0000 Subject: [PATCH 29/58] Patch Paranoia#delete to resolve ActiveRecord::ConnectionAdapters::NullTransaction errors Patches Paranoia gem to fix a conflict with transactions in Rspec: https://github.com/rubysherpas/paranoia/issues/274 Example error: ``` Failure/Error: order.line_items.first.variant.tap(&:delete) NoMethodError: undefined method `state' for # ``` --- config/initializers/paranoia.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/initializers/paranoia.rb b/config/initializers/paranoia.rb index f0e5cf8ea1..0789eb4e95 100644 --- a/config/initializers/paranoia.rb +++ b/config/initializers/paranoia.rb @@ -4,7 +4,7 @@ module Paranoia if persisted? # if a transaction exists, add the record so that after_commit # callbacks can be run - add_to_transaction + add_to_transaction unless self.class.connection.current_transaction.closed? update_columns(paranoia_destroy_attributes) elsif !frozen? assign_attributes(paranoia_destroy_attributes) From 3c74541145c6300bd79a8de195ff5779ae4468c3 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Fri, 6 Nov 2020 19:28:23 +0000 Subject: [PATCH 30/58] Fix misbehaving params in Api::ProductsController In some cases the given params were being deleted here. --- app/controllers/api/products_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/products_controller.rb b/app/controllers/api/products_controller.rb index f070bba15e..e59b64aba1 100644 --- a/app/controllers/api/products_controller.rb +++ b/app/controllers/api/products_controller.rb @@ -145,7 +145,7 @@ module Api end def query_params_with_defaults - params[:q].to_h.reverse_merge(s: 'created_at desc') + (params[:q] || {}).reverse_merge(s: 'created_at desc') end def pagination_data(results) From 8f8973b6f964b6b8e00ce5ffbc27e256ecf3a6f4 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Fri, 6 Nov 2020 21:03:57 +0000 Subject: [PATCH 31/58] Call #deliver in user_mailer_spec so mail is sent --- spec/mailers/user_mailer_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/mailers/user_mailer_spec.rb b/spec/mailers/user_mailer_spec.rb index 9d1b597d26..8d4e5b40b9 100644 --- a/spec/mailers/user_mailer_spec.rb +++ b/spec/mailers/user_mailer_spec.rb @@ -48,7 +48,7 @@ describe Spree::UserMailer do # adapted from https://github.com/spree/spree_auth_devise/blob/70737af/spec/mailers/user_mailer_spec.rb describe '#reset_password_instructions' do describe 'message contents' do - let(:message) { described_class.reset_password_instructions(user, nil) } + let(:message) { described_class.reset_password_instructions(user, nil).deliver } context 'subject includes' do it 'translated devise instructions' do From e1c15749315e2c817f42aafe316b398090cbc2d2 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sat, 7 Nov 2020 00:02:49 +0000 Subject: [PATCH 32/58] Refactor BulkInvoiceService to use ActiveJob Removes use of #handle_asynchronously, which we need to do elsewhere. Fixes: BulkInvoiceService#start_pdf_job starts a background process to create a pdf with multiple invoices Failure/Error: expect do service.start_pdf_job [1, 2] end.to enqueue_job Delayed::PerformableMethod expected to enqueue exactly 1 jobs, but enqueued 0 # ./spec/services/bulk_invoice_service_spec.rb:8:in `block (3 levels) in ' --- app/jobs/bulk_invoice_job.rb | 25 ++++++++++++++++++++++ app/services/bulk_invoice_service.rb | 19 +--------------- spec/services/bulk_invoice_service_spec.rb | 4 +--- 3 files changed, 27 insertions(+), 21 deletions(-) create mode 100644 app/jobs/bulk_invoice_job.rb diff --git a/app/jobs/bulk_invoice_job.rb b/app/jobs/bulk_invoice_job.rb new file mode 100644 index 0000000000..7335c552d6 --- /dev/null +++ b/app/jobs/bulk_invoice_job.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +class BulkInvoiceJob < ActiveJob::Base + def perform(order_ids, filepath) + pdf = CombinePDF.new + + orders_from(order_ids).each do |order| + invoice = renderer.render_to_string(order) + + pdf << CombinePDF.parse(invoice) + end + + pdf.save filepath + end + + private + + def orders_from(order_ids) + Spree::Order.where(id: order_ids).order("completed_at DESC") + end + + def renderer + @renderer ||= InvoiceRenderer.new + end +end diff --git a/app/services/bulk_invoice_service.rb b/app/services/bulk_invoice_service.rb index ab69df03ca..6776ad448a 100644 --- a/app/services/bulk_invoice_service.rb +++ b/app/services/bulk_invoice_service.rb @@ -6,17 +6,8 @@ class BulkInvoiceService end def start_pdf_job(order_ids) - pdf = CombinePDF.new - - orders_from(order_ids).each do |order| - invoice = renderer.render_to_string(order) - - pdf << CombinePDF.parse(invoice) - end - - pdf.save "#{file_directory}/#{@id}.pdf" + BulkInvoiceJob.perform_later order_ids, "#{file_directory}/#{@id}.pdf" end - handle_asynchronously :start_pdf_job def invoice_created?(invoice_id) File.exist? filepath(invoice_id) @@ -28,10 +19,6 @@ class BulkInvoiceService private - def orders_from(order_ids) - Spree::Order.where(id: order_ids).order("completed_at DESC") - end - def new_invoice_id Time.zone.now.to_i.to_s end @@ -40,10 +27,6 @@ class BulkInvoiceService 'tmp/invoices' end - def renderer - @renderer ||= InvoiceRenderer.new - end - def file_directory Dir.mkdir(directory) unless File.exist?(directory) directory diff --git a/spec/services/bulk_invoice_service_spec.rb b/spec/services/bulk_invoice_service_spec.rb index 687e680bcc..af06476e74 100644 --- a/spec/services/bulk_invoice_service_spec.rb +++ b/spec/services/bulk_invoice_service_spec.rb @@ -7,9 +7,7 @@ describe BulkInvoiceService do it "starts a background process to create a pdf with multiple invoices" do expect do service.start_pdf_job [1, 2] - end.to enqueue_job Delayed::PerformableMethod - - expect(Delayed::Job.last.payload_object.method_name).to eq :start_pdf_job_without_delay + end.to enqueue_job BulkInvoiceJob end it "creates a PDF invoice" do From 54ad90e071f22e1707c5a78649673b8fb45ccb61 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sat, 7 Nov 2020 00:34:13 +0000 Subject: [PATCH 33/58] Replace deprecated ActiveRecord::ConnectionAdapters::Column#value_to_boolean This method has been removed in Rails 4.2 --- lib/open_food_network/users_and_enterprises_report.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/open_food_network/users_and_enterprises_report.rb b/lib/open_food_network/users_and_enterprises_report.rb index 74e328ee20..24a92bdf2f 100644 --- a/lib/open_food_network/users_and_enterprises_report.rb +++ b/lib/open_food_network/users_and_enterprises_report.rb @@ -122,7 +122,7 @@ module OpenFoodNetwork end def to_bool(value) - ActiveRecord::ConnectionAdapters::Column.value_to_boolean(value) + ActiveRecord::Type::Boolean.new.type_cast_from_database(value) end def to_local_datetime(date) From ae33df946eda267d8557b5e1232007d6f7a2cc05 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sat, 7 Nov 2020 01:23:46 +0000 Subject: [PATCH 34/58] Fix StateMachine specs --- spec/models/spree/order/state_machine_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/models/spree/order/state_machine_spec.rb b/spec/models/spree/order/state_machine_spec.rb index f9a4164ef1..b52037a26b 100644 --- a/spec/models/spree/order/state_machine_spec.rb +++ b/spec/models/spree/order/state_machine_spec.rb @@ -73,7 +73,7 @@ describe Spree::Order do end context "#can_cancel?" do - %w(pending backorder ready).each do |shipment_state| + [:pending, :backorder, :ready].each do |shipment_state| it "should be true if shipment_state is #{shipment_state}" do allow(order).to receive_messages completed?: true order.shipment_state = shipment_state @@ -81,7 +81,7 @@ describe Spree::Order do end end - (Spree::Shipment.state_machine.states.keys - %w(pending backorder ready)).each do |shipment_state| + (Spree::Shipment.state_machine.states.keys - [:pending, :backorder, :ready]).each do |shipment_state| it "should be false if shipment_state is #{shipment_state}" do allow(order).to receive_messages completed?: true order.shipment_state = shipment_state From 1aa2b7274bada5eab71b15663fbf10abcebd886e Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sat, 7 Nov 2020 01:43:35 +0000 Subject: [PATCH 35/58] Fix test mailer delivery --- spec/mailers/test_mailer_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/mailers/test_mailer_spec.rb b/spec/mailers/test_mailer_spec.rb index 71087a9f36..e0b023c6bf 100644 --- a/spec/mailers/test_mailer_spec.rb +++ b/spec/mailers/test_mailer_spec.rb @@ -15,7 +15,7 @@ describe Spree::TestMailer do it "confirm_email accepts a user id as an alternative to a User object" do expect(Spree.user_class).to receive(:find).with(user.id).and_return(user) expect { - test_email = Spree::TestMailer.test_email(user.id) + Spree::TestMailer.test_email(user.id).deliver }.to_not raise_error end end From 98c99de835e4431ca9107216271bd3620ce29974 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sat, 7 Nov 2020 02:11:29 +0000 Subject: [PATCH 36/58] Use ActiveJob::Testhelper where needed --- spec/services/bulk_invoice_service_spec.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/spec/services/bulk_invoice_service_spec.rb b/spec/services/bulk_invoice_service_spec.rb index af06476e74..ee1e9ad077 100644 --- a/spec/services/bulk_invoice_service_spec.rb +++ b/spec/services/bulk_invoice_service_spec.rb @@ -1,6 +1,8 @@ require 'spec_helper' describe BulkInvoiceService do + include ActiveJob::TestHelper + let(:service) { BulkInvoiceService.new } describe "#start_pdf_job" do @@ -15,7 +17,9 @@ describe BulkInvoiceService do order.bill_address = order.ship_address order.save! - service.start_pdf_job_without_delay([order.id]) + perform_enqueued_jobs do + service.start_pdf_job([order.id]) + end expect(service.invoice_created?(service.id)).to be_truthy end @@ -63,7 +67,9 @@ describe BulkInvoiceService do expect(renderer).to receive(:render_to_string).with(order_oldest).ordered.and_return("") order_ids = [order_oldest, order_old, order_older].map(&:id) - service.start_pdf_job_without_delay(order_ids) + perform_enqueued_jobs do + service.start_pdf_job(order_ids) + end end end end From b512d3ce21cf0c2099fbcaf81e55714954854430 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sat, 7 Nov 2020 12:32:40 +0000 Subject: [PATCH 37/58] Fix column preferences spec Failure/Error: expect(preferences.map(&:column_name)).to eq [:col1, :col2, :col3] expected: [:col1, :col2, :col3] got: ["col1", "col2", "col3"] (compared using ==) Diff: @@ -1 +1 @@ -[:col1, :col2, :col3] +["col1", "col2", "col3"] # ./spec/models/column_preference_spec.rb:56:in `block (4 levels) in ' --- spec/models/column_preference_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/models/column_preference_spec.rb b/spec/models/column_preference_spec.rb index 94c5c1810c..6cc56fc05f 100644 --- a/spec/models/column_preference_spec.rb +++ b/spec/models/column_preference_spec.rb @@ -53,7 +53,7 @@ describe ColumnPreference, type: :model do it "uses defaults where no stored preference exists" do expect(preferences.all?(&:new_record?)).to be true - expect(preferences.map(&:column_name)).to eq [:col1, :col2, :col3] + expect(preferences.map(&:column_name)).to eq ["col1", "col2", "col3"] expect(preferences.map(&:visible)).to eq [false, true, false] end end From 7ef0056225952c56d2c768245866353ae136aaf6 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sat, 7 Nov 2020 13:40:42 +0000 Subject: [PATCH 38/58] Fix invoice rendering issue Setting `locals: { :@order => order }` no longer works; `@order` is not set as expected in the partial. Fixes various errors eg: Failure/Error: = "#{@order.number}" ActionView::Template::Error: undefined method `number' for nil:NilClass # ./app/views/spree/admin/orders/invoice.html.haml:14:in `_app_views_spree_admin_orders_invoice_html_haml__1740595365701113578_70025078036080' # ./app/services/invoice_renderer.rb:3:in `render_to_string' # ./app/controllers/spree/admin/orders_controller.rb:89:in `invoice' --- app/services/invoice_renderer.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/services/invoice_renderer.rb b/app/services/invoice_renderer.rb index e3613dccbe..2f8663d24c 100644 --- a/app/services/invoice_renderer.rb +++ b/app/services/invoice_renderer.rb @@ -1,5 +1,6 @@ class InvoiceRenderer def render_to_string(order) + renderer.instance_variable_set(:@order, order) renderer.render_to_string(args(order)) end @@ -8,15 +9,14 @@ class InvoiceRenderer pdf: "invoice-#{order.number}.pdf", template: invoice_template, formats: [:html], - encoding: "UTF-8", - locals: { :@order => order } + encoding: "UTF-8" } end private def renderer - ApplicationController.new + @renderer ||= ApplicationController.new end def invoice_template From 71c6cee94c112861fa8771b9595e945e44de4ee8 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sat, 7 Nov 2020 14:13:27 +0000 Subject: [PATCH 39/58] Fix "modifying frozen string" error in Package#inspect --- .../app/services/order_management/stock/package.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/order_management/app/services/order_management/stock/package.rb b/engines/order_management/app/services/order_management/stock/package.rb index f3bfaf38f0..aa92487040 100644 --- a/engines/order_management/app/services/order_management/stock/package.rb +++ b/engines/order_management/app/services/order_management/stock/package.rb @@ -101,7 +101,7 @@ module OrderManagement def inspect out = "#{order} - " - out << contents.map do |content_item| + out.dup << contents.map do |content_item| "#{content_item.variant.name} #{content_item.quantity} #{content_item.state}" end.join('/') out From 29052671429cfec02454897618eaabb3aa4a96ed Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sat, 7 Nov 2020 14:14:27 +0000 Subject: [PATCH 40/58] Fix broken variant weight assignment in spec OrderManagement::Stock::Packer builds a package with all the items Failure/Error: expect(package.weight).to be_positive expected `0.0 (#).positive?` to be truthy, got false # ./engines/order_management/spec/services/order_management/stock/packer_spec.rb:19:in `block (2 levels) in ' --- .../spec/services/order_management/stock/packer_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/order_management/spec/services/order_management/stock/packer_spec.rb b/engines/order_management/spec/services/order_management/stock/packer_spec.rb index 1100090af0..5a3d76b22c 100644 --- a/engines/order_management/spec/services/order_management/stock/packer_spec.rb +++ b/engines/order_management/spec/services/order_management/stock/packer_spec.rb @@ -10,7 +10,7 @@ module OrderManagement subject { Packer.new(stock_location, order) } - before { order.line_items.first.variant.update(weight: 1) } + before { order.line_items.first.variant.weight = 1 } it 'builds a package with all the items' do package = subject.package From ea5c7c5990a336d92d6119dba2904f932b489901 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sat, 7 Nov 2020 18:59:39 +0000 Subject: [PATCH 41/58] Fix broken redirect after bulk product update Error: As an Administrator I want to be able to manage products in bulk updating when a filter has been applied Failure/Error: expect(page.find("#status-message")).to have_content "Changes saved." expected to find text "Changes saved." in "Saving.." # ./spec/features/admin/bulk_product_update_spec.rb:451:in `block (2 levels) in ' --- app/controllers/spree/admin/products_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/spree/admin/products_controller.rb b/app/controllers/spree/admin/products_controller.rb index 42d4006680..a0c8452aac 100644 --- a/app/controllers/spree/admin/products_controller.rb +++ b/app/controllers/spree/admin/products_controller.rb @@ -179,7 +179,7 @@ module Spree end def bulk_index_query(params) - params[:filters].to_h.merge(page: params[:page], per_page: params[:per_page]) + (params[:filters] || {}).merge(page: params[:page], per_page: params[:per_page]) end def load_form_data From 4394d2fe4378df092e8cf0760b92846d166407f7 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sat, 7 Nov 2020 20:07:37 +0000 Subject: [PATCH 42/58] Fix tag_rules ForbiddenAttributes errors Example error: Tag Rules creating allows creation of rules of each type Failure/Error: expect(tag_rule.preferred_shipping_method_tags).to eq "volunteers-only" expected: "volunteers-only" got: "" (compared using ==) # ./spec/features/admin/tag_rules_spec.rb:81:in `block (3 levels) in ' --- app/services/permitted_attributes/tag_rules.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/services/permitted_attributes/tag_rules.rb b/app/services/permitted_attributes/tag_rules.rb index ce6bd879e0..6f150c7b34 100644 --- a/app/services/permitted_attributes/tag_rules.rb +++ b/app/services/permitted_attributes/tag_rules.rb @@ -4,7 +4,11 @@ module PermittedAttributes class TagRules def self.attributes [ - :id, :type, :preferred_customer_tags, :calculator_type, + :id, :type, :priority, :is_default, :preferred_customer_tags, :preferred_exchange_tags, + :preferred_matched_order_cycles_visibility, :preferred_shipping_method_tags, + :preferred_matched_shipping_methods_visibility, :preferred_payment_method_tags, + :preferred_matched_payment_methods_visibility, :preferred_variant_tags, + :preferred_matched_variants_visibility, :calculator_type, { calculator_attributes: [:id, :preferred_flat_percent] } ] end From aa718824d8454bd63d58e709b7957d56172dfcd1 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sat, 7 Nov 2020 20:44:51 +0000 Subject: [PATCH 43/58] Fix touch spec The behavior in #change blocks ironically seems to have changed --- spec/models/enterprise_caching_spec.rb | 62 ++++++++++++++++++++------ 1 file changed, 48 insertions(+), 14 deletions(-) diff --git a/spec/models/enterprise_caching_spec.rb b/spec/models/enterprise_caching_spec.rb index 6160481c91..8cec4d5822 100644 --- a/spec/models/enterprise_caching_spec.rb +++ b/spec/models/enterprise_caching_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe Enterprise do context "key-based caching invalidation" do describe "is touched when a(n)" do - let(:enterprise) { create(:distributor_enterprise, updated_at: 1.week.ago) } + let(:enterprise) { create(:distributor_enterprise, updated_at: Time.zone.now - 1.week) } let(:taxon) { create(:taxon) } let(:supplier2) { create(:supplier_enterprise) } @@ -14,26 +14,37 @@ 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 it "touches enterprise when a classification on that product changes" do - expect { classification.save! }.to change { enterprise.updated_at } + expect { + classification.save! + enterprise.reload + }.to change { enterprise.updated_at } end it "touches enterprise when a property on that product changes" do - expect { property.save! }.to change { enterprise.reload.updated_at } + expect { + property.save! + enterprise.reload + }.to change { enterprise.updated_at } end it "touches enterprise when a producer property on that product changes" do - expect { producer_property.save! }.to change { enterprise.reload.updated_at } + expect { + producer_property.save! + enterprise.reload + }.to change { enterprise.updated_at } end it "touches enterprise when the supplier of a product changes" do expect { product.update!(supplier: supplier2) - }.to change { enterprise.reload.updated_at } + enterprise.reload + }.to change { enterprise.updated_at } end end @@ -54,26 +65,39 @@ describe Enterprise do before { oc } it "touches enterprise when a classification on that product changes" do - expect { classification.save! }.to change { enterprise.reload.updated_at } + expect { + classification.save! + enterprise.reload + }.to change { enterprise.updated_at } end it "touches enterprise when a property on that product changes" do - expect { property.save! }.to change { enterprise.reload.updated_at } + expect { + property.save! + enterprise.reload + }.to change { enterprise.updated_at } end it "touches enterprise when a producer property on that product changes" do - expect { producer_property.save! }.to change { enterprise.reload.updated_at } + expect { + producer_property.save! + enterprise.reload + }.to change { enterprise.updated_at } end it "touches enterprise when the supplier of a product changes" do expect { product.update!(supplier: supplier2) - }.to change { enterprise.reload.updated_at } + enterprise.reload + }.to change { enterprise.updated_at } end end it "touches enterprise when the product's variant is added to order cycle" do - expect { oc }.to change { enterprise.reload.updated_at } + expect { + oc + enterprise.reload + }.to change { enterprise.updated_at } end end @@ -82,7 +106,10 @@ describe Enterprise do let!(:er) { create(:enterprise_relationship, parent: enterprise, child: child_enterprise) } it "touches enterprise when enterprise relationship is updated" do - expect { er.save! }.to change { enterprise.reload.updated_at } + expect { + er.save! + enterprise.reload + }.to change { enterprise.updated_at } end end @@ -96,16 +123,23 @@ describe Enterprise do it "touches enterprise when distributor_shipping_method is updated" do expect { enterprise.distributor_shipping_methods.first.save! - }.to change { enterprise.reload.updated_at } + enterprise.reload + }.to change { enterprise.updated_at } end it "touches enterprise when shipping method is updated" do - expect { sm.save! }.to change { enterprise.reload.updated_at } + expect { + sm.save! + enterprise.reload + }.to change { enterprise.updated_at } end end it "touches enterprise when address is updated" do - expect{ enterprise.address.save! }.to change { enterprise.reload.updated_at } + expect { + enterprise.address.save! + enterprise.reload + }.to change { enterprise.updated_at } end end end From 63fb46f4405aad87146a1903b34d9d8105f3af3e Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sat, 7 Nov 2020 21:57:40 +0000 Subject: [PATCH 44/58] Delete some dead code There are some really weird issues in the spec here, and this module is not in use anywhere. --- app/helpers/html_helper.rb | 21 ---------------- app/mailers/spree/order_mailer.rb | 1 - spec/helpers/html_helper_spec.rb | 42 ------------------------------- 3 files changed, 64 deletions(-) delete mode 100644 app/helpers/html_helper.rb delete mode 100644 spec/helpers/html_helper_spec.rb diff --git a/app/helpers/html_helper.rb b/app/helpers/html_helper.rb deleted file mode 100644 index 3342a8901a..0000000000 --- a/app/helpers/html_helper.rb +++ /dev/null @@ -1,21 +0,0 @@ -module HtmlHelper - def strip_html(html) - strip_surrounding_whitespace substitute_entities strip_tags add_linebreaks html - end - - def substitute_entities(html) - html.andand.gsub(/ /i, ' ').andand.gsub(/&/i, '&') - end - - def add_linebreaks(html) - # I know Cthulu is coming for me. Forgive me. - # http://stackoverflow.com/a/1732454/2720566 - html. - andand.gsub(%r{]>|

|}, "\\1\n\n"). - andand.gsub(/]*>/, "\\1\n") - end - - def strip_surrounding_whitespace(html) - html.andand.strip - end -end diff --git a/app/mailers/spree/order_mailer.rb b/app/mailers/spree/order_mailer.rb index 844a3fac41..953a092bc0 100644 --- a/app/mailers/spree/order_mailer.rb +++ b/app/mailers/spree/order_mailer.rb @@ -2,7 +2,6 @@ module Spree class OrderMailer < BaseMailer - helper HtmlHelper helper ::CheckoutHelper helper SpreeCurrencyHelper helper Spree::Admin::PaymentsHelper diff --git a/spec/helpers/html_helper_spec.rb b/spec/helpers/html_helper_spec.rb deleted file mode 100644 index 3b08d16dd3..0000000000 --- a/spec/helpers/html_helper_spec.rb +++ /dev/null @@ -1,42 +0,0 @@ -require 'spec_helper' - -describe HtmlHelper, type: :helper do - describe "stripping html from a string" do - it "strips tags" do - expect(helper.strip_html('

Hello world!

')).to eq("Hello world!") - end - - it "removes nbsp and amp entities" do - expect(helper.strip_html('Hello world&&')).to eq('Hello world&&') - end - - it "returns nil for nil input" do - expect(helper.strip_html(nil)).to be_nil - end - - describe "line breaks" do - it "adds two line breaks after heading tags" do - expect(helper.strip_html("

foo

bar")).to eq("foo\n\nbar"); - expect(helper.strip_html("

foo

bar")).to eq("foo\n\nbar"); - end - - it "adds two line breaks after p tags" do - expect(helper.strip_html("

foo

bar")).to eq("foo\n\nbar"); - end - - it "adds two line breaks after div tags" do - expect(helper.strip_html("
foo
bar")).to eq("foo\n\nbar"); - end - - it "adds a line break after br tags" do - expect(helper.strip_html("foo
bar")).to eq("foo\nbar"); - expect(helper.strip_html("foo
bar")).to eq("foo\nbar"); - expect(helper.strip_html("foo
bar")).to eq("foo\nbar"); - end - - it "strips line breaks at the end of the string" do - expect(helper.strip_html("
foo

")).to eq("foo"); - end - end - end -end From 9de3370a8af6aa5ae7a2faa2dd7d28f8f4cb73ad Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sat, 7 Nov 2020 23:31:32 +0000 Subject: [PATCH 45/58] Fix precision in adjustment form display The tests here were looking for values with a format like "10.00" but the output had changed to "10.0" --- app/views/spree/admin/adjustments/_edit_form.html.haml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/spree/admin/adjustments/_edit_form.html.haml b/app/views/spree/admin/adjustments/_edit_form.html.haml index 5ca71ff9f7..918a9b5b6f 100644 --- a/app/views/spree/admin/adjustments/_edit_form.html.haml +++ b/app/views/spree/admin/adjustments/_edit_form.html.haml @@ -8,7 +8,8 @@ .four.columns = f.field_container :included_tax do = f.label :included_tax, t(:included_tax) - = text_field :adjustment, :included_tax, disabled: true, class: 'fullwidth' + = f.text_field :included_tax, disabled: true, class: 'fullwidth', + value: number_with_precision(f.object.included_tax, precision: 2) = f.error_message_on :included_tax .omega.four.columns From 64153c507227ed9931cef8c2a1e43f719b36328d Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sun, 8 Nov 2020 00:49:00 +0000 Subject: [PATCH 46/58] Remove #handle_asyncronously and update to recommended asyncronous devise mail method --- app/models/spree/user.rb | 8 +++++--- lib/spree/core/controller_helpers/respond_with.rb | 2 +- spec/features/consumer/authentication_spec.rb | 5 ++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/models/spree/user.rb b/app/models/spree/user.rb index b05413dd78..c07e3559cd 100644 --- a/app/models/spree/user.rb +++ b/app/models/spree/user.rb @@ -58,9 +58,11 @@ module Spree has_spree_role?('admin') end - # handle_asynchronously will define send_reset_password_instructions_with_delay. - # If handle_asynchronously is called twice, we get an infinite job loop. - handle_asynchronously :send_reset_password_instructions unless method_defined? :send_reset_password_instructions_with_delay + # Send devise-based user emails asyncronously via ActiveJob + # See: https://github.com/heartcombo/devise/tree/v3.5.10#activejob-integration + def send_devise_notification(notification, *args) + devise_mailer.public_send(notification, self, *args).deliver_later + end def regenerate_reset_password_token set_reset_password_token diff --git a/lib/spree/core/controller_helpers/respond_with.rb b/lib/spree/core/controller_helpers/respond_with.rb index 5961a8dfc9..5fcd4bc2cb 100644 --- a/lib/spree/core/controller_helpers/respond_with.rb +++ b/lib/spree/core/controller_helpers/respond_with.rb @@ -27,7 +27,7 @@ module ActionController # The action name is needed for processing options[:action_name] = action_name.to_sym # If responder is not specified then pass in Spree::Responder - (options.delete(:responder) || ::Spree::Responder).call(self, resources, options) + (options.delete(:responder) || Spree::Responder).call(self, resources, options) end end diff --git a/spec/features/consumer/authentication_spec.rb b/spec/features/consumer/authentication_spec.rb index 790681cbd6..204b8c3b9b 100644 --- a/spec/features/consumer/authentication_spec.rb +++ b/spec/features/consumer/authentication_spec.rb @@ -82,7 +82,7 @@ feature "Authentication", js: true do expect do click_signup_button expect(page).to have_content I18n.t('devise.user_registrations.spree_user.signed_up_but_unconfirmed') - end.to send_confirmation_instructions + end.to enqueue_job ActionMailer::DeliveryJob end end end @@ -104,8 +104,7 @@ feature "Authentication", js: true do expect do click_reset_password_button expect(page).to have_reset_password - end.to enqueue_job Delayed::PerformableMethod - expect(Delayed::Job.last.payload_object.method_name).to eq(:send_reset_password_instructions_without_delay) + end.to enqueue_job ActionMailer::DeliveryJob end context "user with unconfirmed email" do From 2b884be8dd5746310978a569be232680f77e4d46 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sun, 8 Nov 2020 01:53:53 +0000 Subject: [PATCH 47/58] Update specs to work with ActionMailer::DeliveryJob --- .../user_confirmations_controller_spec.rb | 4 ++- spec/features/admin/users_spec.rb | 2 +- .../consumer/account/settings_spec.rb | 25 +++++++++---------- spec/models/spree/user_spec.rb | 7 +++--- spec/spec_helper.rb | 1 + 5 files changed, 20 insertions(+), 19 deletions(-) diff --git a/spec/controllers/user_confirmations_controller_spec.rb b/spec/controllers/user_confirmations_controller_spec.rb index 82ec5c2cc3..dacbfcb138 100644 --- a/spec/controllers/user_confirmations_controller_spec.rb +++ b/spec/controllers/user_confirmations_controller_spec.rb @@ -70,7 +70,9 @@ describe UserConfirmationsController, type: :controller do performing_deliveries do expect do spree_post :create, spree_user: { email: unconfirmed_user.email } - end.to send_confirmation_instructions + end.to enqueue_job ActionMailer::DeliveryJob + + expect(enqueued_jobs.last.to_s).to match "confirmation_instructions" end end end diff --git a/spec/features/admin/users_spec.rb b/spec/features/admin/users_spec.rb index 94cb4b881f..10efd1e4d2 100644 --- a/spec/features/admin/users_spec.rb +++ b/spec/features/admin/users_spec.rb @@ -124,7 +124,7 @@ feature "Managing users" do # The `a` element doesn't have an href, so we can't use click_link. find("a", text: "Resend").click expect(page).to have_text "Resend done" - end.to send_confirmation_instructions + end.to enqueue_job ActionMailer::DeliveryJob end end end diff --git a/spec/features/consumer/account/settings_spec.rb b/spec/features/consumer/account/settings_spec.rb index 77012ee3d8..e69f74c8a6 100644 --- a/spec/features/consumer/account/settings_spec.rb +++ b/spec/features/consumer/account/settings_spec.rb @@ -21,23 +21,22 @@ feature "Account Settings", js: true do end it "allows the user to update their email address" do - performing_deliveries do - fill_in 'user_email', with: 'new@email.com' + fill_in 'user_email', with: 'new@email.com' + performing_deliveries do expect do click_button I18n.t(:update) - end.to send_confirmation_instructions - - sent_mail = ActionMailer::Base.deliveries.last - expect(sent_mail.to).to eq ['new@email.com'] - - expect(find(".alert-box.success").text.strip).to eq "#{I18n.t('spree.account_updated')} ×" - user.reload - expect(user.email).to eq 'old@email.com' - expect(user.unconfirmed_email).to eq 'new@email.com' - click_link I18n.t('spree.users.show.tabs.settings') - expect(page).to have_content I18n.t('spree.users.show.unconfirmed_email', unconfirmed_email: 'new@email.com') + end.to enqueue_job ActionMailer::DeliveryJob end + + expect(enqueued_jobs.last.to_s).to match "new@email.com" + + expect(find(".alert-box.success").text.strip).to eq "#{I18n.t('spree.account_updated')} ×" + user.reload + expect(user.email).to eq 'old@email.com' + expect(user.unconfirmed_email).to eq 'new@email.com' + click_link I18n.t('spree.users.show.tabs.settings') + expect(page).to have_content I18n.t('spree.users.show.unconfirmed_email', unconfirmed_email: 'new@email.com') end it "allows the user to change their password" do diff --git a/spec/models/spree/user_spec.rb b/spec/models/spree/user_spec.rb index abd34364c3..26930a4925 100644 --- a/spec/models/spree/user_spec.rb +++ b/spec/models/spree/user_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Spree.user_class do +describe Spree::User do include OpenFoodNetwork::EmailHelper describe "associations" do @@ -81,11 +81,10 @@ describe Spree.user_class do performing_deliveries do expect do create(:user, email: 'new_user@example.com', confirmation_sent_at: nil, confirmed_at: nil) - end.to send_confirmation_instructions + end.to enqueue_job ActionMailer::DeliveryJob end - sent_mail = ActionMailer::Base.deliveries.last - expect(sent_mail.to).to eq ['new_user@example.com'] + expect(enqueued_jobs.last.to_s).to match "confirmation_instructions" end context "with the the same email as existing customers" do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index dfbc595eb9..4c78b8542c 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -194,6 +194,7 @@ RSpec.configure do |config| config.include OpenFoodNetwork::DelayedJobHelper config.include OpenFoodNetwork::PerformanceHelper config.include DownloadsHelper, type: :feature + config.include ActiveJob::TestHelper # FactoryBot require 'factory_bot_rails' From f589d278cfdc146a922951e84bd1b9944eaa59c7 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Tue, 10 Nov 2020 11:24:09 +0000 Subject: [PATCH 48/58] Add failing spec for Package#inspect --- .../spec/services/order_management/stock/package_spec.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/engines/order_management/spec/services/order_management/stock/package_spec.rb b/engines/order_management/spec/services/order_management/stock/package_spec.rb index 205d50ae1a..4288e16a51 100644 --- a/engines/order_management/spec/services/order_management/stock/package_spec.rb +++ b/engines/order_management/spec/services/order_management/stock/package_spec.rb @@ -112,6 +112,13 @@ module OrderManagement expect(shipment.shipping_method).to eq shipping_method end + + describe "#inpsect" do + xit "prints the package contents" do + subject.add variant, 5 + expect(subject.inspect).to match("#{variant.name} 5") + end + end end context "#shipping_methods and #shipping_categories" do From 98f42a1f81b286f3822d8d973d85e5b7ddbac11a Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Tue, 10 Nov 2020 11:24:31 +0000 Subject: [PATCH 49/58] Fix output of Package#inspect --- .../app/services/order_management/stock/package.rb | 1 - .../spec/services/order_management/stock/package_spec.rb | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/engines/order_management/app/services/order_management/stock/package.rb b/engines/order_management/app/services/order_management/stock/package.rb index aa92487040..d6ebbb35c1 100644 --- a/engines/order_management/app/services/order_management/stock/package.rb +++ b/engines/order_management/app/services/order_management/stock/package.rb @@ -104,7 +104,6 @@ module OrderManagement out.dup << contents.map do |content_item| "#{content_item.variant.name} #{content_item.quantity} #{content_item.state}" end.join('/') - out end def to_shipment diff --git a/engines/order_management/spec/services/order_management/stock/package_spec.rb b/engines/order_management/spec/services/order_management/stock/package_spec.rb index 4288e16a51..1a7fbd017a 100644 --- a/engines/order_management/spec/services/order_management/stock/package_spec.rb +++ b/engines/order_management/spec/services/order_management/stock/package_spec.rb @@ -114,7 +114,7 @@ module OrderManagement end describe "#inpsect" do - xit "prints the package contents" do + it "prints the package contents" do subject.add variant, 5 expect(subject.inspect).to match("#{variant.name} 5") end From 60aaf8100a678ee5645e3b40b014a99e4842ac9a Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Thu, 12 Nov 2020 22:23:34 +0000 Subject: [PATCH 50/58] Fix some Rubocop offences --- app/controllers/application_controller.rb | 2 ++ lib/application_responder.rb | 2 ++ lib/open_food_network/customers_report.rb | 3 ++- spec/features/consumer/account/settings_spec.rb | 3 ++- spec/models/spree/order/state_machine_spec.rb | 3 ++- 5 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 56a9682559..c4ab6b9bed 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "application_responder" require 'open_food_network/referer_parser' require_dependency 'spree/authentication_helpers' diff --git a/lib/application_responder.rb b/lib/application_responder.rb index cc3e588853..314faee654 100644 --- a/lib/application_responder.rb +++ b/lib/application_responder.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ApplicationResponder < ActionController::Responder include Responders::FlashResponder include Responders::HttpCacheResponder diff --git a/lib/open_food_network/customers_report.rb b/lib/open_food_network/customers_report.rb index b49690eb48..457dc66d59 100644 --- a/lib/open_food_network/customers_report.rb +++ b/lib/open_food_network/customers_report.rb @@ -63,7 +63,8 @@ module OpenFoodNetwork order.line_items.includes(:product) .where("spree_products.supplier_id = ?", params[:supplier_id].to_i) .references(:product) - .count > 0 + .count + .positive? end else orders diff --git a/spec/features/consumer/account/settings_spec.rb b/spec/features/consumer/account/settings_spec.rb index e69f74c8a6..86c952091d 100644 --- a/spec/features/consumer/account/settings_spec.rb +++ b/spec/features/consumer/account/settings_spec.rb @@ -36,7 +36,8 @@ feature "Account Settings", js: true do expect(user.email).to eq 'old@email.com' expect(user.unconfirmed_email).to eq 'new@email.com' click_link I18n.t('spree.users.show.tabs.settings') - expect(page).to have_content I18n.t('spree.users.show.unconfirmed_email', unconfirmed_email: 'new@email.com') + expect(page).to have_content I18n.t('spree.users.show.unconfirmed_email', + unconfirmed_email: 'new@email.com') end it "allows the user to change their password" do diff --git a/spec/models/spree/order/state_machine_spec.rb b/spec/models/spree/order/state_machine_spec.rb index b52037a26b..fb65352a59 100644 --- a/spec/models/spree/order/state_machine_spec.rb +++ b/spec/models/spree/order/state_machine_spec.rb @@ -81,7 +81,8 @@ describe Spree::Order do end end - (Spree::Shipment.state_machine.states.keys - [:pending, :backorder, :ready]).each do |shipment_state| + (Spree::Shipment.state_machine.states.keys - [:pending, :backorder, :ready]) + .each do |shipment_state| it "should be false if shipment_state is #{shipment_state}" do allow(order).to receive_messages completed?: true order.shipment_state = shipment_state From c6c20dc0f69413b24079fef1ea430039b33d58da Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Thu, 12 Nov 2020 23:19:32 +0000 Subject: [PATCH 51/58] Add ActionController::ConditionalGet to Api::BaseController This was added in Spree around the time of Rails 4.2 and seems to fix some of the response errors around the `responders` gem. --- app/controllers/api/base_controller.rb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/controllers/api/base_controller.rb b/app/controllers/api/base_controller.rb index 540c7b1fea..493b13665e 100644 --- a/app/controllers/api/base_controller.rb +++ b/app/controllers/api/base_controller.rb @@ -1,7 +1,6 @@ # Base controller for OFN's API require_dependency 'spree/api/controller_setup' require "spree/core/controller_helpers/ssl" -require "application_responder" module Api class BaseController < ActionController::Metal @@ -10,9 +9,7 @@ module Api include Spree::Api::ControllerSetup include Spree::Core::ControllerHelpers::SSL include ::ActionController::Head - - self.responder = ApplicationResponder - respond_to :json + include ::ActionController::ConditionalGet attr_accessor :current_api_user From d2998f1190e3b0e67e5981b7d848fcfbbf5f1c89 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Fri, 20 Nov 2020 21:27:11 +0000 Subject: [PATCH 52/58] Remove spaces in payments report --- lib/open_food_network/payments_report.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/open_food_network/payments_report.rb b/lib/open_food_network/payments_report.rb index ec92d497ef..33bcfadadc 100644 --- a/lib/open_food_network/payments_report.rb +++ b/lib/open_food_network/payments_report.rb @@ -111,7 +111,7 @@ module OpenFoodNetwork o.payments.select { |payment| payment.completed? && (payment.payment_method.name.to_s.include? "EFT") - } .sum(:amount) + }.sum(:amount) } }, proc { |orders| @@ -119,7 +119,7 @@ module OpenFoodNetwork o.payments.select { |payment| payment.completed? && (payment.payment_method.name.to_s.include? "PayPal") - } .sum(:amount) + }.sum(:amount) } }, proc { |orders| orders.sum(&:outstanding_balance) }] From 2b2f1ac0cd68dc4ae85407dca4a5aa6c471e9f45 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Fri, 20 Nov 2020 21:28:08 +0000 Subject: [PATCH 53/58] Improve specificity of expectation in reset password email test --- spec/features/consumer/authentication_spec.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/features/consumer/authentication_spec.rb b/spec/features/consumer/authentication_spec.rb index 204b8c3b9b..50c9974a49 100644 --- a/spec/features/consumer/authentication_spec.rb +++ b/spec/features/consumer/authentication_spec.rb @@ -105,6 +105,8 @@ feature "Authentication", js: true do click_reset_password_button expect(page).to have_reset_password end.to enqueue_job ActionMailer::DeliveryJob + + expect(enqueued_jobs.last.to_s).to match "reset_password_instructions" end context "user with unconfirmed email" do From d299c8cf01a856e0c53599e0d0e45ef9063ccad7 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sat, 21 Nov 2020 12:35:55 +0000 Subject: [PATCH 54/58] Update test setup in Packer spec. This is the correct way to set a variant's weight. --- .../spec/services/order_management/stock/packer_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/order_management/spec/services/order_management/stock/packer_spec.rb b/engines/order_management/spec/services/order_management/stock/packer_spec.rb index 5a3d76b22c..53b6505231 100644 --- a/engines/order_management/spec/services/order_management/stock/packer_spec.rb +++ b/engines/order_management/spec/services/order_management/stock/packer_spec.rb @@ -10,7 +10,7 @@ module OrderManagement subject { Packer.new(stock_location, order) } - before { order.line_items.first.variant.weight = 1 } + before { order.line_items.first.variant.update(unit_value: 100) } it 'builds a package with all the items' do package = subject.package From 9c41c296e48fb5f1d18725b822a740e3d4787143 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Tue, 24 Nov 2020 09:46:29 +0000 Subject: [PATCH 55/58] Remove default comments from ApplicationResponder --- lib/application_responder.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/application_responder.rb b/lib/application_responder.rb index 314faee654..b27280045e 100644 --- a/lib/application_responder.rb +++ b/lib/application_responder.rb @@ -3,8 +3,4 @@ class ApplicationResponder < ActionController::Responder include Responders::FlashResponder include Responders::HttpCacheResponder - - # Redirects resources to the collection path (index action) instead - # of the resource path (show action) for POST/PUT/DELETE requests. - # include Responders::CollectionResponder end From 049f66c2aabf5d478054749350e3f040198f2d4a Mon Sep 17 00:00:00 2001 From: Andy Brett Date: Tue, 24 Nov 2020 17:55:14 -0800 Subject: [PATCH 56/58] address #6411 --- app/helpers/checkout_helper.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/helpers/checkout_helper.rb b/app/helpers/checkout_helper.rb index 8e54913dc5..4ae026bef7 100644 --- a/app/helpers/checkout_helper.rb +++ b/app/helpers/checkout_helper.rb @@ -19,7 +19,7 @@ module CheckoutHelper adjustments.reject! { |a| a.originator_type == 'EnterpriseFee' && a.source_type != 'Spree::LineItem' } unless exclude.include? :admin_and_handling adjustments << Spree::Adjustment.new( - label: I18n.t(:orders_form_admin), amount: enterprise_fee_adjustments.sum(:amount) + label: I18n.t(:orders_form_admin), amount: enterprise_fee_adjustments.map(&:amount).sum ) end @@ -28,7 +28,7 @@ module CheckoutHelper def display_checkout_admin_and_handling_adjustments_total_for(order) adjustments = order.adjustments.eligible.where('originator_type = ? AND source_type != ? ', 'EnterpriseFee', 'Spree::LineItem') - Spree::Money.new adjustments.sum(:amount), currency: order.currency + Spree::Money.new adjustments.map(&:amount).sum, currency: order.currency end def checkout_line_item_adjustments(order) @@ -36,7 +36,7 @@ module CheckoutHelper end def checkout_subtotal(order) - order.item_total + checkout_line_item_adjustments(order).sum(:amount) + order.item_total + checkout_line_item_adjustments(order).map(&:amount).sum end def display_checkout_subtotal(order) From 1ceb6ac91613ff2764c09da796bf62618fd839c1 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Fri, 27 Nov 2020 12:26:36 +0000 Subject: [PATCH 57/58] Update orders_and_fulfilment report totals --- .../distributor_totals_by_supplier_report.rb | 2 +- .../supplier_totals_by_distributor_report.rb | 2 +- .../orders_and_fulfillments_report/supplier_totals_report.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/open_food_network/orders_and_fulfillments_report/distributor_totals_by_supplier_report.rb b/lib/open_food_network/orders_and_fulfillments_report/distributor_totals_by_supplier_report.rb index cfb1a1f3f9..d9828e6aef 100644 --- a/lib/open_food_network/orders_and_fulfillments_report/distributor_totals_by_supplier_report.rb +++ b/lib/open_food_network/orders_and_fulfillments_report/distributor_totals_by_supplier_report.rb @@ -59,7 +59,7 @@ module OpenFoodNetwork proc { |line_items| line_items.first.variant.product.supplier.name }, proc { |line_items| line_items.first.variant.product.name }, proc { |line_items| line_items.first.variant.full_name }, - proc { |line_items| line_items.sum(:quantity) }, + proc { |line_items| line_items.to_a.sum(&:quantity) }, proc { |line_items| line_items.first.price }, proc { |line_items| line_items.sum(&:amount) }, proc { |_line_items| "" }, diff --git a/lib/open_food_network/orders_and_fulfillments_report/supplier_totals_by_distributor_report.rb b/lib/open_food_network/orders_and_fulfillments_report/supplier_totals_by_distributor_report.rb index cddc962f49..98aa381a79 100644 --- a/lib/open_food_network/orders_and_fulfillments_report/supplier_totals_by_distributor_report.rb +++ b/lib/open_food_network/orders_and_fulfillments_report/supplier_totals_by_distributor_report.rb @@ -60,7 +60,7 @@ module OpenFoodNetwork proc { |line_items| line_items.first.variant.product.name }, proc { |line_items| line_items.first.variant.full_name }, proc { |line_items| line_items.first.order.distributor.name }, - proc { |line_items| line_items.sum(:quantity) }, + proc { |line_items| line_items.to_a.sum(&:quantity) }, proc { |line_items| line_items.first.price }, proc { |line_items| line_items.sum(&:amount) }, proc { |_line_items| I18n.t(:report_header_shipping_method) } diff --git a/lib/open_food_network/orders_and_fulfillments_report/supplier_totals_report.rb b/lib/open_food_network/orders_and_fulfillments_report/supplier_totals_report.rb index 3029cf19b3..a7a341664c 100644 --- a/lib/open_food_network/orders_and_fulfillments_report/supplier_totals_report.rb +++ b/lib/open_food_network/orders_and_fulfillments_report/supplier_totals_report.rb @@ -44,7 +44,7 @@ module OpenFoodNetwork supplier_name, product_name, line_items_name, - proc { |line_items| line_items.sum(:quantity) }, + proc { |line_items| line_items.to_a.sum(&:quantity) }, proc { |line_items| total_units(line_items) }, proc { |line_items| line_items.first.price }, proc { |line_items| line_items.sum(&:amount) }, From b04a76e8bf4d9ac5339c4ff619cf669f89c44094 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Fri, 27 Nov 2020 12:31:13 +0000 Subject: [PATCH 58/58] Update payments_report totals --- lib/open_food_network/payments_report.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/open_food_network/payments_report.rb b/lib/open_food_network/payments_report.rb index 33bcfadadc..1ee3f0a291 100644 --- a/lib/open_food_network/payments_report.rb +++ b/lib/open_food_network/payments_report.rb @@ -92,26 +92,26 @@ module OpenFoodNetwork [proc { |payments| payments.first.order.payment_state }, proc { |payments| payments.first.order.distributor.name }, proc { |payments| payments.first.payment_method.name }, - proc { |payments| payments.sum(:amount) }] + proc { |payments| payments.sum(&:amount) }] when "itemised_payment_totals" [proc { |orders| orders.first.payment_state }, proc { |orders| orders.first.distributor.name }, - proc { |orders| orders.sum(:item_total) }, + proc { |orders| orders.to_a.sum(&:item_total) }, proc { |orders| orders.sum(&:ship_total) }, proc { |orders| orders.sum(&:outstanding_balance) }, - proc { |orders| orders.sum(:total) }] + proc { |orders| orders.map(&:total).sum }] when "payment_totals" [proc { |orders| orders.first.payment_state }, proc { |orders| orders.first.distributor.name }, - proc { |orders| orders.sum(:item_total) }, + proc { |orders| orders.to_a.sum(&:item_total) }, proc { |orders| orders.sum(&:ship_total) }, - proc { |orders| orders.sum(:total) }, + proc { |orders| orders.map(&:total).sum }, proc { |orders| orders.sum { |o| o.payments.select { |payment| payment.completed? && (payment.payment_method.name.to_s.include? "EFT") - }.sum(:amount) + }.sum(&:amount) } }, proc { |orders| @@ -119,7 +119,7 @@ module OpenFoodNetwork o.payments.select { |payment| payment.completed? && (payment.payment_method.name.to_s.include? "PayPal") - }.sum(:amount) + }.sum(&:amount) } }, proc { |orders| orders.sum(&:outstanding_balance) }] @@ -127,7 +127,7 @@ module OpenFoodNetwork [proc { |payments| payments.first.order.payment_state }, proc { |payments| payments.first.order.distributor.name }, proc { |payments| payments.first.payment_method.name }, - proc { |payments| payments.sum(:amount) }] + proc { |payments| payments.sum(&:amount) }] end end end