From fe7f8da636682181f6af196da65a3060f2f65c8b Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Tue, 6 Mar 2018 15:11:26 +0100 Subject: [PATCH] Revert "Bump development gems" This reverts commit d6ad3fc3fd3a1dc6026bad0f8bdd6bd2296ef639. --- .rubocop.yml | 40 ++++++++----------- Gemfile.lock | 12 +++--- Rakefile | 2 +- .../admin/attestation_templates_controller.rb | 2 +- .../admin/mail_templates_controller.rb | 2 +- .../admin/pieces_justificatives_controller.rb | 2 +- .../admin/procedures_controller.rb | 2 +- .../admin/types_de_champ_controller.rb | 2 +- .../types_de_champ_private_controller.rb | 2 +- .../new_gestionnaire/avis_controller.rb | 2 +- .../new_gestionnaire/dossiers_controller.rb | 6 +-- .../new_gestionnaire/procedures_controller.rb | 11 ++--- app/controllers/users/carte_controller.rb | 2 +- app/controllers/users/dossiers_controller.rb | 4 +- app/controllers/users/sessions_controller.rb | 4 +- app/models/administrateur.rb | 2 +- app/models/procedure.rb | 10 ++--- app/models/user.rb | 2 +- bin/bundle | 2 +- bin/setup | 2 +- bin/update | 2 +- config/application.rb | 2 +- config/boot.rb | 2 +- config/environment.rb | 2 +- ...08_link_type_piece_jointe_to_formulaire.rb | 2 +- ...94750_create_france_connect_information.rb | 2 +- .../attestation_templates_controller_spec.rb | 2 +- spec/controllers/invites_controller_spec.rb | 2 +- .../dossiers_controller_spec.rb | 2 +- .../new_user/dossiers_controller_spec.rb | 4 +- .../users/sessions_controller_spec.rb | 2 +- .../procedure_filters_spec.rb | 2 +- spec/models/administrateur_spec.rb | 4 +- spec/models/attestation_template_spec.rb | 4 +- .../concern/tags_substitution_concern_spec.rb | 14 +++---- spec/models/dossier_spec.rb | 2 +- spec/models/gestionnaire_spec.rb | 4 +- spec/models/procedure_spec.rb | 16 ++++---- spec/models/user_spec.rb | 4 +- spec/rails_helper.rb | 2 +- spec/spec_helper.rb | 2 +- .../_identite_entreprise.html.haml_spec.rb | 2 +- 42 files changed, 94 insertions(+), 99 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 10c9c3ced..d356d2312 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -24,9 +24,6 @@ Layout/AlignParameters: Enabled: true EnforcedStyle: with_fixed_indentation -Layout/BlockAlignment: - Enabled: false - Layout/BlockEndNewline: Enabled: true @@ -40,12 +37,6 @@ Layout/ClosingParenthesisIndentation: Layout/CommentIndentation: Enabled: true -Layout/ConditionPosition: - Enabled: false - -Layout/DefEndAlignment: - Enabled: false - Layout/DotPosition: Enabled: true @@ -82,10 +73,6 @@ Layout/EmptyLinesAroundMethodBody: Layout/EmptyLinesAroundModuleBody: Enabled: true -Layout/EndAlignment: - Enabled: true - EnforcedStyleAlignWith: variable - Layout/EndOfLine: Enabled: true EnforcedStyle: lf @@ -261,12 +248,21 @@ Lint/AmbiguousRegexpLiteral: Lint/AssignmentInCondition: Enabled: false +Lint/BlockAlignment: + Enabled: false + Lint/CircularArgumentReference: Enabled: false +Lint/ConditionPosition: + Enabled: false + Lint/Debugger: Enabled: false +Lint/DefEndAlignment: + Enabled: false + Lint/DeprecatedClassMethods: Enabled: false @@ -297,6 +293,10 @@ Lint/EmptyInterpolation: Lint/EmptyWhen: Enabled: false +Lint/EndAlignment: + Enabled: true + EnforcedStyleAlignWith: variable + Lint/EndInMethod: Enabled: false @@ -480,18 +480,12 @@ Naming/FileName: Naming/HeredocDelimiterNaming: Enabled: false -Naming/MemoizedInstanceVariableName: - Enabled: false - Naming/MethodName: Enabled: false Naming/PredicateName: Enabled: false -Naming/UncommunicativeMethodParamName: - Enabled: false - Naming/VariableName: Enabled: false @@ -528,6 +522,9 @@ Performance/FixedSize: Performance/FlatMap: Enabled: true +Performance/HashEachMethods: + Enabled: false + Performance/LstripRstrip: Enabled: true @@ -1083,10 +1080,7 @@ Style/TernaryParentheses: Style/TrailingCommaInArguments: Enabled: false -Style/TrailingCommaInArrayLiteral: - Enabled: false - -Style/TrailingCommaInHashLiteral: +Style/TrailingCommaInLiteral: Enabled: false Style/TrailingUnderscoreVariable: diff --git a/Gemfile.lock b/Gemfile.lock index c61a5d107..839f36379 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -115,7 +115,7 @@ GEM sass (>= 3.3.4) bootstrap-wysihtml5-rails (0.3.3.8) railties (>= 3.0) - brakeman (4.2.0) + brakeman (4.1.1) browser (2.5.3) builder (3.2.3) byebug (10.0.0) @@ -527,7 +527,7 @@ GEM json orm_adapter (0.5.0) parallel (1.12.1) - parser (2.5.0.3) + parser (2.5.0.1) ast (~> 2.4.0) pdf-core (0.7.0) pg (0.19.0) @@ -642,9 +642,9 @@ GEM rspec-support (3.7.1) rspec_junit_formatter (0.3.0) rspec-core (>= 2, < 4, != 2.12.0) - rubocop (0.53.0) + rubocop (0.52.1) parallel (~> 1.10) - parser (>= 2.5) + parser (>= 2.4.0.2, < 3.0) powerpack (~> 0.1) rainbow (>= 2.2.2, < 4.0) ruby-progressbar (~> 1.7) @@ -672,9 +672,9 @@ GEM scenic (1.4.1) activerecord (>= 4.0.0) railties (>= 4.0.0) - scss_lint (0.57.0) + scss_lint (0.56.0) rake (>= 0.9, < 13) - sass (~> 3.5.5) + sass (~> 3.5.3) securecompare (1.0.0) select2-rails (4.0.3) thor (~> 0.14) diff --git a/Rakefile b/Rakefile index 186e5b1ed..bdb67ab62 100644 --- a/Rakefile +++ b/Rakefile @@ -1,7 +1,7 @@ # Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. -require File.expand_path('config/application', __dir__) +require File.expand_path('../config/application', __FILE__) Rails.application.load_tasks diff --git a/app/controllers/admin/attestation_templates_controller.rb b/app/controllers/admin/attestation_templates_controller.rb index 0cdff87c5..10fdb2994 100644 --- a/app/controllers/admin/attestation_templates_controller.rb +++ b/app/controllers/admin/attestation_templates_controller.rb @@ -8,7 +8,7 @@ class Admin::AttestationTemplatesController < AdminController def update attestation_template = @procedure.attestation_template - if attestation_template.update(activated_attestation_params) + if attestation_template.update_attributes(activated_attestation_params) flash.notice = "L'attestation a bien été modifiée" else flash.alert = attestation_template.errors.full_messages.join('
') diff --git a/app/controllers/admin/mail_templates_controller.rb b/app/controllers/admin/mail_templates_controller.rb index 3ef952fae..7ec106986 100644 --- a/app/controllers/admin/mail_templates_controller.rb +++ b/app/controllers/admin/mail_templates_controller.rb @@ -11,7 +11,7 @@ class Admin::MailTemplatesController < AdminController def update mail_template = find_mail_template_by_slug(params[:id]) - mail_template.update(update_params) + mail_template.update_attributes(update_params) redirect_to admin_procedure_mail_templates_path end diff --git a/app/controllers/admin/pieces_justificatives_controller.rb b/app/controllers/admin/pieces_justificatives_controller.rb index 99012c304..0f6d14987 100644 --- a/app/controllers/admin/pieces_justificatives_controller.rb +++ b/app/controllers/admin/pieces_justificatives_controller.rb @@ -6,7 +6,7 @@ class Admin::PiecesJustificativesController < AdminController end def update - if @procedure.update(update_params) + if @procedure.update_attributes(update_params) flash.now.notice = 'Modifications sauvegardées' else flash.now.notice = 'Une erreur est survenue' diff --git a/app/controllers/admin/procedures_controller.rb b/app/controllers/admin/procedures_controller.rb index 511024182..85801ee28 100644 --- a/app/controllers/admin/procedures_controller.rb +++ b/app/controllers/admin/procedures_controller.rb @@ -105,7 +105,7 @@ class Admin::ProceduresController < AdminController def update @procedure = current_administrateur.procedures.find(params[:id]) - if !@procedure.update(procedure_params) + if !@procedure.update_attributes(procedure_params) flash.now.alert = @procedure.errors.full_messages return render 'edit' end diff --git a/app/controllers/admin/types_de_champ_controller.rb b/app/controllers/admin/types_de_champ_controller.rb index 256e06220..b05c52fdd 100644 --- a/app/controllers/admin/types_de_champ_controller.rb +++ b/app/controllers/admin/types_de_champ_controller.rb @@ -15,7 +15,7 @@ class Admin::TypesDeChampController < AdminController end def update - @procedure.update(TypesDeChampService.create_update_procedure_params params) + @procedure.update_attributes(TypesDeChampService.create_update_procedure_params params) create_facade flash.now.notice = 'Modifications sauvegardées' render 'show', format: :js diff --git a/app/controllers/admin/types_de_champ_private_controller.rb b/app/controllers/admin/types_de_champ_private_controller.rb index 320e0064e..a4cea0946 100644 --- a/app/controllers/admin/types_de_champ_private_controller.rb +++ b/app/controllers/admin/types_de_champ_private_controller.rb @@ -16,7 +16,7 @@ class Admin::TypesDeChampPrivateController < AdminController end def update - @procedure.update(TypesDeChampService.create_update_procedure_params params, true) + @procedure.update_attributes(TypesDeChampService.create_update_procedure_params params, true) create_facade flash.now.notice = 'Modifications sauvegardées' render 'admin/types_de_champ/show', format: :js diff --git a/app/controllers/new_gestionnaire/avis_controller.rb b/app/controllers/new_gestionnaire/avis_controller.rb index 814f3c4ba..9e1257063 100644 --- a/app/controllers/new_gestionnaire/avis_controller.rb +++ b/app/controllers/new_gestionnaire/avis_controller.rb @@ -32,7 +32,7 @@ module NewGestionnaire end def update - avis.update(avis_params) + avis.update_attributes(avis_params) flash.notice = 'Votre réponse est enregistrée.' redirect_to instruction_gestionnaire_avis_path(avis) end diff --git a/app/controllers/new_gestionnaire/dossiers_controller.rb b/app/controllers/new_gestionnaire/dossiers_controller.rb index c91e0d2b5..f1a130b41 100644 --- a/app/controllers/new_gestionnaire/dossiers_controller.rb +++ b/app/controllers/new_gestionnaire/dossiers_controller.rb @@ -57,13 +57,13 @@ module NewGestionnaire end def archive - dossier.update(archived: true) + dossier.update_attributes(archived: true) current_gestionnaire.unfollow(dossier) redirect_back(fallback_location: gestionnaire_procedures_url) end def unarchive - dossier.update(archived: false) + dossier.update_attributes(archived: false) redirect_back(fallback_location: gestionnaire_procedures_url) end @@ -166,7 +166,7 @@ module NewGestionnaire def update_annotations dossier = current_gestionnaire.dossiers.includes(champs_private: :type_de_champ).find(params[:dossier_id]) # FIXME: add attachements validation, cf. Champ#piece_justificative_file_errors - dossier.update(champs_private_params) + dossier.update_attributes(champs_private_params) redirect_to annotations_privees_gestionnaire_dossier_path(procedure, dossier) end diff --git a/app/controllers/new_gestionnaire/procedures_controller.rb b/app/controllers/new_gestionnaire/procedures_controller.rb index a7b557d54..7b4d958a6 100644 --- a/app/controllers/new_gestionnaire/procedures_controller.rb +++ b/app/controllers/new_gestionnaire/procedures_controller.rb @@ -109,11 +109,11 @@ module NewGestionnaire c.to_json end - procedure_presentation.update(displayed_fields: fields) + procedure_presentation.update_attributes(displayed_fields: fields) current_sort = procedure_presentation.sort if !values.include?("#{current_sort['table']}/#{current_sort['column']}") - procedure_presentation.update(sort: Procedure.default_sort) + procedure_presentation.update_attributes(sort: Procedure.default_sort) end redirect_back(fallback_location: gestionnaire_procedure_url(procedure)) @@ -136,7 +136,7 @@ module NewGestionnaire 'order' => order }.to_json - procedure_presentation.update(sort: sort) + procedure_presentation.update_attributes(sort: sort) redirect_back(fallback_location: gestionnaire_procedure_url(procedure)) end @@ -154,7 +154,7 @@ module NewGestionnaire 'value' => params[:value] } - procedure_presentation.update(filters: filters.to_json) + procedure_presentation.update_attributes(filters: filters.to_json) end redirect_back(fallback_location: gestionnaire_procedure_url(procedure)) @@ -168,7 +168,7 @@ module NewGestionnaire filters[statut] = filters[statut] - [filter_to_remove] - procedure_presentation.update(filters: filters.to_json) + procedure_presentation.update_attributes(filters: filters.to_json) redirect_back(fallback_location: gestionnaire_procedure_url(procedure)) end @@ -245,6 +245,7 @@ module NewGestionnaire .includes(filter['table']) .where("#{filter['table'].pluralize}.#{filter['column']} LIKE ?", "%#{filter['value']}%") end + end.pluck(:id) end.reduce(:&) end diff --git a/app/controllers/users/carte_controller.rb b/app/controllers/users/carte_controller.rb index f41d55bf2..8ef350893 100644 --- a/app/controllers/users/carte_controller.rb +++ b/app/controllers/users/carte_controller.rb @@ -22,7 +22,7 @@ class Users::CarteController < UsersController ModuleApiCartoService.save_cadastre! dossier, params[:json_latlngs] end - dossier.update(json_latlngs: params[:json_latlngs]) + dossier.update_attributes(json_latlngs: params[:json_latlngs]) redirect_to modifier_dossier_path(dossier) end diff --git a/app/controllers/users/dossiers_controller.rb b/app/controllers/users/dossiers_controller.rb index 7af0fc9e0..121693b89 100644 --- a/app/controllers/users/dossiers_controller.rb +++ b/app/controllers/users/dossiers_controller.rb @@ -156,7 +156,7 @@ class Users::DossiersController < UsersController flash.alert = individual_errors redirect_to users_dossier_path(id: @facade.dossier.id) else - if !Dossier.find(@facade.dossier.id).update update_params_with_formatted_birthdate + if !Dossier.find(@facade.dossier.id).update_attributes update_params_with_formatted_birthdate flash.alert = @facade.dossier.errors.full_messages return redirect_to users_dossier_path(id: @facade.dossier.id) @@ -259,7 +259,7 @@ class Users::DossiersController < UsersController end def update_current_user_siret! siret - current_user.update(siret: siret) + current_user.update_attributes(siret: siret) end def facade id = params[:id] diff --git a/app/controllers/users/sessions_controller.rb b/app/controllers/users/sessions_controller.rb index 0ac64ed65..b2b6f3391 100644 --- a/app/controllers/users/sessions_controller.rb +++ b/app/controllers/users/sessions_controller.rb @@ -20,7 +20,7 @@ class Users::SessionsController < Sessions::SessionsController try_to_authenticate(Administrateur, remember_me) if user_signed_in? - current_user.update(loged_in_with_france_connect: '') + current_user.update_attributes(loged_in_with_france_connect: '') end if user_signed_in? @@ -44,7 +44,7 @@ class Users::SessionsController < Sessions::SessionsController if user_signed_in? connected_with_france_connect = current_user.loged_in_with_france_connect - current_user.update(loged_in_with_france_connect: '') + current_user.update_attributes(loged_in_with_france_connect: '') sign_out :user diff --git a/app/models/administrateur.rb b/app/models/administrateur.rb index f1f2e379b..7048cb473 100644 --- a/app/models/administrateur.rb +++ b/app/models/administrateur.rb @@ -26,7 +26,7 @@ class Administrateur < ActiveRecord::Base end def renew_api_token - update(api_token: generate_api_token) + update_attributes(api_token: generate_api_token) end def registration_state diff --git a/app/models/procedure.rb b/app/models/procedure.rb index e750d7a21..5441fbc3d 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -42,7 +42,7 @@ class Procedure < ActiveRecord::Base def hide! now = DateTime.now - self.update(hidden_at: now) + self.update_attributes(hidden_at: now) self.dossiers.update_all(hidden_at: now) end @@ -89,8 +89,8 @@ class Procedure < ActiveRecord::Base false else - list[index_of_first_element].update(order_place: index_of_first_element + 1) - list[index_of_first_element + 1].update(order_place: index_of_first_element) + list[index_of_first_element].update_attributes(order_place: index_of_first_element + 1) + list[index_of_first_element + 1].update_attributes(order_place: index_of_first_element) true end @@ -129,7 +129,7 @@ class Procedure < ActiveRecord::Base end def publish!(path) - self.update!({ published_at: Time.now, archived_at: nil }) + self.update_attributes!({ published_at: Time.now, archived_at: nil }) ProcedurePath.create!(path: path, procedure: self, administrateur: self.administrateur) end @@ -138,7 +138,7 @@ class Procedure < ActiveRecord::Base end def archive - self.update!(archived_at: Time.now) + self.update_attributes!(archived_at: Time.now) end def archivee? diff --git a/app/models/user.rb b/app/models/user.rb index 362eba6b7..16d5edca6 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -25,7 +25,7 @@ class User < ActiveRecord::Base if user.nil? return User.create(email: email, password: Devise.friendly_token[0, 20], siret: siret) else - user.update(siret: siret) + user.update_attributes(siret: siret) user end end diff --git a/bin/bundle b/bin/bundle index f19acf5b5..66e9889e8 100755 --- a/bin/bundle +++ b/bin/bundle @@ -1,3 +1,3 @@ #!/usr/bin/env ruby -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) load Gem.bin_path('bundler', 'bundle') diff --git a/bin/setup b/bin/setup index 04e288aec..468646cd1 100755 --- a/bin/setup +++ b/bin/setup @@ -4,7 +4,7 @@ require 'fileutils' include FileUtils # path to your application root. -APP_ROOT = Pathname.new File.expand_path('../', __dir__) +APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) def system!(*args) system(*args) || abort("\n== Command #{args} failed ==") diff --git a/bin/update b/bin/update index f02dfd611..a8e4462f2 100755 --- a/bin/update +++ b/bin/update @@ -4,7 +4,7 @@ require 'fileutils' include FileUtils # path to your application root. -APP_ROOT = Pathname.new File.expand_path('../', __dir__) +APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) def system!(*args) system(*args) || abort("\n== Command #{args} failed ==") diff --git a/config/application.rb b/config/application.rb index 7d54fd628..1d381b4b1 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,4 +1,4 @@ -require File.expand_path('boot', __dir__) +require File.expand_path('../boot', __FILE__) require 'rails/all' diff --git a/config/boot.rb b/config/boot.rb index 30f5120df..6b750f00b 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,3 +1,3 @@ -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) require 'bundler/setup' # Set up gems listed in the Gemfile. diff --git a/config/environment.rb b/config/environment.rb index 0b8bdd828..ee8d90dc6 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,5 +1,5 @@ # Load the Rails application. -require File.expand_path('application', __dir__) +require File.expand_path('../application', __FILE__) # Initialize the Rails application. Rails.application.initialize! diff --git a/db/migrate/20150814122208_link_type_piece_jointe_to_formulaire.rb b/db/migrate/20150814122208_link_type_piece_jointe_to_formulaire.rb index e1392c812..db9d9289a 100644 --- a/db/migrate/20150814122208_link_type_piece_jointe_to_formulaire.rb +++ b/db/migrate/20150814122208_link_type_piece_jointe_to_formulaire.rb @@ -2,7 +2,7 @@ class LinkTypePieceJointeToFormulaire < ActiveRecord::Migration # def up # TypePieceJointe.find_each do |type_piece_jointe| # forms = Formulaire.find_by_demarche_id(type_piece_jointe.CERFA) - # type_piece_jointe.update(formulaire_id: forms.id) if forms.present? + # type_piece_jointe.update_attributes(formulaire_id: forms.id) if forms.present? # end # end end diff --git a/db/migrate/20160120094750_create_france_connect_information.rb b/db/migrate/20160120094750_create_france_connect_information.rb index 2178c02eb..88f7f1128 100644 --- a/db/migrate/20160120094750_create_france_connect_information.rb +++ b/db/migrate/20160120094750_create_france_connect_information.rb @@ -46,7 +46,7 @@ class CreateFranceConnectInformation < ActiveRecord::Migration add_column :users, :france_connect_particulier_id, :string FranceConnectInformation.all.each do |fci| - User.find(fci.user_id).update({ + User.find(fci.user_id).update_attributes({ gender: fci.gender, given_name: fci.given_name, family_name: fci.family_name, diff --git a/spec/controllers/admin/attestation_templates_controller_spec.rb b/spec/controllers/admin/attestation_templates_controller_spec.rb index 6939e477e..ed545032e 100644 --- a/spec/controllers/admin/attestation_templates_controller_spec.rb +++ b/spec/controllers/admin/attestation_templates_controller_spec.rb @@ -140,7 +140,7 @@ describe Admin::AttestationTemplatesController, type: :controller do context 'when something wrong happens in the attestation template creation' do before do - expect_any_instance_of(AttestationTemplate).to receive(:update).and_return(false) + expect_any_instance_of(AttestationTemplate).to receive(:update_attributes).and_return(false) expect_any_instance_of(AttestationTemplate).to receive(:errors) .and_return(double(full_messages: ['nop'])) diff --git a/spec/controllers/invites_controller_spec.rb b/spec/controllers/invites_controller_spec.rb index 2e6c47bfd..f32dbaf68 100644 --- a/spec/controllers/invites_controller_spec.rb +++ b/spec/controllers/invites_controller_spec.rb @@ -145,7 +145,7 @@ describe InvitesController, type: :controller do context 'when user has access to dossier' do before do - dossier.update(user: signed_in_profile) + dossier.update_attributes(user: signed_in_profile) end it { expect { subject }.to change(InviteUser, :count).by(1) } diff --git a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb index 6f8c67cb4..c6338051f 100644 --- a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb @@ -94,7 +94,7 @@ describe NewGestionnaire::DossiersController, type: :controller do describe '#unarchive' do before do - dossier.update(archived: true) + dossier.update_attributes(archived: true) patch :unarchive, params: { procedure_id: procedure.id, dossier_id: dossier.id } dossier.reload end diff --git a/spec/controllers/new_user/dossiers_controller_spec.rb b/spec/controllers/new_user/dossiers_controller_spec.rb index 2557d79ec..68c68a9b1 100644 --- a/spec/controllers/new_user/dossiers_controller_spec.rb +++ b/spec/controllers/new_user/dossiers_controller_spec.rb @@ -122,7 +122,7 @@ describe NewUser::DossiersController, type: :controller do end context 'when the dossier is for an personne physique' do - before { dossier.procedure.update(for_individual: true) } + before { dossier.procedure.update_attributes(for_individual: true) } it { is_expected.to redirect_to(identite_dossier_path(dossier)) } end @@ -215,7 +215,7 @@ describe NewUser::DossiersController, type: :controller do let(:value) { nil } before do - first_champ.type_de_champ.update(mandatory: true, libelle: 'l') + first_champ.type_de_champ.update_attributes(mandatory: true, libelle: 'l') allow(PiecesJustificativesService).to receive(:missing_pj_error_messages).and_return(['pj']) subject diff --git a/spec/controllers/users/sessions_controller_spec.rb b/spec/controllers/users/sessions_controller_spec.rb index 2f581ec7f..cb0daa0de 100644 --- a/spec/controllers/users/sessions_controller_spec.rb +++ b/spec/controllers/users/sessions_controller_spec.rb @@ -158,7 +158,7 @@ describe Users::SessionsController, type: :controller do end it 'signs user out from france connect' do - user.update(loged_in_with_france_connect: 'particulier') + user.update_attributes(loged_in_with_france_connect: 'particulier') sign_in user delete :destroy expect(@response.headers["Location"]).to eq(FRANCE_CONNECT[:particulier][:logout_endpoint]) diff --git a/spec/features/new_gestionnaire/procedure_filters_spec.rb b/spec/features/new_gestionnaire/procedure_filters_spec.rb index dcbc3481c..332142f19 100644 --- a/spec/features/new_gestionnaire/procedure_filters_spec.rb +++ b/spec/features/new_gestionnaire/procedure_filters_spec.rb @@ -9,7 +9,7 @@ feature "procedure filters" do let!(:new_unfollow_dossier_2) { create(:dossier, procedure: procedure, state: "en_instruction") } before do - champ.update(value: "Mon champ rempli") + champ.update_attributes(value: "Mon champ rempli") login_as gestionnaire, scope: :gestionnaire visit gestionnaire_procedure_path(procedure) end diff --git a/spec/models/administrateur_spec.rb b/spec/models/administrateur_spec.rb index 5b5b1160a..6fb94c9fc 100644 --- a/spec/models/administrateur_spec.rb +++ b/spec/models/administrateur_spec.rb @@ -32,7 +32,7 @@ describe Administrateur, type: :model do administrateur = create(:administrateur) user = create(:user, email: administrateur.email) - administrateur.update(email: 'whoami@plop.com', password: 'super secret') + administrateur.update_attributes(email: 'whoami@plop.com', password: 'super secret') user.reload expect(user.email).to eq('whoami@plop.com') @@ -43,7 +43,7 @@ describe Administrateur, type: :model do administrateur = create(:administrateur) gestionnaire = create(:gestionnaire, email: administrateur.email) - administrateur.update(email: 'whoami@plop.com', password: 'super secret') + administrateur.update_attributes(email: 'whoami@plop.com', password: 'super secret') gestionnaire.reload expect(gestionnaire.email).to eq('whoami@plop.com') diff --git a/spec/models/attestation_template_spec.rb b/spec/models/attestation_template_spec.rb index 1cd889aa5..680c72ef2 100644 --- a/spec/models/attestation_template_spec.rb +++ b/spec/models/attestation_template_spec.rb @@ -163,12 +163,12 @@ describe AttestationTemplate, type: :model do dossier.champs .select { |champ| champ.libelle == 'libelleA' } .first - .update(value: 'libelle1') + .update_attributes(value: 'libelle1') dossier.champs .select { |champ| champ.libelle == 'libelleB' } .first - .update(value: 'libelle2') + .update_attributes(value: 'libelle2') end it { expect(view_args[:title]).to eq('title libelle1') } diff --git a/spec/models/concern/tags_substitution_concern_spec.rb b/spec/models/concern/tags_substitution_concern_spec.rb index 7a2d2e52e..42cc2bd44 100644 --- a/spec/models/concern/tags_substitution_concern_spec.rb +++ b/spec/models/concern/tags_substitution_concern_spec.rb @@ -99,12 +99,12 @@ describe TagsSubstitutionConcern, type: :model do dossier.champs .select { |champ| champ.libelle == 'libelleA' } .first - .update(value: 'libelle1') + .update_attributes(value: 'libelle1') dossier.champs .select { |champ| champ.libelle == 'libelleB' } .first - .update(value: 'libelle2') + .update_attributes(value: 'libelle2') end it { is_expected.to eq('libelle1 libelle2') } @@ -129,7 +129,7 @@ describe TagsSubstitutionConcern, type: :model do let(:template) { '--libelleA--' } context 'and its value in the dossier is not nil' do - before { dossier.champs_private.first.update(value: 'libelle1') } + before { dossier.champs_private.first.update_attributes(value: 'libelle1') } it { is_expected.to eq('libelle1') } end @@ -152,7 +152,7 @@ describe TagsSubstitutionConcern, type: :model do context 'champs publics are valid tags' do let(:types_de_champ) { [create(:type_de_champ, libelle: 'libelleA')] } - before { dossier.champs.first.update(value: 'libelle1') } + before { dossier.champs.first.update_attributes(value: 'libelle1') } it { is_expected.to eq('libelle1') } end @@ -174,12 +174,12 @@ describe TagsSubstitutionConcern, type: :model do dossier.champs .select { |champ| champ.type_champ == 'date' } .first - .update(value: '2017-04-15') + .update_attributes(value: '2017-04-15') dossier.champs .select { |champ| champ.type_champ == 'datetime' } .first - .update(value: '2017-09-13 09:00') + .update_attributes(value: '2017-09-13 09:00') end it { is_expected.to eq('15/04/2017 2017-09-13 09:00') } @@ -220,7 +220,7 @@ describe TagsSubstitutionConcern, type: :model do end context "match breaking and non breaking spaces" do - before { dossier.champs.first.update(value: 'valeur') } + before { dossier.champs.first.update_attributes(value: 'valeur') } shared_examples "treat all kinds of space as equivalent" do context 'and the champ has a non breaking space' do diff --git a/spec/models/dossier_spec.rb b/spec/models/dossier_spec.rb index 47bcd0a16..4dc9e35f0 100644 --- a/spec/models/dossier_spec.rb +++ b/spec/models/dossier_spec.rb @@ -112,7 +112,7 @@ describe Dossier do it 'does not create default champs' do expect(subject).not_to receive(:build_default_champs) - subject.update(state: 'en_construction') + subject.update_attributes(state: 'en_construction') end end end diff --git a/spec/models/gestionnaire_spec.rb b/spec/models/gestionnaire_spec.rb index 9d13d1042..5f94afe50 100644 --- a/spec/models/gestionnaire_spec.rb +++ b/spec/models/gestionnaire_spec.rb @@ -116,7 +116,7 @@ describe Gestionnaire, type: :model do gestionnaire = create(:gestionnaire) user = create(:user, email: gestionnaire.email) - gestionnaire.update(email: 'whoami@plop.com', password: 'super secret') + gestionnaire.update_attributes(email: 'whoami@plop.com', password: 'super secret') user.reload expect(user.email).to eq('whoami@plop.com') @@ -127,7 +127,7 @@ describe Gestionnaire, type: :model do gestionnaire = create(:gestionnaire) admin = create(:administrateur, email: gestionnaire.email) - gestionnaire.update(email: 'whoami@plop.com', password: 'super secret') + gestionnaire.update_attributes(email: 'whoami@plop.com', password: 'super secret') admin.reload expect(admin.email).to eq('whoami@plop.com') diff --git a/spec/models/procedure_spec.rb b/spec/models/procedure_spec.rb index 4cd13e70f..827205514 100644 --- a/spec/models/procedure_spec.rb +++ b/spec/models/procedure_spec.rb @@ -352,16 +352,16 @@ describe Procedure do procedure.types_de_champ_private << tcp_2 << tcp_1 dossier.build_default_champs - dossier.champs.find_by(type_de_champ: tc_1).update(value: "value 1") - dossier.champs.find_by(type_de_champ: tc_2).update(value: "value 2") - dossier.champs_private.find_by(type_de_champ: tcp_1).update(value: "private value 1") - dossier.champs_private.find_by(type_de_champ: tcp_2).update(value: "private value 2") + dossier.champs.find_by(type_de_champ: tc_1).update_attributes(value: "value 1") + dossier.champs.find_by(type_de_champ: tc_2).update_attributes(value: "value 2") + dossier.champs_private.find_by(type_de_champ: tcp_1).update_attributes(value: "private value 1") + dossier.champs_private.find_by(type_de_champ: tcp_2).update_attributes(value: "private value 2") dossier2.build_default_champs - dossier2.champs.find_by(type_de_champ: tc_1).update(value: "value 1") - dossier2.champs.find_by(type_de_champ: tc_2).update(value: "value 2") - dossier2.champs_private.find_by(type_de_champ: tcp_1).update(value: "private value 1") - dossier2.champs_private.find_by(type_de_champ: tcp_2).update(value: "private value 2") + dossier2.champs.find_by(type_de_champ: tc_1).update_attributes(value: "value 1") + dossier2.champs.find_by(type_de_champ: tc_2).update_attributes(value: "value 2") + dossier2.champs_private.find_by(type_de_champ: tcp_1).update_attributes(value: "private value 1") + dossier2.champs_private.find_by(type_de_champ: tcp_2).update_attributes(value: "private value 2") end it { expect(subject[:headers].index(tc_1.libelle.parameterize.underscore.to_sym)).to be < subject[:headers].index(tc_2.libelle.parameterize.underscore.to_sym) } diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 848909a51..58bd78bc2 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -55,7 +55,7 @@ describe User, type: :model do user = create(:user) gestionnaire = create(:gestionnaire, email: user.email) - user.update(email: 'whoami@plop.com', password: 'super secret') + user.update_attributes(email: 'whoami@plop.com', password: 'super secret') gestionnaire.reload expect(gestionnaire.email).to eq('whoami@plop.com') @@ -66,7 +66,7 @@ describe User, type: :model do user = create(:user) admin = create(:administrateur, email: user.email) - user.update(email: 'whoami@plop.com', password: 'super secret') + user.update_attributes(email: 'whoami@plop.com', password: 'super secret') admin.reload expect(admin.email).to eq('whoami@plop.com') diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index da5f1b49d..59725df09 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -1,7 +1,7 @@ # This file is copied to spec/ when you run 'rails generate rspec:install' ENV['RAILS_ENV'] ||= 'test' require 'spec_helper' -require File.expand_path('../config/environment', __dir__) +require File.expand_path('../../config/environment', __FILE__) require 'rspec/rails' # Add additional requires below this line. Rails is not loaded until this point! diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index a0583ada3..266047f62 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -19,7 +19,7 @@ ENV['RAILS_ENV'] ||= 'test' -require File.expand_path('../config/environment', __dir__) +require File.expand_path('../../config/environment', __FILE__) require 'rspec/rails' require 'capybara/rspec' require 'database_cleaner' diff --git a/spec/views/new_gestionnaire/dossiers/_identite_entreprise.html.haml_spec.rb b/spec/views/new_gestionnaire/dossiers/_identite_entreprise.html.haml_spec.rb index a28649fe1..73830217c 100644 --- a/spec/views/new_gestionnaire/dossiers/_identite_entreprise.html.haml_spec.rb +++ b/spec/views/new_gestionnaire/dossiers/_identite_entreprise.html.haml_spec.rb @@ -6,7 +6,7 @@ describe 'new_gestionnaire/dossiers/identite_entreprise.html.haml', type: :view let(:entreprise) { rna_information.entreprise } context "date_publication is missing on rna" do - before { rna_information.update(date_publication: nil) } + before { rna_information.update_attributes(date_publication: nil) } it "can render without error" do expect(rendered).to include("Date de publication :")