Merge pull request #5939 from betagouv/main

2021-02-25-01
This commit is contained in:
Paul Chavard 2021-02-25 17:06:06 +01:00 committed by GitHub
commit 4171b28eca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 213 additions and 193 deletions

103
.github/workflows/ci.yml vendored Normal file
View file

@ -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 }}

View file

@ -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/**/*"

10
Gemfile
View file

@ -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'

View file

@ -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

View file

@ -0,0 +1,5 @@
//= link application.css
//= link_tree ../images
//= link_tree ../fonts
//= link administrate/application.css
//= link administrate/application.js

View file

@ -5,4 +5,3 @@
// = require ./fonts
// = require leaflet
// = require_tree .
// = stub ./print.scss

View file

@ -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;
}
}

View file

@ -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'

View file

@ -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)

View file

@ -47,7 +47,7 @@
<%= email.subject %>
</td>
<td class="cell-data cell-data--string" style="text-align: center;">
<%= l(email.date, format: '%d/%m/%y à %H:%M') %>
<%= l(email.date.is_a?(String) ? Time.zone.parse(email.date) : email.date, format: '%d/%m/%y à %H:%M') %>
</td>
<td class="cell-data cell-data--string" style="text-align: center;">
<ul>

View file

@ -7,7 +7,6 @@ require 'rails/all'
Bundler.require(*Rails.groups)
Dotenv::Railtie.load
require_relative 'application_name'
module TPS
class Application < Rails::Application

View file

@ -1,3 +1,6 @@
# This file is named '01-application-name.rb' to load it before the other
# initializers, and thus make the APPLICATION_ constants available in
# the other initializers.
APPLICATION_NAME = ENV.fetch("APPLICATION_NAME", "demarches-simplifiees.fr")
APPLICATION_SHORTNAME = ENV.fetch("APPLICATION_SHORTNAME", "d-s.fr")
APPLICATION_BASE_URL = ENV.fetch("APPLICATION_BASE_URL", "https://www.demarches-simplifiees.fr")

View file

@ -11,20 +11,24 @@
# - but let's keep these for a while to make external integrators's life easier.
# To keep some margin, let's say this file can be safely deleted in May 2021.)
require 'excon'
Rails.application.reloader.to_prepare do
if !defined?(ApiEntreprise)
require 'excon'
module ApiEntreprise
Job = APIEntreprise::Job
AssociationJob = APIEntreprise::AssociationJob
AttestationFiscaleJob = APIEntreprise::AttestationFiscaleJob
AttestationSocialeJob = APIEntreprise::AttestationSocialeJob
BilansBdfJob = APIEntreprise::BilansBdfJob
EffectifsAnnuelsJob = APIEntreprise::EffectifsAnnuelsJob
EffectifsJob = APIEntreprise::EffectifsJob
EntrepriseJob = APIEntreprise::EntrepriseJob
ExercicesJob = APIEntreprise::ExercicesJob
end
module ApiEntreprise
Job = APIEntreprise::Job
AssociationJob = APIEntreprise::AssociationJob
AttestationFiscaleJob = APIEntreprise::AttestationFiscaleJob
AttestationSocialeJob = APIEntreprise::AttestationSocialeJob
BilansBdfJob = APIEntreprise::BilansBdfJob
EffectifsAnnuelsJob = APIEntreprise::EffectifsAnnuelsJob
EffectifsJob = APIEntreprise::EffectifsJob
EntrepriseJob = APIEntreprise::EntrepriseJob
ExercicesJob = APIEntreprise::ExercicesJob
end
module Cron
FixMissingAntivirusAnalysis = FixMissingAntivirusAnalysisJob
module Cron
FixMissingAntivirusAnalysis = FixMissingAntivirusAnalysisJob
end
end
end

View file

@ -10,5 +10,6 @@ Rails.application.config.assets.paths << Rails.root.join('node_modules', '@reach
Rails.application.config.assets.paths << Rails.root.join('node_modules', '@mapbox', 'mapbox-gl-draw', 'dist')
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
Rails.application.config.assets.precompile += ['print.css']
# application.js, application.css, and all non-JS/CSS in the app/assets
# folder are already added.
# Rails.application.config.assets.precompile += %w( admin.js admin.css )

View file

@ -1 +1,3 @@
ActionMailer::Base.register_interceptor "DynamicSmtpSettingsInterceptor"
ActiveSupport.on_load(:action_mailer) do
ActionMailer::Base.register_interceptor "DynamicSmtpSettingsInterceptor"
end

View file

@ -3,5 +3,5 @@ Sentry.init do |config|
config.send_default_pii = false
config.enabled_environments = ['production']
config.breadcrumbs_logger = [:active_support_logger]
config.traces_sample_rate = 0.001
config.traces_sample_rate = ENV['SENTRY_ENABLED'] == 'enabled' ? 0.001 : nil
end

View file

@ -1,5 +1,5 @@
task :lint do
sh "bundle exec rubocop"
sh "bundle exec rubocop --parallel"
sh "bundle exec haml-lint app/views/"
sh "bundle exec scss-lint app/assets/stylesheets/"
sh "bundle exec brakeman --no-pager"

View file

@ -772,7 +772,7 @@ describe Instructeurs::DossiersController, type: :controller do
end
it 'does not delete the dossier' do
expect { dossier.reload }.not_to raise_error ActiveRecord::RecordNotFound
expect { dossier.reload }.not_to raise_error # A deleted dossier would raise an ActiveRecord::RecordNotFound
end
it 'does not add a record into deleted_dossiers table' do

View file

@ -77,51 +77,6 @@ FactoryBot.define do
end
end
trait :invalid_multi_polygon do
geometry do
{
"type": "MultiPolygon",
"coordinates": [
[
[
[5.894422531127931, 48.22810341752755],
[5.893049240112306, 48.22427237832278],
[5.892534255981446, 48.22593062452037],
[5.892791748046875, 48.2260449843468],
[5.894422531127931, 48.229933066408215],
[5.894422531127931, 48.22810341752755]
]
],
[
[
[5.8950233459472665, 48.229933066408215],
[5.893478393554688, 48.228961073585126],
[5.892791748046875, 48.228903896961775],
[5.892705917358398, 48.230390468407535],
[5.8950233459472665, 48.229933066408215]
]
],
[
[
[5.893220901489259, 48.229246955743626],
[5.893392562866212, 48.22884672027457],
[5.892705917358398, 48.22878954352343],
[5.892019271850587, 48.22856083588024],
[5.892019271850587, 48.2277031731152],
[5.890989303588868, 48.22787470681807],
[5.889959335327149, 48.22787470681807],
[5.890560150146485, 48.22838930447709],
[5.890645980834962, 48.22878954352343],
[5.890989303588868, 48.229018250144584],
[5.892362594604493, 48.22930413198368],
[5.893220901489259, 48.229246955743626]
]
]
]
}
end
end
trait :line_string do
geometry do
{

View file

@ -45,12 +45,6 @@ RSpec.describe GeoArea, type: :model do
it { expect(geo_area.geometry).to eq(polygon) }
context 'invalid' do
let(:geo_area) { build(:geo_area, :invalid_multi_polygon) }
it { expect(geo_area.rgeo_geometry).to be_nil }
end
context 'polygon_with_extra_coordinate' do
let(:geo_area) { build(:geo_area, :polygon_with_extra_coordinate) }

View file

@ -17,7 +17,6 @@
#
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
require 'rspec'
require 'capybara/rspec'
require 'capybara-screenshot/rspec'
require 'capybara/email/rspec'