diff --git a/app/assets/stylesheets/new_design/landing.scss b/app/assets/stylesheets/new_design/landing.scss index 7cfaa8839..f6bec1754 100644 --- a/app/assets/stylesheets/new_design/landing.scss +++ b/app/assets/stylesheets/new_design/landing.scss @@ -439,19 +439,6 @@ $cta-panel-button-border-size: 2px; } } -.tour-de-france-banner { - padding-top: 15px; - padding-bottom: 15px; - background-color: $blue; - color: #FFFFFF; - text-align: center; - - a { - color: #FFFFFF; - text-decoration: underline; - } -} - .half { width: 45%; float: left; diff --git a/app/decorators/champ_decorator.rb b/app/decorators/champ_decorator.rb index 151eef64d..ef50412f2 100644 --- a/app/decorators/champ_decorator.rb +++ b/app/decorators/champ_decorator.rb @@ -18,20 +18,4 @@ class ChampDecorator < Draper::Decorator object.value end end - - def date_for_input - if object.value.present? - if type_champ == TypeDeChamp.type_champs.fetch(:date) - object.value - elsif type_champ == TypeDeChamp.type_champs.fetch(:datetime) && object.value != ' 00:00' - Time.zone.strptime(object.value, "%Y-%m-%d %H:%M").strftime("%Y-%m-%d") - end - end - end - - def description_with_links - if description - description.gsub(URI.regexp, '\0') - end - end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e6d7cf6d9..873036f21 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -90,13 +90,6 @@ module ApplicationHelper end end - def ensure_safe_json(json) - json.present? ? JSON.parse(json).to_json : '[]' - rescue Exception => e - Raven.capture_exception(e) - {} - end - def sentry_config sentry = Rails.application.secrets.sentry if sentry diff --git a/app/models/champs/datetime_champ.rb b/app/models/champs/datetime_champ.rb index a38aa151f..43d59e26f 100644 --- a/app/models/champs/datetime_champ.rb +++ b/app/models/champs/datetime_champ.rb @@ -1,24 +1,12 @@ class Champs::DatetimeChamp < Champ before_save :format_before_save - def same_hour?(num) - same_date?(num, '%H') - end - - def same_minute?(num) - same_date?(num, '%M') - end - def search_terms # Text search is pretty useless for datetimes so we’re not including these champs end private - def same_date?(num, compare) - return value.present? && value.to_datetime.strftime(compare) == num - end - def format_before_save if (value =~ /=>/).present? self.value = diff --git a/app/models/dossier.rb b/app/models/dossier.rb index fd97c3c59..436c8c707 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -152,22 +152,10 @@ class Dossier < ApplicationRecord update_columns(autorisation_donnees: false) end - def total_follow - follows.size - end - def read_only? en_instruction? || accepte? || refuse? || sans_suite? end - def invite_for_user(user) - invites.find_by(user_id: user.id) - end - - def can_be_en_construction? - !(procedure.archivee? && brouillon?) - end - def can_transition_to_en_construction? !procedure.archivee? && brouillon? end diff --git a/app/models/gestionnaire.rb b/app/models/gestionnaire.rb index 8008cb46b..589cc7f27 100644 --- a/app/models/gestionnaire.rb +++ b/app/models/gestionnaire.rb @@ -22,11 +22,6 @@ class Gestionnaire < ApplicationRecord procedures.merge(Procedure.avec_lien.or(Procedure.archivees)) end - def can_view_dossier?(dossier_id) - avis.where(dossier_id: dossier_id).any? || - dossiers.where(id: dossier_id).any? - end - def follow(dossier) if follow?(dossier) return @@ -43,10 +38,6 @@ class Gestionnaire < ApplicationRecord followed_dossiers.include?(dossier) end - def assigned_on_procedure?(procedure_id) - procedures.find_by(id: procedure_id).present? - end - def assign_to_procedure(procedure) begin procedures << procedure diff --git a/app/models/procedure.rb b/app/models/procedure.rb index 225156e9b..9d5577db3 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -164,10 +164,6 @@ class Procedure < ApplicationRecord types_de_champ_private.order(:order_place) end - def all_types_de_champ - types_de_champ + types_de_champ_private - end - def self.active(id) publiees.find(id) end diff --git a/app/models/user.rb b/app/models/user.rb index 7945bf875..c676fb159 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -28,21 +28,6 @@ class User < ApplicationRecord link_invites! end - def self.find_for_france_connect(email, siret) - user = User.find_by(email: email) - - if user.nil? - User.create(email: email, password: Devise.friendly_token[0, 20], siret: siret) - else - user.update(siret: siret) - user - end - end - - def loged_in_with_france_connect? - loged_in_with_france_connect.present? - end - def owns?(dossier) dossier.user_id == id end diff --git a/app/services/champs_service.rb b/app/services/champs_service.rb deleted file mode 100644 index 888465efe..000000000 --- a/app/services/champs_service.rb +++ /dev/null @@ -1,48 +0,0 @@ -class ChampsService - class << self - def save_champs(champs, params) - fill_champs(champs, params) - - champs.select(&:changed?).each(&:save) - end - - def build_error_messages(champs) - champs.select(&:mandatory_and_blank?) - .map { |c| "Le champ #{c.libelle.truncate(200)} doit être rempli." } - end - - def check_piece_justificative_files(champs) - champs.select do |champ| - champ.type_champ == TypeDeChamp.type_champs.fetch(:piece_justificative) - end.map(&:piece_justificative_file_errors).flatten - end - - private - - def fill_champs(champs, h) - datetimes, not_datetimes = champs.partition { |c| c.type_champ == TypeDeChamp.type_champs.fetch(:datetime) } - - not_datetimes.each do |c| - if c.type_champ == TypeDeChamp.type_champs.fetch(:piece_justificative) && h["champs"]["'#{c.id}'"].present? - c.piece_justificative_file.attach(h["champs"]["'#{c.id}'"]) - else - c.value = h[:champs]["'#{c.id}'"] - end - end - - datetimes.each { |c| c.value = parse_datetime(c.id, h) } - end - - def parse_datetime(champ_id, h) - "#{h[:champs]["'#{champ_id}'"]} #{extract_hour(champ_id, h)}:#{extract_minute(champ_id, h)}" - end - - def extract_hour(champ_id, h) - h[:time_hour]["'#{champ_id}'"] - end - - def extract_minute(champ_id, h) - h[:time_minute]["'#{champ_id}'"] - end - end -end diff --git a/app/services/pieces_justificatives_service.rb b/app/services/pieces_justificatives_service.rb index 521dd5873..b9ef0f767 100644 --- a/app/services/pieces_justificatives_service.rb +++ b/app/services/pieces_justificatives_service.rb @@ -15,23 +15,6 @@ class PiecesJustificativesService .compact() end - def self.upload_one!(dossier, user, params) - content = params[:piece_justificative][:content] - if ClamavService.safe_file?(content.path) - pj = PieceJustificative.new(content: content, - dossier: dossier, - type_de_piece_justificative: nil, - user: user) - - pj.save - else - pj = PieceJustificative.new - pj.errors.add(:content, "#{content.original_filename} : Virus détecté !!") - end - - pj - end - def self.save_pj(content, dossier, tpj, user) pj = PieceJustificative.new(content: content, dossier: dossier, diff --git a/spec/controllers/users/sessions_controller_spec.rb b/spec/controllers/users/sessions_controller_spec.rb index 608791878..b6601b4b9 100644 --- a/spec/controllers/users/sessions_controller_spec.rb +++ b/spec/controllers/users/sessions_controller_spec.rb @@ -17,7 +17,7 @@ describe Users::SessionsController, type: :controller do user.reload end - subject { user.loged_in_with_france_connect? } + subject { user.loged_in_with_france_connect.present? } it { is_expected.to be_falsey } end @@ -141,7 +141,7 @@ describe Users::SessionsController, type: :controller do it 'loged_in_with_france_connect current_user attribut is nil' do user.reload - expect(user.loged_in_with_france_connect?).to be_falsey + expect(user.loged_in_with_france_connect.present?).to be_falsey end context 'when user is connect with france connect particulier' do diff --git a/spec/decorators/champ_decorator_spec.rb b/spec/decorators/champ_decorator_spec.rb index cc4a00757..9d9fde006 100644 --- a/spec/decorators/champ_decorator_spec.rb +++ b/spec/decorators/champ_decorator_spec.rb @@ -62,36 +62,4 @@ describe ChampDecorator do end end end - - describe '#date_for_input' do - subject { decorator.date_for_input } - - describe "for a date" do - let(:type_de_champ) { create(:type_de_champ_date) } - - context "when value is an ISO date" do - before { champ.update value: "2017-12-31" } - it { is_expected.to eq "2017-12-31" } - end - - context "when value is empty" do - before { champ.update value: nil } - it { is_expected.to eq nil } - end - end - - describe "for a datetime" do - let(:type_de_champ) { create(:type_de_champ_date) } - - context "when value is an formatted datetime" do - before { champ.update value: "2017-12-30 23:17" } - it { is_expected.to eq "2017-12-30" } - end - - context "when value is empty" do - before { champ.update value: nil } - it { is_expected.to eq nil } - end - end - end end diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 22c2f9b06..30a7becef 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -17,18 +17,4 @@ describe ApplicationHelper do it { is_expected.to be_nil } end end - - describe "#ensure_safe_json" do - subject { ensure_safe_json(json) } - - context "with a dirty json" do - let(:json) { "alert('haha');" } - it { is_expected.to eq({}) } - end - - context 'with a correct json' do - let(:json) { '[[{"lat": 2.0, "lng": 102.0}, {"lat": 3.0, "lng": 103.0}, {"lat": 2.0, "lng": 102.0}], [{"lat": 2.0, "lng": 102.0}, {"lat": 3.0, "lng": 103.0}, {"lat": 2.0, "lng": 102.0}]]' } - it { is_expected.to eq("[[{\"lat\":2.0,\"lng\":102.0},{\"lat\":3.0,\"lng\":103.0},{\"lat\":2.0,\"lng\":102.0}],[{\"lat\":2.0,\"lng\":102.0},{\"lat\":3.0,\"lng\":103.0},{\"lat\":2.0,\"lng\":102.0}]]") } - end - end end diff --git a/spec/models/dossier_spec.rb b/spec/models/dossier_spec.rb index 36b9d2e95..91732b0a5 100644 --- a/spec/models/dossier_spec.rb +++ b/spec/models/dossier_spec.rb @@ -235,29 +235,6 @@ describe Dossier do it { expect(dossier.champs_private.pluck(:libelle)).to match(['l1', 'l2', 'l3']) } end - describe '#total_follow' do - let(:dossier) { create(:dossier, :with_entreprise, user: user) } - let(:dossier2) { create(:dossier, :with_entreprise, user: user) } - - subject { dossier.total_follow } - - context 'when no body follow dossier' do - it { expect(subject).to eq 0 } - end - - context 'when 2 people follow dossier' do - before do - create :follow, dossier_id: dossier.id, gestionnaire_id: (create :gestionnaire).id - create :follow, dossier_id: dossier.id, gestionnaire_id: (create :gestionnaire).id - - create :follow, dossier_id: dossier2.id, gestionnaire_id: (create :gestionnaire).id - create :follow, dossier_id: dossier2.id, gestionnaire_id: (create :gestionnaire).id - end - - it { expect(subject).to eq 2 } - end - end - describe "#text_summary" do let(:procedure) { create(:procedure, libelle: "Démarche", organisation: "Organisme") } diff --git a/spec/models/gestionnaire_spec.rb b/spec/models/gestionnaire_spec.rb index e860c3231..e24b6d353 100644 --- a/spec/models/gestionnaire_spec.rb +++ b/spec/models/gestionnaire_spec.rb @@ -199,29 +199,6 @@ describe Gestionnaire, type: :model do end end - describe '#can_view_dossier?' do - subject{ gestionnaire.can_view_dossier?(dossier.id) } - - context 'when gestionnaire is assigned on dossier' do - let!(:dossier){ create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_instruction)) } - - it { expect(subject).to be true } - end - - context 'when gestionnaire is invited on dossier' do - let(:dossier){ create(:dossier) } - let!(:avis){ create(:avis, dossier: dossier, gestionnaire: gestionnaire) } - - it { expect(subject).to be true } - end - - context 'when gestionnaire is neither assigned nor invited on dossier' do - let(:dossier){ create(:dossier) } - - it { expect(subject).to be false } - end - end - describe "procedure_presentation_and_errors_for_procedure_id" do let(:procedure_presentation_and_errors) { gestionnaire.procedure_presentation_and_errors_for_procedure_id(procedure_id) } let(:procedure_presentation) { procedure_presentation_and_errors.first } diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 942283c16..9564d4623 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -20,36 +20,6 @@ describe User, type: :model do end end - describe '#find_for_france_connect' do - let(:siret) { '00000000000000' } - context 'when user exist' do - let!(:user) { create(:user) } - subject { described_class.find_for_france_connect(user.email, siret) } - it 'retrieves user' do - expect(subject).to eq(user) - end - it 'saves siret in user' do - expect(subject.siret).to eq(siret) - end - it 'does not create new user' do - expect { subject }.not_to change(User, :count) - end - end - context 'when user does not exist' do - let(:email) { 'super-m@n.com' } - subject { described_class.find_for_france_connect(email, siret) } - it 'returns user' do - expect(subject).to be_an_instance_of(User) - end - it 'creates new user' do - expect { subject }.to change(User, :count).by(1) - end - it 'saves siret' do - expect(subject.siret).to eq(siret) - end - end - end - describe '#owns?' do let(:owner) { create(:user) } let(:dossier) { create(:dossier, user: owner) } diff --git a/spec/services/champs_service_spec.rb b/spec/services/champs_service_spec.rb deleted file mode 100644 index 3d7703348..000000000 --- a/spec/services/champs_service_spec.rb +++ /dev/null @@ -1,40 +0,0 @@ -require 'spec_helper' - -describe ChampsService do - let(:type_de_champ) { create(:type_de_champ) } - let(:type_de_champ_mandatory) { create(:type_de_champ, libelle: 'mandatory', mandatory: true) } - let(:type_de_champ_datetime) { create(:type_de_champ_datetime) } - let!(:champ) { type_de_champ.champ.create(value: 'toto') } - let!(:champ_mandatory_empty) { type_de_champ_mandatory.champ.create } - let!(:champ_datetime) { type_de_champ_datetime.champ.create } - let!(:champs) { [champ, champ_mandatory_empty, champ_datetime] } - - describe 'save_champs' do - before :each do - params_hash = { - champs: { - "'#{champ.id}'" => 'yop', - "'#{champ_datetime.id}'" => 'd' - }, - time_hour: { "'#{champ_datetime.id}'" => '12' }, - time_minute: { "'#{champ_datetime.id}'" => '24' } - } - ChampsService.save_champs(champs, params_hash) - champs.each(&:reload) - end - - it 'saves the changed champ' do - expect(champ.value).to eq('yop') - end - - it 'parses and save the date' do - expect(champ_datetime.value).to eq(nil) - end - end - - describe 'build_error_message' do - it 'adds error for the missing mandatory champ' do - expect(ChampsService.build_error_messages(champs)).to match(['Le champ mandatory doit être rempli.']) - end - end -end