Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Fix quoting first message with stimulus

Oliver Günther9af93ee13280
diff --git a/app/views/messages/show.html.erb b/app/views/messages/show.html.erb
index 5692762d9fe..2a1754164ab 100644
--- a/app/views/messages/show.html.erb
+++ b/app/views/messages/show.html.erb
@@ -31,6 +31,10 @@ See COPYRIGHT and LICENSE files for more details.
link_to(t(:label_forum_plural), project_forums_path(@project)),
link_to(h(@forum.name), project_forum_path(@project, @forum)))
%>
+
+<% content_controller 'forum-messages',
+ dynamic: true %>
+
<% title avatar(@topic.author) + h(@topic.subject) %>
<%= toolbar title: title do %>
<li class="toolbar-item hidden-for-mobile">
@@ -38,7 +42,11 @@ See COPYRIGHT and LICENSE files for more details.
</li>
<li class="toolbar-item hidden-for-mobile">
<% if [email protected]? && authorize_for('messages', 'reply') %>
- <%= link_to({ action: 'quote', id: @topic }, class: 'boards--quote-button button') do %>
+ <%= link_to(
+ { action: 'quote', id: @topic },
+ data: { 'action': 'forum-messages#quote' },
+ class: 'boards--quote-button button'
+ ) do %>
<%= op_icon('button--icon icon-quote') %>
<span class="button--text"><%= t(:button_quote) %></span>
<% end %>
@@ -74,10 +82,7 @@ See COPYRIGHT and LICENSE files for more details.
</div>
<br/>
-<div
- data-controller="forum-messages"
- data-application-target="dynamic"
- class="forum-message--comments comments">
+<div class="forum-message--comments comments">
<% unless @replies.empty? %>
<h3 class="icon-context icon-quote"><%= t(:label_reply_plural) %> (<%= @replies.count %>)</h3>
<% @replies.each do |message| %>
diff --git a/spec/features/forums/message_spec.rb b/spec/features/forums/message_spec.rb
index 07c4306b1fb..ec5e4b3715b 100644
--- a/spec/features/forums/message_spec.rb
+++ b/spec/features/forums/message_spec.rb
@@ -102,7 +102,7 @@ RSpec.describe 'messages', js: true do
.to be 1
expect(ActionMailer::Base.deliveries.last.to)
- .to match_array [other_user.mail]
+ .to contain_exactly other_user.mail
expect(ActionMailer::Base.deliveries.last.subject)
.to include 'The message is'
@@ -136,7 +136,7 @@ RSpec.describe 'messages', js: true do
.to be 2
expect(ActionMailer::Base.deliveries.last.to)
- .to match_array [user.mail]
+ .to contain_exactly user.mail
expect(ActionMailer::Base.deliveries.last.subject)
.to include 'RE: The message is'
@@ -158,10 +158,17 @@ RSpec.describe 'messages', js: true do
expect(page).to have_selector('blockquote', text: 'But, but there should be one')
+ # Quoting the first message
+ show_page.quote(quoted_message: nil,
+ subject: 'Also quoting the first message',
+ content: "Should also work")
+
+ show_page.expect_num_replies(3)
+
index_page.visit!
click_link forum.name
index_page.expect_listed(subject: 'The message is',
- replies: 2,
- last_message: 'And now to something completely different')
+ replies: 3,
+ last_message: 'Also quoting the first message')
end
end