|
3 | 3 | require 'rails_helper'
|
4 | 4 |
|
5 | 5 | RSpec.describe 'Remix requests' do
|
6 |
| - let!(:original_project) { create(:project) } |
| 6 | + let!(:original_project) { create(:project, project_type: original_project_type) } |
| 7 | + let(:original_project_type) { Project::Types::PYTHON } |
7 | 8 | let(:project_params) do
|
8 | 9 | {
|
9 | 10 | name: original_project.name,
|
|
53 | 54 | end
|
54 | 55 |
|
55 | 56 | describe '#show' do
|
| 57 | + let(:project_type) { Project::Types::PYTHON } |
| 58 | + |
56 | 59 | before do
|
57 |
| - create(:project, remixed_from_id: original_project.id, user_id: authenticated_user.id) |
| 60 | + create(:project, remixed_from_id: original_project.id, user_id: authenticated_user.id, project_type:) |
58 | 61 | end
|
59 | 62 |
|
60 | 63 | it 'returns success response' do
|
|
68 | 71 |
|
69 | 72 | expect(response).to have_http_status(:not_found)
|
70 | 73 | end
|
| 74 | + |
| 75 | + context 'when original project and remix are scratch projects' do |
| 76 | + let(:original_project_type) { Project::Types::SCRATCH } |
| 77 | + let(:project_type) { Project::Types::SCRATCH } |
| 78 | + |
| 79 | + it 'returns 404 response if scratch projects are not explicitly included' do |
| 80 | + get("/api/projects/#{original_project.identifier}/remix", headers:) |
| 81 | + |
| 82 | + expect(response).to have_http_status(:not_found) |
| 83 | + end |
| 84 | + |
| 85 | + it 'returns success response if scratch projects are explicitly included' do |
| 86 | + get("/api/projects/#{original_project.identifier}/remix?project_type=scratch", headers:) |
| 87 | + |
| 88 | + expect(response).to have_http_status(:ok) |
| 89 | + end |
| 90 | + end |
71 | 91 | end
|
72 | 92 |
|
73 | 93 | describe '#create' do
|
|
104 | 124 | expect(response.body).to eq({ error: 'Something went wrong' }.to_json)
|
105 | 125 | end
|
106 | 126 | end
|
| 127 | + |
| 128 | + context 'when original project is scratch project' do |
| 129 | + let(:original_project_type) { Project::Types::SCRATCH } |
| 130 | + |
| 131 | + it 'returns 404 response if scratch projects are not explicitly included' do |
| 132 | + post("/api/projects/#{original_project.identifier}/remix", params: { project: project_params }, headers:) |
| 133 | + |
| 134 | + expect(response).to have_http_status(:not_found) |
| 135 | + end |
| 136 | + |
| 137 | + it 'returns success response if scratch projects are explicitly included' do |
| 138 | + post("/api/projects/#{original_project.identifier}/remix?project_type=scratch", params: { project: project_params }, headers:) |
| 139 | + |
| 140 | + expect(response).to have_http_status(:ok) |
| 141 | + end |
| 142 | + end |
107 | 143 | end
|
108 | 144 | end
|
109 | 145 |
|
|
0 commit comments