diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..00651ac06 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,103 @@ +name: Continuous Integration +on: + push: + branches: 'main' + pull_request: + branches: 'main' + +jobs: + linters: + name: Linters + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup Ruby + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + + - name: Setup Node + uses: actions/setup-node@v2 + with: + node-version: '14' + - name: Find yarn cache location + id: yarn-cache + run: echo "::set-output name=dir::$(yarn cache dir)" + - name: JS package cache + uses: actions/cache@v2 + with: + path: ${{ steps.yarn-cache.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + - name: Install packages + run: | + yarn install --pure-lockfile + + - name: Run linters + run: | + bundle exec rake lint + + tests: + name: Tests + runs-on: ubuntu-latest + services: + postgres: + image: postgres:12 + env: + POSTGRES_USER: tps_test + POSTGRES_DB: tps_test + POSTGRES_PASSWORD: tps_test + ports: ["5432:5432"] + + strategy: + matrix: + pattern: + - spec/controllers/*_spec.rb + - spec/controllers/[a-l]**/*_spec.rb + - spec/controllers/[m-z]**/*_spec.rb + - spec/features + - spec/helpers spec/lib spec/middlewares + - spec/mailers spec/jobs spec/policies + - spec/models + - spec/serializers spec/services + - spec/views + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup Ruby + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + + - name: Setup Node + uses: actions/setup-node@v2 + with: + node-version: '14' + - name: Find yarn cache location + id: yarn-cache + run: echo "::set-output name=dir::$(yarn cache dir)" + - name: JS package cache + uses: actions/cache@v2 + with: + path: ${{ steps.yarn-cache.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + - name: Install packages + run: | + yarn install --pure-lockfile + + - name: Setup test database + env: + RAILS_ENV: test + DATABASE_URL: "postgres://tps_test@localhost:5432/tps_test" + run: | + bundle exec rake db:create db:schema:load db:migrate + + - name: Run tests + run: bundle exec rspec ${{ matrix.pattern }} diff --git a/.rubocop.yml b/.rubocop.yml index ccf103e5a..4cc76166b 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -12,6 +12,7 @@ AllCops: - "db/migrate/20190730153555_recreate_structure.rb" - "bin/*" - "node_modules/**/*" + - "vendor/**/*" DS/Unscoped: Enabled: true @@ -19,7 +20,7 @@ DS/Unscoped: DS/ApplicationName: Enabled: true Exclude: - - './config/application_name.rb' + - './config/initializers/01_application_name.rb' - './lib/cops/application_name.rb' - './lib/linters/application_name_linter.rb' - "./spec/**/*" diff --git a/Gemfile b/Gemfile index ed20a87bb..b7708896a 100644 --- a/Gemfile +++ b/Gemfile @@ -21,10 +21,9 @@ gem 'delayed_job_web' gem 'devise' # Gestion des comptes utilisateurs gem 'devise-async' gem 'devise-i18n' -gem 'devise-two-factor', github: 'bryanfagan/devise-two-factor' +gem 'devise-two-factor', github: 'jason-hobbs/devise-two-factor', branch: 'master' # Rails 6.1 compatibility: https://github.com/tinfoil/devise-two-factor/issues/183 gem 'discard' gem 'dotenv-rails', require: 'dotenv/rails-now' # dotenv should always be loaded before rails -gem 'ffi-geos', require: false gem 'flipper' gem 'flipper-active_record' gem 'flipper-ui' @@ -46,6 +45,7 @@ gem 'image_processing' gem 'json_schemer' gem 'jwt' gem 'kaminari', '1.2.1' # Pagination +gem 'listen' # Required by ActiveSupport::EventedFileUpdateChecker gem 'lograge' gem 'logstash-event' gem 'mailjet' @@ -74,7 +74,6 @@ gem 'sib-api-v3-sdk' gem 'skylight' gem 'smart_listing' gem 'spreadsheet_architect' -gem 'sprockets', '< 4' gem 'typhoeus' gem 'warden' gem 'webpacker' @@ -88,9 +87,6 @@ group :test do gem 'capybara-selenium' gem 'database_cleaner' gem 'factory_bot' - gem 'guard' - gem 'guard-livereload', require: false - gem 'guard-rspec', require: false gem 'launchy' gem 'rails-controller-testing' gem 'shoulda-matchers', require: false @@ -112,7 +108,6 @@ group :development do gem 'rubocop-rspec-focused', require: false gem 'scss_lint', require: false gem 'web-console' - gem 'xray-rails' end group :development, :test do @@ -122,7 +117,6 @@ group :development, :test do gem 'pry-byebug' # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'rspec_junit_formatter', require: false gem 'rspec-rails' - gem 'ruby-debug-ide', require: false gem 'simple_xlsx_reader' gem 'spring' # Spring speeds up development by keeping your application running in the background gem 'spring-commands-rspec' diff --git a/Gemfile.lock b/Gemfile.lock index b559be011..081650c09 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,13 +1,14 @@ GIT - remote: https://github.com/bryanfagan/devise-two-factor.git - revision: 60038a699b1847266f6ce0a3457fdc2cd24715be + remote: https://github.com/jason-hobbs/devise-two-factor.git + revision: e153f16ab86de01df034672dfffa321acd891c45 + branch: master specs: - devise-two-factor (3.1.1) - activesupport (< 6.1) + devise-two-factor (3.1.0) + activesupport (< 7.0) attr_encrypted (>= 1.3, < 4, != 2) - devise (~> 4.0) - railties (< 6.1) - rotp (~> 4.0) + devise + railties (< 7.0) + rotp (~> 6) GIT remote: https://github.com/mina-deploy/mina.git @@ -232,9 +233,6 @@ GEM dumb_delegator (0.8.1) ecma-re-validator (0.3.0) regexp_parser (~> 2.0) - em-websocket (0.5.2) - eventmachine (>= 0.12.9) - http_parser.rb (~> 0.6.0) encryptor (3.0.0) equalizer (0.0.11) erubi (1.10.0) @@ -243,7 +241,6 @@ GEM tzinfo ethon (0.12.0) ffi (>= 1.3.0) - eventmachine (1.2.7) excon (0.79.0) execjs (2.7.0) factory_bot (6.1.0) @@ -254,8 +251,6 @@ GEM ruby2_keywords faraday-net_http (1.0.1) ffi (1.14.2) - ffi-geos (2.1.0) - ffi (>= 1.0.0) flipper (0.20.3) flipper-active_record (0.20.3) activerecord (>= 5.0, < 7) @@ -307,25 +302,6 @@ GEM rails (>= 5.1.0) groupdate (5.2.2) activesupport (>= 5) - guard (2.16.2) - formatador (>= 0.2.4) - listen (>= 2.7, < 4.0) - lumberjack (>= 1.0.12, < 2.0) - nenv (~> 0.1) - notiffany (~> 0.0) - pry (>= 0.9.12) - shellany (~> 0.0) - thor (>= 0.18.1) - guard-compat (1.2.1) - guard-livereload (2.5.2) - em-websocket (~> 0.5) - guard (~> 2.8) - guard-compat (~> 1.0) - multi_json (~> 1.8) - guard-rspec (4.7.3) - guard (~> 2.1) - guard-compat (~> 1.1) - rspec (>= 2.99.0, < 4.0) haml (5.2.1) temple (>= 0.8.0) tilt @@ -357,7 +333,6 @@ GEM http-cookie (1.0.3) domain_name (~> 0.5) http_accept_language (2.1.1) - http_parser.rb (0.6.0) httpclient (2.8.3) i18n (1.8.9) concurrent-ruby (~> 1.0) @@ -425,7 +400,6 @@ GEM loofah (2.9.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) - lumberjack (1.2.8) mail (2.7.1) mini_mime (>= 0.1.1) mailjet (1.6.0) @@ -449,15 +423,11 @@ GEM multipart-post (2.1.1) mustermann (1.1.1) ruby2_keywords (~> 0.0.1) - nenv (0.3.0) netrc (0.11.0) nio4r (2.5.5) nokogiri (1.11.1) mini_portile2 (~> 2.5.0) racc (~> 1.4) - notiffany (0.1.3) - nenv (~> 0.1) - shellany (~> 0.0) open4 (1.3.4) openid_connect (1.2.0) activemodel @@ -595,17 +565,12 @@ GEM builder (>= 3.0) dry-inflector (~> 0.1) rubyzip (>= 1.0) - rotp (4.1.0) - addressable (~> 2.5) + rotp (6.2.0) rouge (3.26.0) rqrcode (1.2.0) chunky_png (~> 1.0) rqrcode_core (~> 0.2) rqrcode_core (0.2.0) - rspec (3.10.0) - rspec-core (~> 3.10.0) - rspec-expectations (~> 3.10.0) - rspec-mocks (~> 3.10.0) rspec-core (3.10.1) rspec-support (~> 3.10.0) rspec-expectations (3.10.1) @@ -654,8 +619,6 @@ GEM rubocop-rails (~> 2.0) rubocop-rspec-focused (1.0.0) rubocop (>= 0.51) - ruby-debug-ide (0.7.2) - rake (>= 0.8.1) ruby-graphviz (1.2.5) rexml ruby-progressbar (1.11.0) @@ -700,7 +663,6 @@ GEM concurrent-ruby faraday sexp_processor (4.15.2) - shellany (0.0.1) shoulda-matchers (4.5.1) activesupport (>= 4.2.0) sib-api-v3-sdk (7.4.0) @@ -730,7 +692,7 @@ GEM spring (2.1.1) spring-commands-rspec (1.0.4) spring (>= 0.9.1) - sprockets (3.7.2) + sprockets (4.0.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) sprockets-rails (3.2.2) @@ -799,8 +761,6 @@ GEM websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) - xray-rails (0.3.2) - rails (>= 3.1.0) zeitwerk (2.4.2) zip_tricks (5.5.0) zipline (1.3.0) @@ -845,7 +805,6 @@ DEPENDENCIES discard dotenv-rails factory_bot - ffi-geos flipper flipper-active_record flipper-ui @@ -859,9 +818,6 @@ DEPENDENCIES graphql-schema_comparator graphql_playground-rails groupdate - guard - guard-livereload - guard-rspec haml-lint haml-rails hashie @@ -874,6 +830,7 @@ DEPENDENCIES kaminari (= 1.2.1) launchy letter_opener_web + listen lograge logstash-event mailjet @@ -902,7 +859,6 @@ DEPENDENCIES rubocop rubocop-rails_config rubocop-rspec-focused - ruby-debug-ide ruby-saml-idp sanitize-url sassc-rails @@ -918,7 +874,6 @@ DEPENDENCIES spreadsheet_architect spring spring-commands-rspec - sprockets (< 4) timecop typhoeus vcr @@ -927,7 +882,6 @@ DEPENDENCIES webdrivers (~> 4.0) webmock webpacker - xray-rails zipline zxcvbn-ruby diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js new file mode 100644 index 000000000..8890f53b3 --- /dev/null +++ b/app/assets/config/manifest.js @@ -0,0 +1,5 @@ +//= link application.css +//= link_tree ../images +//= link_tree ../fonts +//= link administrate/application.css +//= link administrate/application.js diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index eaf0c0b98..1fc589860 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -5,4 +5,3 @@ // = require ./fonts // = require leaflet // = require_tree . -// = stub ./print.scss diff --git a/app/assets/stylesheets/print.scss b/app/assets/stylesheets/print.scss index cbb30fc56..4c0e9749c 100644 --- a/app/assets/stylesheets/print.scss +++ b/app/assets/stylesheets/print.scss @@ -1,63 +1,65 @@ @import "colors"; @import "fonts"; -.new-header, -.sub-header, -footer { - display: none; -} - -.print-header { - display: block; - margin-top: 30px; - font-size: 30px; - line-height: 50px; - font-weight: bold; -} - -body { - font-family: "Muli"; -} - -.subtitle { - margin-top: -20px; - color: $dark-grey; -} - -th, -td { - vertical-align: top; -} - -th { - text-align: left; - - &.header-section { - padding-top: 1.2em; - font-size: 1.2em; +@media print { + .new-header, + .sub-header, + footer { + display: none; } -} -.messagerie { - .messages-list { - list-style: none; - padding-left: 0; - max-height: none; + .print-header { + display: block; + margin-top: 30px; + font-size: 30px; + line-height: 50px; + font-weight: bold; + } - h2 { - font-size: 110%; - } + body { + font-family: "Muli"; + } - .person-icon { - display: none; + .subtitle { + margin-top: -20px; + color: $dark-grey; + } + + th, + td { + vertical-align: top; + } + + th { + text-align: left; + + &.header-section { + padding-top: 1.2em; + font-size: 1.2em; } } -} -.message { - margin-bottom: 40px; -} + .messagerie { + .messages-list { + list-style: none; + padding-left: 0; + max-height: none; -.updated-at { - display: none; + h2 { + font-size: 110%; + } + + .person-icon { + display: none; + } + } + } + + .message { + margin-bottom: 40px; + } + + .updated-at { + display: none; + } } diff --git a/app/models/dynamic_smtp_settings_interceptor.rb b/app/models/dynamic_smtp_settings_interceptor.rb index 885c4b8e9..91d6398f8 100644 --- a/app/models/dynamic_smtp_settings_interceptor.rb +++ b/app/models/dynamic_smtp_settings_interceptor.rb @@ -1,3 +1,9 @@ +# Note: this class is instanciated when being added as an interceptor +# during the app initialization. +# +# If you edit this file in development env, you will need to restart +# the app to see the changes. + class DynamicSmtpSettingsInterceptor def self.delivering_email(message) if ENV['SENDINBLUE_BALANCING'] == 'enabled' diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index d2ed48a5c..28285f2ea 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -20,7 +20,6 @@ = preload_link_tag(asset_url("Muli-Bold.woff2")) = stylesheet_link_tag 'application', media: 'all' - = stylesheet_link_tag 'print', media: 'print' = Gon::Base.render_data(camel_case: true, init: true, nonce: request.content_security_policy_nonce) diff --git a/app/views/manager/users/emails.html.erb b/app/views/manager/users/emails.html.erb index 13575b96a..6af6416d3 100644 --- a/app/views/manager/users/emails.html.erb +++ b/app/views/manager/users/emails.html.erb @@ -47,7 +47,7 @@ <%= email.subject %>