+
diff --git a/app/views/entries/show.html.erb b/app/views/entries/show.html.erb
index 0e7e393..b01f80d 100644
--- a/app/views/entries/show.html.erb
+++ b/app/views/entries/show.html.erb
@@ -58,4 +58,6 @@
<% end %>
+
+ <%= render "entries/comments_section", entry: @entry %>
diff --git a/app/views/invitation_mailer/invite.html.erb b/app/views/invitation_mailer/invite.html.erb
index d26b7a9..181dfa5 100644
--- a/app/views/invitation_mailer/invite.html.erb
+++ b/app/views/invitation_mailer/invite.html.erb
@@ -94,7 +94,7 @@
The Sanasto Wiki let you search and compare, or download, translations across languages used all over the living Christianity.
-
You are invited to contribute to this work.
+
With a login account, you can contribute to this work.
Your Account Details:
diff --git a/config/routes.rb b/config/routes.rb
index 5915f1b..1f08c77 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -34,6 +34,7 @@ Rails.application.routes.draw do
end
resources :entries do
+ resources :comments, only: [:create]
collection do
get :download
end
diff --git a/db/migrate/20260123130957_add_language_code_to_comments.rb b/db/migrate/20260123130957_add_language_code_to_comments.rb
new file mode 100644
index 0000000..1c65bd4
--- /dev/null
+++ b/db/migrate/20260123130957_add_language_code_to_comments.rb
@@ -0,0 +1,5 @@
+class AddLanguageCodeToComments < ActiveRecord::Migration[8.1]
+ def change
+ add_column :comments, :language_code, :string
+ end
+end
diff --git a/db/structure.sql b/db/structure.sql
index 12e774c..11d81d6 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -10,7 +10,7 @@ FOREIGN KEY ("updated_by_id")
CREATE INDEX "index_entries_on_created_by_id" ON "entries" ("created_by_id") /*application='SanastoWiki'*/;
CREATE INDEX "index_entries_on_updated_by_id" ON "entries" ("updated_by_id") /*application='SanastoWiki'*/;
CREATE INDEX "index_entries_on_category" ON "entries" ("category") /*application='SanastoWiki'*/;
-CREATE TABLE IF NOT EXISTS "comments" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "user_id" integer NOT NULL, "commentable_type" varchar NOT NULL, "commentable_id" integer NOT NULL, "body" text NOT NULL, "created_at" datetime(6) NOT NULL, "updated_at" datetime(6) NOT NULL, CONSTRAINT "fk_rails_03de2dc08c"
+CREATE TABLE IF NOT EXISTS "comments" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "user_id" integer NOT NULL, "commentable_type" varchar NOT NULL, "commentable_id" integer NOT NULL, "body" text NOT NULL, "created_at" datetime(6) NOT NULL, "updated_at" datetime(6) NOT NULL, "language_code" varchar /*application='SanastoWiki'*/, CONSTRAINT "fk_rails_03de2dc08c"
FOREIGN KEY ("user_id")
REFERENCES "users" ("id")
);
@@ -81,6 +81,7 @@ BEGIN
END;
CREATE TABLE IF NOT EXISTS "setup_states" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "installed" boolean DEFAULT FALSE NOT NULL, "installed_at" datetime(6), "created_at" datetime(6) NOT NULL, "updated_at" datetime(6) NOT NULL);
INSERT INTO "schema_migrations" (version) VALUES
+('20260123130957'),
('20260123125325'),
('20260122131000'),
('20260122130000'),
diff --git a/test/controllers/comments_controller_test.rb b/test/controllers/comments_controller_test.rb
new file mode 100644
index 0000000..5c1cf08
--- /dev/null
+++ b/test/controllers/comments_controller_test.rb
@@ -0,0 +1,42 @@
+require "test_helper"
+
+class CommentsControllerTest < ActionDispatch::IntegrationTest
+ setup do
+ @user = users(:contributor_user)
+ @entry = entries(:one)
+ @supported_language = supported_languages(:one)
+ end
+
+ test "should not create comment if not logged in" do
+ assert_no_difference("Comment.count") do
+ post entry_comments_url(@entry), params: { comment: { body: "Test comment", language_code: @supported_language.code } }
+ end
+ assert_redirected_to new_user_session_url
+ end
+
+ test "should create comment if logged in" do
+ login_as @user
+ assert_difference("Comment.count", 1) do
+ post entry_comments_url(@entry), params: { comment: { body: "Test comment", language_code: @supported_language.code } }
+ end
+ assert_redirected_to @entry
+ assert_equal "Test comment", Comment.last.body
+ assert_equal @supported_language.code, Comment.last.language_code
+ assert_equal @user, Comment.last.user
+ end
+
+ # Assuming you want to test turbo stream responses as well
+ test "should create comment and respond with turbo stream" do
+ login_as @user
+ post entry_comments_url(@entry), params: { comment: { body: "Test turbo comment", language_code: @supported_language.code } }, as: :turbo_stream
+ assert_response :success
+ assert_match(/turbo-stream action=\"append\" target=\"comments-#{@supported_language.code}\"/, response.body)
+ assert_match(/Test turbo comment/, response.body)
+ end
+
+ private
+
+ def new_user_session_url
+ login_path
+ end
+end