From f605cd35acd2c0b408f329d787b358c04cf060ee Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 15 Jan 2018 21:43:56 +0100 Subject: [PATCH 01/24] Enable the Layout/SpaceAfterColon cop --- .rubocop.yml | 2 +- ..._10_30_copy_commentaire_piece_justificative_to_file.rake | 2 +- spec/controllers/api/v1/procedures_controller_spec.rb | 6 +++--- .../controllers/users/dossiers/add_siret_controller_spec.rb | 2 +- .../users/dossiers/commentaires_controller_spec.rb | 2 +- spec/support/shared_exemples_for_dossier.rb | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index d35f0a87c..5e7830875 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -155,7 +155,7 @@ Layout/RescueEnsureAlignment: Enabled: true Layout/SpaceAfterColon: - Enabled: false + Enabled: true Layout/SpaceAfterComma: Enabled: false diff --git a/lib/tasks/2017_10_30_copy_commentaire_piece_justificative_to_file.rake b/lib/tasks/2017_10_30_copy_commentaire_piece_justificative_to_file.rake index 2ad820f4a..8e3422582 100644 --- a/lib/tasks/2017_10_30_copy_commentaire_piece_justificative_to_file.rake +++ b/lib/tasks/2017_10_30_copy_commentaire_piece_justificative_to_file.rake @@ -1,6 +1,6 @@ namespace :'2017_10_30_copy_commentaire_piece_justificative_to_file' do task set: :environment do - commentaires_to_process = Commentaire.where(file:nil).where.not(piece_justificative_id: nil).reorder(id: :desc) + commentaires_to_process = Commentaire.where(file: nil).where.not(piece_justificative_id: nil).reorder(id: :desc) puts "#{commentaires_to_process.count} commentaires to process..." diff --git a/spec/controllers/api/v1/procedures_controller_spec.rb b/spec/controllers/api/v1/procedures_controller_spec.rb index 1eaa71374..00c526a4f 100644 --- a/spec/controllers/api/v1/procedures_controller_spec.rb +++ b/spec/controllers/api/v1/procedures_controller_spec.rb @@ -11,12 +11,12 @@ describe API::V1::ProceduresController, type: :controller do end context 'when procedure does not belong to administrateur' do let(:procedure) { create(:procedure, administrateur: create(:administrateur)) } - subject { get :show, params:{id: procedure, token: admin.api_token }} + subject { get :show, params: {id: procedure, token: admin.api_token }} it { expect(subject.status).to eq(404) } end context 'when procedure exist' do let(:procedure) { create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ, administrateur: admin) } - subject { get :show, params:{id: procedure, token: admin.api_token }} + subject { get :show, params: {id: procedure, token: admin.api_token }} it 'return REST code 200', :show_in_doc do expect(subject.status).to eq(200) @@ -25,7 +25,7 @@ describe API::V1::ProceduresController, type: :controller do describe 'body' do let(:module_api_carto) { create(:module_api_carto, use_api_carto: true, quartiers_prioritaires: true, cadastre: true) } let(:procedure) { create(:procedure, :with_type_de_champ, :with_two_type_de_piece_justificative, module_api_carto: module_api_carto, administrateur: admin) } - let(:response) { get :show, params:{id: procedure.id, token: admin.api_token }} + let(:response) { get :show, params: {id: procedure.id, token: admin.api_token }} subject { JSON.parse(response.body, symbolize_names: true)[:procedure] } it { expect(subject[:id]).to eq(procedure.id) } diff --git a/spec/controllers/users/dossiers/add_siret_controller_spec.rb b/spec/controllers/users/dossiers/add_siret_controller_spec.rb index 2481fd480..091f07aab 100644 --- a/spec/controllers/users/dossiers/add_siret_controller_spec.rb +++ b/spec/controllers/users/dossiers/add_siret_controller_spec.rb @@ -8,7 +8,7 @@ describe Users::Dossiers::AddSiretController, type: :controller do sign_in dossier.user end - subject { get :show, params:{dossier_id: dossier.id }} + subject { get :show, params: {dossier_id: dossier.id }} context 'when dossier is not attached at a procedure with individual siret attribut' do it { is_expected.to redirect_to users_dossiers_path } diff --git a/spec/controllers/users/dossiers/commentaires_controller_spec.rb b/spec/controllers/users/dossiers/commentaires_controller_spec.rb index 18908f468..2871486d9 100644 --- a/spec/controllers/users/dossiers/commentaires_controller_spec.rb +++ b/spec/controllers/users/dossiers/commentaires_controller_spec.rb @@ -6,7 +6,7 @@ describe Users::Dossiers::CommentairesController, type: :controller do describe '#POST create' do subject { - post :create, params:{dossier_id: dossier.id, texte_commentaire: texte_commentaire} + post :create, params: {dossier_id: dossier.id, texte_commentaire: texte_commentaire} dossier.reload } diff --git a/spec/support/shared_exemples_for_dossier.rb b/spec/support/shared_exemples_for_dossier.rb index 7a39ffa22..308aa2b83 100644 --- a/spec/support/shared_exemples_for_dossier.rb +++ b/spec/support/shared_exemples_for_dossier.rb @@ -4,7 +4,7 @@ RSpec.shared_examples 'not owner of dossier' do |controller, redirect| let(:dossier_2) { create(:dossier) } before do - get controller, params:{dossier_id: dossier_2.id} + get controller, params: {dossier_id: dossier_2.id} end it 'redirect to home page' do From c28626bb18bd4d154e36b83713719e1235f89ad3 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 15 Jan 2018 21:45:23 +0100 Subject: [PATCH 02/24] Enable the Layout/SpaceAfterMethodName cop --- .rubocop.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index 5e7830875..782a46cc3 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -161,7 +161,7 @@ Layout/SpaceAfterComma: Enabled: false Layout/SpaceAfterMethodName: - Enabled: false + Enabled: true Layout/SpaceAfterNot: Enabled: false From 359a9a863be00d03bb7842b1c13a55fb3ddf769a Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 15 Jan 2018 21:45:50 +0100 Subject: [PATCH 03/24] Enable the Layout/SpaceAfterNot cop --- .rubocop.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index 782a46cc3..b8d3c2012 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -164,7 +164,7 @@ Layout/SpaceAfterMethodName: Enabled: true Layout/SpaceAfterNot: - Enabled: false + Enabled: true Layout/SpaceAfterSemicolon: Enabled: false From 0572d66efd347f9b2487cce0379211b5bc71fb36 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 15 Jan 2018 21:46:27 +0100 Subject: [PATCH 04/24] Enable the Layout/SpaceAfterSemicolon cop --- .rubocop.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index b8d3c2012..867ba7b32 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -167,7 +167,7 @@ Layout/SpaceAfterNot: Enabled: true Layout/SpaceAfterSemicolon: - Enabled: false + Enabled: true Layout/SpaceAroundBlockParameters: Enabled: false From b9aa71ed3bfeb7353735d292b4fc4650f6b8f900 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 15 Jan 2018 21:46:49 +0100 Subject: [PATCH 05/24] Enable the Layout/SpaceAroundBlockParameters cop --- .rubocop.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index 867ba7b32..a18bd278f 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -170,7 +170,7 @@ Layout/SpaceAfterSemicolon: Enabled: true Layout/SpaceAroundBlockParameters: - Enabled: false + Enabled: true Layout/SpaceAroundEqualsInParameterDefault: Enabled: false From 245c04d2bb6d9a011e188f5113d8045ded5011cb Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 15 Jan 2018 21:47:01 +0100 Subject: [PATCH 06/24] Enable the Layout/SpaceAroundEqualsInParameterDefault cop --- .rubocop.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index a18bd278f..f77c3ad65 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -173,7 +173,7 @@ Layout/SpaceAroundBlockParameters: Enabled: true Layout/SpaceAroundEqualsInParameterDefault: - Enabled: false + Enabled: true Layout/SpaceAroundKeyword: Enabled: false From 278a662350bfe9435bceef2810d1b8bd7469d68c Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 15 Jan 2018 21:47:55 +0100 Subject: [PATCH 07/24] Enable the Layout/SpaceAroundEqualsInParameterDefault cop --- app/controllers/users_controller.rb | 2 +- app/decorators/dossier_decorator.rb | 2 +- app/services/notification_service.rb | 4 ++-- app/services/types_de_champ_service.rb | 2 +- .../20161007095443_reset_all_preference_list_dossier.rb | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 15c7ba21f..a3545612e 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -5,7 +5,7 @@ class UsersController < ApplicationController redirect_to root_path end - def current_user_dossier dossier_id=nil + def current_user_dossier dossier_id = nil dossier_id ||= params[:dossier_id] || params[:id] dossier = Dossier.find(dossier_id) diff --git a/app/decorators/dossier_decorator.rb b/app/decorators/dossier_decorator.rb index e4f7b3cb5..c8d71c0b9 100644 --- a/app/decorators/dossier_decorator.rb +++ b/app/decorators/dossier_decorator.rb @@ -24,7 +24,7 @@ class DossierDecorator < Draper::Decorator end end - def self.case_state_fr state=self.state + def self.case_state_fr state = self.state h.t("activerecord.attributes.dossier.state.#{state}") end end diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb index aacbc527c..8d84d172f 100644 --- a/app/services/notification_service.rb +++ b/app/services/notification_service.rb @@ -1,5 +1,5 @@ class NotificationService - def initialize type_notif, dossier_id, attribut_change='' + def initialize type_notif, dossier_id, attribut_change = '' @type_notif = type_notif @dossier_id = dossier_id @@ -22,7 +22,7 @@ class NotificationService end end - def text_for_notif attribut='' + def text_for_notif attribut = '' case @type_notif when 'commentaire' "#{notification.liste.size + 1} nouveau(x) commentaire(s) déposé(s)." diff --git a/app/services/types_de_champ_service.rb b/app/services/types_de_champ_service.rb index a2e523007..efb546009 100644 --- a/app/services/types_de_champ_service.rb +++ b/app/services/types_de_champ_service.rb @@ -1,5 +1,5 @@ class TypesDeChampService - def self.create_update_procedure_params(params, private=false) + def self.create_update_procedure_params(params, private = false) attributes = (private ? 'types_de_champ_private_attributes' : 'types_de_champ_attributes') params_with_ordered_champs = order_champs(params, attributes) diff --git a/db/migrate/20161007095443_reset_all_preference_list_dossier.rb b/db/migrate/20161007095443_reset_all_preference_list_dossier.rb index 9aab6967c..672f3e7a0 100644 --- a/db/migrate/20161007095443_reset_all_preference_list_dossier.rb +++ b/db/migrate/20161007095443_reset_all_preference_list_dossier.rb @@ -95,7 +95,7 @@ class ResetAllPreferenceListDossier < ActiveRecord::Migration has_many :assign_to, dependent: :destroy has_many :procedures, through: :assign_to - def build_default_preferences_list_dossier procedure_id=nil + def build_default_preferences_list_dossier procedure_id = nil PreferenceListDossier.available_columns_for(procedure_id).each do |table| table.second.each do |column| if valid_couple_table_attr? table.first, column.first From 2814fcf27e762a4103842f7d27ab4d20dcc5552c Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 15 Jan 2018 21:48:16 +0100 Subject: [PATCH 08/24] Enable the Layout/SpaceAroundKeyword cop --- .rubocop.yml | 2 +- app/controllers/new_gestionnaire/procedures_controller.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index f77c3ad65..b70ee4556 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -176,7 +176,7 @@ Layout/SpaceAroundEqualsInParameterDefault: Enabled: true Layout/SpaceAroundKeyword: - Enabled: false + Enabled: true Layout/SpaceAroundOperators: Enabled: true diff --git a/app/controllers/new_gestionnaire/procedures_controller.rb b/app/controllers/new_gestionnaire/procedures_controller.rb index dd60ffbae..f4ceed371 100644 --- a/app/controllers/new_gestionnaire/procedures_controller.rb +++ b/app/controllers/new_gestionnaire/procedures_controller.rb @@ -271,7 +271,7 @@ module NewGestionnaire end when 'self' order = "dossiers.#{column} #{order}" - when'france_connect_information' + when 'france_connect_information' includes = { user: :france_connect_information } order = "france_connect_informations.#{column} #{order}" when 'type_de_champ', 'type_de_champ_private' @@ -315,7 +315,7 @@ module NewGestionnaire end end.each do |group_key, fields| case group_key - when'france_connect_information' + when 'france_connect_information' @dossiers = @dossiers.includes({ user: :france_connect_information }) when 'type_de_champ_group' if fields.any? { |field| field['table'] == 'type_de_champ' } From 3e93bd3615309c34eaa10702eee4ba7644bb23aa Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 15 Jan 2018 21:49:52 +0100 Subject: [PATCH 09/24] Enable the Layout/SpaceBeforeComma cop --- .rubocop.yml | 2 +- app/models/dossier.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index b70ee4556..e3bbb5f81 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -185,7 +185,7 @@ Layout/SpaceBeforeBlockBraces: Enabled: false Layout/SpaceBeforeComma: - Enabled: false + Enabled: true Layout/SpaceBeforeComment: Enabled: false diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 7503197f8..1b4d336be 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -57,7 +57,7 @@ class Dossier < ActiveRecord::Base scope :en_cours, -> { not_archived.state_en_construction_ou_instruction } scope :without_followers, -> { left_outer_joins(:follows).where(follows: { id: nil }) } scope :with_unread_notifications, -> { where(notifications: { already_read: false }) } - scope :followed_by , -> (gestionnaire) { joins(:follows).where(follows: { gestionnaire: gestionnaire }) } + scope :followed_by, -> (gestionnaire) { joins(:follows).where(follows: { gestionnaire: gestionnaire }) } accepts_nested_attributes_for :individual From 836edf616d6db2007f45517e0cb1af374cdd17d5 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 15 Jan 2018 21:50:46 +0100 Subject: [PATCH 10/24] Enable the Layout/SpaceBeforeComment cop --- .rubocop.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index e3bbb5f81..6adfbace5 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -188,7 +188,7 @@ Layout/SpaceBeforeComma: Enabled: true Layout/SpaceBeforeComment: - Enabled: false + Enabled: true Layout/SpaceBeforeFirstArg: Enabled: false From 4bfa9b18c5e45595bc32ea6c25f7f4735dbb7c24 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 15 Jan 2018 21:51:42 +0100 Subject: [PATCH 11/24] Enable the Layout/SpaceBeforeFirstArg cop --- .rubocop.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index 6adfbace5..363326a86 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -191,7 +191,7 @@ Layout/SpaceBeforeComment: Enabled: true Layout/SpaceBeforeFirstArg: - Enabled: false + Enabled: true Layout/SpaceBeforeSemicolon: Enabled: false From 05b1fd96fd146393a261b12fd8ce2c2edb702981 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 15 Jan 2018 21:52:21 +0100 Subject: [PATCH 12/24] Enable the Layout/SpaceBeforeSemicolon cop --- .rubocop.yml | 2 +- spec/controllers/admin/mail_templates_controller_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 363326a86..20514819e 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -194,7 +194,7 @@ Layout/SpaceBeforeFirstArg: Enabled: true Layout/SpaceBeforeSemicolon: - Enabled: false + Enabled: true Layout/SpaceInLambdaLiteral: Enabled: false diff --git a/spec/controllers/admin/mail_templates_controller_spec.rb b/spec/controllers/admin/mail_templates_controller_spec.rb index 313dd93ad..81a24a6da 100644 --- a/spec/controllers/admin/mail_templates_controller_spec.rb +++ b/spec/controllers/admin/mail_templates_controller_spec.rb @@ -34,7 +34,7 @@ describe Admin::MailTemplatesController, type: :controller do it { expect(response).to redirect_to admin_procedure_mail_templates_path(procedure) } context 'the mail template' do - subject { procedure.reload ; procedure.initiated_mail_template } + subject { procedure.reload; procedure.initiated_mail_template } it { expect(subject.subject).to eq(mail_subject) } it { expect(subject.body).to eq(mail_body) } From 9ea11065036847bd9b9cedb34b10836b30047ece Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 15 Jan 2018 21:53:30 +0100 Subject: [PATCH 13/24] Enable the Layout/SpaceInLambdaLiteral cop --- .rubocop.yml | 3 ++- app/models/avis.rb | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 20514819e..295ce372f 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -197,7 +197,8 @@ Layout/SpaceBeforeSemicolon: Enabled: true Layout/SpaceInLambdaLiteral: - Enabled: false + Enabled: true + EnforcedStyle: require_space Layout/SpaceInsideArrayPercentLiteral: Enabled: false diff --git a/app/models/avis.rb b/app/models/avis.rb index 2f9aac2c9..e6d78c580 100644 --- a/app/models/avis.rb +++ b/app/models/avis.rb @@ -10,7 +10,7 @@ class Avis < ApplicationRecord default_scope { joins(:dossier) } scope :with_answer, -> { where.not(answer: nil) } scope :without_answer, -> { where(answer: nil) } - scope :for_dossier, ->(dossier_id) { where(dossier_id: dossier_id) } + scope :for_dossier, -> (dossier_id) { where(dossier_id: dossier_id) } scope :by_latest, -> { order(updated_at: :desc) } scope :updated_since?, -> (date) { where('avis.updated_at > ?', date) } From ff87d0e65f14e5cc194faafeb539691d1e9e0e88 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 15 Jan 2018 21:54:21 +0100 Subject: [PATCH 14/24] Enable the Layout/SpaceInsideArrayPercentLiteral cop --- .rubocop.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index 295ce372f..cc8ceb7df 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -201,7 +201,7 @@ Layout/SpaceInLambdaLiteral: EnforcedStyle: require_space Layout/SpaceInsideArrayPercentLiteral: - Enabled: false + Enabled: true Layout/SpaceInsideBlockBraces: Enabled: false From 897a30da0cade18b9cb167d4d871cc2c6e94cf5d Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 15 Jan 2018 21:54:40 +0100 Subject: [PATCH 15/24] Enable the Layout/SpaceInsideBlockBraces cop --- .rubocop.yml | 2 +- app/models/dossier.rb | 4 +-- .../api/v1/procedures_controller_spec.rb | 8 +++--- .../application_controller_spec.rb | 2 +- .../gestionnaire_controller_spec.rb | 2 +- .../procedures_controller_spec.rb | 6 ++--- .../new_user/dossiers_controller_spec.rb | 2 +- .../new_user/user_controller_spec.rb | 2 +- .../dossiers/add_siret_controller_spec.rb | 2 +- spec/decorators/champ_decorator_spec.rb | 2 +- spec/features/users/list_dossiers_spec.rb | 2 +- spec/jobs/auto_archive_procedure_job_spec.rb | 26 +++++++++---------- spec/mailers/welcome_mailer_spec.rb | 2 +- spec/models/avis_spec.rb | 2 +- spec/models/champ_shared_example.rb | 2 +- .../concern/mail_template_concern_spec.rb | 2 +- spec/models/dossier_spec.rb | 4 +-- spec/models/gestionnaire_spec.rb | 8 +++--- spec/models/procedure_path_spec.rb | 14 +++++----- .../dossier_table_export_serializer_spec.rb | 2 +- spec/services/accompagnateur_service_spec.rb | 2 +- .../users/description/show.html.haml_spec.rb | 4 +-- .../views/users/siret/index.html.haml_spec.rb | 2 +- 23 files changed, 52 insertions(+), 52 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index cc8ceb7df..2c7ac0272 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -204,7 +204,7 @@ Layout/SpaceInsideArrayPercentLiteral: Enabled: true Layout/SpaceInsideBlockBraces: - Enabled: false + Enabled: true Layout/SpaceInsideBrackets: Enabled: false diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 1b4d336be..25b022407 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -273,9 +273,9 @@ class Dossier < ActiveRecord::Base when 'etablissement' self.etablissement&.send(column) when 'type_de_champ' - self.champs.find {|c| c.type_de_champ_id == column.to_i }.value + self.champs.find { |c| c.type_de_champ_id == column.to_i }.value when 'type_de_champ_private' - self.champs_private.find {|c| c.type_de_champ_id == column.to_i }.value + self.champs_private.find { |c| c.type_de_champ_id == column.to_i }.value end end diff --git a/spec/controllers/api/v1/procedures_controller_spec.rb b/spec/controllers/api/v1/procedures_controller_spec.rb index 00c526a4f..3aeb7c023 100644 --- a/spec/controllers/api/v1/procedures_controller_spec.rb +++ b/spec/controllers/api/v1/procedures_controller_spec.rb @@ -6,17 +6,17 @@ describe API::V1::ProceduresController, type: :controller do describe 'GET show' do context 'when procedure does not exist' do - subject { get :show, params: {id: 999_999_999, token: admin.api_token }} + subject { get :show, params: { id: 999_999_999, token: admin.api_token } } it { expect(subject.status).to eq(404) } end context 'when procedure does not belong to administrateur' do let(:procedure) { create(:procedure, administrateur: create(:administrateur)) } - subject { get :show, params: {id: procedure, token: admin.api_token }} + subject { get :show, params: { id: procedure, token: admin.api_token } } it { expect(subject.status).to eq(404) } end context 'when procedure exist' do let(:procedure) { create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ, administrateur: admin) } - subject { get :show, params: {id: procedure, token: admin.api_token }} + subject { get :show, params: { id: procedure, token: admin.api_token } } it 'return REST code 200', :show_in_doc do expect(subject.status).to eq(200) @@ -25,7 +25,7 @@ describe API::V1::ProceduresController, type: :controller do describe 'body' do let(:module_api_carto) { create(:module_api_carto, use_api_carto: true, quartiers_prioritaires: true, cadastre: true) } let(:procedure) { create(:procedure, :with_type_de_champ, :with_two_type_de_piece_justificative, module_api_carto: module_api_carto, administrateur: admin) } - let(:response) { get :show, params: {id: procedure.id, token: admin.api_token }} + let(:response) { get :show, params: { id: procedure.id, token: admin.api_token } } subject { JSON.parse(response.body, symbolize_names: true)[:procedure] } it { expect(subject[:id]).to eq(procedure.id) } diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb index 9a05618a2..21f6dfd56 100644 --- a/spec/controllers/application_controller_spec.rb +++ b/spec/controllers/application_controller_spec.rb @@ -5,7 +5,7 @@ describe ApplicationController, type: :controller do it 'is present' do before_actions = ApplicationController ._process_action_callbacks - .find_all{|process_action_callbacks| process_action_callbacks.kind == :before} + .find_all{ |process_action_callbacks| process_action_callbacks.kind == :before } .map(&:filter) expect(before_actions).to include(:set_raven_context) diff --git a/spec/controllers/new_gestionnaire/gestionnaire_controller_spec.rb b/spec/controllers/new_gestionnaire/gestionnaire_controller_spec.rb index ed8ac8fba..2159b983d 100644 --- a/spec/controllers/new_gestionnaire/gestionnaire_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/gestionnaire_controller_spec.rb @@ -5,7 +5,7 @@ describe NewGestionnaire::GestionnaireController, type: :controller do it 'is present' do before_actions = NewGestionnaire::GestionnaireController ._process_action_callbacks - .find_all{|process_action_callbacks| process_action_callbacks.kind == :before} + .find_all{ |process_action_callbacks| process_action_callbacks.kind == :before } .map(&:filter) expect(before_actions).to include(:authenticate_gestionnaire!) diff --git a/spec/controllers/new_gestionnaire/procedures_controller_spec.rb b/spec/controllers/new_gestionnaire/procedures_controller_spec.rb index 24317adcf..3f79fd866 100644 --- a/spec/controllers/new_gestionnaire/procedures_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/procedures_controller_spec.rb @@ -5,7 +5,7 @@ describe NewGestionnaire::ProceduresController, type: :controller do it "is present" do before_actions = NewGestionnaire::ProceduresController ._process_action_callbacks - .find_all{|process_action_callbacks| process_action_callbacks.kind == :before} + .find_all{ |process_action_callbacks| process_action_callbacks.kind == :before } .map(&:filter) expect(before_actions).to include(:ensure_ownership!) @@ -46,7 +46,7 @@ describe NewGestionnaire::ProceduresController, type: :controller do it "is present" do before_actions = NewGestionnaire::ProceduresController ._process_action_callbacks - .find_all{|process_action_callbacks| process_action_callbacks.kind == :before} + .find_all{ |process_action_callbacks| process_action_callbacks.kind == :before } .map(&:filter) expect(before_actions).to include(:redirect_to_avis_if_needed) @@ -89,7 +89,7 @@ describe NewGestionnaire::ProceduresController, type: :controller do context "when not logged" do before { subject } - it { expect(response).to redirect_to(new_user_session_path)} + it { expect(response).to redirect_to(new_user_session_path) } end context "when logged in" do diff --git a/spec/controllers/new_user/dossiers_controller_spec.rb b/spec/controllers/new_user/dossiers_controller_spec.rb index b08d7d21d..360a7548f 100644 --- a/spec/controllers/new_user/dossiers_controller_spec.rb +++ b/spec/controllers/new_user/dossiers_controller_spec.rb @@ -7,7 +7,7 @@ describe NewUser::DossiersController, type: :controller do it 'is present' do before_actions = NewUser::DossiersController ._process_action_callbacks - .find_all{|process_action_callbacks| process_action_callbacks.kind == :before} + .find_all{ |process_action_callbacks| process_action_callbacks.kind == :before } .map(&:filter) expect(before_actions).to include(:ensure_ownership!) diff --git a/spec/controllers/new_user/user_controller_spec.rb b/spec/controllers/new_user/user_controller_spec.rb index 125466fb6..b4e93c10c 100644 --- a/spec/controllers/new_user/user_controller_spec.rb +++ b/spec/controllers/new_user/user_controller_spec.rb @@ -5,7 +5,7 @@ describe NewUser::UserController, type: :controller do it 'is present' do before_actions = NewUser::UserController ._process_action_callbacks - .find_all{|process_action_callbacks| process_action_callbacks.kind == :before} + .find_all{ |process_action_callbacks| process_action_callbacks.kind == :before } .map(&:filter) expect(before_actions).to include(:authenticate_user!) diff --git a/spec/controllers/users/dossiers/add_siret_controller_spec.rb b/spec/controllers/users/dossiers/add_siret_controller_spec.rb index 091f07aab..9452e3040 100644 --- a/spec/controllers/users/dossiers/add_siret_controller_spec.rb +++ b/spec/controllers/users/dossiers/add_siret_controller_spec.rb @@ -8,7 +8,7 @@ describe Users::Dossiers::AddSiretController, type: :controller do sign_in dossier.user end - subject { get :show, params: {dossier_id: dossier.id }} + subject { get :show, params: {dossier_id: dossier.id } } context 'when dossier is not attached at a procedure with individual siret attribut' do it { is_expected.to redirect_to users_dossiers_path } diff --git a/spec/decorators/champ_decorator_spec.rb b/spec/decorators/champ_decorator_spec.rb index 2dc572ec5..bcf58ed17 100644 --- a/spec/decorators/champ_decorator_spec.rb +++ b/spec/decorators/champ_decorator_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe ChampDecorator do - let(:champ) {create :champ, type_de_champ: (create :type_de_champ_public, type_champ: type_champ)} + let(:champ) { create :champ, type_de_champ: (create :type_de_champ_public, type_champ: type_champ) } let(:decorator) { champ.decorate } describe 'value' do diff --git a/spec/features/users/list_dossiers_spec.rb b/spec/features/users/list_dossiers_spec.rb index edd93ec63..195e80a72 100644 --- a/spec/features/users/list_dossiers_spec.rb +++ b/spec/features/users/list_dossiers_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe 'user access to the list of his dossier' do let(:user) { create(:user) } - let!(:last_updated_dossier) { create(:dossier, :with_entreprise, user: user, state: 'en_construction')} + let!(:last_updated_dossier) { create(:dossier, :with_entreprise, user: user, state: 'en_construction') } let!(:dossier1) { create(:dossier, :with_entreprise, user: user, state: 'en_construction') } let!(:dossier2) { create(:dossier, :with_entreprise) } let!(:dossier_archived) { create(:dossier, :with_entreprise, user: user, state: 'en_construction') } diff --git a/spec/jobs/auto_archive_procedure_job_spec.rb b/spec/jobs/auto_archive_procedure_job_spec.rb index 5aea4b70d..9d44f68e8 100644 --- a/spec/jobs/auto_archive_procedure_job_spec.rb +++ b/spec/jobs/auto_archive_procedure_job_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' RSpec.describe AutoArchiveProcedureJob, type: :job do - let!(:procedure) { create(:procedure, published_at: Time.now, archived_at: nil, auto_archive_on: nil )} - let!(:procedure_hier) { create(:procedure, published_at: Time.now, archived_at: nil, auto_archive_on: 1.day.ago )} - let!(:procedure_aujourdhui) { create(:procedure, published_at: Time.now, archived_at: nil, auto_archive_on: Date.today )} - let!(:procedure_demain) { create(:procedure, published_at: Time.now, archived_at: nil, auto_archive_on: 1.day.from_now )} + let!(:procedure) { create(:procedure, published_at: Time.now, archived_at: nil, auto_archive_on: nil ) } + let!(:procedure_hier) { create(:procedure, published_at: Time.now, archived_at: nil, auto_archive_on: 1.day.ago ) } + let!(:procedure_aujourdhui) { create(:procedure, published_at: Time.now, archived_at: nil, auto_archive_on: Date.today ) } + let!(:procedure_demain) { create(:procedure, published_at: Time.now, archived_at: nil, auto_archive_on: 1.day.from_now ) } subject { AutoArchiveProcedureJob.new.perform } @@ -18,15 +18,15 @@ RSpec.describe AutoArchiveProcedureJob, type: :job do end context "when procedures have auto_archive_on set on yesterday or today" do - let!(:dossier1) { create(:dossier, procedure: procedure_hier, state: 'brouillon', archived: false)} - let!(:dossier2) { create(:dossier, procedure: procedure_hier, state: 'en_construction', archived: false)} - let!(:dossier3) { create(:dossier, procedure: procedure_hier, state: 'en_construction', archived: false)} - let!(:dossier4) { create(:dossier, procedure: procedure_hier, state: 'en_construction', archived: false)} - let!(:dossier5) { create(:dossier, procedure: procedure_hier, state: 'en_instruction', archived: false)} - let!(:dossier6) { create(:dossier, procedure: procedure_hier, state: 'accepte', archived: false)} - let!(:dossier7) { create(:dossier, procedure: procedure_hier, state: 'refuse', archived: false)} - let!(:dossier8) { create(:dossier, procedure: procedure_hier, state: 'sans_suite', archived: false)} - let!(:dossier9) { create(:dossier, procedure: procedure_aujourdhui, state: 'en_construction', archived: false)} + let!(:dossier1) { create(:dossier, procedure: procedure_hier, state: 'brouillon', archived: false) } + let!(:dossier2) { create(:dossier, procedure: procedure_hier, state: 'en_construction', archived: false) } + let!(:dossier3) { create(:dossier, procedure: procedure_hier, state: 'en_construction', archived: false) } + let!(:dossier4) { create(:dossier, procedure: procedure_hier, state: 'en_construction', archived: false) } + let!(:dossier5) { create(:dossier, procedure: procedure_hier, state: 'en_instruction', archived: false) } + let!(:dossier6) { create(:dossier, procedure: procedure_hier, state: 'accepte', archived: false) } + let!(:dossier7) { create(:dossier, procedure: procedure_hier, state: 'refuse', archived: false) } + let!(:dossier8) { create(:dossier, procedure: procedure_hier, state: 'sans_suite', archived: false) } + let!(:dossier9) { create(:dossier, procedure: procedure_aujourdhui, state: 'en_construction', archived: false) } before do subject diff --git a/spec/mailers/welcome_mailer_spec.rb b/spec/mailers/welcome_mailer_spec.rb index f60e24b10..0ce4fe896 100644 --- a/spec/mailers/welcome_mailer_spec.rb +++ b/spec/mailers/welcome_mailer_spec.rb @@ -8,7 +8,7 @@ describe WelcomeMailer, type: :mailer do it { expect(subject.body).to match(new_user_password_url) } it { expect(subject.body).to match(user.email) } it { expect(subject.body).to match('Bienvenue sur la plateforme TPS') } - it { expect(subject.body).to match('Nous vous remercions de vous être inscrit sur TPS. Pour mémoire, voici quelques informations utiles :')} + it { expect(subject.body).to match('Nous vous remercions de vous être inscrit sur TPS. Pour mémoire, voici quelques informations utiles :') } it { expect(subject.subject).to eq("Création de votre compte TPS") } end diff --git a/spec/models/avis_spec.rb b/spec/models/avis_spec.rb index 2581602d0..3ca680440 100644 --- a/spec/models/avis_spec.rb +++ b/spec/models/avis_spec.rb @@ -32,7 +32,7 @@ RSpec.describe Avis, type: :model do subject { Avis.by_latest } - it { expect(subject).to eq([avis, avis3, avis2])} + it { expect(subject).to eq([avis, avis3, avis2]) } end end diff --git a/spec/models/champ_shared_example.rb b/spec/models/champ_shared_example.rb index e09d2179d..9dc5586ac 100644 --- a/spec/models/champ_shared_example.rb +++ b/spec/models/champ_shared_example.rb @@ -55,7 +55,7 @@ shared_examples 'champ_spec' do end context "when type_champ=date" do - let(:type_de_champ) { create(:type_de_champ_public, type_champ: "date")} + let(:type_de_champ) { create(:type_de_champ_public, type_champ: "date") } let(:champ) { create(:champ, type_de_champ: type_de_champ) } it "should convert %d/%m/%Y format to ISO" do diff --git a/spec/models/concern/mail_template_concern_spec.rb b/spec/models/concern/mail_template_concern_spec.rb index 84c36d2a1..13a2cbf34 100644 --- a/spec/models/concern/mail_template_concern_spec.rb +++ b/spec/models/concern/mail_template_concern_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe MailTemplateConcern do - let(:procedure) { create(:procedure)} + let(:procedure) { create(:procedure) } let(:dossier) { create(:dossier, procedure: procedure) } let(:dossier2) { create(:dossier, procedure: procedure) } let(:initiated_mail) { Mails::InitiatedMail.default_for_procedure(procedure) } diff --git a/spec/models/dossier_spec.rb b/spec/models/dossier_spec.rb index f293c9205..2c4ac0202 100644 --- a/spec/models/dossier_spec.rb +++ b/spec/models/dossier_spec.rb @@ -308,7 +308,7 @@ describe Dossier do subject { dossier } - it { expect(dossier.full_data_strings_array).to eq(expected_string)} + it { expect(dossier.full_data_strings_array).to eq(expected_string) } end end @@ -575,7 +575,7 @@ describe Dossier do subject { procedure.dossiers.downloadable_sorted } - it { is_expected.to match([dossier3, dossier4, dossier2])} + it { is_expected.to match([dossier3, dossier4, dossier2]) } end describe "#send_dossier_received" do diff --git a/spec/models/gestionnaire_spec.rb b/spec/models/gestionnaire_spec.rb index f5425bf79..b1e877137 100644 --- a/spec/models/gestionnaire_spec.rb +++ b/spec/models/gestionnaire_spec.rb @@ -214,7 +214,7 @@ describe Gestionnaire, type: :model do end context 'with a followed dossier' do - let!(:dossier){create(:dossier, procedure: procedure, state: 'en_instruction')} + let!(:dossier){ create(:dossier, procedure: procedure, state: 'en_instruction') } let!(:follow){ create(:follow, dossier: dossier, gestionnaire: gestionnaire) } context 'with 1 notification' do @@ -237,7 +237,7 @@ describe Gestionnaire, type: :model do end context 'with another dossier' do - let!(:dossier2){create(:dossier, procedure: procedure, state: 'en_instruction')} + let!(:dossier2){ create(:dossier, procedure: procedure, state: 'en_instruction') } let!(:follow2){ create(:follow, dossier: dossier2, gestionnaire: gestionnaire) } context 'and some notifications' do @@ -346,8 +346,8 @@ describe Gestionnaire, type: :model do let!(:procedure_assign_2) { create :assign_to, gestionnaire: gestionnaire, procedure: procedure_2 } let!(:pp) { ProcedurePresentation.create(assign_to: procedure_assign) } - it { expect(gestionnaire.procedure_presentation_for_procedure_id(procedure.id)).to eq(pp)} - it { expect(gestionnaire.procedure_presentation_for_procedure_id(procedure_2.id).persisted?).to be_falsey} + it { expect(gestionnaire.procedure_presentation_for_procedure_id(procedure.id)).to eq(pp) } + it { expect(gestionnaire.procedure_presentation_for_procedure_id(procedure_2.id).persisted?).to be_falsey } end describe '#notifications_for_dossier' do diff --git a/spec/models/procedure_path_spec.rb b/spec/models/procedure_path_spec.rb index 6f4565fd3..29d349f31 100644 --- a/spec/models/procedure_path_spec.rb +++ b/spec/models/procedure_path_spec.rb @@ -18,31 +18,31 @@ describe ProcedurePath do context 'when path is nil' do let(:path) { nil } - it { expect{procedure_path}.to raise_error ActiveRecord::RecordInvalid } + it { expect{ procedure_path }.to raise_error ActiveRecord::RecordInvalid } end context 'when path is empty' do let(:path) { '' } - it { expect{procedure_path}.to raise_error ActiveRecord::RecordInvalid } + it { expect{ procedure_path }.to raise_error ActiveRecord::RecordInvalid } end context 'when path contains spaces' do let(:path) { 'Demande de subvention' } - it { expect{procedure_path}.to raise_error ActiveRecord::RecordInvalid } + it { expect{ procedure_path }.to raise_error ActiveRecord::RecordInvalid } end context 'when path contains alphanumerics and underscores' do let(:path) { 'ma_super_procedure_1' } - it { expect{procedure_path}.not_to raise_error } + it { expect{ procedure_path }.not_to raise_error } end context 'when path contains dashes' do let(:path) { 'ma-super-procedure' } - it { expect{procedure_path}.not_to raise_error } + it { expect{ procedure_path }.not_to raise_error } end context 'when path is too long' do let(:path) { 'ma-super-procedure-12345678901234567890123456789012345678901234567890' } - it { expect{procedure_path}.to raise_error ActiveRecord::RecordInvalid } + it { expect{ procedure_path }.to raise_error ActiveRecord::RecordInvalid } end context 'when path is too short' do let(:path) { 'pr' } - it { expect{procedure_path}.to raise_error ActiveRecord::RecordInvalid } + it { expect{ procedure_path }.to raise_error ActiveRecord::RecordInvalid } end end end diff --git a/spec/serializers/dossier_table_export_serializer_spec.rb b/spec/serializers/dossier_table_export_serializer_spec.rb index ff2480a07..927edca0a 100644 --- a/spec/serializers/dossier_table_export_serializer_spec.rb +++ b/spec/serializers/dossier_table_export_serializer_spec.rb @@ -39,7 +39,7 @@ describe DossierTableExportSerializer do describe '#emails_accompagnateurs' do let(:gestionnaire){ create(:gestionnaire) } - let(:gestionnaire2) { create :gestionnaire} + let(:gestionnaire2) { create :gestionnaire } let(:dossier) { create(:dossier) } subject { DossierTableExportSerializer.new(dossier).emails_accompagnateurs } diff --git a/spec/services/accompagnateur_service_spec.rb b/spec/services/accompagnateur_service_spec.rb index 295a98d81..a5b71d612 100644 --- a/spec/services/accompagnateur_service_spec.rb +++ b/spec/services/accompagnateur_service_spec.rb @@ -4,7 +4,7 @@ describe AccompagnateurService do let(:procedure) { create :procedure, :published } let(:accompagnateur) { create :gestionnaire } - let(:accompagnateur_service) { AccompagnateurService.new accompagnateur, procedure, to} + let(:accompagnateur_service) { AccompagnateurService.new accompagnateur, procedure, to } describe '#change_assignement!' do subject { accompagnateur_service.change_assignement! } diff --git a/spec/views/users/description/show.html.haml_spec.rb b/spec/views/users/description/show.html.haml_spec.rb index 21c284fc4..4f7bf3d62 100644 --- a/spec/views/users/description/show.html.haml_spec.rb +++ b/spec/views/users/description/show.html.haml_spec.rb @@ -83,8 +83,8 @@ describe 'users/description/show.html.haml', type: :view do describe 'datetime value is correctly setup when is not nil' do it { expect(rendered).to have_css("input[type='datetime'][id='champs_#{champ_datetime.id}'][value='22/06/2016']") } - it { expect(rendered).to have_css("option[value='12'][selected='selected']")} - it { expect(rendered).to have_css("option[value='05'][selected='selected']")} + it { expect(rendered).to have_css("option[value='12'][selected='selected']") } + it { expect(rendered).to have_css("option[value='05'][selected='selected']") } end end diff --git a/spec/views/users/siret/index.html.haml_spec.rb b/spec/views/users/siret/index.html.haml_spec.rb index e489bec08..b51f63c93 100644 --- a/spec/views/users/siret/index.html.haml_spec.rb +++ b/spec/views/users/siret/index.html.haml_spec.rb @@ -25,7 +25,7 @@ describe 'users/siret/index.html.haml', type: :view do end context 'stockage de l\'ID de la procédure dans un champs hidden' do - it {expect(rendered).to have_selector("input[type=hidden][id=procedure_id][name=procedure_id][value='#{procedure.id}']", visible: false)} + it { expect(rendered).to have_selector("input[type=hidden][id=procedure_id][name=procedure_id][value='#{procedure.id}']", visible: false) } end it 'le titre de la procédure est présent sur la page' do From 02ade68b38bfeae93ccd3a24b1f1282fbcae0414 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 15 Jan 2018 22:02:23 +0100 Subject: [PATCH 16/24] Enable the Layout/SpaceInsideBrackets cop --- .rubocop.yml | 2 +- config/initializers/devise.rb | 4 ++-- .../2017_12_21_replace_deprecated_mail_template_tags.rake | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 2c7ac0272..536594e17 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -207,7 +207,7 @@ Layout/SpaceInsideBlockBraces: Enabled: true Layout/SpaceInsideBrackets: - Enabled: false + Enabled: true Layout/SpaceInsideHashLiteralBraces: Enabled: false diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index a12c61265..c365fd228 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -41,12 +41,12 @@ Devise.setup do |config| # Configure which authentication keys should be case-insensitive. # These keys will be downcased upon creating or modifying a user and when used # to authenticate or find a user. Default is :email. - config.case_insensitive_keys = [ :email ] + config.case_insensitive_keys = [:email] # Configure which authentication keys should have whitespace stripped. # These keys will have whitespace before and after removed upon creating or # modifying a user and when used to authenticate or find a user. Default is :email. - config.strip_whitespace_keys = [ :email ] + config.strip_whitespace_keys = [:email] # Tell if authentication through request.params is enabled. True by default. # It can be set to an array that will enable params authentication only for the diff --git a/lib/tasks/2017_12_21_replace_deprecated_mail_template_tags.rake b/lib/tasks/2017_12_21_replace_deprecated_mail_template_tags.rake index 18212003f..af3541161 100644 --- a/lib/tasks/2017_12_21_replace_deprecated_mail_template_tags.rake +++ b/lib/tasks/2017_12_21_replace_deprecated_mail_template_tags.rake @@ -7,7 +7,7 @@ namespace :'2017_12_21_replace_deprecated_mail_template_tags' do end def replace_tag(old_tag, new_tag) - mails = [ Mails::ClosedMail, Mails::InitiatedMail, Mails::ReceivedMail, Mails::RefusedMail, Mails::WithoutContinuationMail] + mails = [Mails::ClosedMail, Mails::InitiatedMail, Mails::ReceivedMail, Mails::RefusedMail, Mails::WithoutContinuationMail] mails.each do |mail| replace_tag_in(mail, 'object', old_tag, new_tag) replace_tag_in(mail, 'body', old_tag, new_tag) From b138dcd876cb06a7f2866450a8a82c99694197da Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Tue, 16 Jan 2018 13:34:24 +0100 Subject: [PATCH 17/24] Enable the Layout/SpaceInsideHashLiteralBraces cop --- .rubocop.yml | 2 +- .../admin/types_de_champ_controller.rb | 2 +- .../types_de_champ_private_controller.rb | 2 +- .../api/v1/procedures_controller.rb | 2 +- app/controllers/application_controller.rb | 2 +- app/controllers/ban/search_controller.rb | 2 +- app/controllers/stats_controller.rb | 2 +- app/controllers/users/carte_controller.rb | 6 ++-- app/controllers/users/dossiers_controller.rb | 2 +- app/lib/carto/sgmap/api.rb | 4 +-- app/models/cerfa.rb | 2 +- app/models/gestionnaire.rb | 2 +- app/models/piece_justificative.rb | 2 +- config/routes.rb | 2 +- ...2_build_default_preference_list_dossier.rb | 2 +- ...95443_reset_all_preference_list_dossier.rb | 2 +- .../admin/accompagnateurs_controller_spec.rb | 4 +-- .../admin/gestionnaires_controller_spec.rb | 4 +-- .../pieces_justificatives_controller_spec.rb | 12 +++---- .../previsualisations_controller_spec.rb | 2 +- .../admin/procedures_controller_spec.rb | 32 ++++++++--------- .../admin/types_de_champ_controller_spec.rb | 14 ++++---- .../types_de_champ_private_controller_spec.rb | 14 ++++---- .../api/v1/dossiers_controller_spec.rb | 16 ++++----- spec/controllers/api_controller_spec.rb | 4 +-- .../controllers/ban/search_controller_spec.rb | 16 ++++----- .../particulier_controller_spec.rb | 2 +- spec/controllers/invites_controller_spec.rb | 2 +- .../dossiers_controller_spec.rb | 8 ++--- .../users/carte_controller_shared_example.rb | 36 +++++++++---------- .../users/description_controller_spec.rb | 2 +- .../dossiers/add_siret_controller_spec.rb | 2 +- .../dossiers/commentaires_controller_spec.rb | 2 +- .../users/dossiers/invites_controller_spec.rb | 8 ++--- .../users/dossiers_controller_spec.rb | 34 +++++++++--------- .../users/recapitulatif_controller_spec.rb | 8 ++--- .../users/sessions_controller_spec.rb | 12 +++---- spec/features/users/dossier_creation_spec.rb | 2 +- spec/lib/carto/geo_api/driver_spec.rb | 4 +-- spec/lib/carto/sgmap/api_spec.rb | 4 +-- spec/lib/carto/sgmap/cadastre/adapter_spec.rb | 4 +-- .../quartiers_prioritaires/adapter_spec.rb | 4 +-- spec/models/champ_shared_example.rb | 2 +- spec/models/dossier_spec.rb | 2 +- spec/models/gestionnaire_spec.rb | 2 +- spec/models/procedure_presentation_spec.rb | 2 +- spec/services/france_connect_service_spec.rb | 2 +- spec/spec_helper.rb | 2 +- spec/support/shared_exemples_for_dossier.rb | 2 +- .../champs/_departements.html.haml_spec.rb | 2 +- .../champs/_regions.html.haml_spec.rb | 2 +- 51 files changed, 154 insertions(+), 154 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 536594e17..f4d827a1d 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -210,7 +210,7 @@ Layout/SpaceInsideBrackets: Enabled: true Layout/SpaceInsideHashLiteralBraces: - Enabled: false + Enabled: true Layout/SpaceInsideArrayLiteralBrackets: Enabled: false diff --git a/app/controllers/admin/types_de_champ_controller.rb b/app/controllers/admin/types_de_champ_controller.rb index 912008ddb..b05c52fdd 100644 --- a/app/controllers/admin/types_de_champ_controller.rb +++ b/app/controllers/admin/types_de_champ_controller.rb @@ -7,7 +7,7 @@ class Admin::TypesDeChampController < AdminController create_facade render 'show', format: :js rescue ActiveRecord::RecordNotFound - render json: {message: 'Champ not found'}, status: 404 + render json: { message: 'Champ not found' }, status: 404 end def show diff --git a/app/controllers/admin/types_de_champ_private_controller.rb b/app/controllers/admin/types_de_champ_private_controller.rb index 28fb9330f..a4cea0946 100644 --- a/app/controllers/admin/types_de_champ_private_controller.rb +++ b/app/controllers/admin/types_de_champ_private_controller.rb @@ -7,7 +7,7 @@ class Admin::TypesDeChampPrivateController < AdminController create_facade render 'admin/types_de_champ/show', format: :js rescue ActiveRecord::RecordNotFound - render json: {message: 'Champ not found'}, status: 404 + render json: { message: 'Champ not found' }, status: 404 end def show diff --git a/app/controllers/api/v1/procedures_controller.rb b/app/controllers/api/v1/procedures_controller.rb index 74895e845..efdca6fa3 100644 --- a/app/controllers/api/v1/procedures_controller.rb +++ b/app/controllers/api/v1/procedures_controller.rb @@ -8,7 +8,7 @@ class API::V1::ProceduresController < APIController def show procedure = current_administrateur.procedures.find(params[:id]).decorate - render json: {procedure: ProcedureSerializer.new(procedure).as_json} + render json: { procedure: ProcedureSerializer.new(procedure).as_json } rescue ActiveRecord::RecordNotFound => e Rails.logger.error(e.message) render json: {}, status: 404 diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 524746fec..5a534f4ce 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -14,7 +14,7 @@ class ApplicationController < ActionController::Base end def default_url_options - return {protocol: 'https'} if Rails.env.staging? || Rails.env.production? + return { protocol: 'https' } if Rails.env.staging? || Rails.env.production? {} end diff --git a/app/controllers/ban/search_controller.rb b/app/controllers/ban/search_controller.rb index ec079347c..aee81b301 100644 --- a/app/controllers/ban/search_controller.rb +++ b/app/controllers/ban/search_controller.rb @@ -17,6 +17,6 @@ class Ban::SearchController < ApplicationController lat = point.y.to_s end - render json: {lon: lon, lat: lat, zoom: '14', dossier_id: params[:dossier_id]} + render json: { lon: lon, lat: lat, zoom: '14', dossier_id: params[:dossier_id] } end end diff --git a/app/controllers/stats_controller.rb b/app/controllers/stats_controller.rb index 342dcd762..470710103 100644 --- a/app/controllers/stats_controller.rb +++ b/app/controllers/stats_controller.rb @@ -64,7 +64,7 @@ class StatsController < ApplicationController .count .to_a .sort_by { |a| a[0] } - .map { |x, y| { x => (sum += y)} } + .map { |x, y| { x => (sum += y) } } .reduce({}, :merge) end diff --git a/app/controllers/users/carte_controller.rb b/app/controllers/users/carte_controller.rb index 8c6314033..08f04f9cd 100644 --- a/app/controllers/users/carte_controller.rb +++ b/app/controllers/users/carte_controller.rb @@ -48,15 +48,15 @@ class Users::CarteController < UsersController lat = point.y.to_s end - render json: {lon: lon, lat: lat, zoom: zoom, dossier_id: params[:dossier_id]} + render json: { lon: lon, lat: lat, zoom: zoom, dossier_id: params[:dossier_id] } end def get_qp - render json: {quartier_prioritaires: ModuleApiCartoService.generate_qp(JSON.parse(params[:coordinates]))} + render json: { quartier_prioritaires: ModuleApiCartoService.generate_qp(JSON.parse(params[:coordinates])) } end def get_cadastre - render json: {cadastres: ModuleApiCartoService.generate_cadastre(JSON.parse(params[:coordinates]))} + render json: { cadastres: ModuleApiCartoService.generate_cadastre(JSON.parse(params[:coordinates])) } end def self.route_authorization diff --git a/app/controllers/users/dossiers_controller.rb b/app/controllers/users/dossiers_controller.rb index 3a95e5199..9c042590e 100644 --- a/app/controllers/users/dossiers_controller.rb +++ b/app/controllers/users/dossiers_controller.rb @@ -181,7 +181,7 @@ class Users::DossiersController < UsersController flash.alert = t('errors.messages.invalid_siret') @facade = facade params[:dossier_id] - render '/dossiers/new_siret', formats: :js, locals: {invalid_siret: siret} + render '/dossiers/new_siret', formats: :js, locals: { invalid_siret: siret } end def update_params diff --git a/app/lib/carto/sgmap/api.rb b/app/lib/carto/sgmap/api.rb index ef72fc062..9ab7a9d9e 100644 --- a/app/lib/carto/sgmap/api.rb +++ b/app/lib/carto/sgmap/api.rb @@ -4,12 +4,12 @@ class CARTO::SGMAP::API def self.search_qp(geojson) endpoint = "/quartiers-prioritaires/search" - call(base_url + endpoint, {geojson: geojson.to_s}) + call(base_url + endpoint, { geojson: geojson.to_s }) end def self.search_cadastre(geojson) endpoint = "/cadastre/geometrie" - call(base_url + endpoint, {geojson: geojson.to_s}) + call(base_url + endpoint, { geojson: geojson.to_s }) end private diff --git a/app/models/cerfa.rb b/app/models/cerfa.rb index d1da7b9d3..8336e4e8a 100644 --- a/app/models/cerfa.rb +++ b/app/models/cerfa.rb @@ -3,7 +3,7 @@ class Cerfa < ActiveRecord::Base belongs_to :user mount_uploader :content, CerfaUploader - validates :content, :file_size => {:maximum => 20.megabytes} + validates :content, :file_size => { :maximum => 20.megabytes } after_save :internal_notification, if: Proc.new { dossier.present? } diff --git a/app/models/gestionnaire.rb b/app/models/gestionnaire.rb index 4a71848a9..02cd33e81 100644 --- a/app/models/gestionnaire.rb +++ b/app/models/gestionnaire.rb @@ -177,7 +177,7 @@ class Gestionnaire < ActiveRecord::Base } ] - couples.include?({table: table, column: column}) + couples.include?({ table: table, column: column }) end def annotations_hash(demande, annotations_privees, avis, messagerie) diff --git a/app/models/piece_justificative.rb b/app/models/piece_justificative.rb index 468fb0fa7..799374d8b 100644 --- a/app/models/piece_justificative.rb +++ b/app/models/piece_justificative.rb @@ -10,7 +10,7 @@ class PieceJustificative < ActiveRecord::Base alias_attribute :type, :type_de_piece_justificative_id mount_uploader :content, PieceJustificativeUploader - validates :content, :file_size => {:maximum => 20.megabytes} + validates :content, :file_size => { :maximum => 20.megabytes } validates :content, presence: true, allow_blank: false, allow_nil: false after_save :internal_notification, if: Proc.new { dossier.present? } diff --git a/config/routes.rb b/config/routes.rb index 1f19a32d7..cfb615098 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -17,7 +17,7 @@ Rails.application.routes.draw do root to: "administrateurs#index" end - get "/ping" => "ping#index", :constraints => {:ip => /127.0.0.1/} + get "/ping" => "ping#index", :constraints => { :ip => /127.0.0.1/ } devise_for :administrations, skip: [:password, :registrations, :sessions], diff --git a/db/migrate/20160802113112_build_default_preference_list_dossier.rb b/db/migrate/20160802113112_build_default_preference_list_dossier.rb index d4b211d69..a1628f20f 100644 --- a/db/migrate/20160802113112_build_default_preference_list_dossier.rb +++ b/db/migrate/20160802113112_build_default_preference_list_dossier.rb @@ -43,7 +43,7 @@ class BuildDefaultPreferenceListDossier < ActiveRecord::Migration } ] - couples.include?({table: table, column: column}) + couples.include?({ table: table, column: column }) end end diff --git a/db/migrate/20161007095443_reset_all_preference_list_dossier.rb b/db/migrate/20161007095443_reset_all_preference_list_dossier.rb index 672f3e7a0..47e44ce44 100644 --- a/db/migrate/20161007095443_reset_all_preference_list_dossier.rb +++ b/db/migrate/20161007095443_reset_all_preference_list_dossier.rb @@ -141,7 +141,7 @@ class ResetAllPreferenceListDossier < ActiveRecord::Migration } ] - couples.include?({table: table, column: column}) + couples.include?({ table: table, column: column }) end end diff --git a/spec/controllers/admin/accompagnateurs_controller_spec.rb b/spec/controllers/admin/accompagnateurs_controller_spec.rb index d80208cbf..f8891a2ad 100644 --- a/spec/controllers/admin/accompagnateurs_controller_spec.rb +++ b/spec/controllers/admin/accompagnateurs_controller_spec.rb @@ -10,12 +10,12 @@ describe Admin::AccompagnateursController, type: :controller do end describe 'GET #show' do - subject { get :show, params: {procedure_id: procedure.id} } + subject { get :show, params: { procedure_id: procedure.id } } it { expect(subject.status).to eq(200) } end describe 'PUT #update' do - subject { put :update, params: {accompagnateur_id: gestionnaire.id, procedure_id: procedure.id, to: 'assign'} } + subject { put :update, params: { accompagnateur_id: gestionnaire.id, procedure_id: procedure.id, to: 'assign' } } it { expect(subject).to redirect_to admin_procedure_accompagnateurs_path(procedure_id: procedure.id) } diff --git a/spec/controllers/admin/gestionnaires_controller_spec.rb b/spec/controllers/admin/gestionnaires_controller_spec.rb index 8e2c55212..3d2bcf246 100644 --- a/spec/controllers/admin/gestionnaires_controller_spec.rb +++ b/spec/controllers/admin/gestionnaires_controller_spec.rb @@ -17,7 +17,7 @@ describe Admin::GestionnairesController, type: :controller do describe 'POST #create' do let(:email) { 'test@plop.com' } let(:procedure_id) { nil } - subject { post :create, params: {gestionnaire: {email: email}, procedure_id: procedure_id} } + subject { post :create, params: { gestionnaire: { email: email }, procedure_id: procedure_id } } context 'When email is valid' do before do @@ -169,7 +169,7 @@ describe Admin::GestionnairesController, type: :controller do let!(:admin) { create :administrateur } let!(:gestionnaire) { create :gestionnaire, email: email, administrateurs: [admin] } - subject { delete :destroy, params: {id: gestionnaire.id} } + subject { delete :destroy, params: { id: gestionnaire.id } } context "when gestionaire_id is valid" do before do diff --git a/spec/controllers/admin/pieces_justificatives_controller_spec.rb b/spec/controllers/admin/pieces_justificatives_controller_spec.rb index c1e66c366..2034cf2d3 100644 --- a/spec/controllers/admin/pieces_justificatives_controller_spec.rb +++ b/spec/controllers/admin/pieces_justificatives_controller_spec.rb @@ -11,7 +11,7 @@ describe Admin::PiecesJustificativesController, type: :controller do describe 'GET #show' do let(:procedure_id) { procedure.id } - subject { get :show, params: {procedure_id: procedure_id} } + subject { get :show, params: { procedure_id: procedure_id } } context 'when procedure is not found' do let(:procedure_id) { 9_999_999 } @@ -47,7 +47,7 @@ describe Admin::PiecesJustificativesController, type: :controller do } end - let(:request) { put :update, params: {procedure_id: procedure_id, format: :js, procedure: update_params} } + let(:request) { put :update, params: { procedure_id: procedure_id, format: :js, procedure: update_params } } subject { request } it { is_expected.to render_template('show') } @@ -75,7 +75,7 @@ describe Admin::PiecesJustificativesController, type: :controller do let!(:pj) { create(:type_de_piece_justificative, procedure: procedure) } let(:procedure_id) { procedure.id } let(:pj_id) { pj.id } - let(:request) { delete :destroy, params: {procedure_id: procedure_id, id: pj_id} } + let(:request) { delete :destroy, params: { procedure_id: procedure_id, id: pj_id } } subject { request } context 'when procedure is not found' do let(:procedure_id) { 9_999_999 } @@ -98,7 +98,7 @@ describe Admin::PiecesJustificativesController, type: :controller do end describe 'POST #move_up' do - subject { post :move_up, params: {procedure_id: procedure.id, index: index, format: :js} } + subject { post :move_up, params: { procedure_id: procedure.id, index: index, format: :js } } context 'when procedure have no type de champ' do let(:index) { 0 } @@ -124,7 +124,7 @@ describe Admin::PiecesJustificativesController, type: :controller do it { expect(subject.status).to eq(200) } it { expect(subject).to render_template('show') } it 'changes order places' do - post :move_up, params: {procedure_id: procedure.id, index: index, format: :js} + post :move_up, params: { procedure_id: procedure.id, index: index, format: :js } type_de_piece_justificative_0.reload type_de_piece_justificative_1.reload expect(type_de_piece_justificative_0.order_place).to eq(1) @@ -135,7 +135,7 @@ describe Admin::PiecesJustificativesController, type: :controller do end describe 'POST #move_down' do - let(:request) { post :move_down, params: {procedure_id: procedure.id, index: index, format: :js} } + let(:request) { post :move_down, params: { procedure_id: procedure.id, index: index, format: :js } } let(:index) { 0 } subject { request } diff --git a/spec/controllers/admin/previsualisations_controller_spec.rb b/spec/controllers/admin/previsualisations_controller_spec.rb index 6d2adedad..8379c65c7 100644 --- a/spec/controllers/admin/previsualisations_controller_spec.rb +++ b/spec/controllers/admin/previsualisations_controller_spec.rb @@ -9,7 +9,7 @@ describe Admin::PrevisualisationsController, type: :controller do end describe 'GET #show' do - subject { get :show, params: {procedure_id: procedure.id} } + subject { get :show, params: { procedure_id: procedure.id } } it { expect(subject.status).to eq(200) } end end diff --git a/spec/controllers/admin/procedures_controller_spec.rb b/spec/controllers/admin/procedures_controller_spec.rb index cf1acb3e4..2564a49c6 100644 --- a/spec/controllers/admin/procedures_controller_spec.rb +++ b/spec/controllers/admin/procedures_controller_spec.rb @@ -59,7 +59,7 @@ describe Admin::ProceduresController, type: :controller do let(:procedure_published) { create :procedure, administrateur: admin, published_at: Time.now, archived_at: nil } let(:procedure_archived) { create :procedure, administrateur: admin, published_at: nil, archived_at: Time.now } - subject { delete :destroy, params: {id: procedure.id} } + subject { delete :destroy, params: { id: procedure.id } } context 'when procedure is draft' do let!(:procedure) { procedure_draft } @@ -96,7 +96,7 @@ describe Admin::ProceduresController, type: :controller do context "when administrateur does not own the procedure" do let(:procedure_not_owned) { create :procedure, administrateur: create(:administrateur), published_at: nil, archived_at: nil } - subject { delete :destroy, params: {id: procedure_not_owned.id} } + subject { delete :destroy, params: { id: procedure_not_owned.id } } it { expect{ subject }.to raise_error(ActiveRecord::RecordNotFound) } end @@ -107,7 +107,7 @@ describe Admin::ProceduresController, type: :controller do let(:procedure) { create(:procedure, administrateur: admin, published_at: published_at) } let(:procedure_id) { procedure.id } - subject { get :edit, params: {id: procedure_id} } + subject { get :edit, params: { id: procedure_id } } context 'when user is not connected' do before do @@ -139,14 +139,14 @@ describe Admin::ProceduresController, type: :controller do describe 'POST #create' do context 'when all attributs are filled' do describe 'new procedure in database' do - subject { post :create, params: {procedure: procedure_params} } + subject { post :create, params: { procedure: procedure_params } } it { expect { subject }.to change { Procedure.count }.by(1) } end context 'when procedure is correctly save' do before do - post :create, params: {procedure: procedure_params} + post :create, params: { procedure: procedure_params } end describe 'procedure attributs in database' do @@ -183,7 +183,7 @@ describe Admin::ProceduresController, type: :controller do let(:description) { '' } describe 'no new procedure in database' do - subject { post :create, params: {procedure: procedure_params} } + subject { post :create, params: { procedure: procedure_params } } it { expect { subject }.to change { Procedure.count }.by(0) } @@ -194,7 +194,7 @@ describe Admin::ProceduresController, type: :controller do describe 'flash message is present' do before do - post :create, params: {procedure: procedure_params} + post :create, params: { procedure: procedure_params } end it { expect(flash[:alert]).to be_present } @@ -210,14 +210,14 @@ describe Admin::ProceduresController, type: :controller do sign_out admin end - subject { put :update, params: {id: procedure.id} } + subject { put :update, params: { id: procedure.id } } it { is_expected.to redirect_to new_user_session_path } end context 'when administrateur is connected' do before do - put :update, params: {id: procedure.id, procedure: procedure_params} + put :update, params: { id: procedure.id, procedure: procedure_params } procedure.reload end @@ -297,7 +297,7 @@ describe Admin::ProceduresController, type: :controller do context 'when admin is the owner of the procedure' do before do - put :publish, params: {procedure_id: procedure.id, procedure_path: procedure_path} + put :publish, params: { procedure_id: procedure.id, procedure_path: procedure_path } procedure.reload procedure2.reload end @@ -364,7 +364,7 @@ describe Admin::ProceduresController, type: :controller do sign_out admin sign_in admin_2 - put :publish, params: {procedure_id: procedure.id, procedure_path: 'fake_path'} + put :publish, params: { procedure_id: procedure.id, procedure_path: 'fake_path' } procedure.reload end @@ -380,7 +380,7 @@ describe Admin::ProceduresController, type: :controller do context 'when admin is the owner of the procedure' do before do - put :archive, params: {procedure_id: procedure.id} + put :archive, params: { procedure_id: procedure.id } procedure.reload end @@ -392,7 +392,7 @@ describe Admin::ProceduresController, type: :controller do context 'when owner want to re-enable procedure' do before do - put :publish, params: {procedure_id: procedure.id, procedure_path: 'fake_path'} + put :publish, params: { procedure_id: procedure.id, procedure_path: 'fake_path' } procedure.reload end @@ -409,7 +409,7 @@ describe Admin::ProceduresController, type: :controller do sign_out admin sign_in admin_2 - put :archive, params: {procedure_id: procedure.id} + put :archive, params: { procedure_id: procedure.id } procedure.reload end @@ -420,7 +420,7 @@ describe Admin::ProceduresController, type: :controller do describe 'PUT #clone' do let!(:procedure) { create(:procedure, administrateur: admin) } - subject { put :clone, params: {procedure_id: procedure.id} } + subject { put :clone, params: { procedure_id: procedure.id } } it { expect { subject }.to change(Procedure, :count).by(1) } @@ -502,7 +502,7 @@ describe Admin::ProceduresController, type: :controller do describe 'POST transfer' do let!(:procedure) { create :procedure, administrateur: admin } - subject { post :transfer, params: {email_admin: email_admin, procedure_id: procedure.id} } + subject { post :transfer, params: { email_admin: email_admin, procedure_id: procedure.id } } context 'when admin is unknow' do let(:email_admin) { 'plop' } diff --git a/spec/controllers/admin/types_de_champ_controller_spec.rb b/spec/controllers/admin/types_de_champ_controller_spec.rb index 3b68c6de6..d3b6fc8fa 100644 --- a/spec/controllers/admin/types_de_champ_controller_spec.rb +++ b/spec/controllers/admin/types_de_champ_controller_spec.rb @@ -13,7 +13,7 @@ describe Admin::TypesDeChampController, type: :controller do let(:procedure) { create(:procedure, administrateur: admin, published_at: published_at) } let(:procedure_id) { procedure.id } - subject { get :show, params: {procedure_id: procedure_id} } + subject { get :show, params: { procedure_id: procedure_id } } context 'when procedure is not found' do let(:procedure_id) { 9_999_999 } @@ -64,7 +64,7 @@ describe Admin::TypesDeChampController, type: :controller do } end - let(:request) { put :update, params: {procedure_id: procedure.id, procedure: procedure_params}, format: :js } + let(:request) { put :update, params: { procedure_id: procedure.id, procedure: procedure_params }, format: :js } context 'when procedure is found' do it { expect { request }.to change(TypeDeChamp, :count).by(1) } @@ -122,7 +122,7 @@ describe Admin::TypesDeChampController, type: :controller do end end context 'when procedure is not found' do - subject { put :update, format: :js, params: {procedure_id: 9_999_999, procedure: procedure_params} } + subject { put :update, format: :js, params: { procedure_id: 9_999_999, procedure: procedure_params } } it 'creates type de champ' do expect(subject.status).to eq(404) end @@ -131,7 +131,7 @@ describe Admin::TypesDeChampController, type: :controller do describe '#destroy' do before do - delete :destroy, params: {procedure_id: procedure.id, id: type_de_champ_id, format: :js} + delete :destroy, params: { procedure_id: procedure.id, id: type_de_champ_id, format: :js } end context 'when type de champs does not exist' do @@ -155,7 +155,7 @@ describe Admin::TypesDeChampController, type: :controller do end describe 'POST #move_up' do - subject { post :move_up, params: {procedure_id: procedure.id, index: index, format: :js} } + subject { post :move_up, params: { procedure_id: procedure.id, index: index, format: :js } } context 'when procedure have no type de champ' do let(:index) { 0 } @@ -181,7 +181,7 @@ describe Admin::TypesDeChampController, type: :controller do it { expect(subject.status).to eq(200) } it { expect(subject).to render_template('show') } it 'changes order places' do - post :move_up, params: {procedure_id: procedure.id, index: index, format: :js} + post :move_up, params: { procedure_id: procedure.id, index: index, format: :js } type_de_champ_0.reload type_de_champ_1.reload expect(type_de_champ_0.order_place).to eq(1) @@ -192,7 +192,7 @@ describe Admin::TypesDeChampController, type: :controller do end describe 'POST #move_down' do - let(:request) { post :move_down, params: {procedure_id: procedure.id, index: index, format: :js} } + let(:request) { post :move_down, params: { procedure_id: procedure.id, index: index, format: :js } } let(:index) { 0 } subject { request } diff --git a/spec/controllers/admin/types_de_champ_private_controller_spec.rb b/spec/controllers/admin/types_de_champ_private_controller_spec.rb index 701bb2c91..61ab44966 100644 --- a/spec/controllers/admin/types_de_champ_private_controller_spec.rb +++ b/spec/controllers/admin/types_de_champ_private_controller_spec.rb @@ -13,7 +13,7 @@ describe Admin::TypesDeChampPrivateController, type: :controller do let(:procedure) { create(:procedure, administrateur: admin, published_at: published_at) } let(:procedure_id) { procedure.id } - subject { get :show, params: {procedure_id: procedure_id} } + subject { get :show, params: { procedure_id: procedure_id } } context 'when procedure is not found' do let(:procedure_id) { 9_999_999 } @@ -65,7 +65,7 @@ describe Admin::TypesDeChampPrivateController, type: :controller do } end - let(:request) { put :update, params: {format: :js, procedure_id: procedure.id, procedure: procedure_params} } + let(:request) { put :update, params: { format: :js, procedure_id: procedure.id, procedure: procedure_params } } context 'when procedure is found' do it { expect { request }.to change(TypeDeChamp, :count).by(1) } @@ -105,7 +105,7 @@ describe Admin::TypesDeChampPrivateController, type: :controller do end end context 'when procedure is not found' do - subject { put :update, params: {format: :js, procedure_id: 9_999_999, procedure: procedure_params} } + subject { put :update, params: { format: :js, procedure_id: 9_999_999, procedure: procedure_params } } it 'creates type de champ' do expect(subject.status).to eq(404) end @@ -114,7 +114,7 @@ describe Admin::TypesDeChampPrivateController, type: :controller do describe '#destroy' do before do - delete :destroy, params: {procedure_id: procedure.id, id: type_de_champ_id, format: :js} + delete :destroy, params: { procedure_id: procedure.id, id: type_de_champ_id, format: :js } end context 'when type de champs does not exist' do @@ -138,7 +138,7 @@ describe Admin::TypesDeChampPrivateController, type: :controller do end describe 'POST #move_up' do - subject { post :move_up, params: {procedure_id: procedure.id, index: index, format: :js} } + subject { post :move_up, params: { procedure_id: procedure.id, index: index, format: :js } } context 'when procedure have no type de champ' do let(:index) { 0 } @@ -164,7 +164,7 @@ describe Admin::TypesDeChampPrivateController, type: :controller do it { expect(subject.status).to eq(200) } it { expect(subject).to render_template('show') } it 'changes order places' do - post :move_up, params: {procedure_id: procedure.id, index: index, format: :js} + post :move_up, params: { procedure_id: procedure.id, index: index, format: :js } type_de_champ_0.reload type_de_champ_1.reload expect(type_de_champ_0.order_place).to eq(1) @@ -175,7 +175,7 @@ describe Admin::TypesDeChampPrivateController, type: :controller do end describe 'POST #move_down' do - let(:request) { post :move_down, params: {procedure_id: procedure.id, index: index, format: :js} } + let(:request) { post :move_down, params: { procedure_id: procedure.id, index: index, format: :js } } let(:index) { 0 } subject { request } diff --git a/spec/controllers/api/v1/dossiers_controller_spec.rb b/spec/controllers/api/v1/dossiers_controller_spec.rb index 266babaad..b22913982 100644 --- a/spec/controllers/api/v1/dossiers_controller_spec.rb +++ b/spec/controllers/api/v1/dossiers_controller_spec.rb @@ -8,7 +8,7 @@ describe API::V1::DossiersController do it { expect(described_class).to be < APIController } describe 'GET index' do - let(:retour) { get :index, params: {token: admin.api_token, procedure_id: procedure_id} } + let(:retour) { get :index, params: { token: admin.api_token, procedure_id: procedure_id } } subject { retour } @@ -59,7 +59,7 @@ describe API::V1::DossiersController do end context 'when there are multiple pages' do - let(:retour) { get :index, params: {token: admin.api_token, procedure_id: procedure_id, page: 2} } + let(:retour) { get :index, params: { token: admin.api_token, procedure_id: procedure_id, page: 2 } } let!(:dossier1) { create(:dossier, :with_entreprise, procedure: procedure, state: 'en_construction') } let!(:dossier2) { create(:dossier, :with_entreprise, procedure: procedure, state: 'en_construction') } @@ -80,7 +80,7 @@ describe API::V1::DossiersController do end describe 'GET show' do - let(:retour) { get :show, params: {token: admin.api_token, procedure_id: procedure_id, id: dossier_id} } + let(:retour) { get :show, params: { token: admin.api_token, procedure_id: procedure_id, id: dossier_id } } subject { retour } context 'when procedure is not found' do @@ -178,7 +178,7 @@ describe API::V1::DossiersController do end end - describe 'piece justificative', vcr: {cassette_name: 'controllers_api_v1_dossiers_controller_piece_justificative'} do + describe 'piece justificative', vcr: { cassette_name: 'controllers_api_v1_dossiers_controller_piece_justificative' } do before do create :piece_justificative, :rib, dossier: dossier, type_de_piece_justificative: dossier.procedure.types_de_piece_justificative.first, user: dossier.user end @@ -240,7 +240,7 @@ describe API::V1::DossiersController do super().find { |champ| champ[:type_de_champ][:type_champ] == 'quartier_prioritaire' } end - it { expect(subject[:type_de_champ]).to match({ id: -1, libelle: 'quartier prioritaire', type_champ: 'quartier_prioritaire', order_place: -1, descripton: ''}) } + it { expect(subject[:type_de_champ]).to match({ id: -1, libelle: 'quartier prioritaire', type_champ: 'quartier_prioritaire', order_place: -1, descripton: '' }) } it { expect(subject[:value]).to match(dossier.quartier_prioritaires.first.geometry.symbolize_keys) } end @@ -253,7 +253,7 @@ describe API::V1::DossiersController do super().find { |champ| champ[:type_de_champ][:type_champ] == 'cadastre' } end - it { expect(subject[:type_de_champ]).to match({ id: -1, libelle: 'cadastre', type_champ: 'cadastre', order_place: -1, descripton: ''}) } + it { expect(subject[:type_de_champ]).to match({ id: -1, libelle: 'cadastre', type_champ: 'cadastre', order_place: -1, descripton: '' }) } it { expect(subject[:value]).to match(dossier.cadastres.first.geometry.symbolize_keys) } end @@ -267,7 +267,7 @@ describe API::V1::DossiersController do super().find { |champ| champ[:type_de_champ][:type_champ] == 'user_geometry' } end - it { expect(subject[:type_de_champ]).to match({ id: -1, libelle: 'user_geometry', type_champ: 'user_geometry', order_place: -1, descripton: ''}) } + it { expect(subject[:type_de_champ]).to match({ id: -1, libelle: 'user_geometry', type_champ: 'user_geometry', order_place: -1, descripton: '' }) } it { expect(subject[:value]).to match(UserGeometry.new(dossier.json_latlngs).value) } end end @@ -318,7 +318,7 @@ describe API::V1::DossiersController do it { expect(subject.first[:email]).to eq 'plop@plip.com' } end - describe 'cerfa', vcr: {cassette_name: 'controllers_api_v1_dossiers_controller_cerfa'} do + describe 'cerfa', vcr: { cassette_name: 'controllers_api_v1_dossiers_controller_cerfa' } do let!(:dossier) { Timecop.freeze(date_creation) { create(:dossier, :with_entreprise, :with_cerfa_upload, procedure: procedure) } } let(:content) { File.open('./spec/support/files/piece_justificative_388.pdf') } diff --git a/spec/controllers/api_controller_spec.rb b/spec/controllers/api_controller_spec.rb index c0c92a9ec..a5eeb335b 100644 --- a/spec/controllers/api_controller_spec.rb +++ b/spec/controllers/api_controller_spec.rb @@ -18,12 +18,12 @@ describe APIController, type: :controller do end context 'when token does not exist' do let(:token) { 'invalid_token' } - subject { get :index, params: {token: token} } + subject { get :index, params: { token: token } } it { expect(subject.status).to eq(401) } end context 'when token exist' do let(:administrateur) { create(:administrateur) } - subject { get :index, params: {token: administrateur.api_token} } + subject { get :index, params: { token: administrateur.api_token } } it { expect(subject.status).to eq(200) } end end diff --git a/spec/controllers/ban/search_controller_spec.rb b/spec/controllers/ban/search_controller_spec.rb index 7fe454e19..76dfeee43 100644 --- a/spec/controllers/ban/search_controller_spec.rb +++ b/spec/controllers/ban/search_controller_spec.rb @@ -2,20 +2,20 @@ require 'spec_helper' describe Ban::SearchController, type: :controller do describe '#GET get' do - subject { get :get, params: {request: request} } + subject { get :get, params: { request: request } } before do subject end - context 'when request return result', vcr: {cassette_name: 'bano_search_paris'} do + context 'when request return result', vcr: { cassette_name: 'bano_search_paris' } do let (:request) { 'Paris' } it { expect(response.status).to eq 200 } it { expect(response.body).to eq '[{"label":"Paris"},{"label":"Paris 63120 Courpière"},{"label":"PARIS (Vaillac) 46240 Cœur de Causse"},{"label":"Paris 40500 Saint-Sever"},{"label":"Paris Buton 37140 Bourgueil"}]' } end - context 'when request return nothing', vcr: {cassette_name: 'bano_search_nothing'} do + context 'when request return nothing', vcr: { cassette_name: 'bano_search_nothing' } do let (:request) { 'je recherche pas grand chose' } it { expect(response.status).to eq 200 } @@ -25,22 +25,22 @@ describe Ban::SearchController, type: :controller do describe '#GET get_address_point' do let(:dossier_id) { "1" } - subject { get :get_address_point, params: {request: request, dossier_id: dossier_id} } + subject { get :get_address_point, params: { request: request, dossier_id: dossier_id } } before do subject end - context 'when request return result', vcr: {cassette_name: 'ban_search_paris'} do + context 'when request return result', vcr: { cassette_name: 'ban_search_paris' } do let(:request) { 'Paris' } - it { expect(response.body).to eq ({lon: '2.3469', lat: '48.8589', zoom: '14', dossier_id: dossier_id}).to_json } + it { expect(response.body).to eq ({ lon: '2.3469', lat: '48.8589', zoom: '14', dossier_id: dossier_id }).to_json } end - context 'when request return nothing', vcr: {cassette_name: 'ban_search_nothing'} do + context 'when request return nothing', vcr: { cassette_name: 'ban_search_nothing' } do let(:request) { 'je recherche pas grand chose' } - it { expect(response.body).to eq ({lon: nil, lat: nil, zoom: '14', dossier_id: dossier_id}).to_json } + it { expect(response.body).to eq ({ lon: nil, lat: nil, zoom: '14', dossier_id: dossier_id }).to_json } end end end diff --git a/spec/controllers/france_connect/particulier_controller_spec.rb b/spec/controllers/france_connect/particulier_controller_spec.rb index fbdc12733..290842db1 100644 --- a/spec/controllers/france_connect/particulier_controller_spec.rb +++ b/spec/controllers/france_connect/particulier_controller_spec.rb @@ -23,7 +23,7 @@ describe FranceConnect::ParticulierController, type: :controller do describe '#callback' do let(:code) { 'plop' } - subject { get :callback, params: {code: code} } + subject { get :callback, params: { code: code } } context 'when param code is missing' do let(:code) { nil } diff --git a/spec/controllers/invites_controller_spec.rb b/spec/controllers/invites_controller_spec.rb index 29e6f6853..f32dbaf68 100644 --- a/spec/controllers/invites_controller_spec.rb +++ b/spec/controllers/invites_controller_spec.rb @@ -11,7 +11,7 @@ describe InvitesController, type: :controller do sign_in signed_in_profile end - subject { post :create, params: {dossier_id: dossier.id, email: email} } + subject { post :create, params: { dossier_id: dossier.id, email: email } } context "when gestionnaire is signed_in" do let(:signed_in_profile) { create(:gestionnaire) } diff --git a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb index 4249ecfaa..26deeb93c 100644 --- a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb @@ -95,7 +95,7 @@ describe NewGestionnaire::DossiersController, type: :controller do sign_in gestionnaire end - subject { post :repasser_en_construction, params: { procedure_id: procedure.id, dossier_id: dossier.id} } + subject { post :repasser_en_construction, params: { procedure_id: procedure.id, dossier_id: dossier.id } } it 'change state to en_construction' do subject @@ -114,7 +114,7 @@ describe NewGestionnaire::DossiersController, type: :controller do sign_in gestionnaire end - subject { post :terminer, params: { process_action: "refuser", procedure_id: procedure.id, dossier_id: dossier.id} } + subject { post :terminer, params: { process_action: "refuser", procedure_id: procedure.id, dossier_id: dossier.id } } it 'change state to refuse' do subject @@ -140,7 +140,7 @@ describe NewGestionnaire::DossiersController, type: :controller do sign_in gestionnaire end - subject { post :terminer, params: { process_action: "classer_sans_suite", procedure_id: procedure.id, dossier_id: dossier.id} } + subject { post :terminer, params: { process_action: "classer_sans_suite", procedure_id: procedure.id, dossier_id: dossier.id } } it 'change state to sans_suite' do subject @@ -174,7 +174,7 @@ describe NewGestionnaire::DossiersController, type: :controller do expect(NotificationMailer).to receive(:deliver_now!) end - subject { post :terminer, params: { process_action: "accepter", procedure_id: procedure.id, dossier_id: dossier.id} } + subject { post :terminer, params: { process_action: "accepter", procedure_id: procedure.id, dossier_id: dossier.id } } it 'change state to accepte' do subject diff --git a/spec/controllers/users/carte_controller_shared_example.rb b/spec/controllers/users/carte_controller_shared_example.rb index 01c885884..4e250c772 100644 --- a/spec/controllers/users/carte_controller_shared_example.rb +++ b/spec/controllers/users/carte_controller_shared_example.rb @@ -7,7 +7,7 @@ shared_examples 'carte_controller_spec' do dossier.state = 'en_instruction' dossier.save - get :show, params: {dossier_id: dossier.id} + get :show, params: { dossier_id: dossier.id } end it { is_expected.to redirect_to root_path } @@ -18,7 +18,7 @@ shared_examples 'carte_controller_spec' do let(:dossier) { create(:dossier) } before do - get :show, params: {dossier_id: dossier.id} + get :show, params: { dossier_id: dossier.id } end it { is_expected.to redirect_to(root_path) } @@ -31,26 +31,26 @@ shared_examples 'carte_controller_spec' do end it 'redirects to users/sign_in' do - get :show, params: {dossier_id: dossier.id} + get :show, params: { dossier_id: dossier.id } expect(response).to redirect_to('/users/sign_in') end end it 'returns http success if carto is activated' do - get :show, params: {dossier_id: dossier.id} + get :show, params: { dossier_id: dossier.id } expect(response).to have_http_status(:success) end context 'when procedure not have activate api carto' do it 'redirection on user dossier list' do - get :show, params: {dossier_id: dossier_with_no_carto.id} + get :show, params: { dossier_id: dossier_with_no_carto.id } expect(response).to redirect_to(root_path) end end context 'when dossier id not exist' do it 'redirection on user dossier list' do - get :show, params: {dossier_id: bad_dossier_id} + get :show, params: { dossier_id: bad_dossier_id } expect(response).to redirect_to(root_path) end end @@ -61,7 +61,7 @@ shared_examples 'carte_controller_spec' do describe 'POST #save' do context 'Aucune localisation n\'a jamais été enregistrée' do it do - post :save, params: {dossier_id: dossier.id, json_latlngs: ''} + post :save, params: { dossier_id: dossier.id, json_latlngs: '' } expect(response).to redirect_to("/users/dossiers/#{dossier.id}/description") end end @@ -69,7 +69,7 @@ shared_examples 'carte_controller_spec' do context 'En train de modifier la localisation' do let(:dossier) { create(:dossier, state: 'en_construction') } before do - post :save, params: {dossier_id: dossier.id, json_latlngs: ''} + post :save, params: { dossier_id: dossier.id, json_latlngs: '' } end it 'Redirection vers la page récapitulatif' do @@ -83,9 +83,9 @@ shared_examples 'carte_controller_spec' do before do allow_any_instance_of(CARTO::SGMAP::QuartiersPrioritaires::Adapter) .to receive(:to_params) - .and_return({"QPCODE1234" => {:code => "QPCODE1234", :nom => "QP de test", :commune => "Paris", :geometry => {:type => "MultiPolygon", :coordinates => [[[[2.38715792094576, 48.8723062632126], [2.38724851642619, 48.8721392348061]]]]}}}) + .and_return({ "QPCODE1234" => { :code => "QPCODE1234", :nom => "QP de test", :commune => "Paris", :geometry => { :type => "MultiPolygon", :coordinates => [[[[2.38715792094576, 48.8723062632126], [2.38724851642619, 48.8721392348061]]]] } } }) - post :save, params: {dossier_id: dossier.id, json_latlngs: json_latlngs} + post :save, params: { dossier_id: dossier.id, json_latlngs: json_latlngs } end context 'when json_latlngs params is empty' do @@ -130,9 +130,9 @@ shared_examples 'carte_controller_spec' do before do allow_any_instance_of(CARTO::SGMAP::Cadastre::Adapter) .to receive(:to_params) - .and_return([{:surface_intersection => "0.0006", :surface_parcelle => 11252.692583090324, :numero => "0013", :feuille => 1, :section => "CD", :code_dep => "30", :nom_com => "Le Grau-du-Roi", :code_com => "133", :code_arr => "000", :geometry => {:type => "MultiPolygon", :coordinates => [[[[4.134084, 43.5209193], [4.1346615, 43.5212035], [4.1346984, 43.521189], [4.135096, 43.5213848], [4.1350839, 43.5214122], [4.1352697, 43.521505], [4.1356278, 43.5211065], [4.1357402, 43.5207188], [4.1350935, 43.5203936], [4.135002, 43.5204366], [4.1346051, 43.5202412], [4.134584, 43.5202472], [4.1345572, 43.5202551], [4.134356, 43.5203137], [4.1342488, 43.5203448], [4.134084, 43.5209193]]]]}}]) + .and_return([{ :surface_intersection => "0.0006", :surface_parcelle => 11252.692583090324, :numero => "0013", :feuille => 1, :section => "CD", :code_dep => "30", :nom_com => "Le Grau-du-Roi", :code_com => "133", :code_arr => "000", :geometry => { :type => "MultiPolygon", :coordinates => [[[[4.134084, 43.5209193], [4.1346615, 43.5212035], [4.1346984, 43.521189], [4.135096, 43.5213848], [4.1350839, 43.5214122], [4.1352697, 43.521505], [4.1356278, 43.5211065], [4.1357402, 43.5207188], [4.1350935, 43.5203936], [4.135002, 43.5204366], [4.1346051, 43.5202412], [4.134584, 43.5202472], [4.1345572, 43.5202551], [4.134356, 43.5203137], [4.1342488, 43.5203448], [4.134084, 43.5209193]]]] } }]) - post :save, params: {dossier_id: dossier.id, json_latlngs: json_latlngs} + post :save, params: { dossier_id: dossier.id, json_latlngs: json_latlngs } end context 'when json_latlngs params is empty' do @@ -172,7 +172,7 @@ shared_examples 'carte_controller_spec' do it { expect(subject.nom_com).to eq('Le Grau-du-Roi') } it { expect(subject.code_com).to eq('133') } it { expect(subject.code_arr).to eq('000') } - it { expect(subject.geometry).to eq({"type" => "MultiPolygon", "coordinates" => [[[[4.134084, 43.5209193], [4.1346615, 43.5212035], [4.1346984, 43.521189], [4.135096, 43.5213848], [4.1350839, 43.5214122], [4.1352697, 43.521505], [4.1356278, 43.5211065], [4.1357402, 43.5207188], [4.1350935, 43.5203936], [4.135002, 43.5204366], [4.1346051, 43.5202412], [4.134584, 43.5202472], [4.1345572, 43.5202551], [4.134356, 43.5203137], [4.1342488, 43.5203448], [4.134084, 43.5209193]]]]}) } + it { expect(subject.geometry).to eq({ "type" => "MultiPolygon", "coordinates" => [[[[4.134084, 43.5209193], [4.1346615, 43.5212035], [4.1346984, 43.521189], [4.135096, 43.5213848], [4.1350839, 43.5214122], [4.1352697, 43.521505], [4.1356278, 43.5211065], [4.1357402, 43.5207188], [4.1350935, 43.5203936], [4.135002, 43.5204366], [4.1346051, 43.5202412], [4.134584, 43.5202472], [4.1345572, 43.5202551], [4.134356, 43.5203137], [4.1342488, 43.5203448], [4.134084, 43.5209193]]]] }) } end end end @@ -185,7 +185,7 @@ shared_examples 'carte_controller_spec' do stub_request(:get, /http:\/\/api-adresse[.]data[.]gouv[.]fr\/search[?]limit=1&q=/) .to_return(status: 200, body: '{"query": "babouba", "version": "draft", "licence": "ODbL 1.0", "features": [], "type": "FeatureCollection", "attribution": "BAN"}', headers: {}) - get :get_position, params: {dossier_id: dossier.id} + get :get_position, params: { dossier_id: dossier.id } end subject { JSON.parse(response.body) } @@ -203,7 +203,7 @@ shared_examples 'carte_controller_spec' do before do stub_request(:get, /http:\/\/api-adresse[.]data[.]gouv[.]fr\/search[?]limit=1&q=/) .to_return(status: 200, body: '{"query": "babouba", "version": "draft", "licence": "ODbL 1.0", "features": [], "type": "FeatureCollection", "attribution": "BAN"}', headers: {}) - get :get_position, params: {dossier_id: dossier.id} + get :get_position, params: { dossier_id: dossier.id } end subject { JSON.parse(response.body) } @@ -219,7 +219,7 @@ shared_examples 'carte_controller_spec' do stub_request(:get, "http://api-adresse.data.gouv.fr/search?limit=1&q=#{adresse}") .to_return(status: 200, body: '{"query": "50 avenue des champs u00e9lysu00e9es Paris 75008", "version": "draft", "licence": "ODbL 1.0", "features": [{"geometry": {"coordinates": [2.306888, 48.870374], "type": "Point"}, "type": "Feature", "properties": {"city": "Paris", "label": "50 Avenue des Champs u00c9lysu00e9es 75008 Paris", "housenumber": "50", "id": "ADRNIVX_0000000270748251", "postcode": "75008", "name": "50 Avenue des Champs u00c9lysu00e9es", "citycode": "75108", "context": "75, u00cele-de-France", "score": 0.9054545454545454, "type": "housenumber"}}], "type": "FeatureCollection", "attribution": "BAN"}', headers: {}) - get :get_position, params: {dossier_id: dossier.id} + get :get_position, params: { dossier_id: dossier.id } end subject { JSON.parse(response.body) } @@ -245,9 +245,9 @@ shared_examples 'carte_controller_spec' do before do allow_any_instance_of(CARTO::SGMAP::QuartiersPrioritaires::Adapter) .to receive(:to_params) - .and_return({"QPCODE1234" => {:code => "QPCODE1234", :geometry => {:type => "MultiPolygon", :coordinates => [[[[2.38715792094576, 48.8723062632126], [2.38724851642619, 48.8721392348061]]]]}}}) + .and_return({ "QPCODE1234" => { :code => "QPCODE1234", :geometry => { :type => "MultiPolygon", :coordinates => [[[[2.38715792094576, 48.8723062632126], [2.38724851642619, 48.8721392348061]]]] } } }) - post :get_qp, params: {dossier_id: dossier.id, coordinates: coordinates} + post :get_qp, params: { dossier_id: dossier.id, coordinates: coordinates } end context 'when coordinates are empty' do diff --git a/spec/controllers/users/description_controller_spec.rb b/spec/controllers/users/description_controller_spec.rb index 4421f1f35..fef283d04 100644 --- a/spec/controllers/users/description_controller_spec.rb +++ b/spec/controllers/users/description_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' require 'controllers/users/description_controller_shared_example' -describe Users::DescriptionController, type: :controller, vcr: {cassette_name: 'controllers_users_description_controller'} do +describe Users::DescriptionController, type: :controller, vcr: { cassette_name: 'controllers_users_description_controller' } do let(:owner_user) { create(:user) } let(:invite_by_user) { create :user, email: 'invite@plop.com' } let(:archived_at) { nil } diff --git a/spec/controllers/users/dossiers/add_siret_controller_spec.rb b/spec/controllers/users/dossiers/add_siret_controller_spec.rb index 9452e3040..de449881c 100644 --- a/spec/controllers/users/dossiers/add_siret_controller_spec.rb +++ b/spec/controllers/users/dossiers/add_siret_controller_spec.rb @@ -8,7 +8,7 @@ describe Users::Dossiers::AddSiretController, type: :controller do sign_in dossier.user end - subject { get :show, params: {dossier_id: dossier.id } } + subject { get :show, params: { dossier_id: dossier.id } } context 'when dossier is not attached at a procedure with individual siret attribut' do it { is_expected.to redirect_to users_dossiers_path } diff --git a/spec/controllers/users/dossiers/commentaires_controller_spec.rb b/spec/controllers/users/dossiers/commentaires_controller_spec.rb index 2871486d9..00519c3e2 100644 --- a/spec/controllers/users/dossiers/commentaires_controller_spec.rb +++ b/spec/controllers/users/dossiers/commentaires_controller_spec.rb @@ -6,7 +6,7 @@ describe Users::Dossiers::CommentairesController, type: :controller do describe '#POST create' do subject { - post :create, params: {dossier_id: dossier.id, texte_commentaire: texte_commentaire} + post :create, params: { dossier_id: dossier.id, texte_commentaire: texte_commentaire } dossier.reload } diff --git a/spec/controllers/users/dossiers/invites_controller_spec.rb b/spec/controllers/users/dossiers/invites_controller_spec.rb index e80f94632..a02810436 100644 --- a/spec/controllers/users/dossiers/invites_controller_spec.rb +++ b/spec/controllers/users/dossiers/invites_controller_spec.rb @@ -6,7 +6,7 @@ describe Users::Dossiers::InvitesController, type: :controller do context 'when email is not set' do context 'when user is not connected' do before do - get :show, params: {id: invite.id} + get :show, params: { id: invite.id } end it { is_expected.to redirect_to new_user_session_path } @@ -18,7 +18,7 @@ describe Users::Dossiers::InvitesController, type: :controller do before do sign_in invite.user - get :show, params: {id: invite.id} + get :show, params: { id: invite.id } end it { expect(response.status).to eq 200 } @@ -27,7 +27,7 @@ describe Users::Dossiers::InvitesController, type: :controller do context 'when email is set' do before do - get :show, params: {id: invite.id, email: email} + get :show, params: { id: invite.id, email: email } end context 'when email is blank' do @@ -57,7 +57,7 @@ describe Users::Dossiers::InvitesController, type: :controller do let(:invite) { create :invite, email: email, dossier: (create :dossier) } - subject { get :show, params: {id: invite.id} } + subject { get :show, params: { id: invite.id } } before do sign_in user diff --git a/spec/controllers/users/dossiers_controller_spec.rb b/spec/controllers/users/dossiers_controller_spec.rb index 3b5865c60..6635d49d0 100644 --- a/spec/controllers/users/dossiers_controller_spec.rb +++ b/spec/controllers/users/dossiers_controller_spec.rb @@ -27,12 +27,12 @@ describe Users::DossiersController, type: :controller do sign_in dossier.user end it 'returns http success with dossier_id valid' do - get :show, params: {id: dossier_id} + get :show, params: { id: dossier_id } expect(response).to have_http_status(:success) end it 'redirection vers liste dossier si mauvais dossier ID' do - get :show, params: {id: siret_not_found} + get :show, params: { id: siret_not_found } expect(response).to redirect_to root_path end @@ -42,7 +42,7 @@ describe Users::DossiersController, type: :controller do dossier.state = 'en_instruction' dossier.save - get :show, params: {id: dossier.id} + get :show, params: { id: dossier.id } end it { is_expected.to redirect_to root_path } @@ -51,7 +51,7 @@ describe Users::DossiersController, type: :controller do end describe 'GET #new' do - subject { get :new, params: {procedure_id: procedure_id} } + subject { get :new, params: { procedure_id: procedure_id } } context 'when params procedure_id is present' do context 'when procedure_id is valid' do @@ -68,7 +68,7 @@ describe Users::DossiersController, type: :controller do describe 'save user siret' do context 'when user have not a saved siret' do context 'when siret is present on request' do - subject { get :new, params: {procedure_id: procedure_id, siret: siret} } + subject { get :new, params: { procedure_id: procedure_id, siret: siret } } before do subject @@ -96,7 +96,7 @@ describe Users::DossiersController, type: :controller do end context 'when siret is present on request' do - subject { get :new, params: {procedure_id: procedure_id, siret: siret} } + subject { get :new, params: { procedure_id: procedure_id, siret: siret } } before do subject @@ -203,7 +203,7 @@ describe Users::DossiersController, type: :controller do sign_in user end - subject { post :siret_informations, params: {dossier_id: dossier.id, dossier: {siret: example_siret}} } + subject { post :siret_informations, params: { dossier_id: dossier.id, dossier: { siret: example_siret } } } it 'create a dossier' do expect { subject }.to change { Dossier.count }.by(0) @@ -331,7 +331,7 @@ describe Users::DossiersController, type: :controller do end let(:siret_not_found) { '11111111111111' } - subject { post :siret_informations, params: {dossier_id: dossier.id, dossier: {siret: siret_not_found}} } + subject { post :siret_informations, params: { dossier_id: dossier.id, dossier: { siret: siret_not_found } } } it 'does not create new dossier' do expect { subject }.not_to change { Dossier.count } @@ -346,7 +346,7 @@ describe Users::DossiersController, type: :controller do context 'when REST error 400 is return' do let(:status_entreprise_call) { 400 } - subject { post :siret_informations, params: {dossier_id: dossier.id, dossier: {siret: siret}} } + subject { post :siret_informations, params: { dossier_id: dossier.id, dossier: { siret: siret } } } before do sign_in user @@ -437,7 +437,7 @@ describe Users::DossiersController, type: :controller do let!(:dossier_brouillon) { create :dossier, state: "brouillon", user: user } let!(:dossier_not_brouillon) { create :dossier, state: "en_construction", user: user } - subject { delete :destroy, params: {id: dossier.id} } + subject { delete :destroy, params: { id: dossier.id } } before do sign_in user @@ -474,7 +474,7 @@ describe Users::DossiersController, type: :controller do describe 'PUT #change_siret' do let(:dossier) { create(:dossier, :with_entreprise, user: user, procedure: procedure) } - subject { put :change_siret, params: {dossier_id: dossier.id} } + subject { put :change_siret, params: { dossier_id: dossier.id } } before do sign_in user @@ -495,7 +495,7 @@ describe Users::DossiersController, type: :controller do end it 'returns http success' do - get :index, params: {liste: :a_traiter} + get :index, params: { liste: :a_traiter } expect(response).to have_http_status(200) end end @@ -508,7 +508,7 @@ describe Users::DossiersController, type: :controller do end it 'returns http success' do - get :index, params: {liste: :en_instruction} + get :index, params: { liste: :en_instruction } expect(response).to have_http_status(200) end end @@ -521,7 +521,7 @@ describe Users::DossiersController, type: :controller do end it 'returns http success' do - get :index, params: {liste: :brouillon} + get :index, params: { liste: :brouillon } expect(response).to have_http_status(200) end end @@ -534,7 +534,7 @@ describe Users::DossiersController, type: :controller do end it 'returns http success' do - get :index, params: {liste: :termine} + get :index, params: { liste: :termine } expect(response).to have_http_status(200) end end @@ -547,7 +547,7 @@ describe Users::DossiersController, type: :controller do end it 'returns http success' do - get :index, params: {liste: :invite} + get :index, params: { liste: :invite } expect(response).to have_http_status(200) end end @@ -560,7 +560,7 @@ describe Users::DossiersController, type: :controller do end it 'returns http success' do - get :index, params: {liste: :list_fake} + get :index, params: { liste: :list_fake } expect(response).to redirect_to(users_dossiers_path) end end diff --git a/spec/controllers/users/recapitulatif_controller_spec.rb b/spec/controllers/users/recapitulatif_controller_spec.rb index d5c9c9490..f288504c9 100644 --- a/spec/controllers/users/recapitulatif_controller_spec.rb +++ b/spec/controllers/users/recapitulatif_controller_spec.rb @@ -10,12 +10,12 @@ describe Users::RecapitulatifController, type: :controller do describe 'GET #show' do it 'returns http success' do - get :show, params: {dossier_id: dossier.id} + get :show, params: { dossier_id: dossier.id } expect(response).to have_http_status(:success) end it 'redirection vers siret si mauvais dossier ID' do - get :show, params: {dossier_id: bad_dossier_id} + get :show, params: { dossier_id: bad_dossier_id } expect(response).to redirect_to('/') end @@ -27,7 +27,7 @@ describe Users::RecapitulatifController, type: :controller do dossier.state = 'brouillon' dossier.save - get :show, params: {dossier_id: dossier.id} + get :show, params: { dossier_id: dossier.id } end it { is_expected.to redirect_to root_path } @@ -38,7 +38,7 @@ describe Users::RecapitulatifController, type: :controller do describe 'POST #initiate' do context 'when an user initiate his dossier' do before do - post :initiate, params: {dossier_id: dossier.id} + post :initiate, params: { dossier_id: dossier.id } end it 'dossier change his state for accepte' do diff --git a/spec/controllers/users/sessions_controller_spec.rb b/spec/controllers/users/sessions_controller_spec.rb index 2263df65e..cb0daa0de 100644 --- a/spec/controllers/users/sessions_controller_spec.rb +++ b/spec/controllers/users/sessions_controller_spec.rb @@ -13,7 +13,7 @@ describe Users::SessionsController, type: :controller do describe 'France Connect attribut' do before do - post :create, params: {user: {email: user.email, password: user.password}} + post :create, params: { user: { email: user.email, password: user.password } } user.reload end @@ -31,7 +31,7 @@ describe Users::SessionsController, type: :controller do let(:administrateur) { create(:administrateur, email: email, password: password) } it 'signs user in' do - post :create, params: {user: {email: user.email, password: user.password}} + post :create, params: { user: { email: user.email, password: user.password } } expect(@response.redirect?).to be(true) expect(subject.current_user).to eq(user) expect(subject.current_gestionnaire).to be(nil) @@ -40,7 +40,7 @@ describe Users::SessionsController, type: :controller do end it 'signs gestionnaire in' do - post :create, params: {user: {email: gestionnaire.email, password: gestionnaire.password}} + post :create, params: { user: { email: gestionnaire.email, password: gestionnaire.password } } expect(@response.redirect?).to be(true) expect(subject.current_user).to be(nil) expect(subject.current_gestionnaire).to eq(gestionnaire) @@ -48,7 +48,7 @@ describe Users::SessionsController, type: :controller do end it 'signs administrateur in' do - post :create, params: {user: {email: administrateur.email, password: administrateur.password}} + post :create, params: { user: { email: administrateur.email, password: administrateur.password } } expect(@response.redirect?).to be(true) expect(subject.current_user).to be(nil) expect(subject.current_gestionnaire).to be(nil) @@ -62,7 +62,7 @@ describe Users::SessionsController, type: :controller do end it 'signs user + gestionnaire + administrateur in' do - post :create, params: {user: {email: administrateur.email, password: administrateur.password}} + post :create, params: { user: { email: administrateur.email, password: administrateur.password } } expect(@response.redirect?).to be(true) expect(subject.current_user).to eq(user) expect(subject.current_gestionnaire).to eq(gestionnaire) @@ -72,7 +72,7 @@ describe Users::SessionsController, type: :controller do } it 'fails to sign in with bad credentials' do - post :create, params: {user: {email: user.email, password: 'wrong_password'}} + post :create, params: { user: { email: user.email, password: 'wrong_password' } } expect(@response.unauthorized?).to be(true) expect(subject.current_user).to be(nil) expect(subject.current_gestionnaire).to be(nil) diff --git a/spec/features/users/dossier_creation_spec.rb b/spec/features/users/dossier_creation_spec.rb index bba22f26c..564f224f5 100644 --- a/spec/features/users/dossier_creation_spec.rb +++ b/spec/features/users/dossier_creation_spec.rb @@ -41,7 +41,7 @@ feature 'As a User I wanna create a dossier' do end end - scenario 'Identification through siret', vcr: {cassette_name: 'search_ban_paris'}, js: true do + scenario 'Identification through siret', vcr: { cassette_name: 'search_ban_paris' }, js: true do login_as user, scope: :user visit commencer_path(procedure_path: procedure_with_siret.path) expect(page).to have_current_path(users_dossier_path(procedure_with_siret.dossiers.last.id.to_s), only_path: true) diff --git a/spec/lib/carto/geo_api/driver_spec.rb b/spec/lib/carto/geo_api/driver_spec.rb index 4d13c15ca..dace760cd 100644 --- a/spec/lib/carto/geo_api/driver_spec.rb +++ b/spec/lib/carto/geo_api/driver_spec.rb @@ -1,13 +1,13 @@ require 'spec_helper' describe Carto::GeoAPI::Driver do - describe '.regions', vcr: {cassette_name: 'geoapi_regions'} do + describe '.regions', vcr: { cassette_name: 'geoapi_regions' } do subject { described_class.regions } it { expect(subject.code).to eq 200 } end - describe '.departements', vcr: {cassette_name: 'geoapi_departements'} do + describe '.departements', vcr: { cassette_name: 'geoapi_departements' } do subject { described_class.departements } it { expect(subject.code).to eq 200 } diff --git a/spec/lib/carto/sgmap/api_spec.rb b/spec/lib/carto/sgmap/api_spec.rb index 1a541d1cc..d84f62cea 100644 --- a/spec/lib/carto/sgmap/api_spec.rb +++ b/spec/lib/carto/sgmap/api_spec.rb @@ -7,7 +7,7 @@ describe CARTO::SGMAP::API do before do stub_request(:post, "https://apicarto.sgmap.fr/quartiers-prioritaires/search") .with(:body => /.*/, - :headers => {'Content-Type' => 'application/json'}) + :headers => { 'Content-Type' => 'application/json' }) .to_return(status: status, body: body) end context 'when geojson is empty' do @@ -55,7 +55,7 @@ describe CARTO::SGMAP::API do before do stub_request(:post, "https://apicarto.sgmap.fr/cadastre/geometrie") .with(:body => /.*/, - :headers => {'Content-Type' => 'application/json'}) + :headers => { 'Content-Type' => 'application/json' }) .to_return(status: status, body: body) end context 'when geojson is empty' do diff --git a/spec/lib/carto/sgmap/cadastre/adapter_spec.rb b/spec/lib/carto/sgmap/cadastre/adapter_spec.rb index 46b11e1b1..c061eec44 100644 --- a/spec/lib/carto/sgmap/cadastre/adapter_spec.rb +++ b/spec/lib/carto/sgmap/cadastre/adapter_spec.rb @@ -6,7 +6,7 @@ describe CARTO::SGMAP::Cadastre::Adapter do before do stub_request(:post, "https://apicarto.sgmap.fr/cadastre/geometrie") .with(:body => /.*/, - :headers => {'Content-Type' => 'application/json'}) + :headers => { 'Content-Type' => 'application/json' }) .to_return(status: status, body: body) end @@ -51,7 +51,7 @@ describe CARTO::SGMAP::Cadastre::Adapter do it { expect(subject[:code_com]).to eq('046') } it { expect(subject[:code_arr]).to eq('000') } - it { expect(subject[:geometry]).to eq({type: "MultiPolygon", coordinates: [[[[2.4362443, 48.8092078], [2.436384, 48.8092043], [2.4363802, 48.8091414]]]]}) } + it { expect(subject[:geometry]).to eq({ type: "MultiPolygon", coordinates: [[[[2.4362443, 48.8092078], [2.436384, 48.8092043], [2.4363802, 48.8091414]]]] }) } end end diff --git a/spec/lib/carto/sgmap/quartiers_prioritaires/adapter_spec.rb b/spec/lib/carto/sgmap/quartiers_prioritaires/adapter_spec.rb index 1458acb06..43f028759 100644 --- a/spec/lib/carto/sgmap/quartiers_prioritaires/adapter_spec.rb +++ b/spec/lib/carto/sgmap/quartiers_prioritaires/adapter_spec.rb @@ -6,7 +6,7 @@ describe CARTO::SGMAP::QuartiersPrioritaires::Adapter do before do stub_request(:post, "https://apicarto.sgmap.fr/quartiers-prioritaires/search") .with(:body => /.*/, - :headers => {'Content-Type' => 'application/json'}) + :headers => { 'Content-Type' => 'application/json' }) .to_return(status: status, body: body) end @@ -26,7 +26,7 @@ describe CARTO::SGMAP::QuartiersPrioritaires::Adapter do it { expect(subject[:nom]).to eq('Hauts De Vallières') } it { expect(subject[:commune]).to eq('Metz') } - it { expect(subject[:geometry]).to eq({:type => "MultiPolygon", :coordinates => [[[[6.2136923480551, 49.1342109827851], [6.21416055031881, 49.1338823553928]]]]}) } + it { expect(subject[:geometry]).to eq({ :type => "MultiPolygon", :coordinates => [[[[6.2136923480551, 49.1342109827851], [6.21416055031881, 49.1338823553928]]]] }) } end end diff --git a/spec/models/champ_shared_example.rb b/spec/models/champ_shared_example.rb index 9dc5586ac..c8bb4360e 100644 --- a/spec/models/champ_shared_example.rb +++ b/spec/models/champ_shared_example.rb @@ -48,7 +48,7 @@ shared_examples 'champ_spec' do end end - describe '.departement', vcr: {cassette_name: 'call_geo_api_departements'} do + describe '.departement', vcr: { cassette_name: 'call_geo_api_departements' } do subject { Champ.departements } it { expect(subject).to include '99 - Étranger' } diff --git a/spec/models/dossier_spec.rb b/spec/models/dossier_spec.rb index 2c4ac0202..5f8f32820 100644 --- a/spec/models/dossier_spec.rb +++ b/spec/models/dossier_spec.rb @@ -51,7 +51,7 @@ describe Dossier do end end - describe '#retrieve_last_piece_justificative_by_type', vcr: {cassette_name: 'models_dossier_retrieve_last_piece_justificative_by_type'} do + describe '#retrieve_last_piece_justificative_by_type', vcr: { cassette_name: 'models_dossier_retrieve_last_piece_justificative_by_type' } do let(:types_de_pj_dossier) { dossier.procedure.types_de_piece_justificative } subject { dossier.retrieve_last_piece_justificative_by_type types_de_pj_dossier.first } diff --git a/spec/models/gestionnaire_spec.rb b/spec/models/gestionnaire_spec.rb index b1e877137..e300ffe6c 100644 --- a/spec/models/gestionnaire_spec.rb +++ b/spec/models/gestionnaire_spec.rb @@ -338,7 +338,7 @@ describe Gestionnaire, type: :model do context 'when a followed dossier has unread notification' do let(:followed_dossier) { dossier_with_no_unread_notification } - it { is_expected.to eq({ }) } + it { is_expected.to eq({}) } end end diff --git a/spec/models/procedure_presentation_spec.rb b/spec/models/procedure_presentation_spec.rb index 21c8a6a9e..4d018ec23 100644 --- a/spec/models/procedure_presentation_spec.rb +++ b/spec/models/procedure_presentation_spec.rb @@ -14,7 +14,7 @@ describe ProcedurePresentation do let (:procedure_presentation) { ProcedurePresentation.find(procedure_presentation_id) } describe "#displayed_fields" do - it { expect(procedure_presentation.displayed_fields).to eq([{"label" => "test1", "table" => "user"}, {"label" => "test2", "table" => "champs"}]) } + it { expect(procedure_presentation.displayed_fields).to eq([{ "label" => "test1", "table" => "user" }, { "label" => "test2", "table" => "champs" }]) } end describe "#sort" do diff --git a/spec/services/france_connect_service_spec.rb b/spec/services/france_connect_service_spec.rb index c3c1f70b4..96b2a633b 100644 --- a/spec/services/france_connect_service_spec.rb +++ b/spec/services/france_connect_service_spec.rb @@ -14,7 +14,7 @@ describe FranceConnectService do let(:phone) { '012345678' } let(:france_connect_particulier_id) { 'izhikziogjuziegj' } - let(:user_info_hash) { {sub: france_connect_particulier_id, given_name: given_name, family_name: family_name, birthdate: birthdate, gender: gender, birthplace: birthplace, email: email, phone: phone} } + let(:user_info_hash) { { sub: france_connect_particulier_id, given_name: given_name, family_name: family_name, birthdate: birthdate, gender: gender, birthplace: birthplace, email: email, phone: phone } } let(:user_info) { instance_double('OpenIDConnect::ResponseObject::UserInfo', raw_attributes: user_info_hash) } subject { described_class.retrieve_user_informations_particulier code } diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 96d04f492..4960225b8 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -123,7 +123,7 @@ RSpec.configure do |config| if Features.remote_storage VCR.use_cassette("ovh_storage_init") do CarrierWave.configure do |config| - config.fog_credentials = {provider: 'OpenStack'} + config.fog_credentials = { provider: 'OpenStack' } end end end diff --git a/spec/support/shared_exemples_for_dossier.rb b/spec/support/shared_exemples_for_dossier.rb index 308aa2b83..a985e6aed 100644 --- a/spec/support/shared_exemples_for_dossier.rb +++ b/spec/support/shared_exemples_for_dossier.rb @@ -4,7 +4,7 @@ RSpec.shared_examples 'not owner of dossier' do |controller, redirect| let(:dossier_2) { create(:dossier) } before do - get controller, params: {dossier_id: dossier_2.id} + get controller, params: { dossier_id: dossier_2.id } end it 'redirect to home page' do diff --git a/spec/views/users/description/champs/_departements.html.haml_spec.rb b/spec/views/users/description/champs/_departements.html.haml_spec.rb index d0d6d4fa1..8ca65c223 100644 --- a/spec/views/users/description/champs/_departements.html.haml_spec.rb +++ b/spec/views/users/description/champs/_departements.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'users/description/champs/departements.html.haml', vcr: {cassette_name: 'geoapi_departements'}, type: :view do +describe 'users/description/champs/departements.html.haml', vcr: { cassette_name: 'geoapi_departements' }, type: :view do let(:champ) { create(:champ) } before do diff --git a/spec/views/users/description/champs/_regions.html.haml_spec.rb b/spec/views/users/description/champs/_regions.html.haml_spec.rb index 95e9fdef8..bc627ddff 100644 --- a/spec/views/users/description/champs/_regions.html.haml_spec.rb +++ b/spec/views/users/description/champs/_regions.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'users/description/champs/regions.html.haml', vcr: {cassette_name: 'geoapi_regions'}, type: :view do +describe 'users/description/champs/regions.html.haml', vcr: { cassette_name: 'geoapi_regions' }, type: :view do let(:champ) { create(:champ) } before do From d30ea70c0895253d764ef005969ba875b81414fc Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 15 Jan 2018 22:10:46 +0100 Subject: [PATCH 18/24] Enable the Layout/SpaceInsideParens cop --- .rubocop.yml | 2 +- app/models/procedure.rb | 4 ++-- spec/controllers/stats_controller_spec.rb | 2 +- spec/features/users/dossier_edition_spec.rb | 2 +- spec/helpers/dossier_link_helper_spec.rb | 4 ++-- spec/jobs/auto_archive_procedure_job_spec.rb | 8 ++++---- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index f4d827a1d..b7f7268ef 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -216,7 +216,7 @@ Layout/SpaceInsideArrayLiteralBrackets: Enabled: false Layout/SpaceInsideParens: - Enabled: false + Enabled: true Layout/SpaceInsidePercentLiteralDelimiters: Enabled: false diff --git a/app/models/procedure.rb b/app/models/procedure.rb index 7ca38294b..0d81f0a3a 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -220,14 +220,14 @@ class Procedure < ActiveRecord::Base end types_de_champ - .reject { |tdc| ['header_section', 'explication'].include?(tdc.type_champ ) } + .reject { |tdc| ['header_section', 'explication'].include?(tdc.type_champ) } .each do |type_de_champ| fields << field_hash(type_de_champ.libelle, 'type_de_champ', type_de_champ.id.to_s) end types_de_champ_private - .reject { |tdc| ['header_section', 'explication'].include?(tdc.type_champ ) } + .reject { |tdc| ['header_section', 'explication'].include?(tdc.type_champ) } .each do |type_de_champ| fields << field_hash(type_de_champ.libelle, 'type_de_champ_private', type_de_champ.id.to_s) diff --git a/spec/controllers/stats_controller_spec.rb b/spec/controllers/stats_controller_spec.rb index 74e912e49..625b56133 100644 --- a/spec/controllers/stats_controller_spec.rb +++ b/spec/controllers/stats_controller_spec.rb @@ -298,7 +298,7 @@ describe StatsController, type: :controller do end describe '#motivation_usage_procedure' do - let!(:dossier) { create(:dossier, processed_at: 1.week.ago, motivation: "Motivation" ) } + let!(:dossier) { create(:dossier, processed_at: 1.week.ago, motivation: "Motivation") } let!(:dossier1) { create(:dossier, processed_at: 1.week.ago, motivation: "Motivation", procedure: dossier.procedure) } let!(:dossier2) { create(:dossier, processed_at: 1.week.ago) } let!(:dossier3) { create(:dossier, processed_at: 1.week.ago) } diff --git a/spec/features/users/dossier_edition_spec.rb b/spec/features/users/dossier_edition_spec.rb index 32c972110..86d7f1708 100644 --- a/spec/features/users/dossier_edition_spec.rb +++ b/spec/features/users/dossier_edition_spec.rb @@ -12,7 +12,7 @@ feature 'As a User I want to edit a dossier I own' do context 'After sign_in, I can navigate through dossiers indexes and edit a dossier' do scenario 'After sign_in, I can see dossiers "à traiter" (default), and other indexes' do - expect(page.find('#a_traiter')['class'] ).to eq('active procedure-list-element') + expect(page.find('#a_traiter')['class']).to eq('active procedure-list-element') page.find_by_id('brouillon').click page.find_by_id('a_traiter').click page.find_by_id('en_instruction').click diff --git a/spec/helpers/dossier_link_helper_spec.rb b/spec/helpers/dossier_link_helper_spec.rb index 5613c5207..504524d5f 100644 --- a/spec/helpers/dossier_link_helper_spec.rb +++ b/spec/helpers/dossier_link_helper_spec.rb @@ -8,7 +8,7 @@ describe DossierLinkHelper do end context "when access as gestionnaire" do - let(:dossier) { create(:dossier ) } + let(:dossier) { create(:dossier) } let(:gestionnaire) { create(:gestionnaire) } before { dossier.procedure.gestionnaires << gestionnaire } @@ -17,7 +17,7 @@ describe DossierLinkHelper do end context "when access as expert" do - let(:dossier) { create(:dossier ) } + let(:dossier) { create(:dossier) } let(:gestionnaire) { create(:gestionnaire) } let!(:avis) { create(:avis, dossier: dossier, gestionnaire: gestionnaire) } diff --git a/spec/jobs/auto_archive_procedure_job_spec.rb b/spec/jobs/auto_archive_procedure_job_spec.rb index 9d44f68e8..2f92e5f2f 100644 --- a/spec/jobs/auto_archive_procedure_job_spec.rb +++ b/spec/jobs/auto_archive_procedure_job_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' RSpec.describe AutoArchiveProcedureJob, type: :job do - let!(:procedure) { create(:procedure, published_at: Time.now, archived_at: nil, auto_archive_on: nil ) } - let!(:procedure_hier) { create(:procedure, published_at: Time.now, archived_at: nil, auto_archive_on: 1.day.ago ) } - let!(:procedure_aujourdhui) { create(:procedure, published_at: Time.now, archived_at: nil, auto_archive_on: Date.today ) } - let!(:procedure_demain) { create(:procedure, published_at: Time.now, archived_at: nil, auto_archive_on: 1.day.from_now ) } + let!(:procedure) { create(:procedure, published_at: Time.now, archived_at: nil, auto_archive_on: nil) } + let!(:procedure_hier) { create(:procedure, published_at: Time.now, archived_at: nil, auto_archive_on: 1.day.ago) } + let!(:procedure_aujourdhui) { create(:procedure, published_at: Time.now, archived_at: nil, auto_archive_on: Date.today) } + let!(:procedure_demain) { create(:procedure, published_at: Time.now, archived_at: nil, auto_archive_on: 1.day.from_now) } subject { AutoArchiveProcedureJob.new.perform } From 89a75240b05021f32ca5eaf0cdb89e8e700e6c68 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 15 Jan 2018 22:11:18 +0100 Subject: [PATCH 19/24] Layout/SpaceInsidePercentLiteralDelimiters --- .rubocop.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index b7f7268ef..9604af135 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -219,7 +219,7 @@ Layout/SpaceInsideParens: Enabled: true Layout/SpaceInsidePercentLiteralDelimiters: - Enabled: false + Enabled: true Layout/SpaceInsideRangeLiteral: Enabled: false From a98ec10b908c5cde77b7802f9f537c4423a9e026 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 15 Jan 2018 22:11:37 +0100 Subject: [PATCH 20/24] Enable the Layout/SpaceInsideRangeLiteral cop --- .rubocop.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index 9604af135..c6db80d18 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -222,7 +222,7 @@ Layout/SpaceInsidePercentLiteralDelimiters: Enabled: true Layout/SpaceInsideRangeLiteral: - Enabled: false + Enabled: true Layout/SpaceInsideStringInterpolation: Enabled: false From 75868ff84b03e71ffbde6afd7a807af97babfb44 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 15 Jan 2018 22:12:00 +0100 Subject: [PATCH 21/24] Enable the Layout/SpaceInsideStringInterpolation cop --- .rubocop.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index c6db80d18..65cda8d30 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -225,7 +225,7 @@ Layout/SpaceInsideRangeLiteral: Enabled: true Layout/SpaceInsideStringInterpolation: - Enabled: false + Enabled: true Layout/Tab: Enabled: false From 6428aa023dc79909c1d1ce762c543bce4a6cfdf0 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 15 Jan 2018 22:12:58 +0100 Subject: [PATCH 22/24] Enable the Layout/Tab cop --- .rubocop.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index 65cda8d30..1fe97fbf2 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -228,7 +228,7 @@ Layout/SpaceInsideStringInterpolation: Enabled: true Layout/Tab: - Enabled: false + Enabled: true Layout/TrailingBlankLines: Enabled: false From 2df14691e7c3532c8a7a358eef544704f41fc8f5 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 15 Jan 2018 22:13:29 +0100 Subject: [PATCH 23/24] Enable the Layout/TrailingBlankLines cop --- .rubocop.yml | 2 +- .../new_gestionnaire/gestionnaire_controller_spec.rb | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 1fe97fbf2..afdf8f6f4 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -231,7 +231,7 @@ Layout/Tab: Enabled: true Layout/TrailingBlankLines: - Enabled: false + Enabled: true Layout/TrailingWhitespace: Enabled: false diff --git a/spec/controllers/new_gestionnaire/gestionnaire_controller_spec.rb b/spec/controllers/new_gestionnaire/gestionnaire_controller_spec.rb index 2159b983d..83c189582 100644 --- a/spec/controllers/new_gestionnaire/gestionnaire_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/gestionnaire_controller_spec.rb @@ -12,4 +12,3 @@ describe NewGestionnaire::GestionnaireController, type: :controller do end end end - From 813844f9dbed0eb6f45f35cd30876369dc129a3d Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 15 Jan 2018 22:13:52 +0100 Subject: [PATCH 24/24] Enable the Layout/TrailingWhitespace cop --- .rubocop.yml | 2 +- app/models/administrateur.rb | 4 ++-- app/models/administration.rb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index afdf8f6f4..fa0601957 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -234,7 +234,7 @@ Layout/TrailingBlankLines: Enabled: true Layout/TrailingWhitespace: - Enabled: false + Enabled: true Lint/AmbiguousBlockAssociation: Enabled: false diff --git a/app/models/administrateur.rb b/app/models/administrateur.rb index 18ad7e7ae..7048cb473 100644 --- a/app/models/administrateur.rb +++ b/app/models/administrateur.rb @@ -43,9 +43,9 @@ class Administrateur < ActiveRecord::Base if active? raise "Impossible d'inviter un utilisateur déjà actif !" end - + reset_password_token = set_reset_password_token - + AdministrationMailer.invite_admin(self, reset_password_token).deliver_now! reset_password_token diff --git a/app/models/administration.rb b/app/models/administration.rb index a2e3b56fa..b9805b3cc 100644 --- a/app/models/administration.rb +++ b/app/models/administration.rb @@ -10,7 +10,7 @@ class Administration < ActiveRecord::Base def invite_admin(email) administrateur = Administrateur.new({ email: email, - active: false + active: false }) administrateur.password = administrateur.password_confirmation = SecureRandom.hex