Skip to content

Commit

Permalink
Merge pull request #2446 from alphagov/408-edit-assignee-updates-foll…
Browse files Browse the repository at this point in the history
…owing-desk-check

Edit assignee updates following desk check
  • Loading branch information
mtaylorgds authored Dec 5, 2024
2 parents e933c78 + 8298230 commit e0c3b5b
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 20 deletions.
18 changes: 18 additions & 0 deletions app/helpers/editions_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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} <span class='govuk-tag govuk-tag--#{edition.state}'>#{edition.status_text}</span>"),
},
]
end
end
8 changes: 4 additions & 4 deletions app/helpers/tabbed_nav_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 1 addition & 15 deletions app/views/editions/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,7 @@
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds editions__edit__summary">
<%= 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} <span class='govuk-tag govuk-tag--#{@resource.state}'>#{@resource.status_text}</span>"),
},
],
items: document_summary_items(@resource),
} %>
</div>
</div>
Expand Down
30 changes: 29 additions & 1 deletion test/integration/edition_edit_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class EditionEditTest < IntegrationTest
stub_linkables
end

context "all tabs" do
context "edit page" do
setup do
visit_published_edition
end
Expand All @@ -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
Expand Down

0 comments on commit e0c3b5b

Please sign in to comment.