diff --git a/.rubocop.yml b/.rubocop.yml index d356d2312..10c9c3ced 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -24,6 +24,9 @@ Layout/AlignParameters: Enabled: true EnforcedStyle: with_fixed_indentation +Layout/BlockAlignment: + Enabled: false + Layout/BlockEndNewline: Enabled: true @@ -37,6 +40,12 @@ Layout/ClosingParenthesisIndentation: Layout/CommentIndentation: Enabled: true +Layout/ConditionPosition: + Enabled: false + +Layout/DefEndAlignment: + Enabled: false + Layout/DotPosition: Enabled: true @@ -73,6 +82,10 @@ Layout/EmptyLinesAroundMethodBody: Layout/EmptyLinesAroundModuleBody: Enabled: true +Layout/EndAlignment: + Enabled: true + EnforcedStyleAlignWith: variable + Layout/EndOfLine: Enabled: true EnforcedStyle: lf @@ -248,21 +261,12 @@ 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 @@ -293,10 +297,6 @@ Lint/EmptyInterpolation: Lint/EmptyWhen: Enabled: false -Lint/EndAlignment: - Enabled: true - EnforcedStyleAlignWith: variable - Lint/EndInMethod: Enabled: false @@ -480,12 +480,18 @@ 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 @@ -522,9 +528,6 @@ Performance/FixedSize: Performance/FlatMap: Enabled: true -Performance/HashEachMethods: - Enabled: false - Performance/LstripRstrip: Enabled: true @@ -1080,7 +1083,10 @@ Style/TernaryParentheses: Style/TrailingCommaInArguments: Enabled: false -Style/TrailingCommaInLiteral: +Style/TrailingCommaInArrayLiteral: + Enabled: false + +Style/TrailingCommaInHashLiteral: Enabled: false Style/TrailingUnderscoreVariable: diff --git a/Gemfile.lock b/Gemfile.lock index 839f36379..c61a5d107 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.1.1) + brakeman (4.2.0) 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.1) + parser (2.5.0.3) 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.52.1) + rubocop (0.53.0) parallel (~> 1.10) - parser (>= 2.4.0.2, < 3.0) + parser (>= 2.5) 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.56.0) + scss_lint (0.57.0) rake (>= 0.9, < 13) - sass (~> 3.5.3) + sass (~> 3.5.5) securecompare (1.0.0) select2-rails (4.0.3) thor (~> 0.14) diff --git a/Rakefile b/Rakefile index bdb67ab62..186e5b1ed 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', __FILE__) +require File.expand_path('config/application', __dir__) Rails.application.load_tasks diff --git a/app/controllers/admin/attestation_templates_controller.rb b/app/controllers/admin/attestation_templates_controller.rb index 10fdb2994..0cdff87c5 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_attributes(activated_attestation_params) + if attestation_template.update(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 7ec106986..3ef952fae 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_attributes(update_params) + mail_template.update(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 0f6d14987..99012c304 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_attributes(update_params) + if @procedure.update(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 85801ee28..511024182 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_attributes(procedure_params) + if !@procedure.update(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 b05c52fdd..256e06220 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_attributes(TypesDeChampService.create_update_procedure_params params) + @procedure.update(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 a4cea0946..320e0064e 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_attributes(TypesDeChampService.create_update_procedure_params params, true) + @procedure.update(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 9e1257063..814f3c4ba 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_attributes(avis_params) + avis.update(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 f1a130b41..c91e0d2b5 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_attributes(archived: true) + dossier.update(archived: true) current_gestionnaire.unfollow(dossier) redirect_back(fallback_location: gestionnaire_procedures_url) end def unarchive - dossier.update_attributes(archived: false) + dossier.update(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_attributes(champs_private_params) + dossier.update(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 7b4d958a6..a7b557d54 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_attributes(displayed_fields: fields) + procedure_presentation.update(displayed_fields: fields) current_sort = procedure_presentation.sort if !values.include?("#{current_sort['table']}/#{current_sort['column']}") - procedure_presentation.update_attributes(sort: Procedure.default_sort) + procedure_presentation.update(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_attributes(sort: sort) + procedure_presentation.update(sort: sort) redirect_back(fallback_location: gestionnaire_procedure_url(procedure)) end @@ -154,7 +154,7 @@ module NewGestionnaire 'value' => params[:value] } - procedure_presentation.update_attributes(filters: filters.to_json) + procedure_presentation.update(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_attributes(filters: filters.to_json) + procedure_presentation.update(filters: filters.to_json) redirect_back(fallback_location: gestionnaire_procedure_url(procedure)) end @@ -245,7 +245,6 @@ 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 8ef350893..f41d55bf2 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_attributes(json_latlngs: params[:json_latlngs]) + dossier.update(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 121693b89..7af0fc9e0 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_attributes update_params_with_formatted_birthdate + if !Dossier.find(@facade.dossier.id).update 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_attributes(siret: siret) + current_user.update(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 b2b6f3391..0ac64ed65 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_attributes(loged_in_with_france_connect: '') + current_user.update(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_attributes(loged_in_with_france_connect: '') + current_user.update(loged_in_with_france_connect: '') sign_out :user diff --git a/app/models/administrateur.rb b/app/models/administrateur.rb index 7048cb473..f1f2e379b 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_attributes(api_token: generate_api_token) + update(api_token: generate_api_token) end def registration_state diff --git a/app/models/procedure.rb b/app/models/procedure.rb index 5441fbc3d..e750d7a21 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_attributes(hidden_at: now) + self.update(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_attributes(order_place: index_of_first_element + 1) - list[index_of_first_element + 1].update_attributes(order_place: index_of_first_element) + 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) true end @@ -129,7 +129,7 @@ class Procedure < ActiveRecord::Base end def publish!(path) - self.update_attributes!({ published_at: Time.now, archived_at: nil }) + self.update!({ 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_attributes!(archived_at: Time.now) + self.update!(archived_at: Time.now) end def archivee? diff --git a/app/models/user.rb b/app/models/user.rb index 16d5edca6..362eba6b7 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_attributes(siret: siret) + user.update(siret: siret) user end end diff --git a/bin/bundle b/bin/bundle index 66e9889e8..f19acf5b5 100755 --- a/bin/bundle +++ b/bin/bundle @@ -1,3 +1,3 @@ #!/usr/bin/env ruby -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) load Gem.bin_path('bundler', 'bundle') diff --git a/bin/setup b/bin/setup index 468646cd1..04e288aec 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('../../', __FILE__) +APP_ROOT = Pathname.new File.expand_path('../', __dir__) def system!(*args) system(*args) || abort("\n== Command #{args} failed ==") diff --git a/bin/update b/bin/update index a8e4462f2..f02dfd611 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('../../', __FILE__) +APP_ROOT = Pathname.new File.expand_path('../', __dir__) def system!(*args) system(*args) || abort("\n== Command #{args} failed ==") diff --git a/config/application.rb b/config/application.rb index 1d381b4b1..7d54fd628 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,4 +1,4 @@ -require File.expand_path('../boot', __FILE__) +require File.expand_path('boot', __dir__) require 'rails/all' diff --git a/config/boot.rb b/config/boot.rb index 6b750f00b..30f5120df 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,3 +1,3 @@ -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) require 'bundler/setup' # Set up gems listed in the Gemfile. diff --git a/config/environment.rb b/config/environment.rb index ee8d90dc6..0b8bdd828 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,5 +1,5 @@ # Load the Rails application. -require File.expand_path('../application', __FILE__) +require File.expand_path('application', __dir__) # 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 db9d9289a..e1392c812 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_attributes(formulaire_id: forms.id) if forms.present? + # type_piece_jointe.update(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 88f7f1128..2178c02eb 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_attributes({ + User.find(fci.user_id).update({ 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 ed545032e..6939e477e 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_attributes).and_return(false) + expect_any_instance_of(AttestationTemplate).to receive(:update).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 f32dbaf68..2e6c47bfd 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_attributes(user: signed_in_profile) + dossier.update(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 c6338051f..6f8c67cb4 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_attributes(archived: true) + dossier.update(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 68c68a9b1..2557d79ec 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_attributes(for_individual: true) } + before { dossier.procedure.update(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_attributes(mandatory: true, libelle: 'l') + first_champ.type_de_champ.update(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 cb0daa0de..2f581ec7f 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_attributes(loged_in_with_france_connect: 'particulier') + user.update(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 332142f19..dcbc3481c 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_attributes(value: "Mon champ rempli") + champ.update(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 6fb94c9fc..5b5b1160a 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_attributes(email: 'whoami@plop.com', password: 'super secret') + administrateur.update(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_attributes(email: 'whoami@plop.com', password: 'super secret') + administrateur.update(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 680c72ef2..1cd889aa5 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_attributes(value: 'libelle1') + .update(value: 'libelle1') dossier.champs .select { |champ| champ.libelle == 'libelleB' } .first - .update_attributes(value: 'libelle2') + .update(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 42cc2bd44..7a2d2e52e 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_attributes(value: 'libelle1') + .update(value: 'libelle1') dossier.champs .select { |champ| champ.libelle == 'libelleB' } .first - .update_attributes(value: 'libelle2') + .update(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_attributes(value: 'libelle1') } + before { dossier.champs_private.first.update(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_attributes(value: 'libelle1') } + before { dossier.champs.first.update(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_attributes(value: '2017-04-15') + .update(value: '2017-04-15') dossier.champs .select { |champ| champ.type_champ == 'datetime' } .first - .update_attributes(value: '2017-09-13 09:00') + .update(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_attributes(value: 'valeur') } + before { dossier.champs.first.update(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 4dc9e35f0..47bcd0a16 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_attributes(state: 'en_construction') + subject.update(state: 'en_construction') end end end diff --git a/spec/models/gestionnaire_spec.rb b/spec/models/gestionnaire_spec.rb index 5f94afe50..9d13d1042 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_attributes(email: 'whoami@plop.com', password: 'super secret') + gestionnaire.update(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_attributes(email: 'whoami@plop.com', password: 'super secret') + gestionnaire.update(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 827205514..4cd13e70f 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_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") + 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") dossier2.build_default_champs - 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") + 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") 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 58bd78bc2..848909a51 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_attributes(email: 'whoami@plop.com', password: 'super secret') + user.update(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_attributes(email: 'whoami@plop.com', password: 'super secret') + user.update(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 59725df09..da5f1b49d 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', __FILE__) +require File.expand_path('../config/environment', __dir__) 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 266047f62..a0583ada3 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', __FILE__) +require File.expand_path('../config/environment', __dir__) 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 73830217c..a28649fe1 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_attributes(date_publication: nil) } + before { rna_information.update(date_publication: nil) } it "can render without error" do expect(rendered).to include("Date de publication :")