diff --git a/app/models/edition.rb b/app/models/edition.rb index 101d98c29..af1c5edcd 100644 --- a/app/models/edition.rb +++ b/app/models/edition.rb @@ -337,6 +337,7 @@ def self.find_or_create_from_panopticon_data(panopticon_id, importing_user) panopticon_id: metadata.id, slug: metadata.slug, title: metadata.name, + assigned_to_id: importing_user.id, ) end diff --git a/test/models/edition_test.rb b/test/models/edition_test.rb index ae32edef7..93551cf77 100644 --- a/test/models/edition_test.rb +++ b/test/models/edition_test.rb @@ -427,6 +427,24 @@ def draft_second_edition_from(published_edition) assert_equal artefact.id.to_s, publication.panopticon_id.to_s end + test "should create a publication with the current user as the assignee" do + artefact = FactoryBot.create( + :artefact, + slug: "foo-bar", + kind: "answer", + name: "Foo bar", + owning_app: "publisher", + ) + artefact.save! + + Artefact.find(artefact.id) + user = FactoryBot.create(:user, :govuk_editor) + + publication = Edition.find_or_create_from_panopticon_data(artefact.id, user) + + assert_equal user.id.to_s, publication.assigned_to_id.to_s + end + test "should not change edition metadata if archived" do artefact = FactoryBot.create( :artefact,