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

solving conflicts in collection tests

parents 6d90788c 07f3714b
No related branches found
No related tags found
No related merge requests found
require 'acceptance_helpers'
require 'shared/examples'
require 'shared/contexts'
resource 'Collections' do
header 'Accept', 'application/json'
......@@ -34,4 +35,39 @@ resource 'Collections' do
end
end
post '/v1/collections/:id/like' do
include_context "authenticate_user"
let(:id) { collections.first.id }
example 'Liking a collection' do
likes = collections.first.likes.count
do_request
expect(path).to eq("/v1/collections/#{id}/like")
expect(JSON.parse(response_body)['count']).to eq(likes + 1)
expect(status).to eq(201)
end
end
delete '/v1/collections/:id/like' do
include_context "authenticate_user"
let(:id) { collections.first.id }
before do
create(:like, user: @user, likeable: collections.first)
end
example 'Unliking a collection' do
likes = collections.first.likes.count
do_request
expect(path).to eq("/v1/collections/#{id}/like")
expect(JSON.parse(response_body)['count']).to eq(likes - 1)
expect(status).to eq(200)
end
end
end
......@@ -46,4 +46,22 @@ resource 'Learning Objects' do
end
end
delete '/v1/learning_objects/:id/like' do
include_context "authenticate_user"
let(:id) { learning_objects.first.id }
before do
create(:like, user: @user, likeable: learning_objects.first)
end
example 'Unliking a learning object' do
likes = learning_objects.first.likes.count
do_request
expect(path).to eq("/v1/learning_objects/#{id}/like")
expect(JSON.parse(response_body)['count']).to eq(likes - 1)
expect(status).to eq(200)
end
end
end
......@@ -9,7 +9,8 @@ RSpec.shared_context "authenticate_user", shared_context: :metadata do
let(:access_token) { @auth_headers['access-token'] }
before do
@auth_headers = create(:user).create_new_auth_token
@user = create(:user)
@auth_headers = @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