From 3db0083f54f7623776c84f855c6854e4d10c04d9 Mon Sep 17 00:00:00 2001
From: Arnaud Levy <contact@arnaudlevy.com>
Date: Fri, 13 Aug 2021 08:56:46 +0200
Subject: [PATCH] proto

---
 .../journal/application_controller.rb         | 17 +++++
 .../research/journal/volumes_controller.rb    | 58 ++++++++++++++++
 .../admin/research/journals_controller.rb     |  8 +--
 .../research/journal/volumes_controller.rb    | 69 +++++++++++++++++++
 app/models/research/journal.rb                |  1 +
 app/models/research/journal/volume.rb         | 31 +++++++++
 .../research/journal/volumes/_form.html.erb   |  8 +++
 .../research/journal/volumes/edit.html.erb    |  6 ++
 .../research/journal/volumes/index.html.erb   | 25 +++++++
 .../research/journal/volumes/new.html.erb     |  3 +
 .../research/journal/volumes/show.html.erb    | 11 +++
 .../admin/research/journals/show.html.erb     | 19 +++++
 .../research/journals/volumes/new.html.erb    |  3 +
 .../_research_journal_volume.json.jbuilder    |  2 +
 .../research/journal/volumes/index.html.erb   | 31 +++++++++
 .../journal/volumes/index.json.jbuilder       |  1 +
 .../research/journal/volumes/show.html.erb    | 19 +++++
 .../journal/volumes/show.json.jbuilder        |  1 +
 config/locales/fr.yml                         |  3 -
 config/locales/research/journal.yml           |  9 +++
 config/routes.rb                              |  9 ++-
 config/routes/admin.rb                        |  4 +-
 ...2094327_create_research_journal_volumes.rb | 13 ++++
 db/schema.rb                                  | 16 ++++-
 .../journal/volumes_controller_test.rb        | 48 +++++++++++++
 test/fixtures/research/journal/volumes.yml    | 33 +++++++++
 test/fixtures/research/journals.yml           |  1 -
 test/models/research/journal/volume_test.rb   | 30 ++++++++
 test/system/research/journal/volumes_test.rb  | 47 +++++++++++++
 29 files changed, 512 insertions(+), 14 deletions(-)
 create mode 100644 app/controllers/admin/research/journal/application_controller.rb
 create mode 100644 app/controllers/admin/research/journal/volumes_controller.rb
 create mode 100644 app/controllers/research/journal/volumes_controller.rb
 create mode 100644 app/models/research/journal/volume.rb
 create mode 100644 app/views/admin/research/journal/volumes/_form.html.erb
 create mode 100644 app/views/admin/research/journal/volumes/edit.html.erb
 create mode 100644 app/views/admin/research/journal/volumes/index.html.erb
 create mode 100644 app/views/admin/research/journal/volumes/new.html.erb
 create mode 100644 app/views/admin/research/journal/volumes/show.html.erb
 create mode 100644 app/views/admin/research/journals/volumes/new.html.erb
 create mode 100644 app/views/research/journal/volumes/_research_journal_volume.json.jbuilder
 create mode 100644 app/views/research/journal/volumes/index.html.erb
 create mode 100644 app/views/research/journal/volumes/index.json.jbuilder
 create mode 100644 app/views/research/journal/volumes/show.html.erb
 create mode 100644 app/views/research/journal/volumes/show.json.jbuilder
 create mode 100644 config/locales/research/journal.yml
 create mode 100644 db/migrate/20210812094327_create_research_journal_volumes.rb
 create mode 100644 test/controllers/research/journal/volumes_controller_test.rb
 create mode 100644 test/fixtures/research/journal/volumes.yml
 create mode 100644 test/models/research/journal/volume_test.rb
 create mode 100644 test/system/research/journal/volumes_test.rb

diff --git a/app/controllers/admin/research/journal/application_controller.rb b/app/controllers/admin/research/journal/application_controller.rb
new file mode 100644
index 000000000..7ef43a13a
--- /dev/null
+++ b/app/controllers/admin/research/journal/application_controller.rb
@@ -0,0 +1,17 @@
+class Admin::Research::Journal::ApplicationController < Admin::Research::ApplicationController
+  load_and_authorize_resource :journal, class: Research::Journal
+
+  protected
+
+  def breadcrumb
+    super
+    add_breadcrumb Research::Journal.model_name.human(count: 2), admin_research_journals_path
+    breadcrumb_for @journal
+  end
+
+  def default_url_options
+    {
+      journal_id: params[:journal_id]
+    }
+  end
+end
diff --git a/app/controllers/admin/research/journal/volumes_controller.rb b/app/controllers/admin/research/journal/volumes_controller.rb
new file mode 100644
index 000000000..dd66f4924
--- /dev/null
+++ b/app/controllers/admin/research/journal/volumes_controller.rb
@@ -0,0 +1,58 @@
+class Admin::Research::Journal::VolumesController < Admin::Research::Journal::ApplicationController
+  load_and_authorize_resource class: Research::Journal::Volume
+
+  def index
+    breadcrumb
+  end
+
+  def show
+    breadcrumb
+  end
+
+  def new
+    breadcrumb
+  end
+
+  def edit
+    breadcrumb
+  end
+
+  def create
+    @journal = current_university.research_journals.find params[:journal_id]
+    @volume.journal = @journal
+    @volume.university = @journal.university
+    if @volume.save
+      redirect_to admin_research_journal_volume_path(@volume), notice: "Volume was successfully created."
+    else
+      breadcrumb
+      render :new, status: :unprocessable_entity
+    end
+  end
+
+  def update
+    if @volume.update(volume_params)
+      redirect_to admin_research_journal_volume_path(@volume), notice: "Volume was successfully updated."
+    else
+      breadcrumb
+      render :edit, status: :unprocessable_entity
+  end
+  end
+
+  def destroy
+    @journal = @volume.journal
+    @volume.destroy
+    redirect_to admin_research_journal_path(@journal), notice: "Volume was successfully destroyed."
+  end
+
+  private
+
+  def breadcrumb
+    super
+    add_breadcrumb Research::Journal::Volume.model_name.human(count: 2), admin_research_journal_volumes_path
+    breadcrumb_for @volume
+  end
+
+  def volume_params
+    params.require(:research_journal_volume).permit(:title, :number, :published_at)
+  end
+end
diff --git a/app/controllers/admin/research/journals_controller.rb b/app/controllers/admin/research/journals_controller.rb
index 593493749..84790252e 100644
--- a/app/controllers/admin/research/journals_controller.rb
+++ b/app/controllers/admin/research/journals_controller.rb
@@ -1,4 +1,4 @@
-class Admin::Research::JournalsController < Admin::Research::ApplicationController
+class Admin::Research::JournalsController < Admin::Research::Journal::ApplicationController
   load_and_authorize_resource class: Research::Journal
 
   def index
@@ -43,12 +43,6 @@ class Admin::Research::JournalsController < Admin::Research::ApplicationControll
 
   protected
 
-  def breadcrumb
-    super
-    add_breadcrumb Research::Journal.model_name.human(count: 2), admin_research_journals_path
-    breadcrumb_for @journal
-  end
-
   def journal_params
     params.require(:research_journal).permit(:title, :description)
   end
diff --git a/app/controllers/research/journal/volumes_controller.rb b/app/controllers/research/journal/volumes_controller.rb
new file mode 100644
index 000000000..95c9eff70
--- /dev/null
+++ b/app/controllers/research/journal/volumes_controller.rb
@@ -0,0 +1,69 @@
+class Research::Journal::VolumesController < ApplicationController
+  before_action :set_research_journal_volume, only: %i[ show edit update destroy ]
+
+  # GET /research/journal/volumes or /research/journal/volumes.json
+  def index
+    @research_journal_volumes = Research::Journal::Volume.all
+  end
+
+  # GET /research/journal/volumes/1 or /research/journal/volumes/1.json
+  def show
+  end
+
+  # GET /research/journal/volumes/new
+  def new
+    @research_journal_volume = Research::Journal::Volume.new
+  end
+
+  # GET /research/journal/volumes/1/edit
+  def edit
+  end
+
+  # POST /research/journal/volumes or /research/journal/volumes.json
+  def create
+    @research_journal_volume = Research::Journal::Volume.new(research_journal_volume_params)
+
+    respond_to do |format|
+      if @research_journal_volume.save
+        format.html { redirect_to @research_journal_volume, notice: "Volume was successfully created." }
+        format.json { render :show, status: :created, location: @research_journal_volume }
+      else
+        format.html { render :new, status: :unprocessable_entity }
+        format.json { render json: @research_journal_volume.errors, status: :unprocessable_entity }
+      end
+    end
+  end
+
+  # PATCH/PUT /research/journal/volumes/1 or /research/journal/volumes/1.json
+  def update
+    respond_to do |format|
+      if @research_journal_volume.update(research_journal_volume_params)
+        format.html { redirect_to @research_journal_volume, notice: "Volume was successfully updated." }
+        format.json { render :show, status: :ok, location: @research_journal_volume }
+      else
+        format.html { render :edit, status: :unprocessable_entity }
+        format.json { render json: @research_journal_volume.errors, status: :unprocessable_entity }
+      end
+    end
+  end
+
+  # DELETE /research/journal/volumes/1 or /research/journal/volumes/1.json
+  def destroy
+    @research_journal_volume.destroy
+    respond_to do |format|
+      format.html { redirect_to research_journal_volumes_url, notice: "Volume was successfully destroyed." }
+      format.json { head :no_content }
+    end
+  end
+
+  private
+    # Use callbacks to share common setup or constraints between actions.
+    def set_research_journal_volume
+      @research_journal_volume = Research::Journal::Volume.find(params[:id])
+    end
+
+    # Only allow a list of trusted parameters through.
+    def research_journal_volume_params
+      params.require(:research_journal_volume).permit(:title, :number, :published_at)
+    end
+end
diff --git a/app/models/research/journal.rb b/app/models/research/journal.rb
index fcdf35c01..5ce8ff734 100644
--- a/app/models/research/journal.rb
+++ b/app/models/research/journal.rb
@@ -19,6 +19,7 @@
 #
 class Research::Journal < ApplicationRecord
   belongs_to :university
+  has_many :volumes, foreign_key: :research_journal_id
 
   def to_s
     "#{title}"
diff --git a/app/models/research/journal/volume.rb b/app/models/research/journal/volume.rb
new file mode 100644
index 000000000..873e9f2aa
--- /dev/null
+++ b/app/models/research/journal/volume.rb
@@ -0,0 +1,31 @@
+# == Schema Information
+#
+# Table name: research_journal_volumes
+#
+#  id                  :uuid             not null, primary key
+#  number              :integer
+#  published_at        :datetime
+#  title               :string
+#  created_at          :datetime         not null
+#  updated_at          :datetime         not null
+#  research_journal_id :uuid             not null
+#  university_id       :uuid             not null
+#
+# Indexes
+#
+#  index_research_journal_volumes_on_research_journal_id  (research_journal_id)
+#  index_research_journal_volumes_on_university_id        (university_id)
+#
+# Foreign Keys
+#
+#  fk_rails_...  (research_journal_id => research_journals.id)
+#  fk_rails_...  (university_id => universities.id)
+#
+class Research::Journal::Volume < ApplicationRecord
+  belongs_to :university
+  belongs_to :journal, foreign_key: :research_journal_id
+
+  def to_s
+    "##{number} #{title}"
+  end
+end
diff --git a/app/views/admin/research/journal/volumes/_form.html.erb b/app/views/admin/research/journal/volumes/_form.html.erb
new file mode 100644
index 000000000..04fb38734
--- /dev/null
+++ b/app/views/admin/research/journal/volumes/_form.html.erb
@@ -0,0 +1,8 @@
+<%= simple_form_for [:admin, volume] do |f| %>
+  <%= f.input :title %>
+  <%= f.input :number %>
+  <%= f.input :published_at, html5: true %>
+  <% content_for :buttons do %>
+    <%= submit f %>
+  <% end %>
+<% end %>
diff --git a/app/views/admin/research/journal/volumes/edit.html.erb b/app/views/admin/research/journal/volumes/edit.html.erb
new file mode 100644
index 000000000..80ce995f0
--- /dev/null
+++ b/app/views/admin/research/journal/volumes/edit.html.erb
@@ -0,0 +1,6 @@
+<h1>Editing Research Journal Volume</h1>
+
+<%= render 'form', research_journal_volume: @research_journal_volume %>
+
+<%= link_to 'Show', @research_journal_volume %> |
+<%= link_to 'Back', research_journal_volumes_path %>
diff --git a/app/views/admin/research/journal/volumes/index.html.erb b/app/views/admin/research/journal/volumes/index.html.erb
new file mode 100644
index 000000000..d43c44d11
--- /dev/null
+++ b/app/views/admin/research/journal/volumes/index.html.erb
@@ -0,0 +1,25 @@
+<% content_for :title, Research::Journal::Volume.model_name.human(count: 2) %>
+
+<table class="table">
+  <thead>
+    <tr>
+      <th>Title</th>
+      <th>Number</th>
+      <th>Published at</th>
+      <th colspan="3"></th>
+    </tr>
+  </thead>
+  <tbody>
+    <% @volumes.each do |research_journal_volume| %>
+      <tr>
+        <td><%= research_journal_volume.title %></td>
+        <td><%= research_journal_volume.number %></td>
+        <td><%= research_journal_volume.published_at %></td>
+      </tr>
+    <% end %>
+  </tbody>
+</table>
+
+<br>
+
+<%= link_to 'New Research Journal Volume', new_research_journal_volume_path %>
diff --git a/app/views/admin/research/journal/volumes/new.html.erb b/app/views/admin/research/journal/volumes/new.html.erb
new file mode 100644
index 000000000..e59c090de
--- /dev/null
+++ b/app/views/admin/research/journal/volumes/new.html.erb
@@ -0,0 +1,3 @@
+<% content_for :title, Research::Journal::Volume.model_name.human %>
+
+<%= render 'form', volume: @volume %>
diff --git a/app/views/admin/research/journal/volumes/show.html.erb b/app/views/admin/research/journal/volumes/show.html.erb
new file mode 100644
index 000000000..ace032fb1
--- /dev/null
+++ b/app/views/admin/research/journal/volumes/show.html.erb
@@ -0,0 +1,11 @@
+<% content_for :title, @volume %>
+
+<p>
+  <strong>Number:</strong>
+  <%= @volume.number %>
+</p>
+
+<p>
+  <strong>Published at:</strong>
+  <%= @volume.published_at %>
+</p>
diff --git a/app/views/admin/research/journals/show.html.erb b/app/views/admin/research/journals/show.html.erb
index a43f749a7..dc06abae3 100644
--- a/app/views/admin/research/journals/show.html.erb
+++ b/app/views/admin/research/journals/show.html.erb
@@ -4,6 +4,25 @@
   <%= @journal.description %>
 </p>
 
+
+<h2 class="mt-5"><%= Research::Journal::Volume.model_name.human(count: 2) %></h2>
+
+<%= link_to t('create'),
+            new_admin_research_journal_volume_path,
+            class: button_classes %>
+
+<%= link_to 'Tous les volumes',
+            admin_research_journal_volumes_path %>
+
+<div class="row">
+  <% @journal.volumes.each do |volume| %>
+    <div class="col-md-3 mt-4">
+      <%= link_to volume, [:admin, volume] %>
+    </div>
+  <% end %>
+</div>
+
+
 <% content_for :buttons do %>
   <%= edit_link @journal %>
 <% end %>
diff --git a/app/views/admin/research/journals/volumes/new.html.erb b/app/views/admin/research/journals/volumes/new.html.erb
new file mode 100644
index 000000000..e59c090de
--- /dev/null
+++ b/app/views/admin/research/journals/volumes/new.html.erb
@@ -0,0 +1,3 @@
+<% content_for :title, Research::Journal::Volume.model_name.human %>
+
+<%= render 'form', volume: @volume %>
diff --git a/app/views/research/journal/volumes/_research_journal_volume.json.jbuilder b/app/views/research/journal/volumes/_research_journal_volume.json.jbuilder
new file mode 100644
index 000000000..535d4a189
--- /dev/null
+++ b/app/views/research/journal/volumes/_research_journal_volume.json.jbuilder
@@ -0,0 +1,2 @@
+json.extract! research_journal_volume, :id, :title, :number, :published_at, :created_at, :updated_at
+json.url research_journal_volume_url(research_journal_volume, format: :json)
diff --git a/app/views/research/journal/volumes/index.html.erb b/app/views/research/journal/volumes/index.html.erb
new file mode 100644
index 000000000..728aa29d5
--- /dev/null
+++ b/app/views/research/journal/volumes/index.html.erb
@@ -0,0 +1,31 @@
+<p id="notice"><%= notice %></p>
+
+<h1>Research Journal Volumes</h1>
+
+<table>
+  <thead>
+    <tr>
+      <th>Title</th>
+      <th>Number</th>
+      <th>Published at</th>
+      <th colspan="3"></th>
+    </tr>
+  </thead>
+
+  <tbody>
+    <% @research_journal_volumes.each do |research_journal_volume| %>
+      <tr>
+        <td><%= research_journal_volume.title %></td>
+        <td><%= research_journal_volume.number %></td>
+        <td><%= research_journal_volume.published_at %></td>
+        <td><%= link_to 'Show', research_journal_volume %></td>
+        <td><%= link_to 'Edit', edit_research_journal_volume_path(research_journal_volume) %></td>
+        <td><%= link_to 'Destroy', research_journal_volume, method: :delete, data: { confirm: 'Are you sure?' } %></td>
+      </tr>
+    <% end %>
+  </tbody>
+</table>
+
+<br>
+
+<%= link_to 'New Research Journal Volume', new_research_journal_volume_path %>
diff --git a/app/views/research/journal/volumes/index.json.jbuilder b/app/views/research/journal/volumes/index.json.jbuilder
new file mode 100644
index 000000000..bb11ceb64
--- /dev/null
+++ b/app/views/research/journal/volumes/index.json.jbuilder
@@ -0,0 +1 @@
+json.array! @research_journal_volumes, partial: "research_journal_volumes/research_journal_volume", as: :research_journal_volume
diff --git a/app/views/research/journal/volumes/show.html.erb b/app/views/research/journal/volumes/show.html.erb
new file mode 100644
index 000000000..2b3f84d47
--- /dev/null
+++ b/app/views/research/journal/volumes/show.html.erb
@@ -0,0 +1,19 @@
+<p id="notice"><%= notice %></p>
+
+<p>
+  <strong>Title:</strong>
+  <%= @research_journal_volume.title %>
+</p>
+
+<p>
+  <strong>Number:</strong>
+  <%= @research_journal_volume.number %>
+</p>
+
+<p>
+  <strong>Published at:</strong>
+  <%= @research_journal_volume.published_at %>
+</p>
+
+<%= link_to 'Edit', edit_research_journal_volume_path(@research_journal_volume) %> |
+<%= link_to 'Back', research_journal_volumes_path %>
diff --git a/app/views/research/journal/volumes/show.json.jbuilder b/app/views/research/journal/volumes/show.json.jbuilder
new file mode 100644
index 000000000..5ce421e45
--- /dev/null
+++ b/app/views/research/journal/volumes/show.json.jbuilder
@@ -0,0 +1 @@
+json.partial! "research_journal_volumes/research_journal_volume", research_journal_volume: @research_journal_volume
diff --git a/config/locales/fr.yml b/config/locales/fr.yml
index adb539dc5..9e129820f 100644
--- a/config/locales/fr.yml
+++ b/config/locales/fr.yml
@@ -14,9 +14,6 @@ fr:
       user:
         one: Utilisateur
         other: Utilisateurs
-      research/journal:
-        one: Revue scientifique
-        other: Revues scientifiques
     attributes:
       university:
         name: Nom
diff --git a/config/locales/research/journal.yml b/config/locales/research/journal.yml
new file mode 100644
index 000000000..0d29ed04c
--- /dev/null
+++ b/config/locales/research/journal.yml
@@ -0,0 +1,9 @@
+fr:
+  activerecord:
+    models:
+      research/journal:
+        one: Revue scientifique
+        other: Revues scientifiques
+      research/journal/volume:
+        one: Volume
+        other: Volumes
diff --git a/config/routes.rb b/config/routes.rb
index 1de595c48..2852bdaeb 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,4 +1,9 @@
 Rails.application.routes.draw do
+  namespace :research do
+    namespace :journal do
+      resources :volumes
+    end
+  end
   devise_for :users, controllers: {
     registrations: 'users/registrations',
     sessions: 'users/sessions'
@@ -14,7 +19,9 @@ Rails.application.routes.draw do
   end
 
   namespace :research do
-    resources :journals, only: [:index, :show]
+    resources :journals, only: [:index, :show] do
+      resources :volumes, only: [:index, :show]
+    end
   end
 
   root to: 'home#index'
diff --git a/config/routes/admin.rb b/config/routes/admin.rb
index 7949fef20..5cba51304 100644
--- a/config/routes/admin.rb
+++ b/config/routes/admin.rb
@@ -8,7 +8,9 @@ namespace :admin do
   end
 
   namespace :research do
-    resources :journals
+    resources :journals do
+      resources :volumes, controller: 'journal/volumes'
+    end
   end
 
   root to: 'dashboard#index'
diff --git a/db/migrate/20210812094327_create_research_journal_volumes.rb b/db/migrate/20210812094327_create_research_journal_volumes.rb
new file mode 100644
index 000000000..e613693ba
--- /dev/null
+++ b/db/migrate/20210812094327_create_research_journal_volumes.rb
@@ -0,0 +1,13 @@
+class CreateResearchJournalVolumes < ActiveRecord::Migration[6.1]
+  def change
+    create_table :research_journal_volumes, id: :uuid do |t|
+      t.references :university, null: false, foreign_key: true, type: :uuid
+      t.references :research_journal, null: false, foreign_key: true, type: :uuid
+      t.string :title
+      t.integer :number
+      t.datetime :published_at
+
+      t.timestamps
+    end
+  end
+end
diff --git a/db/schema.rb b/db/schema.rb
index db8f63cce..8c29914d8 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.define(version: 2021_08_12_085608) do
+ActiveRecord::Schema.define(version: 2021_08_12_094327) do
 
   # These are extensions that must be enabled in order to support this database
   enable_extension "pgcrypto"
@@ -68,6 +68,18 @@ ActiveRecord::Schema.define(version: 2021_08_12_085608) do
     t.index ["university_id"], name: "index_features_websites_sites_on_university_id"
   end
 
+  create_table "research_journal_volumes", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
+    t.uuid "university_id", null: false
+    t.uuid "research_journal_id", null: false
+    t.string "title"
+    t.integer "number"
+    t.datetime "published_at"
+    t.datetime "created_at", precision: 6, null: false
+    t.datetime "updated_at", precision: 6, null: false
+    t.index ["research_journal_id"], name: "index_research_journal_volumes_on_research_journal_id"
+    t.index ["university_id"], name: "index_research_journal_volumes_on_university_id"
+  end
+
   create_table "research_journals", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
     t.uuid "university_id", null: false
     t.string "title"
@@ -123,6 +135,8 @@ ActiveRecord::Schema.define(version: 2021_08_12_085608) do
   add_foreign_key "features_education_programs", "universities"
   add_foreign_key "features_education_qualiopi_indicators", "features_education_qualiopi_criterions", column: "criterion_id"
   add_foreign_key "features_websites_sites", "universities"
+  add_foreign_key "research_journal_volumes", "research_journals"
+  add_foreign_key "research_journal_volumes", "universities"
   add_foreign_key "research_journals", "universities"
   add_foreign_key "users", "universities"
 end
diff --git a/test/controllers/research/journal/volumes_controller_test.rb b/test/controllers/research/journal/volumes_controller_test.rb
new file mode 100644
index 000000000..cc8b7ad85
--- /dev/null
+++ b/test/controllers/research/journal/volumes_controller_test.rb
@@ -0,0 +1,48 @@
+require "test_helper"
+
+class Research::Journal::VolumesControllerTest < ActionDispatch::IntegrationTest
+  setup do
+    @research_journal_volume = research_journal_volumes(:one)
+  end
+
+  test "should get index" do
+    get research_journal_volumes_url
+    assert_response :success
+  end
+
+  test "should get new" do
+    get new_research_journal_volume_url
+    assert_response :success
+  end
+
+  test "should create research_journal_volume" do
+    assert_difference('Research::Journal::Volume.count') do
+      post research_journal_volumes_url, params: { research_journal_volume: { number: @research_journal_volume.number, published_at: @research_journal_volume.published_at, title: @research_journal_volume.title } }
+    end
+
+    assert_redirected_to research_journal_volume_url(Research::Journal::Volume.last)
+  end
+
+  test "should show research_journal_volume" do
+    get research_journal_volume_url(@research_journal_volume)
+    assert_response :success
+  end
+
+  test "should get edit" do
+    get edit_research_journal_volume_url(@research_journal_volume)
+    assert_response :success
+  end
+
+  test "should update research_journal_volume" do
+    patch research_journal_volume_url(@research_journal_volume), params: { research_journal_volume: { number: @research_journal_volume.number, published_at: @research_journal_volume.published_at, title: @research_journal_volume.title } }
+    assert_redirected_to research_journal_volume_url(@research_journal_volume)
+  end
+
+  test "should destroy research_journal_volume" do
+    assert_difference('Research::Journal::Volume.count', -1) do
+      delete research_journal_volume_url(@research_journal_volume)
+    end
+
+    assert_redirected_to research_journal_volumes_url
+  end
+end
diff --git a/test/fixtures/research/journal/volumes.yml b/test/fixtures/research/journal/volumes.yml
new file mode 100644
index 000000000..b5dfce353
--- /dev/null
+++ b/test/fixtures/research/journal/volumes.yml
@@ -0,0 +1,33 @@
+# == Schema Information
+#
+# Table name: research_journal_volumes
+#
+#  id                  :uuid             not null, primary key
+#  number              :integer
+#  published_at        :datetime
+#  title               :string
+#  created_at          :datetime         not null
+#  updated_at          :datetime         not null
+#  research_journal_id :uuid             not null
+#  university_id       :uuid             not null
+#
+# Indexes
+#
+#  index_research_journal_volumes_on_research_journal_id  (research_journal_id)
+#  index_research_journal_volumes_on_university_id        (university_id)
+#
+# Foreign Keys
+#
+#  fk_rails_...  (research_journal_id => research_journals.id)
+#  fk_rails_...  (university_id => universities.id)
+#
+
+one:
+  title: MyString
+  number: 1
+  published_at: 2021-08-12 11:43:30
+
+two:
+  title: MyString
+  number: 1
+  published_at: 2021-08-12 11:43:30
diff --git a/test/fixtures/research/journals.yml b/test/fixtures/research/journals.yml
index 2799b8f96..b4aba9399 100644
--- a/test/fixtures/research/journals.yml
+++ b/test/fixtures/research/journals.yml
@@ -17,7 +17,6 @@
 #
 #  fk_rails_...  (university_id => universities.id)
 #
-# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
 
 one:
   title: MyString
diff --git a/test/models/research/journal/volume_test.rb b/test/models/research/journal/volume_test.rb
new file mode 100644
index 000000000..3d62a1aaa
--- /dev/null
+++ b/test/models/research/journal/volume_test.rb
@@ -0,0 +1,30 @@
+# == Schema Information
+#
+# Table name: research_journal_volumes
+#
+#  id                  :uuid             not null, primary key
+#  number              :integer
+#  published_at        :datetime
+#  title               :string
+#  created_at          :datetime         not null
+#  updated_at          :datetime         not null
+#  research_journal_id :uuid             not null
+#  university_id       :uuid             not null
+#
+# Indexes
+#
+#  index_research_journal_volumes_on_research_journal_id  (research_journal_id)
+#  index_research_journal_volumes_on_university_id        (university_id)
+#
+# Foreign Keys
+#
+#  fk_rails_...  (research_journal_id => research_journals.id)
+#  fk_rails_...  (university_id => universities.id)
+#
+require "test_helper"
+
+class Research::Journal::VolumeTest < ActiveSupport::TestCase
+  # test "the truth" do
+  #   assert true
+  # end
+end
diff --git a/test/system/research/journal/volumes_test.rb b/test/system/research/journal/volumes_test.rb
new file mode 100644
index 000000000..85d50549b
--- /dev/null
+++ b/test/system/research/journal/volumes_test.rb
@@ -0,0 +1,47 @@
+require "application_system_test_case"
+
+class Research::Journal::VolumesTest < ApplicationSystemTestCase
+  setup do
+    @research_journal_volume = research_journal_volumes(:one)
+  end
+
+  test "visiting the index" do
+    visit research_journal_volumes_url
+    assert_selector "h1", text: "Research/Journal/Volumes"
+  end
+
+  test "creating a Volume" do
+    visit research_journal_volumes_url
+    click_on "New Research/Journal/Volume"
+
+    fill_in "Number", with: @research_journal_volume.number
+    fill_in "Published at", with: @research_journal_volume.published_at
+    fill_in "Title", with: @research_journal_volume.title
+    click_on "Create Volume"
+
+    assert_text "Volume was successfully created"
+    click_on "Back"
+  end
+
+  test "updating a Volume" do
+    visit research_journal_volumes_url
+    click_on "Edit", match: :first
+
+    fill_in "Number", with: @research_journal_volume.number
+    fill_in "Published at", with: @research_journal_volume.published_at
+    fill_in "Title", with: @research_journal_volume.title
+    click_on "Update Volume"
+
+    assert_text "Volume was successfully updated"
+    click_on "Back"
+  end
+
+  test "destroying a Volume" do
+    visit research_journal_volumes_url
+    page.accept_confirm do
+      click_on "Destroy", match: :first
+    end
+
+    assert_text "Volume was successfully destroyed"
+  end
+end
-- 
GitLab