diff --git a/.github/workflows/next-rails.yml b/.github/workflows/next-rails.yml index 5f31a6eb..31086e9d 100644 --- a/.github/workflows/next-rails.yml +++ b/.github/workflows/next-rails.yml @@ -26,7 +26,7 @@ jobs: echo "BUNDLE_CACHE_PATH=vendor/cache.next" >> $GITHUB_ENV - uses: ruby/setup-ruby@v1 with: - ruby-version: 3.1.0 + ruby-version: 3.1.2 bundler-cache: true - name: Prepare spec run: | diff --git a/.github/workflows/spec.yml b/.github/workflows/spec.yml index d1a27a3a..cb13886c 100644 --- a/.github/workflows/spec.yml +++ b/.github/workflows/spec.yml @@ -16,7 +16,7 @@ jobs: - uses: actions/checkout@v2 - uses: ruby/setup-ruby@v1 with: - ruby-version: 3.1.0 + ruby-version: 3.1.2 bundler-cache: true - run: bundle exec rubocop - run: bundle exec haml-lint app/views @@ -34,7 +34,7 @@ jobs: - uses: actions/checkout@v2 - uses: ruby/setup-ruby@v1 with: - ruby-version: 3.1.0 + ruby-version: 3.1.2 bundler-cache: true - name: Prepare spec run: | diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 0d9a6f13..b4637d3e 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -426,7 +426,7 @@ Lint/UriRegexp: # Offense count: 127 # Configuration parameters: IgnoredMethods, CountRepeatedAttributes. Metrics/AbcSize: - Max: 71 + Max: 72 # Offense count: 313 # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods. @@ -457,7 +457,7 @@ Metrics/MethodLength: # Offense count: 5 # Configuration parameters: CountComments, CountAsOne. Metrics/ModuleLength: - Max: 173 + Max: 174 # Offense count: 26 # Configuration parameters: IgnoredMethods. diff --git a/.ruby-version b/.ruby-version index fd2a0186..ef538c28 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.1.0 +3.1.2 diff --git a/Dockerfile b/Dockerfile index 276b87a2..4097d60e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,5 @@ FROM registry.opensuse.org/opensuse/infrastructure/dale/containers/osem/base:latest ARG CONTAINER_USERID -ENV NOKOGIRI_USE_SYSTEM_LIBRARIES=1 # Configure our user RUN usermod -u $CONTAINER_USERID osem @@ -14,8 +13,8 @@ COPY Gemfile.lock /osem/ RUN chown -R osem /osem # Install bundler & foreman -RUN gem.ruby3.1 install bundler -v "$(grep -A 1 "BUNDLED WITH" /osem/Gemfile.lock | tail -n 1)"; \ - gem.ruby3.1 install foreman +RUN gem install bundler -v "$(grep -A 1 "BUNDLED WITH" /osem/Gemfile.lock | tail -n 1)"; \ + gem install foreman # Continue as user USER osem diff --git a/Dockerfile.production b/Dockerfile.production index adb84a19..8192c8f0 100644 --- a/Dockerfile.production +++ b/Dockerfile.production @@ -1,20 +1,22 @@ FROM registry.opensuse.org/opensuse/infrastructure/dale/containers/osem/base:latest -# Install bundler & foreman -RUN gem install bundler:1.17.3 foreman +ENV RAILS_ENV=production # Add our files COPY --chown=1000:1000 . /osem/ +# Install bundler & foreman +RUN gem install bundler -v "$(grep -A 1 "BUNDLED WITH" /osem/Gemfile.lock | tail -n 1)"; \ + gem install foreman + USER osem WORKDIR /osem/ # Install our bundle -RUN export NOKOGIRI_USE_SYSTEM_LIBRARIES=1; bundle install --jobs=3 --retry=3 --without test development +RUN bundle config set --local without 'test development' +RUN bundle install --jobs=3 --retry=3 # Generate assets -RUN export RAILS_ENV=production; bundle exec rake assets:precompile - -ENV RAILS_ENV=production +RUN bundle exec rake assets:precompile CMD ["foreman", "start"] diff --git a/Gemfile b/Gemfile index 6e0706bb..f7b96a1e 100644 --- a/Gemfile +++ b/Gemfile @@ -5,7 +5,7 @@ end source 'https://rubygems.org' -ruby ENV['OSEM_RUBY_VERSION'] || '3.1.0' +ruby ENV.fetch('OSEM_RUBY_VERSION', '3.1.2') # rails-assets requires >= 1.8.4 if Gem::Version.new(Bundler::VERSION) < Gem::Version.new('1.8.4') @@ -20,7 +20,7 @@ else end # Use Puma as the app server -gem 'puma', '~> 4.3' +gem 'puma' # respond_to methods have been extracted to the responders gem # http://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html#responders @@ -145,6 +145,10 @@ gem 'prawn-rails' # see https://github.com/prawnpdf/prawn/commit/3658d5125c3b20eb11484c3b039ca6b89dc7d1b7 gem 'matrix', '~> 0.4' +# FIXME: for selenium-webdriver, rexml isn't in the default set of Ruby 3.1 anymore +# see https://github.com/SeleniumHQ/selenium/commit/526fd9d0de60a53746ffa982feab985fed09a278 +gem 'rexml' + # for QR code generation gem 'rqrcode' @@ -180,7 +184,7 @@ gem 'money-rails' gem 'acts_as_list' # for switch checkboxes -gem 'bootstrap-switch-rails', '~> 3.3.5' +gem 'bootstrap-switch-rails', '3.3.3' # Locked pending Bttstrp/bootstrap-switch#707 # for parsing OEmbed data gem 'ruby-oembed' diff --git a/Gemfile.lock b/Gemfile.lock index ecc0baea..d807fe8a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -14,7 +14,7 @@ GEM rails-assets-jquery-smooth-scroll (2.2.0) rails-assets-jquery (>= 1.7.0) rails-assets-markdown (0.5.0) - rails-assets-momentjs (2.22.2) + rails-assets-momentjs (2.29.3) rails-assets-spectrum (1.8.0) rails-assets-jquery (>= 1.7.2) rails-assets-tinycolor (1.4.1) @@ -110,24 +110,25 @@ GEM archive-zip (0.12.0) io-like (~> 0.3.0) ast (2.4.2) - autoprefixer-rails (10.3.1.0) + autoprefixer-rails (10.4.7.0) execjs (~> 2) awesome_nested_set (3.5.0) activerecord (>= 4.0.0, < 7.1) aws_cf_signer (0.1.3) - bcrypt (3.1.16) + bcrypt (3.1.17) bindex (0.8.1) bootstrap-sass (3.4.1) autoprefixer-rails (>= 5.2.1) sassc (>= 2.0.0) - bootstrap-switch-rails (3.3.5) + bootstrap-switch-rails (3.3.3) bootstrap3-datetimepicker-rails (4.17.47) momentjs-rails (>= 2.8.1) builder (3.2.4) byebug (11.1.3) cancancan (3.3.0) - capybara (3.35.3) + capybara (3.36.0) addressable + matrix mini_mime (>= 0.1.3) nokogiri (~> 1.8) rack (>= 1.6.0) @@ -148,32 +149,32 @@ GEM fastimage case_transform (0.2) activesupport - caxlsx (3.1.0) + caxlsx (3.2.0) htmlentities (~> 4.3, >= 4.3.4) marcel (~> 1.0) nokogiri (~> 1.10, >= 1.10.4) rubyzip (>= 1.3.0, < 3) - caxlsx_rails (0.6.2) + caxlsx_rails (0.6.3) actionpack (>= 3.1) caxlsx (>= 3.0) chartkick (4.1.3) - childprocess (3.0.0) + childprocess (4.1.0) chronic (0.10.2) chunky_png (1.4.0) climate_control (1.0.1) - cloudinary (1.20.0) + cloudinary (1.23.0) aws_cf_signer rest-client (>= 2.0.0) cocoon (1.2.15) colorize (0.8.1) - concurrent-ruby (1.1.9) + concurrent-ruby (1.1.10) countable-rails (0.0.1) railties (>= 3.1) - countries (4.0.1) - i18n_data (~> 0.13.0) + countries (4.2.2) + i18n_data (~> 0.15.0) sixarm_ruby_unaccent (~> 1.1) - country_select (6.0.0) - countries (~> 4.0) + country_select (6.1.1) + countries (~> 4.2) sort_alphabetical (~> 1.1) crack (0.4.5) rexml @@ -200,7 +201,7 @@ GEM warden (~> 1.2.3) devise_ichain_authenticatable (0.3.2) devise (>= 2.2) - diff-lcs (1.4.4) + diff-lcs (1.5.0) digest (3.1.0) docile (1.4.0) domain_name (0.5.20190701) @@ -212,35 +213,20 @@ GEM erubi (1.10.0) erubis (2.7.0) execjs (2.8.1) - factory_bot (6.2.0) + factory_bot (6.2.1) activesupport (>= 5.0.0) factory_bot_rails (6.2.0) factory_bot (~> 6.2.0) railties (>= 5.0.0) - faker (2.18.0) - i18n (>= 1.6, < 2) - faraday (1.7.0) - faraday-em_http (~> 1.0) - faraday-em_synchrony (~> 1.0) - faraday-excon (~> 1.1) - faraday-httpclient (~> 1.0.1) - faraday-net_http (~> 1.0) - faraday-net_http_persistent (~> 1.1) - faraday-patron (~> 1.0) - faraday-rack (~> 1.0) - multipart-post (>= 1.2, < 3) + faker (2.20.0) + i18n (>= 1.8.11, < 2) + faraday (2.3.0) + faraday-net_http (~> 2.0) ruby2_keywords (>= 0.0.4) - faraday-em_http (1.0.0) - faraday-em_synchrony (1.0.0) - faraday-excon (1.1.0) - faraday-httpclient (1.0.1) - faraday-net_http (1.0.1) - faraday-net_http_persistent (1.2.0) - faraday-patron (1.0.0) - faraday-rack (1.0.0) - fastimage (2.2.5) + faraday-net_http (2.0.2) + fastimage (2.2.6) feature (1.4.0) - ffi (1.15.3) + ffi (1.15.5) font-awesome-rails (4.7.0.8) railties (>= 3.2, < 8.0) geckodriver-helper (0.24.0) @@ -265,7 +251,7 @@ GEM sysexits (~> 1.1) hashdiff (1.0.1) hashery (2.1.2) - hashie (4.1.0) + hashie (5.0.0) html2haml (2.2.0) erubis (~> 2.7.0) haml (>= 4.0, < 6) @@ -275,17 +261,17 @@ GEM http-accept (1.7.0) http-cookie (1.0.4) domain_name (~> 0.5) - i18n (1.9.1) + i18n (1.10.0) concurrent-ruby (~> 1.0) - i18n_data (0.13.0) + i18n_data (0.15.0) + simple_po_parser (~> 1.1) icalendar (2.7.1) ice_cube (~> 0.16) - ice_cube (0.16.3) - image_processing (1.12.1) + ice_cube (0.16.4) + image_processing (1.12.2) mini_magick (>= 4.9.5, < 5) ruby-vips (>= 2.0.17, < 3) io-like (0.3.1) - io-wait (0.2.1) iso-639 (0.3.5) jquery-datatables-rails (3.4.0) actionpack (>= 3.1) @@ -298,55 +284,54 @@ GEM thor (>= 0.14, < 2.0) jquery-ui-rails (6.0.1) railties (>= 3.2.16) - json (2.5.1) + json (2.6.1) json-schema (2.8.1) addressable (>= 2.4) jsonapi-renderer (0.2.2) - jwt (2.2.3) + jwt (2.3.0) launchy (2.5.0) addressable (~> 2.7) leaflet-rails (1.7.0) rails (>= 4.2.0) - letter_opener (1.7.0) - launchy (~> 2.2) + letter_opener (1.8.1) + launchy (>= 2.2, < 3) letter_opener_web (2.0.0) actionmailer (>= 5.2) letter_opener (~> 1.7) railties (>= 5.2) rexml - loofah (2.13.0) + loofah (2.17.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.1) mini_mime (>= 0.1.1) - marcel (1.0.1) + marcel (1.0.2) matrix (0.4.2) method_source (1.0.0) - mime-types (3.3.1) + mime-types (3.4.1) mime-types-data (~> 3.2015) - mime-types-data (3.2021.0704) + mime-types-data (3.2022.0105) mina (1.2.4) open4 (~> 1.3.4) rake mini_magick (4.11.0) mini_mime (1.1.2) - mini_portile2 (2.7.1) + mini_portile2 (2.8.0) minitest (5.15.0) - momentjs-rails (2.20.1) + momentjs-rails (2.29.1.1) railties (>= 3.1) - monetize (1.9.4) + monetize (1.12.0) money (~> 6.12) - money (6.13.8) + money (6.16.0) i18n (>= 0.6.4, <= 2) - money-rails (1.14.0) + money-rails (1.15.0) activesupport (>= 3.0) - monetize (~> 1.9.0) - money (~> 6.13.2) + monetize (~> 1.9) + money (~> 6.13) railties (>= 3.0) multi_json (1.15.0) multi_xml (0.6.0) - multipart-post (2.1.1) - mysql2 (0.5.3) + mysql2 (0.5.4) net-imap (0.2.3) digest net-protocol @@ -355,67 +340,66 @@ GEM digest net-protocol timeout - net-protocol (0.1.2) - io-wait + net-protocol (0.1.3) timeout net-smtp (0.3.1) digest net-protocol timeout netrc (0.11.0) - next_rails (1.0.4) + next_rails (1.0.5) colorize (>= 0.8.1) nio4r (2.5.8) - nokogiri (1.13.1) - mini_portile2 (~> 2.7.0) + nokogiri (1.13.6) + mini_portile2 (~> 2.8.0) racc (~> 1.4) - oauth2 (1.4.7) - faraday (>= 0.8, < 2.0) + oauth2 (1.4.9) + faraday (>= 0.17.3, < 3.0) jwt (>= 1.0, < 3.0) multi_json (~> 1.3) multi_xml (~> 0.5) rack (>= 1.2, < 3) - omniauth (2.0.4) + omniauth (2.1.0) hashie (>= 3.4.6) - rack (>= 1.6.2, < 3) + rack (>= 2.2.3) rack-protection - omniauth-facebook (8.0.0) + omniauth-facebook (9.0.0) omniauth-oauth2 (~> 1.2) omniauth-github (2.0.0) omniauth (~> 2.0) omniauth-oauth2 (~> 1.7.1) - omniauth-google-oauth2 (1.0.0) + omniauth-google-oauth2 (1.0.1) jwt (>= 2.0) oauth2 (~> 1.1) omniauth (~> 2.0) omniauth-oauth2 (~> 1.7.1) - omniauth-oauth2 (1.7.1) + omniauth-oauth2 (1.7.2) oauth2 (~> 1.4) omniauth (>= 1.9, < 3) omniauth-openid (2.0.1) omniauth (>= 1.0, < 3.0) rack-openid (~> 1.4.0) - omniauth-rails_csrf_protection (1.0.0) + omniauth-rails_csrf_protection (1.0.1) actionpack (>= 4.2) omniauth (~> 2.0) open4 (1.3.4) orm_adapter (0.5.0) - paper_trail (12.2.0) + paper_trail (12.3.0) activerecord (>= 5.2) request_store (~> 1.1) - parallel (1.21.0) - parser (3.1.0.0) + parallel (1.22.1) + parser (3.1.2.0) ast (~> 2.4.1) pdf-core (0.9.0) pdf-inspector (1.3.0) pdf-reader (>= 1.0, < 3.0.a) - pdf-reader (2.5.0) + pdf-reader (2.9.2) Ascii85 (~> 1.0) afm (~> 0.2.1) hashery (~> 2.0) ruby-rc4 ttfunk - pg (1.2.3) + pg (1.3.5) prawn (2.4.0) pdf-core (~> 0.9.0) ttfunk (~> 1.7) @@ -428,15 +412,15 @@ GEM prawn-table prawn-table (0.2.2) prawn (>= 1.3.0, < 3.0.0) - public_suffix (4.0.6) - puma (4.3.8) + public_suffix (4.0.7) + puma (5.6.4) nio4r (~> 2.0) racc (1.6.0) rack (2.2.3) rack-openid (1.4.2) rack (>= 1.1.0) ruby-openid (>= 2.1.8) - rack-protection (2.1.0) + rack-protection (2.2.0) rack rack-test (1.1.0) rack (>= 1.0, < 3) @@ -463,7 +447,7 @@ GEM nokogiri (>= 1.6) rails-html-sanitizer (1.4.2) loofah (~> 2.3) - rails-i18n (7.0.1) + rails-i18n (7.0.3) i18n (>= 0.7, < 2) railties (>= 6.0.0, < 8) railties (7.0.1) @@ -475,10 +459,10 @@ GEM zeitwerk (~> 2.5) rainbow (3.1.1) rake (13.0.6) - recaptcha (5.8.1) + recaptcha (5.10.0) json redcarpet (3.5.1) - regexp_parser (2.2.0) + regexp_parser (2.4.0) request_store (1.5.1) rack (>= 1.4) responders (3.0.1) @@ -491,23 +475,23 @@ GEM netrc (~> 0.8) rexml (3.2.5) rolify (6.0.0) - rqrcode (2.0.0) + rqrcode (2.1.1) chunky_png (~> 1.0) rqrcode_core (~> 1.0) - rqrcode_core (1.1.0) + rqrcode_core (1.2.0) rspec-activemodel-mocks (1.1.0) activemodel (>= 3.0) activesupport (>= 3.0) rspec-mocks (>= 2.99, < 4.0) - rspec-core (3.10.1) - rspec-support (~> 3.10.0) - rspec-expectations (3.10.1) + rspec-core (3.11.0) + rspec-support (~> 3.11.0) + rspec-expectations (3.11.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.10.0) - rspec-mocks (3.10.2) + rspec-support (~> 3.11.0) + rspec-mocks (3.11.1) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.10.0) - rspec-rails (5.0.2) + rspec-support (~> 3.11.0) + rspec-rails (5.1.2) actionpack (>= 5.2) activesupport (>= 5.2) railties (>= 5.2) @@ -515,34 +499,33 @@ GEM rspec-expectations (~> 3.10) rspec-mocks (~> 3.10) rspec-support (~> 3.10) - rspec-support (3.10.2) - rubocop (1.25.1) + rspec-support (3.11.0) + rubocop (1.29.0) parallel (~> 1.10) parser (>= 3.1.0.0) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) - rexml - rubocop-ast (>= 1.15.1, < 2.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.17.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.15.1) - parser (>= 3.0.1.1) - rubocop-rails (2.11.3) + rubocop-ast (1.17.0) + parser (>= 3.1.1.0) + rubocop-rails (2.14.2) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.7.0, < 2.0) - rubocop-rspec (2.4.0) - rubocop (~> 1.0) - rubocop-ast (>= 1.1.0) + rubocop-rspec (2.10.0) + rubocop (~> 1.19) ruby-oembed (0.15.0) ruby-openid (2.9.2) ruby-progressbar (1.11.0) ruby-rc4 (0.1.5) - ruby-vips (2.1.2) + ruby-vips (2.1.4) ffi (~> 1.12) ruby2_keywords (0.0.5) - ruby_parser (3.17.0) - sexp_processor (~> 4.15, >= 4.15.1) + ruby_parser (3.19.1) + sexp_processor (~> 4.16) rubyzip (2.3.2) sass-rails (6.0.0) sassc-rails (~> 2.1, >= 2.1.1) @@ -555,8 +538,9 @@ GEM sprockets-rails tilt selectize-rails (0.12.6) - selenium-webdriver (3.142.7) - childprocess (>= 0.5, < 4.0) + selenium-webdriver (4.1.0) + childprocess (>= 0.5, < 5.0) + rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2) sentry-rails (4.6.5) railties (>= 5.0) @@ -564,32 +548,34 @@ GEM sentry-ruby-core (4.6.5) concurrent-ruby faraday - sexp_processor (4.15.3) + sexp_processor (4.16.1) shoulda-matchers (4.5.1) activesupport (>= 4.2.0) + simple_po_parser (1.1.6) simplecov (0.21.2) docile (~> 1.1) simplecov-html (~> 0.11) simplecov_json_formatter (~> 0.1) - simplecov-cobertura (1.4.2) - simplecov (~> 0.8) + simplecov-cobertura (2.1.0) + rexml + simplecov (~> 0.19) simplecov-html (0.12.3) - simplecov_json_formatter (0.1.3) + simplecov_json_formatter (0.1.4) sixarm_ruby_unaccent (1.2.0) - skylight (5.1.0) + skylight (5.3.2) activesupport (>= 5.2.0) sort_alphabetical (1.1.0) unicode_utils (>= 1.2.2) - sprockets (4.0.2) + sprockets (4.0.3) concurrent-ruby (~> 1.0) rack (> 1, < 3) - sprockets-rails (3.2.2) - actionpack (>= 4.0) - activesupport (>= 4.0) + sprockets-rails (3.4.2) + actionpack (>= 5.2) + activesupport (>= 5.2) sprockets (>= 3.0.0) sqlite3 (1.4.2) ssrf_filter (1.0.7) - stripe (5.43.0) + stripe (5.53.0) stripe-ruby-mock (3.1.0.rc3) dante (>= 0.2.0) multi_json (~> 1.0) @@ -599,9 +585,9 @@ GEM temple (0.8.2) thor (1.2.1) tilt (2.0.10) - timecop (0.9.4) + timecop (0.9.5) timeout (0.2.0) - transitions (1.2.1) + transitions (1.3.0) ttfunk (1.7.0) turbolinks (5.2.1) turbolinks-source (~> 5.2) @@ -612,7 +598,7 @@ GEM execjs (>= 0.3.0, < 3) unf (0.1.4) unf_ext - unf_ext (0.0.7.7) + unf_ext (0.0.8.1) unicode-display_width (2.1.0) unicode_utils (1.4.0) unobtrusive_flash (3.3.1) @@ -624,10 +610,10 @@ GEM activemodel (>= 6.0.0) bindex (>= 0.4.0) railties (>= 6.0.0) - webdrivers (4.6.0) + webdrivers (5.0.0) nokogiri (~> 1.6) rubyzip (>= 1.3.0) - selenium-webdriver (>= 3.0, < 4.0) + selenium-webdriver (~> 4.0) webmock (3.14.0) addressable (>= 2.8.0) crack (>= 0.3.2) @@ -652,7 +638,7 @@ DEPENDENCIES autoprefixer-rails awesome_nested_set bootstrap-sass (~> 3.4.0) - bootstrap-switch-rails (~> 3.3.5) + bootstrap-switch-rails (= 3.3.3) bootstrap3-datetimepicker-rails (~> 4.17.47) byebug cancancan @@ -708,7 +694,7 @@ DEPENDENCIES pg prawn-qrcode prawn-rails - puma (~> 4.3) + puma rails (~> 7.0) rails-assets-bootstrap-markdown! rails-assets-bootstrap-select! @@ -727,6 +713,7 @@ DEPENDENCIES recaptcha redcarpet responders (~> 3.0) + rexml rolify rqrcode rspec-activemodel-mocks @@ -756,7 +743,7 @@ DEPENDENCIES whenever RUBY VERSION - ruby 3.1.0 + ruby 3.1.2 BUNDLED WITH 2.3.3 diff --git a/app/assets/javascripts/osem.js b/app/assets/javascripts/osem.js index 5f1bc625..65795fe3 100644 --- a/app/assets/javascripts/osem.js +++ b/app/assets/javascripts/osem.js @@ -133,7 +133,7 @@ function get_color() { function word_count(text, divId, maxcount) { var area = document.getElementById(text.id) - Countable.live(area, function(counter) { + Countable.once(area, function(counter) { $('#' + divId).text(counter.words); if (counter.words > maxcount) $('#' + divId).css('color', 'red'); @@ -157,7 +157,7 @@ $( document ).ready(function() { .trigger('change'); /* Count the proposal abstract length */ - $("#event_abstract").bind('change keyup paste input', function() { + $("#event_abstract").on('input', function() { var $selected = $("#event_event_type_id option:selected") var max = $selected.data("max-words"); word_count(this, 'abstract-count', max); diff --git a/app/controllers/admin/registrations_controller.rb b/app/controllers/admin/registrations_controller.rb index 0fa8a8af..88027bbd 100644 --- a/app/controllers/admin/registrations_controller.rb +++ b/app/controllers/admin/registrations_controller.rb @@ -20,7 +20,7 @@ module Admin respond_to do |format| format.html format.json do - render json: RegistrationDatatable.new({}, conference: @conference, view_context: view_context) + render json: RegistrationDatatable.new(params, conference: @conference, view_context: view_context) end format.pdf { render 'index', layout: false } format.xlsx do diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index 6b317a7e..9820cef1 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -23,7 +23,7 @@ module Admin respond_to do |format| format.html format.json do - render json: UserDatatable.new(view_context: view_context) + render json: UserDatatable.new(params, view_context: view_context) end end end diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index c281d4e1..0db33128 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -26,14 +26,9 @@ class RegistrationsController < Devise::RegistrationsController end def account_update_params - params.require(:user).permit( - :email, - :password, - :password_confirmation, - :current_password, - :username, - :email_public - ) + user_attributes = [:email, :name, :password, :password_confirmation, :current_password, :email_public] + user_attributes << :is_admin if current_user.is_admin? + params.require(:user).permit(user_attributes) end def check_captcha diff --git a/app/controllers/surveys_controller.rb b/app/controllers/surveys_controller.rb index fdf24963..a5c9fd0d 100644 --- a/app/controllers/surveys_controller.rb +++ b/app/controllers/surveys_controller.rb @@ -40,6 +40,6 @@ class SurveysController < ApplicationController end end - redirect_back(fallback_location: root_path) + redirect_back(fallback_location: root_path, notice: 'Successfully responded to survey.') end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 0e802ad8..f68ea51f 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -26,7 +26,7 @@ class UsersController < ApplicationController def search respond_to do |format| format.json do - render json: { users: User.where('username like ?', "%#{params[:query]}%").select(:username, :id) } + render json: { users: User.active.where('username like ?', "%#{params[:query]}%").select(:username, :id) } end end end diff --git a/app/datatables/registration_datatable.rb b/app/datatables/registration_datatable.rb index 7384933c..965aa822 100644 --- a/app/datatables/registration_datatable.rb +++ b/app/datatables/registration_datatable.rb @@ -14,7 +14,6 @@ class RegistrationDatatable < AjaxDatatablesRails::ActiveRecord @view_columns ||= { id: { source: 'Registration.id', cond: :eq }, name: { source: 'User.name' }, - roles: { source: 'Role.name' }, email: { source: 'User.email' }, accepted_code_of_conduct: { source: 'Registration.accepted_code_of_conduct', searchable: false }, actions: { source: 'Registration.id', searchable: false, orderable: false } @@ -41,7 +40,6 @@ class RegistrationDatatable < AjaxDatatablesRails::ActiveRecord roles: conference_role_titles(record.user), email: record.email, accepted_code_of_conduct: !!record.accepted_code_of_conduct, # rubocop:disable Style/DoubleNegation - questions: {}, edit_url: edit_admin_conference_registration_path(conference, record), DT_RowId: record.id } @@ -53,7 +51,7 @@ class RegistrationDatatable < AjaxDatatablesRails::ActiveRecord end # override upstream santitation, which converts everything to strings - def sanitize(records) + def sanitize_data(records) records end end diff --git a/app/datatables/user_datatable.rb b/app/datatables/user_datatable.rb index cc2ece66..d7e102d2 100644 --- a/app/datatables/user_datatable.rb +++ b/app/datatables/user_datatable.rb @@ -1,12 +1,17 @@ # frozen_string_literal: true -class UserDatatable < AjaxDatatablesRails::Base +class UserDatatable < AjaxDatatablesRails::ActiveRecord extend Forwardable def_delegator :@view, :show_roles def_delegator :@view, :admin_user_path def_delegator :@view, :edit_admin_user_path + def initialize(params, opts = {}) + @view = opts[:view_context] + super + end + def view_columns # Declare strings in this format: ModelName.column_name # or in aliased_join_table.column_name format @@ -17,8 +22,7 @@ class UserDatatable < AjaxDatatablesRails::Base name: { source: 'User.name' }, attended: { source: 'attended_count', searchable: false }, roles: { source: 'Role.name' }, - view_url: { source: 'User.id', searchable: false, orderable: false }, - edit_url: { source: 'User.id', searchable: false, orderable: false } + actions: { source: 'User.id', searchable: false, orderable: false } } end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index fe8b25e2..e3474111 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -111,36 +111,12 @@ module ApplicationHelper safe_join(event.speakers.map{ |speaker| link_to speaker.name, admin_user_path(speaker) }, ',') end - def speaker_selector_input(form) - user_selector_input(:speakers, form, '', true) - end - - def user_selector_input(field, form, hint = '', multiple = true) - users = User.where(is_disabled: false).pluck(:id, :name, :username, :email).map { |user| [user[0], user[1].blank? ? user[2] : user[1], user[2], user[3]] }.sort_by { |user| user[1].downcase } - form.input( - field, - as: :select, - include_blank: true, - label: field.to_s.titleize, - hint: hint, - collection: options_for_select( - users.map { |user| ["#{user[1]} (#{user[2]}) #{user[3]}", user[0]] }, - (form.object.send(field)&.map(&:id) || form.object.send(field)&.id) - ), - input_html: { - class: 'select-help-toggle', - multiple: multiple, - placeholder: (multiple ? 'Select users...' : 'Select a user...') - } - ) - end - def event_types_sentence(conference) conference.event_types.map { |et| et.title.pluralize }.to_sentence end def sign_in_path - if ENV['OSEM_ICHAIN_ENABLED'] == 'true' + if ENV.fetch('OSEM_ICHAIN_ENABLED', nil) == 'true' new_user_ichain_session_path else new_user_session_path @@ -164,9 +140,7 @@ module ApplicationHelper def nav_root_link_for(conference) link_text = ( - conference.try(:organization).try(:name) || - ENV['OSEM_NAME'] || - 'OSEM' + conference.try(:organization).try(:name) || ENV.fetch('OSEM_NAME', 'OSEM') ) link_to( link_text, diff --git a/app/helpers/format_helper.rb b/app/helpers/format_helper.rb index 67f53b2c..07a982ab 100644 --- a/app/helpers/format_helper.rb +++ b/app/helpers/format_helper.rb @@ -190,15 +190,18 @@ module FormatHelper def markdown(text, escape_html=true) return '' if text.nil? - options = { + markdown_options = { autolink: true, space_after_headers: true, no_intra_emphasis: true, fenced_code_blocks: true, - disable_indented_code_blocks: true, - safe_links_only: true + disable_indented_code_blocks: true } - markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML.new(escape_html: escape_html), options) + render_options = { + escape_html: escape_html, + safe_links_only: true + } + markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML.new(render_options), markdown_options) sanitize(markdown.render(text)) end diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 1ee065ea..906e6f3b 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -19,7 +19,7 @@ module UsersHelper unless Rails.application.secrets.send(provider_key).blank? || Rails.application.secrets.send(provider_secret).blank? providers << provider end - providers << provider if !ENV["OSEM_#{provider.upcase}_KEY"].blank? && !ENV["OSEM_#{provider.upcase}_SECRET"].blank? + providers << provider if ENV.fetch("OSEM_#{provider.upcase}_KEY", nil).present? && ENV.fetch("OSEM_#{provider.upcase}_SECRET", nil).present? end providers.uniq diff --git a/app/models/ability.rb b/app/models/ability.rb index caf8f2a4..77746620 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -42,7 +42,7 @@ class Ability can [:index, :show], Survey, surveyable_type: 'Conference' # Things that are possible without ichain enabled that are **not*+ possible with ichain mode enabled. - if ENV['OSEM_ICHAIN_ENABLED'] != 'true' + if ENV.fetch('OSEM_ICHAIN_ENABLED', nil) != 'true' # There is no reliable way for this workflow (enable not logged in users to fill out a form, then telling # them to sign up once they submit) in ichain. So enable it only without ichain. @@ -122,9 +122,7 @@ class Ability # if not, do not allow replies. # do not allow replies before the start_date or after the end_date of survey - cannot :reply, Survey do |survey| - survey.start_date > Time.current || survey.end_date < Time.current - end + cannot :reply, Survey, &:closed? can [:destroy], Openid diff --git a/app/models/admin_ability.rb b/app/models/admin_ability.rb index 19d6c4d3..6100455c 100644 --- a/app/models/admin_ability.rb +++ b/app/models/admin_ability.rb @@ -51,7 +51,7 @@ class AdminAbility # for admins can :manage, :all if user.is_admin # even admin cannot create new users with ICHAIN enabled - cannot [:new, :create], User if ENV['OSEM_ICHAIN_ENABLED'] == 'true' + cannot [:new, :create], User if ENV.fetch('OSEM_ICHAIN_ENABLED', nil) == 'true' cannot :revert_object, PaperTrail::Version do |version| (version.event == 'create' && %w[Conference User Event].include?(version.item_type)) end @@ -142,6 +142,10 @@ class AdminAbility can :manage, Room, venue: { conference_id: conf_ids } can :manage, Sponsor, conference_id: conf_ids can :manage, SponsorshipLevel, conference_id: conf_ids + can :manage, Survey, surveyable_type: 'Conference', + surveyable_id: conf_ids + can :manage, SurveyQuestion, survey: { surveyable_type: 'Conference', + surveyable_id: conf_ids } can :manage, Ticket, conference_id: conf_ids can :create, TicketScanning do |ticket_scanning| conf_id = ticket_scanning.physical_ticket.ticket_purchase.conference_id diff --git a/app/models/email_settings.rb b/app/models/email_settings.rb index 55487496..053a82db 100644 --- a/app/models/email_settings.rb +++ b/app/models/email_settings.rb @@ -13,12 +13,12 @@ class EmailSettings < ApplicationRecord 'conference_start_date' => conference.start_date, 'conference_end_date' => conference.end_date, 'registrationlink' => Rails.application.routes.url_helpers.conference_conference_registration_url( - conference.short_title, host: (ENV['OSEM_HOSTNAME'] || 'localhost:3000')), + conference.short_title, host: ENV.fetch('OSEM_HOSTNAME', 'localhost:3000')), 'conference_splash_link' => Rails.application.routes.url_helpers.conference_url( - conference.short_title, host: (ENV['OSEM_HOSTNAME'] || 'localhost:3000')), + conference.short_title, host: ENV.fetch('OSEM_HOSTNAME', 'localhost:3000')), 'schedule_link' => Rails.application.routes.url_helpers.conference_schedule_url( - conference.short_title, host: (ENV['OSEM_HOSTNAME'] || 'localhost:3000')) + conference.short_title, host: ENV.fetch('OSEM_HOSTNAME', 'localhost:3000')) } if conference.program.cfp @@ -45,7 +45,7 @@ class EmailSettings < ApplicationRecord if event h['eventtitle'] = event.title h['proposalslink'] = Rails.application.routes.url_helpers.conference_program_proposals_url( - conference.short_title, host: (ENV['OSEM_HOSTNAME'] || 'localhost:3000')) + conference.short_title, host: ENV.fetch('OSEM_HOSTNAME', 'localhost:3000')) end if booth diff --git a/app/models/survey.rb b/app/models/survey.rb index 50e251a7..66783e90 100644 --- a/app/models/survey.rb +++ b/app/models/survey.rb @@ -32,4 +32,8 @@ class Survey < ActiveRecord::Base now <= end_date end end + + def closed? + !active? + end end diff --git a/app/models/user.rb b/app/models/user.rb index 86c197db..993d4892 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -23,8 +23,8 @@ class User < ApplicationRecord end has_many :users_roles - has_many :roles, through: :users_roles, dependent: :destroy rolify + has_many :roles, through: :users_roles, dependent: :destroy has_paper_trail on: [:create, :update], ignore: [:sign_in_count, :remember_created_at, :current_sign_in_at, :last_sign_in_at, :current_sign_in_ip, :last_sign_in_ip, :unconfirmed_email, :avatar_content_type, :avatar_file_size, :avatar_updated_at, :updated_at, :confirmation_sent_at, :confirmation_token, :reset_password_token] @@ -51,7 +51,7 @@ class User < ApplicationRecord # :lockable, :timeoutable and :omniauthable devise_modules = [] - devise_modules += if ENV['OSEM_ICHAIN_ENABLED'] == 'true' + devise_modules += if ENV.fetch('OSEM_ICHAIN_ENABLED', nil) == 'true' [:ichain_authenticatable, :ichain_registerable, :omniauthable, omniauth_providers: []] else [:database_authenticatable, :registerable, diff --git a/app/models/venue.rb b/app/models/venue.rb index 5abdcf96..5df7c60e 100644 --- a/app/models/venue.rb +++ b/app/models/venue.rb @@ -21,7 +21,7 @@ class Venue < ApplicationRecord def country_name name = ISO3166::Country[country] - name&.name + name&.iso_short_name end def location? diff --git a/app/views/admin/emails/index.html.haml b/app/views/admin/emails/index.html.haml index 48f19a89..41a43825 100644 --- a/app/views/admin/emails/index.html.haml +++ b/app/views/admin/emails/index.html.haml @@ -21,8 +21,8 @@ #onboarding.tab-pane.active{ role: 'tabpanel' } .checkbox %label - = f.check_box :send_on_registration, data: {name: 'email_settings_registration_subject'}, class: 'send_on_radio' - Send an email when the user registers for the conference? + = f.check_box :send_on_registration, data: {name: 'email_settings_registration_subject'}, class: 'send_on_radio' + Send an email when the user registers for the conference? .form-group = f.label :registration_subject, 'Subject' = f.text_field :registration_subject, class: 'form-control' @@ -38,7 +38,7 @@ .checkbox %label = f.check_box :send_on_submitted_proposal, data: { name: 'email_settings_proposal_submited_subject'}, class: 'send_on_radio' - Send an email when the proposal is submitted + Send an email when the proposal is submitted? .form-group = f.label :submitted_proposal_subject, 'Subject' = f.text_field :submitted_proposal_subject, class: 'form-control' @@ -50,8 +50,8 @@ = render partial: 'help', locals: { id: 'submitted_proposal_help', show_event_variables: true } .checkbox %label - = f.check_box :send_on_accepted, data: { name: 'email_settings_accepted_subject' }, class: 'send_on_radio' - Send an email when the proposal is accepted? + = f.check_box :send_on_accepted, data: { name: 'email_settings_accepted_subject' }, class: 'send_on_radio' + Send an email when the proposal is accepted? .form-group = f.label :accepted_subject, 'Subject' = f.text_field :accepted_subject, class: 'form-control' @@ -100,7 +100,7 @@ .checkbox %label = f.check_box :send_on_conference_dates_updated, data: { name: 'email_settings_conference_dates_updated_subject'}, class: 'send_on_radio' - Send an email when to all participants if the conference dates are changed? + Send an email to all participants if the conference dates are changed? .form-group = f.label :conference_dates_updated_subject, 'Subject' = f.text_field :conference_dates_updated_subject, class: 'form-control' @@ -116,7 +116,7 @@ .checkbox %label = f.check_box :send_on_conference_registration_dates_updated, data: { name: 'email_settings_conference_registration_dates_updated_subject' }, class: 'send_on_radio' - Send an email when to all participants if the conference registration dates changed? + Send an email to all participants if the conference registration dates changed? .form-group = f.label :conference_registration_dates_updated_subject, 'Subject' = f.text_field :conference_registration_dates_updated_subject, class: 'form-control' @@ -132,7 +132,7 @@ .checkbox %label = f.check_box :send_on_venue_updated, data: { name: 'email_settings_venue_updated_subject'}, class: 'send_on_radio' - Send an email on updating the Venue? + Send an email on updating the venue? .form-group = f.label :venue_updated_subject, 'Subject' = f.text_field :venue_updated_subject, class: 'form-control' @@ -147,9 +147,9 @@ = render partial: 'help', locals: {id: 'updated_venue_help', show_event_variables: false} #cfp.tab-pane{ role: 'tabpanel' } .checkbox - %labl + %label = f.check_box :send_on_program_schedule_public - Send an email when to all participants if the schedule is made public? + Send an email to all participants if the schedule is made public? .form-group = f.label :program_schedule_public_subject, 'Subject' = f.text_field :program_schedule_public_subject, class: 'form-control' @@ -165,7 +165,7 @@ .checkbox %label = f.check_box :send_on_cfp_dates_updated - Send an email when to all participants if call for paper dates are updated? + Send an email to all participants if call for paper dates are updated? .form-group = f.label :cfp_dates_updated_subject, 'Subject' = f.text_field :cfp_dates_updated_subject, class: 'form-control' @@ -179,9 +179,10 @@ %a.btn.btn-link.control_label.template_help_link{ 'data-name' => 'updated_cfp_help' } Show Help = render partial: 'help', locals: {id: 'updated_cfp_help', show_event_variables: false} #booth.tab-pane{ role: 'tabpanel' } - .check_box + .checkbox %label - = f.check_box :send_on_booths_acceptance + = f.check_box :send_on_booths_acceptance + Send an email when the booth is accepted? .form-group = f.label :booths_acceptance_subject, 'Subject' = f.text_field :booths_acceptance_subject, class: 'form-control' @@ -197,6 +198,7 @@ .checkbox %label = f.check_box :send_on_booths_rejection + Send an email when the booth is rejected? .form-group = f.label :booths_rejection_subject, 'Subject' = f.text_field :booths_rejection_subject, class: 'form-control' diff --git a/app/views/admin/registrations/index.html.haml b/app/views/admin/registrations/index.html.haml index 09f674e9..512899a2 100644 --- a/app/views/admin/registrations/index.html.haml +++ b/app/views/admin/registrations/index.html.haml @@ -26,7 +26,6 @@ %tr %th{ width: '0' } ID# %th{ width: '25%' } Name - %th{ width: '0' } Roles %th{ width: '0' } E-Mail %th{ width: '0' } %abbr{ title: 'Code of Conduct' } CoC @@ -63,14 +62,6 @@ return content; } }, - { - "name": "roles", - "data": "roles", - "className": "truncate", - "render": function(data, type, row) { - return data.join(', '); - } - }, { "data": "email" }, @@ -80,13 +71,13 @@ "searchable": false }, { - "data": null, + "data": "actions", "className": "actions", "searchable": false, "sortable": false, "render": function (data, type, row, meta) { return '
'+ - 'Edit'+ + 'Edit'+ '
'; } } @@ -94,5 +85,4 @@ }); registrationsDataTable.columns(3).visible(codeOfConductPresent); - registrationsDataTable.columns(2).visible(false); }); diff --git a/app/views/admin/survey_questions/_form.html.haml b/app/views/admin/survey_questions/_form.html.haml index a4e1eea6..0cde22c5 100644 --- a/app/views/admin/survey_questions/_form.html.haml +++ b/app/views/admin/survey_questions/_form.html.haml @@ -30,7 +30,7 @@ = f.label :max_choices = f.number_field :max_choices, class: 'form-control' .form-group - %label{ required: 'required' } + %label{ for: 'survey_question_kind', required: 'required' } Type of Question: .form-group %select.selectpicker.form-control{ id: 'survey_question_kind', name: 'survey_question[kind]' } diff --git a/app/views/admin/survey_questions/new.html.haml b/app/views/admin/survey_questions/new.html.haml new file mode 100644 index 00000000..72992799 --- /dev/null +++ b/app/views/admin/survey_questions/new.html.haml @@ -0,0 +1 @@ += render partial: 'form' diff --git a/app/views/admin/surveys/_form.html.haml b/app/views/admin/surveys/_form.html.haml index ef35538f..b03022ab 100644 --- a/app/views/admin/surveys/_form.html.haml +++ b/app/views/admin/surveys/_form.html.haml @@ -22,7 +22,7 @@ = f.select :target, Survey.targets.keys, class: 'form-control' .form-group = f.label :start_date - = f.text_field :start_date, class: 'datetimepicker', class: 'form-control' + = f.text_field :start_date, class: 'datetimepicker form-control' = f.label :end_date - = f.text_field :end_date, class: 'datetimepicker', class: 'form-control' + = f.text_field :end_date, class: 'datetimepicker form-control' = f.submit nil, class: 'btn btn-primary' diff --git a/app/views/admin/users/index.html.haml b/app/views/admin/users/index.html.haml index e2b47504..2fb1c72a 100644 --- a/app/views/admin/users/index.html.haml +++ b/app/views/admin/users/index.html.haml @@ -61,13 +61,13 @@ } }, { - "data": null, + "data": "actions", "className": "actions", "sortable": false, "render": function (data, type, row, meta) { return '
'+ - 'View'+ - 'Edit'+ + 'View'+ + 'Edit'+ '
'; } } diff --git a/app/views/application/_donut_chart.haml b/app/views/application/_donut_chart.haml index 8a65e390..3c91cdc4 100644 --- a/app/views/application/_donut_chart.haml +++ b/app/views/application/_donut_chart.haml @@ -1,8 +1,9 @@ :ruby combined_data ||= {} data ||= chart_values(combined_data) + colors ||= chart_colors(combined_data) .text-center %h4 = title - = pie_chart data, donut: true, legend: 'bottom', download: true, messages: { empty: 'No data' }, colors: chart_colors(combined_data) + = pie_chart data, donut: true, legend: 'bottom', download: true, messages: { empty: 'No data' }, colors: colors diff --git a/app/views/booths/_form.html.haml b/app/views/booths/_form.html.haml index a7dbfd65..7796149d 100644 --- a/app/views/booths/_form.html.haml +++ b/app/views/booths/_form.html.haml @@ -24,7 +24,8 @@ %abbr{title: 'This field is required'} * = f.text_field :website_url, class: 'form-control', required: true, placeholder: 'URL' .form-group - = f.text_field :responsible_ids, multiple: true, class: "form-control", id: "booth_responsibles", placeholder: "Responsibles" + = f.label :responsible_ids, 'Responsibles' + = f.select :responsible_ids, @booth.responsibles.pluck(:username, :id), {}, { multiple: true, class: 'form-control', id: 'users_selectize', placeholder: 'Responsibles' } %span.help-block The people responsible for the `t('booth')`. You can only select existing users. .form-group @@ -38,33 +39,5 @@ - else Update `(t'booth').capitalize` Request -:javascript - $(document).ready(function() { - $('#booth_responsibles').selectize({ - persist: false, - create: false, - valueField: 'id', - labelField: 'username', - searchField: 'username', - load: function(query, callback) { - if (!query.length) return callback(); - $.ajax({ - url: "#{search_users_path}.json", - type: 'GET', - dataType: 'json', - data: { - query: query, - }, - error: function(res) { - console.log("selectize error"); - callback(); - }, - success: function(res) { - console.log("selectize success"); - // console.log(res); - callback(res.users); - } - }); - } - }); - }); += render partial: 'shared/user_selectize' + diff --git a/app/views/conference_registrations/edit.html.haml b/app/views/conference_registrations/edit.html.haml index 25a22666..4ec17f4d 100644 --- a/app/views/conference_registrations/edit.html.haml +++ b/app/views/conference_registrations/edit.html.haml @@ -11,7 +11,7 @@ %legend %span =link_to('#signup', role: 'tab', "aria-controls" => "home", "data-toggle" => "tab") do - = ENV['OSEM_NAME'] || 'OSEM' + = ENV.fetch('OSEM_NAME', 'OSEM') Account %span.pull-right#account-already =link_to('#signin', role: 'tab', "aria-controls" => "home", "data-toggle" => "tab") do diff --git a/app/views/conference_registrations/new.html.haml b/app/views/conference_registrations/new.html.haml index 25a22666..4ec17f4d 100644 --- a/app/views/conference_registrations/new.html.haml +++ b/app/views/conference_registrations/new.html.haml @@ -11,7 +11,7 @@ %legend %span =link_to('#signup', role: 'tab', "aria-controls" => "home", "data-toggle" => "tab") do - = ENV['OSEM_NAME'] || 'OSEM' + = ENV.fetch('OSEM_NAME', 'OSEM') Account %span.pull-right#account-already =link_to('#signin', role: 'tab', "aria-controls" => "home", "data-toggle" => "tab") do diff --git a/app/views/conferences/_highlights.haml b/app/views/conferences/_highlights.haml index b44a24b1..2bb5b383 100644 --- a/app/views/conferences/_highlights.haml +++ b/app/views/conferences/_highlights.haml @@ -11,9 +11,11 @@ = link_to(conference_program_proposal_path(conference_id, event), class: 'thumbnail') do - = image_tag speaker.gravatar_url(size: 300), - class: ['img-responsive', 'img-circle'], - title: speaker.name + - if speaker + = image_tag speaker.gravatar_url(size: 300), + class: ['img-responsive', 'img-circle'], + title: speaker.name .caption - %h3.text-center= speaker.name + - if speaker + %h3.text-center= speaker.name %h4.text-center= event.title diff --git a/app/views/conferences/new_install.html.haml b/app/views/conferences/new_install.html.haml index d6cf8eef..772511aa 100644 --- a/app/views/conferences/new_install.html.haml +++ b/app/views/conferences/new_install.html.haml @@ -1,21 +1,22 @@ -.row - .col-md-12 - .well - %h1 - Welcome to your new - = link_to('https://osem.io') do - Open Source Event Manager - installation! - %p - The first user to - - if ENV['OSEM_ICHAIN_ENABLED'] == 'true' - = link_to(new_ichain_registration_path('user')) do - sign up - - else - = link_to(new_registration_path('user')) do - sign up - will the be administrator of it. - %p - We hope you enjoy using OSEM, if you have any question don't hesitate to - = link_to('https://osem.io/#contact') do - contact us! +.container + .row + .col-md-12 + .well + %h1 + Welcome to your new + = link_to('https://osem.io') do + Open Source Event Manager + installation! + %p + The first user to + - if ENV.fetch('OSEM_ICHAIN_ENABLED', nil) == 'true' + = link_to(new_ichain_registration_path('user')) do + sign up + - else + = link_to(new_registration_path('user')) do + sign up + will the be administrator of it. + %p + We hope you enjoy using OSEM, if you have any question don't hesitate to + = link_to('https://osem.io/#contact') do + contact us! diff --git a/app/views/conferences/show.html.haml b/app/views/conferences/show.html.haml index e8f64db3..85b2bac6 100644 --- a/app/views/conferences/show.html.haml +++ b/app/views/conferences/show.html.haml @@ -1,6 +1,6 @@ - content_for :head do %meta{ property: "og:title", content: @conference.title } - %meta{ property: "og:site_name", content: (ENV['OSEM_NAME'] || 'OSEM') } + %meta{ property: "og:site_name", content: ENV.fetch('OSEM_NAME', 'OSEM') } %meta{ property: "og:description", content: @conference.description } %meta{ property: "og:url", content: conference_url(@conference.short_title) } %meta{ property: "twitter:title", content: (@conference.title) } diff --git a/app/views/devise/registrations/_form_fields.html.haml b/app/views/devise/registrations/_form_fields.html.haml index 88ab0d39..5425d747 100644 --- a/app/views/devise/registrations/_form_fields.html.haml +++ b/app/views/devise/registrations/_form_fields.html.haml @@ -1,7 +1,8 @@ -.form-group - = f.label :username - %abbr{title: 'This field is required'} * - = f.text_field :username, required: true, autocomplete: 'off', class: 'form-control', placeholder: 'Username' +- unless @user.persisted? + .form-group + = f.label :username + %abbr{title: 'This field is required'} * + = f.text_field :username, required: true, autocomplete: 'off', class: 'form-control', placeholder: 'Username' .form-group = f.label :email %abbr{title: 'This field is required'} * @@ -10,17 +11,17 @@ .checkbox %label = f.check_box :email_public - Check if you want your email address to appear publicly (e.g. on sessions, registration lists, etc.) - .form-group - = f.label :name, 'Real Name' - = f.text_field :name, required: true, class: 'form-control', placeholder: 'Name' + Do you want your email address to appear publicly + %span.help-block + For instance on sessions pages or registration lists. .form-group = f.label :password, 'Password' - %abbr{title: 'This field is required'} * - = f.password_field :password, required: true, class: 'form-control', placeholder: 'Password' + - if !@user.persisted? + %abbr{title: 'This field is required'} * + = f.password_field :password, required: !@user.persisted?, class: 'form-control', placeholder: 'Password' .form-group = f.label :password_confirmation, 'Password Confirmation' - = f.password_field :password_confirmation, required: true, class: 'form-control', placeholder: 'Password Confirmation' + = f.password_field :password_confirmation, required: !@user.persisted?, class: 'form-control', placeholder: 'Password Confirmation' - if @user.persisted? %p.text-muted Leave blank if you don't want to change your password @@ -32,16 +33,16 @@ is Admin? %span.help-block An admin can create a new conference, manage users and make other users admins. -- elsif @user.persisted? +- if @user.persisted? %h4 Confirmation %hr .form-group = f.label :password, "Current Password" %abbr{title: 'This field is required'} * - = f.password_field :current_password, autocomplete: 'off', class: 'form-control', placeholder: 'Password' + = f.password_field :current_password, required: true, autocomplete: 'off', class: 'form-control', placeholder: 'Password' %p.text-muted - We need your current password to confirm password, email or username changes + We need your current password to confirm changes - Feature.with(:recaptcha) do .form-group = recaptcha_tags diff --git a/app/views/devise/sessions/_new_embedded.html.haml b/app/views/devise/sessions/_new_embedded.html.haml index 16f21c52..193a6335 100644 --- a/app/views/devise/sessions/_new_embedded.html.haml +++ b/app/views/devise/sessions/_new_embedded.html.haml @@ -1,4 +1,4 @@ -- if ENV['OSEM_ICHAIN_ENABLED'] != 'true' +- if ENV.fetch('OSEM_ICHAIN_ENABLED', nil) != 'true' = form_tag(new_user_session_path, class: 'form-horizontal') do %legend %span diff --git a/app/views/layouts/_admin_sidebar_index.html.haml b/app/views/layouts/_admin_sidebar_index.html.haml index 0283bf72..65735952 100644 --- a/app/views/layouts/_admin_sidebar_index.html.haml +++ b/app/views/layouts/_admin_sidebar_index.html.haml @@ -37,7 +37,7 @@ = link_to(admin_revision_history_path) do %span.fa.fa-history Revision History - - if ENV['ORGANIZATIONS_ENABLED'] == 'true' + - if ENV.fetch('ORGANIZATIONS_ENABLED', nil) == 'true' %li = link_to(admin_organizations_path) do %span.fa.fa-group diff --git a/app/views/layouts/_navigation.html.haml b/app/views/layouts/_navigation.html.haml index deea4f09..338f4f0e 100644 --- a/app/views/layouts/_navigation.html.haml +++ b/app/views/layouts/_navigation.html.haml @@ -32,7 +32,7 @@ = render 'layouts/user_menu' - else %ul.nav.navbar-nav.navbar-right - - if ENV['OSEM_ICHAIN_ENABLED'] == 'true' + - if ENV.fetch('OSEM_ICHAIN_ENABLED', nil) == 'true' %li{class: "#{active_nav_li(new_ichain_registration_path('user'))}"} = link_to(new_ichain_registration_path('user')) do %span.fa.fa-heart @@ -48,7 +48,7 @@ Sign In %span.caret .dropdown-menu - - if ENV['OSEM_ICHAIN_ENABLED'] == 'true' + - if ENV.fetch('OSEM_ICHAIN_ENABLED', nil) == 'true' = form_tag User.ichain_login_url do = text_field_tag 'username', nil, id: 'user_ichain_email_dd', class: 'form-control', placeholder: 'Username' = password_field_tag 'password', nil, id: 'user_ichain_password_dd', class: 'form-control', placeholder: 'Password' diff --git a/app/views/layouts/_user_menu.html.haml b/app/views/layouts/_user_menu.html.haml index b839f913..787c8eb2 100644 --- a/app/views/layouts/_user_menu.html.haml +++ b/app/views/layouts/_user_menu.html.haml @@ -10,7 +10,7 @@ %li= link_to "See all unread Comments (#{unread_notifications(current_user).length})", admin_comments_path %li= link_to 'See all Comments', admin_comments_path(anchor: 'all_comments') %li.divider -- unless ENV['OSEM_ICHAIN_ENABLED'] == 'true' +- unless ENV.fetch('OSEM_ICHAIN_ENABLED', nil) == 'true' %li = link_to(edit_user_registration_path) do %span.fa.fa-wrench @@ -40,7 +40,7 @@ %span.fa.fa-shopping-bag My #{(t'booth').capitalize } Requests %li - - if ENV['OSEM_ICHAIN_ENABLED'] == 'true' + - if ENV.fetch('OSEM_ICHAIN_ENABLED', nil) == 'true' = link_to(destroy_user_ichain_session_path, method: 'delete') do %span.fa.fa-minus Sign out @@ -76,7 +76,7 @@ = link_to(admin_revision_history_path) do %span.fa.fa-history Revision History - - if ENV['ORGANIZATIONS_ENABLED'] == 'true' + - if ENV.fetch('OSEM_ICHAIN_ENABLED', nil) == 'true' %li = link_to(admin_organizations_path) do %span.fa.fa-group diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 7dfaf2c8..2b2eca75 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -2,7 +2,7 @@ %head %meta{charset: 'utf-8'} %meta{name: 'viewport', content: 'width=device-width, initial-scale=1, maximum-scale=1'} - %title= content_for?(:title) ? yield(:title) : (ENV['OSEM_NAME'] || 'OSEM') + %title= content_for?(:title) ? yield(:title) : ENV.fetch('OSEM_NAME', 'OSEM') %meta{content: '', name: 'description'} %meta{content: '', name: 'author'} = stylesheet_link_tag "application", media: 'all' @@ -10,7 +10,7 @@ = csrf_meta_tags = content_for(:script_head) - - if ENV['OSEM_TRANSIFEX_APIKEY'] + - if ENV.fetch('OSEM_TRANSIFEX_APIKEY', nil) :javascript window.liveSettings = { api_key: "#{ENV['OSEM_TRANSIFEX_APIKEY']}", @@ -46,7 +46,7 @@ You can run, copy, distribute, study, change and improve it. The source code and the developers are on #{link_to "GitHub", "https://github.com/openSUSE/osem"}. - - if ENV["SKYLIGHT_PUBLIC_DASHBOARD_URL"].present? + - if ENV.fetch('SKYLIGHT_PUBLIC_DASHBOARD_URL', nil) Performance data is available on #{link_to "Skylight", ENV["SKYLIGHT_PUBLIC_DASHBOARD_URL"]}. = yield :script_body diff --git a/app/views/payments/_payment.html.haml b/app/views/payments/_payment.html.haml index 56af80f7..3fa79e6b 100644 --- a/app/views/payments/_payment.html.haml +++ b/app/views/payments/_payment.html.haml @@ -22,6 +22,6 @@ = form_tag conference_payments_path do %script.stripe-button{ src: "https://checkout.stripe.com/checkout.js", data: { amount: @total_amount_to_pay.cents, label: "Pay #{humanized_money_with_symbol @total_amount_to_pay}", - email: current_user.email, currency: @total_amount_to_pay.currency, name: ENV['OSEM_NAME'] || 'OSEM', + email: current_user.email, currency: @total_amount_to_pay.currency, name: ENV.fetch('OSEM_NAME', 'OSEM'), description: "book your tickets", key: Rails.application.secrets.stripe_publishable_key, locale: "auto"}} = link_to 'Edit Purchase', conference_tickets_path(@conference.short_title), class: 'btn btn-default' diff --git a/app/views/proposals/_proposal_form.html.haml b/app/views/proposals/_proposal_form.html.haml index 3571379e..940cd286 100644 --- a/app/views/proposals/_proposal_form.html.haml +++ b/app/views/proposals/_proposal_form.html.haml @@ -9,13 +9,20 @@ .form-group = f.label :subtitle = f.text_field :subtitle, class: 'form-control' - = # speaker_selector_input f + .form-group + = f.label :speaker_ids, 'Speakers' + = f.select :speaker_ids, f.object.speakers.pluck(:username, :id), {}, { multiple: true, class: "form-control", id: "users_selectize", placeholder: "Speakers" } + %span.help-block + The people responsible for the event, beside you. You can only select existing users. - if @program.tracks.confirmed.cfp_active.any? - = f.label :track_id, 'Track' - = f.select :track_id, @program.tracks.confirmed.cfp_active.pluck(:name, :id), include_blank: '(Please select)' - = f.label :event_type_id, 'Type' - = f.select :event_type_id, event_type_select_options(@conference.program.event_types), { include_blank: false }, { class: 'select-help-toggle form-control' } + .form-group + = f.label :track_id, 'Track' + = f.select :track_id, @program.tracks.confirmed.cfp_active.pluck(:name, :id), { include_blank: '(Please select)' }, { class: 'form-control' } + .form-group + = f.label :event_type_id, 'Type' + = f.select :event_type_id, event_type_select_options(@conference.program.event_types), { include_blank: false }, { class: 'select-help-toggle form-control' } - if @program.languages.present? + .form-group = f.label :language = f.select :language, @languages, { include_blank: false}, { class: 'select-help-toggle form-control' } - @conference.program.event_types.each do |event_type| @@ -72,10 +79,5 @@ %p.text-right = f.submit 'Update Proposal', class: 'btn btn-success' -:javascript - $(document).ready(function() { - $('#event_speaker_ids').selectize({ - plugins: ['remove_button'], - maxItems: 5 - } ) - }); += render partial: 'shared/user_selectize' + diff --git a/app/views/proposals/new.html.haml b/app/views/proposals/new.html.haml index f3e93ee8..212ef458 100644 --- a/app/views/proposals/new.html.haml +++ b/app/views/proposals/new.html.haml @@ -17,7 +17,7 @@ %legend %span =link_to('#signup', role: 'tab', 'aria-controls' => 'home', 'data-toggle' => 'tab') do - = ENV['OSEM_NAME'] || 'OSEM' + = ENV.fetch('OSEM_NAME', 'OSEM') Account %span.pull-right#account-already =link_to('#signin', role: 'tab', 'aria-controls' => 'home', 'data-toggle' => 'tab') do @@ -56,9 +56,10 @@ words. = markdown_hint('[Tips to improve your presentations.](http://blog.hubspot.com/blog/tabid/6307/bid/5975/10-Rules-to-Instantly-Improve-Your-Presentations.aspx)') - if @program.cfp.enable_registrations? - .form-group - = f.label :require_registration, 'Require participants to register to your event' - = f.check_box :require_registration, class: 'form-control' + .checkbox + %label + = f.check_box :require_registration + Require participants to register to your event? %p.text-right = link_to '#description', 'data-toggle' => 'collapse', id: 'description_link' do Do you require something special for your event? diff --git a/app/views/proposals/show.html.haml b/app/views/proposals/show.html.haml index a7a155bb..a4f947fd 100644 --- a/app/views/proposals/show.html.haml +++ b/app/views/proposals/show.html.haml @@ -2,7 +2,7 @@ %meta{ property: "og:title", content: @event.title } %meta{ property: "og:url", content: conference_program_proposal_url(@conference.short_title, @event) } %meta{ property: "og:description", content: @event.abstract } - %meta{ property: "og:site_name", content: (ENV['OSEM_NAME'] || 'OSEM') } + %meta{ property: "og:site_name", content: ENV.fetch('OSEM_NAME', 'OSEM') } - if @speakers_ordered.any? %meta{ property: "og:image", content: @speakers_ordered.first.gravatar_url } %meta{ property: "og:image:secure_url", content: @speakers_ordered.first.gravatar_url } diff --git a/app/views/shared/_user_selectize.html.haml b/app/views/shared/_user_selectize.html.haml new file mode 100644 index 00000000..95f3729f --- /dev/null +++ b/app/views/shared/_user_selectize.html.haml @@ -0,0 +1,30 @@ +:javascript + $(document).ready(function() { + $('#users_selectize').selectize({ + persist: false, + create: false, + valueField: 'id', + labelField: 'username', + searchField: 'username', + load: function(query, callback) { + if (!query.length) return callback(); + $.ajax({ + url: "#{search_users_path}.json", + type: 'GET', + dataType: 'json', + data: { + query: query, + }, + error: function(res) { + console.log("selectize error"); + callback(); + }, + success: function(res) { + console.log("selectize success"); + // console.log(res); + callback(res.users); + } + }); + } + }); + }); diff --git a/bin/bundle b/bin/bundle index 96131dad..1c6e5116 100755 --- a/bin/bundle +++ b/bin/bundle @@ -18,7 +18,7 @@ m = Module.new do end def env_var_version - ENV['BUNDLER_VERSION'] + ENV.fetch('BUNDLER_VERSION', nil) end def cli_arg_version @@ -40,7 +40,7 @@ m = Module.new do end def gemfile - gemfile = ENV['BUNDLE_GEMFILE'] + gemfile = ENV.fetch('BUNDLE_GEMFILE', nil) return gemfile if gemfile && !gemfile.empty? File.expand_path('../../Gemfile', __FILE__) diff --git a/config/database.yml b/config/database.yml index dd8ac693..96ef1936 100644 --- a/config/database.yml +++ b/config/database.yml @@ -1,19 +1,19 @@ <% encoding = 'unicode' - if ENV['OSEM_DB_ADAPTER'] == 'mysql2' + if ENV.fetch('OSEM_DB_ADAPTER', nil) == 'mysql2' encoding = 'utf8' end %> default: &default - adapter: <%= ENV['OSEM_DB_ADAPTER'] || 'postgresql' %> + adapter: <%= ENV.fetch('OSEM_DB_ADAPTER', 'postgresql') %> encoding: <%= encoding %> - host: <%= ENV['OSEM_DB_HOST'] || 'database' %> - port: <%= ENV['OSEM_DB_PORT'] || '5432' %> - username: <%= ENV['OSEM_DB_USER'] || 'postgres' %> - password: <%= ENV['OSEM_DB_PASSWORD'] || 'mysecretpassword' %> - database: <%= ENV['OSEM_DB_NAME'] || 'postgres' %> + host: <%= ENV.fetch('OSEM_DB_HOST', 'database') %> + port: <%= ENV.fetch('OSEM_DB_PORT', '5432') %> + username: <%= ENV.fetch('OSEM_DB_USER', 'postgres') %> + password: <%= ENV.fetch('OSEM_DB_PASSWORD', 'mysecretpassword') %> + database: <%= ENV.fetch('OSEM_DB_NAME', 'postgres') %> pool: 5 timeout: 5000 diff --git a/config/deploy.rb b/config/deploy.rb index 8519deb5..af9ebaf4 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -19,7 +19,7 @@ set :branch, OSEM_DEPLOY_BRANCH # Shared dirs and files will be symlinked into the app-folder by the 'deploy:link_shared_paths' step. # Some plugins already add folders to shared_dirs like `mina/rails` add `public/assets`, `vendor/bundle` and many more # run `mina -d` to see all folders and files already included in `shared_dirs` and `shared_files` -set :shared_dirs, fetch(:shared_dirs, []).push('public/system') +set :shared_dirs, fetch(:shared_dirs, []).push('public/system', '.bundle', 'tmp/pids') set :shared_files, fetch(:shared_files, []).push('.env.production') desc "Deploys the current version to the server." @@ -36,8 +36,7 @@ task :deploy do on :launch do in_path(fetch(:current_path)) do - command %{mkdir -p tmp/} - command %{touch tmp/restart.txt} + command %{sudo systemctl restart osem} command %{sudo systemctl restart osem-dj} end end diff --git a/config/environments/development.rb b/config/environments/development.rb index 7c66d30e..0397ea88 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -55,7 +55,7 @@ Rails.application.configure do # config.action_view.annotate_rendered_view_with_filenames = true # Set the detault url for action mailer - config.action_mailer.default_url_options = { host: (ENV['OSEM_HOSTNAME'] || 'localhost:3000') } + config.action_mailer.default_url_options = { host: ENV.fetch('OSEM_HOSTNAME', 'localhost:3000') } # Access all mails sent at http://localhost:3000/letter_opener config.action_mailer.delivery_method = :letter_opener diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 76f615a0..69c2d9e3 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -7,16 +7,16 @@ Devise.setup do |config| # Pass each provider to User model in :omniauth_providers (for open_id providers use their name) config.omniauth :open_id, name: 'suse', identifier: 'http://www.opensuse.org/openid/user' - config.omniauth :google_oauth2, (ENV['OSEM_GOOGLE_KEY'] || Rails.application.secrets.google_key), (ENV['OSEM_GOOGLE_SECRET'] || Rails.application.secrets.google_secret), + config.omniauth :google_oauth2, ENV.fetch('OSEM_GOOGLE_KEY', Rails.application.secrets.google_key), ENV.fetch('OSEM_GOOGLE_SECRET', Rails.application.secrets.google_secret), name: 'google', scope: 'email' - config.omniauth :facebook, (ENV['OSEM_FACEBOOK_KEY'] || Rails.application.secrets.facebook_key), (ENV['OSEM_FACEBOOK_SECRET'] || Rails.application.secrets.facebook_secret) - config.omniauth :github, (ENV['OSEM_GITHUB_KEY'] || Rails.application.secrets.github_key), (ENV['OSEM_GITHUB_SECRET'] || Rails.application.secrets.github_secret) + config.omniauth :facebook, ENV.fetch('OSEM_FACEBOOK_KEY', Rails.application.secrets.facebook_key), ENV.fetch('OSEM_FACEBOOK_SECRET', Rails.application.secrets.facebook_secret) + config.omniauth :github, ENV.fetch('OSEM_GITHUB_KEY', Rails.application.secrets.github_key), ENV.fetch('OSEM_GITHUB_SECRET', Rails.application.secrets.github_secret) # ==> Mailer Configuration # Configure the e-mail address which will be shown in Devise::Mailer, # note that it will be overwritten if you use your own mailer class with default "from" parameter. - config.mailer_sender = ENV['OSEM_EMAIL_ADDRESS'] || 'no-reply@localhost' + config.mailer_sender = ENV.fetch('OSEM_EMAIL_ADDRESS', 'no-reply@localhost') # Configure the class responsible to send e-mails. # config.mailer = "Devise::Mailer" diff --git a/config/piwik.yml b/config/piwik.yml index 9b92a97c..afc903a1 100644 --- a/config/piwik.yml +++ b/config/piwik.yml @@ -13,9 +13,9 @@ default: &default id_site: <%= ENV['OSEM_PIWIK_ID'] %> url: <%= ENV['OSEM_PIWIK_URL'] %> - use_async: <%= ENV['OSEM_PIWIK_ASYNC'] || false %> - disabled: <%= ENV['OSEM_PIWIK_DISABLED'] || true %> - hostname: <%= ENV['OSEM_PIWIK_HOSTNAME'] || 'localhost' %> + use_async: <%= ENV.fetch('OSEM_PIWIK_ASYNC', false) %> + disabled: <%= ENV.fetch('OSEM_PIWIK_DISABLED', true) %> + hostname: <%= ENV.fetch('OSEM_PIWIK_HOSTNAME', 'localhost') %> production: piwik: diff --git a/config/puma.rb b/config/puma.rb index c867218c..208cea5d 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -4,33 +4,27 @@ # the maximum value specified for Puma. Default is set to 5 threads for minimum # and maximum; this matches the default thread size of Active Record. # -max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } -min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count } -threads min_threads_count, max_threads_count - -# Specifies the `worker_timeout` threshold that Puma will use to wait before -# terminating a worker in development environments. -# -worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development" +threads_count = ENV.fetch('RAILS_MAX_THREADS') { 5 } +threads threads_count, threads_count # Specifies the `port` that Puma will listen on to receive requests; default is 3000. # -port ENV.fetch("PORT") { 3000 } +port ENV.fetch('PORT') { 3000 } # Specifies the `environment` that Puma will run in. # -environment ENV.fetch("RAILS_ENV") { "development" } +environment ENV.fetch('RAILS_ENV') { 'development' } # Specifies the `pidfile` that Puma will use. pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } # Specifies the number of `workers` to boot in clustered mode. -# Workers are forked web server processes. If using threads and workers together +# Workers are forked webserver processes. If using threads and workers together # the concurrency of the application would be max `threads` * `workers`. # Workers do not work on JRuby or Windows (both of which do not support # processes). # -workers ENV.fetch("WEB_CONCURRENCY") { 2 } +workers ENV.fetch('WEB_CONCURRENCY') { 2 } # Use the `preload_app!` method when specifying a `workers` number. # This directive tells Puma to first boot the application and load code @@ -40,4 +34,4 @@ workers ENV.fetch("WEB_CONCURRENCY") { 2 } preload_app! # Allow puma to be restarted by `rails restart` command. -plugin :tmp_restart +plugin 'tmp_restart' diff --git a/config/routes.rb b/config/routes.rb index 4ac25755..5865281d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -5,7 +5,7 @@ Osem::Application.routes.draw do get '/', to: 'conferences#show' end - if ENV['OSEM_ICHAIN_ENABLED'] == 'true' + if ENV.fetch('OSEM_ICHAIN_ENABLED', nil) == 'true' devise_for :users, controllers: { registrations: :registrations } else devise_for :users, @@ -225,8 +225,8 @@ Osem::Application.routes.draw do get '/calendar' => 'conferences#calendar' - unless ENV['OSEM_ROOT_CONFERENCE'].blank? - root to: redirect("/conferences/#{ENV['OSEM_ROOT_CONFERENCE']}") + if ENV.fetch('OSEM_ROOT_CONFERENCE', nil) + root to: redirect("/conferences/#{ENV.fetch('OSEM_ROOT_CONFERENCE')}") else root to: 'conferences#index', via: [:get, :options] end diff --git a/dotenv.example b/dotenv.example index a93a5c4c..372800ec 100644 --- a/dotenv.example +++ b/dotenv.example @@ -32,8 +32,8 @@ # OSEM_MEMCACHED_USERNAME='root' # OSEM_MEMCACHED_PASSWORD='1234' -# Set this if you want to deviate from our 'standar' ruby version -# OSEM_RUBY_VERSION=3.1.0 +# Set this if you want to deviate from our 'standard' ruby version +# OSEM_RUBY_VERSION=3.1.2 # What time is it? # OSEM_TIME_ZONE="UTC" diff --git a/spec/controllers/admin/tracks_controller_spec.rb b/spec/controllers/admin/tracks_controller_spec.rb index f51f1dda..92da7c77 100644 --- a/spec/controllers/admin/tracks_controller_spec.rb +++ b/spec/controllers/admin/tracks_controller_spec.rb @@ -22,8 +22,8 @@ describe Admin::TracksController do it 'assigns @tracks with the correct values' do expect(assigns(:tracks).length).to eq 2 - expect(assigns(:tracks).include?(track)).to eq true - expect(assigns(:tracks).include?(self_organized_track)).to eq true + expect(assigns(:tracks).include?(track)).to be true + expect(assigns(:tracks).include?(self_organized_track)).to be true end it 'renders the index template' do @@ -52,7 +52,7 @@ describe Admin::TracksController do it 'assigns a new track with the correct conference' do expect(assigns(:track)).to be_a Track - expect(assigns(:track).new_record?).to eq true + expect(assigns(:track).new_record?).to be true expect(assigns(:track).program_id).to eq conference.program.id end @@ -69,7 +69,7 @@ describe Admin::TracksController do it 'assigns a new track with the correct conference' do expect(assigns(:track)).to be_a Track - expect(assigns(:track).new_record?).to eq false + expect(assigns(:track).new_record?).to be false expect(assigns(:track).program_id).to eq conference.program.id end @@ -87,7 +87,7 @@ describe Admin::TracksController do it 'the new track has the correct attributes' do expect(assigns(:track).state).to eq 'confirmed' - expect(assigns(:track).cfp_active).to eq true + expect(assigns(:track).cfp_active).to be true end end @@ -99,7 +99,7 @@ describe Admin::TracksController do it 'assigns a new track with the correct conference' do expect(assigns(:track)).to be_a Track - expect(assigns(:track).new_record?).to eq true + expect(assigns(:track).new_record?).to be true expect(assigns(:track).program_id).to eq conference.program.id end @@ -112,7 +112,7 @@ describe Admin::TracksController do end it 'does not create a new track' do - expect(conference.program.tracks.find_by(short_name: 'my_track')).to eq nil + expect(conference.program.tracks.find_by(short_name: 'my_track')).to be_nil end end end @@ -199,7 +199,7 @@ describe Admin::TracksController do end it 'deletes the track' do - expect(Track.find_by(id: track)).to eq nil + expect(Track.find_by(id: track)).to be_nil end end @@ -249,7 +249,7 @@ describe Admin::TracksController do end it 'becomes true' do - expect(self_organized_track.cfp_active).to eq true + expect(self_organized_track.cfp_active).to be true end end @@ -269,7 +269,7 @@ describe Admin::TracksController do end it 'stays false' do - expect(self_organized_track.cfp_active).to eq false + expect(self_organized_track.cfp_active).to be false end end end @@ -295,7 +295,7 @@ describe Admin::TracksController do end it 'becomes false' do - expect(self_organized_track.cfp_active).to eq false + expect(self_organized_track.cfp_active).to be false end end @@ -315,7 +315,7 @@ describe Admin::TracksController do end it 'stays true' do - expect(self_organized_track.cfp_active).to eq true + expect(self_organized_track.cfp_active).to be true end end end diff --git a/spec/controllers/admin/users_controller_spec.rb b/spec/controllers/admin/users_controller_spec.rb index bf5d125e..39b6c401 100644 --- a/spec/controllers/admin/users_controller_spec.rb +++ b/spec/controllers/admin/users_controller_spec.rb @@ -8,7 +8,7 @@ describe Admin::UsersController do sign_in(admin) end describe 'GET #index' do - xit 'sets up users array with existing users records' do + it 'sets up users array with existing users records' do user1 = create(:user, email: 'user1@email.osem') user2 = create(:user, email: 'user2@email.osem') user_deleted = User.find_by!(username: 'deleted_user') @@ -25,12 +25,12 @@ describe Admin::UsersController do user_to_confirm = create(:user, email: 'unconfirmed_user@osem.io', confirmed_at: nil) patch :toggle_confirmation, params: { id: user_to_confirm.id, user: { to_confirm: 'true' } } user_to_confirm.reload - expect(user_to_confirm.confirmed?).to eq true + expect(user_to_confirm.confirmed?).to be true end it 'undo confirmation of user' do patch :toggle_confirmation, params: { id: user.id, user: { to_confirm: 'false' } } user.reload - expect(user.confirmed?).to eq false + expect(user.confirmed?).to be false end end describe 'PATCH #update' do diff --git a/spec/controllers/admin/versions_controller_spec.rb b/spec/controllers/admin/versions_controller_spec.rb index 654909db..c44ba2c4 100644 --- a/spec/controllers/admin/versions_controller_spec.rb +++ b/spec/controllers/admin/versions_controller_spec.rb @@ -31,7 +31,7 @@ describe Admin::VersionsController do expect(flash[:error]).to match('The item is already in the state that you are trying to revert it back to') end - it 'reverting deletion of object creates it again' do + it 'reverting deletion of object creates it again' do event_type = conference.program.event_types.first event_type.destroy event_types_count = conference.program.event_types.count @@ -41,7 +41,7 @@ describe Admin::VersionsController do expect(conference.program.event_types.count).to eq(event_types_count + 1) end - it 'reverting creation of object deletes it ' do + it 'reverting creation of object deletes it' do lodging = create(:lodging, conference: conference) get :revert_object, params: { id: lodging.versions.last.id } expect(lodging.versions.last.event).to eq 'destroy' @@ -131,8 +131,8 @@ describe Admin::VersionsController do sign_in @user get :index, params: { conference_id: conference.short_title } - expect(assigns(:versions).include?(@version_cfp)).to eq true - expect(assigns(:versions).include?(@version_organizer)).to eq false + expect(assigns(:versions).include?(@version_cfp)).to be true + expect(assigns(:versions).include?(@version_organizer)).to be false end it 'when user has role info_desk' do @@ -140,9 +140,9 @@ describe Admin::VersionsController do sign_in @user get :index, params: { conference_id: conference.short_title } - expect(assigns(:versions).include?(@version_info_desk)).to eq true - expect(assigns(:versions).include?(@version_organizer)).to eq false - expect(assigns(:versions).include?(@version_cfp)).to eq false + expect(assigns(:versions).include?(@version_info_desk)).to be true + expect(assigns(:versions).include?(@version_organizer)).to be false + expect(assigns(:versions).include?(@version_cfp)).to be false end it 'when user has role organizer' do @@ -150,9 +150,9 @@ describe Admin::VersionsController do sign_in @user get :index, params: { conference_id: conference.short_title } - expect(assigns(:versions).include?(@version_organizer)).to eq true - expect(assigns(:versions).include?(@version_cfp)).to eq true - expect(assigns(:versions).include?(@version_info_desk)).to eq true + expect(assigns(:versions).include?(@version_organizer)).to be true + expect(assigns(:versions).include?(@version_cfp)).to be true + expect(assigns(:versions).include?(@version_info_desk)).to be true end end end diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb index 8ebf4a40..87b38e35 100644 --- a/spec/controllers/application_controller_spec.rb +++ b/spec/controllers/application_controller_spec.rb @@ -33,46 +33,5 @@ describe ApplicationController, type: :controller do end end end - end - -end - -describe ApplicationController, type: :request do - let(:conference) { create(:conference) } - - describe 'Skylight link' do - - around do |example| - original_value = ENV['SKYLIGHT_PUBLIC_DASHBOARD_URL'] - example.run - ENV['SKYLIGHT_PUBLIC_DASHBOARD_URL'] = original_value - end - - context 'when SKYLIGHT_PUBLIC_DASHBOARD_URL is set' do - before do - ENV['SKYLIGHT_PUBLIC_DASHBOARD_URL'] = 'https://oss.skylight.io/app/applications/my-osem' - end - - it 'should include a link to view performance data' do - get '/' - expect(response.body).to match(/Performance data/i) - expect(response.body).to include('https://oss.skylight.io/app/applications/my-osem') - end - end - - context 'when SKYLIGHT_PUBLIC_DASHBOARD_URL is not set' do - before do - ENV['SKYLIGHT_PUBLIC_DASHBOARD_URL'] = nil - end - - it 'should not include a link to view performance data' do - get '/' - expect(response.body).to_not match(/performance data/i) - expect(response.body).to_not match(/skylight/i) - end - end - - end - end diff --git a/spec/controllers/confirmations_controller_spec.rb b/spec/controllers/confirmations_controller_spec.rb index 60675d47..6b8718ef 100644 --- a/spec/controllers/confirmations_controller_spec.rb +++ b/spec/controllers/confirmations_controller_spec.rb @@ -13,7 +13,7 @@ describe ConfirmationsController do it 'confirms and signs in user' do get :show, params: { confirmation_token: user.confirmation_token } user.reload - expect(user.confirmed?).to eq true + expect(user.confirmed?).to be true expect(controller.current_user).to eq user end end @@ -24,7 +24,7 @@ describe ConfirmationsController do it 'confirms user' do get :show, params: { confirmation_token: user.confirmation_token } user.reload - expect(user.confirmed?).to eq true + expect(user.confirmed?).to be true end end end diff --git a/spec/controllers/tracks_controller_spec.rb b/spec/controllers/tracks_controller_spec.rb index 3216e8d0..e3637f4e 100644 --- a/spec/controllers/tracks_controller_spec.rb +++ b/spec/controllers/tracks_controller_spec.rb @@ -20,8 +20,8 @@ describe TracksController do it 'assigns @tracks with the correct values' do expect(assigns(:tracks).length).to eq 1 - expect(assigns(:tracks).include?(regular_track)).to eq false - expect(assigns(:tracks).include?(self_organized_track)).to eq true + expect(assigns(:tracks).include?(regular_track)).to be false + expect(assigns(:tracks).include?(self_organized_track)).to be true end it 'renders the index template' do @@ -50,7 +50,7 @@ describe TracksController do it 'assigns a new track with the correct conference' do expect(assigns(:track)).to be_a Track - expect(assigns(:track).new_record?).to eq true + expect(assigns(:track).new_record?).to be true expect(assigns(:track).program_id).to eq conference.program.id end @@ -74,14 +74,14 @@ describe TracksController do end it 'creates new track' do - expect(assigns(:track).new_record?).to eq false + expect(assigns(:track).new_record?).to be false end it 'the new tracks has the correct attributes' do expect(assigns(:track).program_id).to eq conference.program.id expect(assigns(:track).submitter).to eq user expect(assigns(:track).state).to eq 'new' - expect(assigns(:track).cfp_active).to eq false + expect(assigns(:track).cfp_active).to be false end end @@ -93,7 +93,7 @@ describe TracksController do it 'assigns a new track with the correct conference' do expect(assigns(:track)).to be_a Track - expect(assigns(:track).new_record?).to eq true + expect(assigns(:track).new_record?).to be true expect(assigns(:track).program_id).to eq conference.program.id end @@ -106,7 +106,7 @@ describe TracksController do end it 'does not create a new track' do - expect(conference.program.tracks.find_by(short_name: 'my_track')).to eq nil + expect(conference.program.tracks.find_by(short_name: 'my_track')).to be_nil end end end diff --git a/spec/datatables/user_datatable_spec.rb b/spec/datatables/user_datatable_spec.rb index 89c2b7e3..23d660db 100644 --- a/spec/datatables/user_datatable_spec.rb +++ b/spec/datatables/user_datatable_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' describe UserDatatable do subject! do - described_class.new(view) + described_class.new({}, view_context: view) end let(:data_cols) do @@ -95,22 +95,18 @@ describe UserDatatable do let(:output) { subject.as_json } it 'recordsTotal' do - skip('This fails since Ruby 2.5.8') expect(output[:recordsTotal]).to eq(1) end it 'recordsFiltered' do - skip('This fails since Ruby 2.5.8') expect(output[:recordsFiltered]).to eq(1) end it 'data length' do - skip('This fails since Ruby 2.5.8') expect(output[:data].length).to eq(1) end it 'has expected data columns' do - skip('This fails since Ruby 2.5.8') expect(output[:data].first.keys).to eq(data_cols) end @@ -118,32 +114,26 @@ describe UserDatatable do let(:user_data) { output[:data].first } it 'id' do - skip('This fails since Ruby 2.5.8') expect(user_data[:id].to_i).to eq(user.id) end it 'name' do - skip('This fails since Ruby 2.5.8') expect(user_data[:name]).to eq(user.name) end it 'email' do - skip('This fails since Ruby 2.5.8') expect(user_data[:email]).to eq(user.email) end it 'confirmed_at' do - skip('This fails since Ruby 2.5.8') expect(Date.parse(user_data[:confirmed_at])).to eq(user.confirmed_at.to_date) end it 'attended' do - skip('This fails since Ruby 2.5.8') expect(user_data[:attended].to_i).to eq(user.attended_count) end it 'roles' do - skip('This fails since Ruby 2.5.8') expect(user_data[:roles]).to eq('None') end end diff --git a/spec/factories/surveys.rb b/spec/factories/surveys.rb index cf44f7ed..c95a9d27 100644 --- a/spec/factories/surveys.rb +++ b/spec/factories/surveys.rb @@ -3,8 +3,6 @@ FactoryBot.define do factory :survey do title { 'This is my survey' } - start_date { Date.current - 1.day } - end_date { Date.current + 1.day } factory :conference_survey do association :surveyable, factory: :conference diff --git a/spec/features/base_controller_spec.rb b/spec/features/base_controller_spec.rb index 0be5b5a3..3392cce3 100644 --- a/spec/features/base_controller_spec.rb +++ b/spec/features/base_controller_spec.rb @@ -19,7 +19,7 @@ feature 'BaseController' do end end - context 'when user is ' do + context 'when user is' do before(:each) do sign_in(user) end diff --git a/spec/features/conference_spec.rb b/spec/features/conference_spec.rb index abd253c7..39d5106f 100644 --- a/spec/features/conference_spec.rb +++ b/spec/features/conference_spec.rb @@ -34,7 +34,7 @@ feature Conference do expect(Conference.count).to eq(expected_count) expect(Conference.last.organization).to eq(organization) user.reload - expect(user.has_cached_role? :organizer, Conference.last).to eq(true) + expect(user.has_cached_role? :organizer, Conference.last).to be(true) end scenario 'update conference', feature: true, js: true do diff --git a/spec/features/omniauth_spec.rb b/spec/features/omniauth_spec.rb index 3594bc32..83940dc1 100644 --- a/spec/features/omniauth_spec.rb +++ b/spec/features/omniauth_spec.rb @@ -71,7 +71,7 @@ feature Openid do expect(flash).to eq('test-participant-1@example.com signed in successfully with google') expect(Openid.count).to eq(expected_count_openid) expect(User.count).to eq(expected_count_user) - expect(Openid.where(email: 'test-1@example.com').first.nil?).to eq(false) + expect(Openid.where(email: 'test-1@example.com').first.nil?).to be(false) end scenario 'signs in with openID using the same email as another associated openid' do @@ -105,8 +105,8 @@ feature Openid do page.find('#flash .close').click expect(Openid.count).to eq(expected_count_openid) expect(User.count).to eq(expected_count_user) - expect(Openid.where(email: 'test-participant-1@example.com').first.nil?).to eq(false) - expect(Openid.where(email: 'test-1@example.com').first.nil?).to eq(false) + expect(Openid.where(email: 'test-participant-1@example.com').first.nil?).to be(false) + expect(Openid.where(email: 'test-1@example.com').first.nil?).to be(false) # Sign in with different openID using same email (test-1@gmail.com) sign_out @@ -131,8 +131,8 @@ feature Openid do shared_examples 'sign up with openid' do |provider| scenario "has option to sign in with #{provider}" do visit '/accounts/sign_up' - expect(page.has_content?('or sign in using')).to eq true - expect(page.has_link?("omniauth-#{provider}")).to eq true + expect(page.has_content?('or sign in using')).to be true + expect(page.has_link?("omniauth-#{provider}")).to be true end scenario "sign up with #{provider}" do diff --git a/spec/features/roles_spec.rb b/spec/features/roles_spec.rb index b08e0398..a76387a6 100644 --- a/spec/features/roles_spec.rb +++ b/spec/features/roles_spec.rb @@ -37,7 +37,7 @@ feature Role do visit admin_conference_roles_path(conference.short_title) end scenario "role #{role_name}" do - expect(page.has_link?('Edit', href: edit_admin_conference_role_path(conference.short_title, role_name))).to eq false + expect(page.has_link?('Edit', href: edit_admin_conference_role_path(conference.short_title, role_name))).to be false end end @@ -60,7 +60,7 @@ feature Role do click_button 'Add' user_with_no_role.reload - expect(user_with_no_role.has_cached_role?(role.name, conference)).to eq true + expect(user_with_no_role.has_cached_role?(role.name, conference)).to be true end scenario "removes role #{role_name}", feature: true, js: true do @@ -72,7 +72,7 @@ feature Role do expect(page).to have_css('.alert', text: "Successfully removed role #{role_name} from user #{user_with_role.email}") expect(by_role_name).to eq(role_name) | eq('organizer') user_with_role.reload - expect(user_with_role.has_cached_role?(role_name, conference)).to eq false + expect(user_with_role.has_cached_role?(role_name, conference)).to be false end end @@ -91,13 +91,13 @@ feature Role do scenario "add role #{role_name}", feature: true, js: true do click_link('Users', href: admin_conference_role_path(conference.short_title, role_name)) - expect(page.has_field?('user_email')).to eq false + expect(page.has_field?('user_email')).to be false end scenario "remove role #{role_name}", feature: true, js: true do click_link('Users', href: admin_conference_role_path(conference.short_title, role_name)) - expect(first('td').has_css?('.bootstrap-switch-container')).to eq false + expect(first('td').has_css?('.bootstrap-switch-container')).to be false end end @@ -121,7 +121,7 @@ feature Role do click_button 'Add' user_with_no_role.reload - expect(user_with_no_role.has_cached_role?('organization_admin', organization)).to eq true + expect(user_with_no_role.has_cached_role?('organization_admin', organization)).to be true end scenario 'successfully removes role organization_admin' do @@ -129,7 +129,7 @@ feature Role do first('tr').find('.btn-danger').click organization_admin.reload - expect(organization_admin.has_cached_role?('organization_admin', organization)).to eq false + expect(organization_admin.has_cached_role?('organization_admin', organization)).to be false end end @@ -137,12 +137,12 @@ feature Role do scenario 'does not successfully add role organization_admin' do click_link('Admins', href: admins_admin_organization_path(other_organization.id)) - expect(page.has_field?('user_email')).to eq false + expect(page.has_field?('user_email')).to be false end scenario 'does not successfully removes role organization_admin' do click_link('Admins', href: admins_admin_organization_path(other_organization.id)) - expect(page.has_css?('.btn-danger')).to eq false + expect(page.has_css?('.btn-danger')).to be false end end end diff --git a/spec/features/surveys_spec.rb b/spec/features/surveys_spec.rb new file mode 100644 index 00000000..927c23fc --- /dev/null +++ b/spec/features/surveys_spec.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true + +require 'spec_helper' + +feature Survey do + let(:conference) { create(:conference) } + + context 'as an organizer' do + let(:organizer) { create(:organizer, resource: conference) } + + before :each do + sign_in organizer + end + + scenario 'create a survey', feature: true, js: true do + visit admin_conference_path(conference) + click_link 'Surveys' + click_link 'New' + fill_in 'Title', with: 'Example Survey' + click_button 'Create Survey' + expect(flash).to eq('Successfully created survey') + + fill_in :survey_question_title, with: 'Example question' + select 'boolean', from: 'Type of Question:', visible: false # Hidden by bootstrap-select + click_button 'Create Survey question' + expect(flash).to eq('Successfully created Survey Question.') + end + end + + context 'as an attendee' do + let(:attendee) { create(:user) } + + before :each do + sign_in attendee + end + + scenario 'respond to a survey during registration', feature: true, js: true do + create :registration_period, conference: conference + create :registration, conference: conference, user: attendee + survey = create(:survey, surveyable: conference, target: :during_registration) + create :boolean_mandatory, survey: survey + + visit conference_conference_registration_path(conference) + expect(find(:link, survey.title).sibling('.fa')[:title]).to eq('Please fill out the survey') + + click_link survey.title + choose 'Yes' + click_button 'Submit' + expect(flash).to eq('Successfully responded to survey.') + + visit conference_conference_registration_path(conference) + expect(find(:link, survey.title).sibling('.fa')[:title]).to eq('Thank you for filling out the survey') + end + end +end diff --git a/spec/features/tracks_spec.rb b/spec/features/tracks_spec.rb index 1e43365a..7bebc19d 100644 --- a/spec/features/tracks_spec.rb +++ b/spec/features/tracks_spec.rb @@ -90,8 +90,8 @@ feature Track do expected.to change { Track.count }.by 1 expect(flash).to eq('Track request successfully created.') within('table#tracks') do - expect(page.has_content?('Distribution')).to eq true - expect(page.has_content?('Events about our Linux dist...')).to eq true + expect(page.has_content?('Distribution')).to be true + expect(page.has_content?('Events about our Linux dist...')).to be true end end @@ -111,8 +111,8 @@ feature Track do expected.to_not(change { Track.count }) expect(flash).to eq("Track #{track.name} withdrawn.") within('table#tracks') do - expect(page.has_content?(track.name)).to eq true - expect(page.has_link?('Re-Submit')).to eq true + expect(page.has_content?(track.name)).to be true + expect(page.has_link?('Re-Submit')).to be true end end @@ -134,8 +134,8 @@ feature Track do expected.to_not(change { Track.count }) expect(flash).to eq('Track request successfully updated.') within('table#tracks') do - expect(page.has_content?('Distribution')).to eq true - expect(page.has_content?('Events about our Linux dist...')).to eq true + expect(page.has_content?('Distribution')).to be true + expect(page.has_content?('Events about our Linux dist...')).to be true end end end diff --git a/spec/features/versions_spec.rb b/spec/features/versions_spec.rb index f246fb09..bc1ebf89 100644 --- a/spec/features/versions_spec.rb +++ b/spec/features/versions_spec.rb @@ -231,30 +231,31 @@ feature 'Version' do expect(page).to have_text("Someone (probably via the console) deleted difficulty level Expert with ID #{difficulty_level_id} in conference #{conference.short_title}") end - xscenario 'display changes in splashpages', feature: true, versioning: true, js: true do + scenario 'display changes in splashpages', feature: true, versioning: true, js: true do visit admin_conference_splashpage_path(conference.short_title) click_link 'Create Splashpage' - click_button 'Save Changes' + click_button 'Save' - click_link 'Edit' - uncheck('Display the program') - uncheck('Display call for papers and call for tracks, while open') - uncheck('Display the venue') - uncheck('Display tickets') - uncheck('Display the lodgings') - uncheck('Display sponsors') - uncheck('Display social media links') + click_link 'Configure' + check('Display the program?') + check('Display call for papers and call for tracks?') + check('Display the venue?') + check('Display the tickets?') + check('Display the lodgings?') + check('Display the sponsors?') + check('Display the social media links?') check('Make splash page public?') - click_button 'Save Changes' + click_button 'Save' + splashpage_id = conference.splashpage.id click_link 'Delete' page.accept_alert expect(page).to have_text('Splashpage was successfully destroyed') visit admin_revision_history_path - expect(page).to have_text("#{organizer.name} created new splashpage in conference #{conference.short_title}") - expect(page).to have_text("#{organizer.name} updated public, include program, include cfp, include venue, include tickets, include lodgings, include sponsors and include social media of splashpage in conference #{conference.short_title}") - expect(page).to have_text("#{organizer.name} deleted splashpage in conference #{conference.short_title}") + expect(page).to have_text("#{organizer.name} created new splashpage with ID #{splashpage_id} in conference #{conference.short_title}") + expect(page).to have_text("#{organizer.name} updated public, include program, include social media, include venue, include tickets, include sponsors, include lodgings and include cfp of splashpage with ID #{splashpage_id} in conference #{conference.short_title}") + expect(page).to have_text("#{organizer.name} deleted splashpage with ID #{splashpage_id} in conference #{conference.short_title}") end scenario 'displays users subscribe/unsubscribe to conferences', feature: true, versioning: true, js: true do @@ -344,7 +345,6 @@ feature 'Version' do end scenario 'display changes in users_role for conference role', feature: true, versioning: true, js: true do - skip('fails since paper_trail 12.2.0') user = create(:user) role = Role.find_by(name: 'cfp', resource_id: conference.id, resource_type: 'Conference') user.add_role :cfp, conference diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 95d87059..5a036ebc 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -36,29 +36,29 @@ describe ApplicationHelper, type: :helper do describe 'does return correct concurrent events' do it 'when events starts at the same time' do - expect(concurrent_events(event).include?(@other_event)).to eq true + expect(concurrent_events(event).include?(@other_event)).to be true end it 'when event is in between the other event' do @event_schedule.update_attribute(:start_time, @other_event_schedule.start_time + 10.minutes) - expect(concurrent_events(event).include?(@other_event)).to eq true + expect(concurrent_events(event).include?(@other_event)).to be true end end - describe 'does not return as concurrent event ' do + describe 'does not return as concurrent event' do it 'when event is not scheduled' do @event_schedule.destroy - expect(concurrent_events(event).present?).to eq false + expect(concurrent_events(event).present?).to be false end it 'when one event starts and other ends at the same time' do @event_schedule.update_attribute(:start_time, @other_event_schedule.end_time) - expect(concurrent_events(event).present?).to eq false + expect(concurrent_events(event).present?).to be false end it 'when conference program does not have a selected schedule' do conference.program.update_attribute(:selected_schedule_id, nil) - expect(concurrent_events(event).present?).to eq false + expect(concurrent_events(event).present?).to be false end end @@ -68,11 +68,6 @@ describe ApplicationHelper, type: :helper do expect(nav_root_link_for(nil)).to match 'OSEM' end - it 'should use the environment variable' do - ENV['OSEM_NAME'] = Faker::Company.name + "'" - expect(nav_root_link_for(nil)).to match h(ENV['OSEM_NAME']) - end - it 'should use the conference organization name' do expect(nav_root_link_for(conference)).to match h(conference.organization.name) end diff --git a/spec/helpers/date_time_helper_spec.rb b/spec/helpers/date_time_helper_spec.rb index 6cbd34de..f77e585e 100644 --- a/spec/helpers/date_time_helper_spec.rb +++ b/spec/helpers/date_time_helper_spec.rb @@ -6,7 +6,7 @@ describe DateTimeHelper, type: :helper do describe 'format_datetime' do it 'returns nothing if there is no parameter' do - expect(format_datetime(nil)).to eq nil + expect(format_datetime(nil)).to be_nil end it 'returns formatted string' do diff --git a/spec/helpers/format_helper_spec.rb b/spec/helpers/format_helper_spec.rb index dc364c2c..4e64eb94 100644 --- a/spec/helpers/format_helper_spec.rb +++ b/spec/helpers/format_helper_spec.rb @@ -9,11 +9,11 @@ describe FormatHelper, type: :helper do expect(markdown(nil)).to eq '' end - it 'should return HTML for header markdown' do - expect(Redcarpet::Markdown).to receive(:new) - .with(Redcarpet::Render::HTML, autolink: true, space_after_headers: true, no_intra_emphasis: true, fenced_code_blocks: true, disable_indented_code_blocks: true, safe_links_only: true) - .and_call_original + it "doesn't render links with unsafe URI schemes" do + expect(markdown('[a](javascript:b)')).to eq "

[a](javascript:b)

\n" + end + it 'should return HTML for header markdown' do expect(markdown('# this is my header')).to eq "

this is my header

\n" end end diff --git a/spec/models/cfp_spec.rb b/spec/models/cfp_spec.rb index 74d16907..5b405a07 100644 --- a/spec/models/cfp_spec.rb +++ b/spec/models/cfp_spec.rb @@ -21,7 +21,7 @@ describe Cfp do it 'returns nil when the cfp for events doesn\'t exist' do cfp.destroy! - expect(conference.program.cfps.for_events).to eq nil + expect(conference.program.cfps.for_events).to be_nil end end @@ -32,7 +32,7 @@ describe Cfp do end it 'returns nil when the cfp for tracks doesn\'t exist' do - expect(conference.program.cfps.for_tracks).to eq nil + expect(conference.program.cfps.for_tracks).to be_nil end end @@ -81,24 +81,24 @@ describe Cfp do describe 'returns true' do it 'when end_date changed' do cfp.end_date = Date.today - expect(cfp.start_date_changed?).to eq false - expect(cfp.end_date_changed?).to eq true - expect(cfp.notify_on_cfp_date_update?).to eq true + expect(cfp.start_date_changed?).to be false + expect(cfp.end_date_changed?).to be true + expect(cfp.notify_on_cfp_date_update?).to be true end it 'when start_date changed' do cfp.start_date = Date.today - expect(cfp.end_date_changed?).to eq false - expect(cfp.start_date_changed?).to eq true - expect(cfp.notify_on_cfp_date_update?).to eq true + expect(cfp.end_date_changed?).to be false + expect(cfp.start_date_changed?).to be true + expect(cfp.notify_on_cfp_date_update?).to be true end end describe 'returns false' do it 'when there is no change in cfp dates' do - expect(cfp.start_date_changed?).to eq false - expect(cfp.end_date_changed?).to eq false - expect(cfp.notify_on_cfp_date_update?).to eq false + expect(cfp.start_date_changed?).to be false + expect(cfp.end_date_changed?).to be false + expect(cfp.notify_on_cfp_date_update?).to be false end it 'when send_on_cfp_dates_updates is not set' do @@ -106,8 +106,8 @@ describe Cfp do conference.email_settings.save! cfp.end_date = Date.today - expect(cfp.end_date_changed?).to eq true - expect(cfp.notify_on_cfp_date_update?).to eq false + expect(cfp.end_date_changed?).to be true + expect(cfp.notify_on_cfp_date_update?).to be false end it 'when cfp_dates_updates_subject is not set' do @@ -115,8 +115,8 @@ describe Cfp do conference.email_settings.save! cfp.end_date = Date.today - expect(cfp.end_date_changed?).to eq true - expect(cfp.notify_on_cfp_date_update?).to eq false + expect(cfp.end_date_changed?).to be true + expect(cfp.notify_on_cfp_date_update?).to be false end it 'when cfp_dates_updates_template is not set' do @@ -124,8 +124,8 @@ describe Cfp do conference.email_settings.save! cfp.end_date = Date.today - expect(cfp.end_date_changed?).to eq true - expect(cfp.notify_on_cfp_date_update?).to eq false + expect(cfp.end_date_changed?).to be true + expect(cfp.notify_on_cfp_date_update?).to be false end end end @@ -135,13 +135,13 @@ describe Cfp do it 'when start and end dates are in the past' do cfp.start_date = Date.current - 3 cfp.end_date = Date.current - 1 - expect(cfp.open?).to eq(false) + expect(cfp.open?).to be(false) end it 'when start and end dates are in the future' do cfp.start_date = Date.current + 1 cfp.end_date = Date.current + 3 - expect(cfp.open?).to eq(false) + expect(cfp.open?).to be(false) end end @@ -149,7 +149,7 @@ describe Cfp do it 'when start date is in the past and end date is in the future' do cfp.start_date = Date.current - 1 cfp.end_date = Date.current + 1 - expect(cfp.open?).to eq(true) + expect(cfp.open?).to be(true) end end end diff --git a/spec/models/commercial_spec.rb b/spec/models/commercial_spec.rb index 90064fe5..5f8dc4ec 100644 --- a/spec/models/commercial_spec.rb +++ b/spec/models/commercial_spec.rb @@ -8,12 +8,12 @@ describe Commercial do it 'validates url format' do commercial = build(:conference_commercial, url: 'ftp://example.com') - expect(commercial.valid?).to eq false + expect(commercial.valid?).to be false expect(commercial.errors['url']).to eq ['is invalid'] end it 'validates url rendering' do commercial = build(:conference_commercial) - expect(commercial.valid?).to eq true + expect(commercial.valid?).to be true end end diff --git a/spec/models/conference_spec.rb b/spec/models/conference_spec.rb index fc593a14..0831d18d 100755 --- a/spec/models/conference_spec.rb +++ b/spec/models/conference_spec.rb @@ -5,22 +5,22 @@ require 'spec_helper' context 'Delegation' do subject do - FactoryBot.create(:conference, start_date: 1.month.from_now, end_date: 2.month.from_now) + create(:conference, start_date: 1.month.from_now, end_date: 2.month.from_now) end context 'Venue' do context 'when venue has not been set' do it 'the accessors should be nil' do - expect(subject.city).to eq(nil) - expect(subject.country_name).to eq(nil) - expect(subject.venue_name).to eq(nil) - expect(subject.venue_street).to eq(nil) + expect(subject.city).to be_nil + expect(subject.country_name).to be_nil + expect(subject.venue_name).to be_nil + expect(subject.venue_street).to be_nil end end context 'when venue has been set' do it 'should delegate to venue' do - venue = FactoryBot.create(:venue) + venue = create(:venue) subject.update(venue: venue) expect(subject.city).to eq(venue.city) expect(subject.country_name).to eq(venue.country_name) @@ -33,7 +33,7 @@ end describe Conference do - let(:subject) { create(:conference, start_date: Date.new(2014, 06, 30), end_date: Date.new(2014, 06, 30)) } + subject(:test_subject) { create(:conference, start_date: Date.new(2014, 06, 30), end_date: Date.new(2014, 06, 30)) } describe '#write_event_distribution_to_db' do @@ -744,7 +744,7 @@ describe Conference do end describe '#get_submission_line_colors' do - it ' returns correct values' do + it 'returns correct values' do result = [] result.push(short_title: 'Submitted', color: 'blue') result.push(short_title: 'Confirmed', color: 'green') diff --git a/spec/models/event_schedule_spec.rb b/spec/models/event_schedule_spec.rb index f111e896..e8e45a8b 100644 --- a/spec/models/event_schedule_spec.rb +++ b/spec/models/event_schedule_spec.rb @@ -21,7 +21,7 @@ describe EventSchedule do context 'is invalid' do it 'when event schedule start_time is after the conference end_hour, and returns an error message' do new_scheduled_event = build(:event_scheduled, program: conference.program, hour: conference.start_date + conference.end_hour.hours + 1.hour) - expect(new_scheduled_event.valid?).to eq false + expect(new_scheduled_event.valid?).to be false expect(new_scheduled_event.event_schedules.first.errors[:start_time]).to eq ["can't be after the conference end hour (#{conference.end_hour})"] end end @@ -29,7 +29,7 @@ describe EventSchedule do context 'is valid' do it 'when event schedule start_time is between the conference end_hour and start_hour' do new_scheduled_event = build(:event_scheduled, program: conference.program, hour: conference.start_date + conference.end_hour.hours - 1.hour) - expect(new_scheduled_event.valid?).to eq true + expect(new_scheduled_event.valid?).to be true end end end @@ -38,7 +38,7 @@ describe EventSchedule do context 'is invalid' do it 'when event schedule start_time is before the conference start_hour, and returns an error message' do new_scheduled_event = build(:event_scheduled, program: conference.program, hour: conference.start_date) - expect(new_scheduled_event.valid?).to eq false + expect(new_scheduled_event.valid?).to be false expect(new_scheduled_event.event_schedules.first.errors[:start_time]).to eq ["can't be before the conference start hour (#{conference.start_hour})"] end end @@ -56,21 +56,21 @@ describe EventSchedule do context 'is valid' do it 'when scheduled in the track\'s room' do event_schedule = build(:event_schedule, event: @event, room: @room) - expect(event_schedule.valid?).to eq true + expect(event_schedule.valid?).to be true end it 'when the track doesn\'t have a room' do @track.room = nil @track.save! event_schedule = build(:event_schedule, event: @event) - expect(event_schedule.valid?).to eq true + expect(event_schedule.valid?).to be true end end context 'is invalid' do it 'when scheduled in different room than the track\'s' do event_schedule = build(:event_schedule, event: @event) - expect(event_schedule.valid?).to eq false + expect(event_schedule.valid?).to be false expect(event_schedule.errors[:room]).to eq ["must be the same as the track's room (#{@room.name})"] end end @@ -88,20 +88,20 @@ describe EventSchedule do context 'is valid' do it 'when scheduled during the track\'s time slot' do event_schedule = build(:event_schedule, event: @event, room: @room, start_time: Date.current + 3.hours) - expect(event_schedule.valid?).to eq true + expect(event_schedule.valid?).to be true end end context 'is invalid' do it 'when scheduled before the track\'s start date' do event_schedule = build(:event_schedule, event: @event, room: @room, start_time: Date.current - 1.hour) - expect(event_schedule.valid?).to eq false + expect(event_schedule.valid?).to be false expect(event_schedule.errors[:start_time]).to eq ["can't be before the track's start date (#{@track.start_date})"] end it 'when event ends after the track\'s end date' do event_schedule = build(:event_schedule, event: @event, room: @room, start_time: Date.current + 1.day - 10.minutes) - expect(event_schedule.valid?).to eq false + expect(event_schedule.valid?).to be false expect(event_schedule.errors[:end_time]).to eq ["can't be after the track's end date (#{@track.end_date})"] end end @@ -119,7 +119,7 @@ describe EventSchedule do it 'when the event belongs to a self-organized track and is scheduled in one of its track\'s schedules' do schedule = create(:schedule, program: conference.program, track: @event.track) event_schedule = build(:event_schedule, event: @event, room: @room, schedule: schedule) - expect(event_schedule.valid?).to eq true + expect(event_schedule.valid?).to be true expect(event_schedule.errors[:schedule]).to eq [] end @@ -127,7 +127,7 @@ describe EventSchedule do @event.track = nil @event.save! event_schedule = build(:event_schedule, event: @event, room: @room) - expect(event_schedule.valid?).to eq true + expect(event_schedule.valid?).to be true expect(event_schedule.errors[:schedule]).to eq [] end end @@ -135,7 +135,7 @@ describe EventSchedule do context 'is invalid' do it 'when the event belongs to a self_organized track but isn\'t scheduled in one of its schedules' do event_schedule = build(:event_schedule, event: @event, room: @room) - expect(event_schedule.valid?).to eq false + expect(event_schedule.valid?).to be false expect(event_schedule.errors[:schedule]).to eq ['must be one of My awesome track track\'s schedules'] end end diff --git a/spec/models/event_spec.rb b/spec/models/event_spec.rb index ccdeb468..9a7f0a36 100644 --- a/spec/models/event_spec.rb +++ b/spec/models/event_spec.rb @@ -35,14 +35,14 @@ describe Event do it 'it is valid, if max_attendees is less than room size' do event.max_attendees = 2 - expect(event.valid?).to eq true + expect(event.valid?).to be true expect(event.errors.full_messages).to eq [] end it 'it is not valid, if max_attendees attribute is bigger than size of room' do event.max_attendees = 4 - expect(event.valid?).to eq false + expect(event.valid?).to be false expect(event.errors[:max_attendees]).to eq ['cannot be more than the room\'s capacity (3)'] end end @@ -56,13 +56,13 @@ describe Event do context 'is invalid' do it 'when abstract is too long' do event.abstract = 'Test abstract here' - expect(event.valid?).to eq false + expect(event.valid?).to be false expect(event.errors[:abstract]).to eq ['cannot have more than 2 words'] end it 'when abstract is too short' do event.abstract = 'Test' - expect(event.valid?).to eq false + expect(event.valid?).to be false expect(event.errors[:abstract]).to eq ['cannot have less than 2 words'] end end @@ -70,7 +70,7 @@ describe Event do context 'is valid' do it 'when abstract length is within limits' do event.abstract = 'Test abstract' - expect(event.valid?).to eq true + expect(event.valid?).to be true expect(event.errors.size).to eq 0 end end @@ -81,7 +81,7 @@ describe Event do it 'when event is created after the conference end_date, and returns an error message' do conference = create(:conference, start_date: Date.today - 1, end_date: Date.today - 1) new_event = build(:event, program: conference.program) - expect(new_event.valid?).to eq false + expect(new_event.valid?).to be false expect(new_event.errors[:created_at]).to eq ["can't be after the conference end date!"] end end @@ -90,7 +90,7 @@ describe Event do it 'when event is created before the conference end_date' do conference = create(:conference, start_date: Date.today - 1, end_date: Date.today + 1) new_event = build(:event, program: conference.program) - expect(new_event.valid?).to eq true + expect(new_event.valid?).to be true end end end @@ -100,7 +100,7 @@ describe Event do it 'when the track belongs to the same program and is confirmed' do track = create(:track, state: 'confirmed', program: conference.program) event = build(:event, program: conference.program, track: track) - expect(event.valid?).to eq true + expect(event.valid?).to be true end end @@ -108,7 +108,7 @@ describe Event do it 'when the track doesn\'t have the same program' do track = create(:track, state: 'confirmed') event = build(:event, program: conference.program, track: track) - expect(event.valid?).to eq false + expect(event.valid?).to be false expect(event.errors[:track]).to eq ['is invalid'] end @@ -116,7 +116,7 @@ describe Event do track = create(:track, program: conference.program) allow(track).to receive(:confirmed?).and_return(false) event = build(:event, program: conference.program, track: track) - expect(event.valid?).to eq false + expect(event.valid?).to be false expect(event.errors[:track]).to eq ['is invalid'] end end @@ -146,7 +146,7 @@ describe Event do end end - describe 'scope ' do + describe 'scope' do context 'confirmed' do it 'returns only confirmed events' do my_event = create(:event, state: 'confirmed', program: conference.program) @@ -165,10 +165,10 @@ describe Event do end describe '#scheduled?' do - it { expect(event.scheduled?).to eq false } + it { expect(event.scheduled?).to be false } it 'returns true if the event is scheduled' do create(:event_schedule, event: event) - expect(event.scheduled?).to eq true + expect(event.scheduled?).to be true end end @@ -185,34 +185,34 @@ describe Event do it 'returns true, if the event has no max_attendees' do event.max_attendees = nil event.save! - expect(event.registration_possible?).to eq true + expect(event.registration_possible?).to be true end it 'returns true, if the limit has not been reached' do - expect(event.registration_possible?).to eq true + expect(event.registration_possible?).to be true end it 'returns true, if the event is confirmed' do event.save! - expect(event.registration_possible?).to eq true + expect(event.registration_possible?).to be true end it 'returns false, if the limit has been reached' do event.registrations << create(:registration) event.registrations << create(:registration) - expect(event.registration_possible?).to eq false + expect(event.registration_possible?).to be false end it 'returns false, if the event is not confirmed' do event.state = 'new' event.save! - expect(event.registration_possible?).to eq false + expect(event.registration_possible?).to be false end end describe 'when the event does not require registration' do it 'returns false' do - expect(event.registration_possible?).to eq false + expect(event.registration_possible?).to be false end end end @@ -236,22 +236,22 @@ describe Event do describe '#voted?' do it 'returns false if the event has no votes' do - expect(event.voted?).to eq false + expect(event.voted?).to be false end it 'returns false if the event has no votes by that user' do create(:vote, user: another_user, event: event) - expect(event.voted?(user)).to eq false + expect(event.voted?(user)).to be false end it 'returns true when the event has votes' do create(:vote, user: another_user, event: event) - expect(event.voted?).to eq true + expect(event.voted?).to be true end it 'returns true when the event has votes by that user' do create(:vote, user: user, event: event) - expect(event.voted?(user)).to eq true + expect(event.voted?(user)).to be true end end diff --git a/spec/models/payment_spec.rb b/spec/models/payment_spec.rb index f637e211..e1edeb8a 100644 --- a/spec/models/payment_spec.rb +++ b/spec/models/payment_spec.rb @@ -24,7 +24,7 @@ describe Payment do let(:ticket_1) { create(:ticket, price: 10, price_currency: 'USD', conference: conference) } let(:payment) { create(:payment, user: user, conference: conference) } - it ' returns correct unpaid amount' do + it 'returns correct unpaid amount' do create(:ticket_purchase, ticket: ticket_1, user: user, quantity: 8) expect(payment.amount_to_pay).to eq(8000) end @@ -71,7 +71,7 @@ describe Payment do context 'when the card is invalid' do it 'returns false' do payment_result = payment.purchase - expect(payment_result).to eq false + expect(payment_result).to be false end it 'assigns "failure" to payment.status' do diff --git a/spec/models/program_spec.rb b/spec/models/program_spec.rb index 581fc185..23c42ff1 100644 --- a/spec/models/program_spec.rb +++ b/spec/models/program_spec.rb @@ -75,7 +75,7 @@ describe Program do end it 'returns true if blind_voting is disabled' do program.blind_voting = false - expect(program.show_voting?).to eq true + expect(program.show_voting?).to be true end end @@ -86,19 +86,19 @@ describe Program do it 'returns true if voting period is over' do program.voting_end_date = Date.today - 1 - expect(program.show_voting?).to eq true + expect(program.show_voting?).to be true end it 'returns false if we are still in votig period' do program.voting_end_date = Date.today + 1 - expect(program.show_voting?).to eq false + expect(program.show_voting?).to be false end end end describe 'voting_period?' do it 'retuns true when voting dates are not set' do - expect(program.voting_period?).to eq true + expect(program.voting_period?).to be true end shared_examples 'voting period' do |voting_start_date, voting_end_date, returns| @@ -125,7 +125,7 @@ describe Program do expect(program.rating_enabled?).to be true end - it 'returns false if proposals cannot be rated (program.rating == 0) ' do + it 'returns false if proposals cannot be rated (program.rating == 0)' do program = conference.program program.rating = 0 expect(program.rating_enabled?).to be false @@ -156,7 +156,7 @@ describe Program do it 'and creates events_types' do program.destroy! conference.reload - expect(conference.program).to eq nil + expect(conference.program).to be_nil create(:program, conference_id: conference.id) conference.reload @@ -166,7 +166,7 @@ describe Program do it 'and creates difficulty_levels' do program.destroy! conference.reload - expect(conference.program).to eq nil + expect(conference.program).to be_nil create(:program, conference_id: conference.id) conference.reload @@ -206,25 +206,25 @@ describe Program do describe 'languages' do it "is not valid if languages aren't two letters separated by commas" do program.languages = 'eng, De es' - expect(program.valid?).to eq false + expect(program.valid?).to be false expect(program.errors[:languages]).to eq ['must be two letters separated by commas'] end it 'is not valid if languages are repeated' do program.languages = 'en,de,es,en' - expect(program.valid?).to eq false + expect(program.valid?).to be false expect(program.errors[:languages]).to eq ["can't be repeated"] end it "is not valid if languages aren't ISO 639-1 valid codes" do program.languages = 'en,hh,yu,zi,oo' - expect(program.valid?).to eq false + expect(program.valid?).to be false expect(program.errors[:languages]).to eq ['must be ISO 639-1 valid codes'] end it 'is valid otherwise' do program.languages = 'en,De, ES, ru,el' - expect(program.valid?).to eq true + expect(program.valid?).to be true end end @@ -244,15 +244,15 @@ describe Program do let!(:event_schedule) { create(:event_schedule, event: event, schedule: schedule, start_time: DateTime.parse("#{Date.current + 1} 10:00").utc) } it 'returns false irrespective of any date' do - expect(program.any_event_for_this_date?(Date.current + 1)).to eq false + expect(program.any_event_for_this_date?(Date.current + 1)).to be false end it 'returns false if date passed is empty' do - expect(program.any_event_for_this_date?('')).to eq false + expect(program.any_event_for_this_date?('')).to be false end it 'returns false if date passed is nil' do - expect(program.any_event_for_this_date?(nil)).to eq false + expect(program.any_event_for_this_date?(nil)).to be false end end @@ -266,19 +266,19 @@ describe Program do end it 'returns true if there is any event for this date' do - expect(program.any_event_for_this_date?(Date.current + 1)).to eq true + expect(program.any_event_for_this_date?(Date.current + 1)).to be true end it 'returns false if there is no event for this date' do - expect(program.any_event_for_this_date?(Date.current + 2)).to eq false + expect(program.any_event_for_this_date?(Date.current + 2)).to be false end it 'returns false if date passed is empty' do - expect(program.any_event_for_this_date?('')).to eq false + expect(program.any_event_for_this_date?('')).to be false end it 'returns false if date passed is nil' do - expect(program.any_event_for_this_date?(nil)).to eq false + expect(program.any_event_for_this_date?(nil)).to be false end end end @@ -291,7 +291,7 @@ describe Program do end it 'returns nil if the program doesn\'t have a cfp' do - expect(program.cfp).to eq(nil) + expect(program.cfp).to be_nil end end @@ -299,19 +299,19 @@ describe Program do it 'returns an array without the \'events\' type, when the cfp for events exists' do create(:cfp, cfp_type: 'events', program: program) expect(program.remaining_cfp_types).to be_a Array - expect(program.remaining_cfp_types.include?('events')).to eq false + expect(program.remaining_cfp_types.include?('events')).to be false end it 'returns an array without the \'booths\' type, when the cfp for booths exists' do create(:cfp, cfp_type: 'booths', program: program) expect(program.remaining_cfp_types).to be_a Array - expect(program.remaining_cfp_types.include?('booths')).to eq false + expect(program.remaining_cfp_types.include?('booths')).to be false end it 'returns an array without the \'tracks\' type, when the cfp for tracks exists' do create(:cfp, cfp_type: 'tracks', program: program) expect(program.remaining_cfp_types).to be_a Array - expect(program.remaining_cfp_types.include?('tracks')).to eq false + expect(program.remaining_cfp_types.include?('tracks')).to be false end it 'returns an empty array when cfps for all the types exist' do diff --git a/spec/models/registration_period_spec.rb b/spec/models/registration_period_spec.rb index ae33e51d..5575b4be 100644 --- a/spec/models/registration_period_spec.rb +++ b/spec/models/registration_period_spec.rb @@ -22,13 +22,13 @@ describe RegistrationPeriod do it 'when start_date and end_date are before conference end_date' do registration_period.start_date = conference.end_date - 2 registration_period.end_date = conference.end_date - 1 - expect(registration_period.valid?).to eq true + expect(registration_period.valid?).to be true end it 'when start_date and end_date are the same day as conference end_date' do registration_period.start_date = conference.end_date registration_period.end_date = conference.end_date - expect(registration_period.valid?).to eq true + expect(registration_period.valid?).to be true end end @@ -36,13 +36,13 @@ describe RegistrationPeriod do it 'when start_date and end_date are after conference end_date' do registration_period.start_date = conference.end_date + 1 registration_period.end_date = conference.end_date + 2 - expect(registration_period.valid?).to eq false + expect(registration_period.valid?).to be false end it 'when end_date is after conference end_date' do registration_period.start_date = conference.end_date - 1 registration_period.end_date = conference.end_date + 1 - expect(registration_period.valid?).to eq false + expect(registration_period.valid?).to be false end end end @@ -52,13 +52,13 @@ describe RegistrationPeriod do it 'when start_date is before end_date' do registration_period.start_date = conference.end_date - 2 registration_period.end_date = conference.end_date - 1 - expect(registration_period.valid?).to eq true + expect(registration_period.valid?).to be true end it 'when start_date and end_date are on the same day' do registration_period.start_date = conference.end_date - 2 registration_period.end_date = conference.end_date - 2 - expect(registration_period.valid?).to eq true + expect(registration_period.valid?).to be true end end @@ -66,7 +66,7 @@ describe RegistrationPeriod do it 'when start_date is after end_date' do registration_period.start_date = conference.start_date + 2 registration_period.end_date = conference.start_date + 1 - expect(registration_period.valid?).to eq false + expect(registration_period.valid?).to be false end end end diff --git a/spec/models/resource_spec.rb b/spec/models/resource_spec.rb index 9ef5a71a..73d47297 100644 --- a/spec/models/resource_spec.rb +++ b/spec/models/resource_spec.rb @@ -26,6 +26,6 @@ describe Resource do it 'is not valid with used greater than quantity' do resource.used = resource.quantity + 1 - expect(resource.valid?).to eq false + expect(resource.valid?).to be false end end diff --git a/spec/models/survey_question_spec.rb b/spec/models/survey_question_spec.rb index 0f86950d..18cec5ca 100644 --- a/spec/models/survey_question_spec.rb +++ b/spec/models/survey_question_spec.rb @@ -30,35 +30,35 @@ describe SurveyQuestion do it 'max_choices > min_choices' do survey_question = build(:survey_question, kind: :choice, min_choices: 3, max_choices: 2) - expect(survey_question.valid?).to eq false + expect(survey_question.valid?).to be false expect(survey_question.errors[:max_choices]).to eq ['Max choices should not be less than min choices'] end end describe '#multiple_choice?' do it 'returns false, when choice with 1 max_choice' do - expect(single_choice_question.multiple_choice?).to eq false + expect(single_choice_question.multiple_choice?).to be false end it 'returns true, when choice with 2 max_choices' do - expect(multiple_choice_question.multiple_choice?).to eq true + expect(multiple_choice_question.multiple_choice?).to be true end end describe '#single_choice?' do it 'returns true, when choice with 1 max_choice' do - expect(single_choice_question.single_choice?).to eq true + expect(single_choice_question.single_choice?).to be true end it 'returns false, when choice with 2 max_choices' do - expect(multiple_choice_question.single_choice?).to eq false + expect(multiple_choice_question.single_choice?).to be false end end describe 'min_choices value' do it 'nil, when boolean question' do boolean_question = create(:boolean_mandatory, min_choices: 3) - expect(boolean_question.min_choices).to eq nil + expect(boolean_question.min_choices).to be_nil end it 'not nil, when choice question' do @@ -86,7 +86,7 @@ describe SurveyQuestion do shared_examples 'is nil' do |question_kind, field| scenario "when question is #{question_kind} and field is #{field}" do question = create(:survey_question, kind: question_kind.to_sym, field => 3) - expect(question.send(field)).to eq nil + expect(question.send(field)).to be_nil end end diff --git a/spec/models/survey_spec.rb b/spec/models/survey_spec.rb index 12a87c67..4a38df3b 100644 --- a/spec/models/survey_spec.rb +++ b/spec/models/survey_spec.rb @@ -17,10 +17,10 @@ describe Survey do end describe '#active?' do - it { expect(survey_active.active?).to eq true } - it { expect(survey_inactive.active?).to eq false } + it { expect(survey_active.active?).to be true } + it { expect(survey_inactive.active?).to be false } it 'returns true, if both start_date and end_date are not set' do - expect(create(:survey, start_date: nil, end_date: nil, surveyable: create(:conference)).active?).to eq true + expect(create(:survey, start_date: nil, end_date: nil, surveyable: create(:conference)).active?).to be true end end end diff --git a/spec/models/ticket_purchase_spec.rb b/spec/models/ticket_purchase_spec.rb index d309e215..989c7470 100644 --- a/spec/models/ticket_purchase_spec.rb +++ b/spec/models/ticket_purchase_spec.rb @@ -42,7 +42,7 @@ describe TicketPurchase do it 'it is not valid, if quantity for registration tickets is greater than to one' do ticket_purchase.quantity = 4 - expect(ticket_purchase.valid?).to eq false + expect(ticket_purchase.valid?).to be false expect(ticket_purchase.errors[:quantity]).to eq ['cannot be greater than one for registration tickets.'] end end diff --git a/spec/models/ticket_scanning_spec.rb b/spec/models/ticket_scanning_spec.rb index ce18e63e..11b2bb40 100644 --- a/spec/models/ticket_scanning_spec.rb +++ b/spec/models/ticket_scanning_spec.rb @@ -13,10 +13,10 @@ describe TicketScanning do describe 'before_create' do it 'marks user as present' do - expect(registration.attended).to eq(false) + expect(registration.attended).to be(false) ticket_scanning registration.reload - expect(registration.attended).to eq(true) + expect(registration.attended).to be(true) end end end diff --git a/spec/models/ticket_spec.rb b/spec/models/ticket_spec.rb index 32dd30cf..8b230142 100644 --- a/spec/models/ticket_spec.rb +++ b/spec/models/ticket_spec.rb @@ -54,11 +54,11 @@ describe Ticket do create(:ticket_purchase, user: user, ticket: ticket) - expect(ticket.bought?(user)).to eq(true) + expect(ticket.bought?(user)).to be(true) end it 'returns false if the user has not bought this ticket' do - expect(ticket.bought?(user)).to eq(false) + expect(ticket.bought?(user)).to be(false) end end @@ -79,7 +79,7 @@ describe Ticket do context 'user has not paid' do it 'returns true' do - expect(ticket.unpaid?(user)).to eq(true) + expect(ticket.unpaid?(user)).to be(true) end end @@ -87,7 +87,7 @@ describe Ticket do before { ticket_purchase.update_attribute(:paid, true) } it 'returns false' do - expect(ticket.unpaid?(user)).to eq(false) + expect(ticket.unpaid?(user)).to be(false) end end end diff --git a/spec/models/track_spec.rb b/spec/models/track_spec.rb index 27066442..7974bb99 100644 --- a/spec/models/track_spec.rb +++ b/spec/models/track_spec.rb @@ -75,32 +75,32 @@ describe Track do context 'is valid' do it 'when the track\'s dates are between the conference\'s dates' do track = build(:track, start_date: @conference.start_date, end_date: @conference.end_date, program: @conference.program) - expect(track.valid?).to eq true + expect(track.valid?).to be true end end context 'is invalid' do it 'when the track\'s start date is before the conference\'s start date' do track = build(:track, start_date: 2.days.ago, end_date: Date.tomorrow, program: @conference.program) - expect(track.valid?).to eq false + expect(track.valid?).to be false expect(track.errors[:start_date]).to eq ["can't be outside of the conference's dates (#{1.day.ago.to_date}-#{2.days.from_now.to_date})"] end it 'when the track\'s start date is after the conference\'s end date' do track = build(:track, start_date: 3.days.from_now, end_date: 4.days.from_now, program: @conference.program) - expect(track.valid?).to eq false + expect(track.valid?).to be false expect(track.errors[:start_date]).to eq ["can't be outside of the conference's dates (#{1.day.ago.to_date}-#{2.days.from_now.to_date})"] end it 'when the track\'s end date is before the conference\'s start date' do track = build(:track, start_date: 3.days.ago, end_date: 2.days.ago, program: @conference.program) - expect(track.valid?).to eq false + expect(track.valid?).to be false expect(track.errors[:end_date]).to eq ["can't be outside of the conference's dates (#{1.day.ago.to_date}-#{2.days.from_now.to_date})"] end it 'when the track\'s end date is after the conference\'s end date' do track = build(:track, start_date: Date.today, end_date: 3.days.from_now, program: @conference.program) - expect(track.valid?).to eq false + expect(track.valid?).to be false expect(track.errors[:end_date]).to eq ["can't be outside of the conference's dates (#{1.day.ago.to_date}-#{2.days.from_now.to_date})"] end end @@ -114,14 +114,14 @@ describe Track do context 'is valid' do it 'when the track\'s start date is before its end date' do track = build(:track, start_date: Date.today, end_date: Date.tomorrow, program: @conference.program) - expect(track.valid?).to eq true + expect(track.valid?).to be true end end context 'is invalid' do it 'when the track\'s start date is after it\'s end date' do track = build(:track, start_date: 1.day.from_now, end_date: 1.day.ago) - expect(track.valid?).to eq false + expect(track.valid?).to be false expect(track.errors[:start_date]).to eq ['can\'t be after the end date'] end end @@ -137,7 +137,7 @@ describe Track do it 'when the track\'s room belongs to the venue of the conference' do room = create(:room, venue: @conference.venue) track = build(:track, :self_organized, state: 'accepted', program: @conference.program, room: room) - expect(track.valid?).to eq true + expect(track.valid?).to be true end end @@ -147,7 +147,7 @@ describe Track do other_conference.venue = create(:venue) room = create(:room, venue: other_conference.venue) track = build(:track, :self_organized, state: 'accepted', program: @conference.program, room: room) - expect(track.valid?).to eq false + expect(track.valid?).to be false expect(track.errors[:room]).to eq ['must be a room of The venue'] end end @@ -165,19 +165,19 @@ describe Track do other_room = create(:room, venue: @conference.venue) create(:track, :self_organized, state: 'confirmed', program: @conference.program, room: other_room, start_date: Date.current, end_date: Date.current) track = build(:track, :self_organized, program: @conference.program, room: @room, start_date: Date.current, end_date: Date.current) - expect(track.valid?).to eq true + expect(track.valid?).to be true end it 'when it ends before the other tracks in the same room' do create(:track, :self_organized, state: 'confirmed', program: @conference.program, room: @room, start_date: Date.current, end_date: Date.current) track = build(:track, :self_organized, program: @conference.program, room: @room, start_date: Date.current - 1.day, end_date: Date.current - 1.day) - expect(track.valid?).to eq true + expect(track.valid?).to be true end it 'when it starts after the other tracks in the same room' do create(:track, :self_organized, state: 'confirmed', program: @conference.program, room: @room, start_date: Date.current, end_date: Date.current) track = build(:track, :self_organized, program: @conference.program, room: @room, start_date: Date.current + 1.day, end_date: Date.current + 1.day) - expect(track.valid?).to eq true + expect(track.valid?).to be true end end @@ -185,35 +185,35 @@ describe Track do it 'when it starts and/or ends with another track in the same room' do create(:track, :self_organized, state: 'confirmed', program: @conference.program, room: @room, start_date: Date.current, end_date: Date.current) track = build(:track, :self_organized, program: @conference.program, room: @room, start_date: Date.current, end_date: Date.current) - expect(track.valid?).to eq false + expect(track.valid?).to be false expect(track.errors[:track]).to eq ['has overlapping dates with a confirmed or accepted track in the same room'] end it 'when it starts before another track and ends after the other starts and before it ends' do create(:track, :self_organized, state: 'confirmed', program: @conference.program, room: @room, start_date: Date.current, end_date: Date.current + 2.days) track = build(:track, :self_organized, program: @conference.program, room: @room, start_date: Date.current - 1.day, end_date: Date.current + 1.day) - expect(track.valid?).to eq false + expect(track.valid?).to be false expect(track.errors[:track]).to eq ['has overlapping dates with a confirmed or accepted track in the same room'] end it 'when it starts after another track and before it ends and ends after the other' do create(:track, :self_organized, state: 'confirmed', program: @conference.program, room: @room, start_date: Date.current, end_date: Date.current + 2.days) track = build(:track, :self_organized, program: @conference.program, room: @room, start_date: Date.current + 1.day, end_date: Date.current + 3.days) - expect(track.valid?).to eq false + expect(track.valid?).to be false expect(track.errors[:track]).to eq ['has overlapping dates with a confirmed or accepted track in the same room'] end it 'when it starts after another track and ends before the other' do create(:track, :self_organized, state: 'confirmed', program: @conference.program, room: @room, start_date: Date.current, end_date: Date.current + 2.days) track = build(:track, :self_organized, program: @conference.program, room: @room, start_date: Date.current + 1.day, end_date: Date.current + 1.day) - expect(track.valid?).to eq false + expect(track.valid?).to be false expect(track.errors[:track]).to eq ['has overlapping dates with a confirmed or accepted track in the same room'] end it 'when it starts before another track and ends after the other' do create(:track, :self_organized, state: 'confirmed', program: @conference.program, room: @room, start_date: Date.current, end_date: Date.current) track = build(:track, :self_organized, program: @conference.program, room: @room, start_date: Date.current - 1.day, end_date: Date.current + 1.day) - expect(track.valid?).to eq false + expect(track.valid?).to be false expect(track.errors[:track]).to eq ['has overlapping dates with a confirmed or accepted track in the same room'] end end @@ -229,7 +229,7 @@ describe Track do context 'includes' do it 'when track is accepted' do accepted_track = create(:track, state: 'accepted', program: @program) - expect(@program.tracks.accepted.include?(accepted_track)).to eq true + expect(@program.tracks.accepted.include?(accepted_track)).to be true end end @@ -237,7 +237,7 @@ describe Track do %w[new to_accept confirmed to_reject rejected canceled withdrawn].each do |state| it "when track is #{state.humanize}" do not_accepted_track = create(:track, state: state, program: @program) - expect(@program.tracks.accepted.include?(not_accepted_track)).to eq false + expect(@program.tracks.accepted.include?(not_accepted_track)).to be false end end end @@ -251,7 +251,7 @@ describe Track do context 'includes' do it 'tracks with state \'confirmed\'' do confirmed_track = create(:track, state: 'confirmed', program: @program) - expect(@program.tracks.confirmed.include?(confirmed_track)).to eq true + expect(@program.tracks.confirmed.include?(confirmed_track)).to be true end end @@ -259,7 +259,7 @@ describe Track do %w[new to_accept accepted to_reject rejected canceled withdrawn].each do |state| it "tracks with state '#{state}'" do unconfirmed_track = create(:track, state: state, program: @program) - expect(@program.tracks.confirmed.include?(unconfirmed_track)).to eq false + expect(@program.tracks.confirmed.include?(unconfirmed_track)).to be false end end end @@ -273,11 +273,11 @@ describe Track do end it 'include tracks with the cfp_active flag enabled' do - expect(@program.tracks.cfp_active.include?(@cfp_active_track)).to eq true + expect(@program.tracks.cfp_active.include?(@cfp_active_track)).to be true end it 'excludes tracks with the cfp_active flag disabled' do - expect(@program.tracks.cfp_active.include?(@non_cfp_active_track)).to eq false + expect(@program.tracks.cfp_active.include?(@non_cfp_active_track)).to be false end end @@ -291,11 +291,11 @@ describe Track do end it 'includes self-organized tracks' do - expect(@program.tracks.self_organized.include?(self_organized_track)).to eq true + expect(@program.tracks.self_organized.include?(self_organized_track)).to be true end it 'excludes regular tracks' do - expect(@program.tracks.self_organized.include?(track)).to eq false + expect(@program.tracks.self_organized.include?(track)).to be false end end end @@ -303,12 +303,12 @@ describe Track do describe '#self_organized?' do it 'returns true when it has a submitter' do expect(self_organized_track.submitter).to be_a User - expect(self_organized_track.self_organized?).to eq true + expect(self_organized_track.self_organized?).to be true end it 'returns false when it doesn\'t have a submitter' do - expect(track.submitter).to eq nil - expect(track.self_organized?).to eq false + expect(track.submitter).to be_nil + expect(track.self_organized?).to be false end end @@ -346,17 +346,17 @@ describe Track do end it 'gives the role of the track organizer to the submitter of the track' do - expect(@submitter.has_cached_role?(:track_organizer, self_organized_track)).to eq false + expect(@submitter.has_cached_role?(:track_organizer, self_organized_track)).to be false self_organized_track.assign_role_to_submitter - expect(@submitter.has_cached_role?(:track_organizer, self_organized_track)).to eq true + expect(@submitter.has_cached_role?(:track_organizer, self_organized_track)).to be true end it 'is executed when the track is confirmed' do self_organized_track.state = 'accepted' self_organized_track.save! - expect(@submitter.has_cached_role?(:track_organizer, self_organized_track)).to eq false + expect(@submitter.has_cached_role?(:track_organizer, self_organized_track)).to be false self_organized_track.confirm - expect(@submitter.has_cached_role?(:track_organizer, self_organized_track)).to eq true + expect(@submitter.has_cached_role?(:track_organizer, self_organized_track)).to be true end end @@ -373,23 +373,23 @@ describe Track do end it 'revokes the role of the track organizer' do - expect(@a_track_organizer.has_cached_role?(:track_organizer, self_organized_track)).to eq true + expect(@a_track_organizer.has_cached_role?(:track_organizer, self_organized_track)).to be true self_organized_track.revoke_role_and_cleanup @a_track_organizer.reload - expect(@a_track_organizer.has_cached_role?(:track_organizer, self_organized_track)).to eq false + expect(@a_track_organizer.has_cached_role?(:track_organizer, self_organized_track)).to be false end it 'destroys the track\'s schedules' do expect(Schedule.find(@schedule_of_self_organized_track.id)).to eq @schedule_of_self_organized_track self_organized_track.revoke_role_and_cleanup - expect(Schedule.find_by(id: @schedule_of_self_organized_track.id)).to eq nil + expect(Schedule.find_by(id: @schedule_of_self_organized_track.id)).to be_nil end it 'removes the track from the events that have it set' do expect(@event_of_self_organized_track.track).to eq self_organized_track self_organized_track.revoke_role_and_cleanup @event_of_self_organized_track.reload - expect(@event_of_self_organized_track.track).to eq nil + expect(@event_of_self_organized_track.track).to be_nil end it 'sets the state of the track\'s events to new' do @@ -404,17 +404,17 @@ describe Track do self_organized_track.save! self_organized_track.cancel @a_track_organizer.reload - expect(@a_track_organizer.has_cached_role?(:track_organizer, self_organized_track)).to eq false + expect(@a_track_organizer.has_cached_role?(:track_organizer, self_organized_track)).to be false @event_of_self_organized_track.reload - expect(@event_of_self_organized_track.track).to eq nil + expect(@event_of_self_organized_track.track).to be_nil end it 'is executed when the track is withdrawn' do self_organized_track.withdraw @a_track_organizer.reload - expect(@a_track_organizer.has_cached_role?(:track_organizer, self_organized_track)).to eq false + expect(@a_track_organizer.has_cached_role?(:track_organizer, self_organized_track)).to be false @event_of_self_organized_track.reload - expect(@event_of_self_organized_track.track).to eq nil + expect(@event_of_self_organized_track.track).to be_nil end end @@ -423,7 +423,7 @@ describe Track do it 'when the state is "accepted"' do self_organized_track.state = 'accepted' self_organized_track.save! - expect(self_organized_track.accepted?).to eq true + expect(self_organized_track.accepted?).to be true end end @@ -432,7 +432,7 @@ describe Track do it "when the state is \"#{state}\"" do self_organized_track.state = state self_organized_track.save! - expect(self_organized_track.accepted?).to eq false + expect(self_organized_track.accepted?).to be false end end end @@ -443,7 +443,7 @@ describe Track do it 'when the state is "confirmed"' do self_organized_track.state = 'confirmed' self_organized_track.save! - expect(self_organized_track.confirmed?).to eq true + expect(self_organized_track.confirmed?).to be true end end @@ -452,7 +452,7 @@ describe Track do it "when the state is \"#{state}\"" do self_organized_track.state = state self_organized_track.save! - expect(self_organized_track.confirmed?).to eq false + expect(self_organized_track.confirmed?).to be false end end end @@ -472,7 +472,7 @@ describe Track do allow(track).to receive(:confirmed?).and_return(false) end - it { expect(track.self_organized_and_accepted_or_confirmed?).to eq true } + it { expect(track.self_organized_and_accepted_or_confirmed?).to be true } end context 'accepted? returns false and confirmed? returns true' do @@ -481,7 +481,7 @@ describe Track do allow(track).to receive(:confirmed?).and_return(true) end - it { expect(track.self_organized_and_accepted_or_confirmed?).to eq true } + it { expect(track.self_organized_and_accepted_or_confirmed?).to be true } end end end @@ -498,7 +498,7 @@ describe Track do allow(track).to receive(:confirmed?).and_return(false) end - it { expect(track.self_organized_and_accepted_or_confirmed?).to eq false } + it { expect(track.self_organized_and_accepted_or_confirmed?).to be false } end end @@ -513,7 +513,7 @@ describe Track do allow(track).to receive(:confirmed?).and_return(false) end - it { expect(track.self_organized_and_accepted_or_confirmed?).to eq false } + it { expect(track.self_organized_and_accepted_or_confirmed?).to be false } end context 'accepted? returns true and confirmed? returns false' do @@ -522,7 +522,7 @@ describe Track do allow(track).to receive(:confirmed?).and_return(false) end - it { expect(track.self_organized_and_accepted_or_confirmed?).to eq false } + it { expect(track.self_organized_and_accepted_or_confirmed?).to be false } end context 'accepted? returns false and confirmed? returns true' do @@ -531,7 +531,7 @@ describe Track do allow(track).to receive(:confirmed?).and_return(true) end - it { expect(track.self_organized_and_accepted_or_confirmed?).to eq false } + it { expect(track.self_organized_and_accepted_or_confirmed?).to be false } end end end @@ -539,13 +539,13 @@ describe Track do describe '#create_organizer_role' do it 'creates the role of the track organizer' do - expect(Role.find_by(name: 'track_organizer', resource: self_organized_track)).to eq nil + expect(Role.find_by(name: 'track_organizer', resource: self_organized_track)).to be_nil self_organized_track.send(:create_organizer_role) expect(Role.find_by(name: 'track_organizer', resource: self_organized_track).description).to eq 'For the organizers of the Track' end it 'is executed when the track is accepted' do - expect(Role.find_by(name: 'track_organizer', resource: self_organized_track)).to eq nil + expect(Role.find_by(name: 'track_organizer', resource: self_organized_track)).to be_nil self_organized_track.accept expect(Role.find_by(name: 'track_organizer', resource: self_organized_track).description).to eq 'For the organizers of the Track' end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 9c87238b..29bb59cb 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -346,7 +346,7 @@ describe User do describe '#confirmed?' do context 'confirmed user' do it 'returns true' do - expect(user.confirmed?).to eq true + expect(user.confirmed?).to be true end end @@ -354,7 +354,7 @@ describe User do before { user.update_attribute(:confirmed_at, nil) } it 'returns false' do - expect(user.confirmed?).to eq false + expect(user.confirmed?).to be false end end end @@ -395,7 +395,7 @@ describe User do describe 'rolify' do it 'returns the correct role' do - expect(user_admin.is_admin).to eq(true) + expect(user_admin.is_admin).to be(true) expect(organizer.roles.first).to eq(organizer_role) end @@ -430,7 +430,7 @@ describe User do end describe 'assigns admin attribute' do - xit 'to second user when first user is deleted_user' do + it 'to second user when first user is deleted_user' do deleted_user = User.find_by(email: 'deleted@localhost.osem') expect(deleted_user.is_admin).to be false diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 10cab9e5..59310381 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -85,7 +85,7 @@ RSpec.configure do |config| # use a real browser for JS tests Capybara.javascript_driver = ( - ENV['OSEM_TEST_DRIVER'].try(:to_sym) || :chrome_headless + ENV.fetch('OSEM_TEST_DRIVER', 'chrome_headless').to_sym ) # Includes helpers and connect them to specific types of tests diff --git a/spec/support/deprecation_shitlist.rb b/spec/support/deprecation_shitlist.rb index bbaea59b..fc962504 100644 --- a/spec/support/deprecation_shitlist.rb +++ b/spec/support/deprecation_shitlist.rb @@ -1,10 +1,10 @@ RSpec.configure do |config| # Tracker deprecation messages in each file - if ENV['DEPRECATION_TRACKER'] + if ENV.fetch('DEPRECATION_TRACKER', nil) DeprecationTracker.track_rspec( config, shitlist_path: 'spec/support/deprecation_shitlist.json', - mode: ENV['DEPRECATION_TRACKER'], + mode: ENV.fetch('DEPRECATION_TRACKER'), transform_message: ->(message) { message.gsub("#{Rails.root}/", '') } ) end