diff --git a/app/views/polls/questions/show.html.erb b/app/views/polls/questions/show.html.erb index 018f3b986..2b7225f9f 100644 --- a/app/views/polls/questions/show.html.erb +++ b/app/views/polls/questions/show.html.erb @@ -28,7 +28,12 @@ <%= t('poll_questions.show.author') %>
- <%= link_to @question.author.name, @question.author %> + <% if @question.author_visible_name.present? %> + <%= @question.author_visible_name %> + <% else %> + <%= link_to @question.author.name, @question.author %> + <% end %> +

diff --git a/spec/features/polls/questions_spec.rb b/spec/features/polls/questions_spec.rb index 5ccbd33a8..6f2225175 100644 --- a/spec/features/polls/questions_spec.rb +++ b/spec/features/polls/questions_spec.rb @@ -12,6 +12,19 @@ feature 'Poll Questions' do expect(proposal_question.title).to appear_before(normal_question.title) end + scenario 'shows the author visible name instead of a link to the author' do + poll = create(:poll) + question_with_author = create(:poll_question, poll: poll) + question_with_author_visible_name = create(:poll_question, poll: poll, author_visible_name: 'potato') + + visit question_path(question_with_author) + expect(page).to have_link(question_with_author.author.name) + + visit question_path(question_with_author_visible_name) + expect(page).to_not have_link(question_with_author_visible_name.author.name) + expect(page).to have_content(question_with_author_visible_name.author_visible_name) + end + context 'Answering' do let(:geozone) { create(:geozone) } let(:poll) { create(:poll, geozone_restricted: true, geozone_ids: [geozone.id]) }