Add feature test with unicode trace

Squashed commit of the following:

commit 43e5bba774e9e383dd55c665e82f6fcfc4ebfc4f
Author: Shinya Maeda <gitlab.shinyamaeda@gmail.com>
Date:   Mon Apr 17 17:28:44 2017 +0900

    Add fix

commit 09610eebdf22ad048812bb86022504b2ad917e19
Author: Shinya Maeda <gitlab.shinyamaeda@gmail.com>
Date:   Mon Apr 17 17:03:49 2017 +0900

    Add trace test
This commit is contained in:
Shinya Maeda 2017-04-17 19:59:55 +08:00 committed by Lin Jen-Shin
parent d71577468c
commit a74b7d90a8
3 changed files with 29 additions and 42 deletions

View File

@ -0,0 +1,4 @@
---
title: Add a feature test for Unicode trace
merge_request: 10736
author: dosuken123

View File

@ -144,6 +144,8 @@ describe Projects::BuildsController do
it 'returns a trace' do
expect(response).to have_http_status(:ok)
expect(json_response['id']).to eq build.id
expect(json_response['status']).to eq build.status
expect(json_response['html']).to eq('BUILD TRACE')
end
end
@ -153,10 +155,23 @@ describe Projects::BuildsController do
it 'returns no traces' do
expect(response).to have_http_status(:ok)
expect(json_response['id']).to eq build.id
expect(json_response['status']).to eq build.status
expect(json_response['html']).to be_nil
end
end
context 'when build has a trace with ANSI sequence and Unicode' do
let(:build) { create(:ci_build, :unicode_trace, pipeline: pipeline) }
it 'returns a trace with Unicode' do
expect(response).to have_http_status(:ok)
expect(json_response['id']).to eq build.id
expect(json_response['status']).to eq build.status
expect(json_response['html']).to include("ヾ(´༎ຶД༎ຶ`)ノ")
end
end
def get_trace
get :trace, namespace_id: project.namespace,
project_id: project,
@ -185,48 +200,6 @@ describe Projects::BuildsController do
end
end
describe 'GET trace.json' do
let(:pipeline) { create(:ci_pipeline, project: project) }
let(:build) { create(:ci_build, pipeline: pipeline) }
let(:user) { create(:user) }
context 'when user is logged in as developer' do
before do
project.add_developer(user)
sign_in(user)
get_trace
end
it 'traces build log' do
expect(response).to have_http_status(:ok)
expect(json_response['id']).to eq build.id
expect(json_response['status']).to eq build.status
end
end
context 'when user is logged in as non member' do
before do
sign_in(user)
get_trace
end
it 'traces build log' do
expect(response).to have_http_status(:ok)
expect(json_response['id']).to eq build.id
expect(json_response['status']).to eq build.status
end
end
def get_trace
get :trace, namespace_id: project.namespace,
project_id: project,
id: build.id,
format: :json
end
end
describe 'POST retry' do
before do
project.add_developer(user)

View File

@ -128,6 +128,16 @@ FactoryGirl.define do
end
end
trait :unicode_trace do
after(:create) do |build, evaluator|
trace = File.binread(
File.expand_path(
Rails.root.join('spec/fixtures/trace/ansi-sequence-and-unicode')))
build.trace.set(trace)
end
end
trait :erased do
erased_at Time.now
erased_by factory: :user