diff --git a/spec/acceptance/learning_objects_spec.rb b/spec/acceptance/learning_objects_spec.rb index 9a1606709b8e46756fd1fdd1898d807b069eea1f..e26472b6268e9d884dd02f1d7d4a8f0a649a1601 100644 --- a/spec/acceptance/learning_objects_spec.rb +++ b/spec/acceptance/learning_objects_spec.rb @@ -6,6 +6,12 @@ resource 'Learning Objects' do before { 12.times { create(:learning_object) } } let(:learning_objects) { LearningObject.all } + let(:object_types) { ObjectType.all } + let(:languages) { Language.all } + let(:licenses) { License.all } + let(:subject) { Subject.all } + let(:educational_stage) { EducationalStage.all } + let(:tag) { Tag.all } get '/v1/learning_objects' do parameter :limit, 'Limit of learning objects' @@ -32,6 +38,40 @@ resource 'Learning Objects' do end end + post '/v1/learning_objects' do + include_context "authenticate_user" + + parameter :author, 'The author of a educational content' + parameter :name, 'The name of the learning object' + parameter :description, 'The description of educational content of the learning object' + parameter :link, 'Object link, when don’t have any attachments' + parameter :software, 'If some software is needed to run the object' + parameter :tags, 'Array with tags (by name)' + parameter :subjects, 'Array with subjects ids' + parameter :educational_stages, 'Array with educational stages ids' + parameter :object_type_id, 'The id of object type' + parameter :language_id, 'The id of a language' + parameter :license_id, 'The id of a license' + + let(:author) { Faker::Name.name } + let(:name) { Faker::Name.name } + let(:description) { Faker::Lorem.paragraph } + let(:object_type_id) { object_types.first.id } + let(:language_id) { languages.first.id } + let(:license_id) { licenses.first.id } + let(:software) { Faker::Lorem::sentence } + let(:link) { Faker::Internet.url } + let(:tags) { [ name: tag.first.name, name: tag.last.name ] } + let(:subjects) { [ subject.first.id ] } + let(:educational_stages) { [ educational_stage.first.id ] } + let(:raw_post) { params.to_json } + + example 'Creating a learning_object draft' do + do_request + expect(status).to eq(201) + end + end + post '/v1/learning_objects/:id/like' do include_context "authenticate_user"