From 7fe84c012a748e9a89176e1e721d7b097c0a17a8 Mon Sep 17 00:00:00 2001 From: Giovanne Marcelo <gms15@inf.ufpr.br> Date: Mon, 6 Mar 2017 11:29:52 -0300 Subject: [PATCH] add create collection test --- spec/acceptance/collections_spec.rb | 32 +++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/spec/acceptance/collections_spec.rb b/spec/acceptance/collections_spec.rb index f669a25e0..a3d636d57 100644 --- a/spec/acceptance/collections_spec.rb +++ b/spec/acceptance/collections_spec.rb @@ -10,6 +10,38 @@ resource 'Collections' do let(:collections) { Collection.all } let(:learning_objects) { LearningObject.all } + let(:_subjects) { Subject.all } + let(:_educational_stages) { EducationalStage.all } + + post '/v1/collections' do + include_context "authenticate_user" + + parameter :name, 'The name of the collection', scope: :collection + parameter :description, 'The description of educational content of the collection', scope: :collection + parameter :owner_id, 'The id of the collection’s owner', scope: :collection + parameter :owner_type, 'Represents a type of the collections owner [User, Institution]', scope: :collection + parameter :privacy, 'Represents if collections is public, or not. [public, private]', scope: :collection + parameter :items, 'Items belongs to the collection [LearningObject, Collection]', scope: :collection + parameter :tags, 'Array with tags', scope: :collection + parameter :subjects, 'Array with subjects', scope: :collection + parameter :educational_stages, 'Array with educational stages', scope: :collection + + let(:name) { Faker::Lorem.word } + let(:description) { Faker::Lorem.sentence } + let(:owner_id) { @user.id } + let(:owner_type) { 'User' } + let(:privacy) { 'public' } + let(:items) { [ { id: learning_objects.first.id, type: "LearningObject", position: 0 } ] } + let(:tags) { [ { name: Faker::Lorem.word} ] } + let(:educational_stages) { [_educational_stages.first.id, _educational_stages.second.id] } + let(:subjects) { [_subjects.first.id, _subjects.second.id] } + let(:raw_post) { params.to_json } + + example 'Creating a collection' do + do_request + expect(status).to eq(201) + end + end get '/v1/collections' do parameter :limit, 'Limit of collections' -- GitLab