Commit d07e85e1 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'add-unicode-trace-feature-test' into 'master'

Add feature test with unicode trace

See merge request !10736
parents b9f07618 a74b7d90
---
title: Add a feature test for Unicode trace
merge_request: 10736
author: dosuken123
...@@ -144,6 +144,8 @@ describe Projects::BuildsController do ...@@ -144,6 +144,8 @@ describe Projects::BuildsController do
it 'returns a trace' do it 'returns a trace' do
expect(response).to have_http_status(:ok) 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') expect(json_response['html']).to eq('BUILD TRACE')
end end
end end
...@@ -153,10 +155,23 @@ describe Projects::BuildsController do ...@@ -153,10 +155,23 @@ describe Projects::BuildsController do
it 'returns no traces' do it 'returns no traces' do
expect(response).to have_http_status(:ok) 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 expect(json_response['html']).to be_nil
end end
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 def get_trace
get :trace, namespace_id: project.namespace, get :trace, namespace_id: project.namespace,
project_id: project, project_id: project,
...@@ -185,48 +200,6 @@ describe Projects::BuildsController do ...@@ -185,48 +200,6 @@ describe Projects::BuildsController do
end end
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 describe 'POST retry' do
before do before do
project.add_developer(user) project.add_developer(user)
......
...@@ -128,6 +128,16 @@ FactoryGirl.define do ...@@ -128,6 +128,16 @@ FactoryGirl.define do
end end
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 trait :erased do
erased_at Time.now erased_at Time.now
erased_by factory: :user 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