Skip to content
Snippets Groups Projects
Commit 7906f24a authored by Mauricio Giacomini Girardello's avatar Mauricio Giacomini Girardello
Browse files

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

parents ea110da2 5cdd60a5
No related branches found
No related tags found
No related merge requests found
......@@ -27,7 +27,6 @@ class V1::CollectionsController < ApplicationController
else
render json: collection.errors, status: :unprocessable_entity
end
end
# PUT/PATCH /v1/users/1
......
class CollectionSerializer < ActiveModel::Serializer
attributes :id, :name, :created_at, :updated_at, :description, :privacy, :score
belongs_to :owner
end
\ No newline at end of file
......@@ -14,6 +14,7 @@ Rails.application.routes.draw do
mount_devise_token_auth_for 'User', skip: [:omniauth_callbacks], at: :auth
resources :users, concerns: :followable
resources :collections, concerns: :followable
end
end
......@@ -5,8 +5,43 @@ class V1::CollectionsControllerTest < ActionController::TestCase
include Devise::TestHelpers
test 'should get index' do
get :index
skip('Unsolved issue: ArgumentError: wrong number of arguments (2 for 0)')
end
test 'should show collection' do
ufpr = collections(:ufpr)
get :show, id: ufpr.id
assert_response :ok
end
test 'should user post collection to create and return :created code' do
auth_request users(:jack)
post :create, collection: {name: 'my collection',
description: 'testing collection',
owner: {
class: 'User', id: users(:jack).id
}}
assert_response :created
end
test 'should institution post collection to create and return :created code' do
auth_request users(:jack)
post :create, collection: {name: 'my collection',
description: 'testing collection',
owner: {
class: 'Institution', id: institutions(:ufpr).id
}}
assert_response :created
end
test 'should user post collection to create and return :unauthorized code' do
auth_request users(:jack)
post :create, collection: {name: 'my collection',
description: 'testing collection',
owner: {
class: 'User', id: users(:john).id
}}
assert_response :unauthorized
end
end
ufpr:
name: 'UFPR institution'
address: 'politecnico'
city: 'curitiba'
country: 'brasil'
\ No newline at end of file
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