Skip to content

Commit 079534e

Browse files
committed
adding tests for show remix identifier
1 parent 0c95767 commit 079534e

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

spec/requests/projects/remix_spec.rb

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,35 @@
7070
end
7171
end
7272

73+
describe("#show_identifier") do
74+
let!(:remixed_project) do
75+
create(:project, remixed_from_id: original_project.id, user_id: authenticated_user.id)
76+
end
77+
78+
it 'returns success response' do
79+
get("/api/projects/#{original_project.identifier}/remix/identifier", headers:)
80+
expect(response).to have_http_status(:ok)
81+
end
82+
83+
it 'returns the project identifier' do
84+
get("/api/projects/#{original_project.identifier}/remix/identifier", headers:)
85+
expect(response.parsed_body['identifier']).to eq(remixed_project.identifier)
86+
end
87+
88+
it 'returns 404 response if invalid project' do
89+
get('/api/projects/no-such-project/remix/identifier', headers:)
90+
expect(response).to have_http_status(:not_found)
91+
end
92+
93+
it 'returns 404 if no remixed project for user' do
94+
another_user = create(:owner, school:)
95+
authenticated_in_hydra_as(another_user)
96+
97+
get("/api/projects/#{original_project.identifier}/remix/identifier", headers:)
98+
expect(response).to have_http_status(:not_found)
99+
end
100+
end
101+
73102
describe '#create' do
74103
it 'returns success response' do
75104
post("/api/projects/#{original_project.identifier}/remix", params: { project: project_params }, headers:)
@@ -116,6 +145,13 @@
116145
end
117146
end
118147

148+
describe '#show_identifier' do
149+
it 'returns unauthorized' do
150+
get "/api/projects/#{original_project.identifier}/remix/identifier"
151+
expect(response).to have_http_status(:unauthorized)
152+
end
153+
end
154+
119155
describe '#create' do
120156
it 'returns unauthorized' do
121157
post "/api/projects/#{original_project.identifier}/remix"

0 commit comments

Comments
 (0)