summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/presenters/blobs/unfold_presenter.rb15
-rw-r--r--lib/gt_one_coercion.rb7
-rw-r--r--spec/presenters/blobs/unfold_presenter_spec.rb2
3 files changed, 4 insertions, 20 deletions
diff --git a/app/presenters/blobs/unfold_presenter.rb b/app/presenters/blobs/unfold_presenter.rb
index 7b13db3bb74..45af4a33c18 100644
--- a/app/presenters/blobs/unfold_presenter.rb
+++ b/app/presenters/blobs/unfold_presenter.rb
@@ -1,24 +1,15 @@
# frozen_string_literal: true
-require 'gt_one_coercion'
-
module Blobs
class UnfoldPresenter < BlobPresenter
- include Virtus.model
+ include ActiveModel::Model
include Gitlab::Utils::StrongMemoize
- attribute :full, Boolean, default: false
- attribute :since, GtOneCoercion
- attribute :to, GtOneCoercion
- attribute :bottom, Boolean
- attribute :unfold, Boolean, default: true
- attribute :offset, Integer
- attribute :indent, Integer, default: 0
+ attr_accessor :full, :since, :to, :bottom, :unfold, :offset, :indent
def initialize(blob, params)
- @subject = blob
+ super(blob, params)
@all_lines = highlight.lines
- super(params)
if full?
self.attributes = { since: 1, to: @all_lines.size, bottom: false, unfold: false, offset: 0, indent: 0 }
diff --git a/lib/gt_one_coercion.rb b/lib/gt_one_coercion.rb
deleted file mode 100644
index 99be51bc8c6..00000000000
--- a/lib/gt_one_coercion.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# frozen_string_literal: true
-
-class GtOneCoercion < Virtus::Attribute
- def coerce(value)
- [1, value.to_i].max
- end
-end
diff --git a/spec/presenters/blobs/unfold_presenter_spec.rb b/spec/presenters/blobs/unfold_presenter_spec.rb
index 7ece5f623ce..8b65415fa84 100644
--- a/spec/presenters/blobs/unfold_presenter_spec.rb
+++ b/spec/presenters/blobs/unfold_presenter_spec.rb
@@ -5,7 +5,7 @@ require 'spec_helper'
describe Blobs::UnfoldPresenter do
include FakeBlobHelpers
- let(:project) { create(:project, :repository) }
+ set(:project) { create(:project, :repository) }
let(:blob) { fake_blob(path: 'foo', data: "1\n2\n3") }
let(:subject) { described_class.new(blob, params) }