Skip to content
Snippets Groups Projects
Commit 67d264f6 authored by Douglas AC's avatar Douglas AC
Browse files

Testing request "/v1/complaints/:id/show_related".

parent 7cb38e88
No related branches found
No related tags found
No related merge requests found
......@@ -33,7 +33,7 @@ resource 'Complaints' do
create(:learning_object)
}
}
let(:complaints) { Complaint.all }
let(:complaint_reasons) { ComplaintReason.all }
let(:learning_objects) { LearningObject.all }
......@@ -64,6 +64,18 @@ resource 'Complaints' do
end
end
get '/v1/complaints/:id/show_related' do
include_context "authenticate_user_editor"
let(:id) { Complaint.first.id }
example_request 'show all complaints whtih the same complainable as the infomed id' do
expect(JSON.parse(response_body).map { |o| o['id'] }.sort).to eq(Complaint.where(complainable: Complaint.first.complainable, state: "complained").pluck(:id).sort)
expect(status).to eq(200)
end
end
post '/v1/complaints' do
include_context 'authenticate_user'
......@@ -112,6 +124,21 @@ resource 'Complaints' do
end
end
post '/v1/complaints/:id/treat_related' do
include_context "authenticate_user_editor"
parameter :complaints, 'group of complaints related to to one Object'
parameter :option, 'Inform the final sentence to the related Object that the complaints are directed to.'
let(:id) { Complaint.where(complainable_type: "User", state: "complained").first.complainable_id}
let(:complaints){ [{id: Complaint.where(complainable_type: "User", state: "complained").first.id, state: "accept"}] }
let(:option) { "blocked" }
let(:raw_post) { params.to_json }
example_request 'Treat all pendent complaints related to the complainable indicated by the id' do
expect(status).to eq(200)
end
end
get '/v1/complaints' do
include_context "authenticate_user_editor"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment