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

Use current user as assignee #1999

Merged
merged 1 commit into from
Jan 10, 2024
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
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