Skip to content
Snippets Groups Projects
Commit 03d25998 authored by Marcela Ribeiro de Oliveira's avatar Marcela Ribeiro de Oliveira
Browse files

Merge branch 'rspec' of gitlab.c3sl.ufpr.br:portalmec/portalmec into rspec

parents 9c16b83e c8347d64
No related branches found
No related tags found
No related merge requests found
......@@ -4,9 +4,10 @@ resource 'Educational Stages' do
header 'Accept', 'application/json'
header 'Content-Type', 'application/json'
before { 12.times { create(:educational_stage) } }
before { 12.times { create(:educational_stage); create(:learning_object) } }
let(:educational_stages) { EducationalStage.all }
let(:educationalstages) { EducationalStage.all }
let(:learning_objects) { LearningObject.all }
get '/v1/educational_stages' do
parameter :limit, 'Limit of educational stages'
......@@ -22,4 +23,26 @@ resource 'Educational Stages' do
end
end
post '/v1/:type/:id/educational_stages' do
include_context "authenticate_user"
parameter :id, 'The id of object'
parameter :type, 'Represents the type of object, [learning_objects, collection]'
parameter :educational_stages, 'array with the educational_stages ids'
let(:type) { 'learning_objects' }
let(:id) { @learning_object.id }
let(:educational_stages) { [educationalstages.first.id] }
let(:raw_post) { params.to_json }
before do
@learning_object = create(:learning_object, publisher: @user)
end
example_request 'Adding Educational Stages' do
expect(status).to eq(201)
end
end
end
......@@ -4,7 +4,10 @@ resource 'Object Type' do
header 'Accept', 'application/json'
header 'Content-Type', 'application/json'
before { 12.times { create(:mime_type) } }
let(:object_types) { ObjectType.all }
let(:mimetypes) { MimeType.all }
get '/v1/object_types' do
parameter :limit, 'Limit of object types'
......@@ -30,5 +33,21 @@ resource 'Object Type' do
expect(status).to eq(200)
end
end
post '/v1/object_types' do
include_context "authenticate_user"
parameter :name, 'The name of the object type', scope: :object_type
parameter :mime_types, 'Array of mime_types', scope: :object_type
let(:name) { Faker::Lorem.word }
let(:mime_types) { [ { "id": mimetypes.first.id } ] }
let(:raw_post) { params.to_json }
example 'Adding a object_type' do
do_request
expect(status).to eq(201)
end
end
end
require 'acceptance_helpers'
resource 'Tags' do
before { 12.times { create(:learning_object) } }
let(:learning_objects) { LearningObject.all }
post '/v1/:type/:id/tagging' do
include_context "authenticate_user"
parameter :type, 'Represents the type of object, [learning_objects,collections]'
parameter :id, 'The id of object'
parameter :name, 'The name of tag', scope: :tags
parameter :owner_id, 'The id of owner', scope: :tags
parameter :owner_type, 'Can be [User,Institution]', scope: :tags
let(:type) { 'learning_objects' }
let(:id) { learning_objects.first.id }
let(:name) { Faker::Lorem.word }
let(:owner_id) { @user.id }
let(:owner_type) { "User" }
let(:raw_post) { params.to_json }
example_request 'Adding a tag' do
expect(status).to eq(201)
end
end
delete '/v1/:type/:id/tagging' do
include_context "authenticate_user"
parameter :type, 'Represents the type of object, [learning_objects,collections]'
parameter :id, 'The id of object'
parameter :name, 'The name of tag', scope: :tags
parameter :owner_id, 'The id of owner', scope: :tags
parameter :owner_type, 'Can be [User,Institution]', scope: :tags
let(:type) { 'learning_objects' }
let(:id) { learning_objects.first.id }
let(:name) { "test" }
let(:owner_id) { @user.id }
let(:owner_type) { "User" }
let(:raw_post) { params.to_json }
before do
@tag = create(:tag, name: 'test')
create(:tagging, tagger: @user, taggable: learning_objects.first, tag: @tag)
end
example_request ' Untagging a object or collection' do
expect(status).to eq(200)
end
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