From f048caa0ccfce5f555e56766c204f05adbc10c11 Mon Sep 17 00:00:00 2001 From: mikoto2000 Date: Sat, 7 Sep 2024 02:44:57 +0000 Subject: [PATCH] =?UTF-8?q?=E8=B2=B8=E5=87=BA=E3=82=B9=E3=83=86=E3=83=BC?= =?UTF-8?q?=E3=82=BF=E3=82=B9=E3=81=A8=E6=9B=B8=E7=B1=8D=E5=9C=A8=E5=BA=AB?= =?UTF-8?q?=E3=81=AE=E7=99=BB=E9=8C=B2=E3=83=BB=E5=8F=82=E7=85=A7=E3=83=9A?= =?UTF-8?q?=E3=83=BC=E3=82=B8=E3=82=92=E8=BF=BD=E5=8A=A0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 + .../book_stock_statuses_controller.rb | 65 ++++++++ app/controllers/book_stocks_controller.rb | 68 ++++++++ app/helpers/book_stock_statuses_helper.rb | 3 + app/helpers/book_stocks_helper.rb | 3 + app/models/book_stock.rb | 7 + app/models/book_stock_status.rb | 5 + .../_book_stock_status.html.erb | 42 +++++ .../_book_stock_status.json.jbuilder | 2 + app/views/book_stock_statuses/_form.html.erb | 45 ++++++ app/views/book_stock_statuses/edit.html.erb | 9 ++ app/views/book_stock_statuses/index.html.erb | 111 +++++++++++++ .../book_stock_statuses/index.json.jbuilder | 1 + app/views/book_stock_statuses/new.html.erb | 8 + app/views/book_stock_statuses/show.html.erb | 16 ++ .../book_stock_statuses/show.json.jbuilder | 1 + app/views/book_stocks/_book_stock.html.erb | 62 ++++++++ .../book_stocks/_book_stock.json.jbuilder | 2 + app/views/book_stocks/_form.html.erb | 69 ++++++++ app/views/book_stocks/edit.html.erb | 9 ++ app/views/book_stocks/index.html.erb | 141 ++++++++++++++++ app/views/book_stocks/index.json.jbuilder | 1 + app/views/book_stocks/new.html.erb | 8 + app/views/book_stocks/show.html.erb | 16 ++ app/views/book_stocks/show.json.jbuilder | 1 + config/routes.rb | 2 + ...240907021517_create_book_stock_statuses.rb | 9 ++ .../20240907021544_create_book_stocks.rb | 11 ++ db/schema.rb | 20 ++- db/seeds.rb | 15 ++ doc/worklog.md | 60 +++++++ .../book_stock_statuses_controller_test.rb | 132 +++++++++++++++ .../book_stocks_controller_test.rb | 150 ++++++++++++++++++ test/fixtures/book_stock_statuses.yml | 21 +++ test/fixtures/book_stocks.yml | 29 ++++ test/models/book_stock_status_test.rb | 7 + test/models/book_stock_test.rb | 7 + test/system/book_stock_statuses_test.rb | 41 +++++ test/system/book_stocks_test.rb | 45 ++++++ 39 files changed, 1245 insertions(+), 1 deletion(-) create mode 100644 app/controllers/book_stock_statuses_controller.rb create mode 100644 app/controllers/book_stocks_controller.rb create mode 100644 app/helpers/book_stock_statuses_helper.rb create mode 100644 app/helpers/book_stocks_helper.rb create mode 100644 app/models/book_stock.rb create mode 100644 app/models/book_stock_status.rb create mode 100644 app/views/book_stock_statuses/_book_stock_status.html.erb create mode 100644 app/views/book_stock_statuses/_book_stock_status.json.jbuilder create mode 100644 app/views/book_stock_statuses/_form.html.erb create mode 100644 app/views/book_stock_statuses/edit.html.erb create mode 100644 app/views/book_stock_statuses/index.html.erb create mode 100644 app/views/book_stock_statuses/index.json.jbuilder create mode 100644 app/views/book_stock_statuses/new.html.erb create mode 100644 app/views/book_stock_statuses/show.html.erb create mode 100644 app/views/book_stock_statuses/show.json.jbuilder create mode 100644 app/views/book_stocks/_book_stock.html.erb create mode 100644 app/views/book_stocks/_book_stock.json.jbuilder create mode 100644 app/views/book_stocks/_form.html.erb create mode 100644 app/views/book_stocks/edit.html.erb create mode 100644 app/views/book_stocks/index.html.erb create mode 100644 app/views/book_stocks/index.json.jbuilder create mode 100644 app/views/book_stocks/new.html.erb create mode 100644 app/views/book_stocks/show.html.erb create mode 100644 app/views/book_stocks/show.json.jbuilder create mode 100644 db/migrate/20240907021517_create_book_stock_statuses.rb create mode 100644 db/migrate/20240907021544_create_book_stocks.rb create mode 100644 test/controllers/book_stock_statuses_controller_test.rb create mode 100644 test/controllers/book_stocks_controller_test.rb create mode 100644 test/fixtures/book_stock_statuses.yml create mode 100644 test/fixtures/book_stocks.yml create mode 100644 test/models/book_stock_status_test.rb create mode 100644 test/models/book_stock_test.rb create mode 100644 test/system/book_stock_statuses_test.rb create mode 100644 test/system/book_stocks_test.rb diff --git a/.gitignore b/.gitignore index 1a2d2ce..cf35911 100644 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,5 @@ !/app/assets/builds/.keep /node_modules + +vendor/ diff --git a/app/controllers/book_stock_statuses_controller.rb b/app/controllers/book_stock_statuses_controller.rb new file mode 100644 index 0000000..b725ad9 --- /dev/null +++ b/app/controllers/book_stock_statuses_controller.rb @@ -0,0 +1,65 @@ +class BookStockStatusesController < ApplicationController + include Pagy::Backend + before_action :set_book_stock_status, only: %i[show edit update destroy] + + # GET /book_stock_statuses + def index + @book_stock_statuses = BookStockStatus + .all + @q = @book_stock_statuses.ransack(params[:q]) + @q.sorts = "id asc" if @q.sorts.empty? + @pagy, @book_stock_statuses = pagy(@q.result, page: params[:page], items: params[:items]) + end + + # GET /book_stock_statuses/1 + def show + end + + # GET /book_stock_statuses/new + def new + @book_stock_status = BookStockStatus.new + end + + # GET /book_stock_statuses/1/edit + def edit + end + + # POST /book_stock_statuses + def create + @book_stock_status = BookStockStatus.new(book_stock_status_params) + + if @book_stock_status.save + redirect_to @book_stock_status, notice: t("controller.create.success", model: BookStockStatus.model_name.human) + else + render :new, status: :unprocessable_entity + end + end + + # PATCH/PUT /book_stock_statuses/1 + def update + if @book_stock_status.update(book_stock_status_params) + redirect_to @book_stock_status, notice: t("controller.edit.success", model: BookStockStatus.model_name.human) + else + render :edit, status: :unprocessable_entity + end + end + + # DELETE /book_stock_statuses/1 + def destroy + @book_stock_status.destroy! + redirect_to book_stock_statuses_url, notice: t("controller.destroy.success", model: BookStockStatus.model_name.human) + end + + private + + # Use callbacks to share common setup or constraints between actions. + def set_book_stock_status + @book_stock_status = BookStockStatus + .find(params[:id]) + end + + # Only allow a list of trusted parameters through. + def book_stock_status_params + params.require(:book_stock_status).permit(:name) + end +end diff --git a/app/controllers/book_stocks_controller.rb b/app/controllers/book_stocks_controller.rb new file mode 100644 index 0000000..5f74cd7 --- /dev/null +++ b/app/controllers/book_stocks_controller.rb @@ -0,0 +1,68 @@ +class BookStocksController < ApplicationController + include Pagy::Backend + before_action :set_book_stock, only: %i[show edit update destroy] + + # GET /book_stocks + def index + @book_stocks = BookStock + .eager_load(:book_master) + .eager_load(:book_stock_status) + @q = @book_stocks.ransack(params[:q]) + @q.sorts = "id asc" if @q.sorts.empty? + @pagy, @book_stocks = pagy(@q.result, page: params[:page], items: params[:items]) + end + + # GET /book_stocks/1 + def show + end + + # GET /book_stocks/new + def new + @book_stock = BookStock.new + end + + # GET /book_stocks/1/edit + def edit + end + + # POST /book_stocks + def create + @book_stock = BookStock.new(book_stock_params) + + if @book_stock.save + redirect_to @book_stock, notice: t("controller.create.success", model: BookStock.model_name.human) + else + render :new, status: :unprocessable_entity + end + end + + # PATCH/PUT /book_stocks/1 + def update + if @book_stock.update(book_stock_params) + redirect_to @book_stock, notice: t("controller.edit.success", model: BookStock.model_name.human) + else + render :edit, status: :unprocessable_entity + end + end + + # DELETE /book_stocks/1 + def destroy + @book_stock.destroy! + redirect_to book_stocks_url, notice: t("controller.destroy.success", model: BookStock.model_name.human) + end + + private + + # Use callbacks to share common setup or constraints between actions. + def set_book_stock + @book_stock = BookStock + .eager_load(:book_master) + .eager_load(:book_stock_status) + .find(params[:id]) + end + + # Only allow a list of trusted parameters through. + def book_stock_params + params.require(:book_stock).permit(:book_master_id, :book_stock_status_id, :memo) + end +end diff --git a/app/helpers/book_stock_statuses_helper.rb b/app/helpers/book_stock_statuses_helper.rb new file mode 100644 index 0000000..d1d7777 --- /dev/null +++ b/app/helpers/book_stock_statuses_helper.rb @@ -0,0 +1,3 @@ +module BookStockStatusesHelper + include Pagy::Frontend +end diff --git a/app/helpers/book_stocks_helper.rb b/app/helpers/book_stocks_helper.rb new file mode 100644 index 0000000..e2ebcc6 --- /dev/null +++ b/app/helpers/book_stocks_helper.rb @@ -0,0 +1,3 @@ +module BookStocksHelper + include Pagy::Frontend +end diff --git a/app/models/book_stock.rb b/app/models/book_stock.rb new file mode 100644 index 0000000..65d543d --- /dev/null +++ b/app/models/book_stock.rb @@ -0,0 +1,7 @@ +class BookStock < ApplicationRecord + def self.ransackable_attributes(_auth_object = nil) + %w[book_master_id book_stock_status_id memo id created_at updated_at] + end + belongs_to :book_master + belongs_to :book_stock_status +end diff --git a/app/models/book_stock_status.rb b/app/models/book_stock_status.rb new file mode 100644 index 0000000..d323b28 --- /dev/null +++ b/app/models/book_stock_status.rb @@ -0,0 +1,5 @@ +class BookStockStatus < ApplicationRecord + def self.ransackable_attributes(_auth_object = nil) + %w[name id created_at updated_at] + end +end diff --git a/app/views/book_stock_statuses/_book_stock_status.html.erb b/app/views/book_stock_statuses/_book_stock_status.html.erb new file mode 100644 index 0000000..0315ed4 --- /dev/null +++ b/app/views/book_stock_statuses/_book_stock_status.html.erb @@ -0,0 +1,42 @@ +
+ + + + + + + + + + + + + + + + + +
+ Id: + + <%= book_stock_status.id %> +
+ + <%= BookStockStatus.human_attribute_name(:name) %> + + + <%= book_stock_status.name %> +
+ + <%= BookStockStatus.human_attribute_name(:created_at) %> + + + <%= book_stock_status.created_at && l(book_stock_status.created_at) %> +
+ + <%= BookStockStatus.human_attribute_name(:updated_at) %> + + + <%= book_stock_status.updated_at && l(book_stock_status.updated_at) %> +
+
diff --git a/app/views/book_stock_statuses/_book_stock_status.json.jbuilder b/app/views/book_stock_statuses/_book_stock_status.json.jbuilder new file mode 100644 index 0000000..590ed50 --- /dev/null +++ b/app/views/book_stock_statuses/_book_stock_status.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! book_stock_status, :id, :name, :created_at, :updated_at +json.url book_stock_status_url(book_stock_status, format: :json) diff --git a/app/views/book_stock_statuses/_form.html.erb b/app/views/book_stock_statuses/_form.html.erb new file mode 100644 index 0000000..53a4db5 --- /dev/null +++ b/app/views/book_stock_statuses/_form.html.erb @@ -0,0 +1,45 @@ +<%= form_with(model: book_stock_status, html: { class: %w[form-control form-control-sm] }) do |form| -%> + <%- if book_stock_status.errors.any? -%> +
+

<%= t("errors.template.header", model: BookStockStatus.model_name.human, count: book_stock_status.errors.count) %>

+ + +
+ <%- end -%> + + <%- if book_stock_status.persisted? -%> +
+ <%= form.label :id, style: "display: block" %> +
+ <%= form.number_field :id, class: %w[form-control form-control-sm], disabled: true %> +
+
+ <%- end -%> +
+ <%= form.label :name, style: "display: block" %> +
+ <%= form.text_field :name, class: %w[form-control form-control-sm] %> +
+
+ <%- if book_stock_status.persisted? -%> +
+ <%= form.label :created_at, style: "display: block" %> +
+ <%= form.datetime_field :created_at, class: %w[form-control form-control-sm], disabled: true %> +
+
+
+ <%= form.label :updated_at, style: "display: block" %> +
+ <%= form.datetime_field :updated_at, class: %w[form-control form-control-sm], disabled: true %> +
+
+ <%- end -%> +
+ <%= form.submit class: %w[btn btn-primary] %> +
+<% end %> diff --git a/app/views/book_stock_statuses/edit.html.erb b/app/views/book_stock_statuses/edit.html.erb new file mode 100644 index 0000000..c90fa9d --- /dev/null +++ b/app/views/book_stock_statuses/edit.html.erb @@ -0,0 +1,9 @@ +

<%= t("view.edit.title", model: BookStockStatus.model_name.human) %>

+<%= render "form", book_stock_status: @book_stock_status %> + +
+ +
+ <%= link_to t("view.edit.move_to_show", model: BookStockStatus.model_name.human), @book_stock_status %> | + <%= link_to t("view.edit.move_to_index", model: BookStockStatus.model_name.human.pluralize), book_stock_statuses_path %> +
diff --git a/app/views/book_stock_statuses/index.html.erb b/app/views/book_stock_statuses/index.html.erb new file mode 100644 index 0000000..f979518 --- /dev/null +++ b/app/views/book_stock_statuses/index.html.erb @@ -0,0 +1,111 @@ +
+ +
+

<%= notice %>

+ +

<%= BookStockStatus.model_name.human %><%= link_to "", new_book_stock_status_path, class: %w[bi bi-plus-circle-fill ms-2] %>

+ +
+
+

+ +

+
+<%= search_form_for @q, html: { class: %w[form-control form-control-sm], data: { turbo_frame: "list" } } do |f| %> +
+ <%= f.label :id_eq %> +
+ <%= f.number_field :id_eq, class: %w[form-control form-control-sm] %> +
+
+
+ <%= f.label :name_cont %> +
+ <%= f.search_field :name_cont, class: %w[form-control form-control-sm] %> +
+
+
+ <%= f.label :created_at %> +
+ <%= f.datetime_field :created_at_gteq, class: %w[form-control form-control-sm] %> + ~ + <%= f.datetime_field :created_at_lteq_end_of_minute, class: %w[form-control form-control-sm] %> +
+
+
+ <%= f.label :updated_at %> +
+ <%= f.datetime_field :updated_at_gteq, class: %w[form-control form-control-sm] %> + ~ + <%= f.datetime_field :updated_at_lteq_end_of_minute, class: %w[form-control form-control-sm] %> +
+
+ <%= f.hidden_field :limit, id: "f-limit", value: params[:limit] || Pagy::DEFAULT[:limit] %> + <%= f.submit class: %w[btn btn-primary] %> + "> +<%- end -%> +
+
+
+ +
+<%= turbo_frame_tag "list" do %> +
+ + + + + + + + + + <%- @book_stock_statuses.each do |book_stock_status| %> + + + + + + + + <%- end %> + +
<%= sort_link(@q, :id, default_order: :asc, class: "d-block") %><%= sort_link(@q, :name, default_order: :asc, class: "d-block") %><%= sort_link(@q, :created_at, default_order: :asc, class: "d-block") %><%= sort_link(@q, :updated_at, default_order: :asc, class: "d-block") %><%= t("view.index.operation") %>
<%= book_stock_status.id %><%= book_stock_status.name %><%= book_stock_status.created_at && l(book_stock_status.created_at) %><%= book_stock_status.updated_at && l(book_stock_status.updated_at) %> + <%= button_to( + t("helpers.submit.delete"), + book_stock_status, + method: :delete, + tabindex: 0, + class: %w[btn btn-primary], + onclick: "handleDeleteListItem(arguments[0], this)", + data: { turbo_confirm: t("helpers.dialog.delete", id: book_stock_status.id) } + ) %> +
+
+
+ <%== pagy_bootstrap_nav(@pagy) %> + <%== pagy_limit_selector_js(@pagy, item_name: "Book stock status".pluralize(@pagy.count), id: "pagy-limit-selector") %> + <%= link_to( + t("view.index.update_item_per_page", model: BookStockStatus.model_name.human), + "javascript:void(0);", + onClick: "updateItemPerPage(arguments[0], + this)" + ) %> +
+<% end %> +
+
diff --git a/app/views/book_stock_statuses/index.json.jbuilder b/app/views/book_stock_statuses/index.json.jbuilder new file mode 100644 index 0000000..c94b790 --- /dev/null +++ b/app/views/book_stock_statuses/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @book_stock_statuses, partial: "book_stock_statuses/book_stock_status", as: :book_stock_status diff --git a/app/views/book_stock_statuses/new.html.erb b/app/views/book_stock_statuses/new.html.erb new file mode 100644 index 0000000..6d11dc5 --- /dev/null +++ b/app/views/book_stock_statuses/new.html.erb @@ -0,0 +1,8 @@ +

<%= t("view.new.title", model: BookStockStatus.model_name.human) %>

+<%= render "form", book_stock_status: @book_stock_status %> + +
+ +
+ <%= link_to t("view.new.move_to_index", model: BookStockStatus.model_name.human.pluralize), book_stock_statuses_path %> +
diff --git a/app/views/book_stock_statuses/show.html.erb b/app/views/book_stock_statuses/show.html.erb new file mode 100644 index 0000000..2d270a7 --- /dev/null +++ b/app/views/book_stock_statuses/show.html.erb @@ -0,0 +1,16 @@ +

<%= notice %>

+ +

<%= BookStockStatus.model_name.human %>

+ +<%= render @book_stock_status %> + +
+ <%= link_to t("view.show.move_to_update", model: BookStockStatus.model_name.human), edit_book_stock_status_path(@book_stock_status) %> | + <%= link_to t("view.show.move_to_index", model: BookStockStatus.model_name.human.pluralize), book_stock_statuses_path %> + + <%= button_to t("helpers.submit.delete"), + @book_stock_status, + method: :delete, + class: %w[btn btn-primary], + data: { turbo_confirm: t("helpers.dialog.delete", id: @book_stock_status.id) } %> +
diff --git a/app/views/book_stock_statuses/show.json.jbuilder b/app/views/book_stock_statuses/show.json.jbuilder new file mode 100644 index 0000000..61cf3d4 --- /dev/null +++ b/app/views/book_stock_statuses/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "book_stock_statuses/book_stock_status", book_stock_status: @book_stock_status diff --git a/app/views/book_stocks/_book_stock.html.erb b/app/views/book_stocks/_book_stock.html.erb new file mode 100644 index 0000000..d2e8e93 --- /dev/null +++ b/app/views/book_stocks/_book_stock.html.erb @@ -0,0 +1,62 @@ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ Id: + + <%= book_stock.id %> +
+ + <%= BookStock.human_attribute_name(:book_master_id) %> + + + <%= book_stock.book_master.title %> +
+ + <%= BookStock.human_attribute_name(:book_stock_status_id) %> + + + <%= book_stock.book_stock_status.name %> +
+ + <%= BookStock.human_attribute_name(:memo) %> + + + <%= book_stock.memo %> +
+ + <%= BookStock.human_attribute_name(:created_at) %> + + + <%= book_stock.created_at && l(book_stock.created_at) %> +
+ + <%= BookStock.human_attribute_name(:updated_at) %> + + + <%= book_stock.updated_at && l(book_stock.updated_at) %> +
+
diff --git a/app/views/book_stocks/_book_stock.json.jbuilder b/app/views/book_stocks/_book_stock.json.jbuilder new file mode 100644 index 0000000..e8247cf --- /dev/null +++ b/app/views/book_stocks/_book_stock.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! book_stock, :id, :book_master_id, :book_stock_status_id, :memo, :created_at, :updated_at +json.url book_stock_url(book_stock, format: :json) diff --git a/app/views/book_stocks/_form.html.erb b/app/views/book_stocks/_form.html.erb new file mode 100644 index 0000000..4f1de92 --- /dev/null +++ b/app/views/book_stocks/_form.html.erb @@ -0,0 +1,69 @@ +<%= form_with(model: book_stock, html: { class: %w[form-control form-control-sm] }) do |form| -%> + <%- if book_stock.errors.any? -%> +
+

<%= t("errors.template.header", model: BookStock.model_name.human, count: book_stock.errors.count) %>

+ + +
+ <%- end -%> + + <%- if book_stock.persisted? -%> +
+ <%= form.label :id, style: "display: block" %> +
+ <%= form.number_field :id, class: %w[form-control form-control-sm], disabled: true %> +
+
+ <%- end -%> +
+ <%= form.label BookStock.reflect_on_association(:book_master).foreign_key %> +
+ <%= form.collection_select( + BookStock.reflect_on_association(:book_master).foreign_key, + BookStock.reflect_on_association(:book_master).klass.all, + :id, + :title, + { include_blank: "選択なし" } + ) %> +
+
+
+ <%= form.label BookStock.reflect_on_association(:book_stock_status).foreign_key %> +
+ <%= form.collection_select( + BookStock.reflect_on_association(:book_stock_status).foreign_key, + BookStock.reflect_on_association(:book_stock_status).klass.all, + :id, + :name, + { include_blank: "選択なし" } + ) %> +
+
+
+ <%= form.label :memo, style: "display: block" %> +
+ <%= form.text_area :memo, class: %w[form-control form-control-sm] %> +
+
+ <%- if book_stock.persisted? -%> +
+ <%= form.label :created_at, style: "display: block" %> +
+ <%= form.datetime_field :created_at, class: %w[form-control form-control-sm], disabled: true %> +
+
+
+ <%= form.label :updated_at, style: "display: block" %> +
+ <%= form.datetime_field :updated_at, class: %w[form-control form-control-sm], disabled: true %> +
+
+ <%- end -%> +
+ <%= form.submit class: %w[btn btn-primary] %> +
+<% end %> diff --git a/app/views/book_stocks/edit.html.erb b/app/views/book_stocks/edit.html.erb new file mode 100644 index 0000000..494b355 --- /dev/null +++ b/app/views/book_stocks/edit.html.erb @@ -0,0 +1,9 @@ +

<%= t("view.edit.title", model: BookStock.model_name.human) %>

+<%= render "form", book_stock: @book_stock %> + +
+ +
+ <%= link_to t("view.edit.move_to_show", model: BookStock.model_name.human), @book_stock %> | + <%= link_to t("view.edit.move_to_index", model: BookStock.model_name.human.pluralize), book_stocks_path %> +
diff --git a/app/views/book_stocks/index.html.erb b/app/views/book_stocks/index.html.erb new file mode 100644 index 0000000..b3c5edd --- /dev/null +++ b/app/views/book_stocks/index.html.erb @@ -0,0 +1,141 @@ +
+ +
+

<%= notice %>

+ +

<%= BookStock.model_name.human %><%= link_to "", new_book_stock_path, class: %w[bi bi-plus-circle-fill ms-2] %>

+ +
+
+

+ +

+
+<%= search_form_for @q, html: { class: %w[form-control form-control-sm], data: { turbo_frame: "list" } } do |f| %> +
+ <%= f.label :id_eq %> +
+ <%= f.number_field :id_eq, class: %w[form-control form-control-sm] %> +
+
+
+ <%= f.label BookStock.reflect_on_association(:book_master).foreign_key + "_in".to_s %> +
+ <%= f.collection_select( + BookStock.reflect_on_association(:book_master).foreign_key + "_in".to_s, + BookStock.reflect_on_association(:book_master).klass.all, + :id, + :title, + {}, + { multiple: true } + ) %> +
+
+
+ <%= f.label BookStock.reflect_on_association(:book_stock_status).foreign_key + "_in".to_s %> +
+ <%= f.collection_select( + BookStock.reflect_on_association(:book_stock_status).foreign_key + "_in".to_s, + BookStock.reflect_on_association(:book_stock_status).klass.all, + :id, + :name, + {}, + { multiple: true } + ) %> +
+
+
+ <%= f.label :memo_cont %> +
+ <%= f.search_field :memo_cont, class: %w[form-control form-control-sm] %> +
+
+
+ <%= f.label :created_at %> +
+ <%= f.datetime_field :created_at_gteq, class: %w[form-control form-control-sm] %> + ~ + <%= f.datetime_field :created_at_lteq_end_of_minute, class: %w[form-control form-control-sm] %> +
+
+
+ <%= f.label :updated_at %> +
+ <%= f.datetime_field :updated_at_gteq, class: %w[form-control form-control-sm] %> + ~ + <%= f.datetime_field :updated_at_lteq_end_of_minute, class: %w[form-control form-control-sm] %> +
+
+ <%= f.hidden_field :limit, id: "f-limit", value: params[:limit] || Pagy::DEFAULT[:limit] %> + <%= f.submit class: %w[btn btn-primary] %> + "> +<%- end -%> +
+
+
+ +
+<%= turbo_frame_tag "list" do %> +
+ + + + + + + + + + + + <%- @book_stocks.each do |book_stock| %> + + + + + + + + + + <%- end %> + +
<%= sort_link(@q, :id, default_order: :asc, class: "d-block") %><%= sort_link(@q, :book_master_id, default_order: :asc, class: "d-block") %><%= sort_link(@q, :book_stock_status_id, default_order: :asc, class: "d-block") %><%= sort_link(@q, :memo, default_order: :asc, class: "d-block") %><%= sort_link(@q, :created_at, default_order: :asc, class: "d-block") %><%= sort_link(@q, :updated_at, default_order: :asc, class: "d-block") %><%= t("view.index.operation") %>
<%= book_stock.id %><%= book_stock.book_master.title %><%= book_stock.book_stock_status.name %><%= book_stock.memo %><%= book_stock.created_at && l(book_stock.created_at) %><%= book_stock.updated_at && l(book_stock.updated_at) %> + <%= button_to( + t("helpers.submit.delete"), + book_stock, + method: :delete, + tabindex: 0, + class: %w[btn btn-primary], + onclick: "handleDeleteListItem(arguments[0], this)", + data: { turbo_confirm: t("helpers.dialog.delete", id: book_stock.id) } + ) %> +
+
+
+ <%== pagy_bootstrap_nav(@pagy) %> + <%== pagy_limit_selector_js(@pagy, item_name: "Book stock".pluralize(@pagy.count), id: "pagy-limit-selector") %> + <%= link_to( + t("view.index.update_item_per_page", model: BookStock.model_name.human), + "javascript:void(0);", + onClick: "updateItemPerPage(arguments[0], + this)" + ) %> +
+<% end %> +
+
diff --git a/app/views/book_stocks/index.json.jbuilder b/app/views/book_stocks/index.json.jbuilder new file mode 100644 index 0000000..ffd4ba9 --- /dev/null +++ b/app/views/book_stocks/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @book_stocks, partial: "book_stocks/book_stock", as: :book_stock diff --git a/app/views/book_stocks/new.html.erb b/app/views/book_stocks/new.html.erb new file mode 100644 index 0000000..b6ab3bf --- /dev/null +++ b/app/views/book_stocks/new.html.erb @@ -0,0 +1,8 @@ +

<%= t("view.new.title", model: BookStock.model_name.human) %>

+<%= render "form", book_stock: @book_stock %> + +
+ +
+ <%= link_to t("view.new.move_to_index", model: BookStock.model_name.human.pluralize), book_stocks_path %> +
diff --git a/app/views/book_stocks/show.html.erb b/app/views/book_stocks/show.html.erb new file mode 100644 index 0000000..a9b6366 --- /dev/null +++ b/app/views/book_stocks/show.html.erb @@ -0,0 +1,16 @@ +

<%= notice %>

+ +

<%= BookStock.model_name.human %>

+ +<%= render @book_stock %> + +
+ <%= link_to t("view.show.move_to_update", model: BookStock.model_name.human), edit_book_stock_path(@book_stock) %> | + <%= link_to t("view.show.move_to_index", model: BookStock.model_name.human.pluralize), book_stocks_path %> + + <%= button_to t("helpers.submit.delete"), + @book_stock, + method: :delete, + class: %w[btn btn-primary], + data: { turbo_confirm: t("helpers.dialog.delete", id: @book_stock.id) } %> +
diff --git a/app/views/book_stocks/show.json.jbuilder b/app/views/book_stocks/show.json.jbuilder new file mode 100644 index 0000000..caea684 --- /dev/null +++ b/app/views/book_stocks/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "book_stocks/book_stock", book_stock: @book_stock diff --git a/config/routes.rb b/config/routes.rb index bbc8541..e5952b1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,6 @@ Rails.application.routes.draw do + resources :book_stocks + resources :book_stock_statuses resources :authors resources :book_masters resources :ndc_categories diff --git a/db/migrate/20240907021517_create_book_stock_statuses.rb b/db/migrate/20240907021517_create_book_stock_statuses.rb new file mode 100644 index 0000000..336c40e --- /dev/null +++ b/db/migrate/20240907021517_create_book_stock_statuses.rb @@ -0,0 +1,9 @@ +class CreateBookStockStatuses < ActiveRecord::Migration[7.2] + def change + create_table :book_stock_statuses do |t| + t.string :name + + t.timestamps + end + end +end diff --git a/db/migrate/20240907021544_create_book_stocks.rb b/db/migrate/20240907021544_create_book_stocks.rb new file mode 100644 index 0000000..2193b96 --- /dev/null +++ b/db/migrate/20240907021544_create_book_stocks.rb @@ -0,0 +1,11 @@ +class CreateBookStocks < ActiveRecord::Migration[7.2] + def change + create_table :book_stocks do |t| + t.references :book_master, null: false, foreign_key: true + t.references :book_stock_status, null: false, foreign_key: true + t.text :memo + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 436e439..163f705 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.2].define(version: 2024_09_06_035657) do +ActiveRecord::Schema[7.2].define(version: 2024_09_07_021544) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -39,6 +39,22 @@ t.index ["ndc_category_id"], name: "index_book_masters_on_ndc_category_id" end + create_table "book_stock_statuses", force: :cascade do |t| + t.string "name" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "book_stocks", force: :cascade do |t| + t.bigint "book_master_id", null: false + t.bigint "book_stock_status_id", null: false + t.text "memo" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["book_master_id"], name: "index_book_stocks_on_book_master_id" + t.index ["book_stock_status_id"], name: "index_book_stocks_on_book_stock_status_id" + end + create_table "ndc_categories", force: :cascade do |t| t.string "name" t.integer "number" @@ -49,4 +65,6 @@ add_foreign_key "book_author_relationships", "authors" add_foreign_key "book_author_relationships", "book_masters" add_foreign_key "book_masters", "ndc_categories" + add_foreign_key "book_stocks", "book_masters" + add_foreign_key "book_stocks", "book_stock_statuses" end diff --git a/db/seeds.rb b/db/seeds.rb index 12f8d60..8834d8d 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -112,3 +112,18 @@ { number: 990, name: 'その他の諸言語文学(Literatures of other languages)' }, ] ) + +BookStockStatus.create!([ + { + name: "貸出可能", + }, + { + name: "貸出中", + }, + { + name: "貸出不可", + }, + { + name: "破棄", + } +]) diff --git a/doc/worklog.md b/doc/worklog.md index fee475d..71e3eb4 100644 --- a/doc/worklog.md +++ b/doc/worklog.md @@ -211,3 +211,63 @@ end ```sh sudo BINDING=0.0.0.0 ./bin/dev ``` + +# 貸出管理 + +## まずは在庫ステータスと在庫 + +### scaffold の作成 + +```sh +./bin/rails generate scaffold BookStockStatus name:string +./bin/rails generate scaffold BookStock book_master:references book_stock_status:references memo:text +``` + +### scaffold の修正 + +`app/views/book_stocks/index.html.erb`: + +`book_master` の `name` を `title` に変更。 + +`app/views/book_stocks/_book_master.html.erb`: + +`<%= book_stock.book_master.name %>` を `<%= book_stock.book_master.title %>` に変更。 + +`app/views/book_stocks/_form.html.erb`: + +`book_stock` の `:name` を `:title` に変更。 + + +### db マイグレーション + +```sh +./bin/rails db:drop +./bin/rails db:create +./bin/rails db:migrate +./bin/rails db:seed +``` + +### seed 作成 + +```rb +BookStockStatus.create!([ + { + name: "貸出可能", + }, + { + name: "貸出中", + }, + { + name: "貸出不可", + }, + { + name: "破棄", + } +]) +``` + +### 動作確認 + +```sh +sudo BINDING=0.0.0.0 ./bin/dev +``` diff --git a/test/controllers/book_stock_statuses_controller_test.rb b/test/controllers/book_stock_statuses_controller_test.rb new file mode 100644 index 0000000..1f64f3e --- /dev/null +++ b/test/controllers/book_stock_statuses_controller_test.rb @@ -0,0 +1,132 @@ +require "test_helper" + +class BookStockStatusesControllerTest < ActionDispatch::IntegrationTest + setup do + @book_stock_status = book_stock_statuses(:one) + end + + test "should get index" do + get book_stock_statuses_url + assert_response :success + end + + test "should get index find by id" do + get book_stock_statuses_url, params: { q: { id_eq: @book_stock_status.id } } + assert_response :success + + assert_select "table > tbody > tr", count: 1 + assert_select "table > tbody > tr:nth-of-type(1) > td", text: @book_stock_status.id.to_s + end + test "should get index search name" do + search_string = @book_stock_status.name + get book_stock_statuses_url, params: { q: { name_cont: search_string } } + assert_response :success + + assert_select "table > tbody > tr", count: 1 + assert_select "table > tbody > tr > td:nth-of-type(2)", text: search_string # one + end + + test "should get index search name, multi hit" do + search_string = "o" # `o`ne, tw`o`, destr`o`y_target. + get book_stock_statuses_url, params: { q: { name_cont: search_string } } + assert_response :success + + assert_select "table > tbody > tr", count: 3 + assert_select "table > tbody > tr > td:nth-of-type(2)", text: book_stock_statuses(:one).name # one + assert_select "table > tbody > tr > td:nth-of-type(2)", text: book_stock_statuses(:two).name # two + assert_select "table > tbody > tr > td:nth-of-type(2)", text: book_stock_statuses(:destroy_target).name # destroy_target + end + + test "should get index search created_at single hit" do + target_datetime = @book_stock_status.created_at + get book_stock_statuses_url, params: { q: { + created_at_gteq: target_datetime, + created_at_lteq_end_of_minute: target_datetime + } } + assert_response :success + + assert_select "table > tbody > tr", count: 1 + assert_select "table > tbody > tr > td:nth-of-type(3)", text: I18n.l(target_datetime) # one + end + + test "should get index search created_at, multi hit" do + target_datetime_from = book_stock_statuses(:one).created_at + target_datetime_to = book_stock_statuses(:two).created_at + get book_stock_statuses_url, params: { q: { + created_at_gteq: target_datetime_from, + created_at_lteq_end_of_minute: target_datetime_to + } } + assert_response :success + + assert_select "table > tbody > tr", count: 2 + assert_select "table > tbody > tr > td:nth-of-type(3)", text: I18n.l(target_datetime_from) # one + assert_select "table > tbody > tr > td:nth-of-type(3)", text: I18n.l(target_datetime_to) # two + end + + test "should get index search updated_at" do + target_datetime = @book_stock_status.updated_at + get book_stock_statuses_url, params: { q: { + updated_at_gteq: target_datetime, + updated_at_lteq_end_of_minute: target_datetime + } } + assert_response :success + + assert_select "table > tbody > tr", count: 1 + assert_select "table > tbody > tr > td:nth-of-type(4)", text: I18n.l(target_datetime) # one + end + + test "should get index search updated_at, multi hit" do + target_datetime_from = book_stock_statuses(:one).updated_at + target_datetime_to = book_stock_statuses(:two).updated_at + get book_stock_statuses_url, params: { q: { + updated_at_gteq: target_datetime_from, + updated_at_lteq_end_of_minute: target_datetime_to + } } + assert_response :success + + assert_select "table > tbody > tr", count: 2 + assert_select "table > tbody > tr > td:nth-of-type(4)", text: I18n.l(target_datetime_from) # one + assert_select "table > tbody > tr > td:nth-of-type(4)", text: I18n.l(target_datetime_to) # two + end + + test "should get new" do + get new_book_stock_status_url + assert_response :success + end + + test "should create book_stock_status" do + assert_difference("BookStockStatus.count") do + post book_stock_statuses_url, params: { book_stock_status: { + { name: @book_stock_status.name } + } } + end + + assert_redirected_to book_stock_status_url(BookStockStatus.last) + end + + test "should show book_stock_status" do + get book_stock_status_url(@book_stock_status) + assert_response :success + end + + test "should get edit" do + get edit_book_stock_status_url(@book_stock_status) + assert_response :success + end + + test "should update book_stock_status" do + patch book_stock_status_url(@book_stock_status), params: { book_stock_status: { + { name: @book_stock_status.name } + } } + assert_redirected_to book_stock_status_url(@book_stock_status) + end + + test "should destroy book_stock_status" do + book_stock_status = book_stock_statuses(:destroy_target) + assert_difference("BookStockStatus.count", -1) do + delete book_stock_status_url(book_stock_status) + end + + assert_redirected_to book_stock_statuses_url + end +end diff --git a/test/controllers/book_stocks_controller_test.rb b/test/controllers/book_stocks_controller_test.rb new file mode 100644 index 0000000..c9bc181 --- /dev/null +++ b/test/controllers/book_stocks_controller_test.rb @@ -0,0 +1,150 @@ +require "test_helper" + +class BookStocksControllerTest < ActionDispatch::IntegrationTest + setup do + @book_stock = book_stocks(:one) + end + + test "should get index" do + get book_stocks_url + assert_response :success + end + + test "should get index find by id" do + get book_stocks_url, params: { q: { id_eq: @book_stock.id } } + assert_response :success + + assert_select "table > tbody > tr", count: 1 + assert_select "table > tbody > tr:nth-of-type(1) > td", text: @book_stock.id.to_s + end + test "should get index search book_masters" do + search_ids = [book_stocks(:one).role_id, book_stocks(:two).role_id] + get book_stocks_url, params: { q: { book_master_id_in: search_ids } } + assert_response :success + + assert_select "table > tbody > tr", count: 2 + assert_select "table > tbody > tr > td:nth-of-type(2)", text: @book_stock.book_master.name # one + assert_select "table > tbody > tr > td:nth-of-type(2)", text: @book_stock.book_master.name # two + end + test "should get index search book_stock_statuss" do + search_ids = [book_stocks(:one).role_id, book_stocks(:two).role_id] + get book_stocks_url, params: { q: { book_stock_status_id_in: search_ids } } + assert_response :success + + assert_select "table > tbody > tr", count: 2 + assert_select "table > tbody > tr > td:nth-of-type(3)", text: @book_stock.book_stock_status.name # one + assert_select "table > tbody > tr > td:nth-of-type(3)", text: @book_stock.book_stock_status.name # two + end + test "should get index search memo" do + search_string = @book_stock.memo + get book_stocks_url, params: { q: { memo_cont: search_string } } + assert_response :success + + assert_select "table > tbody > tr", count: 1 + assert_select "table > tbody > tr > td:nth-of-type(4)", text: search_string # one + end + + test "should get index search memo, multi hit" do + search_string = "o" # `o`ne, tw`o`, destr`o`y_target. + get book_stocks_url, params: { q: { memo_cont: search_string } } + assert_response :success + + assert_select "table > tbody > tr", count: 3 + assert_select "table > tbody > tr > td:nth-of-type(4)", text: book_stocks(:one).name # one + assert_select "table > tbody > tr > td:nth-of-type(4)", text: book_stocks(:two).name # two + assert_select "table > tbody > tr > td:nth-of-type(4)", text: book_stocks(:destroy_target).name # destroy_target + end + + test "should get index search created_at single hit" do + target_datetime = @book_stock.created_at + get book_stocks_url, params: { q: { + created_at_gteq: target_datetime, + created_at_lteq_end_of_minute: target_datetime + } } + assert_response :success + + assert_select "table > tbody > tr", count: 1 + assert_select "table > tbody > tr > td:nth-of-type(5)", text: I18n.l(target_datetime) # one + end + + test "should get index search created_at, multi hit" do + target_datetime_from = book_stocks(:one).created_at + target_datetime_to = book_stocks(:two).created_at + get book_stocks_url, params: { q: { + created_at_gteq: target_datetime_from, + created_at_lteq_end_of_minute: target_datetime_to + } } + assert_response :success + + assert_select "table > tbody > tr", count: 2 + assert_select "table > tbody > tr > td:nth-of-type(5)", text: I18n.l(target_datetime_from) # one + assert_select "table > tbody > tr > td:nth-of-type(5)", text: I18n.l(target_datetime_to) # two + end + + test "should get index search updated_at" do + target_datetime = @book_stock.updated_at + get book_stocks_url, params: { q: { + updated_at_gteq: target_datetime, + updated_at_lteq_end_of_minute: target_datetime + } } + assert_response :success + + assert_select "table > tbody > tr", count: 1 + assert_select "table > tbody > tr > td:nth-of-type(6)", text: I18n.l(target_datetime) # one + end + + test "should get index search updated_at, multi hit" do + target_datetime_from = book_stocks(:one).updated_at + target_datetime_to = book_stocks(:two).updated_at + get book_stocks_url, params: { q: { + updated_at_gteq: target_datetime_from, + updated_at_lteq_end_of_minute: target_datetime_to + } } + assert_response :success + + assert_select "table > tbody > tr", count: 2 + assert_select "table > tbody > tr > td:nth-of-type(6)", text: I18n.l(target_datetime_from) # one + assert_select "table > tbody > tr > td:nth-of-type(6)", text: I18n.l(target_datetime_to) # two + end + + test "should get new" do + get new_book_stock_url + assert_response :success + end + + test "should create book_stock" do + assert_difference("BookStock.count") do + post book_stocks_url, params: { book_stock: { + { book_master_id: @book_stock.book_master_id, book_stock_status_id: @book_stock.book_stock_status_id, memo: @book_stock.memo } + } } + end + + assert_redirected_to book_stock_url(BookStock.last) + end + + test "should show book_stock" do + get book_stock_url(@book_stock) + assert_response :success + end + + test "should get edit" do + get edit_book_stock_url(@book_stock) + assert_response :success + end + + test "should update book_stock" do + patch book_stock_url(@book_stock), params: { book_stock: { + { book_master_id: @book_stock.book_master_id, book_stock_status_id: @book_stock.book_stock_status_id, memo: @book_stock.memo } + } } + assert_redirected_to book_stock_url(@book_stock) + end + + test "should destroy book_stock" do + book_stock = book_stocks(:destroy_target) + assert_difference("BookStock.count", -1) do + delete book_stock_url(book_stock) + end + + assert_redirected_to book_stocks_url + end +end diff --git a/test/fixtures/book_stock_statuses.yml b/test/fixtures/book_stock_statuses.yml new file mode 100644 index 0000000..94fdb16 --- /dev/null +++ b/test/fixtures/book_stock_statuses.yml @@ -0,0 +1,21 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + name: one + created_at: 2024-09-07 11:15:17 +0900 + updated_at: 2024-09-08 11:15:17 +0900 + +two: + name: two + created_at: 2024-09-09 11:15:17 +0900 + updated_at: 2024-09-10 11:15:17 +0900 + +dummy: + name: dummy + created_at: 2024-09-11 11:15:17 +0900 + updated_at: 2024-09-12 11:15:17 +0900 + +destroy_target: + name: BookStockStatus + created_at: 2024-09-13 11:15:17 +0900 + updated_at: 2024-09-14 11:15:17 +0900 diff --git a/test/fixtures/book_stocks.yml b/test/fixtures/book_stocks.yml new file mode 100644 index 0000000..8d8699f --- /dev/null +++ b/test/fixtures/book_stocks.yml @@ -0,0 +1,29 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + book_master: one + book_stock_status: one + memo: one + created_at: 2024-09-07 11:16:02 +0900 + updated_at: 2024-09-08 11:16:02 +0900 + +two: + book_master: two + book_stock_status: two + memo: two + created_at: 2024-09-09 11:16:02 +0900 + updated_at: 2024-09-10 11:16:02 +0900 + +dummy: + book_master: dummy + book_stock_status: dummy + memo: dummy + created_at: 2024-09-11 11:16:02 +0900 + updated_at: 2024-09-12 11:16:02 +0900 + +destroy_target: + book_master: dummy + book_stock_status: dummy + memo: BookStock + created_at: 2024-09-13 11:16:02 +0900 + updated_at: 2024-09-14 11:16:02 +0900 diff --git a/test/models/book_stock_status_test.rb b/test/models/book_stock_status_test.rb new file mode 100644 index 0000000..7008e43 --- /dev/null +++ b/test/models/book_stock_status_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class BookStockStatusTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/models/book_stock_test.rb b/test/models/book_stock_test.rb new file mode 100644 index 0000000..8746b05 --- /dev/null +++ b/test/models/book_stock_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class BookStockTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/system/book_stock_statuses_test.rb b/test/system/book_stock_statuses_test.rb new file mode 100644 index 0000000..1a4c3a6 --- /dev/null +++ b/test/system/book_stock_statuses_test.rb @@ -0,0 +1,41 @@ +require "application_system_test_case" + +class BookStockStatusesTest < ApplicationSystemTestCase + setup do + @book_stock_status = book_stock_statuses(:one) + end + + test "visiting the index" do + visit book_stock_statuses_url + assert_selector "h1", text: "Book stock statuses" + end + + test "should create book stock status" do + visit book_stock_statuses_url + click_on "New book stock status" + + fill_in "Name", with: @book_stock_status.name + click_on "Create Book stock status" + + assert_text "Book stock status was successfully created" + click_on "Back" + end + + test "should update Book stock status" do + visit book_stock_status_url(@book_stock_status) + click_on "Edit this book stock status", match: :first + + fill_in "Name", with: @book_stock_status.name + click_on "Update Book stock status" + + assert_text "Book stock status was successfully updated" + click_on "Back" + end + + test "should destroy Book stock status" do + visit book_stock_status_url(@book_stock_status) + click_on "Destroy this book stock status", match: :first + + assert_text "Book stock status was successfully destroyed" + end +end diff --git a/test/system/book_stocks_test.rb b/test/system/book_stocks_test.rb new file mode 100644 index 0000000..c864315 --- /dev/null +++ b/test/system/book_stocks_test.rb @@ -0,0 +1,45 @@ +require "application_system_test_case" + +class BookStocksTest < ApplicationSystemTestCase + setup do + @book_stock = book_stocks(:one) + end + + test "visiting the index" do + visit book_stocks_url + assert_selector "h1", text: "Book stocks" + end + + test "should create book stock" do + visit book_stocks_url + click_on "New book stock" + + fill_in "Book master", with: @book_stock.book_master_id + fill_in "Book stock status", with: @book_stock.book_stock_status_id + fill_in "Memo", with: @book_stock.memo + click_on "Create Book stock" + + assert_text "Book stock was successfully created" + click_on "Back" + end + + test "should update Book stock" do + visit book_stock_url(@book_stock) + click_on "Edit this book stock", match: :first + + fill_in "Book master", with: @book_stock.book_master_id + fill_in "Book stock status", with: @book_stock.book_stock_status_id + fill_in "Memo", with: @book_stock.memo + click_on "Update Book stock" + + assert_text "Book stock was successfully updated" + click_on "Back" + end + + test "should destroy Book stock" do + visit book_stock_url(@book_stock) + click_on "Destroy this book stock", match: :first + + assert_text "Book stock was successfully destroyed" + end +end