Skip to content

Commit

Permalink
Merge pull request #1999 from alphagov/use-current-user-as-asignee
Browse files Browse the repository at this point in the history
Use current user as assignee
  • Loading branch information
1pretz1 authored Jan 10, 2024
2 parents 0252a48 + 818444f commit 7f67c03
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/editions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def duplicate
if !resource.can_create_new_edition?
flash[:warning] = "Another person has created a newer edition"
redirect_to edition_path(resource)
elsif command.duplicate(target_edition_class_name, new_assignee)
elsif command.duplicate(target_edition_class_name, current_user)
new_edition = command.new_edition
UpdateWorker.perform_async(new_edition.id.to_s)

Expand Down
1 change: 1 addition & 0 deletions app/models/edition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
18 changes: 18 additions & 0 deletions test/models/edition_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 7f67c03

Please sign in to comment.