fix failing specs

This commit is contained in:
zmagod 2018-04-24 09:47:16 +02:00
parent 503ad1ba20
commit de6c40a921

View file

@ -12,66 +12,6 @@ describe Api::V20170715::CoreApiController, type: :controller do
UserProject.create!(user: user, project: task.experiment.project, role: 0)
end
describe 'GET #task_samples' do
context 'When valid request' do
before do
request.headers['HTTP_ACCEPT'] = 'application/json'
request.headers['Authorization'] = 'Bearer ' + generate_token(user.id)
get :task_samples, params: { task_id: task.id }
end
it 'Returns HTTP success' do
expect(response).to have_http_status(200)
end
it 'Returns JSON body containing expected Samples' do
hash_body = nil
expect { hash_body = json }.not_to raise_exception
expect(hash_body).to match(
[{ 'sample_id' => sample1.id.to_s, 'name' => sample1.name },
{ 'sample_id' => sample2.id.to_s, 'name' => sample2.name },
{ 'sample_id' => sample3.id.to_s, 'name' => sample3.name }]
)
end
end
context 'When invalid request' do
context 'When invalid token' do
before do
request.headers['HTTP_ACCEPT'] = 'application/json'
request.headers['Authorization'] = 'Bearer WroNgToken'
get :task_samples, params: { task_id: task.id }
end
it 'Returns HTTP unauthorized' do
expect(response).to have_http_status(401)
end
end
context 'When valid token, but invalid request' do
before do
request.headers['HTTP_ACCEPT'] = 'application/json'
request.headers['Authorization'] = 'Bearer ' + generate_token(user.id)
end
it 'Returns HTTP not found' do
get :task_samples, params: { task_id: 1000 }
expect(response).to have_http_status(404)
expect(json).to match({})
end
it 'Returns HTTP access denied' do
UserProject.where(user: user, project: task.experiment.project)
.first
.destroy!
get :task_samples, params: { task_id: task.id }
expect(response).to have_http_status(403)
expect(json).to match({})
end
end
end
end
describe 'GET #tasks_tree' do
let!(:user_team) { create :user_team, team: team, user: user }
context 'When valid request' do