-
Notifications
You must be signed in to change notification settings - Fork 898
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Redirect tasks subcollection to request_tasks #15357
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -192,4 +192,40 @@ | |
expect(response).to have_http_status(:ok) | ||
end | ||
end | ||
|
||
context 'Tasks subcollection' do | ||
let(:automation_request) { FactoryGirl.create(:automation_request) } | ||
|
||
it 'redirects to request_tasks subcollection' do | ||
task = FactoryGirl.create(:miq_request_task, :miq_request_id => automation_request.id) | ||
api_basic_authorize | ||
|
||
run_get("#{automation_requests_url(automation_request.id)}/tasks") | ||
|
||
expect(response).to have_http_status(:moved_permanently) | ||
expect(response.redirect?).to be_truthy | ||
expect(response.redirect_url).to include("#{automation_requests_url(automation_request.id)}/request_tasks") | ||
|
||
run_get response.redirect_url, :expand => :resources | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Although I like the idea of testing the whole flow of being redirected in this test, on the flip side this could also be a test duplication. I think we could assume that this subsequent request will do the right thing, especially if it is tested elsewhere (assuming it is). So I'm not sure this extra check is necessary. WDYT? |
||
|
||
expect(response).to have_http_status(:ok) | ||
expect(response.parsed_body['resources'].first['id']).to eq(task.id) | ||
end | ||
|
||
it 'redirects to request_tasks subresources' do | ||
task = FactoryGirl.create(:miq_request_task, :miq_request_id => automation_request.id) | ||
api_basic_authorize | ||
|
||
run_get("#{automation_requests_url(automation_request.id)}/tasks/#{task.id}") | ||
|
||
expect(response).to have_http_status(:moved_permanently) | ||
expect(response.redirect?).to be_truthy | ||
expect(response.redirect_url).to include("#{automation_requests_url(automation_request.id)}/request_tasks/#{task.id}") | ||
|
||
run_get response.redirect_url | ||
|
||
expect(response).to have_http_status(:ok) | ||
expect(response.parsed_body['id']).to eq(task.id) | ||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this expectation is redundant - the one above checks that it is a 301, this one checks that it is in the set of many redirect codes