Commit 78874519 authored by Rémy Coutable's avatar Rémy Coutable

Add Presentable concern

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent e5a29b45
......@@ -94,7 +94,7 @@ class Projects::BuildsController < Projects::ApplicationController
private
def build
@build ||= project.builds.find_by!(id: params[:id])
@build ||= project.builds.find_by!(id: params[:id]).present(current_user)
end
def build_path(build)
......
......@@ -2,6 +2,7 @@ module Ci
class Build < CommitStatus
include TokenAuthenticatable
include AfterCommitQueue
include Presentable
belongs_to :runner
belongs_to :trigger_request
......
module Presentable
def present(**attributes)
Gitlab::View::Presenter::Factory
.new(self, attributes)
.fabricate!
end
end
......@@ -51,8 +51,10 @@
.prepend-top-default
- if @build.erased?
.erased.alert.alert-warning
- erased_by = "by #{link_to @build.erased_by.name, user_path(@build.erased_by)}" if @build.erased_by
Build has been erased #{erased_by.html_safe} #{time_ago_with_tooltip(@build.erased_at)}
- if @build.erased_by_user?
Build has been erased by #{link_to(@build.erased_by_name, user_path(@build.erased_by))} #{time_ago_with_tooltip(@build.erased_at)}
- else
Build has been erased #{time_ago_with_tooltip(@build.erased_at)}
- else
#js-build-scroll.scroll-controls
.scroll-step
......
require 'spec_helper'
describe Presentable do
let(:build) { create(:ci_build) }
describe '#present' do
it 'returns a presenter' do
expect(build.present).to be_a(Ci::Build::Presenter)
end
it 'takes optional attributes' do
expect(build.present(foo: 'bar').foo).to eq('bar')
end
end
end
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