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

Merge branch 'rspec' into 'master'

Download - Rspec

See merge request !438
parents 100f900d 6c224f54
No related branches found
No related tags found
No related merge requests found
......@@ -39,7 +39,7 @@ class V1::LearningObjectsController < ApplicationController
publisher = LearningObjectPublisher.new(DspaceService.create_client)
if publisher.create_draft(learning_object, current_user)
learning_object_associations(learning_object)
learning_object_associations(learning_object, false)
render json: learning_object, status: :created
else
render json: learning_object.errors, status: :unprocessable_entity
......@@ -49,7 +49,7 @@ class V1::LearningObjectsController < ApplicationController
# PATCH/PUT /learning_objects/1
# PATCH/PUT /learning_objects/1.json
def update
if !learning_object_params[:object_type_id].blank? && learning_object_params[:object_type_id] != @learning_object.object_type_id && learning_object_params[:link].blank?
if !learning_object_params[:object_type_id].blank? && learning_object_params[:object_type_id] != @learning_object.object_type_id && learning_object_params[:link].blank?
change_object_type_id = true
end
if @learning_object.update(learning_object_params)
......@@ -119,8 +119,7 @@ class V1::LearningObjectsController < ApplicationController
end
learning_object.add_subjects(ids: extra_params[:subjects]) unless extra_params[:subjects].nil?
learning_object.add_educational_stages(ids: extra_params[:educational_stages]) unless extra_params[:educational_stages].nil?
if change_object_type_id
if change_object_type_id
learning_object.link = nil
end
end
......
require 'acceptance_helpers'
require 'shared/contexts'
resource 'Downloads' do
explanation "An user can download the content of a learning object or collection."
get '/v1/:type/:id/download' do
include_context "authenticate_user"
parameter :type, "Represents the type of object [‘learning_objects’,'collections']", scope: :download
parameter :id, "The id of object", scope: :download
let(:type) { 'learning_objects' }
let(:id) { @learning_object.id }
before do
@learning_object = create(:learning_object, publisher: @user)
create(:attachment, learning_object: @learning_object)
end
example_request 'Download an object' do
expect(status).to eq(302)
end
end
end
FactoryGirl.define do
factory :attachment, class: LearningObject::Attachment do |f|
f.name { Faker::Name.name }
f.retrieve_link { Faker::File.file_name }
f.mime_type { Faker::File.mime_type }
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