Skip to content

Commit

Permalink
Preserve the scorer when cloning! Fixes #273 (#372)
Browse files Browse the repository at this point in the history
Co-authored-by: [email protected] <>
  • Loading branch information
epugh authored Jun 4, 2021
1 parent 0a55b93 commit 7c4d669
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/models/case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ def clone_case original_case, user, try: nil, clone_queries: false, clone_rating
end
end

self.scorer = original_case.scorer

save!
end
end
Expand Down
11 changes: 11 additions & 0 deletions test/models/case_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,17 @@ class CaseTest < ActiveSupport::TestCase
end
end
end
it 'preserves the scorer' do
assert_difference 'Case.count' do
user_scorer = scorers(:random_scorer)
the_case.scorer = user_scorer
the_case.save

cloned_case.clone_case the_case, user, try: the_try, clone_queries: false

assert_equal user_scorer, cloned_case.scorer
end
end
end

describe 'when cloning a try and the queries and the ratings' do
Expand Down

0 comments on commit 7c4d669

Please sign in to comment.