|
20 | 20 | let(:project_json) do
|
21 | 21 | {
|
22 | 22 | identifier: project.identifier,
|
23 |
| - project_type: 'python', |
| 23 | + project_type: Project::Types::PYTHON, |
24 | 24 | locale: project.locale,
|
25 | 25 | name: project.name,
|
26 | 26 | user_id: project.user_id,
|
|
62 | 62 | let(:student_project_json) do
|
63 | 63 | {
|
64 | 64 | identifier: student_project.identifier,
|
65 |
| - project_type: 'python', |
| 65 | + project_type: Project::Types::PYTHON, |
66 | 66 | locale: student_project.locale,
|
67 | 67 | name: student_project.name,
|
68 | 68 | user_id: student_project.user_id,
|
|
102 | 102 | let(:another_teacher_project_json) do
|
103 | 103 | {
|
104 | 104 | identifier: another_teacher_project.identifier,
|
105 |
| - project_type: 'python', |
| 105 | + project_type: Project::Types::PYTHON, |
106 | 106 | locale: another_teacher_project.locale,
|
107 | 107 | name: another_teacher_project.name,
|
108 | 108 | user_id: teacher.id,
|
|
130 | 130 | let(:another_project_json) do
|
131 | 131 | {
|
132 | 132 | identifier: another_project.identifier,
|
133 |
| - project_type: 'python', |
| 133 | + project_type: Project::Types::PYTHON, |
134 | 134 | name: another_project.name,
|
135 | 135 | locale: another_project.locale,
|
136 | 136 | user_id: another_project.user_id,
|
|
156 | 156 |
|
157 | 157 | context 'when user is not logged in' do
|
158 | 158 | context 'when loading a starter project' do
|
159 |
| - let!(:starter_project) { create(:project, user_id: nil, locale: 'ja-JP') } |
| 159 | + let(:project_type) { Project::Types::PYTHON } |
| 160 | + let!(:starter_project) { create(:project, user_id: nil, locale: 'ja-JP', project_type:) } |
160 | 161 | let(:starter_project_json) do
|
161 | 162 | {
|
162 | 163 | identifier: starter_project.identifier,
|
163 |
| - project_type: 'python', |
| 164 | + project_type:, |
164 | 165 | locale: starter_project.locale,
|
165 | 166 | name: starter_project.name,
|
166 | 167 | user_id: starter_project.user_id,
|
|
192 | 193 | expect(response).to have_http_status(:not_found)
|
193 | 194 | end
|
194 | 195 |
|
| 196 | + context 'when project is a scratch project' do |
| 197 | + let(:project_type) { Project::Types::SCRATCH } |
| 198 | + |
| 199 | + context 'when project_type is set to scratch in query params' do |
| 200 | + before do |
| 201 | + get("/api/projects/#{starter_project.identifier}?locale=#{starter_project.locale}&project_type=scratch", headers:) |
| 202 | + end |
| 203 | + |
| 204 | + it 'returns success response' do |
| 205 | + expect(response).to have_http_status(:ok) |
| 206 | + end |
| 207 | + |
| 208 | + it 'returns json' do |
| 209 | + expect(response.content_type).to eq('application/json; charset=utf-8') |
| 210 | + end |
| 211 | + |
| 212 | + it 'returns the project json' do |
| 213 | + expect(response.body).to eq(starter_project_json) |
| 214 | + end |
| 215 | + end |
| 216 | + |
| 217 | + it 'returns 404 response if scratch project' do |
| 218 | + get("/api/projects/#{starter_project.identifier}?locale=#{starter_project.locale}", headers:) |
| 219 | + expect(response).to have_http_status(:not_found) |
| 220 | + end |
| 221 | + end |
| 222 | + |
195 | 223 | it 'creates a new ProjectLoader with the correct parameters' do
|
196 | 224 | allow(ProjectLoader).to receive(:new).and_call_original
|
197 | 225 | get("/api/projects/#{starter_project.identifier}?locale=#{starter_project.locale}", headers:)
|
|
205 | 233 | let(:project_json) do
|
206 | 234 | {
|
207 | 235 | identifier: project.identifier,
|
208 |
| - project_type: 'python', |
| 236 | + project_type: Project::Types::PYTHON, |
209 | 237 | locale: project.locale,
|
210 | 238 | name: project.name,
|
211 | 239 | user_id: project.user_id,
|
|
0 commit comments