-
-
- <%= form.govuk_check_box :schools, true, false, label: { text: "Copy placement schools?" }, multiple: false %>
+ <%= form.govuk_check_box :schools, true, false, label: { text: "Copy placement schools?" }, hint: { text: tag.div("Any placement schools that are not already linked to the target provider will not be copied", class: %w[govuk-hint govuk-!-font-size-16]) }, multiple: false %>
+
<%= form.govuk_submit "Continue" %>
diff --git a/spec/requests/support/copy_courses_spec.rb b/spec/requests/support/copy_courses_spec.rb
new file mode 100644
index 0000000000..4b17515d1d
--- /dev/null
+++ b/spec/requests/support/copy_courses_spec.rb
@@ -0,0 +1,41 @@
+# frozen_string_literal: true
+
+require 'rails_helper'
+
+RSpec.describe 'Support::CopyCourses' do
+ include DfESignInUserHelper
+ let(:user) { create(:user, :admin) }
+ let(:source_provider) { create(:provider, courses: create_list(:course, 3, :with_full_time_sites)) }
+ let!(:target_provider) { create(:provider, sites: source_provider.courses.flat_map(&:sites)) }
+ let!(:year) { find_or_create(:recruitment_cycle).year }
+
+ before { host! URI(Settings.base_url).host }
+
+ describe 'GET new' do
+ it 'responds with 200' do
+ login_user(user)
+ get "/support/2025/providers/#{source_provider.id}/copy_courses/new"
+ expect(response).to have_http_status(:ok)
+ end
+ end
+
+ describe 'POST create' do
+ context 'with schools' do
+ it 'copies the courses with schools' do
+ login_user(user)
+ post "/support/#{year}/providers/#{target_provider.id}/copy_courses", params: { 'course[autocompleted_provider_code]' => source_provider.provider_code, schools: '1' }
+ expect(target_provider.reload.courses.length).to eq(3)
+ courses = target_provider.reload.courses
+ expect(courses.flat_map(&:sites).length).to eq(3)
+ end
+ end
+
+ context 'without schools' do
+ it 'copies the course without schools' do
+ login_user(user)
+ post "/support/#{year}/providers/#{target_provider.id}/copy_courses", params: { 'course[autocompleted_provider_code]' => source_provider.provider_code }
+ expect(target_provider.reload.courses.length).to eq(3)
+ end
+ end
+ end
+end
diff --git a/spec/system/support/providers/copy_courses_to_provider_spec.rb b/spec/system/support/providers/copy_courses_to_provider_spec.rb
index 84ca8b0605..d2bde1704a 100644
--- a/spec/system/support/providers/copy_courses_to_provider_spec.rb
+++ b/spec/system/support/providers/copy_courses_to_provider_spec.rb
@@ -12,17 +12,15 @@
create(:course, :withdrawn, :with_full_time_sites)
]
end
- let(:source_provider) { create(:provider, provider_name: 'Source Provider', courses:) }
- let(:target_provider) { create(:provider, provider_name: 'Target Provider') }
+ let!(:source_provider) { create(:provider, provider_name: 'Source Provider', courses:) }
+ let!(:target_provider) { create(:provider, provider_name: 'Target Provider') }
let(:user) { create(:user, :admin) }
before do
sign_in_system_test(user:)
- source_provider
- target_provider
end
- it 'copy courses from one provider to another', :js_browser do
+ it 'copy courses from one provider to another', :js do
visit '/support'
click_on 'Target Provider'
click_on 'Copy Courses'
@@ -31,7 +29,7 @@
sleep 3
li = page.find('ul#provider__listbox li', visible: false)
li.click
- page.find_by_id('sites-true-field', visible: false).click
+ page.find_by_id('schools-true-field', visible: false).click
click_on 'Continue'
click_on 'Courses'
courses.map(&:name).each do |course_name|