Open gabina opened 4 days ago
That spec was added as part of the project to add support for un-tracking specific articles. The main use case is if you have an event like an edit-a-thon where everyone is working on a specific set of articles related to the theme of the edit-a-thon, but there's a user who also edited a few unrelated articles, you can mark those edited articles as 'untracked' and then they will not be counted in the stats.
It looks like I did a poor job updating the spec when I was trying to make the revision_count behave as expected, in https://github.com/WikiEducationFoundation/WikiEduDashboard/commit/e76ce7d51bf829f384efdd1a8650d1396631c5cf
I think you are correct, we should expect revision_count not to be zero here. The lack of a reload after the cache update action, as you pointed out, is probably the source of the problem.
What is happening?
It's not clear (for me) what the "updates only updates cache from tracked revisions" spec in
spec/models/courses_users_spec.rb
is trying to test.First of all, the spec tries to get
CoursesUsers
record with id = 1 doingdescribed_class.update_all_caches(described_class.where(id: 1))
. I wonder if we can be sure that the id of the recently createdCoursesUsers
record is 1 (at least, locally) becuase we're not sepcifying the course user id when creating it.Supposing that we force the
CoursesUsers
id to be 1 during creation, the other point is that we're doing expectations overcourse_user
(wherecourse_user = courses_user
). According to what I see when printing it, it looks likecourse_user
is not being updated as expected (even though the print happens after theupdate_all_caches
call). However, it gets updated if we reload it.The point is that if we're only un-tracking the
ArticlesCourses
record forarticle
(ArticlesCourses.first.update(tracked: false)
), why would weexpect(course_user.revision_count).to eq(0)
? I think revisions fortalk_page
,sandbox
anddraft
should be counted and we shouldexpect(course_user.revision_count).to eq(3)
.Additional context
As part of the data re-architecture project, I'm creating specs for new timeslices models based on the existing specs for non-timeslices models. For example, to create
CourseUserWikiTimeslices
specs I start by looking at theCoursesUsers
specs. That's why I ended up taking a deep look at these specs.