- <%= form_with model: Comment.new, url: collection_card_comments_path(card.collection, card), class: "flex flex-column gap full-width",
+ <%= form_with model: Comment.new, url: card_comments_path(card), class: "flex flex-column gap full-width",
data: { controller: "form paste local-save",
local_save_key_value: "comment-#{card.id}",
action: "turbo:submit-end->local-save#submit keydown.ctrl+enter->form#submit:prevent keydown.meta+enter->form#submit:prevent keydown.esc->form#cancel:stop paste->paste#pasteFiles" } do |form| %>
diff --git a/app/views/comments/create.html.erb b/app/views/cards/comments/create.html.erb
similarity index 100%
rename from app/views/comments/create.html.erb
rename to app/views/cards/comments/create.html.erb
diff --git a/app/views/comments/edit.html.erb b/app/views/cards/comments/edit.html.erb
similarity index 73%
rename from app/views/comments/edit.html.erb
rename to app/views/cards/comments/edit.html.erb
index 795a79d71..e3a2e783d 100644
--- a/app/views/comments/edit.html.erb
+++ b/app/views/cards/comments/edit.html.erb
@@ -1,14 +1,14 @@
<%= turbo_frame_tag dom_id(@comment) do %>
- <%= form_with model: [@card.collection, @card, @comment], class: "flex flex-column gap full-width",
+ <%= form_with model: [ @card, @comment ], class: "flex flex-column gap full-width",
data: { controller: "form paste", action: "keydown.ctrl+enter->form#submit:prevent keydown.meta+enter->form#submit:prevent keydown.esc->form#cancel:stop paste->paste#pasteFiles" } do |form| %>
<%= form.markdown_area :body, class: "input comment__input", required: true, autofocus: true, placeholder: new_comment_placeholder(@card) %>
<%= form.button class: "btn btn--reversed", type: :submit do %>
Save changes
<% end %>
- <%= link_to collection_card_comment_path(@card.collection, @card, @comment), class: "btn", data: { form_target: "cancel" } do %>
+ <%= link_to card_comment_path(@card, @comment), class: "btn", data: { form_target: "cancel" } do %>
Cancel
<% end %>
@@ -20,7 +20,7 @@
<% end %>
- <%= form_with url: collection_card_comment_path(@card.collection, @card, @comment), method: :delete, id: dom_id(@comment, :delete_form), data: { turbo_frame: "_top" } %>
+ <%= form_with url: card_comment_path(@card, @comment), method: :delete, id: dom_id(@comment, :delete_form), data: { turbo_frame: "_top" } %>
<% end %>
diff --git a/app/views/comments/reactions/_reaction.html.erb b/app/views/cards/comments/reactions/_reaction.html.erb
similarity index 92%
rename from app/views/comments/reactions/_reaction.html.erb
rename to app/views/cards/comments/reactions/_reaction.html.erb
index c5790204d..d88ed4fae 100644
--- a/app/views/comments/reactions/_reaction.html.erb
+++ b/app/views/cards/comments/reactions/_reaction.html.erb
@@ -13,7 +13,7 @@
class: [ "txt-small", { "txt-medium": reaction.all_emoji? } ],
data: { action: "click->reaction-delete#reveal keydown.enter->reaction-delete#reveal:prevent", reaction_delete_target: "content" } %>
- <%= button_to collection_card_comment_reaction_path(comment.card.collection, comment.card, comment, reaction),
+ <%= button_to card_comment_reaction_path(comment.card, comment, reaction),
method: :delete,
class: "btn btn--negative flex-item-justify-end reaction__delete",
data: { action: "reaction-delete#perform", reaction_delete_target: "button" } do %>
diff --git a/app/views/comments/reactions/_reactions.html.erb b/app/views/cards/comments/reactions/_reactions.html.erb
similarity index 70%
rename from app/views/comments/reactions/_reactions.html.erb
rename to app/views/cards/comments/reactions/_reactions.html.erb
index 0106deefe..5c9b9f846 100644
--- a/app/views/comments/reactions/_reactions.html.erb
+++ b/app/views/cards/comments/reactions/_reactions.html.erb
@@ -2,12 +2,12 @@
<%= turbo_stream_from comment, :comments %>
<%= turbo_frame_tag comment, :new_reaction do %>
- <%= link_to new_collection_card_comment_reaction_path(comment.card.collection, comment.card, comment), role: "button",
+ <%= link_to new_card_comment_reaction_path(comment.card, comment), role: "button",
class: "btn reaction__action", action: "soft-keyboard#open" do %>
<%= icon_tag "reaction" %>
Add a reaction
diff --git a/app/views/cards/comments/reactions/index.html.erb b/app/views/cards/comments/reactions/index.html.erb
new file mode 100644
index 000000000..74863a9f1
--- /dev/null
+++ b/app/views/cards/comments/reactions/index.html.erb
@@ -0,0 +1 @@
+<%= render "cards/comments/reactions/reactions", comment: @comment %>
diff --git a/app/views/comments/reactions/new.html.erb b/app/views/cards/comments/reactions/new.html.erb
similarity index 84%
rename from app/views/comments/reactions/new.html.erb
rename to app/views/cards/comments/reactions/new.html.erb
index fc3983949..a7945c112 100644
--- a/app/views/comments/reactions/new.html.erb
+++ b/app/views/cards/comments/reactions/new.html.erb
@@ -1,5 +1,5 @@
<%= turbo_frame_tag dom_id(@comment, :new_reaction) do %>
- <%= form_with url: collection_card_comment_reactions_path(@comment.card.collection, @comment.card, @comment),
+ <%= form_with url: card_comment_reactions_path(@comment.card, @comment),
class: "reaction reaction__form flex-inline postion--relative max-width align-center fill-white gap expanded",
html: { aria: { label: "New reaction" } },
data: { controller: "form", turbo_frame: dom_id(@comment, :reacting), action: "keydown.esc->form#cancel" } do |form| %>
@@ -17,7 +17,7 @@
Submit
<% end %>
- <%= link_to collection_card_comment_reactions_path(@comment.card.collection, @comment.card, @comment), role: "button",
+ <%= link_to card_comment_reactions_path(@comment.card, @comment), role: "button",
data: { turbo_frame: dom_id(@comment, :reactions), form_target: "cancel" }, class: "btn btn--negative" do %>
<%= icon_tag "minus" %>
Cancel
diff --git a/app/views/cards/comments/show.html.erb b/app/views/cards/comments/show.html.erb
new file mode 100644
index 000000000..a17046280
--- /dev/null
+++ b/app/views/cards/comments/show.html.erb
@@ -0,0 +1 @@
+<%= render "cards/comments/body", comment: @comment %>
diff --git a/app/views/cards/comments/update.html.erb b/app/views/cards/comments/update.html.erb
new file mode 100644
index 000000000..a17046280
--- /dev/null
+++ b/app/views/cards/comments/update.html.erb
@@ -0,0 +1 @@
+<%= render "cards/comments/body", comment: @comment %>
diff --git a/app/views/comments/reactions/index.html.erb b/app/views/comments/reactions/index.html.erb
deleted file mode 100644
index 7228b8718..000000000
--- a/app/views/comments/reactions/index.html.erb
+++ /dev/null
@@ -1 +0,0 @@
-<%= render "comments/reactions/reactions", comment: @comment %>
\ No newline at end of file
diff --git a/app/views/comments/show.html.erb b/app/views/comments/show.html.erb
deleted file mode 100644
index 815881610..000000000
--- a/app/views/comments/show.html.erb
+++ /dev/null
@@ -1 +0,0 @@
-<%= render "comments/body", comment: @comment %>
diff --git a/app/views/comments/update.html.erb b/app/views/comments/update.html.erb
deleted file mode 100644
index 815881610..000000000
--- a/app/views/comments/update.html.erb
+++ /dev/null
@@ -1 +0,0 @@
-<%= render "comments/body", comment: @comment %>
diff --git a/app/views/messages/_message.html.erb b/app/views/messages/_message.html.erb
index 1a3b8e401..54fa127cc 100644
--- a/app/views/messages/_message.html.erb
+++ b/app/views/messages/_message.html.erb
@@ -1,5 +1,5 @@
<% cache message do %>
- <%# Template Dependency: comments/comment %>
+ <%# Template Dependency: cards/comments/comment %>
<%# Template Dependency: event_summaries/event_summary %>
<%= render partial: message.messageable.to_partial_path, object: message.messageable %>
<% end %>
diff --git a/config/routes.rb b/config/routes.rb
index 70de37a31..a0a3f5ffa 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -28,6 +28,10 @@ Rails.application.routes.draw do
resources :boosts
resources :stagings
resources :taggings
+
+ resources :comments do
+ resources :reactions, module: :comments
+ end
end
end
@@ -52,11 +56,7 @@ Rails.application.routes.draw do
resource :involvement
end
- resources :cards do
- resources :comments do
- resources :reactions, module: :comments
- end
- end
+ resources :cards
end
resources :events, only: :index
diff --git a/test/controllers/cards/comments/reactions_controller_test.rb b/test/controllers/cards/comments/reactions_controller_test.rb
new file mode 100644
index 000000000..83f556992
--- /dev/null
+++ b/test/controllers/cards/comments/reactions_controller_test.rb
@@ -0,0 +1,26 @@
+require "test_helper"
+
+class Cards::Comments::ReactionsControllerTest < ActionDispatch::IntegrationTest
+ setup do
+ sign_in_as :jz
+ @comment = comments(:logo_agreement_jz)
+ end
+
+ test "create" do
+ assert_turbo_stream_broadcasts [ @comment, :comments ], count: 1 do
+ assert_difference -> { @comment.reactions.count }, 1 do
+ post card_comment_reactions_url(@comment.card, @comment, format: :turbo_stream), params: { reaction: { content: "Great work!" } }
+ assert_redirected_to card_comment_reactions_url(@comment.card, @comment)
+ end
+ end
+ end
+
+ test "destroy" do
+ assert_turbo_stream_broadcasts [ @comment, :comments ], count: 1 do
+ assert_difference -> { @comment.reactions.count }, -1 do
+ delete card_comment_reaction_url(@comment.card, @comment, reactions(:kevin), format: :turbo_stream)
+ assert_response :success
+ end
+ end
+ end
+end
diff --git a/test/controllers/cards/comments_controller_test.rb b/test/controllers/cards/comments_controller_test.rb
new file mode 100644
index 000000000..a9e45f838
--- /dev/null
+++ b/test/controllers/cards/comments_controller_test.rb
@@ -0,0 +1,30 @@
+require "test_helper"
+
+class Cards::CommentsControllerTest < ActionDispatch::IntegrationTest
+ setup do
+ sign_in_as :kevin
+ end
+
+ test "create" do
+ assert_difference "cards(:logo).messages.comments.count", +1 do
+ post card_comments_url(cards(:logo), params: { comment: { body: "Agreed." } })
+ end
+
+ assert_response :success
+ end
+
+ test "update" do
+ put card_comment_url(cards(:logo), comments(:logo_agreement_kevin)), params: { comment: { body: "I've changed my mind" } }
+
+ assert_response :success
+ assert_equal "I've changed my mind", comments(:logo_agreement_kevin).reload.body.content
+ end
+
+ test "update another user's comment" do
+ assert_no_changes "comments(:logo_agreement_jz).body.content" do
+ put card_comment_url(cards(:logo), comments(:logo_agreement_jz)), params: { comment: { body: "I've changed my mind" } }
+ end
+
+ assert_response :forbidden
+ end
+end
diff --git a/test/controllers/comments_controller_test.rb b/test/controllers/comments_controller_test.rb
deleted file mode 100644
index 78d4987ae..000000000
--- a/test/controllers/comments_controller_test.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-require "test_helper"
-
-class CommentsControllerTest < ActionDispatch::IntegrationTest
- setup do
- sign_in_as :kevin
- end
-
- test "create" do
- assert_difference "cards(:logo).messages.comments.count", +1 do
- post collection_card_comments_url(collections(:writebook), cards(:logo), params: { comment: { body: "Agreed." } })
- end
-
- assert_response :success
- end
-
- test "update" do
- put collection_card_comment_url(collections(:writebook), cards(:logo), comments(:logo_agreement_kevin)), params: { comment: { body: "I've changed my mind" } }
-
- assert_response :success
- assert_equal "I've changed my mind", comments(:logo_agreement_kevin).reload.body.content
- end
-
- test "update another user's comment" do
- assert_no_changes "comments(:logo_agreement_jz).body.content" do
- put collection_card_comment_url(collections(:writebook), cards(:logo), comments(:logo_agreement_jz)), params: { comment: { body: "I've changed my mind" } }
- end
-
- assert_response :forbidden
- end
-end
diff --git a/test/controllers/reactions_controller_test.rb b/test/controllers/reactions_controller_test.rb
deleted file mode 100644
index e46c9ac30..000000000
--- a/test/controllers/reactions_controller_test.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-require "test_helper"
-
-class Comments::ReactionsControllerTest < ActionDispatch::IntegrationTest
- setup do
- sign_in_as :jz
- @comment = comments(:logo_agreement_jz)
- end
-
- test "create" do
- assert_turbo_stream_broadcasts [ @comment, :comments ], count: 1 do
- assert_difference -> { @comment.reactions.count }, 1 do
- post collection_card_comment_reactions_url(@comment.card.collection, @comment.card, @comment, format: :turbo_stream), params: { reaction: { content: "Great work!" } }
- assert_redirected_to collection_card_comment_reactions_url(@comment.card.collection, @comment.card, @comment)
- end
- end
- end
-
- test "destroy" do
- assert_turbo_stream_broadcasts [ @comment, :comments ], count: 1 do
- assert_difference -> { @comment.reactions.count }, -1 do
- delete collection_card_comment_reaction_url(@comment.card.collection, @comment.card, @comment, reactions(:kevin), format: :turbo_stream)
- assert_response :success
- end
- end
- end
-end