-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
51 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters