From 5791206a454937a609e562d0d2175482bf896402 Mon Sep 17 00:00:00 2001 From: Xavier J Date: Mon, 19 Dec 2016 14:27:50 +0100 Subject: [PATCH 1/5] Delete old code --- app/services/france_connect_service.rb | 8 -------- 1 file changed, 8 deletions(-) diff --git a/app/services/france_connect_service.rb b/app/services/france_connect_service.rb index 0e8b398eb..883169e70 100644 --- a/app/services/france_connect_service.rb +++ b/app/services/france_connect_service.rb @@ -1,12 +1,4 @@ class FranceConnectService - def self.retrieve_user_informations_entreprise code - client = FranceConnectEntrepriseClient.new code: code - - access_token = client.access_token!(client_auth_method: :secret) - user_info = access_token.userinfo! - Hashie::Mash.new user_info.raw_attributes - end - def self.retrieve_user_informations_particulier code client = FranceConnectParticulierClient.new code: code From 2fccbbf4f04c9c06f413acfb0eeb86f1e91ee757 Mon Sep 17 00:00:00 2001 From: Xavier J Date: Mon, 19 Dec 2016 15:08:00 +0100 Subject: [PATCH 2/5] Delete un-use code --- Gemfile | 4 ++-- Gemfile.lock | 6 ------ app/controllers/users/description_controller.rb | 10 +++++----- config/routes.rb | 2 +- .../users/description_controller_shared_example.rb | 2 ++ 5 files changed, 10 insertions(+), 14 deletions(-) diff --git a/Gemfile b/Gemfile index 2acbdef98..bb142816d 100644 --- a/Gemfile +++ b/Gemfile @@ -127,8 +127,8 @@ group :development, :test do gem 'pry-byebug' # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring - gem 'spring' - gem 'spring-commands-rspec' + # gem 'spring' + # gem 'spring-commands-rspec' gem 'rspec-rails', '~> 3.0' gem 'railroady' diff --git a/Gemfile.lock b/Gemfile.lock index e70af9a9f..3d8969e9e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -551,10 +551,6 @@ GEM spreadsheet_architect (1.4.8) axlsx (>= 2.0) rodf (= 0.3.7) - spring (2.0.0) - activesupport (>= 4.2) - spring-commands-rspec (1.0.4) - spring (>= 0.9.1) sprockets (3.7.0) concurrent-ruby (~> 1.0) rack (> 1, < 3) @@ -687,8 +683,6 @@ DEPENDENCIES simplecov smart_listing spreadsheet_architect - spring - spring-commands-rspec therubyracer timecop turbolinks (~> 2.5) diff --git a/app/controllers/users/description_controller.rb b/app/controllers/users/description_controller.rb index d7791e8f2..215973c72 100644 --- a/app/controllers/users/description_controller.rb +++ b/app/controllers/users/description_controller.rb @@ -22,11 +22,11 @@ class Users::DescriptionController < UsersController redirect_to url_for(root_path) end - def error - show - flash.now.alert = 'Un ou plusieurs attributs obligatoires sont manquants ou incorrects.' - render 'show' - end + # def error + # show + # flash.now.alert = 'Un ou plusieurs attributs obligatoires sont manquants ou incorrects.' + # render 'show' + # end def create @dossier = current_user_dossier diff --git a/config/routes.rb b/config/routes.rb index d9daff608..58d2811dc 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -65,7 +65,7 @@ Rails.application.routes.draw do get '/add_siret' => 'dossiers/add_siret#show' get '/description' => 'description#show' - get '/description/error' => 'description#error' + # get '/description/error' => 'description#error' post 'description' => 'description#create' patch 'pieces_justificatives' => 'description#pieces_justificatives' diff --git a/spec/controllers/users/description_controller_shared_example.rb b/spec/controllers/users/description_controller_shared_example.rb index 765e7a894..a751f08e2 100644 --- a/spec/controllers/users/description_controller_shared_example.rb +++ b/spec/controllers/users/description_controller_shared_example.rb @@ -27,6 +27,8 @@ shared_examples 'description_controller_spec' do it 'redirection vers start si mauvais dossier ID' do get :show, params: {dossier_id: bad_dossier_id} + + expect(flash[:alert]).to be_present expect(response).to redirect_to(root_path) end From d7569f3cb28ef469570e3478ab8d4119540d3fb3 Mon Sep 17 00:00:00 2001 From: Xavier J Date: Mon, 19 Dec 2016 15:43:55 +0100 Subject: [PATCH 3/5] Add tests for file size validator --- spec/lib/file_size_validator_spec.rb | 48 ++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 spec/lib/file_size_validator_spec.rb diff --git a/spec/lib/file_size_validator_spec.rb b/spec/lib/file_size_validator_spec.rb new file mode 100644 index 000000000..aafde89c2 --- /dev/null +++ b/spec/lib/file_size_validator_spec.rb @@ -0,0 +1,48 @@ +require 'spec_helper' + +describe FileSizeValidator, lib: true do + let(:validator) { FileSizeValidator.new(options) } + let(:attachment) { CerfaUploader.new } + let(:note) { create(:cerfa) } + + describe 'options uses an integer' do + let(:options) { { maximum: 10, attributes: { content: attachment } } } + + it 'attachment exceeds maximum limit' do + allow(attachment).to receive(:size) { 100 } + validator.validate_each(note, :content, attachment) + expect(note.errors).to have_key(:content) + end + + it 'attachment under maximum limit' do + allow(attachment).to receive(:size) { 1 } + validator.validate_each(note, :content, attachment) + expect(note.errors).not_to have_key(:content) + end + end + + describe 'options uses a symbol' do + let(:options) do + { + maximum: :test, + attributes: { content: attachment } + } + end + + before do + allow(note).to receive(:test) { 10 } + end + + it 'attachment exceeds maximum limit' do + allow(attachment).to receive(:size) { 100 } + validator.validate_each(note, :content, attachment) + expect(note.errors).to have_key(:content) + end + + it 'attachment under maximum limit' do + allow(attachment).to receive(:size) { 1 } + validator.validate_each(note, :content, attachment) + expect(note.errors).not_to have_key(:content) + end + end +end \ No newline at end of file From 907ac0f56c1b1f11c3e4b80512ae53cad3c1e2f8 Mon Sep 17 00:00:00 2001 From: Xavier J Date: Mon, 19 Dec 2016 15:55:11 +0100 Subject: [PATCH 4/5] Delete death code --- app/models/dossier.rb | 48 ------------------------------------------- 1 file changed, 48 deletions(-) diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 0ea6eb05a..52d6a5ce2 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -172,58 +172,10 @@ class Dossier < ActiveRecord::Base state end - def all_state? - ALL_STATE.include?(state) - end - def brouillon? BROUILLON.include?(state) end - def nouveaux? - NOUVEAUX.include?(state) - end - - def waiting_for_gestionnaire? - WAITING_FOR_GESTIONNAIRE.include?(state) - end - - def waiting_for_user? - WAITING_FOR_USER.include?(state) - end - - def en_construction? - EN_CONSTRUCTION.include?(state) - end - - def ouvert? - OUVERT.include?(state) - end - - def deposes? - DEPOSES.include?(state) - end - - def valides? - VALIDES.include?(state) - end - - def fige? - VALIDES.include?(state) - end - - def a_instruire? - A_INSTRUIRE.include?(state) - end - - def en_instruction? - EN_INSTRUCTION.include?(state) - end - - def termine? - TERMINE.include?(state) - end - def self.all_state order = 'ASC' where(state: ALL_STATE, archived: false).order("updated_at #{order}") end From 80c9165f08b06a9e451f62c5f2e1deedba741eae Mon Sep 17 00:00:00 2001 From: Xavier J Date: Mon, 19 Dec 2016 16:02:35 +0100 Subject: [PATCH 5/5] Delete death code Model/Dossier --- app/models/dossier.rb | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 52d6a5ce2..0baf68e4c 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -95,14 +95,6 @@ class Dossier < ActiveRecord::Base commentaires.order(created_at: :desc) end - def sous_domaine - if Rails.env.production? - 'tps' - else - 'tps-dev' - end - end - def next_step! role, action unless %w(initiate follow update comment valid submit receive refuse without_continuation close).include?(action) fail 'action is not valid' @@ -314,10 +306,6 @@ class Dossier < ActiveRecord::Base follows.size end - def total_commentaire - self.commentaires.size - end - def submit! self.deposit_datetime= DateTime.now @@ -336,12 +324,4 @@ class Dossier < ActiveRecord::Base def invite_by_user? email (invites_user.pluck :email).include? email end - - def self.word_is_an_integer word - return 0 if Float(word) > 2147483647 - - Float(word) - rescue ArgumentError - 0 - end end