Skip to content

Commit

Permalink
Merge pull request #1696 from DFE-Digital/feature/dao-revocations-cha…
Browse files Browse the repository at this point in the history
…nges-project-state

DAO Revocation change project state
  • Loading branch information
mec committed Jun 25, 2024
2 parents 96df5f3 + 95ba77f commit 2a75e23
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/forms/dao_revocation_stepped_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def save_to_project(project)

if revocation.valid?
revocation.save!
project.update!(state: :dao_revoked)
true
else
errors.add(:base, :check_answers)
Expand Down
7 changes: 6 additions & 1 deletion app/models/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ class Project < ApplicationRecord
enum :state, {
active: 0,
completed: 1,
deleted: 2
deleted: 2,
dao_revoked: 3
}

def establishment
Expand Down Expand Up @@ -137,6 +138,10 @@ def all_contacts
ContactsFetcherService.new(self).all_project_contacts
end

def dao_revokable?
is_a?(Conversion::Project) && directive_academy_order?
end

# :nocov:
private def fetch_member_of_parliament
result = Api::MembersApi::Client.new.member_for_constituency(establishment.parliamentary_constituency)
Expand Down
17 changes: 17 additions & 0 deletions app/views/conversions/shared/_project_summary.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,33 @@
<span class="govuk-caption-l">
<%= t("project.summary.heading.conversion", urn: @project.urn) %>
<%= govuk_tag(text: t("project.summary.type.conversion"), colour: "purple") %>
<% if @project.form_a_mat? %>
<%= govuk_tag(text: t("project.summary.type.form_a_mat"), colour: "pink") %>
<% end %>
<% if @project.dao_revoked? %>
<%= govuk_tag(text: t("project.summary.type.dao_revoked"), colour: "red") %>
<% end %>
</span>
<h1 class="govuk-heading-xl"><%= @project.establishment.name %></h1>
</div>
</div>

<%= project_notification_banner(@project, current_user) %>
<% if @project.dao_revoked? %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= govuk_notification_banner(
title_text: t("conversion_project.dao_revoked.notification.title"),
text: t("conversion_project.dao_revoked.notification.body_html", revocation_date: @project.dao_revocation.date_of_decision.to_fs(:govuk)),
html_attributes: {id: "notification-dao-revoked"}
) %>
</div>
</div>
<% end %>

<div class="govuk-grid-row">
<div class="govuk-grid-column-three-quarters">
<%= govuk_summary_list(actions: false, html_attributes: {id: "project-summary", class: "dfe-summary-list--project-summary"}) do |summary_list|
Expand Down
7 changes: 7 additions & 0 deletions config/locales/conversion_project.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ en:
<p class="govuk-body">This will help the person continuing this project to organise the kick-off meeting.</p>
<h2 class="govuk-heading-l">What happens next</h2>
<p class="govuk-body">Another person will be assigned to this project.</p>
dao_revoked:
notification:
title: Important
body_html:
<p>This project’s Directive Academy Order was revoked on %{revocation_date}.</p>
<p>Only Service Support team members can make changes to this project.</p>

summary_card:
type: Type
incoming_trust: Incoming trust
Expand Down
1 change: 1 addition & 0 deletions config/locales/project.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ en:
conversion: Conversion
transfer: Transfer
form_a_mat: Form a MAT
dao_revoked: DAO revoked
incoming_trust:
title: Incoming trust
outgoing_trust:
Expand Down
22 changes: 22 additions & 0 deletions spec/features/users_can_view_a_project_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,26 @@
end
end
end

context "when the project is a conversion with a DAO revocation" do
let(:project) { create(:conversion_project, state: :dao_revoked, directive_academy_order: true) }
let!(:dao_revocation) { DaoRevocation.create!(project_id: project.id, date_of_decision: Date.today, decision_makers_name: "Minister Name", reason_school_closed: true) }

scenario "they can see the tag in the summary" do
visit project_path(project)

within(".govuk-caption-l .govuk-tag--red") do
expect(page).to have_content("DAO revoked")
end
end

scenario "they can see the notification banner" do
visit project_path(project)

within("#notification-dao-revoked") do
expect(page).to have_content("This project’s Directive Academy Order was revoked on")
expect(page).to have_content(Date.today.to_fs(:govuk))
end
end
end
end
8 changes: 8 additions & 0 deletions spec/forms/dao_revocation_stepped_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,14 @@
expect(dao_revocation.date_of_decision).to eql Date.today
end

it "updates the project state to dao_revoked" do
project = create(:conversion_project, directive_academy_order: true)

valid_form.save_to_project(project)

expect(project.reload.state).to eql "dao_revoked"
end

it "returns false and adds an error when invalid" do
project = create(:conversion_project, directive_academy_order: false)

Expand Down
16 changes: 16 additions & 0 deletions spec/models/project_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,22 @@
end
end

describe "#dao_revokable?" do
it "returns true when the project is a conversion with a DAO applied" do
project = build(:conversion_project, directive_academy_order: true)

expect(project.dao_revokable?).to be true
end

it "returns false when the project is not appropriate" do
conversion_project = build(:conversion_project, directive_academy_order: false)
transfer_project = build(:transfer_project)

expect(conversion_project.dao_revokable?).to be false
expect(transfer_project.dao_revokable?).to be false
end
end

describe "delegation" do
it "delegates local_authority to establishment" do
local_authotity = double(code: 100)
Expand Down

0 comments on commit 2a75e23

Please sign in to comment.