|
5 | 5 | RSpec.describe 'Updating a project', type: :request do |
6 | 6 | let(:headers) { { Authorization: UserProfileMock::TOKEN } } |
7 | 7 | let(:locale) { 'en' } |
8 | | - let!(:project) { create(:project, name: 'Test Project', user_id: owner.id, locale:) } |
| 8 | + let(:project_type) { Project::Types::PYTHON } |
| 9 | + let!(:project) { create(:project, name: 'Test Project', user_id: owner.id, locale:, project_type:) } |
9 | 10 | let(:owner) { create(:owner, school:) } |
10 | 11 | let(:school) { create(:school) } |
11 | 12 |
|
|
77 | 78 | expect(response).to have_http_status(:not_found) |
78 | 79 | end |
79 | 80 | end |
| 81 | + |
| 82 | + context 'when the user is an Experience CS admin and project type is scratch' do |
| 83 | + let(:experience_cs_admin) { create(:experience_cs_admin_user) } |
| 84 | + let(:project_type) { Project::Types::SCRATCH } |
| 85 | + let(:params) do |
| 86 | + { |
| 87 | + project: { |
| 88 | + identifier: 'test-project', |
| 89 | + name: 'Test Project', |
| 90 | + locale: 'fr', |
| 91 | + project_type: Project::Types::SCRATCH, |
| 92 | + user_id: nil, |
| 93 | + components: [] |
| 94 | + } |
| 95 | + } |
| 96 | + end |
| 97 | + |
| 98 | + before do |
| 99 | + authenticated_in_hydra_as(experience_cs_admin) |
| 100 | + end |
| 101 | + |
| 102 | + it 'responds 200 OK' do |
| 103 | + put("/api/projects/#{project.identifier}?project_type=scratch", headers:, params:) |
| 104 | + expect(response).to have_http_status(:success) |
| 105 | + end |
| 106 | + |
| 107 | + it 'sets the project name to the specified value' do |
| 108 | + put("/api/projects/#{project.identifier}?project_type=scratch", headers:, params:) |
| 109 | + data = JSON.parse(response.body, symbolize_names: true) |
| 110 | + |
| 111 | + expect(data[:name]).to eq('Test Project') |
| 112 | + end |
| 113 | + end |
80 | 114 | end |
0 commit comments