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

Fix creation issue with Exercises #1829

Merged
merged 2 commits into from
Sep 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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