Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/helpers/events_helper_spec.rb')
-rw-r--r--spec/helpers/events_helper_spec.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/helpers/events_helper_spec.rb b/spec/helpers/events_helper_spec.rb
index 7005b3dc53e..39901047b0f 100644
--- a/spec/helpers/events_helper_spec.rb
+++ b/spec/helpers/events_helper_spec.rb
@@ -4,6 +4,30 @@ require 'spec_helper'
RSpec.describe EventsHelper do
include Gitlab::Routing
+ include Banzai::Filter::OutputSafety
+
+ describe '#link_to_author' do
+ let(:user) { create(:user) }
+ let(:event) { create(:event, author: user) }
+
+ it 'returns a link to the author' do
+ name = user.name
+ expect(helper.link_to_author(event)).to eq(link_to(name, user_path(user.username), title: name))
+ end
+
+ it 'returns the author name if the author is not present' do
+ event.author = nil
+
+ expect(helper.link_to_author(event)).to eq(escape_once(event.author_name))
+ end
+
+ it 'returns "You" if the author is the current user' do
+ allow(helper).to receive(:current_user).and_return(user)
+
+ name = _('You')
+ expect(helper.link_to_author(event, self_added: true)).to eq(link_to(name, user_path(user.username), title: name))
+ end
+ end
describe '#event_target_path' do
subject { helper.event_target_path(event.present) }