Skip to content
Snippets Groups Projects
Commit 86952972 authored by Giovanne Marcelo's avatar Giovanne Marcelo
Browse files

add create complaints test

parent 4180abbb
No related branches found
No related tags found
No related merge requests found
......@@ -4,9 +4,17 @@ resource 'Complaints' do
header 'Accept', 'application/json'
header 'Content-Type', 'application/json'
before { 12.times { create(:complaint) } }
before {
12.times {
create(:complaint)
create(:complaint_reason)
create(:learning_object)
}
}
let(:complaints) { Complaint.all }
let(:complaint_reasons) { ComplaintReason.all }
let(:learning_objects) { LearningObject.all }
get '/v1/complaints' do
parameter :limit, 'Limit of complaints'
......@@ -22,4 +30,29 @@ resource 'Complaints' do
end
end
post '/v1/complaints' do
include_context 'authenticate_user'
parameter :user_id, 'The id of user', scope: :complaint
parameter :description, 'The description of the complaint', scope: :complaint
parameter :complainable_id, 'The id of the complainable [LearningObject, Review, User, Collection]', scope: :complaint
parameter :complainable_type, 'Represents a type of the complainable [LearningObject, Review, User, Collection]', scope: :complaint
parameter :complaint_reason_id, 'Id of the reason of the complaint', scope: :complaint
let(:user_id) { @user.id }
let(:description) { Faker::Lorem::sentence }
let(:complainable_id) { learning_objects.first.id }
let(:complainable_type) { "LearningObject" }
let(:complaint_reason_id) { complaint_reasons.first.id }
let(:raw_post) { params.to_json }
example_request 'Creating a complaint' do
expect(status).to eq(201)
end
end
end
FactoryGirl.define do
factory :complaint_reason do
reason { Faker::Lorem.paragraph }
reason { Faker::Lorem.sentence }
end
end
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