diff --git a/app/helpers/editions_helper.rb b/app/helpers/editions_helper.rb
index 5bfd15844..ca8bd3688 100644
--- a/app/helpers/editions_helper.rb
+++ b/app/helpers/editions_helper.rb
@@ -53,4 +53,22 @@ def legacy_format_filter_selection_options
[displayed_format_name, format_name]
end
end
+
+ def document_summary_items(edition)
+ [
+ {
+ field: "Assigned to",
+ value: edition.assigned_to || "None",
+ edit: assignee_edit_link(edition),
+ },
+ {
+ field: "Content type",
+ value: edition.format.underscore.humanize,
+ },
+ {
+ field: "Edition",
+ value: sanitize("#{edition.version_number} #{edition.status_text}"),
+ },
+ ]
+ end
end
diff --git a/app/helpers/tabbed_nav_helper.rb b/app/helpers/tabbed_nav_helper.rb
index 7c8e2c2f2..a02a3d135 100644
--- a/app/helpers/tabbed_nav_helper.rb
+++ b/app/helpers/tabbed_nav_helper.rb
@@ -73,15 +73,15 @@ def edit_nav_item(label, href, current)
]
end
- def available_assignee_items(resource)
+ def available_assignee_items(edition)
items = []
- unless resource.assignee.nil?
- items << { value: resource.assigned_to_id, text: resource.assignee, checked: true }
+ unless edition.assignee.nil?
+ items << { value: edition.assigned_to_id, text: edition.assignee, checked: true }
items << { value: "none", text: "None" }
items << :or
end
User.enabled.order_by([%i[name asc]]).each do |user|
- items << { value: user.id, text: user.name } unless user.name == resource.assignee
+ items << { value: user.id, text: user.name } unless user.name == edition.assignee || !user.has_editor_permissions?(edition)
end
items
end
diff --git a/app/views/editions/show.html.erb b/app/views/editions/show.html.erb
index 8f13a3eab..08c79a9ed 100644
--- a/app/views/editions/show.html.erb
+++ b/app/views/editions/show.html.erb
@@ -21,21 +21,7 @@
<%= render "govuk_publishing_components/components/summary_list", {
- items: [
- {
- field: "Assigned to",
- value: @resource.assigned_to,
- edit: assignee_edit_link(@resource),
- },
- {
- field: "Content type",
- value: @resource.format.underscore.humanize,
- },
- {
- field: "Edition",
- value: sanitize("#{@resource.version_number} #{@resource.status_text}"),
- },
- ],
+ items: document_summary_items(@resource),
} %>
diff --git a/test/integration/edition_edit_test.rb b/test/integration/edition_edit_test.rb
index d49732ac9..0a5eaf23d 100644
--- a/test/integration/edition_edit_test.rb
+++ b/test/integration/edition_edit_test.rb
@@ -10,7 +10,7 @@ class EditionEditTest < IntegrationTest
stub_linkables
end
- context "all tabs" do
+ context "edit page" do
setup do
visit_published_edition
end
@@ -36,6 +36,34 @@ class EditionEditTest < IntegrationTest
assert row[2].has_text?("1")
assert row[2].has_text?("Published")
end
+
+ should "indicate when an edition does not have an assignee" do
+ within all(".govuk-summary-list__row")[0] do
+ assert_selector(".govuk-summary-list__key", text: "Assigned to")
+ assert_selector(".govuk-summary-list__value", text: "None")
+ end
+ end
+
+ should "show the person assigned to an edition" do
+ visit_draft_edition
+
+ within all(".govuk-summary-list__row")[0] do
+ assert_selector(".govuk-summary-list__key", text: "Assigned to")
+ assert_selector(".govuk-summary-list__value", text: @draft_edition.assignee)
+ end
+ end
+ end
+
+ context "edit assignee page" do
+ should "only show editors as available for assignment" do
+ edition = FactoryBot.create(:answer_edition, state: "draft")
+ non_editor_user = FactoryBot.create(:user, name: "Non Editor User")
+
+ visit edit_assignee_edition_path(edition)
+
+ assert_selector "label", text: @govuk_editor.name
+ assert_no_selector "label", text: non_editor_user.name
+ end
end
context "metadata tab" do