mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-08 22:56:06 +00:00
Merge pull request #6354 from openfoodfoundation/rails-4-2-rebased
Rails 4.2 upgrade
This commit is contained in:
14
Gemfile
14
Gemfile
@@ -2,13 +2,14 @@ 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"
|
||||
gem 'responders', '~> 2.0'
|
||||
|
||||
gem "catalog", path: "./engines/catalog"
|
||||
gem 'dfc_provider', path: './engines/dfc_provider'
|
||||
@@ -23,11 +24,11 @@ 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'
|
||||
gem 'state_machines-activerecord'
|
||||
gem 'stringex', '~> 1.5.1'
|
||||
|
||||
gem 'spree_i18n', github: 'openfoodfoundation/spree_i18n', branch: '1-3-stable'
|
||||
@@ -90,7 +91,6 @@ gem 'combine_pdf'
|
||||
gem 'wicked_pdf'
|
||||
gem 'wkhtmltopdf-binary'
|
||||
|
||||
gem 'foreigner'
|
||||
gem 'immigrant'
|
||||
gem 'roo', '~> 2.8.3'
|
||||
|
||||
|
||||
232
Gemfile.lock
232
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)
|
||||
@@ -371,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)
|
||||
@@ -384,8 +397,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 +408,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 +443,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 +457,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 +475,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 +505,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 +515,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 +551,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 +562,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 +644,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)
|
||||
@@ -628,9 +667,15 @@ 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.25.0)
|
||||
stripe (5.28.0)
|
||||
temple (0.8.2)
|
||||
test-prof (0.7.5)
|
||||
test-unit (3.3.6)
|
||||
@@ -643,6 +688,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 +718,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
|
||||
@@ -718,7 +766,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)
|
||||
@@ -726,20 +773,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,11 +801,12 @@ 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
|
||||
responders (~> 2.0)
|
||||
roadie-rails (~> 1.3.0)
|
||||
roo (~> 2.8.3)
|
||||
rspec-rails (>= 3.5.2)
|
||||
@@ -776,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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
@@ -319,6 +320,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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -5,11 +5,11 @@ require "spree/core/controller_helpers/ssl"
|
||||
module Api
|
||||
class BaseController < ActionController::Metal
|
||||
include ActionController::StrongParameters
|
||||
include ActionController::RespondWith
|
||||
include Spree::Api::ControllerSetup
|
||||
include Spree::Core::ControllerHelpers::SSL
|
||||
include ::ActionController::Head
|
||||
|
||||
respond_to :json
|
||||
include ::ActionController::ConditionalGet
|
||||
|
||||
attr_accessor :current_api_user
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
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
|
||||
@@ -10,6 +16,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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.map(&:amount).sum
|
||||
)
|
||||
end
|
||||
|
||||
adjustments
|
||||
@@ -26,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)
|
||||
@@ -34,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)
|
||||
|
||||
@@ -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{</h[^>]>|</p>|</div>}, "\\1\n\n").
|
||||
andand.gsub(/<br[^>]*>/, "\\1\n")
|
||||
end
|
||||
|
||||
def strip_surrounding_whitespace(html)
|
||||
html.andand.strip
|
||||
end
|
||||
end
|
||||
25
app/jobs/bulk_invoice_job.rb
Normal file
25
app/jobs/bulk_invoice_job.rb
Normal file
@@ -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
|
||||
@@ -1,5 +1,7 @@
|
||||
ConfirmOrderJob = Struct.new(:order_id) do
|
||||
def perform
|
||||
# frozen_string_literal: true
|
||||
|
||||
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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# 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
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
WelcomeEnterpriseJob = Struct.new(:enterprise_id) do
|
||||
def perform
|
||||
# frozen_string_literal: true
|
||||
|
||||
class WelcomeEnterpriseJob < ActiveJob::Base
|
||||
def perform(enterprise_id)
|
||||
enterprise = Enterprise.find enterprise_id
|
||||
EnterpriseMailer.welcome(enterprise).deliver
|
||||
end
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
module Spree
|
||||
class OrderMailer < BaseMailer
|
||||
helper HtmlHelper
|
||||
helper ::CheckoutHelper
|
||||
helper SpreeCurrencyHelper
|
||||
helper Spree::Admin::PaymentsHelper
|
||||
|
||||
@@ -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|
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -61,6 +61,8 @@ module Spree
|
||||
end
|
||||
|
||||
def delete(key)
|
||||
return if key.nil?
|
||||
|
||||
@cache.delete(key)
|
||||
destroy(key)
|
||||
end
|
||||
|
||||
@@ -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
|
||||
@@ -101,7 +103,7 @@ module Spree
|
||||
end
|
||||
|
||||
def send_signup_confirmation
|
||||
Delayed::Job.enqueue ConfirmSignupJob.new(id)
|
||||
ConfirmSignupJob.perform_later(id)
|
||||
end
|
||||
|
||||
def associate_customers
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
16
app/services/permitted_attributes/tag_rules.rb
Normal file
16
app/services/permitted_attributes/tag_rules.rb
Normal file
@@ -0,0 +1,16 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module PermittedAttributes
|
||||
class TagRules
|
||||
def self.attributes
|
||||
[
|
||||
: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
|
||||
end
|
||||
end
|
||||
@@ -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
|
||||
|
||||
@@ -199,5 +199,9 @@ 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
|
||||
|
||||
config.active_record.raise_in_transactional_callbacks = true
|
||||
end
|
||||
end
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
15
config/initializers/paranoia.rb
Normal file
15
config/initializers/paranoia.rb
Normal file
@@ -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 unless self.class.connection.current_transaction.closed?
|
||||
update_columns(paranoia_destroy_attributes)
|
||||
elsif !frozen?
|
||||
assign_attributes(paranoia_destroy_attributes)
|
||||
end
|
||||
self
|
||||
end
|
||||
alias_method :delete, :paranoia_delete
|
||||
end
|
||||
@@ -1,11 +0,0 @@
|
||||
module StateMachine
|
||||
module Integrations
|
||||
module ActiveModel
|
||||
public :around_validation
|
||||
end
|
||||
|
||||
module ActiveRecord
|
||||
public :around_save
|
||||
end
|
||||
end
|
||||
end
|
||||
1185
db/schema.rb
1185
db/schema.rb
File diff suppressed because it is too large
Load Diff
@@ -101,10 +101,9 @@ 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
|
||||
end
|
||||
|
||||
def to_shipment
|
||||
|
||||
@@ -112,6 +112,13 @@ module OrderManagement
|
||||
|
||||
expect(shipment.shipping_method).to eq shipping_method
|
||||
end
|
||||
|
||||
describe "#inpsect" do
|
||||
it "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
|
||||
|
||||
@@ -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.update(unit_value: 100) }
|
||||
|
||||
it 'builds a package with all the items' do
|
||||
package = subject.package
|
||||
|
||||
6
lib/application_responder.rb
Normal file
6
lib/application_responder.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ApplicationResponder < ActionController::Responder
|
||||
include Responders::FlashResponder
|
||||
include Responders::HttpCacheResponder
|
||||
end
|
||||
@@ -60,7 +60,11 @@ 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
|
||||
.positive?
|
||||
end
|
||||
else
|
||||
orders
|
||||
|
||||
@@ -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| "" },
|
||||
|
||||
@@ -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) }
|
||||
|
||||
@@ -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) },
|
||||
|
||||
@@ -92,28 +92,42 @@ 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.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.map(&:total).sum },
|
||||
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 },
|
||||
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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -10,7 +10,7 @@ require 'mail'
|
||||
require 'paperclip'
|
||||
require 'paranoia'
|
||||
require 'ransack'
|
||||
require 'state_machine'
|
||||
require 'state_machines'
|
||||
|
||||
module Spree
|
||||
mattr_accessor :user_class
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -21,23 +21,23 @@ 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
|
||||
|
||||
@@ -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,9 @@ 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
|
||||
|
||||
expect(enqueued_jobs.last.to_s).to match "reset_password_instructions"
|
||||
end
|
||||
|
||||
context "user with unconfirmed email" do
|
||||
|
||||
@@ -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('<p><b>Hello</b> <em>world</em>!</p>')).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("<h1>foo</h1>bar")).to eq("foo\n\nbar");
|
||||
expect(helper.strip_html("<h2>foo</h2>bar")).to eq("foo\n\nbar");
|
||||
end
|
||||
|
||||
it "adds two line breaks after p tags" do
|
||||
expect(helper.strip_html("<p>foo</p>bar")).to eq("foo\n\nbar");
|
||||
end
|
||||
|
||||
it "adds two line breaks after div tags" do
|
||||
expect(helper.strip_html("<div>foo</div>bar")).to eq("foo\n\nbar");
|
||||
end
|
||||
|
||||
it "adds a line break after br tags" do
|
||||
expect(helper.strip_html("foo<br>bar")).to eq("foo\nbar");
|
||||
expect(helper.strip_html("foo<br/>bar")).to eq("foo\nbar");
|
||||
expect(helper.strip_html("foo<br />bar")).to eq("foo\nbar");
|
||||
end
|
||||
|
||||
it "strips line breaks at the end of the string" do
|
||||
expect(helper.strip_html("<div>foo</div><br />")).to eq("foo");
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -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("<a class=\"remove_fields icon_link with-tip icon-trash\" data-action=\"remove\" href=\"#\" title=\"Remove\"><span class='text'>Hola</span></a><input type="hidden" name="_method" value="destroy">")
|
||||
expect(subject).to eq("<a class=\"remove_fields icon_link with-tip icon-trash\" data-action=\"remove\" title=\"Remove\" href=\"#\"><span class='text'>Hola</span></a><input type="hidden" name="_method" value="destroy">")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,8 @@ 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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe BulkInvoiceService do
|
||||
include ActiveJob::TestHelper
|
||||
|
||||
let(:service) { BulkInvoiceService.new }
|
||||
|
||||
describe "#start_pdf_job" 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
|
||||
@@ -17,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
|
||||
@@ -65,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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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(
|
||||
@@ -193,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'
|
||||
|
||||
Reference in New Issue
Block a user