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

fix versions of learning object

parent 522b32ad
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,8 @@ class V1::LearningObjectsController < ApplicationController
before_action :set_learning_object, only: [:show, :update, :destroy, :subjecting, :unsubjecting, :add_stages, :remove_stages]
before_action :set_new_learning_object, only: :index
before_action :authorize!, except: [:create, :tagging, :untagging]
before_action :set_paper_trail_whodunnit
def index
learning_objects = paginate LearningObject.includes(:tags, :publisher, :language, :license, :subjects, :educational_stages, :reviews)
......
......@@ -48,6 +48,9 @@ class LearningObject < ApplicationRecord
# *current_user* destroy learning object
include Trackable
has_paper_trail
has_many :collection_items, as: :collectionable
has_many :collections, through: :collection_items
has_many :attachments, class_name: 'LearningObject::Attachment', autosave: true # autosave to allow import
......
......@@ -64,25 +64,22 @@ resource 'Learning Objects' do
end
end
# This test doesnt work yet
# First I have to find a way to create a version
# get '/v1/learning_objects/:id/versions' do
# include_context "authenticate_user"
#
# before do
# @learning_object = create(:learning_object)
# @learning_object.update(name: Faker::Name.name)
# p @learning_object
# temp = PaperTrail::Version.find(@learning_object.id)
# print(temp)
# p "============="
# end
#
# example 'Getting all learning_objects versions' do
# expect(path).to eq("/v1/learning_objects/#{id}/versions") # `:id` is replaced with the value of `id`
# expect(response_body).to eq(Helper.serialize(PaperTrail::VersionSerializer.find(id)))
# expect(status).to eq(200)
# end
# end
get '/v1/learning_objects/:id/versions' do
include_context "authenticate_user"
before do
@learning_object = create(:learning_object)
@learning_object.update(name: Faker::Name.name)
end
let(:id) { @learning_object.id }
example 'Getting all learning_objects versions' do
do_request
expect(path).to eq("/v1/learning_objects/#{id}/versions") # `:id` is replaced with the value of `id`
expect(response_body).to eq(Helper.serialize(@learning_object.versions))
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