mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-26 09:42:46 +08:00
fix failing specs
This commit is contained in:
parent
503ad1ba20
commit
de6c40a921
1 changed files with 0 additions and 60 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue