Skip to content

Commit

Permalink
Fix creation issue with Exercises (#1829)
Browse files Browse the repository at this point in the history
* Fix creation issue with Exercises

* Force syncing for new concepts/concept exercises/practice exercises

Co-authored-by: Erik Schierboom <[email protected]>
  • Loading branch information
iHiD and ErikSchierboom authored Sep 8, 2021
1 parent 6ee8f40 commit 431d624
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/commands/git/sync_track.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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_previously_changed?)
end
end

Expand All @@ -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

Expand Down
54 changes: 54 additions & 0 deletions test/commands/git/sync_track_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 431d624

Please sign in to comment.