gitlab-org--gitlab-foss/spec/lib/gitlab/view/presenter/delegated_spec.rb

36 lines
981 B
Ruby
Raw Normal View History

# frozen_string_literal: true
require 'spec_helper'
describe Gitlab::View::Presenter::Delegated do
let(:project) { double(:project, user: 'John Doe') }
let(:presenter_class) do
Class.new(described_class)
end
it 'includes Gitlab::View::Presenter::Base' do
expect(described_class).to include(Gitlab::View::Presenter::Base)
end
describe '#initialize' do
it 'takes arbitrary key/values and exposes them' do
presenter = presenter_class.new(project, current_user: 'Jane Doe')
expect(presenter.current_user).to eq('Jane Doe')
end
it 'raise an error if the presentee already respond to method' do
2017-06-21 09:48:12 -04:00
expect { presenter_class.new(project, user: 'Jane Doe') }
.to raise_error Gitlab::View::Presenter::CannotOverrideMethodError
end
end
describe 'delegation' do
it 'forwards missing methods to subject' do
presenter = presenter_class.new(project)
expect(presenter.user).to eq('John Doe')
end
end
end