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::Simple 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 'override the presentee attributes' do
|
|
|
|
presenter = presenter_class.new(project, user: 'Jane Doe')
|
|
|
|
|
|
|
|
expect(presenter.user).to eq('Jane Doe')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'delegation' do
|
|
|
|
it 'does not forward missing methods to subject' do
|
|
|
|
presenter = presenter_class.new(project)
|
|
|
|
|
|
|
|
expect { presenter.user }.to raise_error(NoMethodError)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|