summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changelogs/unreleased/add-unicode-trace-feature-test.yml4
-rw-r--r--spec/controllers/projects/builds_controller_spec.rb57
-rw-r--r--spec/factories/ci/builds.rb10
3 files changed, 29 insertions, 42 deletions
diff --git a/changelogs/unreleased/add-unicode-trace-feature-test.yml b/changelogs/unreleased/add-unicode-trace-feature-test.yml
new file mode 100644
index 00000000000..90c6a9afefc
--- /dev/null
+++ b/changelogs/unreleased/add-unicode-trace-feature-test.yml
@@ -0,0 +1,4 @@
+---
+title: Add a feature test for Unicode trace
+merge_request: 10736
+author: dosuken123
diff --git a/spec/controllers/projects/builds_controller_spec.rb b/spec/controllers/projects/builds_controller_spec.rb
index 3ce23c17cdc..f41503fd34e 100644
--- a/spec/controllers/projects/builds_controller_spec.rb
+++ b/spec/controllers/projects/builds_controller_spec.rb
@@ -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)
diff --git a/spec/factories/ci/builds.rb b/spec/factories/ci/builds.rb
index 78ddd8d5584..f5e99fdf00b 100644
--- a/spec/factories/ci/builds.rb
+++ b/spec/factories/ci/builds.rb
@@ -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