diff --git a/.travis.yml b/.travis.yml index 05b96b18f4..c44bb8e257 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,19 +1,15 @@ language: ruby sudo: false rvm: - - 2.3 + - 2.4 services: - - xvfb - mysql - redis-server addons: apt: packages: - libmagic-dev - - qt5-default - - libqt5webkit5-dev - - gstreamer1.0-plugins-base - - gstreamer1.0-tools + chrome: stable env: COVERALLS=1 cache: bundler bundler_args: @@ -24,4 +20,4 @@ before_script: - "mysql -e 'grant all on foodsoft_test.* to travis;'" - 'printf "test:\n adapter: mysql2\n database: foodsoft_test\n username: travis\n encoding: utf8\n" >config/database.yml' - 'bundle exec rake db:schema:load RAILS_ENV=test' -script: xvfb-run -a bundle exec rake rspec-rerun:spec +script: bundle exec rake rspec-rerun:spec diff --git a/Dockerfile b/Dockerfile index 27b6f078bc..ef9bbfff07 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ruby:2.3 +FROM ruby:2.4 RUN supercronicUrl=https://github.com/aptible/supercronic/releases/download/v0.1.3/supercronic-linux-amd64 && \ supercronicBin=/usr/local/bin/supercronic && \ @@ -34,14 +34,14 @@ RUN export DATABASE_URL=mysql2://localhost/temp && \ export SECRET_KEY_BASE=thisisnotimportantnow && \ export DEBIAN_FRONTEND=noninteractive && \ apt-get update && \ - apt-get install -y mysql-server && \ + apt-get install -y mariadb-server && \ /etc/init.d/mysql start && \ cp config/app_config.yml.SAMPLE config/app_config.yml && \ bundle exec rake db:setup assets:precompile && \ rm -Rf config/app_config.yml tmp/* && \ /etc/init.d/mysql stop && \ rm -Rf /run/mysqld /tmp/* /var/tmp/* /var/lib/mysql /var/log/mysql* && \ - apt-get purge -y --auto-remove mysql-server && \ + apt-get purge -y --auto-remove mariadb-server && \ rm -Rf /var/lib/apt/lists/* /var/cache/apt/* # Make relevant dirs writable for app user diff --git a/Dockerfile-dev b/Dockerfile-dev index 7e784e2a33..bdca19d581 100644 --- a/Dockerfile-dev +++ b/Dockerfile-dev @@ -1,7 +1,7 @@ -FROM ruby:2.3 +FROM ruby:2.4 # Install dependencies -RUN deps='libmagic-dev xvfb qt5-default libqt5webkit5-dev gstreamer1.0-plugins-base gstreamer1.0-tools gstreamer1.0-x' && \ +RUN deps='libmagic-dev chromium' && \ apt-get update && \ apt-get install --no-install-recommends -y $deps && \ rm -Rf /var/lib/apt/lists/* /var/cache/apt/* @@ -12,6 +12,9 @@ ENV PORT=3000 \ RAILS_LOG_TO_STDOUT=true \ RAILS_SERVE_STATIC_FILES=true \ \ + CHROMIUM_FLAGS=--no-sandbox \ + DATABASE_CLEANER_ALLOW_REMOTE_DATABASE_URL=true \ + \ BUNDLE_PATH=/home/app/bundle \ BUNDLE_APP_CONFIG=/home/app/bundle/config diff --git a/Gemfile b/Gemfile index 658460955a..45f348f2ad 100644 --- a/Gemfile +++ b/Gemfile @@ -101,7 +101,8 @@ group :test do gem 'factory_bot_rails' gem 'faker' gem 'capybara' - gem 'capybara-webkit' + gem 'puma' # for faster Capybara tests + gem 'apparition' # Capybara javascript driver gem 'database_cleaner' gem 'connection_pool' # need to include rspec components before i18n-spec or rake fails in test environment diff --git a/Gemfile.lock b/Gemfile.lock index bb0abd6bec..71916a1d87 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -51,49 +51,49 @@ PATH GEM remote: https://rubygems.org/ specs: - actionmailer (4.2.11) - actionpack (= 4.2.11) - actionview (= 4.2.11) - activejob (= 4.2.11) + actionmailer (4.2.11.1) + actionpack (= 4.2.11.1) + actionview (= 4.2.11.1) + activejob (= 4.2.11.1) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 1.0, >= 1.0.5) - actionpack (4.2.11) - actionview (= 4.2.11) - activesupport (= 4.2.11) + actionpack (4.2.11.1) + actionview (= 4.2.11.1) + activesupport (= 4.2.11.1) rack (~> 1.6) rack-test (~> 0.6.2) rails-dom-testing (~> 1.0, >= 1.0.5) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (4.2.11) - activesupport (= 4.2.11) + actionview (4.2.11.1) + activesupport (= 4.2.11.1) 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.10.7) - actionpack (>= 4.1, < 6) - activemodel (>= 4.1, < 6) + active_model_serializers (0.10.10) + actionpack (>= 4.1, < 6.1) + activemodel (>= 4.1, < 6.1) case_transform (>= 0.2) jsonapi-renderer (>= 0.1.1.beta1, < 0.3) - activejob (4.2.11) - activesupport (= 4.2.11) + activejob (4.2.11.1) + activesupport (= 4.2.11.1) globalid (>= 0.3.0) - activemodel (4.2.11) - activesupport (= 4.2.11) + activemodel (4.2.11.1) + activesupport (= 4.2.11.1) builder (~> 3.1) - activerecord (4.2.11) - activemodel (= 4.2.11) - activesupport (= 4.2.11) + activerecord (4.2.11.1) + activemodel (= 4.2.11.1) + activesupport (= 4.2.11.1) arel (~> 6.0) - activesupport (4.2.11) + activesupport (4.2.11.1) i18n (~> 0.7) minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) - acts_as_tree (2.8.0) + acts_as_tree (2.9.0) activerecord (>= 3.0.0) - addressable (2.5.2) - public_suffix (>= 2.0.2, < 4.0) + addressable (2.7.0) + public_suffix (>= 2.0.2, < 5.0) apivore (1.6.2) actionpack (>= 4, < 6) hashie (~> 3.3) @@ -101,10 +101,13 @@ GEM rspec (~> 3) rspec-expectations (~> 3.1) rspec-mocks (~> 3.1) + apparition (0.4.0) + capybara (~> 3.13, < 4) + websocket-driver (>= 0.6.5) arel (6.0.4) attribute_normalizer (1.2.0) base32 (0.3.2) - better_errors (2.5.0) + better_errors (2.5.1) coderay (>= 1.0.0) erubi (>= 1.0.0) rack (>= 0.9.0) @@ -113,20 +116,17 @@ GEM bootstrap-datepicker-rails (1.8.0.1) railties (>= 3.0) builder (3.2.3) - bullet (5.7.6) + bullet (6.0.2) activesupport (>= 3.0.0) - uniform_notifier (~> 1.11.0) - callsite (0.0.11) - capybara (2.13.0) + uniform_notifier (~> 1.11) + capybara (3.29.0) addressable - mime-types (>= 1.16) - nokogiri (>= 1.3.3) - rack (>= 1.0.0) - rack-test (>= 0.5.4) - xpath (~> 2.0) - capybara-webkit (1.14.0) - capybara (>= 2.3.0, < 2.14.0) - json + mini_mime (>= 0.1.3) + nokogiri (~> 1.8) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (~> 1.5) + xpath (~> 3.2) case_transform (0.2) activesupport chronic (0.10.2) @@ -139,54 +139,53 @@ GEM execjs coffee-script-source (1.12.2) commonjs (0.2.7) - concurrent-ruby (1.1.4) + concurrent-ruby (1.1.5) connection_pool (2.2.2) content_for_in_controllers (0.0.2) - coveralls (0.8.22) - json (>= 1.8, < 3) - simplecov (~> 0.16.1) - term-ansicolor (~> 1.3) - thor (~> 0.19.4) - tins (~> 1.6) - crass (1.0.4) - daemons (1.2.6) + coveralls (0.7.2) + multi_json (~> 1.3) + rest-client (= 1.6.7) + simplecov (>= 0.7) + term-ansicolor (= 1.2.2) + thor (= 0.18.1) + crass (1.0.5) + daemons (1.3.1) database_cleaner (1.7.0) date_time_attribute (0.1.2) activesupport (>= 3.0.0) debug_inspector (0.0.3) - deface (1.3.2) + deface (1.5.3) nokogiri (>= 1.6) polyglot rails (>= 4.1) rainbow (>= 2.1.0) diff-lcs (1.3) - diffy (3.2.1) - docile (1.3.1) - doorkeeper (5.0.1) + diffy (3.3.0) + docile (1.3.2) + doorkeeper (5.0.2) railties (>= 4.2) - doorkeeper-i18n (4.0.0) + doorkeeper-i18n (5.0.3) email_reply_trimmer (0.1.12) - erubi (1.7.1) + erubi (1.9.0) erubis (2.7.0) eventmachine (1.2.7) - exception_notification (4.2.2) - actionmailer (>= 4.0, < 6) - activesupport (>= 4.0, < 6) + exception_notification (4.4.0) + actionmailer (>= 4.0, < 7) + activesupport (>= 4.0, < 7) execjs (2.7.0) expression_parser (0.9.0) - factory_bot (4.8.2) - activesupport (>= 3.0.0) - factory_bot_rails (4.8.2) - factory_bot (~> 4.8.2) - railties (>= 3.0.0) - faker (1.8.4) - i18n (~> 0.5) - ffi (1.9.25) + factory_bot (5.1.1) + activesupport (>= 4.2.0) + factory_bot_rails (5.1.1) + factory_bot (~> 5.1.0) + railties (>= 4.2.0) + faker (2.2.1) + i18n (>= 0.8) + ffi (1.11.1) gaffe (1.2.0) rails (>= 4.0.0) - globalid (0.4.1) + globalid (0.4.2) activesupport (>= 4.2.0) - grease (0.3.1) haml (4.0.7) tilt haml-rails (1.0.0) @@ -220,14 +219,14 @@ GEM interception (0.5) iso (0.2.2) i18n - jquery-rails (4.3.3) + jquery-rails (4.3.5) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) - json (2.1.0) - json-schema (2.8.0) + json (2.2.0) + json-schema (2.8.1) addressable (>= 2.4) - jsonapi-renderer (0.2.0) + jsonapi-renderer (0.2.2) kaminari (1.1.1) activesupport (>= 4.1.0) kaminari-actionview (= 1.1.1) @@ -242,14 +241,12 @@ GEM kaminari-core (1.1.1) less (2.6.0) commonjs (~> 0.2.7) - less-rails (3.0.0) - actionpack (>= 4.0) - grease + less-rails (4.0.0) + actionpack (>= 4) less (~> 2.6.0) - sprockets (> 2, < 4) - tilt + sprockets (>= 2) libv8 (3.16.14.19) - loofah (2.2.3) + loofah (2.3.1) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.1) @@ -264,22 +261,22 @@ GEM skinny (>= 0.1.2) sqlite3-ruby thin - meta_request (0.6.0) - callsite (~> 0.0, >= 0.0.11) + meta_request (0.7.2) rack-contrib (>= 1.1, < 3) - railties (>= 3.0.0, < 6) - method_source (0.9.0) - midi-smtp-server (2.1.4) - mime-types (3.2.2) + railties (>= 3.0.0, < 7) + method_source (0.9.2) + midi-smtp-server (2.3.1) + mime-types (3.3) mime-types-data (~> 3.2015) - mime-types-data (3.2018.0812) - mini_mime (1.0.1) + mime-types-data (3.2019.1009) + mini_mime (1.0.2) mini_portile2 (2.4.0) - minitest (5.11.3) + minitest (5.12.2) mono_logger (1.1.0) - multi_json (1.13.1) + multi_json (1.14.1) mysql2 (0.4.10) - nokogiri (1.9.1) + nio4r (2.5.2) + nokogiri (1.10.4) mini_portile2 (~> 2.4.0) pdf-core (0.7.0) polyglot (0.3.5) @@ -290,36 +287,38 @@ GEM prawn (>= 1.3.0, < 3.0.0) protected_attributes (1.1.0) activemodel (>= 4.0.1, < 5.0) - pry (0.11.3) + pry (0.12.2) coderay (~> 1.1.0) method_source (~> 0.9.0) - pry-rescue (1.4.5) + pry-rescue (1.5.0) interception (>= 0.5) - pry - pry-stack_explorer (0.4.9.2) + pry (>= 0.12.0) + pry-stack_explorer (0.4.9.3) binding_of_caller (>= 0.7) pry (>= 0.9.11) - public_suffix (3.0.3) + public_suffix (4.0.1) + puma (4.2.1) + nio4r (~> 2.0) quiet_assets (1.1.0) railties (>= 3.1, < 5.0) rack (1.6.11) rack-contrib (1.8.0) rack (~> 1.4) - rack-cors (1.0.2) + rack-cors (1.0.3) rack-protection (1.5.5) rack rack-test (0.6.3) rack (>= 1.0) - rails (4.2.11) - actionmailer (= 4.2.11) - actionpack (= 4.2.11) - actionview (= 4.2.11) - activejob (= 4.2.11) - activemodel (= 4.2.11) - activerecord (= 4.2.11) - activesupport (= 4.2.11) + rails (4.2.11.1) + actionmailer (= 4.2.11.1) + actionpack (= 4.2.11.1) + actionview (= 4.2.11.1) + activejob (= 4.2.11.1) + activemodel (= 4.2.11.1) + activerecord (= 4.2.11.1) + activesupport (= 4.2.11.1) bundler (>= 1.3.0, < 2.0) - railties (= 4.2.11) + railties (= 4.2.11.1) sprockets-rails rails-assets-listjs (0.2.0.beta.4) railties (>= 3.1) @@ -329,8 +328,8 @@ GEM activesupport (>= 4.2.0, < 5.0) nokogiri (~> 1.6) rails-deprecated_sanitizer (>= 1.0.1) - rails-html-sanitizer (1.0.4) - loofah (~> 2.2, >= 2.2.2) + rails-html-sanitizer (1.3.0) + loofah (~> 2.3) rails-i18n (4.0.9) i18n (~> 0.7) railties (~> 4.0) @@ -338,91 +337,90 @@ GEM rails (>= 4.2.0) rails_tokeninput (1.7.0) railties (>= 3.1.0) - railties (4.2.11) - actionpack (= 4.2.11) - activesupport (= 4.2.11) + railties (4.2.11.1) + actionpack (= 4.2.11.1) + activesupport (= 4.2.11.1) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rainbow (3.0.0) - rake (12.3.2) - ransack (1.8.9) - actionpack (>= 3.0, <= 5.1.1) - activerecord (>= 3.0, <= 5.1.1) - activesupport (>= 3.0, <= 5.1.1) + rake (13.0.0) + ransack (1.8.10) + actionpack (>= 3.0, < 5.2) + activerecord (>= 3.0, < 5.2) + activesupport (>= 3.0, < 5.2) i18n - rb-fsevent (0.10.3) - rb-inotify (0.9.10) - ffi (>= 0.5.0, < 2) recurring_select (2.1.0) coffee-rails (>= 3.1) ice_cube (>= 0.11) jquery-rails (>= 3.0) rails (>= 3.2) sass-rails (>= 4.0) - redis (4.1.0) + redis (4.1.3) redis-namespace (1.6.0) redis (>= 3.0.4) ref (2.0.0) - responders (2.4.0) - actionpack (>= 4.2.0, < 5.3) - railties (>= 4.2.0, < 5.3) + regexp_parser (1.6.0) + responders (2.4.1) + actionpack (>= 4.2.0, < 6.0) + railties (>= 4.2.0, < 6.0) resque (2.0.0) mono_logger (~> 1.0) multi_json (~> 1.0) redis-namespace (~> 1.6) sinatra (>= 0.9.2) vegas (~> 0.1.2) - roo (2.7.1) + rest-client (1.6.7) + mime-types (>= 1.16) + roo (2.8.2) nokogiri (~> 1) - rubyzip (~> 1.1, < 2.0.0) + rubyzip (>= 1.2.1, < 2.0.0) roo-xls (1.2.0) nokogiri roo (>= 2.0.0, < 3) spreadsheet (> 0.9.0) - rspec (3.8.0) - rspec-core (~> 3.8.0) - rspec-expectations (~> 3.8.0) - rspec-mocks (~> 3.8.0) - rspec-core (3.8.0) - rspec-support (~> 3.8.0) - rspec-expectations (3.8.2) + rspec (3.9.0) + rspec-core (~> 3.9.0) + rspec-expectations (~> 3.9.0) + rspec-mocks (~> 3.9.0) + rspec-core (3.9.0) + rspec-support (~> 3.9.0) + rspec-expectations (3.9.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.8.0) - rspec-mocks (3.8.0) + rspec-support (~> 3.9.0) + rspec-mocks (3.9.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.8.0) - rspec-rails (3.8.0) + rspec-support (~> 3.9.0) + rspec-rails (3.9.0) actionpack (>= 3.0) activesupport (>= 3.0) railties (>= 3.0) - rspec-core (~> 3.8.0) - rspec-expectations (~> 3.8.0) - rspec-mocks (~> 3.8.0) - rspec-support (~> 3.8.0) + rspec-core (~> 3.9.0) + rspec-expectations (~> 3.9.0) + rspec-mocks (~> 3.9.0) + rspec-support (~> 3.9.0) rspec-rerun (1.1.0) rspec (~> 3.0) - rspec-support (3.8.0) + rspec-support (3.9.0) ruby-filemagic (0.7.2) - ruby-ole (1.2.12.1) - ruby-prof (0.17.0) + ruby-ole (1.2.12.2) + ruby-prof (1.0.0) ruby-units (2.3.1) - ruby_parser (3.11.0) + ruby_parser (3.14.0) sexp_processor (~> 4.9) - rubyzip (1.2.2) - sass (3.6.0) - sass-listen (~> 4.0.0) - sass-listen (4.0.0) - rb-fsevent (~> 0.9, >= 0.9.4) - rb-inotify (~> 0.9, >= 0.9.7) - sass-rails (5.0.7) - railties (>= 4.0.0, < 6) - sass (~> 3.1) - sprockets (>= 2.8, < 4.0) - sprockets-rails (>= 2.0, < 4.0) - tilt (>= 1.1, < 3) + rubyzip (1.3.0) + sass-rails (6.0.0) + sassc-rails (~> 2.1, >= 2.1.1) + sassc (2.2.1) + ffi (~> 1.9) + sassc-rails (2.1.2) + railties (>= 4.0.0) + sassc (>= 2.0) + sprockets (> 3.0) + sprockets-rails + tilt select2-rails (4.0.3) thor (~> 0.14) - sexp_processor (4.11.0) + sexp_processor (4.13.0) simple-navigation (3.14.0) activesupport (>= 2.3.2) simple-navigation-bootstrap (1.0.2) @@ -431,7 +429,7 @@ GEM simple_form (4.0.0) actionpack (> 4) activemodel (> 4) - simplecov (0.16.1) + simplecov (0.17.1) docile (~> 1.1) json (>= 1.8, < 3) simplecov-html (~> 0.10.0) @@ -443,7 +441,7 @@ GEM skinny (0.2.2) eventmachine (~> 1.0) thin - spreadsheet (1.1.8) + spreadsheet (1.2.5) ruby-ole (>= 1.0) sprockets (3.7.2) concurrent-ruby (~> 1.0) @@ -452,11 +450,11 @@ GEM actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) - sqlite3 (1.3.13) + sqlite3 (1.4.1) sqlite3-ruby (1.3.3) sqlite3 (>= 1.3.3) - term-ansicolor (1.6.0) - tins (~> 1.0) + term-ansicolor (1.2.2) + tins (~> 0.8) therubyracer (0.12.3) libv8 (~> 3.16.14.15) ref @@ -464,10 +462,10 @@ GEM daemons (~> 1.0, >= 1.0.9) eventmachine (~> 1.0, >= 1.0.4) rack (>= 1, < 3) - thor (0.19.4) + thor (0.18.1) thread_safe (0.3.6) - tilt (2.0.9) - tins (1.16.3) + tilt (2.0.10) + tins (0.13.2) ttfunk (1.5.1) twitter-bootstrap-rails (2.2.8) actionpack (>= 3.1) @@ -478,12 +476,12 @@ GEM unf (~> 0.1.0) tzinfo (1.2.5) thread_safe (~> 0.1) - uglifier (4.1.19) + uglifier (4.2.0) execjs (>= 0.3.0, < 3) unf (0.1.4) unf_ext - unf_ext (0.0.7.5) - uniform_notifier (1.11.0) + unf_ext (0.0.7.6) + uniform_notifier (1.13.0) vegas (0.1.11) rack (>= 1.0.0) web-console (2.3.0) @@ -491,7 +489,10 @@ GEM binding_of_caller (>= 0.7.2) railties (>= 4.0) sprockets-rails (>= 2.0, < 4.0) - whenever (0.10.0) + websocket-driver (0.7.1) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.4) + whenever (1.0.0) chronic (>= 0.6.3) wikicloth (0.8.3) builder @@ -499,8 +500,8 @@ GEM htmlentities nokogiri twitter-text - xpath (2.1.0) - nokogiri (~> 1.3) + xpath (3.2.0) + nokogiri (~> 1.8) PLATFORMS ruby @@ -510,13 +511,13 @@ DEPENDENCIES acts_as_tree acts_as_versioned! apivore + apparition attribute_normalizer better_errors binding_of_caller bootstrap-datepicker-rails bullet capybara - capybara-webkit connection_pool coveralls daemons @@ -553,6 +554,7 @@ DEPENDENCIES protected_attributes (= 1.1.0) pry-rescue pry-stack_explorer + puma quiet_assets rack-cors rails (~> 4.2) diff --git a/app/views/articles/index.html.haml b/app/views/articles/index.html.haml index 8e9bef3c27..7c42276b76 100644 --- a/app/views/articles/index.html.haml +++ b/app/views/articles/index.html.haml @@ -53,9 +53,9 @@ - content_for :javascript do :javascript // keep import button pressed when import section is shown - $(document).on('touchclick', 'a[data-toggle-this=#import]', function() { + $(document).on('touchclick', 'a[data-toggle-this="#import"]', function() { var state = $('#import').is(':visible'); - $('.btn-toolbar a[data-toggle-this=#import]').toggleClass('active', !state); + $('.btn-toolbar a[data-toggle-this="#import"]').toggleClass('active', !state); if (!state) { // also load articles when shown $('#import form').submit(); diff --git a/bin/test b/bin/test index f6746a0c05..cfffaa9b56 100755 --- a/bin/test +++ b/bin/test @@ -5,13 +5,5 @@ unset DATABASE_URL; export DATABASE_URL [ "$TEST_DATABASE_URL" ] && export DATABASE_URL="$TEST_DATABASE_URL" export RAILS_ENV=test -# Start virtuals X environment to allow integration testing via firefox/iceweasel -export DISPLAY=:99 -Xvfb $DISPLAY -nolisten tcp & -XVFB_PID=$! - # Start tests bundle exec rspec $@ - -# Cleanup -kill $XVFB_PID diff --git a/doc/SETUP_DEVELOPMENT.md b/doc/SETUP_DEVELOPMENT.md index f73518fa24..85a7ff15b3 100644 --- a/doc/SETUP_DEVELOPMENT.md +++ b/doc/SETUP_DEVELOPMENT.md @@ -29,13 +29,13 @@ If instead you just want to run Foodsoft without changing its code, please refer unfinished parts. If you want to be safe, choose the last release: `git checkout $(git tag -l | grep ^v | sort -rn | head -n1)` -1. Install RVM and Ruby 2+ (if you have not done so before): +1. Install RVM and Ruby 2.4+ (if you have not done so before): \curl -L https://get.rvm.io | bash source ~/.rvm/scripts/rvm - rvm install 2.3 + rvm install 2.4 - We try to keep Foodsoft compatible with Ruby 2.3 as well as any later versions, + We try to keep Foodsoft compatible with Ruby 2.4 as well as any later versions, so if you use this and don't want to use RVM, that might actually work. 2. Install system dependencies. @@ -47,11 +47,10 @@ If instead you just want to run Foodsoft without changing its code, please refer [libxslt1-dev](https://packages.debian.org/stable/libxslt1-dev) [libffi-dev](https://packages.debian.org/stable/libffi-dev) [libreadline-dev](https://packages.debian.org/stable/libreadline-dev) - [libmagic-dev](https://packages.debian.org/stable/libmagic-dev) - [libqtwebkit-dev](https://packages.debian.org/stable/libqtwebkit-dev): + [libmagic-dev](https://packages.debian.org/stable/libmagic-dev): # Debian/Ubuntu - sudo apt-get install libv8-dev libmysqlclient-dev libxml2-dev libxslt1-dev libffi-dev libreadline-dev libmagic-dev libqtwebkit-dev + sudo apt-get install libv8-dev libmysqlclient-dev libxml2-dev libxslt1-dev libffi-dev libreadline-dev libmagic-dev For CentOS/Redhat you need [v8](https://apps.fedoraproject.org/packages/v8) @@ -60,11 +59,10 @@ If instead you just want to run Foodsoft without changing its code, please refer [libxslt-devel](https://apps.fedoraproject.org/packages/libxslt-devel) [libffi-devel](https://apps.fedoraproject.org/packages/libffi-devel) [readline-devel](https://apps.fedoraproject.org/packages/readline-devel) - [file-devel](https://apps.fedoraproject.org/packages/file-devel) - [qtwebkit-devel](https://apps.fedoraproject.org/packages/qtwebkit-devel): + [file-devel](https://apps.fedoraproject.org/packages/file-devel): # CentOS/Redhat - sudo yum install v8 community-mysql-devel libxml2-devel libxslt-devel libffi-devel readline-devel file-devel qtwebkit-devel + sudo yum install v8 community-mysql-devel libxml2-devel libxslt-devel libffi-devel readline-devel file-devel 3. Install Ruby dependencies: @@ -99,6 +97,9 @@ If instead you just want to run Foodsoft without changing its code, please refer 9. Have phun! +For running integration tests, you also need the Chromium/Chrome web browser. +On Debian that would be `sudo apt-get install chromium chromium-sandbox`, on Ubuntu +`sudo apt-get install chromium-browser`. ### Manual configuration diff --git a/doc/SETUP_DEVELOPMENT_DOCKER.md b/doc/SETUP_DEVELOPMENT_DOCKER.md index cbfce496cf..2dd1d0aec8 100644 --- a/doc/SETUP_DEVELOPMENT_DOCKER.md +++ b/doc/SETUP_DEVELOPMENT_DOCKER.md @@ -57,7 +57,7 @@ Open a rails console Setup the test database - docker-compose-dev run --rm foodsoft bundle exec rake db:setup RAILS_ENV=test DATABASE_URL=mysql2://root:secret@mariadb/test + docker-compose-dev run --rm foodsoft bundle exec rake db:setup RAILS_ENV=test DATABASE_URL=mysql2://root:secret@mariadb/test?encoding=utf8 Run the tests diff --git a/spec/factories/article.rb b/spec/factories/article.rb index e37ca71387..6cf16e311b 100644 --- a/spec/factories/article.rb +++ b/spec/factories/article.rb @@ -10,20 +10,20 @@ unit_quantity { rand(5) < 3 ? 1 : rand(1..20) } factory :article do - sequence(:name) { |n| Faker::Lorem.words(rand(2..4)).join(' ') + " ##{n}" } + sequence(:name) { |n| Faker::Lorem.words(number: rand(2..4)).join(' ') + " ##{n}" } supplier { create :supplier } article_category { create :article_category } end factory :shared_article, class: SharedArticle do - sequence(:name) { |n| Faker::Lorem.words(rand(2..4)).join(' ') + " s##{n}" } - order_number { Faker::Lorem.characters(rand(1..12)) } + sequence(:name) { |n| Faker::Lorem.words(number: rand(2..4)).join(' ') + " s##{n}" } + order_number { Faker::Lorem.characters(number: rand(1..12)) } supplier { create :shared_supplier } end end factory :article_category do - sequence(:name) { |n| Faker::Lorem.characters(rand(2..12)) + " ##{n}" } + sequence(:name) { |n| Faker::Lorem.characters(number: rand(2..12)) + " ##{n}" } end end diff --git a/spec/factories/doorkeeper.rb b/spec/factories/doorkeeper.rb index 8fd1a48459..8880d979c4 100644 --- a/spec/factories/doorkeeper.rb +++ b/spec/factories/doorkeeper.rb @@ -5,7 +5,7 @@ factory :oauth2_application, class: Doorkeeper::Application do name { Faker::App.name } - redirect_uri 'https://example.com:1234/app' + redirect_uri { 'https://example.com:1234/app' } end factory :oauth2_access_token, class: Doorkeeper::AccessToken do diff --git a/spec/factories/financial_transaction_type.rb b/spec/factories/financial_transaction_type.rb index 45882ff293..3f4a5543ba 100644 --- a/spec/factories/financial_transaction_type.rb +++ b/spec/factories/financial_transaction_type.rb @@ -3,12 +3,12 @@ FactoryBot.define do factory :financial_transaction_class do - sequence(:name) { |n| Faker::Lorem.characters(rand(2..12)) + " ##{n}" } + sequence(:name) { |n| Faker::Lorem.characters(number: rand(2..12)) + " ##{n}" } end factory :financial_transaction_type do financial_transaction_class - sequence(:name) { |n| Faker::Lorem.words(rand(2..4)).join(' ') + " ##{n}" } + sequence(:name) { |n| Faker::Lorem.words(number: rand(2..4)).join(' ') + " ##{n}" } end end diff --git a/spec/factories/order.rb b/spec/factories/order.rb index 1b63744dc6..64d15f7519 100644 --- a/spec/factories/order.rb +++ b/spec/factories/order.rb @@ -8,12 +8,12 @@ article_ids { supplier.articles.map(&:id) unless supplier.nil? } transient do - article_count true + article_count { true } end # for an order from stock; need to add articles factory :stock_order do - supplier_id 0 + supplier_id { 0 } # article_ids needs to be supplied end diff --git a/spec/factories/supplier.rb b/spec/factories/supplier.rb index 27b4f41466..290fbb69a2 100644 --- a/spec/factories/supplier.rb +++ b/spec/factories/supplier.rb @@ -8,7 +8,7 @@ address { Faker::Address.street_address } transient do - article_count 0 + article_count { 0 } end after :create do |supplier, evaluator| diff --git a/spec/factories/user.rb b/spec/factories/user.rb index c4bcb6a2ec..2a83f64e5b 100644 --- a/spec/factories/user.rb +++ b/spec/factories/user.rb @@ -10,7 +10,7 @@ factory :admin do sequence(:nick) { |n| "admin#{n}" } - first_name 'Administrator' + first_name { 'Administrator' } after :create do |user, evaluator| create :workgroup, role_admin: true, user_ids: [user.id] end @@ -35,11 +35,11 @@ sequence(:name) {|n| "Group ##{n}"} factory :workgroup do - type '' + type { '' } end factory :ordergroup do - type 'Ordergroup' + type { 'Ordergroup' } sequence(:name) {|n| "Order group ##{n}"} # workaround to avoid needing to save the ordergroup # avoids e.g. error after logging in related to applebar diff --git a/spec/integration/balancing_spec.rb b/spec/integration/balancing_spec.rb index 55434622c9..6fc1966aa5 100644 --- a/spec/integration/balancing_spec.rb +++ b/spec/integration/balancing_spec.rb @@ -53,7 +53,9 @@ it 'keeps ordered quantities when article is deleted from resulting order' do within("#order_article_#{oa.id}") do - click_link I18n.t('ui.delete') + accept_confirm do + click_link I18n.t('ui.delete') + end end expect(page).to_not have_selector("#order_article_#{oa.id}") expect(OrderArticle.exists?(oa.id)).to be true @@ -69,7 +71,9 @@ goa1.destroy goa2.destroy within("#order_article_#{oa.id}") do - click_link I18n.t('ui.delete') + accept_confirm do + click_link I18n.t('ui.delete') + end end expect(page).to_not have_selector("#order_article_#{oa.id}") expect(OrderArticle.exists?(oa.id)).to be false @@ -107,10 +111,10 @@ click_link I18n.t('ui.edit') end within("#edit_order_article_#{oa.id}") do - fill_in :order_article_units_to_order, :with => 0 + find('#order_article_units_to_order').set(0) + sleep 0.2 find('input[type="submit"]').click end - sleep 0.5 # workaround "javascript error" "e is null" expect(page).to have_selector("#order_article_#{oa.id}") # make sure it still works after reloading visit new_finance_order_path(order_id: order.id) @@ -129,7 +133,8 @@ expect(page).to have_selector('form#new_group_order_article') within('#new_group_order_article') do select user.ordergroup.name, :from => 'group_order_article_ordergroup_id' - fill_in 'group_order_article_result', :with => 8 + find('#group_order_article_result').set(8) + sleep 0.2 find('input[type="submit"]').click end expect(page).to_not have_selector('form#new_group_order_article') @@ -144,7 +149,7 @@ it 'can modify an ordergroup result' do click_link article.name within("#group_order_articles_#{oa.id}") do - fill_in "r_#{goa1.id}", :with => 5 + find("#r_#{goa1.id}").set(5).send_keys(:tab) # tab to blur and let js update end expect(page).to have_selector('#summaryChangedWarning') # becomes visible after request is done expect(goa1.reload.result).to eq 5 @@ -167,8 +172,10 @@ click_link I18n.t('finance.balancing.edit_results_by_articles.add_article') expect(page).to have_selector('form#new_order_article') within('#new_order_article') do - select new_article.name, :from => 'order_article_article_id' + find('#order_article_article_id').select(new_article.name) + sleep 0.1 find('input[type="submit"]').click + sleep 0.1 end expect(page).to_not have_selector('form#new_order_article') expect(page).to have_content(new_article.name) diff --git a/spec/integration/config_spec.rb b/spec/integration/config_spec.rb index 8a9b043cef..125b592048 100644 --- a/spec/integration/config_spec.rb +++ b/spec/integration/config_spec.rb @@ -1,7 +1,7 @@ require_relative '../spec_helper' feature 'admin/configs' do - let(:name) { Faker::Lorem.words(rand(2..4)).join(' ') } + let(:name) { Faker::Lorem.words(number: rand(2..4)).join(' ') } let(:email) { Faker::Internet.email } let(:admin) { create :admin } diff --git a/spec/integration/order_spec.rb b/spec/integration/order_spec.rb index bf7aa90336..2c8df500e2 100644 --- a/spec/integration/order_spec.rb +++ b/spec/integration/order_spec.rb @@ -50,7 +50,9 @@ def setup_and_close_order oa.update_results! # and close the order visit orders_path - click_link_or_button I18n.t('orders.index.action_end') + accept_confirm do + click_link_or_button I18n.t('orders.index.action_end') + end expect(page).to have_selector('.alert-success') order.reload oa.reload diff --git a/spec/lib/foodsoft_config_spec.rb b/spec/lib/foodsoft_config_spec.rb index 20ab28f5be..668800e75f 100644 --- a/spec/lib/foodsoft_config_spec.rb +++ b/spec/lib/foodsoft_config_spec.rb @@ -1,8 +1,8 @@ require_relative '../spec_helper' describe FoodsoftConfig do - let(:name) { Faker::Lorem.words(rand(2..4)).join(' ') } - let(:other_name) { Faker::Lorem.words(rand(2..4)).join(' ') } + let(:name) { Faker::Lorem.words(number: rand(2..4)).join(' ') } + let(:other_name) { Faker::Lorem.words(number: rand(2..4)).join(' ') } it 'returns a default value' do expect(FoodsoftConfig[:protected][:database]).to be true diff --git a/spec/lib/foodsoft_mail_receiver_spec.rb b/spec/lib/foodsoft_mail_receiver_spec.rb index fea00b581b..5901009e5e 100644 --- a/spec/lib/foodsoft_mail_receiver_spec.rb +++ b/spec/lib/foodsoft_mail_receiver_spec.rb @@ -3,7 +3,7 @@ describe FoodsoftMailReceiver do before :all do - @server = FoodsoftMailReceiver.new 0 + @server = FoodsoftMailReceiver.new 2525, '127.0.0.1', 4, logger_severity: 5 @server.start end @@ -42,7 +42,7 @@ it 'does not accept invalid addresses via SMTP' do expect { - Net::SMTP.start(@server.host, @server.port) do |smtp| + Net::SMTP.start(@server.hosts.first, @server.ports.first) do |smtp| smtp.send_message 'body', 'from@example.com', 'invalid' end }.to raise_error(Net::SMTPFatalError) @@ -50,7 +50,7 @@ it 'does not accept invalid addresses via SMTP' do expect { - Net::SMTP.start(@server.host, @server.port) do |smtp| + Net::SMTP.start(@server.hosts.first, @server.ports.first) do |smtp| smtp.send_message 'body', 'from@example.com', 'invalid' end }.to raise_error(Net::SMTPFatalError) diff --git a/spec/lib/token_verifier_spec.rb b/spec/lib/token_verifier_spec.rb index d398a140e4..e3e4568ef6 100644 --- a/spec/lib/token_verifier_spec.rb +++ b/spec/lib/token_verifier_spec.rb @@ -23,7 +23,7 @@ msg oldscope = FoodsoftConfig.scope begin - FoodsoftConfig.scope = Faker::Lorem.words(1) + FoodsoftConfig.scope = Faker::Lorem.words(number: 1) v2 = TokenVerifier.new(prefix) expect{ v2.verify(msg) }.to raise_error(TokenVerifier::InvalidScope) ensure @@ -32,7 +32,7 @@ end it 'does not validate a random string' do - expect{ v.verify(Faker::Lorem.characters(100)) }.to raise_error(ActiveSupport::MessageVerifier::InvalidSignature) + expect{ v.verify(Faker::Lorem.characters(number: 100)) }.to raise_error(ActiveSupport::MessageVerifier::InvalidSignature) end it 'returns the message' do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 016ce61eb9..fe954f1c41 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -5,8 +5,10 @@ require File.expand_path("../../config/environment", __FILE__) require 'rspec/rails' require 'capybara/rails' +require 'capybara/apparition' -Capybara.javascript_driver = :webkit +Capybara.server = :puma, { Silent: true } +Capybara.javascript_driver = :apparition # Requires supporting ruby files with custom matchers and macros, etc, # in spec/support/ and its subdirectories.