|
6 | 6 | before do
|
7 | 7 | authenticated_in_hydra_as(owner)
|
8 | 8 | stub_profile_api_create_school_student
|
| 9 | + stub_profile_api_create_safeguarding_flag |
9 | 10 | end
|
10 | 11 |
|
11 | 12 | let(:headers) { { Authorization: UserProfileMock::TOKEN } }
|
|
15 | 16 |
|
16 | 17 | let(:file) { fixture_file_upload('students.csv') }
|
17 | 18 |
|
| 19 | + it 'creates the school owner safeguarding flag' do |
| 20 | + post("/api/schools/#{school.id}/students/batch", headers:, params: { file: }) |
| 21 | + expect(ProfileApiClient).to have_received(:create_safeguarding_flag).with(token: UserProfileMock::TOKEN, flag: ProfileApiClient::SAFEGUARDING_FLAGS[:owner]) |
| 22 | + end |
| 23 | + |
| 24 | + it 'does not create the school teacher safeguarding flag' do |
| 25 | + post("/api/schools/#{school.id}/students/batch", headers:, params: { file: }) |
| 26 | + expect(ProfileApiClient).not_to have_received(:create_safeguarding_flag).with(token: UserProfileMock::TOKEN, flag: ProfileApiClient::SAFEGUARDING_FLAGS[:teacher]) |
| 27 | + end |
| 28 | + |
18 | 29 | it 'responds 204 No Content' do
|
19 | 30 | post("/api/schools/#{school.id}/students/batch", headers:, params: { file: })
|
20 | 31 | expect(response).to have_http_status(:no_content)
|
|
28 | 39 | expect(response).to have_http_status(:no_content)
|
29 | 40 | end
|
30 | 41 |
|
| 42 | + it 'does not createt the school owner safeguarding flag when the user is a school-teacher' do |
| 43 | + teacher = create(:teacher, school:) |
| 44 | + authenticated_in_hydra_as(teacher) |
| 45 | + |
| 46 | + post("/api/schools/#{school.id}/students/batch", headers:, params: { file: }) |
| 47 | + expect(ProfileApiClient).not_to have_received(:create_safeguarding_flag).with(token: UserProfileMock::TOKEN, flag: ProfileApiClient::SAFEGUARDING_FLAGS[:owner]) |
| 48 | + end |
| 49 | + |
| 50 | + it 'does not create the school teacher safeguarding flag when the user is a school-teacher' do |
| 51 | + teacher = create(:teacher, school:) |
| 52 | + authenticated_in_hydra_as(teacher) |
| 53 | + |
| 54 | + post("/api/schools/#{school.id}/students/batch", headers:, params: { file: }) |
| 55 | + expect(ProfileApiClient).to have_received(:create_safeguarding_flag).with(token: UserProfileMock::TOKEN, flag: ProfileApiClient::SAFEGUARDING_FLAGS[:teacher]) |
| 56 | + end |
| 57 | + |
31 | 58 | it 'responds 422 Unprocessable Entity when params are invalid' do
|
32 | 59 | post("/api/schools/#{school.id}/students/batch", headers:, params: {})
|
33 | 60 | expect(response).to have_http_status(:unprocessable_entity)
|
|
0 commit comments