From 8d0da0e4517cd811d02e3226f6f18049573884a1 Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 18 Feb 2017 15:55:09 -0300 Subject: [PATCH] Ivan - Fix ruby tests --- tests/staff/add.rb | 6 +++--- tests/staff/edit.rb | 2 +- tests/staff/get-all.rb | 4 ++-- tests/system/file-upload-download.rb | 22 ++++++++++++++++++++++ 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/tests/staff/add.rb b/tests/staff/add.rb index 1f557034..f9bafedc 100644 --- a/tests/staff/add.rb +++ b/tests/staff/add.rb @@ -10,7 +10,7 @@ describe'/staff/add' do email: 'tyrion@opensupports.com', password: 'testpassword', level: 2, - profilePic: 'http://www.opensupports.com/profilepic.jpg', + profilePic: '', departments: '[1]' }) @@ -20,7 +20,7 @@ describe'/staff/add' do (row['name']).should.equal('Tyrion Lannister') (row['email']).should.equal('tyrion@opensupports.com') - (row['profile_pic']).should.equal('http://www.opensupports.com/profilepic.jpg') + (row['profile_pic']).should.equal('') (row['level']).should.equal('2') row = $database.getRow('department', 1, 'id') @@ -38,7 +38,7 @@ describe'/staff/add' do email: 'tyrion@opensupports.com', password: 'testpassword', level: 2, - profilePic: 'http://www.opensupports.com/profilepic.jpg', + profilePic: '', departments: '[1]' }) diff --git a/tests/staff/edit.rb b/tests/staff/edit.rb index 4181fb80..a42de635 100644 --- a/tests/staff/edit.rb +++ b/tests/staff/edit.rb @@ -39,7 +39,7 @@ describe'/staff/edit' do password: 'starkpassword', email: 'arya@opensupports.com', level: 2, - profilePic: 'http://www.opensupports.com/profilepic.jpg', + profilePic: '', departments: '[1]' }) request('/user/logout') diff --git a/tests/staff/get-all.rb b/tests/staff/get-all.rb index ba5544f5..ca257ced 100644 --- a/tests/staff/get-all.rb +++ b/tests/staff/get-all.rb @@ -12,7 +12,7 @@ describe'/staff/get-all' do (result['data'][0]['name']).should.equal('Emilia Clarke') (result['data'][0]['email']).should.equal('staff@opensupports.com') - (result['data'][0]['profilePic']).should.equal('http://www.opensupports.com/profilepic.jpg') + (result['data'][0]['profilePic']).should.equal('') (result['data'][0]['level']).should.equal('3') (result['data'][0]['departments'][0]['id']).should.equal('1') (result['data'][0]['departments'][0]['name']).should.equal('Tech Support') @@ -25,7 +25,7 @@ describe'/staff/get-all' do (result['data'][1]['name']).should.equal('Arya Stark') (result['data'][1]['email']).should.equal('newwstaff@opensupports.com') - (result['data'][1]['profilePic']).should.equal('http://www.opensupports.com/profilepic.jpg') + (result['data'][1]['profilePic']).should.equal('') (result['data'][1]['level']).should.equal('2') (result['data'][1]['departments'][0]['id']).should.equal('1') (result['data'][1]['departments'][0]['name']).should.equal('Tech Support') diff --git a/tests/system/file-upload-download.rb b/tests/system/file-upload-download.rb index 87738188..9319422c 100644 --- a/tests/system/file-upload-download.rb +++ b/tests/system/file-upload-download.rb @@ -71,4 +71,26 @@ describe 'File Upload and Download' do (result.body).should.equal(file.read) end + it 'should upload profile picture' do + file = File.new('../server/files/profile.jpg', 'w+') + file.puts('file content') + file.close + + request('/staff/edit', { + 'csrf_userid' => $csrf_userid, + 'csrf_token' => $csrf_token, + 'staffId' => $csrf_userid, + 'file' => File.open( "../server/files/profile.jpg") + }) + + user = $database.getRow('staff', $csrf_userid) + + result = plainRequest('/system/download', { + 'csrf_userid' => $csrf_userid, + 'csrf_token' => $csrf_token, + 'file' => user['profile_pic'] + }, 'GET') + + (result.body).should.include('file content') + end end