diff options
author | Peter Leitzen <pleitzen@gitlab.com> | 2019-04-08 12:46:33 +0200 |
---|---|---|
committer | Peter Leitzen <pleitzen@gitlab.com> | 2019-04-08 12:46:33 +0200 |
commit | 6c1b3ecfb01a7e5f043110e9d46508a7c89c8a2c (patch) | |
tree | bfcd62adaa470acf3d469ca391a86a6db1a47a1b | |
parent | 56ac52f6069be5bf4ea152047aafe34a99b1e854 (diff) | |
download | gitlab-ce-pl-remove-virtus.tar.gz |
-rw-r--r-- | app/presenters/blobs/unfold_presenter.rb | 15 | ||||
-rw-r--r-- | lib/gt_one_coercion.rb | 7 | ||||
-rw-r--r-- | spec/presenters/blobs/unfold_presenter_spec.rb | 2 |
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) } |