Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ajout de contraintes sur les dates de début et de fin des scolarités #1253

Merged
merged 15 commits into from
Dec 4, 2024

Conversation

tnicolas1
Copy link
Collaborator

No description provided.

app/models/pfmp.rb Outdated Show resolved Hide resolved
spec/factories/schoolings.rb Outdated Show resolved Hide resolved
@tnicolas1 tnicolas1 force-pushed the fix/validates-dates branch 2 times, most recently from 36d9833 to ad05873 Compare December 2, 2024 10:03
@tnicolas1 tnicolas1 force-pushed the fix/validates-dates branch 3 times, most recently from da012d1 to 0b184f0 Compare December 2, 2024 13:20
@@ -34,6 +34,19 @@ class Schooling < ApplicationRecord # rubocop:disable Metrics/ClassLength
validates :student, uniqueness: { scope: :end_date, message: :unique_active_schooling }, if: :open?
validates :student, uniqueness: { scope: :classe }, if: :closed?

validates :end_date,
:start_date,
if: ->(schooling) { schooling.classe.present? },
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Condition ajoutée à cause du test dans schooling_spec (Ligne 10) :

it { is_expected.to belong_to(:classe).class_name("Classe") }

@tnicolas1 tnicolas1 force-pushed the fix/validates-dates branch from 1e31825 to ca9aac6 Compare December 3, 2024 10:57
@tnicolas1 tnicolas1 changed the title Ajout de contraintes sur les dates de début et de fin des scolarités et des PFMPs Ajout de contraintes sur les dates de début et de fin des scolarités Dec 4, 2024
@tnicolas1 tnicolas1 requested a review from pskl December 4, 2024 08:42
status { :student }

after(:build) do |schooling|
schooling.start_date = if schooling.end_date.present?
schooling.end_date - 1.month
else
"#{SchoolYear.current.start_year}-01-10"
Date.parse("#{schooling.classe.school_year.start_year}-09-01")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bien vu!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A un moment dans le code, j'ai aussi adapté l'année des dates de la Factory 'PFMP' sur celles de la Factory 'Schooling', mais j'ai supprimé ce code quand j'ai annulé mes modifications sur le 'validates' du modèle 'PFMP'.
Est-ce qu'il faudrait que je rajoute cette logique ou non ? (Sachant que tous les tests passent actuellement)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pour l'instant c'est pas très grave je dirais.

@@ -16,12 +16,6 @@
sign_in(user)
schooling.pfmps = [payment_request.pfmp]
schooling.save!
Timecop.safe_mode = false
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pas mal de pouvoir virer ca!

@pskl pskl merged commit efc91e2 into main Dec 4, 2024
5 checks passed
@pskl pskl deleted the fix/validates-dates branch December 4, 2024 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ajout de contraintes sur les dates de début et de fin des scolarités
2 participants