From 3382eb3635443af51335ef1692b8e017ec319626 Mon Sep 17 00:00:00 2001
From: 0chan <0chan@disroot.org>
Date: Sun, 31 Dec 2023 02:51:04 +0600
Subject: [PATCH] add posts and boards scaffolds
---
app/controllers/boards_controller.rb | 70 ++++++++++++++++++
app/controllers/posts_controller.rb | 70 ++++++++++++++++++
app/helpers/boards_helper.rb | 2 +
app/helpers/posts_helper.rb | 2 +
app/models/board.rb | 2 +
app/models/post.rb | 2 +
app/views/boards/_board.html.erb | 17 +++++
app/views/boards/_board.json.jbuilder | 2 +
app/views/boards/_form.html.erb | 27 +++++++
app/views/boards/edit.html.erb | 8 +++
app/views/boards/index.html.erb | 14 ++++
app/views/boards/index.json.jbuilder | 1 +
app/views/boards/new.html.erb | 7 ++
app/views/boards/show.html.erb | 15 ++++
app/views/boards/show.json.jbuilder | 1 +
app/views/posts/_form.html.erb | 82 ++++++++++++++++++++++
app/views/posts/_post.html.erb | 72 +++++++++++++++++++
app/views/posts/_post.json.jbuilder | 2 +
app/views/posts/edit.html.erb | 8 +++
app/views/posts/index.html.erb | 14 ++++
app/views/posts/index.json.jbuilder | 1 +
app/views/posts/new.html.erb | 7 ++
app/views/posts/show.html.erb | 15 ++++
app/views/posts/show.json.jbuilder | 1 +
db/migrate/20231230203445_create_boards.rb | 10 +++
db/migrate/20231230205017_create_posts.rb | 21 ++++++
db/schema.rb | 21 ++++++
test/controllers/boards_controller_test.rb | 48 +++++++++++++
test/controllers/posts_controller_test.rb | 48 +++++++++++++
test/fixtures/boards.yml | 9 +++
test/fixtures/posts.yml | 31 ++++++++
test/models/board_test.rb | 7 ++
test/models/post_test.rb | 7 ++
test/system/boards_test.rb | 43 ++++++++++++
test/system/posts_test.rb | 65 +++++++++++++++++
35 files changed, 752 insertions(+)
create mode 100644 app/controllers/boards_controller.rb
create mode 100644 app/controllers/posts_controller.rb
create mode 100644 app/helpers/boards_helper.rb
create mode 100644 app/helpers/posts_helper.rb
create mode 100644 app/models/board.rb
create mode 100644 app/models/post.rb
create mode 100644 app/views/boards/_board.html.erb
create mode 100644 app/views/boards/_board.json.jbuilder
create mode 100644 app/views/boards/_form.html.erb
create mode 100644 app/views/boards/edit.html.erb
create mode 100644 app/views/boards/index.html.erb
create mode 100644 app/views/boards/index.json.jbuilder
create mode 100644 app/views/boards/new.html.erb
create mode 100644 app/views/boards/show.html.erb
create mode 100644 app/views/boards/show.json.jbuilder
create mode 100644 app/views/posts/_form.html.erb
create mode 100644 app/views/posts/_post.html.erb
create mode 100644 app/views/posts/_post.json.jbuilder
create mode 100644 app/views/posts/edit.html.erb
create mode 100644 app/views/posts/index.html.erb
create mode 100644 app/views/posts/index.json.jbuilder
create mode 100644 app/views/posts/new.html.erb
create mode 100644 app/views/posts/show.html.erb
create mode 100644 app/views/posts/show.json.jbuilder
create mode 100644 db/migrate/20231230203445_create_boards.rb
create mode 100644 db/migrate/20231230205017_create_posts.rb
create mode 100644 db/schema.rb
create mode 100644 test/controllers/boards_controller_test.rb
create mode 100644 test/controllers/posts_controller_test.rb
create mode 100644 test/fixtures/boards.yml
create mode 100644 test/fixtures/posts.yml
create mode 100644 test/models/board_test.rb
create mode 100644 test/models/post_test.rb
create mode 100644 test/system/boards_test.rb
create mode 100644 test/system/posts_test.rb
diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb
new file mode 100644
index 0000000..61b856b
--- /dev/null
+++ b/app/controllers/boards_controller.rb
@@ -0,0 +1,70 @@
+class BoardsController < ApplicationController
+ before_action :set_board, only: %i[ show edit update destroy ]
+
+ # GET /boards or /boards.json
+ def index
+ @boards = Board.all
+ end
+
+ # GET /boards/1 or /boards/1.json
+ def show
+ end
+
+ # GET /boards/new
+ def new
+ @board = Board.new
+ end
+
+ # GET /boards/1/edit
+ def edit
+ end
+
+ # POST /boards or /boards.json
+ def create
+ @board = Board.new(board_params)
+
+ respond_to do |format|
+ if @board.save
+ format.html { redirect_to board_url(@board), notice: "Board was successfully created." }
+ format.json { render :show, status: :created, location: @board }
+ else
+ format.html { render :new, status: :unprocessable_entity }
+ format.json { render json: @board.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # PATCH/PUT /boards/1 or /boards/1.json
+ def update
+ respond_to do |format|
+ if @board.update(board_params)
+ format.html { redirect_to board_url(@board), notice: "Board was successfully updated." }
+ format.json { render :show, status: :ok, location: @board }
+ else
+ format.html { render :edit, status: :unprocessable_entity }
+ format.json { render json: @board.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /boards/1 or /boards/1.json
+ def destroy
+ @board.destroy!
+
+ respond_to do |format|
+ format.html { redirect_to boards_url, notice: "Board was successfully destroyed." }
+ format.json { head :no_content }
+ end
+ end
+
+ private
+ # Use callbacks to share common setup or constraints between actions.
+ def set_board
+ @board = Board.find(params[:id])
+ end
+
+ # Only allow a list of trusted parameters through.
+ def board_params
+ params.require(:board).permit(:slug, :name)
+ end
+end
diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb
new file mode 100644
index 0000000..e9aabc7
--- /dev/null
+++ b/app/controllers/posts_controller.rb
@@ -0,0 +1,70 @@
+class PostsController < ApplicationController
+ before_action :set_post, only: %i[ show edit update destroy ]
+
+ # GET /posts or /posts.json
+ def index
+ @posts = Post.all
+ end
+
+ # GET /posts/1 or /posts/1.json
+ def show
+ end
+
+ # GET /posts/new
+ def new
+ @post = Post.new
+ end
+
+ # GET /posts/1/edit
+ def edit
+ end
+
+ # POST /posts or /posts.json
+ def create
+ @post = Post.new(post_params)
+
+ respond_to do |format|
+ if @post.save
+ format.html { redirect_to post_url(@post), notice: "Post was successfully created." }
+ format.json { render :show, status: :created, location: @post }
+ else
+ format.html { render :new, status: :unprocessable_entity }
+ format.json { render json: @post.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # PATCH/PUT /posts/1 or /posts/1.json
+ def update
+ respond_to do |format|
+ if @post.update(post_params)
+ format.html { redirect_to post_url(@post), notice: "Post was successfully updated." }
+ format.json { render :show, status: :ok, location: @post }
+ else
+ format.html { render :edit, status: :unprocessable_entity }
+ format.json { render json: @post.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /posts/1 or /posts/1.json
+ def destroy
+ @post.destroy!
+
+ respond_to do |format|
+ format.html { redirect_to posts_url, notice: "Post was successfully destroyed." }
+ format.json { head :no_content }
+ end
+ end
+
+ private
+ # Use callbacks to share common setup or constraints between actions.
+ def set_post
+ @post = Post.find(params[:id])
+ end
+
+ # Only allow a list of trusted parameters through.
+ def post_params
+ params.require(:post).permit(:board_id, :parent_id, :visible_id, :reply_id, :name, :title, :message, :message_formatted, :password, :created_at, :updated_at, :bumped_at, :deleted_at)
+ end
+end
diff --git a/app/helpers/boards_helper.rb b/app/helpers/boards_helper.rb
new file mode 100644
index 0000000..8b8af15
--- /dev/null
+++ b/app/helpers/boards_helper.rb
@@ -0,0 +1,2 @@
+module BoardsHelper
+end
diff --git a/app/helpers/posts_helper.rb b/app/helpers/posts_helper.rb
new file mode 100644
index 0000000..a7b8cec
--- /dev/null
+++ b/app/helpers/posts_helper.rb
@@ -0,0 +1,2 @@
+module PostsHelper
+end
diff --git a/app/models/board.rb b/app/models/board.rb
new file mode 100644
index 0000000..29e9728
--- /dev/null
+++ b/app/models/board.rb
@@ -0,0 +1,2 @@
+class Board < ApplicationRecord
+end
diff --git a/app/models/post.rb b/app/models/post.rb
new file mode 100644
index 0000000..b2a8b46
--- /dev/null
+++ b/app/models/post.rb
@@ -0,0 +1,2 @@
+class Post < ApplicationRecord
+end
diff --git a/app/views/boards/_board.html.erb b/app/views/boards/_board.html.erb
new file mode 100644
index 0000000..aef5659
--- /dev/null
+++ b/app/views/boards/_board.html.erb
@@ -0,0 +1,17 @@
+
+
+ Slug:
+ <%= board.slug %>
+
+
+
+ Name:
+ <%= board.name %>
+
+
+ <% if action_name != "show" %>
+ <%= link_to "Show this board", board, class: "rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
+ <%= link_to "Edit this board", edit_board_path(board), class: "rounded-lg py-3 ml-2 px-5 bg-gray-100 inline-block font-medium" %>
+
+ <% end %>
+
diff --git a/app/views/boards/_board.json.jbuilder b/app/views/boards/_board.json.jbuilder
new file mode 100644
index 0000000..744fe38
--- /dev/null
+++ b/app/views/boards/_board.json.jbuilder
@@ -0,0 +1,2 @@
+json.extract! board, :id, :slug, :name, :created_at, :updated_at
+json.url board_url(board, format: :json)
diff --git a/app/views/boards/_form.html.erb b/app/views/boards/_form.html.erb
new file mode 100644
index 0000000..67512d5
--- /dev/null
+++ b/app/views/boards/_form.html.erb
@@ -0,0 +1,27 @@
+<%= form_with(model: board, class: "contents") do |form| %>
+ <% if board.errors.any? %>
+
+
<%= pluralize(board.errors.count, "error") %> prohibited this board from being saved:
+
+
+ <% board.errors.each do |error| %>
+ - <%= error.full_message %>
+ <% end %>
+
+
+ <% end %>
+
+
+ <%= form.label :slug %>
+ <%= form.text_field :slug, class: "block shadow rounded-md border border-gray-200 outline-none px-3 py-2 mt-2 w-full" %>
+
+
+
+ <%= form.label :name %>
+ <%= form.text_field :name, class: "block shadow rounded-md border border-gray-200 outline-none px-3 py-2 mt-2 w-full" %>
+
+
+
+ <%= form.submit class: "rounded-lg py-3 px-5 bg-blue-600 text-white inline-block font-medium cursor-pointer" %>
+
+<% end %>
diff --git a/app/views/boards/edit.html.erb b/app/views/boards/edit.html.erb
new file mode 100644
index 0000000..99c70c0
--- /dev/null
+++ b/app/views/boards/edit.html.erb
@@ -0,0 +1,8 @@
+
+
Editing board
+
+ <%= render "form", board: @board %>
+
+ <%= link_to "Show this board", @board, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
+ <%= link_to "Back to boards", boards_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
+
diff --git a/app/views/boards/index.html.erb b/app/views/boards/index.html.erb
new file mode 100644
index 0000000..5c42303
--- /dev/null
+++ b/app/views/boards/index.html.erb
@@ -0,0 +1,14 @@
+
+ <% if notice.present? %>
+
<%= notice %>
+ <% end %>
+
+
+
Boards
+ <%= link_to "New board", new_board_path, class: "rounded-lg py-3 px-5 bg-blue-600 text-white block font-medium" %>
+
+
+
+ <%= render @boards %>
+
+
diff --git a/app/views/boards/index.json.jbuilder b/app/views/boards/index.json.jbuilder
new file mode 100644
index 0000000..fe042c9
--- /dev/null
+++ b/app/views/boards/index.json.jbuilder
@@ -0,0 +1 @@
+json.array! @boards, partial: "boards/board", as: :board
diff --git a/app/views/boards/new.html.erb b/app/views/boards/new.html.erb
new file mode 100644
index 0000000..f4d2285
--- /dev/null
+++ b/app/views/boards/new.html.erb
@@ -0,0 +1,7 @@
+
+
New board
+
+ <%= render "form", board: @board %>
+
+ <%= link_to "Back to boards", boards_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
+
diff --git a/app/views/boards/show.html.erb b/app/views/boards/show.html.erb
new file mode 100644
index 0000000..e0cc8cc
--- /dev/null
+++ b/app/views/boards/show.html.erb
@@ -0,0 +1,15 @@
+
+
+ <% if notice.present? %>
+
<%= notice %>
+ <% end %>
+
+ <%= render @board %>
+
+ <%= link_to "Edit this board", edit_board_path(@board), class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
+
+ <%= button_to "Destroy this board", board_path(@board), method: :delete, class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 font-medium" %>
+
+ <%= link_to "Back to boards", boards_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
+
+
diff --git a/app/views/boards/show.json.jbuilder b/app/views/boards/show.json.jbuilder
new file mode 100644
index 0000000..a6916c4
--- /dev/null
+++ b/app/views/boards/show.json.jbuilder
@@ -0,0 +1 @@
+json.partial! "boards/board", board: @board
diff --git a/app/views/posts/_form.html.erb b/app/views/posts/_form.html.erb
new file mode 100644
index 0000000..224166d
--- /dev/null
+++ b/app/views/posts/_form.html.erb
@@ -0,0 +1,82 @@
+<%= form_with(model: post, class: "contents") do |form| %>
+ <% if post.errors.any? %>
+
+
<%= pluralize(post.errors.count, "error") %> prohibited this post from being saved:
+
+
+ <% post.errors.each do |error| %>
+ - <%= error.full_message %>
+ <% end %>
+
+
+ <% end %>
+
+
+ <%= form.label :board_id %>
+ <%= form.number_field :board_id, class: "block shadow rounded-md border border-gray-200 outline-none px-3 py-2 mt-2 w-full" %>
+
+
+
+ <%= form.label :parent_id %>
+ <%= form.number_field :parent_id, class: "block shadow rounded-md border border-gray-200 outline-none px-3 py-2 mt-2 w-full" %>
+
+
+
+ <%= form.label :visible_id %>
+ <%= form.number_field :visible_id, class: "block shadow rounded-md border border-gray-200 outline-none px-3 py-2 mt-2 w-full" %>
+
+
+
+ <%= form.label :reply_id %>
+ <%= form.number_field :reply_id, class: "block shadow rounded-md border border-gray-200 outline-none px-3 py-2 mt-2 w-full" %>
+
+
+
+ <%= form.label :name %>
+ <%= form.text_field :name, class: "block shadow rounded-md border border-gray-200 outline-none px-3 py-2 mt-2 w-full" %>
+
+
+
+ <%= form.label :title %>
+ <%= form.text_field :title, class: "block shadow rounded-md border border-gray-200 outline-none px-3 py-2 mt-2 w-full" %>
+
+
+
+ <%= form.label :message %>
+ <%= form.text_area :message, rows: 4, class: "block shadow rounded-md border border-gray-200 outline-none px-3 py-2 mt-2 w-full" %>
+
+
+
+ <%= form.label :message_formatted %>
+ <%= form.text_area :message_formatted, rows: 4, class: "block shadow rounded-md border border-gray-200 outline-none px-3 py-2 mt-2 w-full" %>
+
+
+
+ <%= form.label :password %>
+ <%= form.text_field :password, class: "block shadow rounded-md border border-gray-200 outline-none px-3 py-2 mt-2 w-full" %>
+
+
+
+ <%= form.label :created_at %>
+ <%= form.datetime_field :created_at, class: "block shadow rounded-md border border-gray-200 outline-none px-3 py-2 mt-2 w-full" %>
+
+
+
+ <%= form.label :updated_at %>
+ <%= form.datetime_field :updated_at, class: "block shadow rounded-md border border-gray-200 outline-none px-3 py-2 mt-2 w-full" %>
+
+
+
+ <%= form.label :bumped_at %>
+ <%= form.datetime_field :bumped_at, class: "block shadow rounded-md border border-gray-200 outline-none px-3 py-2 mt-2 w-full" %>
+
+
+
+ <%= form.label :deleted_at %>
+ <%= form.datetime_field :deleted_at, class: "block shadow rounded-md border border-gray-200 outline-none px-3 py-2 mt-2 w-full" %>
+
+
+
+ <%= form.submit class: "rounded-lg py-3 px-5 bg-blue-600 text-white inline-block font-medium cursor-pointer" %>
+
+<% end %>
diff --git a/app/views/posts/_post.html.erb b/app/views/posts/_post.html.erb
new file mode 100644
index 0000000..42bc5ed
--- /dev/null
+++ b/app/views/posts/_post.html.erb
@@ -0,0 +1,72 @@
+
+
+ Board:
+ <%= post.board_id %>
+
+
+
+ Parent:
+ <%= post.parent_id %>
+
+
+
+ Visible:
+ <%= post.visible_id %>
+
+
+
+ Reply:
+ <%= post.reply_id %>
+
+
+
+ Name:
+ <%= post.name %>
+
+
+
+ Title:
+ <%= post.title %>
+
+
+
+ Message:
+ <%= post.message %>
+
+
+
+ Message formatted:
+ <%= post.message_formatted %>
+
+
+
+ Password:
+ <%= post.password %>
+
+
+
+ Created at:
+ <%= post.created_at %>
+
+
+
+ Updated at:
+ <%= post.updated_at %>
+
+
+
+ Bumped at:
+ <%= post.bumped_at %>
+
+
+
+ Deleted at:
+ <%= post.deleted_at %>
+
+
+ <% if action_name != "show" %>
+ <%= link_to "Show this post", post, class: "rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
+ <%= link_to "Edit this post", edit_post_path(post), class: "rounded-lg py-3 ml-2 px-5 bg-gray-100 inline-block font-medium" %>
+
+ <% end %>
+
diff --git a/app/views/posts/_post.json.jbuilder b/app/views/posts/_post.json.jbuilder
new file mode 100644
index 0000000..fb2a1e2
--- /dev/null
+++ b/app/views/posts/_post.json.jbuilder
@@ -0,0 +1,2 @@
+json.extract! post, :id, :board_id, :parent_id, :visible_id, :reply_id, :name, :title, :message, :message_formatted, :password, :created_at, :updated_at, :bumped_at, :deleted_at, :created_at, :updated_at
+json.url post_url(post, format: :json)
diff --git a/app/views/posts/edit.html.erb b/app/views/posts/edit.html.erb
new file mode 100644
index 0000000..109dac1
--- /dev/null
+++ b/app/views/posts/edit.html.erb
@@ -0,0 +1,8 @@
+
+
Editing post
+
+ <%= render "form", post: @post %>
+
+ <%= link_to "Show this post", @post, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
+ <%= link_to "Back to posts", posts_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
+
diff --git a/app/views/posts/index.html.erb b/app/views/posts/index.html.erb
new file mode 100644
index 0000000..e35726a
--- /dev/null
+++ b/app/views/posts/index.html.erb
@@ -0,0 +1,14 @@
+
+ <% if notice.present? %>
+
<%= notice %>
+ <% end %>
+
+
+
Posts
+ <%= link_to "New post", new_post_path, class: "rounded-lg py-3 px-5 bg-blue-600 text-white block font-medium" %>
+
+
+
+ <%= render @posts %>
+
+
diff --git a/app/views/posts/index.json.jbuilder b/app/views/posts/index.json.jbuilder
new file mode 100644
index 0000000..a3c6f4a
--- /dev/null
+++ b/app/views/posts/index.json.jbuilder
@@ -0,0 +1 @@
+json.array! @posts, partial: "posts/post", as: :post
diff --git a/app/views/posts/new.html.erb b/app/views/posts/new.html.erb
new file mode 100644
index 0000000..8fdb010
--- /dev/null
+++ b/app/views/posts/new.html.erb
@@ -0,0 +1,7 @@
+
+
New post
+
+ <%= render "form", post: @post %>
+
+ <%= link_to "Back to posts", posts_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
+
diff --git a/app/views/posts/show.html.erb b/app/views/posts/show.html.erb
new file mode 100644
index 0000000..dc1ae42
--- /dev/null
+++ b/app/views/posts/show.html.erb
@@ -0,0 +1,15 @@
+
+
+ <% if notice.present? %>
+
<%= notice %>
+ <% end %>
+
+ <%= render @post %>
+
+ <%= link_to "Edit this post", edit_post_path(@post), class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
+
+ <%= button_to "Destroy this post", post_path(@post), method: :delete, class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 font-medium" %>
+
+ <%= link_to "Back to posts", posts_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
+
+
diff --git a/app/views/posts/show.json.jbuilder b/app/views/posts/show.json.jbuilder
new file mode 100644
index 0000000..5274482
--- /dev/null
+++ b/app/views/posts/show.json.jbuilder
@@ -0,0 +1 @@
+json.partial! "posts/post", post: @post
diff --git a/db/migrate/20231230203445_create_boards.rb b/db/migrate/20231230203445_create_boards.rb
new file mode 100644
index 0000000..b5e7109
--- /dev/null
+++ b/db/migrate/20231230203445_create_boards.rb
@@ -0,0 +1,10 @@
+class CreateBoards < ActiveRecord::Migration[7.1]
+ def change
+ create_table :boards do |t|
+ t.string :slug
+ t.string :name
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20231230205017_create_posts.rb b/db/migrate/20231230205017_create_posts.rb
new file mode 100644
index 0000000..a2bad76
--- /dev/null
+++ b/db/migrate/20231230205017_create_posts.rb
@@ -0,0 +1,21 @@
+class CreatePosts < ActiveRecord::Migration[7.1]
+ def change
+ create_table :posts do |t|
+ t.integer :board_id
+ t.integer :parent_id
+ t.integer :visible_id
+ t.integer :reply_id
+ t.string :name
+ t.string :title
+ t.text :message
+ t.text :message_formatted
+ t.string :password
+ t.datetime :created_at
+ t.datetime :updated_at
+ t.datetime :bumped_at
+ t.datetime :deleted_at
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
new file mode 100644
index 0000000..e3d0914
--- /dev/null
+++ b/db/schema.rb
@@ -0,0 +1,21 @@
+# This file is auto-generated from the current state of the database. Instead
+# of editing this file, please use the migrations feature of Active Record to
+# incrementally modify your database, and then regenerate this schema definition.
+#
+# This file is the source Rails uses to define your schema when running `bin/rails
+# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
+# be faster and is potentially less error prone than running all of your
+# migrations from scratch. Old migrations may fail to apply correctly if those
+# migrations use external dependencies or application code.
+#
+# It's strongly recommended that you check this file into your version control system.
+
+ActiveRecord::Schema[7.1].define(version: 2023_12_30_203445) do
+ create_table "boards", force: :cascade do |t|
+ t.string "slug"
+ t.string "name"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
+end
diff --git a/test/controllers/boards_controller_test.rb b/test/controllers/boards_controller_test.rb
new file mode 100644
index 0000000..cd9799b
--- /dev/null
+++ b/test/controllers/boards_controller_test.rb
@@ -0,0 +1,48 @@
+require "test_helper"
+
+class BoardsControllerTest < ActionDispatch::IntegrationTest
+ setup do
+ @board = boards(:one)
+ end
+
+ test "should get index" do
+ get boards_url
+ assert_response :success
+ end
+
+ test "should get new" do
+ get new_board_url
+ assert_response :success
+ end
+
+ test "should create board" do
+ assert_difference("Board.count") do
+ post boards_url, params: { board: { name: @board.name, slug: @board.slug } }
+ end
+
+ assert_redirected_to board_url(Board.last)
+ end
+
+ test "should show board" do
+ get board_url(@board)
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get edit_board_url(@board)
+ assert_response :success
+ end
+
+ test "should update board" do
+ patch board_url(@board), params: { board: { name: @board.name, slug: @board.slug } }
+ assert_redirected_to board_url(@board)
+ end
+
+ test "should destroy board" do
+ assert_difference("Board.count", -1) do
+ delete board_url(@board)
+ end
+
+ assert_redirected_to boards_url
+ end
+end
diff --git a/test/controllers/posts_controller_test.rb b/test/controllers/posts_controller_test.rb
new file mode 100644
index 0000000..ec8fb73
--- /dev/null
+++ b/test/controllers/posts_controller_test.rb
@@ -0,0 +1,48 @@
+require "test_helper"
+
+class PostsControllerTest < ActionDispatch::IntegrationTest
+ setup do
+ @post = posts(:one)
+ end
+
+ test "should get index" do
+ get posts_url
+ assert_response :success
+ end
+
+ test "should get new" do
+ get new_post_url
+ assert_response :success
+ end
+
+ test "should create post" do
+ assert_difference("Post.count") do
+ post posts_url, params: { post: { board_id: @post.board_id, bumped_at: @post.bumped_at, created_at: @post.created_at, deleted_at: @post.deleted_at, message: @post.message, message_formatted: @post.message_formatted, name: @post.name, parent_id: @post.parent_id, password: @post.password, reply_id: @post.reply_id, title: @post.title, updated_at: @post.updated_at, visible_id: @post.visible_id } }
+ end
+
+ assert_redirected_to post_url(Post.last)
+ end
+
+ test "should show post" do
+ get post_url(@post)
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get edit_post_url(@post)
+ assert_response :success
+ end
+
+ test "should update post" do
+ patch post_url(@post), params: { post: { board_id: @post.board_id, bumped_at: @post.bumped_at, created_at: @post.created_at, deleted_at: @post.deleted_at, message: @post.message, message_formatted: @post.message_formatted, name: @post.name, parent_id: @post.parent_id, password: @post.password, reply_id: @post.reply_id, title: @post.title, updated_at: @post.updated_at, visible_id: @post.visible_id } }
+ assert_redirected_to post_url(@post)
+ end
+
+ test "should destroy post" do
+ assert_difference("Post.count", -1) do
+ delete post_url(@post)
+ end
+
+ assert_redirected_to posts_url
+ end
+end
diff --git a/test/fixtures/boards.yml b/test/fixtures/boards.yml
new file mode 100644
index 0000000..7c2b66c
--- /dev/null
+++ b/test/fixtures/boards.yml
@@ -0,0 +1,9 @@
+# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+one:
+ slug: MyString
+ name: MyString
+
+two:
+ slug: MyString
+ name: MyString
diff --git a/test/fixtures/posts.yml b/test/fixtures/posts.yml
new file mode 100644
index 0000000..2368047
--- /dev/null
+++ b/test/fixtures/posts.yml
@@ -0,0 +1,31 @@
+# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+one:
+ board_id: 1
+ parent_id: 1
+ visible_id: 1
+ reply_id: 1
+ name: MyString
+ title: MyString
+ message: MyText
+ message_formatted: MyText
+ password: MyString
+ created_at: 2023-12-31 02:50:17
+ updated_at: 2023-12-31 02:50:17
+ bumped_at: 2023-12-31 02:50:17
+ deleted_at: 2023-12-31 02:50:17
+
+two:
+ board_id: 1
+ parent_id: 1
+ visible_id: 1
+ reply_id: 1
+ name: MyString
+ title: MyString
+ message: MyText
+ message_formatted: MyText
+ password: MyString
+ created_at: 2023-12-31 02:50:17
+ updated_at: 2023-12-31 02:50:17
+ bumped_at: 2023-12-31 02:50:17
+ deleted_at: 2023-12-31 02:50:17
diff --git a/test/models/board_test.rb b/test/models/board_test.rb
new file mode 100644
index 0000000..efde2c3
--- /dev/null
+++ b/test/models/board_test.rb
@@ -0,0 +1,7 @@
+require "test_helper"
+
+class BoardTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/models/post_test.rb b/test/models/post_test.rb
new file mode 100644
index 0000000..ff155c4
--- /dev/null
+++ b/test/models/post_test.rb
@@ -0,0 +1,7 @@
+require "test_helper"
+
+class PostTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/system/boards_test.rb b/test/system/boards_test.rb
new file mode 100644
index 0000000..e2a23ac
--- /dev/null
+++ b/test/system/boards_test.rb
@@ -0,0 +1,43 @@
+require "application_system_test_case"
+
+class BoardsTest < ApplicationSystemTestCase
+ setup do
+ @board = boards(:one)
+ end
+
+ test "visiting the index" do
+ visit boards_url
+ assert_selector "h1", text: "Boards"
+ end
+
+ test "should create board" do
+ visit boards_url
+ click_on "New board"
+
+ fill_in "Name", with: @board.name
+ fill_in "Slug", with: @board.slug
+ click_on "Create Board"
+
+ assert_text "Board was successfully created"
+ click_on "Back"
+ end
+
+ test "should update Board" do
+ visit board_url(@board)
+ click_on "Edit this board", match: :first
+
+ fill_in "Name", with: @board.name
+ fill_in "Slug", with: @board.slug
+ click_on "Update Board"
+
+ assert_text "Board was successfully updated"
+ click_on "Back"
+ end
+
+ test "should destroy Board" do
+ visit board_url(@board)
+ click_on "Destroy this board", match: :first
+
+ assert_text "Board was successfully destroyed"
+ end
+end
diff --git a/test/system/posts_test.rb b/test/system/posts_test.rb
new file mode 100644
index 0000000..1179fc3
--- /dev/null
+++ b/test/system/posts_test.rb
@@ -0,0 +1,65 @@
+require "application_system_test_case"
+
+class PostsTest < ApplicationSystemTestCase
+ setup do
+ @post = posts(:one)
+ end
+
+ test "visiting the index" do
+ visit posts_url
+ assert_selector "h1", text: "Posts"
+ end
+
+ test "should create post" do
+ visit posts_url
+ click_on "New post"
+
+ fill_in "Board", with: @post.board_id
+ fill_in "Bumped at", with: @post.bumped_at
+ fill_in "Created at", with: @post.created_at
+ fill_in "Deleted at", with: @post.deleted_at
+ fill_in "Message", with: @post.message
+ fill_in "Message formatted", with: @post.message_formatted
+ fill_in "Name", with: @post.name
+ fill_in "Parent", with: @post.parent_id
+ fill_in "Password", with: @post.password
+ fill_in "Reply", with: @post.reply_id
+ fill_in "Title", with: @post.title
+ fill_in "Updated at", with: @post.updated_at
+ fill_in "Visible", with: @post.visible_id
+ click_on "Create Post"
+
+ assert_text "Post was successfully created"
+ click_on "Back"
+ end
+
+ test "should update Post" do
+ visit post_url(@post)
+ click_on "Edit this post", match: :first
+
+ fill_in "Board", with: @post.board_id
+ fill_in "Bumped at", with: @post.bumped_at
+ fill_in "Created at", with: @post.created_at
+ fill_in "Deleted at", with: @post.deleted_at
+ fill_in "Message", with: @post.message
+ fill_in "Message formatted", with: @post.message_formatted
+ fill_in "Name", with: @post.name
+ fill_in "Parent", with: @post.parent_id
+ fill_in "Password", with: @post.password
+ fill_in "Reply", with: @post.reply_id
+ fill_in "Title", with: @post.title
+ fill_in "Updated at", with: @post.updated_at
+ fill_in "Visible", with: @post.visible_id
+ click_on "Update Post"
+
+ assert_text "Post was successfully updated"
+ click_on "Back"
+ end
+
+ test "should destroy Post" do
+ visit post_url(@post)
+ click_on "Destroy this post", match: :first
+
+ assert_text "Post was successfully destroyed"
+ end
+end