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

rspec tests working

parent bbccc139
No related branches found
No related tags found
No related merge requests found
......@@ -41,7 +41,7 @@ resource 'Learning Objects' do
end
post '/v1/learning_objects' do
include_context "authenticate_user"
include_context "authenticate_user_submitter"
parameter :author, 'The author of a educational content', scope: :learning_object
parameter :name, 'The name of the learning object', scope: :learning_object
......@@ -79,7 +79,7 @@ resource 'Learning Objects' do
end
put '/v1/learning_objects/:id' do
include_context "authenticate_user"
include_context "authenticate_user_submitter"
parameter :author, 'The author of a educational content'
parameter :name, 'The name of the learning object'
......@@ -159,12 +159,12 @@ resource 'Learning Objects' do
end
post '/v1/learning_objects/:id/publish' do
include_context "authenticate_user"
include_context "authenticate_user_moderator"
let(:id) { @learning_object.id }
before do
@learning_object = create(:learning_object, publisher: @user, state: LearningObject.states[:draft])
@learning_object = create(:learning_object, publisher: @user, state: LearningObject.states[:submitted])
end
example 'Publishing a learning object' do
......
......@@ -28,3 +28,68 @@ RSpec.shared_context "authenticate_user_admin", shared_context: :metadata do
end
end
RSpec.shared_context "authenticate_user_submitter", shared_context: :metadata do
let(:auth_client) { @auth_headers['client'] }
let(:uid) { @auth_headers['uid'] }
let(:access_token) { @auth_headers['access-token'] }
let(:role) { Role.all }
before do
@user = create(:user, roles: [role.find_by(name: 'submitter')])
@auth_headers = @user.create_new_auth_token
end
end
RSpec.shared_context "authenticate_user_curator", shared_context: :metadata do
let(:auth_client) { @auth_headers['client'] }
let(:uid) { @auth_headers['uid'] }
let(:access_token) { @auth_headers['access-token'] }
let(:role) { Role.all }
before do
@user = create(:user, roles: [role.find_by(name: 'curator')])
@auth_headers = @user.create_new_auth_token
end
end
RSpec.shared_context "authenticate_user_moderator", shared_context: :metadata do
let(:auth_client) { @auth_headers['client'] }
let(:uid) { @auth_headers['uid'] }
let(:access_token) { @auth_headers['access-token'] }
let(:role) { Role.all }
before do
@user = create(:user, roles: [role.find_by(name: 'moderator')])
@auth_headers = @user.create_new_auth_token
end
end
RSpec.shared_context "authenticate_user_editor", shared_context: :metadata do
let(:auth_client) { @auth_headers['client'] }
let(:uid) { @auth_headers['uid'] }
let(:access_token) { @auth_headers['access-token'] }
let(:role) { Role.all }
before do
@user = create(:user, roles: [role.find_by(name: 'editor')])
@auth_headers = @user.create_new_auth_token
end
end
RSpec.shared_context "authenticate_user_supervisor", shared_context: :metadata do
let(:auth_client) { @auth_headers['client'] }
let(:uid) { @auth_headers['uid'] }
let(:access_token) { @auth_headers['access-token'] }
let(:role) { Role.all }
before do
@user = create(:user, roles: [role.find_by(name: 'supervisor')])
@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