Commit a74b7d90 authored by Shinya Maeda's avatar Shinya Maeda Committed by Lin Jen-Shin

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
parent d7157746
---
title: Add a feature test for Unicode trace
merge_request: 10736
author: dosuken123
......@@ -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)
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment