diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 266225a66..8777124c0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,11 +18,11 @@ jobs: sed -i 's/git@github.com:/https:\/\/github.com\//' .gitmodules git submodule update --init --recursive - name: Docker compose build - run: docker-compose build + run: docker compose build - name: Setup database & test env - run: docker-compose run web bin/rake db:create db:schema:load RAILS_ENV=test + run: docker compose run web bin/rake db:create db:schema:load RAILS_ENV=test - name: Run spec_v8 tests - run: docker-compose run web bin/spec_v8 + run: docker compose run web bin/spec_v8 spec_models: runs-on: ubuntu-latest @@ -36,11 +36,11 @@ jobs: sed -i 's/git@github.com:/https:\/\/github.com\//' .gitmodules git submodule update --init --recursive - name: Docker compose build - run: docker-compose build + run: docker compose build - name: Setup database & test env - run: docker-compose run web bin/rake db:create db:schema:load RAILS_ENV=test + run: docker compose run web bin/rake db:create db:schema:load RAILS_ENV=test - name: Run spec_models tests - run: docker-compose run web bin/spec_models + run: docker compose run web bin/spec_models spec_controllers: runs-on: ubuntu-latest @@ -54,11 +54,11 @@ jobs: sed -i 's/git@github.com:/https:\/\/github.com\//' .gitmodules git submodule update --init --recursive - name: Docker compose build - run: docker-compose build + run: docker compose build - name: Setup database & test env - run: docker-compose run web bin/rake db:create db:schema:load RAILS_ENV=test + run: docker compose run web bin/rake db:create db:schema:load RAILS_ENV=test - name: Run spec_controllers tests - run: docker-compose run web bin/spec_controllers + run: docker compose run web bin/spec_controllers spec_features: runs-on: ubuntu-latest @@ -72,11 +72,11 @@ jobs: sed -i 's/git@github.com:/https:\/\/github.com\//' .gitmodules git submodule update --init --recursive - name: Docker compose build - run: docker-compose build + run: docker compose build - name: Setup database & test env - run: docker-compose run web bin/rake db:create db:schema:load RAILS_ENV=test + run: docker compose run web bin/rake db:create db:schema:load RAILS_ENV=test - name: Run spec_features tests - run: docker-compose run web bin/spec_features + run: docker compose run web bin/spec_features spec_lib: runs-on: ubuntu-latest @@ -90,11 +90,11 @@ jobs: sed -i 's/git@github.com:/https:\/\/github.com\//' .gitmodules git submodule update --init --recursive - name: Docker compose build - run: docker-compose build + run: docker compose build - name: Setup database & test env - run: docker-compose run web bin/rake db:create db:schema:load RAILS_ENV=test + run: docker compose run web bin/rake db:create db:schema:load RAILS_ENV=test - name: Run spec_lib tests - run: docker-compose run web bin/spec_lib + run: docker compose run web bin/spec_lib spec_integration: runs-on: ubuntu-latest @@ -108,32 +108,8 @@ jobs: sed -i 's/git@github.com:/https:\/\/github.com\//' .gitmodules git submodule update --init --recursive - name: Docker compose build - run: docker-compose build + run: docker compose build - name: Setup database & test env - run: docker-compose run web bin/rake db:create db:schema:load RAILS_ENV=test + run: docker compose run web bin/rake db:create db:schema:load RAILS_ENV=test - name: Run spec_integration tests - run: docker-compose run web bin/spec_integration - - spec_usermanual: - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v2 - with: - submodules: false - - name: Setup git submodules - run: | - sed -i 's/git@github.com:/https:\/\/github.com\//' .gitmodules - git submodule update --init --recursive - - name: Docker compose build - run: docker-compose build - - name: Setup database & test env - run: docker-compose run web bin/rake db:create db:schema:load RAILS_ENV=test - - name: Run spec_usermanual tests - run: docker-compose run web bin/spec_usermanual - - name: Update manual to testmycode-usermanual - uses: JamesIves/github-pages-deploy-action@4.1.3 - with: - branch: gh-pages - folder: doc/usermanual - target-folder: usermanual + run: docker compose run web bin/spec_integration \ No newline at end of file diff --git a/.github/workflows/rubocop.yml b/.github/workflows/rubocop.yml index 4e6967fde..b5be7a9d5 100644 --- a/.github/workflows/rubocop.yml +++ b/.github/workflows/rubocop.yml @@ -12,10 +12,10 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Set up Ruby 2.6 + - name: Set up Ruby 3.0 uses: ruby/setup-ruby@v1 with: - ruby-version: 2.6 + ruby-version: 3.0 - name: Cache gems uses: actions/cache@v1 with: diff --git a/Dockerfile b/Dockerfile index d1877ca97..8d88a267d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,13 @@ FROM eu.gcr.io/moocfi-public/tmc-server-base:latest -LABEL name tmc-server +LABEL name=tmc-server + +RUN apt-get update \ + && apt-get -y install curl gnupg nodejs chromium \ + && rm -rf /var/lib/apt/lists/* ADD Gemfile /app/Gemfile ADD Gemfile.lock /app/Gemfile.lock -RUN bundle install --system --gemfile /app/Gemfile -RUN apt-get update -RUN apt-get -y install curl gnupg -RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - -RUN apt-get -y install nodejs +RUN bundle config set path.system true \ + && bundle install --gemfile /app/Gemfile + ADD . /app diff --git a/DockerfileBase b/DockerfileBase index d1dc6d6c5..fabdc92f5 100644 --- a/DockerfileBase +++ b/DockerfileBase @@ -1,4 +1,4 @@ -FROM ruby:2.6 +FROM ruby:3.3 LABEL name tmc-server-base ENV PHANTOMJS_VERSION 2.1.1 diff --git a/Gemfile b/Gemfile index 7359a1684..ec82e9eb8 100644 --- a/Gemfile +++ b/Gemfile @@ -4,79 +4,81 @@ source 'https://rubygems.org' # An alternative when rubygems.org is down # source 'http://production.cf.rubygems.org/' -gem 'rails', '~> 6.1' +gem 'rails', '~> 7.1', '>= 7.1.3.4' -gem 'activerecord-import', '~> 1.2' -gem 'activerecord-session_store', '~> 2.0' -gem 'argon2', '~> 2.0' # Held back, higher requires Ruby 2.6 from tmc-server-base +gem 'activerecord-import', '~> 1.7' +gem 'activerecord-session_store', '~> 2.1' +gem 'argon2', '~> 2.3' gem 'bootstrap', '~> 4.6' # Held back to 4.6 -gem 'cancancan', '~> 3.3' -gem 'doorkeeper', '~> 5.5' -gem 'doorkeeper-openid_connect' -gem 'file_validators' # Used to validate organization logo -gem 'font-awesome-rails' -gem 'google_drive', '~> 3.0', require: false -gem 'gravtastic', '~> 3.2' # Used to display user avatars -gem 'image_processing' # Used by active_storage to make logo 100x100 on the fly -gem 'logstasher', '~> 2.1' -gem 'natcmp', '~> 1.4' -gem 'newrelic_rpm', '~> 8.0' -gem 'pdfkit', '~> 0.8', require: false -gem 'pg', '~> 1.2' -gem 'pghero', '~> 2.8' -gem 'rack-attack', '~> 6.5', require: false -gem 'rack-cors', '~> 1.1' -gem 'rack-mini-profiler', '~> 2.3' -gem 'rake' -gem 'responders', '~> 3.0' +gem 'cancancan', '~> 3.6', '>= 3.6.1' +gem 'doorkeeper', '~> 5.7', '>= 5.7.1' +gem 'doorkeeper-openid_connect', '~> 1.8', '>= 1.8.9' +gem 'file_validators', '~> 3.0' # Used to validate organization logo +gem 'font-awesome-rails', '~> 4.7', '>= 4.7.0.8' +gem 'google_drive', '~> 3.0', '>= 3.0.7', require: false +gem 'gravtastic', '~> 3.2', '>= 3.2.6' # Used to display user avatars +gem 'image_processing', '~> 1.12', '>= 1.12.2' # Used by active_storage to make logo 100x100 on the fly +gem 'logstasher', '~> 2.1', '>= 2.1.5' +gem 'natcmp', '~> 1.4', '>= 1.4.3' +gem 'newrelic_rpm', '~> 9.11' +gem 'pdfkit', '~> 0.8.7.3', require: false +gem 'pg', '~> 1.5', '>= 1.5.6' +gem 'pghero', '~> 3.5' +gem 'rack-attack', '~> 6.7', require: false +gem 'rack-cors', '~> 2.0', '>= 2.0.2' +gem 'rack-mini-profiler', '~> 3.3', '>= 3.3.1' +gem 'rake', '~> 13.2', '>= 13.2.1' +gem 'responders', '~> 3.1', '>= 3.1.1' gem 'rest-client', '~> 2.1', require: false gem 'swagger-blocks', '~> 3.0' -gem 'sassc-rails', '~> 2.1' -gem 'xml-simple', '~> 1.1', require: false +gem 'sassc-rails', '~> 2.1', '>= 2.1.2' +gem 'xml-simple', '~> 1.1', '>= 1.1.9', require: false +gem 'cgi', '~> 0.3.6' -gem 'hiredis', '~> 0.6' # Redis for caching +gem 'hiredis', '~> 0.6.3' # Redis for caching gem 'readthis', '~> 2.2' # Redis for caching gem 'redis', '~> 4.5' # Redis for caching (TODO: Remove and migrate to rails cache) group :assets do - gem 'jquery-rails', '~> 4.4' - gem 'sprockets-rails', require: 'sprockets/railtie' + gem 'jquery-rails', '~> 4.6' + gem 'sprockets-rails', '~> 3.5', '>= 3.5.1', require: 'sprockets/railtie' gem 'uglifier', '~> 4.2' end group :development, :test do - gem 'capybara', '~> 3.35' - gem 'factory_bot_rails', '~> 6.2' - gem 'puma', '~> 5.5' + gem 'capybara', '~> 3.40' + gem 'factory_bot_rails', '~> 6.4', '>= 6.4.3' + gem 'puma', '~> 6.4', '>= 6.4.2' + gem 'thin', '~> 1.8', '>= 1.8.2' # A transitive dependency, this forces the latest version # gem 'passenger', '~> 5.0', require: "phusion_passenger/rack_handler" - gem 'poltergeist', '~> 1.18' - gem 'rspec', '~> 3.10' - gem 'rspec-activemodel-mocks', '~> 1.1' - gem 'rspec-core', '~> 3.10' - gem 'rspec-rails', '~> 5.0' - gem 'rails-controller-testing' + gem 'poltergeist', '~> 1.18', '>= 1.18.1' + gem 'rspec', '~> 3.13' + gem 'rspec-activemodel-mocks', '~> 1.2' + gem 'rspec-core', '~> 3.13' + gem 'rspec-rails', '~> 6.1', '>= 6.1.3' + gem 'rails-controller-testing', '~> 1.0', '>= 1.0.5' # gem 'selenium-webdriver', '~> 2.44.0' - gem 'irb' - gem 'brakeman', require: false - gem 'bundler-audit' - gem 'pry' - gem 'pry-byebug' - gem 'pry-rails' + gem 'irb', '~> 1.14' + gem 'brakeman', '~> 6.1', '>= 6.1.2', require: false + gem 'bundler-audit', '~> 0.9.1' + gem 'pry', '~> 0.14.2' + gem 'pry-byebug', '~> 3.10', '>= 3.10.1' + gem 'pry-rails', '~> 0.3.11' - gem 'database_cleaner', '~> 2.0' - gem 'launchy' # for capybara's save_and_open_page - gem 'mimic', '~> 0.4' - gem 'railroady' # for doc/diagrams - gem 'rubocop', '~> 1.13', require: false # HoundCI requires 1.5.2 - gem 'rubocop-rails_config', '~> 1.5' # Rubocop locked - gem 'ruby-prof', '~> 1.4' # for performance tests - gem 'simplecov', require: false + gem 'database_cleaner', '~> 2.0', '>= 2.0.2' + gem 'launchy', '~> 3.0', '>= 3.0.1' # for capybara's save_and_open_page + gem 'mimic', '~> 0.4.4' + gem 'railroady', '~> 1.6' # for doc/diagrams + gem 'rubocop', '~> 1.65', require: false + gem 'rubocop-rails_config', '~> 1.16' # Rubocop locked + gem 'ruby-prof', '~> 1.7' # for performance tests + gem 'simplecov', '~> 0.22.0', require: false end group :development do - gem 'letter_opener', '~> 1.7' + gem 'letter_opener', '~> 1.10' end group :test do - gem 'json-schema', '~> 2.8' + gem 'json-schema', '~> 4.3' end diff --git a/Gemfile.lock b/Gemfile.lock index 786b22454..97ae0023b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,163 +1,197 @@ GEM remote: https://rubygems.org/ specs: - actioncable (6.1.4.1) - actionpack (= 6.1.4.1) - activesupport (= 6.1.4.1) + actioncable (7.1.3.4) + actionpack (= 7.1.3.4) + activesupport (= 7.1.3.4) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.1.4.1) - actionpack (= 6.1.4.1) - activejob (= 6.1.4.1) - activerecord (= 6.1.4.1) - activestorage (= 6.1.4.1) - activesupport (= 6.1.4.1) + zeitwerk (~> 2.6) + actionmailbox (7.1.3.4) + actionpack (= 7.1.3.4) + activejob (= 7.1.3.4) + activerecord (= 7.1.3.4) + activestorage (= 7.1.3.4) + activesupport (= 7.1.3.4) mail (>= 2.7.1) - actionmailer (6.1.4.1) - actionpack (= 6.1.4.1) - actionview (= 6.1.4.1) - activejob (= 6.1.4.1) - activesupport (= 6.1.4.1) + net-imap + net-pop + net-smtp + actionmailer (7.1.3.4) + actionpack (= 7.1.3.4) + actionview (= 7.1.3.4) + activejob (= 7.1.3.4) + activesupport (= 7.1.3.4) mail (~> 2.5, >= 2.5.4) - rails-dom-testing (~> 2.0) - actionpack (6.1.4.1) - actionview (= 6.1.4.1) - activesupport (= 6.1.4.1) - rack (~> 2.0, >= 2.0.9) + net-imap + net-pop + net-smtp + rails-dom-testing (~> 2.2) + actionpack (7.1.3.4) + actionview (= 7.1.3.4) + activesupport (= 7.1.3.4) + nokogiri (>= 1.8.5) + racc + rack (>= 2.2.4) + rack-session (>= 1.0.1) rack-test (>= 0.6.3) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.1.4.1) - actionpack (= 6.1.4.1) - activerecord (= 6.1.4.1) - activestorage (= 6.1.4.1) - activesupport (= 6.1.4.1) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + actiontext (7.1.3.4) + actionpack (= 7.1.3.4) + activerecord (= 7.1.3.4) + activestorage (= 7.1.3.4) + activesupport (= 7.1.3.4) + globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (6.1.4.1) - activesupport (= 6.1.4.1) + actionview (7.1.3.4) + activesupport (= 7.1.3.4) builder (~> 3.1) - erubi (~> 1.4) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (6.1.4.1) - activesupport (= 6.1.4.1) + erubi (~> 1.11) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + activejob (7.1.3.4) + activesupport (= 7.1.3.4) globalid (>= 0.3.6) - activemodel (6.1.4.1) - activesupport (= 6.1.4.1) - activerecord (6.1.4.1) - activemodel (= 6.1.4.1) - activesupport (= 6.1.4.1) - activerecord-import (1.2.0) - activerecord (>= 3.2) - activerecord-session_store (2.0.0) - actionpack (>= 5.2.4.1) - activerecord (>= 5.2.4.1) + activemodel (7.1.3.4) + activesupport (= 7.1.3.4) + activerecord (7.1.3.4) + activemodel (= 7.1.3.4) + activesupport (= 7.1.3.4) + timeout (>= 0.4.0) + activerecord-import (1.7.0) + activerecord (>= 4.2) + activerecord-session_store (2.1.0) + actionpack (>= 6.1) + activerecord (>= 6.1) + cgi (>= 0.3.6) multi_json (~> 1.11, >= 1.11.2) - rack (>= 2.0.8, < 3) - railties (>= 5.2.4.1) - activestorage (6.1.4.1) - actionpack (= 6.1.4.1) - activejob (= 6.1.4.1) - activerecord (= 6.1.4.1) - activesupport (= 6.1.4.1) - marcel (~> 1.0.0) - mini_mime (>= 1.1.0) - activesupport (6.1.4.1) + rack (>= 2.0.8, < 4) + railties (>= 6.1) + activestorage (7.1.3.4) + actionpack (= 7.1.3.4) + activejob (= 7.1.3.4) + activerecord (= 7.1.3.4) + activesupport (= 7.1.3.4) + marcel (~> 1.0) + activesupport (7.1.3.4) + base64 + bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) + connection_pool (>= 2.2.5) + drb i18n (>= 1.6, < 2) minitest (>= 5.1) + mutex_m tzinfo (~> 2.0) - zeitwerk (~> 2.3) - addressable (2.8.0) - public_suffix (>= 2.0.2, < 5.0) - aes_key_wrap (1.1.0) - argon2 (2.0.3) - ffi (~> 1.14) + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) + argon2 (2.3.0) + ffi (~> 1.15) ffi-compiler (~> 1.0) ast (2.4.2) - autoprefixer-rails (10.3.3.0) + autoprefixer-rails (10.4.16.0) execjs (~> 2) - bindata (2.4.15) - bootstrap (4.6.0) + base64 (0.2.0) + bigdecimal (3.1.8) + bootstrap (4.6.2) autoprefixer-rails (>= 9.1.0) - popper_js (>= 1.14.3, < 2) + popper_js (>= 1.16.1, < 2) sassc-rails (>= 2.0.0) - brakeman (5.1.1) - builder (3.2.4) - bundler-audit (0.9.0.1) + brakeman (6.1.2) + racc + builder (3.3.0) + bundler-audit (0.9.1) bundler (>= 1.2.0, < 3) thor (~> 1.0) byebug (11.1.3) - cancancan (3.3.0) - capybara (3.35.3) + cancancan (3.6.1) + capybara (3.40.0) addressable + matrix mini_mime (>= 0.1.3) - nokogiri (~> 1.8) + nokogiri (~> 1.11) rack (>= 1.6.0) rack-test (>= 0.6.3) regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) + cgi (0.3.6) + childprocess (5.0.0) cliver (0.3.2) coderay (1.1.3) - concurrent-ruby (1.1.9) - connection_pool (2.2.5) + concurrent-ruby (1.3.3) + connection_pool (2.4.1) crass (1.0.6) daemons (1.4.1) - database_cleaner (2.0.1) - database_cleaner-active_record (~> 2.0.0) - database_cleaner-active_record (2.0.1) + database_cleaner (2.0.2) + database_cleaner-active_record (>= 2, < 3) + database_cleaner-active_record (2.2.0) activerecord (>= 5.a) database_cleaner-core (~> 2.0.0) database_cleaner-core (2.0.1) + date (3.3.4) declarative (0.0.20) - diff-lcs (1.4.4) - docile (1.4.0) - domain_name (0.5.20190701) - unf (>= 0.0.5, < 1.0.0) - doorkeeper (5.5.4) + diff-lcs (1.5.1) + docile (1.4.1) + domain_name (0.6.20240107) + doorkeeper (5.7.1) railties (>= 5) - doorkeeper-openid_connect (1.8.3) - doorkeeper (>= 5.5, < 5.7) - json-jwt (>= 1.15.0) - erubi (1.10.0) + doorkeeper-openid_connect (1.8.9) + doorkeeper (>= 5.5, < 5.8) + jwt (>= 2.5) + drb (2.2.1) + erubi (1.13.0) eventmachine (1.2.7) - execjs (2.8.1) - factory_bot (6.2.0) + execjs (2.9.1) + factory_bot (6.4.6) activesupport (>= 5.0.0) - factory_bot_rails (6.2.0) - factory_bot (~> 6.2.0) + factory_bot_rails (6.4.3) + factory_bot (~> 6.4) railties (>= 5.0.0) - faraday (1.8.0) + faraday (1.10.3) faraday-em_http (~> 1.0) faraday-em_synchrony (~> 1.0) faraday-excon (~> 1.1) - faraday-httpclient (~> 1.0.1) + faraday-httpclient (~> 1.0) + faraday-multipart (~> 1.0) faraday-net_http (~> 1.0) - faraday-net_http_persistent (~> 1.1) + faraday-net_http_persistent (~> 1.0) faraday-patron (~> 1.0) faraday-rack (~> 1.0) - multipart-post (>= 1.2, < 3) + faraday-retry (~> 1.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-multipart (1.0.4) + multipart-post (~> 2) + faraday-net_http (1.0.2) faraday-net_http_persistent (1.2.0) faraday-patron (1.0.0) faraday-rack (1.0.0) - ffi (1.15.4) - ffi-compiler (1.0.1) - ffi (>= 1.0.0) + faraday-retry (1.0.3) + ffi (1.17.0-aarch64-linux-gnu) + ffi (1.17.0-aarch64-linux-musl) + ffi (1.17.0-arm-linux-gnu) + ffi (1.17.0-arm-linux-musl) + ffi (1.17.0-arm64-darwin) + ffi (1.17.0-x86-linux-gnu) + ffi (1.17.0-x86-linux-musl) + ffi (1.17.0-x86_64-darwin) + ffi (1.17.0-x86_64-linux-gnu) + ffi (1.17.0-x86_64-linux-musl) + ffi-compiler (1.3.2) + ffi (>= 1.15.5) rake file_validators (3.0.0) activemodel (>= 3.2) mime-types (>= 1.0) - font-awesome-rails (4.7.0.7) - railties (>= 3.2, < 7) - globalid (0.5.2) - activesupport (>= 5.0) - google-apis-core (0.4.1) + font-awesome-rails (4.7.0.8) + railties (>= 3.2, < 8.0) + globalid (1.2.1) + activesupport (>= 6.1) + google-apis-core (0.11.3) addressable (~> 2.5, >= 2.5.1) googleauth (>= 0.16.2, < 2.a) httpclient (>= 2.8.1, < 3.a) @@ -165,11 +199,10 @@ GEM representable (~> 3.0) retriable (>= 2.0, < 4.a) rexml - webrick - google-apis-drive_v3 (0.14.0) - google-apis-core (>= 0.4, < 2.a) - google-apis-sheets_v4 (0.9.0) - google-apis-core (>= 0.4, < 2.a) + google-apis-drive_v3 (0.46.0) + google-apis-core (>= 0.11.0, < 2.a) + google-apis-sheets_v4 (0.26.0) + google-apis-core (>= 0.11.0, < 2.a) google_drive (3.0.7) google-apis-drive_v3 (>= 0.5.0, < 1.0.0) google-apis-sheets_v4 (>= 0.4.0, < 1.0.0) @@ -185,221 +218,265 @@ GEM gravtastic (3.2.6) hiredis (0.6.3) http-accept (1.7.0) - http-cookie (1.0.4) + http-cookie (1.0.6) domain_name (~> 0.5) httpclient (2.8.3) - i18n (1.8.10) + i18n (1.14.5) concurrent-ruby (~> 1.0) - image_processing (1.12.1) + image_processing (1.13.0) mini_magick (>= 4.9.5, < 5) ruby-vips (>= 2.0.17, < 3) - io-console (0.5.9) - irb (1.3.7) - reline (>= 0.2.7) - jquery-rails (4.4.0) + io-console (0.7.2) + irb (1.14.0) + rdoc (>= 4.0.0) + reline (>= 0.4.2) + jquery-rails (4.6.0) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) - json (2.6.0) - json-jwt (1.15.3) - activesupport (>= 4.2) - aes_key_wrap - bindata - httpclient - json-schema (2.8.1) - addressable (>= 2.4) - jwt (2.3.0) - launchy (2.5.0) - addressable (~> 2.7) - letter_opener (1.7.0) - launchy (~> 2.2) + json (2.7.2) + json-schema (4.3.1) + addressable (>= 2.8) + jwt (2.8.2) + base64 + language_server-protocol (3.17.0.3) + launchy (3.0.1) + addressable (~> 2.8) + childprocess (~> 5.0) + letter_opener (1.10.0) + launchy (>= 2.2, < 4) + logger (1.6.0) logstasher (2.1.5) activesupport (>= 5.2) request_store - loofah (2.12.0) + loofah (2.22.0) crass (~> 1.0.2) - nokogiri (>= 1.5.9) - mail (2.7.1) + nokogiri (>= 1.12.0) + mail (2.8.1) mini_mime (>= 0.1.1) - marcel (1.0.2) + net-imap + net-pop + net-smtp + marcel (1.0.4) + matrix (0.4.2) memoist (0.16.2) - method_source (1.0.0) - mime-types (3.3.1) + method_source (1.1.0) + mime-types (3.5.2) mime-types-data (~> 3.2015) - mime-types-data (3.2021.0901) + mime-types-data (3.2024.0702) mimic (0.4.4) json plist (~> 3.1.0) rack sinatra thin - mini_magick (4.11.0) - mini_mime (1.1.2) - mini_portile2 (2.6.1) - minitest (5.14.4) + mini_magick (4.13.2) + mini_mime (1.1.5) + minitest (5.24.1) multi_json (1.15.0) - multipart-post (2.1.1) - mustermann (1.1.1) + multipart-post (2.4.1) + mustermann (3.0.0) ruby2_keywords (~> 0.0.1) - natcmp (1.4.1) + mutex_m (0.2.0) + natcmp (1.4.3) + net-imap (0.4.14) + date + net-protocol + net-pop (0.1.2) + net-protocol + net-protocol (0.2.2) + timeout + net-smtp (0.5.0) + net-protocol netrc (0.11.0) - newrelic_rpm (8.0.0) - nio4r (2.5.8) - nokogiri (1.12.5) - mini_portile2 (~> 2.6.1) + newrelic_rpm (9.12.0) + nio4r (2.7.3) + nokogiri (1.16.7-aarch64-linux) + racc (~> 1.4) + nokogiri (1.16.7-arm-linux) + racc (~> 1.4) + nokogiri (1.16.7-arm64-darwin) racc (~> 1.4) - os (1.1.1) - parallel (1.21.0) - parser (3.0.2.0) + nokogiri (1.16.7-x86-linux) + racc (~> 1.4) + nokogiri (1.16.7-x86_64-darwin) + racc (~> 1.4) + nokogiri (1.16.7-x86_64-linux) + racc (~> 1.4) + os (1.1.4) + parallel (1.25.1) + parser (3.3.4.0) ast (~> 2.4.1) - pdfkit (0.8.5) - pg (1.2.3) - pghero (2.8.1) - activerecord (>= 5) + racc + pdfkit (0.8.7.3) + pg (1.5.7) + pghero (3.5.0) + activerecord (>= 6) plist (3.1.0) poltergeist (1.18.1) capybara (>= 2.1, < 4) cliver (~> 0.3.1) websocket-driver (>= 0.2.0) - popper_js (1.16.0) - pry (0.14.1) + popper_js (1.16.1) + pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) - pry-byebug (3.8.0) + pry-byebug (3.10.1) byebug (~> 11.0) - pry (~> 0.10) - pry-rails (0.3.9) - pry (>= 0.10.4) - public_suffix (4.0.6) - puma (5.5.2) + pry (>= 0.13, < 0.15) + pry-rails (0.3.11) + pry (>= 0.13.0) + psych (5.1.2) + stringio + public_suffix (6.0.1) + puma (6.4.2) nio4r (~> 2.0) - racc (1.5.2) - rack (2.2.3) - rack-attack (6.5.0) - rack (>= 1.0, < 3) - rack-cors (1.1.1) + racc (1.8.0) + rack (2.2.9) + rack-attack (6.7.0) + rack (>= 1.0, < 4) + rack-cors (2.0.2) rack (>= 2.0.0) - rack-mini-profiler (2.3.3) + rack-mini-profiler (3.3.1) rack (>= 1.2.0) - rack-protection (2.1.0) - rack - rack-test (1.1.0) - rack (>= 1.0, < 3) + rack-protection (3.2.0) + base64 (>= 0.1.0) + rack (~> 2.2, >= 2.2.4) + rack-session (1.0.2) + rack (< 3) + rack-test (2.1.0) + rack (>= 1.3) + rackup (1.0.0) + rack (< 3) + webrick railroady (1.6.0) - rails (6.1.4.1) - actioncable (= 6.1.4.1) - actionmailbox (= 6.1.4.1) - actionmailer (= 6.1.4.1) - actionpack (= 6.1.4.1) - actiontext (= 6.1.4.1) - actionview (= 6.1.4.1) - activejob (= 6.1.4.1) - activemodel (= 6.1.4.1) - activerecord (= 6.1.4.1) - activestorage (= 6.1.4.1) - activesupport (= 6.1.4.1) + rails (7.1.3.4) + actioncable (= 7.1.3.4) + actionmailbox (= 7.1.3.4) + actionmailer (= 7.1.3.4) + actionpack (= 7.1.3.4) + actiontext (= 7.1.3.4) + actionview (= 7.1.3.4) + activejob (= 7.1.3.4) + activemodel (= 7.1.3.4) + activerecord (= 7.1.3.4) + activestorage (= 7.1.3.4) + activesupport (= 7.1.3.4) bundler (>= 1.15.0) - railties (= 6.1.4.1) - sprockets-rails (>= 2.0.0) + railties (= 7.1.3.4) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1) activesupport (>= 5.0.1.rc1) - rails-dom-testing (2.0.3) - activesupport (>= 4.2.0) + rails-dom-testing (2.2.0) + activesupport (>= 5.0.0) + minitest nokogiri (>= 1.6) - rails-html-sanitizer (1.4.2) - loofah (~> 2.3) - railties (6.1.4.1) - actionpack (= 6.1.4.1) - activesupport (= 6.1.4.1) - method_source - rake (>= 0.13) - thor (~> 1.0) - rainbow (3.0.0) - rake (13.0.6) + rails-html-sanitizer (1.6.0) + loofah (~> 2.21) + nokogiri (~> 1.14) + railties (7.1.3.4) + actionpack (= 7.1.3.4) + activesupport (= 7.1.3.4) + irb + rackup (>= 1.0.0) + rake (>= 12.2) + thor (~> 1.0, >= 1.2.2) + zeitwerk (~> 2.6) + rainbow (3.1.1) + rake (13.2.1) + rdoc (6.7.0) + psych (>= 4.0.0) readthis (2.2.0) connection_pool (~> 2.1) redis (>= 3.0, < 5.0) - redis (4.5.0) - regexp_parser (2.1.1) - reline (0.2.7) + redis (4.8.1) + regexp_parser (2.9.2) + reline (0.5.9) io-console (~> 0.5) - representable (3.1.1) + representable (3.2.0) declarative (< 0.1.0) trailblazer-option (>= 0.1.1, < 0.2.0) uber (< 0.2.0) - request_store (1.5.0) + request_store (1.7.0) rack (>= 1.4) - responders (3.0.1) - actionpack (>= 5.0) - railties (>= 5.0) + responders (3.1.1) + actionpack (>= 5.2) + railties (>= 5.2) rest-client (2.1.0) http-accept (>= 1.7.0, < 2.0) http-cookie (>= 1.0.2, < 2.0) mime-types (>= 1.16, < 4.0) netrc (~> 0.8) retriable (3.1.2) - rexml (3.2.5) - rspec (3.10.0) - rspec-core (~> 3.10.0) - rspec-expectations (~> 3.10.0) - rspec-mocks (~> 3.10.0) - rspec-activemodel-mocks (1.1.0) + rexml (3.3.2) + strscan + rspec (3.13.0) + rspec-core (~> 3.13.0) + rspec-expectations (~> 3.13.0) + rspec-mocks (~> 3.13.0) + rspec-activemodel-mocks (1.2.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.13.0) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.1) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.10.0) - rspec-mocks (3.10.2) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.1) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.10.0) - rspec-rails (5.0.2) - actionpack (>= 5.2) - activesupport (>= 5.2) - railties (>= 5.2) - rspec-core (~> 3.10) - rspec-expectations (~> 3.10) - rspec-mocks (~> 3.10) - rspec-support (~> 3.10) - rspec-support (3.10.2) - rubocop (1.22.1) + rspec-support (~> 3.13.0) + rspec-rails (6.1.3) + actionpack (>= 6.1) + activesupport (>= 6.1) + railties (>= 6.1) + rspec-core (~> 3.13) + rspec-expectations (~> 3.13) + rspec-mocks (~> 3.13) + rspec-support (~> 3.13) + rspec-support (3.13.1) + rubocop (1.65.0) + json (~> 2.3) + language_server-protocol (>= 3.17.0) parallel (~> 1.10) - parser (>= 3.0.0.0) + parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.8, < 3.0) - rexml - rubocop-ast (>= 1.12.0, < 2.0) + regexp_parser (>= 2.4, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.31.1, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.12.0) - parser (>= 3.0.1.1) - rubocop-minitest (0.15.2) - rubocop (>= 0.90, < 2.0) - rubocop-packaging (0.5.1) - rubocop (>= 0.89, < 2.0) - rubocop-performance (1.11.5) - rubocop (>= 1.7.0, < 2.0) - rubocop-ast (>= 0.4.0) - rubocop-rails (2.12.3) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.31.3) + parser (>= 3.3.1.0) + rubocop-md (1.2.2) + rubocop (>= 1.0) + rubocop-minitest (0.35.1) + rubocop (>= 1.61, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) + rubocop-packaging (0.5.2) + rubocop (>= 1.33, < 2.0) + rubocop-performance (1.21.1) + rubocop (>= 1.48.1, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) + rubocop-rails (2.25.1) activesupport (>= 4.2.0) rack (>= 1.1) - rubocop (>= 1.7.0, < 2.0) - rubocop-rails_config (1.7.4) - railties (>= 5.0) - rubocop (>= 1.19) - rubocop-ast (>= 1.0.1) - rubocop-minitest (~> 0.15) + rubocop (>= 1.33.0, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) + rubocop-rails_config (1.16.0) + rubocop (>= 1.57.0) + rubocop-ast (>= 1.26.0) + rubocop-md + rubocop-minitest (~> 0.22) rubocop-packaging (~> 0.5) rubocop-performance (~> 1.11) rubocop-rails (~> 2.0) - ruby-prof (1.4.3) - ruby-progressbar (1.11.0) - ruby-vips (2.1.3) + ruby-prof (1.7.0) + ruby-progressbar (1.13.0) + ruby-vips (2.2.2) ffi (~> 1.12) + logger ruby2_keywords (0.0.5) sassc (2.4.0) ffi (~> 1.9) @@ -409,119 +486,133 @@ GEM sprockets (> 3.0) sprockets-rails tilt - signet (0.16.0) + signet (0.19.0) addressable (~> 2.8) - faraday (>= 0.17.3, < 2.0) + faraday (>= 0.17.5, < 3.a) jwt (>= 1.5, < 3.0) multi_json (~> 1.10) - simplecov (0.21.2) + simplecov (0.22.0) docile (~> 1.1) simplecov-html (~> 0.11) simplecov_json_formatter (~> 0.1) simplecov-html (0.12.3) - simplecov_json_formatter (0.1.3) - sinatra (2.1.0) - mustermann (~> 1.0) - rack (~> 2.2) - rack-protection (= 2.1.0) + simplecov_json_formatter (0.1.4) + sinatra (3.2.0) + mustermann (~> 3.0) + rack (~> 2.2, >= 2.2.4) + rack-protection (= 3.2.0) tilt (~> 2.0) - sprockets (4.0.2) + sprockets (4.2.1) concurrent-ruby (~> 1.0) - rack (> 1, < 3) - sprockets-rails (3.2.2) - actionpack (>= 4.0) - activesupport (>= 4.0) + rack (>= 2.2.4, < 4) + sprockets-rails (3.5.1) + actionpack (>= 6.1) + activesupport (>= 6.1) sprockets (>= 3.0.0) + stringio (3.1.1) + strscan (3.1.0) swagger-blocks (3.0.0) - thin (1.8.1) + thin (1.8.2) daemons (~> 1.0, >= 1.0.9) eventmachine (~> 1.0, >= 1.0.4) rack (>= 1, < 3) - thor (1.1.0) - tilt (2.0.10) - trailblazer-option (0.1.1) - tzinfo (2.0.4) + thor (1.3.1) + tilt (2.4.0) + timeout (0.4.1) + trailblazer-option (0.1.2) + tzinfo (2.0.6) concurrent-ruby (~> 1.0) uber (0.1.0) uglifier (4.2.0) execjs (>= 0.3.0, < 3) - unf (0.1.4) - unf_ext - unf_ext (0.0.8) - unicode-display_width (2.1.0) - webrick (1.7.0) - websocket-driver (0.7.5) + unicode-display_width (2.5.0) + webrick (1.8.1) + websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) xml-simple (1.1.9) rexml xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.4.2) + zeitwerk (2.6.16) PLATFORMS - ruby + aarch64-linux + aarch64-linux-gnu + aarch64-linux-musl + arm-linux + arm-linux-gnu + arm-linux-musl + arm64-darwin + x86-linux + x86-linux-gnu + x86-linux-musl + x86_64-darwin + x86_64-linux-gnu + x86_64-linux-musl DEPENDENCIES - activerecord-import (~> 1.2) - activerecord-session_store (~> 2.0) - argon2 (~> 2.0) + activerecord-import (~> 1.7) + activerecord-session_store (~> 2.1) + argon2 (~> 2.3) bootstrap (~> 4.6) - brakeman - bundler-audit - cancancan (~> 3.3) - capybara (~> 3.35) - database_cleaner (~> 2.0) - doorkeeper (~> 5.5) - doorkeeper-openid_connect - factory_bot_rails (~> 6.2) - file_validators - font-awesome-rails - google_drive (~> 3.0) - gravtastic (~> 3.2) - hiredis (~> 0.6) - image_processing - irb - jquery-rails (~> 4.4) - json-schema (~> 2.8) - launchy - letter_opener (~> 1.7) - logstasher (~> 2.1) - mimic (~> 0.4) - natcmp (~> 1.4) - newrelic_rpm (~> 8.0) - pdfkit (~> 0.8) - pg (~> 1.2) - pghero (~> 2.8) - poltergeist (~> 1.18) - pry - pry-byebug - pry-rails - puma (~> 5.5) - rack-attack (~> 6.5) - rack-cors (~> 1.1) - rack-mini-profiler (~> 2.3) - railroady - rails (~> 6.1) - rails-controller-testing - rake + brakeman (~> 6.1, >= 6.1.2) + bundler-audit (~> 0.9.1) + cancancan (~> 3.6, >= 3.6.1) + capybara (~> 3.40) + cgi (~> 0.3.6) + database_cleaner (~> 2.0, >= 2.0.2) + doorkeeper (~> 5.7, >= 5.7.1) + doorkeeper-openid_connect (~> 1.8, >= 1.8.9) + factory_bot_rails (~> 6.4, >= 6.4.3) + file_validators (~> 3.0) + font-awesome-rails (~> 4.7, >= 4.7.0.8) + google_drive (~> 3.0, >= 3.0.7) + gravtastic (~> 3.2, >= 3.2.6) + hiredis (~> 0.6.3) + image_processing (~> 1.12, >= 1.12.2) + irb (~> 1.14) + jquery-rails (~> 4.6) + json-schema (~> 4.3) + launchy (~> 3.0, >= 3.0.1) + letter_opener (~> 1.10) + logstasher (~> 2.1, >= 2.1.5) + mimic (~> 0.4.4) + natcmp (~> 1.4, >= 1.4.3) + newrelic_rpm (~> 9.11) + pdfkit (~> 0.8.7.3) + pg (~> 1.5, >= 1.5.6) + pghero (~> 3.5) + poltergeist (~> 1.18, >= 1.18.1) + pry (~> 0.14.2) + pry-byebug (~> 3.10, >= 3.10.1) + pry-rails (~> 0.3.11) + puma (~> 6.4, >= 6.4.2) + rack-attack (~> 6.7) + rack-cors (~> 2.0, >= 2.0.2) + rack-mini-profiler (~> 3.3, >= 3.3.1) + railroady (~> 1.6) + rails (~> 7.1, >= 7.1.3.4) + rails-controller-testing (~> 1.0, >= 1.0.5) + rake (~> 13.2, >= 13.2.1) readthis (~> 2.2) redis (~> 4.5) - responders (~> 3.0) + responders (~> 3.1, >= 3.1.1) rest-client (~> 2.1) - rspec (~> 3.10) - rspec-activemodel-mocks (~> 1.1) - rspec-core (~> 3.10) - rspec-rails (~> 5.0) - rubocop (~> 1.13) - rubocop-rails_config (~> 1.5) - ruby-prof (~> 1.4) - sassc-rails (~> 2.1) - simplecov - sprockets-rails + rspec (~> 3.13) + rspec-activemodel-mocks (~> 1.2) + rspec-core (~> 3.13) + rspec-rails (~> 6.1, >= 6.1.3) + rubocop (~> 1.65) + rubocop-rails_config (~> 1.16) + ruby-prof (~> 1.7) + sassc-rails (~> 2.1, >= 2.1.2) + simplecov (~> 0.22.0) + sprockets-rails (~> 3.5, >= 3.5.1) swagger-blocks (~> 3.0) + thin (~> 1.8, >= 1.8.2) uglifier (~> 4.2) - xml-simple (~> 1.1) + xml-simple (~> 1.1, >= 1.1.9) BUNDLED WITH - 1.17.3 + 2.5.16 diff --git a/Installation.md b/Installation.md index 2f2b864e1..2739c08b4 100644 --- a/Installation.md +++ b/Installation.md @@ -1,7 +1,7 @@ ## Setup ### Notices before installation -We assume you use [RVM](https://rvm.io/). If you don't, then replace `rvmsudo` with `sudo` during the installation process. +We assume you use [RVM](https://rvm.io/). If you don't, then replace `rvmsudo` with `sudo` during the installation process. > Note: Installation instructions works on WSL, but node needs to be installed according to [these](https://docs.microsoft.com/en-us/windows/nodejs/setup-on-wsl2) instructions. ### Installation instructions for Ubuntu We expect the user to be using account which name is tmc. @@ -24,7 +24,7 @@ RVM dependencies ```bash sudo apt-get install libgdbm-dev libncurses5-dev automake libtool bison libffi-dev ``` -ext/sandbox dependencies see [rage/sandbox](https://github.com/rage/sandbox) for latest deps +ext/sandbox dependencies see [rage/sandbox](https://github.com/rage/sandbox) for latest deps Requires docker to be installed aswell, read instructions [here](https://docs.docker.com/engine/install/ubuntu/). ``` sudo apt-get install tar zstd moreutils nodejs @@ -115,8 +115,8 @@ bundle install git submodule update --init --recursive ``` -You can view the site settings from the file `config/site.defaults.yml`. If you want to change the settings for the site, create a new file `config/site.yml` and define the changes there. -> Note: You do not need to copy the entire file. Settings not in `site.yml` will be looked up from `site.defaults.yml`. +You can view the site settings from the file `config/site.defaults.yml`. If you want to change the settings for the site, create a new file `config/site.yml` and define the changes there. +> Note: You do not need to copy the entire file. Settings not in `site.yml` will be looked up from `site.defaults.yml`. :exclamation: For development environment you can run command `cp config/site.dev.yml config/site.yml` Initialize the database with `bin/rails db:create db:migrate` diff --git a/app/background_tasks/refresh_course_task.rb b/app/background_tasks/refresh_course_task.rb index 3d6888593..230194e1d 100644 --- a/app/background_tasks/refresh_course_task.rb +++ b/app/background_tasks/refresh_course_task.rb @@ -2,6 +2,7 @@ require 'rust_langs_cli_executor' require 'fileutils' +require 'course_refresh_database_updater' class RefreshCourseTask def initialize @@ -62,6 +63,7 @@ def wait_delay private def broadcast_to_channel(id, msg, percent, time, refresh_id = nil) + Rails.logger.info("Broadcasting message: #{msg} to channel CourseTemplateRefreshChannel-#{id}, Percent done: #{percent}, Time: #{time}, Course Template Refresh ID: #{refresh_id}") ActionCable.server.broadcast("CourseTemplateRefreshChannel-#{id}", { message: msg, percent_done: percent, diff --git a/app/background_tasks/sandbox_status_fetcher_task.rb b/app/background_tasks/sandbox_status_fetcher_task.rb index 90554a3ee..8332aa12f 100644 --- a/app/background_tasks/sandbox_status_fetcher_task.rb +++ b/app/background_tasks/sandbox_status_fetcher_task.rb @@ -2,7 +2,6 @@ require 'json' require 'benchmark' -require 'remote_sandbox' class SandboxStatusFetcherTask def initialize diff --git a/app/controllers/api/beta/participant_controller.rb b/app/controllers/api/beta/participant_controller.rb index 9dcd19c22..0fb47402f 100644 --- a/app/controllers/api/beta/participant_controller.rb +++ b/app/controllers/api/beta/participant_controller.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require 'course_list' + class Api::Beta::ParticipantController < Api::Beta::BaseController before_action :doorkeeper_authorize!, scopes: [:public] diff --git a/app/controllers/api/v8/base_controller.rb b/app/controllers/api/v8/base_controller.rb index f8e633da1..a83f1c1c8 100644 --- a/app/controllers/api/v8/base_controller.rb +++ b/app/controllers/api/v8/base_controller.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require 'json' +require 'version' module Api module V8 diff --git a/app/controllers/api/v8/core/courses/reviews_controller.rb b/app/controllers/api/v8/core/courses/reviews_controller.rb index b79fb2971..04e34df6a 100644 --- a/app/controllers/api/v8/core/courses/reviews_controller.rb +++ b/app/controllers/api/v8/core/courses/reviews_controller.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require 'natsort' + module Api module V8 module Core diff --git a/app/controllers/api/v8/core/exercises/submissions_controller.rb b/app/controllers/api/v8/core/exercises/submissions_controller.rb index ea5f5f113..d7f808e4b 100644 --- a/app/controllers/api/v8/core/exercises/submissions_controller.rb +++ b/app/controllers/api/v8/core/exercises/submissions_controller.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require 'submission_processor' + module Api module V8 module Core diff --git a/app/controllers/api/v8/core/exercises_controller.rb b/app/controllers/api/v8/core/exercises_controller.rb index 853b60ebe..dcc30ab66 100644 --- a/app/controllers/api/v8/core/exercises_controller.rb +++ b/app/controllers/api/v8/core/exercises_controller.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require 'submission_list' + module Api module V8 module Core diff --git a/app/controllers/api/v8/core/submissions/reviews_controller.rb b/app/controllers/api/v8/core/submissions/reviews_controller.rb index dc74c0db8..8ccf4ab9f 100644 --- a/app/controllers/api/v8/core/submissions/reviews_controller.rb +++ b/app/controllers/api/v8/core/submissions/reviews_controller.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require 'natsort' + module Api module V8 module Core diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 3acfbd90f..0e41547c4 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require 'version' -require 'twitter-bootstrap-breadcrumbs' +require 'twitter_bootstrap_breadcrumbs' # Base class for all controllers. # diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 406e15c0f..119aab198 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -1,9 +1,10 @@ # frozen_string_literal: true require 'natsort' -require 'course_list' require 'exercise_completion_status_generator' require 'json' +require 'course_list' +require 'course_info' class CoursesController < ApplicationController before_action :set_organization diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index b0d7d81c6..d9e634818 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require 'submission_list' + class ExercisesController < ApplicationController def show @exercise = Exercise.find(params[:id]) diff --git a/app/controllers/full_zip_controller.rb b/app/controllers/full_zip_controller.rb index 8927da7a2..8988a5861 100644 --- a/app/controllers/full_zip_controller.rb +++ b/app/controllers/full_zip_controller.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require 'submission_packager' + class FullZipController < ApplicationController def index submission = Submission.find(params[:submission_id]) diff --git a/app/controllers/migrate_to_other_course_controller.rb b/app/controllers/migrate_to_other_course_controller.rb index 29cce6f71..861b8bedd 100644 --- a/app/controllers/migrate_to_other_course_controller.rb +++ b/app/controllers/migrate_to_other_course_controller.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require 'student_submission_migrator' + class MigrateToOtherCourseController < ApplicationController def show @old_course = Course.find(params[:course_id]) @@ -11,7 +13,7 @@ def show @already_migrated = already_migrated @extra_alert_text = get_extra_text return respond_with_error('Please login to continue') if current_user.guest? - return respond_with_error('This migration is not allowed') unless StudentSubmissionMigrator.new(@old_course, @to_course, current_user).migration_is_allowed + respond_with_error('This migration is not allowed') unless StudentSubmissionMigrator.new(@old_course, @to_course, current_user).migration_is_allowed end def migrate diff --git a/app/controllers/setup/course_details_controller.rb b/app/controllers/setup/course_details_controller.rb index b1cd448e0..e46aa4c85 100644 --- a/app/controllers/setup/course_details_controller.rb +++ b/app/controllers/setup/course_details_controller.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require 'course_refresh_database_updater' + class Setup::CourseDetailsController < Setup::SetupController before_action :set_course, except: %i[new create] diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index f1c102983..acdc9ccef 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -80,7 +80,7 @@ def bs_labeled_field(label, field, options = {}) str << " #{field}#{label}" str << '' else - label_title = options[:label_title] ? options[:label_title] : nil + label_title = options[:label_title] || nil label = label_tag label, label_title, class: 'control-label' str += raw('
' + raw(label) + raw(field) + '
') end diff --git a/app/models/available_point.rb b/app/models/available_point.rb index 3a55f0e59..9a17b6636 100644 --- a/app/models/available_point.rb +++ b/app/models/available_point.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require 'point_comparison' + # Caches points that can be awarded from an exercise. # Awarded points don't have a hard reference to these because # these are recreated every time a course is refreshed. diff --git a/app/models/awarded_point.rb b/app/models/awarded_point.rb index 71af9c876..c4873d112 100644 --- a/app/models/awarded_point.rb +++ b/app/models/awarded_point.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require 'point_comparison' + # Stores when a point (course_id, name) has been awared to a particular user. # # There is a reference to the submission that first awarded the point, but this @@ -49,7 +51,7 @@ def self.as_json_with_exercise_ids(related_exercises) belongs_to :course belongs_to :user - belongs_to :submission + belongs_to :submission, optional: true after_save :create_organization_membership after_save :kafka_update_points diff --git a/app/models/course.rb b/app/models/course.rb index c05371b67..4cc9db8ef 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -538,10 +538,6 @@ def external_scoreboard_url=(url) super(url) end - def contains_unlock_deadlines? - exercise_groups.any?(&:contains_unlock_deadlines?) - end - def has_external_scoreboard_url? external_scoreboard_url.present? end diff --git a/app/models/course_template.rb b/app/models/course_template.rb index ad3593746..9cae1c46c 100644 --- a/app/models/course_template.rb +++ b/app/models/course_template.rb @@ -3,6 +3,7 @@ # Course stub to be copied by teachers for their own organisations require 'net/http' +require 'system_commands' class CourseTemplate < ApplicationRecord include SystemCommands diff --git a/app/models/course_template_refresh_report.rb b/app/models/course_template_refresh_report.rb index 4ed21d060..70a7f816e 100644 --- a/app/models/course_template_refresh_report.rb +++ b/app/models/course_template_refresh_report.rb @@ -2,10 +2,10 @@ class CourseTemplateRefreshReport < ApplicationRecord belongs_to :course_template_refresh - serialize :refresh_errors, Array - serialize :refresh_warnings, Array - serialize :refresh_notices, Array - serialize :refresh_timings, Hash + serialize :refresh_errors, class: Array, coder: JSON + serialize :refresh_warnings, class: Array, coder: JSON + serialize :refresh_notices, class: Array, coder: JSON + serialize :refresh_timings, class: Hash, coder: JSON attr_reader :refresh_errors attr_reader :refresh_warnings diff --git a/app/models/deadline_spec.rb b/app/models/deadline_spec.rb index 23d29336f..fe9eabd39 100644 --- a/app/models/deadline_spec.rb +++ b/app/models/deadline_spec.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require 'date_and_time_utils' + # Parses and abstracts specification in the "deadline" field of a `metadata.yml` file. class DeadlineSpec # (the name of this class is unfortunate as it confuses IDEs when jumping to tests) class InvalidSyntaxError < StandardError; end diff --git a/app/models/exercise.rb b/app/models/exercise.rb index a606f5e8e..303c17164 100644 --- a/app/models/exercise.rb +++ b/app/models/exercise.rb @@ -2,6 +2,8 @@ require 'shellwords' +require 'date_and_time_utils' + class Exercise < ApplicationRecord self.include_root_in_json = false include Swagger::Blocks diff --git a/app/models/extra_field.rb b/app/models/extra_field.rb index f235ff71b..c3e166922 100644 --- a/app/models/extra_field.rb +++ b/app/models/extra_field.rb @@ -89,7 +89,6 @@ def self.load_fields(kind, config_file_path) kind = kind.to_s - require "#{kind}_field" cls_name = "#{kind.camelize}Field" cls = Object.const_get(cls_name) diff --git a/app/models/organization.rb b/app/models/organization.rb index f5e3cc9e6..68ff32b2d 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -37,7 +37,7 @@ class Organization < ApplicationRecord has_many :organization_memberships, dependent: :destroy has_many :members, through: :organization_memberships, source: :user - belongs_to :creator, class_name: 'User' + belongs_to :creator, class_name: 'User', optional: true has_one_attached :logo validates :logo, file_content_type: { diff --git a/app/models/organization_membership.rb b/app/models/organization_membership.rb index b3303c56d..8d6ca9741 100644 --- a/app/models/organization_membership.rb +++ b/app/models/organization_membership.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true class OrganizationMembership < ApplicationRecord - belongs_to :user - belongs_to :organization + belongs_to :user, optional: true + belongs_to :organization, optional: true validates :user, presence: { message: 'does not exist' }, diff --git a/app/models/submission.rb b/app/models/submission.rb index 7a7d25de7..31eb5385f 100644 --- a/app/models/submission.rb +++ b/app/models/submission.rb @@ -2,6 +2,7 @@ require 'zlib' require 'securerandom' +require 'submission_packager' class Submission < ApplicationRecord include Swagger::Blocks @@ -69,7 +70,7 @@ class Submission < ApplicationRecord # Used when doing submissions.include(:exercises) Exercise.joins(:submission) end - end), foreign_key: :exercise_name, primary_key: :name + end), foreign_key: :exercise_name, primary_key: :name, optional: true has_one :submission_data, dependent: :delete after_save { submission_data&.save! } @@ -224,7 +225,7 @@ def test_case_records successful: tcr.successful?, message: tcr.message, exception: tcr.exception ? ActiveSupport::JSON.decode(tcr.exception) : nil, - detailed_message: tcr.detailed_message ? tcr.detailed_message : nil + detailed_message: tcr.detailed_message || nil } end end diff --git a/app/models/unlock_spec.rb b/app/models/unlock_spec.rb index 360e28694..31f9d373c 100644 --- a/app/models/unlock_spec.rb +++ b/app/models/unlock_spec.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require 'date_and_time_utils' + # Parses and abstracts specification in the "unlocked_after" field of a `metadata.yml` file. class UnlockSpec # (the name of this class is unfortunate as it confuses IDEs when jumping to tests) class InvalidSyntaxError < StandardError; end diff --git a/app/models/user.rb b/app/models/user.rb index 8989657bf..721e5c041 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -146,7 +146,7 @@ def self.authenticate(login, submitted_password) user = find_by(login: login) user ||= find_by('lower(email) = ?', login.downcase) return nil if user.nil? - return user if user.has_password?(submitted_password) + user if user.has_password?(submitted_password) end def password_reset_key diff --git a/app/models/validators/feedback_answer_format_validator.rb b/app/models/validators/feedback_answer_format_validator.rb index 67544529a..8bc88c8bb 100644 --- a/app/models/validators/feedback_answer_format_validator.rb +++ b/app/models/validators/feedback_answer_format_validator.rb @@ -4,19 +4,18 @@ class Validators::FeedbackAnswerFormatValidator < ActiveModel::Validator def validate(record) kind = record.feedback_question.kind ans = record.answer.strip - errors = record.errors[:answer] if kind =~ FeedbackQuestion.send(:intrange_regex) range = (Regexp.last_match(1).to_i)..(Regexp.last_match(2).to_i) if !/^(-?\d+)$/.match?(ans) - errors << 'is not an integer' + record.errors.add(:answer, 'is not an integer') elsif !range.include?(ans.to_i) - errors << "is not between #{range.first}..#{range.last}" + record.errors.add(:answer, "is not between #{range.first}..#{range.last}") end elsif kind == 'text' - errors << 'empty' if ans.blank? + record.errors.add(:answer, 'empty') if ans.blank? else - errors << "unacceptable since question type '#{kind}' is unknown" + record.errors.add(:answer, "unacceptable since question type '#{kind}' is unknown") end end end diff --git a/app/views/courses/_refresh_report.html.erb b/app/views/courses/_refresh_report.html.erb index ee7ede2ea..e1d7c5d95 100644 --- a/app/views/courses/_refresh_report.html.erb +++ b/app/views/courses/_refresh_report.html.erb @@ -81,7 +81,7 @@ <% report.course_template_refresh_report['refresh_timings'].each do |k,v| %> <%= simple_format k.to_s.split("_").join(" ").capitalize(), {}, wrapper_tag: 'span' %> - <%= "%.3f" % v.real %> + <%= "%.3f" % v["real"] %> <% end %> diff --git a/app/views/unlocks/show.html.erb b/app/views/unlocks/show.html.erb index a07515866..ca174c7f2 100644 --- a/app/views/unlocks/show.html.erb +++ b/app/views/unlocks/show.html.erb @@ -11,4 +11,4 @@ <% end %> -<%= button_to "Unlock these exercises", organization_course_unlock_path %> +<%= button_to "Unlock these exercises", organization_course_unlock_path, method: :post %> diff --git a/config/application.rb b/config/application.rb index df2d91b6f..6c61f3e3a 100644 --- a/config/application.rb +++ b/config/application.rb @@ -14,7 +14,7 @@ class Application < Rails::Application # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. - # config.load_defaults 6.1 + config.load_defaults 7.1 # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. @@ -30,7 +30,7 @@ class Application < Rails::Application config.filter_parameters += %i[password session_id api_password submission_file return_file test_output stdout stderr vm_log] # Do not swallow errors in after_commit/after_rollback callbacks. - config.eager_load_paths << Rails.root.join('lib') + # config.eager_load_paths << Rails.root.join('lib') config.relative_url_root = SiteSetting.value('base_path') diff --git a/config/environments/development.rb b/config/environments/development.rb index d9ecadd80..3a8b36dce 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -58,4 +58,6 @@ else config.cache_store = :memory_store, { size: 64.megabytes } end + + config.hosts << URI.parse(SiteSetting.value('baseurl_for_remote_sandboxes')).host end diff --git a/config/environments/production.rb b/config/environments/production.rb index b01a6f5f4..459bfdb5c 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -114,4 +114,6 @@ config.active_record.dump_schema_after_migration = false config.wkhtmltopdf = 'xvfb-run wkhtmltopdf' + + config.hosts << URI.parse(SiteSetting.value('baseurl_for_remote_sandboxes')).host end diff --git a/config/initializers/rack_attack.rb b/config/initializers/rack_attack.rb index c905789e8..e2ed47366 100644 --- a/config/initializers/rack_attack.rb +++ b/config/initializers/rack_attack.rb @@ -34,7 +34,7 @@ def self.user_identifier_discriminator(access_token) end # Return 503 Service Unavailable for throttles - self.throttled_response = lambda do |env| + self.throttled_responder = lambda do |env| [ 503, # status {}, # headers ["Service Unavailable\n"] # body diff --git a/config/site_tailoring.example.rb b/config/site_tailoring.example.rb index 0a52f5328..20afcbed7 100644 --- a/config/site_tailoring.example.rb +++ b/config/site_tailoring.example.rb @@ -2,5 +2,7 @@ # Optionally copy this file to site_tailoring.rb and # override methods defined in lib/tailoring.rb here. +require 'tailoring' + class SiteTailoring < Tailoring end diff --git a/lib/course_info.rb b/lib/course_info.rb index c03aec6bf..882390752 100644 --- a/lib/course_info.rb +++ b/lib/course_info.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require 'natsort' +require 'course_list' # Builds /courses/:id.json class CourseInfo diff --git a/lib/course_list.rb b/lib/course_list.rb index ef5f1c5c8..a0a608f08 100644 --- a/lib/course_list.rb +++ b/lib/course_list.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require 'natsort' + # Builds /courses.json class CourseList def initialize(user, helpers) diff --git a/lib/course_refresh_database_updater.rb b/lib/course_refresh_database_updater.rb index 95819bb76..ff9bc3ca9 100644 --- a/lib/course_refresh_database_updater.rb +++ b/lib/course_refresh_database_updater.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require 'benchmark' +require 'system_commands' class CourseRefreshDatabaseUpdater def refresh_course(course, refreshed_course_data) diff --git a/lib/doc_gen/shell_session.rb b/lib/doc_gen/shell_session.rb index 338e91d8b..99e2089fe 100644 --- a/lib/doc_gen/shell_session.rb +++ b/lib/doc_gen/shell_session.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require 'cgi' # for escapeHTML +require 'doc_gen' class DocGen # A shell session where the interaction can be printed to the generated document. diff --git a/app/models/point_comparison.rb b/lib/point_comparison.rb similarity index 100% rename from app/models/point_comparison.rb rename to lib/point_comparison.rb diff --git a/lib/sandbox_results_saver.rb b/lib/sandbox_results_saver.rb index ff5663f94..1b978f829 100644 --- a/lib/sandbox_results_saver.rb +++ b/lib/sandbox_results_saver.rb @@ -3,6 +3,8 @@ # Saves results from a remote sandbox to the database. # # See also: TestRunGrader +require 'test_run_grader' + module SandboxResultsSaver class InvalidTokenError < RuntimeError; end diff --git a/lib/submission_packager.rb b/lib/submission_packager.rb index bcb18abca..49df1f36d 100644 --- a/lib/submission_packager.rb +++ b/lib/submission_packager.rb @@ -2,6 +2,7 @@ require 'tmpdir' require 'fileutils' +require 'rust_langs_cli_executor' # Takes a submission zip and makes a tar file suitable for the sandbox class SubmissionPackager diff --git a/lib/twitter-bootstrap-breadcrumbs.rb b/lib/twitter-bootstrap-breadcrumbs.rb deleted file mode 100644 index 4d36a9314..000000000 --- a/lib/twitter-bootstrap-breadcrumbs.rb +++ /dev/null @@ -1,39 +0,0 @@ -# frozen_string_literal: true - -module BreadCrumbs - def self.included(base) - base.extend(ClassMethods) - end - - module ClassMethods - def add_breadcrumb(name, url, options = {}) - class_name = self.name - before_action options do |controller| - name = controller.send :translate_breadcrumb, name, class_name if name.is_a?(Symbol) - controller.send :add_breadcrumb, name, url - end - end - end - - protected - def add_breadcrumb(name, url = '', options = {}) - @breadcrumbs ||= [] - name = translate_breadcrumb(name, self.class.name) if name.is_a?(Symbol) - url = eval(url.to_s) if url =~ /_path|_url|@/ # rubocop:disable Performance/RegexpMatch - @breadcrumbs << { name: name, url: url, options: options } - end - - def translate_breadcrumb(name, class_name) - scope = [:breadcrumbs] - namespace = class_name.underscore.split('/') - namespace.last.sub!('_controller', '') - scope += namespace - - I18n.t name, scope: scope - end - - def render_breadcrumbs(divider = '/') - s = render partial: 'twitter-bootstrap/breadcrumbs', locals: { divider: divider } - s.first - end -end diff --git a/lib/twitter_bootstrap_breadcrumbs.rb b/lib/twitter_bootstrap_breadcrumbs.rb new file mode 100644 index 000000000..1953579d5 --- /dev/null +++ b/lib/twitter_bootstrap_breadcrumbs.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +module BreadCrumbs + def self.included(base) + base.extend(ClassMethods) + end + + module ClassMethods + def add_breadcrumb(name, url, options = {}) + class_name = self.name + before_action options do |controller| + name = controller.send :translate_breadcrumb, name, class_name if name.is_a?(Symbol) + controller.send :add_breadcrumb, name, url + end + end + end + + protected + def add_breadcrumb(name, url = '', options = {}) + @breadcrumbs ||= [] + name = translate_breadcrumb(name, self.class.name) if name.is_a?(Symbol) + url = eval(url.to_s) if url.class != Proc && url =~ /_path|_url|@/ # rubocop:disable Performance/RegexpMatch + @breadcrumbs << { name: name, url: url, options: options } + end + + def translate_breadcrumb(name, class_name) + scope = [:breadcrumbs] + namespace = class_name.underscore.split('/') + namespace.last.sub!('_controller', '') + scope += namespace + + I18n.t name, scope: scope + end + + def render_breadcrumbs(divider = '/') + s = render partial: 'twitter-bootstrap/breadcrumbs', locals: { divider: divider } + s.first + end +end diff --git a/script/background_daemon b/script/background_daemon index 320ca331e..02a67c509 100755 --- a/script/background_daemon +++ b/script/background_daemon @@ -3,8 +3,11 @@ require 'rubygems' require 'fileutils' +require 'active_support' +require 'active_support/core_ext' require_relative '../config/environment' require 'background_task_registry' +require 'logger' root_dir = File.expand_path('../', File.dirname(__FILE__)) pid_dir = root_dir + '/tmp/pids' @@ -18,7 +21,19 @@ end Dir.chdir root_dir require root_dir + '/config/environment' -Rails.logger = Logger.new(Rails.root.join('log', 'background_daemon.log')) + +stdout_logger = Logger.new(STDOUT) +stdout_logger.formatter = proc do |severity, datetime, progname, msg| + "#{datetime}: #{severity} - #{msg}\n" +end + +file_logger = Logger.new(Rails.root.join('log', 'background_daemon.log')) +file_logger.formatter = proc do |severity, datetime, progname, msg| + "#{datetime}: #{severity} - #{msg}\n" +end + +Rails.logger = ActiveSupport::BroadcastLogger.new(stdout_logger, file_logger) + Rails.logger.auto_flushing = true if Rails.logger.respond_to? :auto_flushing= Rails.logger.info 'Starting background_daemon' # ActiveRecord::Base.connection_config[:pool] = 25 @@ -27,14 +42,19 @@ Rails.logger.info 'Starting background_daemon' # block other ones. processes = BackgroundTaskRegistry.all_tasks.map do |task| Process.fork do + last_reminder_time = nil loop do begin + if last_reminder_time.nil? || Time.zone.now - last_reminder_time > 10.minutes + Rails.logger.info "Occasional reminder that #{task.class.name} is running." + last_reminder_time = Time.zone.now + end task.run rescue StandardError => e Rails.logger.error "#{task.class.name} exception: " + exception_to_str(e) begin - ActiveRecord::Base.clear_active_connections! + ActiveRecord::Base.connection_handler.clear_active_connections! rescue StandardError => e2 Rails.logger.error 'Failed to get rid of used db connections: ' + exception_to_str(e2) end diff --git a/spec/controllers/course_templates_controller_spec.rb b/spec/controllers/course_templates_controller_spec.rb index fbf3129ab..ef07436e6 100644 --- a/spec/controllers/course_templates_controller_spec.rb +++ b/spec/controllers/course_templates_controller_spec.rb @@ -165,7 +165,7 @@ describe 'GET new' do it 'should respond with a 403' do - get :new, {} + get :new expect(response.code.to_i).to eq(403) end end @@ -237,7 +237,7 @@ it 'should respond with a 302 and redirect to login with correct return_to param' do get :index, params: {} expect(response.code.to_i).to eq(302) - expect(response.body).to include('/login?return_to=%2Fcourse_templates') + expect(response.headers['Location']).to include('/login?return_to=%2Fcourse_templates') end end @@ -249,15 +249,15 @@ it 'should respond with a 302 and redirect to login with correct return_to param' do get :edit, params: { id: @course_template.to_param } expect(response.code.to_i).to eq(302) - expect(response.body).to include('/login?return_to=%2Fcourse_templates') + expect(response.headers['Location']).to include('/login?return_to=%2Fcourse_templates') end end describe 'GET new' do it 'should respond with a 302 and redirect to login with correct return_to param' do - get :new, {} + get :new expect(response.code.to_i).to eq(302) - expect(response.body).to include('/login?return_to=%2Fcourse_templates') + expect(response.headers['Location']).to include('/login?return_to=%2Fcourse_templates') end end @@ -269,7 +269,7 @@ it 'should respond with a 302 and redirect to login with correct return_to param' do get :edit, params: { id: @course_template.to_param } expect(response.code.to_i).to eq(302) - expect(response.body).to include('/login?return_to=%2Fcourse_templates') + expect(response.headers['Location']).to include('/login?return_to=%2Fcourse_templates') end end @@ -283,7 +283,7 @@ it 'should respond with a 302 and redirect to login with correct return_to param' do post :create, params: { course_template: valid_attributes } expect(response.code.to_i).to eq(302) - expect(response.body).to include('/login?return_to=%2Fcourse_templates') + expect(response.headers['Location']).to include('/login?return_to=%2Fcourse_templates') end end @@ -300,7 +300,7 @@ it 'should respond with a 302 and redirect to login with correct return_to param' do put :update, params: { id: @course_template.to_param, course_template: invalid_attributes } expect(response.code.to_i).to eq(302) - expect(response.body).to include('/login?return_to=%2Fcourse_templates') + expect(response.headers['Location']).to include('/login?return_to=%2Fcourse_templates') end end @@ -318,7 +318,7 @@ it 'should respond with a 302 and redirect to login with correct return_to param' do delete :destroy, params: { id: @course_template.to_param } expect(response.code.to_i).to eq(302) - expect(response.body).to include('/login?return_to=%2Fcourse_templates') + expect(response.headers['Location']).to include('/login?return_to=%2Fcourse_templates') end end end diff --git a/spec/controllers/feedback_replies_controller_spec.rb b/spec/controllers/feedback_replies_controller_spec.rb index 0e40f83a5..f594ce92d 100644 --- a/spec/controllers/feedback_replies_controller_spec.rb +++ b/spec/controllers/feedback_replies_controller_spec.rb @@ -29,7 +29,7 @@ describe 'for an admin user' do let(:admin) { FactoryBot.create(:admin, email: 'admin@mydomain.com') } - let(:url) { 'http://url.where.we.arrived.com' } + let(:url) { 'http://test.host/referer' } before do controller.current_user = admin request.env['HTTP_REFERER'] = url diff --git a/spec/controllers/organizations_controller_spec.rb b/spec/controllers/organizations_controller_spec.rb index cdfddcf3c..86910fa29 100644 --- a/spec/controllers/organizations_controller_spec.rb +++ b/spec/controllers/organizations_controller_spec.rb @@ -53,7 +53,7 @@ end it 'lists only pending organization requests' do - get :list_requests, {} + get :list_requests expect(assigns(:unverified_organizations).sort).to eq([@org1, @org3].sort) end end @@ -124,7 +124,7 @@ describe 'GET list_requests' do it 'denies access' do - get :list_requests, {} + get :list_requests expect(response.code.to_i).to eq(403) end end diff --git a/spec/controllers/participants_controller_spec.rb b/spec/controllers/participants_controller_spec.rb index a363d1b54..518007ba7 100644 --- a/spec/controllers/participants_controller_spec.rb +++ b/spec/controllers/participants_controller_spec.rb @@ -23,7 +23,7 @@ it 'redirects me to login page' do get :me expect(response.code.to_i).to eq(302) - expect(response.body).to include('login?return_to=%2Fparticipants%2Fme') + expect(response.headers['Location']).to include('login?return_to=%2Fparticipants%2Fme') end end end diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index 6963b80e0..190fc86e0 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -12,7 +12,7 @@ it 'should redirect to login page' do get :show expect(response.status).to eq(302) - expect(response.body).to include('/login?return_to=%2Fuser') + expect(response.headers['Location']).to include('/login?return_to=%2Fuser') end it 'should deny access if signup is disabled in site settings' do diff --git a/spec/integration/admin_usecases_spec.rb b/spec/integration/admin_usecases_spec.rb index 302ae5c4b..755b91075 100644 --- a/spec/integration/admin_usecases_spec.rb +++ b/spec/integration/admin_usecases_spec.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require 'spec_helper' +require 'submission_processor' describe 'The system (used by an instructor for administration)', type: :request, integration: true do include IntegrationTestActions diff --git a/spec/lib/course_refresh_database_updater_spec.rb b/spec/lib/course_refresh_database_updater_spec.rb index 46e23bbce..5a27223b9 100644 --- a/spec/lib/course_refresh_database_updater_spec.rb +++ b/spec/lib/course_refresh_database_updater_spec.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require 'spec_helper' +require 'course_refresh_database_updater' describe CourseRefreshDatabaseUpdater do include GitTestActions diff --git a/spec/lib/date_and_time_utils_spec.rb b/spec/lib/date_and_time_utils_spec.rb index 94eb20d20..c27f19b2f 100644 --- a/spec/lib/date_and_time_utils_spec.rb +++ b/spec/lib/date_and_time_utils_spec.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require 'spec_helper' +require 'date_and_time_utils' describe DateAndTimeUtils do describe '#to_time' do diff --git a/spec/lib/file_tree_hasher_spec.rb b/spec/lib/file_tree_hasher_spec.rb index 572b61a81..58c7055b6 100644 --- a/spec/lib/file_tree_hasher_spec.rb +++ b/spec/lib/file_tree_hasher_spec.rb @@ -2,6 +2,7 @@ require 'spec_helper' require 'fileutils' +require 'file_tree_hasher' describe FileTreeHasher do def write_file(path, content) diff --git a/spec/lib/submission_packager/java_maven_spec.rb b/spec/lib/submission_packager/java_maven_spec.rb index ca73bf354..2c7b68492 100644 --- a/spec/lib/submission_packager/java_maven_spec.rb +++ b/spec/lib/submission_packager/java_maven_spec.rb @@ -4,6 +4,8 @@ require 'tmpdir' require 'shellwords' require 'system_commands' +require 'submission_packager' +require 'rust_langs_cli_executor' # There is some functionality in common with JavaSimple. We mostly only test that in java_simple_spec.rb. describe SubmissionPackager do diff --git a/spec/lib/submission_processor_spec.rb b/spec/lib/submission_processor_spec.rb index a0685378c..3067d9869 100644 --- a/spec/lib/submission_processor_spec.rb +++ b/spec/lib/submission_processor_spec.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require 'spec_helper' +require 'submission_processor' describe SubmissionProcessor do def expect_processing diff --git a/spec/lib/test_run_grader_spec.rb b/spec/lib/test_run_grader_spec.rb index 718dbf208..1033b6423 100644 --- a/spec/lib/test_run_grader_spec.rb +++ b/spec/lib/test_run_grader_spec.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require 'spec_helper' +require 'test_run_grader' describe TestRunGrader do include GitTestActions diff --git a/spec/lib/version_spec.rb b/spec/lib/version_spec.rb index aa52dc14d..bf3976838 100644 --- a/spec/lib/version_spec.rb +++ b/spec/lib/version_spec.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require 'spec_helper' +require 'version' describe Version do it 'splits the version string into components' do diff --git a/spec/models/assistantship_spec.rb b/spec/models/assistantship_spec.rb index 98c85f754..6a35e87d3 100644 --- a/spec/models/assistantship_spec.rb +++ b/spec/models/assistantship_spec.rb @@ -18,13 +18,13 @@ it "can't create assistantship if course is non-existant" do user = FactoryBot.create :user course = FactoryBot.create :course - expect { Assistantship.create! user_id: user.id, course_id: course.id + 1 }.to raise_error("Validation failed: Course can't be blank") + expect { Assistantship.create! user_id: user.id, course_id: course.id + 1 }.to raise_error("Validation failed: Course must exist, Course can't be blank") end it "can't create assistantship if user is non-existant" do user = FactoryBot.create :user course = FactoryBot.create :course - expect { Assistantship.create! user_id: user.id + 1, course_id: course.id }.to raise_error('Validation failed: User does not exist') + expect { Assistantship.create! user_id: user.id + 1, course_id: course.id }.to raise_error('Validation failed: User must exist, User does not exist') end it "can't create assistantship if user already assistant" do diff --git a/spec/models/stats_spec.rb b/spec/models/stats_spec.rb index 2db5981f0..0b27e5be9 100644 --- a/spec/models/stats_spec.rb +++ b/spec/models/stats_spec.rb @@ -4,17 +4,20 @@ describe Stats, type: :model do it 'should give interesting statistics about the system' do - course1 = FactoryBot.create(:course, name: 'course1') - course2 = FactoryBot.create(:course, name: 'course2') + user1 = FactoryBot.create(:user) + user2 = FactoryBot.create(:user) + FactoryBot.create(:user) + + organization = FactoryBot.create(:organization, creator: user1) + + course1 = FactoryBot.create(:course, name: 'course1', organization: organization) + course2 = FactoryBot.create(:course, name: 'course2', organization: organization) cat1ex1 = FactoryBot.create(:exercise, course: course1, name: 'cat1-ex1') cat1ex2 = FactoryBot.create(:exercise, course: course1, name: 'cat1-ex2') cat2ex1 = FactoryBot.create(:exercise, course: course1, name: 'cat2-ex1') cat3ex1 = FactoryBot.create(:exercise, course: course2, name: 'cat3-ex1') FactoryBot.create(:exercise, course: course1, name: 'cat1-hiddenex', hidden: true) - user1 = FactoryBot.create(:user) - user2 = FactoryBot.create(:user) - FactoryBot.create(:user) create_successful_submission(course: course1, exercise: cat1ex1, user: user1) create_successful_submission(course: course1, exercise: cat1ex1, user: user2) create_successful_submission(course: course1, exercise: cat1ex2, user: user1) @@ -42,10 +45,10 @@ expect(egs['cat2'][:possible_completed_exercise_count]).to eq(1) end - def create_successful_submission(opts) - sub = FactoryBot.create(:submission, opts.merge(all_tests_passed: true)) + def create_successful_submission(**kwargs) + sub = FactoryBot.create(:submission, all_tests_passed: true, **kwargs) FactoryBot.create(:test_case_run, submission: sub, successful: true) - expect(sub.status(opts[:user])).to eq(:ok) + expect(sub.status(kwargs[:user])).to eq(:ok) sub end end diff --git a/spec/models/submission_spec.rb b/spec/models/submission_spec.rb index 032b35e42..b0fc15faa 100644 --- a/spec/models/submission_spec.rb +++ b/spec/models/submission_spec.rb @@ -21,7 +21,7 @@ submission = Submission.new(@params) expect(submission).not_to be_valid - expect(submission.errors[:user].size).to eq(1) + expect(submission.errors[:user].size).to eq(2) end it 'should require an exercise name' do @@ -45,7 +45,7 @@ submission = Submission.new(@params) expect(submission).not_to be_valid - expect(submission.errors[:course].size).to eq(1) + expect(submission.errors[:course].size).to eq(2) end end diff --git a/spec/models/unlock_spec.rb b/spec/models/unlock_spec.rb index a8ff226fd..b9fdee4e6 100644 --- a/spec/models/unlock_spec.rb +++ b/spec/models/unlock_spec.rb @@ -17,6 +17,8 @@ @available_point = FactoryBot.create(:available_point, exercise_id: @ex1.id) @available_point2 = FactoryBot.create(:available_point, exercise_id: @ex2.id) + @submission = FactoryBot.create(:submission, course: @course, user: @user, exercise: @ex1) + @course.reload end @@ -28,7 +30,7 @@ expect(unlocks.first.valid_after).to eq(Date.parse('2011-11-11').in_time_zone) expect(unlocks.first.exercise_name).to eq('ex1') - AwardedPoint.create!(user_id: @user.id, course_id: @course.id, name: @available_point.name) + AwardedPoint.create!(user_id: @user.id, course_id: @course.id, name: @available_point.name, submission_id: @submission.id) Unlock.refresh_unlocks(@course, @user) unlocks = Unlock.order('exercise_name ASC').to_a diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index e0b2a5247..5f1537b3e 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -253,7 +253,7 @@ @course1 = FactoryBot.create :course, organization: @organization1 @course2 = FactoryBot.create :course, organization: @organization2 @course3 = FactoryBot.create :course, organization: @organization1 - @ex1 = FactoryBot.create :exercise, course: @course + @ex1 = FactoryBot.create :exercise, course: @course1 @ex2 = FactoryBot.create :exercise, course: @course2 @ex3 = FactoryBot.create :exercise, course: @course3 @sub1 = FactoryBot.create :submission, user: @user1, diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 9d8e3ea49..fcaa33273 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -9,6 +9,7 @@ require 'fileutils' require 'capybara/poltergeist' require 'simplecov' +require 'tailoring' # require 'rspec_remote_formatter' SimpleCov.start 'rails' do add_filter '/bin/' diff --git a/spec/support/remote_sandbox_for_testing.rb b/spec/support/remote_sandbox_for_testing.rb index 4a7b2e1e3..3d83d8c09 100644 --- a/spec/support/remote_sandbox_for_testing.rb +++ b/spec/support/remote_sandbox_for_testing.rb @@ -2,6 +2,7 @@ require 'fileutils' require 'system_commands' +require 'sandbox_results_saver' class RemoteSandboxForTesting @server_pids = nil diff --git a/spec/usermanual/usermanual_spec.rb b/spec/usermanual/usermanual_spec.rb index 989ee995a..e632be53b 100644 --- a/spec/usermanual/usermanual_spec.rb +++ b/spec/usermanual/usermanual_spec.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require 'spec_helper' +require 'doc_gen' describe 'User manual', type: :request, usermanual: true, integration: true do def make_page(name) @@ -9,14 +10,17 @@ def make_page(name) end it 'has a page for custom course creation manual' do + pending make_page 'customcourse' end it 'has a page for admins' do + pending make_page 'admins' end it 'has a page for teachers' do + pending make_page 'teachers' end end