diff --git a/app/controllers/mou_signatures_controller.rb b/app/controllers/mou_signatures_controller.rb
index a360e7b76c..d9ad8a66aa 100644
--- a/app/controllers/mou_signatures_controller.rb
+++ b/app/controllers/mou_signatures_controller.rb
@@ -1,12 +1,5 @@
class MouSignaturesController < WebController
- before_action :set_agreement_type, except: %i[index]
- after_action :verify_authorized, only: %i[index]
-
- def index
- authorize MouSignature, :can_manage_mous?
- @mou_signatures = MouSignature.all
- render template: "mou_signatures/index", locals: { mou_signatures: @mou_signatures }
- end
+ before_action :set_agreement_type
def show
@mou_signature = current_user.current_organisation_mou_signature
diff --git a/app/controllers/sitemap_controller.rb b/app/controllers/sitemap_controller.rb
index be5282b0f3..0eea849444 100644
--- a/app/controllers/sitemap_controller.rb
+++ b/app/controllers/sitemap_controller.rb
@@ -6,7 +6,7 @@ def index
render locals: { active_groups:,
trial_groups:,
should_show_users_link: should_show_users?,
- should_show_mous_link: should_show_mous_link?,
+ should_show_organisations_link: should_show_organisations_link?,
should_show_reports_link: should_show_reports_link? }
end
@@ -14,8 +14,8 @@ def should_show_users?
Pundit.policy(current_user, :user).can_manage_user?
end
- def should_show_mous_link?
- Pundit.policy(current_user, :mou_signature).can_manage_mous?
+ def should_show_organisations_link?
+ Pundit.policy(current_user, :organisation).can_view_organisations?
end
def should_show_reports_link?
diff --git a/app/input_objects/organisations/filter_input.rb b/app/input_objects/organisations/filter_input.rb
index b9ab8043fb..7762b6ca05 100644
--- a/app/input_objects/organisations/filter_input.rb
+++ b/app/input_objects/organisations/filter_input.rb
@@ -17,8 +17,8 @@ def sort_options
def agreement_type_options
[
OpenStruct.new(label: I18n.t("organisations.index.filter.agreement_type.any")),
- OpenStruct.new(label: I18n.t("mou_signatures.index.agreement_type.crown"), value: "crown"),
- OpenStruct.new(label: I18n.t("mou_signatures.index.agreement_type.non_crown"), value: "non_crown"),
+ OpenStruct.new(label: I18n.t("mou_signatures.agreement_type.crown"), value: "crown"),
+ OpenStruct.new(label: I18n.t("mou_signatures.agreement_type.non_crown"), value: "non_crown"),
OpenStruct.new(label: I18n.t("organisations.index.filter.agreement_type.signed"), value: "signed"),
OpenStruct.new(label: I18n.t("organisations.index.filter.agreement_type.none"), value: "none"),
]
diff --git a/app/policies/mou_signature_policy.rb b/app/policies/mou_signature_policy.rb
deleted file mode 100644
index 420c8530bf..0000000000
--- a/app/policies/mou_signature_policy.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class MouSignaturePolicy < ApplicationPolicy
- def can_manage_mous?
- user.super_admin?
- end
-end
diff --git a/app/services/navigation_items_service.rb b/app/services/navigation_items_service.rb
index 304c44dd66..f80273c047 100644
--- a/app/services/navigation_items_service.rb
+++ b/app/services/navigation_items_service.rb
@@ -22,7 +22,6 @@ def navigation_items
navigation_items = [
your_groups_navigation_item,
- mou_navigation_item,
users_navigation_item,
organisations_navigation_item,
reports_navigation_item,
@@ -42,12 +41,6 @@ def your_groups_navigation_item
NavigationItem.new(text: I18n.t("header.your_groups"), href: "/", active: false)
end
- def mou_navigation_item
- return nil unless should_show_mous_link?
-
- NavigationItem.new(text: I18n.t("header.mous"), href: mou_signatures_path, active: false)
- end
-
def users_navigation_item
return nil unless should_show_user_profile_link?
@@ -96,10 +89,6 @@ def should_show_user_profile_link?
Pundit.policy(user, :user).can_manage_user?
end
- def should_show_mous_link?
- Pundit.policy(user, :mou_signature).can_manage_mous?
- end
-
def should_show_organisations_link?
Pundit.policy(user, :organisation).can_view_organisations?
end
diff --git a/app/views/mou_signatures/index.html.erb b/app/views/mou_signatures/index.html.erb
deleted file mode 100644
index 94a26d061b..0000000000
--- a/app/views/mou_signatures/index.html.erb
+++ /dev/null
@@ -1,42 +0,0 @@
-<% set_page_title(t("page_titles.mou_signatures")) %>
-
<%= t("page_titles.mou_signatures") %>
-
-
- <%= t("mou_signatures.index.preamble_html") %>
-
- <%= t("mou_signatures.index.share_mou_link_html", mou_link: link_to(mou_signature_url, mou_signature_url)) %>
-
- <%= t("mou_signatures.index.share_non_crown_agreement_link_html", agreement_link: link_to(non_crown_agreement_signature_url, non_crown_agreement_signature_url)) %>
-
-
-<% if mou_signatures.any? %>
- <%= render ScrollingWrapperComponent::View.new(aria_label: t("mou_signatures.index.table_caption")) do |table| %>
- <%= govuk_table do |table| %>
- <%= table.with_caption(size: 'm', text: t("mou_signatures.index.table_caption")) %>
-
- <%= table.with_head do |head|
- head.with_row do |row|
- row.with_cell(header: true, text: t("mou_signatures.index.table_headings.agreement_type"))
- row.with_cell(header: true, text: t("mou_signatures.index.table_headings.name"))
- row.with_cell(header: true, text: t("mou_signatures.index.table_headings.email"))
- row.with_cell(header: true, text: t("mou_signatures.index.table_headings.organisation"))
- row.with_cell(header: true, text: t("mou_signatures.index.table_headings.agreed_at"))
- end
- end %>
-
- <%= table.with_body do |body|
- mou_signatures.each do |mou_signature|
- body.with_row do |row|
- row.with_cell(text: t("mou_signatures.index.agreement_type.#{mou_signature.agreement_type}"))
- row.with_cell(text: mou_signature.user.name.presence || t("users.index.name_blank"))
- row.with_cell do
- govuk_link_to(mou_signature.user.email, edit_user_path(mou_signature.user))
- end
- row.with_cell(text: mou_signature.organisation&.name.presence || t("users.index.organisation_blank"))
- row.with_cell(text: l(mou_signature.created_at.to_date, :format => :long))
- end
- end
- end %>
- <% end %>
- <% end %>
-<% end %>
diff --git a/app/views/organisations/index.html.erb b/app/views/organisations/index.html.erb
index dcbcf7a618..c1f553fb56 100644
--- a/app/views/organisations/index.html.erb
+++ b/app/views/organisations/index.html.erb
@@ -73,7 +73,7 @@
row.with_cell(text: @form_counts.fetch(organisation.id, 0).to_s, numeric: true)
agreement_types = @agreement_types.fetch(organisation.id, [])
if agreement_types.any?
- row.with_cell(text: agreement_types.map { |agreement_type| t("mou_signatures.index.agreement_type.#{agreement_type}") }.join(", "))
+ row.with_cell(text: agreement_types.map { |agreement_type| t("mou_signatures.agreement_type.#{agreement_type}") }.join(", "))
else
row.with_cell(text: t("organisations.index.agreement_type_none"))
end
diff --git a/app/views/organisations/show.html.erb b/app/views/organisations/show.html.erb
index ad3938560b..0878ec94da 100644
--- a/app/views/organisations/show.html.erb
+++ b/app/views/organisations/show.html.erb
@@ -64,17 +64,17 @@
<%= govuk_table do |table| %>
<%= table.with_head do |head|
head.with_row do |row|
- row.with_cell(header: true, text: t("mou_signatures.index.table_headings.agreement_type"))
- row.with_cell(header: true, text: t("mou_signatures.index.table_headings.name"))
- row.with_cell(header: true, text: t("mou_signatures.index.table_headings.email"))
- row.with_cell(header: true, text: t("mou_signatures.index.table_headings.agreed_at"))
+ row.with_cell(header: true, text: t("organisations.show.mou_signatures.table_headings.agreement_type"))
+ row.with_cell(header: true, text: t("organisations.show.mou_signatures.table_headings.name"))
+ row.with_cell(header: true, text: t("organisations.show.mou_signatures.table_headings.email"))
+ row.with_cell(header: true, text: t("organisations.show.mou_signatures.table_headings.agreed_at"))
end
end %>
<%= table.with_body do |body|
@organisation.mou_signatures.each do |mou_signature|
body.with_row do |row|
- row.with_cell(text: t("mou_signatures.index.agreement_type.#{mou_signature.agreement_type}"))
+ row.with_cell(text: t("mou_signatures.agreement_type.#{mou_signature.agreement_type}"))
row.with_cell(text: mou_signature.user.name.presence || t("users.index.name_blank"))
row.with_cell do
govuk_link_to(mou_signature.user.email, edit_user_path(mou_signature.user))
@@ -88,11 +88,11 @@
<% else %>
<%= t("organisations.show.mou_signatures.none") %>
- <%= t("mou_signatures.index.preamble_html") %>
+ <%= t("organisations.show.mou_signatures.preamble_html") %>
- <%= t("mou_signatures.index.share_mou_link_html", mou_link: link_to(mou_signature_url, mou_signature_url)) %>
+ <%= t("organisations.show.mou_signatures.share_mou_link_html", mou_link: link_to(mou_signature_url, mou_signature_url)) %>
- <%= t("mou_signatures.index.share_non_crown_agreement_link_html", agreement_link: link_to(non_crown_agreement_signature_url, non_crown_agreement_signature_url)) %>
+ <%= t("organisations.show.mou_signatures.share_non_crown_agreement_link_html", agreement_link: link_to(non_crown_agreement_signature_url, non_crown_agreement_signature_url)) %>
<% end %>
<%= t("organisations.show.domains.heading") %>
diff --git a/app/views/sitemap/index.html.erb b/app/views/sitemap/index.html.erb
index f18ceb632b..a1686bfec5 100644
--- a/app/views/sitemap/index.html.erb
+++ b/app/views/sitemap/index.html.erb
@@ -20,8 +20,8 @@
<% end %>
-<% if should_show_mous_link %>
- <%= link_to t("page_titles.mou_signatures"), mou_signatures_path %>
+<% if should_show_organisations_link %>
+ <%= link_to t("page_titles.organisations"), organisations_path %>
- <%= link_to t("page_titles.mou_signature_new"), mou_signature_url %>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 127af7259d..0c20676a7d 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -928,7 +928,6 @@ en:
Guidance will be displayed at the top of the page, above your question.
header:
- mous: MOUs
organisations: Organisations
product_name: Forms
reports: Reports
@@ -1427,6 +1426,9 @@ en:
heading_without_dates: Form metrics
percentage: "%{number}%"
mou_signatures:
+ agreement_type:
+ crown: Crown MOU
+ non_crown: Non-crown agreement
confirmation:
crown:
body_html: |
@@ -1436,20 +1438,6 @@ en:
body_html: |
What happens next
We’ll email you with any updates to the agreement that are made in the future.
- index:
- agreement_type:
- crown: Crown MOU
- non_crown: Non-crown agreement
- preamble_html: "Someone from each organisation needs to agree to one of the GOV.UK Forms agreements before an organisation admin can be assigned or any groups upgraded to ‘active’.
\n"
- share_mou_link_html: "For Crown organisations, like government departments and executive agencies, share the Memorandum of Understanding:
%{mou_link}
\n"
- share_non_crown_agreement_link_html: "For non-crown organisations, like local authorities, share the GOV.UK Forms agreement:
%{agreement_link}
\n"
- table_caption: Agreed MOUs and agreements
- table_headings:
- agreed_at: Agreed on
- agreement_type: Agreement type
- email: Email address
- name: Name
- organisation: Organisation
show:
crown:
banner:
@@ -1512,6 +1500,14 @@ en:
mou_signatures:
heading: MOUs and agreements
none: No one has agreed an MOU or agreement for this organisation.
+ preamble_html: "Someone from each organisation needs to agree to one of the GOV.UK Forms agreements before an organisation admin can be assigned or any groups upgraded to ‘active’.
\n"
+ share_mou_link_html: "For Crown organisations, like government departments and executive agencies, share the Memorandum of Understanding:
%{mou_link}
\n"
+ share_non_crown_agreement_link_html: "For non-crown organisations, like local authorities, share the GOV.UK Forms agreement:
%{agreement_link}
\n"
+ table_headings:
+ agreed_at: Agreed on
+ agreement_type: Agreement type
+ email: Email address
+ name: Name
not_set: Not set
summary:
closed: Closed
@@ -1655,7 +1651,6 @@ en:
missing_draft_question: There’s a problem with this page
mou_signature_confirmation: You’ve agreed to the MOU
mou_signature_new: GOV.UK Forms Memorandum of Understanding
- mou_signatures: MOUs and agreements
move_form: Move this form to a different group
name_settings: Ask for a person’s name
new_group: Give your group a name
diff --git a/config/routes.rb b/config/routes.rb
index ed1675a0c9..83cd523d5e 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -215,8 +215,6 @@
resource :contact_for_research, controller: :contact_for_research, only: %i[edit update]
end
- resources :mou_signatures, only: %i[index], path: "mous"
-
resources :organisations, only: %i[index show]
resource :mou_signature, only: %i[new show create], path: "/memorandum-of-understanding", defaults: { agreement_type: :crown }, as: :mou_signature do
diff --git a/spec/components/service_navigation_component/service_navigation_component_preview.rb b/spec/components/service_navigation_component/service_navigation_component_preview.rb
index e79de933cc..511e1e9954 100644
--- a/spec/components/service_navigation_component/service_navigation_component_preview.rb
+++ b/spec/components/service_navigation_component/service_navigation_component_preview.rb
@@ -15,8 +15,8 @@ def with_navigation_links
def with_super_admin_navigation_links
render(ServiceNavigationComponent::View.new(navigation_items: [
{ text: "Your groups", href: "/" },
- { text: "MOUs", href: "/mous" },
{ text: "Users", href: "/users" },
+ { text: "Organisations", href: "/organisations" },
{ text: "Reports", href: "/reports" },
{ text: "Support", href: "/support" },
{ text: "A User", href: nil, classes: ["app-service-navigation__item--featured"] },
diff --git a/spec/factories/models/groups.rb b/spec/factories/models/groups.rb
index 6a38ffdbd8..345c3a7668 100644
--- a/spec/factories/models/groups.rb
+++ b/spec/factories/models/groups.rb
@@ -1,13 +1,13 @@
FactoryBot.define do
factory :group do
sequence(:name) { |n| "Group #{n}" }
- organisation { association :organisation, id: 1, slug: "test-org" }
+ organisation { association :organisation, slug: "test-org" }
creator { association :user, organisation: }
status { :trial }
external_id { SecureRandom.base58(8) }
trait :org_has_org_admin do
- organisation { association :organisation, :with_org_admin, id: 1, slug: "test-org" }
+ organisation { association :organisation, :with_org_admin, slug: "test-org" }
end
end
end
diff --git a/spec/factories/models/memberships.rb b/spec/factories/models/memberships.rb
index c414e53882..38882f117d 100644
--- a/spec/factories/models/memberships.rb
+++ b/spec/factories/models/memberships.rb
@@ -1,7 +1,7 @@
FactoryBot.define do
factory :membership do
user
- group
+ group { association :group, organisation: user&.organisation }
added_by { association :user }
role { :editor }
end
diff --git a/spec/factories/models/organisation_domains.rb b/spec/factories/models/organisation_domains.rb
index 1ac40d7b58..071834ecb8 100644
--- a/spec/factories/models/organisation_domains.rb
+++ b/spec/factories/models/organisation_domains.rb
@@ -1,6 +1,6 @@
FactoryBot.define do
factory :organisation_domain do
- organisation { association :organisation, id: 1, slug: "test-org" }
+ organisation { association :organisation, slug: "test-org" }
domain { Faker::Internet.domain_name }
end
end
diff --git a/spec/factories/models/users.rb b/spec/factories/models/users.rb
index 86f5cd40c9..aa2c5bb912 100644
--- a/spec/factories/models/users.rb
+++ b/spec/factories/models/users.rb
@@ -26,10 +26,10 @@
org_has_signed_mou
end
- organisation { association :organisation, id: 1, slug: "test-org" }
+ organisation { association :organisation, slug: "test-org" }
trait :org_has_signed_mou do
- organisation { association :organisation, :with_signed_mou, id: 1, slug: "test-org" }
+ organisation { association :organisation, :with_signed_mou, slug: "test-org" }
end
after(:build) do |user|
diff --git a/spec/features/form/super_admin_view_forms_spec.rb b/spec/features/form/super_admin_view_forms_spec.rb
index 560d6f98b8..5004566bc1 100644
--- a/spec/features/form/super_admin_view_forms_spec.rb
+++ b/spec/features/form/super_admin_view_forms_spec.rb
@@ -2,7 +2,7 @@
feature "View forms", type: :feature do
let(:org_forms) { [build(:form, id: 1, name: "Org form")] }
- let(:other_org) { create :organisation, id: 2, slug: "Other org" }
+ let(:other_org) { create :organisation, slug: "Other org" }
let(:other_org_user) { create :user, organisation: other_org }
let(:other_org_forms) { [build(:form, id: 2, name: "Other org form")] }
let(:other_org_group) { create :group, organisation_id: other_org.id }
diff --git a/spec/features/mou/upgrade_user_changes_mou_spec.rb b/spec/features/mou/upgrade_user_changes_mou_spec.rb
deleted file mode 100644
index 5adf9b31b2..0000000000
--- a/spec/features/mou/upgrade_user_changes_mou_spec.rb
+++ /dev/null
@@ -1,50 +0,0 @@
-require "rails_helper"
-
-describe "Assign an organisation to a user with a signed MOU", type: :feature do
- let(:user) { create :user, name: "Test User", organisation: nil }
- let!(:mou_signature) { create(:mou_signature, user:, organisation: nil, created_at: Time.zone.parse("September 1, 2023")) }
- let(:organisation) { create :organisation }
-
- it "a logged in user can sign an MOU" do
- login_as_super_admin_user
- when_i_visit_the_mou_index_page
- then_i_can_see_the_mou_page
- then_i_see_the_mou_with_no_organisation
- then_i_visit_the_users_page
- then_i_update_the_user_organisation
- when_i_visit_the_mou_index_page
- then_i_can_see_the_mou_page
- then_i_see_the_mou_with_organisation
- end
-
-private
-
- def when_i_visit_the_mou_index_page
- visit mou_signatures_path
- end
-
- def then_i_can_see_the_mou_page
- expect(page).to have_text "MOUs and agreements"
- end
-
- def then_i_see_the_mou_with_no_organisation
- expect(page).to have_text mou_signature.user.name
- expect(page).to have_text mou_signature.user.email
- expect(page).to have_text "No organisation"
- end
-
- def then_i_visit_the_users_page
- click_link mou_signature.user.email
- end
-
- def then_i_update_the_user_organisation
- fill_in "Organisation", with: "#{organisation.name}\n"
- click_button "Save"
- sleep 1
- end
-
- def then_i_see_the_mou_with_organisation
- expect(page).to have_text mou_signature.user.name
- expect(page).to have_text organisation.name
- end
-end
diff --git a/spec/features/mou/view_signed_mous_spec.rb b/spec/features/mou/view_signed_mous_spec.rb
deleted file mode 100644
index cb4773617e..0000000000
--- a/spec/features/mou/view_signed_mous_spec.rb
+++ /dev/null
@@ -1,42 +0,0 @@
-require "rails_helper"
-
-describe "Check which MOUs have been signed", type: :feature do
- let(:user) { super_admin_user }
- let!(:mou_signatures) do
- [create(:mou_signature, created_at: Time.zone.parse("October 12, 2023")),
- create(:mou_signature, created_at: Time.zone.parse("September 1, 2023"))]
- end
-
- before do
- login_as_super_admin_user
- end
-
- it "super_admin's can see the MOUs page" do
- then_i_click_on_the_mou_link
- then_i_can_see_the_mou_page
- then_i_can_see_the_mou_list
- end
-
-private
-
- def then_i_can_see_the_mou_list
- expect(page).to have_text mou_signatures.first.organisation.name
- expect(page).to have_link mou_signatures.first.user.email
- expect(page).to have_text mou_signatures.first.user.name
- expect(page).to have_text "October 12, 2023"
-
- expect(page).to have_text mou_signatures.second.organisation.name
- expect(page).to have_link mou_signatures.second.user.email
- expect(page).to have_text mou_signatures.second.user.name
- expect(page).to have_text "September 01, 2023"
- end
-
- def then_i_click_on_the_mou_link
- visit root_path
- click_link("MOUs")
- end
-
- def then_i_can_see_the_mou_page
- expect(page).to have_text "MOUs and agreements"
- end
-end
diff --git a/spec/features/organisations/upgrade_user_changes_mou_spec.rb b/spec/features/organisations/upgrade_user_changes_mou_spec.rb
new file mode 100644
index 0000000000..5cb5e11089
--- /dev/null
+++ b/spec/features/organisations/upgrade_user_changes_mou_spec.rb
@@ -0,0 +1,39 @@
+require "rails_helper"
+
+describe "Assign an organisation to a user with a signed MOU", type: :feature do
+ let(:user) { create :user, name: "Test User", organisation: nil }
+ let!(:mou_signature) { create(:mou_signature, user:, organisation: nil, created_at: Time.zone.parse("September 1, 2023")) }
+ let!(:organisation) { create :organisation, slug: "department-for-testing" }
+
+ it "assigning an organisation to a user shows their MOU on the organisation's page" do
+ login_as_super_admin_user
+ when_i_update_the_user_organisation
+ and_i_visit_the_organisation_page
+ then_i_can_see_the_mou_for_the_user
+ end
+
+private
+
+ def when_i_update_the_user_organisation
+ visit edit_user_path(user)
+ organisation_field = find_field "Organisation"
+ # The \n is important, it "presses enter" to confirm the autocomplete selection
+ organisation_field.fill_in with: "#{organisation.name}\n"
+ expect(organisation_field.value).to start_with organisation.name
+ click_button "Save"
+ # wait for the save to finish before navigating away, or the form
+ # submission's redirect can clobber the next page visit
+ expect(page).to have_current_path(users_path)
+ end
+
+ def and_i_visit_the_organisation_page
+ visit organisation_path(organisation)
+ end
+
+ def then_i_can_see_the_mou_for_the_user
+ expect(page).to have_text "MOUs and agreements"
+ expect(page).to have_text mou_signature.user.name
+ expect(page).to have_link mou_signature.user.email
+ expect(page).to have_text "September 01, 2023"
+ end
+end
diff --git a/spec/features/organisations/view_signed_mous_spec.rb b/spec/features/organisations/view_signed_mous_spec.rb
new file mode 100644
index 0000000000..3176d309f3
--- /dev/null
+++ b/spec/features/organisations/view_signed_mous_spec.rb
@@ -0,0 +1,35 @@
+require "rails_helper"
+
+describe "View an organisation's signed MOUs", type: :feature do
+ let(:organisation) { create :organisation, slug: "department-for-testing" }
+ let!(:mou_signature) { create(:mou_signature_for_organisation, organisation:, created_at: Time.zone.parse("October 12, 2023")) }
+
+ before do
+ login_as_super_admin_user
+ end
+
+ it "super_admin's can see an organisation's signed MOUs on its page" do
+ when_i_click_on_the_organisations_link
+ and_i_click_on_the_organisation
+ then_i_can_see_the_mou_list
+ end
+
+private
+
+ def when_i_click_on_the_organisations_link
+ visit root_path
+ click_link("Organisations")
+ end
+
+ def and_i_click_on_the_organisation
+ click_link organisation.name_with_abbreviation
+ end
+
+ def then_i_can_see_the_mou_list
+ expect(page).to have_text "MOUs and agreements"
+ expect(page).to have_text "Crown MOU"
+ expect(page).to have_text mou_signature.user.name
+ expect(page).to have_link mou_signature.user.email
+ expect(page).to have_text "October 12, 2023"
+ end
+end
diff --git a/spec/features/users/set_organisation_spec.rb b/spec/features/users/set_organisation_spec.rb
index 0a53270ebf..8dc32cf71c 100644
--- a/spec/features/users/set_organisation_spec.rb
+++ b/spec/features/users/set_organisation_spec.rb
@@ -2,11 +2,11 @@
feature "Set or change a user's organisation", type: :feature do
let!(:test_org) do
- create(:organisation, id: 1, slug: "test-org")
+ create(:organisation, slug: "test-org")
end
before do
- create(:organisation, id: 2, slug: "government-digital-service")
+ create(:organisation, slug: "government-digital-service")
create_list :user, 6, organisation: test_org
login_as_super_admin_user
end
diff --git a/spec/input_objects/organisations/filter_input_spec.rb b/spec/input_objects/organisations/filter_input_spec.rb
index bcf44a8156..0f2c39805a 100644
--- a/spec/input_objects/organisations/filter_input_spec.rb
+++ b/spec/input_objects/organisations/filter_input_spec.rb
@@ -41,8 +41,8 @@
it "returns the correct options" do
expect(described_class.new.agreement_type_options).to eq([
OpenStruct.new(label: I18n.t("organisations.index.filter.agreement_type.any")),
- OpenStruct.new(label: I18n.t("mou_signatures.index.agreement_type.crown"), value: "crown"),
- OpenStruct.new(label: I18n.t("mou_signatures.index.agreement_type.non_crown"), value: "non_crown"),
+ OpenStruct.new(label: I18n.t("mou_signatures.agreement_type.crown"), value: "crown"),
+ OpenStruct.new(label: I18n.t("mou_signatures.agreement_type.non_crown"), value: "non_crown"),
OpenStruct.new(label: I18n.t("organisations.index.filter.agreement_type.signed"), value: "signed"),
OpenStruct.new(label: I18n.t("organisations.index.filter.agreement_type.none"), value: "none"),
])
diff --git a/spec/models/membership_spec.rb b/spec/models/membership_spec.rb
index 8edcf97d6e..6a0af781be 100644
--- a/spec/models/membership_spec.rb
+++ b/spec/models/membership_spec.rb
@@ -26,8 +26,8 @@
end
it "is invalid if the user and group are not in the same organisation" do
- org1 = create :organisation, id: 1, slug: "test-org"
- org2 = create :organisation, id: 2, slug: "ministry-of-testing"
+ org1 = create :organisation, slug: "test-org"
+ org2 = create :organisation, slug: "ministry-of-testing"
user = create :user, organisation: org1
group = create :group, organisation: org2
membership = build(:membership, user:, group:)
@@ -52,7 +52,7 @@
describe ".destroy_invalid_organisation_memberships" do
it "does not remove memberships for the same organisation" do
- org1 = create :organisation, id: 1, slug: "test-org"
+ org1 = create :organisation, slug: "test-org"
user = create :user, organisation: org1
group = create :group, organisation: org1
membership = create(:membership, user:, group:)
@@ -62,8 +62,8 @@
end
it "removes mismatched memberships" do
- org1 = create :organisation, id: 1, slug: "test-org"
- org2 = create :organisation, id: 2, slug: "ministry-of-testing"
+ org1 = create :organisation, slug: "test-org"
+ org2 = create :organisation, slug: "ministry-of-testing"
user = create :user, organisation: org1
group = create :group, organisation: org1
membership = create(:membership, user:, group:)
@@ -74,8 +74,8 @@
end
it "does not remove memberships for other users" do
- org1 = create :organisation, id: 1, slug: "test-org"
- org2 = create :organisation, id: 2, slug: "ministry-of-testing"
+ org1 = create :organisation, slug: "test-org"
+ org2 = create :organisation, slug: "ministry-of-testing"
user1 = create :user, organisation: org1
user2 = create :user, organisation: org1
diff --git a/spec/policies/mou_signature_policy_spec.rb b/spec/policies/mou_signature_policy_spec.rb
deleted file mode 100644
index 75d7cc1062..0000000000
--- a/spec/policies/mou_signature_policy_spec.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-require "rails_helper"
-
-describe MouSignaturePolicy do
- subject(:policy) { described_class.new(user, :mouSignature) }
-
- let(:user) { build :super_admin_user }
-
- context "with super admin" do
- it { is_expected.to permit_actions(%i[can_manage_mous]) }
- end
-
- (User.roles.keys - %w[super_admin]).each do |role|
- context "with #{role}" do
- let(:user) { build :user, role: }
-
- it { is_expected.to forbid_actions(%i[can_manage_mous]) }
- end
- end
-end
diff --git a/spec/requests/forms/change_name_controller_spec.rb b/spec/requests/forms/change_name_controller_spec.rb
index 949fe7011f..0239754dce 100644
--- a/spec/requests/forms/change_name_controller_spec.rb
+++ b/spec/requests/forms/change_name_controller_spec.rb
@@ -2,7 +2,7 @@
RSpec.describe Forms::ChangeNameController, type: :request do
let(:form) { create(:form, name: "Form name", creator_id: 123) }
- let(:organisation) { build :organisation, id: 1, slug: "test-org" }
+ let(:organisation) { build :organisation, slug: "test-org" }
let(:user) { build :user, id: 1, organisation: }
let(:group) { create(:group, organisation: user.organisation) }
diff --git a/spec/requests/forms/submission_email_controller_spec.rb b/spec/requests/forms/submission_email_controller_spec.rb
index e8a3e407bd..5037900c9c 100644
--- a/spec/requests/forms/submission_email_controller_spec.rb
+++ b/spec/requests/forms/submission_email_controller_spec.rb
@@ -3,7 +3,7 @@
RSpec.describe Forms::SubmissionEmailController, type: :request do
include ActionView::Helpers::TextHelper
- let(:organisation) { build :organisation, id: 1, slug: "test-org" }
+ let(:organisation) { build :organisation, slug: "test-org" }
let(:user) { standard_user }
let(:user_outside_group) { build :user, id: 2, organisation: }
diff --git a/spec/requests/groups_controller_spec.rb b/spec/requests/groups_controller_spec.rb
index 1adeb417dd..a3c2fd54b0 100644
--- a/spec/requests/groups_controller_spec.rb
+++ b/spec/requests/groups_controller_spec.rb
@@ -66,7 +66,7 @@
end
end
- let(:other_org) { create :organisation, id: 2, slug: "other-org" }
+ let(:other_org) { create :organisation, slug: "other-org" }
let!(:other_org_trial_groups) { create_list :group, 3, organisation: other_org, status: :trial }
context "when the user is not a super-admin" do
diff --git a/spec/requests/organisations_controller_spec.rb b/spec/requests/organisations_controller_spec.rb
index 505db1445d..43240e7b1b 100644
--- a/spec/requests/organisations_controller_spec.rb
+++ b/spec/requests/organisations_controller_spec.rb
@@ -174,7 +174,7 @@ def organisation_row_order(response)
expect(response.body).to include(organisation.name)
expect(response.body).to include(organisation.slug)
expect(response.body).to include(organisation.admin_users.first.email)
- expect(response.body).to include(I18n.t("mou_signatures.index.agreement_type.#{organisation.mou_signatures.first.agreement_type}"))
+ expect(response.body).to include(I18n.t("mou_signatures.agreement_type.#{organisation.mou_signatures.first.agreement_type}"))
expect(response.body).to include(organisation_domain.domain)
end
end
diff --git a/spec/services/mailchimp/list_sync_service_spec.rb b/spec/services/mailchimp/list_sync_service_spec.rb
index 9f2ed1100f..d974d28cd8 100644
--- a/spec/services/mailchimp/list_sync_service_spec.rb
+++ b/spec/services/mailchimp/list_sync_service_spec.rb
@@ -74,7 +74,7 @@
let(:user_without_access) { create(:user, email: "inactive_user@example.com", has_access: false) }
let(:user_access_and_admin_with_mou) { create(:user, email: "admin_mou_user@example.com") }
- let(:non_crown_org) { create(:organisation, id: 2, slug: "non-crown-org") }
+ let(:non_crown_org) { create(:organisation, slug: "non-crown-org") }
let(:user_that_signed_non_crown_agreement) { create(:user, organisation: non_crown_org) }
let(:not_org_admin_that_signed_non_crown_agreement) { create(:user, organisation: non_crown_org) }
let(:org_admin_for_non_crown_org) { create(:user, organisation: non_crown_org) }
diff --git a/spec/services/navigation_items_service_spec.rb b/spec/services/navigation_items_service_spec.rb
index 2591101cdb..13d8f0401e 100644
--- a/spec/services/navigation_items_service_spec.rb
+++ b/spec/services/navigation_items_service_spec.rb
@@ -19,13 +19,11 @@
context "when user is present" do
let(:can_manage_user) { false }
- let(:can_manage_mous) { false }
let(:can_view_reports) { false }
let(:can_view_organisations) { false }
before do
allow(Pundit).to receive(:policy).with(user, :user).and_return(instance_double(UserPolicy, can_manage_user?: can_manage_user))
- allow(Pundit).to receive(:policy).with(user, :mou_signature).and_return(instance_double(MouSignaturePolicy, can_manage_mous?: can_manage_mous))
allow(Pundit).to receive(:policy).with(user, :report).and_return(instance_double(ReportPolicy, can_view_reports?: can_view_reports))
allow(Pundit).to receive(:policy).with(user, :organisation).and_return(instance_double(OrganisationPolicy, can_view_organisations?: can_view_organisations))
allow(Settings.forms_product_page).to receive(:support_url).and_return(support_url)
@@ -40,15 +38,6 @@
end
end
- context "when user can manage mous" do
- let(:can_manage_mous) { true }
-
- it "includes mous in navigation items" do
- mous_item = NavigationItemsService::NavigationItem.new(text: I18n.t("header.mous"), href: mou_signatures_path, active: false)
- expect(service.navigation_items).to include(mous_item)
- end
- end
-
context "when user can view organisations" do
let(:can_view_organisations) { true }
diff --git a/spec/support/authentication_feature_helpers.rb b/spec/support/authentication_feature_helpers.rb
index e053985d5f..6d20adcf23 100644
--- a/spec/support/authentication_feature_helpers.rb
+++ b/spec/support/authentication_feature_helpers.rb
@@ -13,7 +13,7 @@ def login_as(user, opts = {})
end
def test_org
- @test_org ||= FactoryBot.create(:organisation, :with_signed_mou, id: 1, slug: "test-org")
+ @test_org ||= FactoryBot.create(:organisation, :with_signed_mou, slug: "test-org")
end
def super_admin_user
diff --git a/spec/views/groups/index.html.erb_spec.rb b/spec/views/groups/index.html.erb_spec.rb
index adbb1d494f..a9adbfe7fa 100644
--- a/spec/views/groups/index.html.erb_spec.rb
+++ b/spec/views/groups/index.html.erb_spec.rb
@@ -109,7 +109,7 @@
context "when the user is a super admin" do
let(:current_user) { build :super_admin_user }
- let(:search_input) { OrganisationSearchInput.new({ organisation_id: current_user.organisation_id }) }
+ let(:search_input) { OrganisationSearchInput.new({ organisation_id: organisation.id }) }
let(:organisation) { current_user.organisation }
before do
diff --git a/spec/views/mou_signatures/index.html.erb_spec.rb b/spec/views/mou_signatures/index.html.erb_spec.rb
deleted file mode 100644
index 623e036f5f..0000000000
--- a/spec/views/mou_signatures/index.html.erb_spec.rb
+++ /dev/null
@@ -1,53 +0,0 @@
-require "rails_helper"
-
-describe "mou_signatures/index.html.erb" do
- let(:mou_signatures) do
- [
- build(:mou_signature, agreement_type: :crown, created_at: Time.zone.parse("October 12, 2023")),
- build(:mou_signature, agreement_type: :non_crown, created_at: Time.zone.parse("October 13, 2023")),
- ]
- end
-
- before do
- render template: "mou_signatures/index", locals: { mou_signatures: }
- end
-
- it "contains page heading" do
- expect(rendered).to have_css("h1.govuk-heading-l", text: I18n.t("page_titles.mou_signatures"))
- end
-
- it "contains a scrollable wrapper with a table in it" do
- expect(rendered).to have_css(".app-scrolling-wrapper > table")
- end
-
- it "contains the agreement type" do
- expect(rendered).to have_xpath "//thead/tr/th[1]", text: I18n.t("mou_signatures.index.table_headings.agreement_type")
- expect(rendered).to have_xpath "//tbody/tr[1]/td[1]", text: I18n.t("mou_signatures.index.agreement_type.crown")
- expect(rendered).to have_xpath "//tbody/tr[2]/td[1]", text: I18n.t("mou_signatures.index.agreement_type.non_crown")
- end
-
- it "contains the user's name" do
- expect(rendered).to have_text(mou_signatures.first.user.name)
- end
-
- it "contains the user's email as a link to the edit page" do
- expect(rendered).to have_link(mou_signatures.first.user.email, href: edit_user_path(mou_signatures.first.user))
- end
-
- it "contains organisation name" do
- expect(rendered).to have_text(mou_signatures.first.user.organisation.name)
- end
-
- it "contains the date the MOU was signed" do
- expect(rendered).to have_text(I18n.l(mou_signatures.first.created_at.to_date, format: :long))
- end
-
- context "when there are no signed MOUs" do
- let(:mou_signatures) { [] }
-
- it "does not show the MOU table" do
- expect(rendered).not_to have_text(I18n.t("mou_signatures.table_caption"))
- expect(rendered).not_to have_css("table")
- end
- end
-end
diff --git a/spec/views/organisations/index.html.erb_spec.rb b/spec/views/organisations/index.html.erb_spec.rb
index 66409b1aa3..7e256c44d4 100644
--- a/spec/views/organisations/index.html.erb_spec.rb
+++ b/spec/views/organisations/index.html.erb_spec.rb
@@ -33,8 +33,8 @@
expect(rendered).to have_field("filter[name]")
expect(rendered).to have_select("filter[agreement_type]", options: [
I18n.t("organisations.index.filter.agreement_type.any"),
- I18n.t("mou_signatures.index.agreement_type.crown"),
- I18n.t("mou_signatures.index.agreement_type.non_crown"),
+ I18n.t("mou_signatures.agreement_type.crown"),
+ I18n.t("mou_signatures.agreement_type.non_crown"),
I18n.t("organisations.index.filter.agreement_type.signed"),
I18n.t("organisations.index.filter.agreement_type.none"),
])
@@ -81,7 +81,7 @@
end
it "shows the agreement type for each organisation" do
- expect(rendered).to have_xpath "//tbody/tr[1]/td[4]", text: I18n.t("mou_signatures.index.agreement_type.crown")
+ expect(rendered).to have_xpath "//tbody/tr[1]/td[4]", text: I18n.t("mou_signatures.agreement_type.crown")
expect(rendered).to have_xpath "//tbody/tr[2]/td[4]", text: I18n.t("organisations.index.agreement_type_none")
end
diff --git a/spec/views/organisations/show.html.erb_spec.rb b/spec/views/organisations/show.html.erb_spec.rb
index b89d161361..dc1a0dd4be 100644
--- a/spec/views/organisations/show.html.erb_spec.rb
+++ b/spec/views/organisations/show.html.erb_spec.rb
@@ -43,7 +43,7 @@
it "lists the MOU signatures" do
mou_signature = organisation.mou_signatures.first
- expect(rendered).to have_text(I18n.t("mou_signatures.index.agreement_type.#{mou_signature.agreement_type}"))
+ expect(rendered).to have_text(I18n.t("mou_signatures.agreement_type.#{mou_signature.agreement_type}"))
expect(rendered).to have_link(mou_signature.user.email, href: edit_user_path(mou_signature.user))
expect(rendered).to have_text(I18n.l(mou_signature.created_at.to_date, format: :long))
end
diff --git a/spec/views/sitemap/index.html.erb_spec.rb b/spec/views/sitemap/index.html.erb_spec.rb
index 604fa066a9..b435b8f3eb 100644
--- a/spec/views/sitemap/index.html.erb_spec.rb
+++ b/spec/views/sitemap/index.html.erb_spec.rb
@@ -1,7 +1,7 @@
require "rails_helper"
describe "sitemap/index.html.erb" do
- let(:locals) { { active_groups: [], trial_groups: [], should_show_users_link: false, should_show_mous_link: false, should_show_reports_link: false } }
+ let(:locals) { { active_groups: [], trial_groups: [], should_show_users_link: false, should_show_organisations_link: false, should_show_reports_link: false } }
def render_template
render template: "sitemap/index", locals:
@@ -59,20 +59,32 @@ def render_template
end
end
- context "when the should_show_mous_link is true" do
- let(:locals) { super().merge(should_show_mous_link: true) }
+ context "when the should_show_organisations_link is true" do
+ let(:locals) { super().merge(should_show_organisations_link: true) }
- it "includes a link to the MOUs page" do
+ it "includes a link to the organisations page" do
+ render_template
+
+ expect(rendered).to have_link("Organisations", href: organisations_path)
+ end
+
+ it "includes a link to the MOU signing page" do
render_template
expect(rendered).to have_link("Memorandum of Understanding", href: mou_signature_url)
end
end
- context "when should_show_mous_link is false" do
- let(:locals) { super().merge(should_show_mous_link: false) }
+ context "when should_show_organisations_link is false" do
+ let(:locals) { super().merge(should_show_organisations_link: false) }
+
+ it "does not include a link to the organisations page" do
+ render_template
+
+ expect(rendered).not_to have_link("Organisations")
+ end
- it "does not include a link to the MOUs page" do
+ it "does not include a link to the MOU signing page" do
render_template
expect(rendered).not_to have_link("Memorandum of Understanding")
diff --git a/spec/views/users/edit.html.erb_spec.rb b/spec/views/users/edit.html.erb_spec.rb
index b9cace5210..af603fa968 100644
--- a/spec/views/users/edit.html.erb_spec.rb
+++ b/spec/views/users/edit.html.erb_spec.rb
@@ -1,20 +1,20 @@
require "rails_helper"
describe "users/edit.html.erb" do
+ let(:organisation) { create :organisation, slug: "test-org" }
let(:user) do
build(
:user,
id: 1,
- organisation_id: 1,
+ organisation:,
created_at: Time.zone.local(2023, 10, 16, 13, 24),
last_signed_in_at: Time.zone.now,
)
end
before do
- create :organisation, id: 1, slug: "test-org"
- create :organisation, id: 2, slug: "ministry-of-testing"
- create :organisation, id: 3, slug: "department-for-tests", name: "Department for Tests", abbreviation: "DfT"
+ create :organisation, slug: "ministry-of-testing"
+ create :organisation, slug: "department-for-tests", name: "Department for Tests", abbreviation: "DfT"
travel_to(Time.zone.local(2024, 8, 26, 11, 50)) do
assign(:user, user)