Skip to content

Conversation

@bagedevimo
Copy link
Contributor

  • Add tests for (and fix) the after_save behaviour for contest
  • Refactor contest#after_save

@coveralls
Copy link

coveralls commented Jul 11, 2025

Coverage Status

coverage: 37.776% (+0.1%) from 37.654%
when pulling 2dcf8fd on contest-after-save-with-spec
into 01e4e8f on master.

This after_save hook is supposed to be handling the cases where the
contest is changed, but there are all sorts of things going on that
means it's being overwritten or ignored or just not called at all.

I'd like to write out the weird stuff around contest_relation#finish_at,
so this is step 1 of that.

before_save is changed to after_save, as that's really what it should
have been in the first place. The only reason it works now is that the
calculation of finish_at is done inside `Contest` instead of
`ContestRelation` which is 'a bit odd', but fine.
The prior version of this code is a bit hard to follow as also has one
hook doing two responsibilities. This is just a minor factor to
hopefully clear it all up a bit and move some of the responsibilities
around.

The long term goal is to let ContestRelation calculate it's own
finish_at from its parent Contest, then changes to Contest just ask
ContestRelation to recalculate, like every other way a contest_relation
might need to be updated.

We _could_ use touch: true on the has_many so that any saved changed to
contest causes an update of contest_relation, then have the
set_finish_at be a before_validation callback on ContestRelation, but I
always feel a little weird about the implictness of that.
@bagedevimo bagedevimo force-pushed the contest-after-save-with-spec branch from 9f70875 to 2dcf8fd Compare November 23, 2025 06:14
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.

3 participants