From da15c9d2b367d97543a51a8bad46a4e6c69e27c4 Mon Sep 17 00:00:00 2001 From: Jeremy Walker Date: Tue, 7 Sep 2021 15:03:19 +0100 Subject: [PATCH 1/2] Fix creation issue with Exercises --- app/commands/git/sync_track.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/commands/git/sync_track.rb b/app/commands/git/sync_track.rb index a2167fb23d..3883cfb30a 100644 --- a/app/commands/git/sync_track.rb +++ b/app/commands/git/sync_track.rb @@ -102,7 +102,7 @@ def sync_concept_exercises! prerequisites: exercise_concepts(exercise_config[:prerequisites]), has_test_runner: git_exercise.has_test_runner? ) - Git::SyncConceptExercise.(exercise, force_sync: force_sync) + Git::SyncConceptExercise.(exercise, force_sync: force_sync || exercise.id_changed?) end end From f7a8696f0d665b507b07a5a31cd78c0b7176c1f2 Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Wed, 8 Sep 2021 11:47:58 +0200 Subject: [PATCH 2/2] Force syncing for new concepts/concept exercises/practice exercises --- app/commands/git/sync_track.rb | 6 ++-- test/commands/git/sync_track_test.rb | 54 ++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 3 deletions(-) diff --git a/app/commands/git/sync_track.rb b/app/commands/git/sync_track.rb index 3883cfb30a..ee68c39825 100644 --- a/app/commands/git/sync_track.rb +++ b/app/commands/git/sync_track.rb @@ -78,7 +78,7 @@ def sync_concepts! blurb: git_concept.blurb, synced_to_git_sha: head_git_track.commit.oid ).tap do |concept| - Git::SyncConcept.(concept, force_sync: force_sync) + Git::SyncConcept.(concept, force_sync: force_sync || concept.id_previously_changed?) end end end @@ -102,7 +102,7 @@ def sync_concept_exercises! prerequisites: exercise_concepts(exercise_config[:prerequisites]), has_test_runner: git_exercise.has_test_runner? ) - Git::SyncConceptExercise.(exercise, force_sync: force_sync || exercise.id_changed?) + Git::SyncConceptExercise.(exercise, force_sync: force_sync || exercise.id_previously_changed?) end end @@ -126,7 +126,7 @@ def sync_practice_exercises! practiced_concepts: exercise_concepts(exercise_config[:practices]), has_test_runner: git_exercise.has_test_runner? ) - Git::SyncPracticeExercise.(exercise, force_sync: force_sync) + Git::SyncPracticeExercise.(exercise, force_sync: force_sync || exercise.id_previously_changed?) end end diff --git a/test/commands/git/sync_track_test.rb b/test/commands/git/sync_track_test.rb index 204b4ef92f..5121d12e59 100644 --- a/test/commands/git/sync_track_test.rb +++ b/test/commands/git/sync_track_test.rb @@ -470,4 +470,58 @@ class Git::SyncTrackTest < ActiveSupport::TestCase assert track.course? end + + test "new concept syncs with force_sync even when track is not force synced" do + track = create :track, synced_to_git_sha: "HEAD" + + Git::SyncConcept.expects(:call).with(anything, force_sync: true).at_least_once + + Git::SyncTrack.(track) + end + + test "new concept exercise syncs with force_sync even when track is not force synced" do + track = create :track, synced_to_git_sha: "HEAD" + + Git::SyncConceptExercise.expects(:call).with(anything, force_sync: true).at_least_once + + Git::SyncTrack.(track) + end + + test "new practice exercise syncs with force_sync even when track is not force synced" do + track = create :track, synced_to_git_sha: "HEAD" + + Git::SyncPracticeExercise.expects(:call).with(anything, force_sync: true).at_least_once + + Git::SyncTrack.(track) + end + + test "existing concept does not sync with force_sync" do + track = create :track, synced_to_git_sha: "HEAD" + Git::SyncTrack.(track) + + Git::SyncConcept.expects(:call).with(anything, force_sync: true).never + Git::SyncConcept.expects(:call).with(anything, force_sync: false).at_least_once + + Git::SyncTrack.(track) + end + + test "existing concept exercise does not sync with force_sync" do + track = create :track, synced_to_git_sha: "HEAD" + Git::SyncTrack.(track) + + Git::SyncConceptExercise.expects(:call).with(anything, force_sync: true).never + Git::SyncConceptExercise.expects(:call).with(anything, force_sync: false).at_least_once + + Git::SyncTrack.(track) + end + + test "existing practice exercise does not sync with force_sync" do + track = create :track, synced_to_git_sha: "HEAD" + Git::SyncTrack.(track) + + Git::SyncPracticeExercise.expects(:call).with(anything, force_sync: true).never + Git::SyncPracticeExercise.expects(:call).with(anything, force_sync: false).at_least_once + + Git::SyncTrack.(track) + end end