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

Add like learning object test

parent 7e550237
No related branches found
No related tags found
No related merge requests found
require 'acceptance_helpers'
require 'shared/contexts'
resource 'Learning Objects' do
header 'Accept', 'application/json'
header 'Content-Type', 'application/json'
before { 12.times { create(:learning_object) } }
......@@ -34,14 +33,16 @@ resource 'Learning Objects' do
end
post '/v1/learning_objects/:id/like' do
let(:id) { learning_objects.first.id }
include_context "authenticate_user"
let(:id) { learning_objects.first.id }
example 'Liking a learning object' do
likes = learning_objects.first.likes
likes = learning_objects.first.likes.count
do_request
expect(path).to eq("/v1/learning_objects/#{id}/like")
expect(JSON.parse(response_body)).to eq(likes + 1)
expect(status).to eq(200)
expect(JSON.parse(response_body)['count']).to eq(likes + 1)
expect(status).to eq(201)
end
end
......
......@@ -3,12 +3,13 @@ require 'rspec_api_documentation'
require 'rspec_api_documentation/dsl'
require 'spec_helper'
RSpec.shared_context "authentication", shared_context: :metadata do
RSpec.shared_context "authenticate_user", shared_context: :metadata do
let(:auth_client) { @auth_headers['client'] }
let(:uid) { @auth_headers['uid'] }
let(:access_token) { @auth_headers['access-token'] }
def authenticate(user)
@auth_headers = user.create_new_auth_token
before do
@auth_headers = create(:user).create_new_auth_token
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