debian-mirror-gitlab/spec/lib/gitlab/view/presenter/delegated_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

36 lines
987 B
Ruby
Raw Normal View History

2019-12-04 20:38:33 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe Gitlab::View::Presenter::Delegated do
2017-08-17 22:00:37 +05:30
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-09-10 17:25:29 +05:30
expect { presenter_class.new(project, user: 'Jane Doe') }
.to raise_error Gitlab::View::Presenter::CannotOverrideMethodError
2017-08-17 22:00:37 +05:30
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