Skip to content

Commit

Permalink
unit testing for achievement list
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelSipayung committed Jan 24, 2024
1 parent d3f1243 commit b3a6458
Show file tree
Hide file tree
Showing 36 changed files with 591 additions and 1 deletion.
70 changes: 70 additions & 0 deletions app/controllers/achievement_kategori_lists_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
class AchievementKategoriListsController < ApplicationController
before_action :set_achievement_kategori_list, only: %i[ show edit update destroy ]

# GET /achievement_kategori_lists or /achievement_kategori_lists.json
def index
@achievement_kategori_lists = AchievementKategoriList.all
end

# GET /achievement_kategori_lists/1 or /achievement_kategori_lists/1.json
def show
end

# GET /achievement_kategori_lists/new
def new
@achievement_kategori_list = AchievementKategoriList.new
end

# GET /achievement_kategori_lists/1/edit
def edit
end

# POST /achievement_kategori_lists or /achievement_kategori_lists.json
def create
@achievement_kategori_list = AchievementKategoriList.new(achievement_kategori_list_params)

respond_to do |format|
if @achievement_kategori_list.save
format.html { redirect_to achievement_kategori_list_url(@achievement_kategori_list), notice: "Achievement kategori list was successfully created." }
format.json { render :show, status: :created, location: @achievement_kategori_list }
else
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @achievement_kategori_list.errors, status: :unprocessable_entity }
end
end
end

# PATCH/PUT /achievement_kategori_lists/1 or /achievement_kategori_lists/1.json
def update
respond_to do |format|
if @achievement_kategori_list.update(achievement_kategori_list_params)
format.html { redirect_to achievement_kategori_list_url(@achievement_kategori_list), notice: "Achievement kategori list was successfully updated." }
format.json { render :show, status: :ok, location: @achievement_kategori_list }
else
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @achievement_kategori_list.errors, status: :unprocessable_entity }
end
end
end

# DELETE /achievement_kategori_lists/1 or /achievement_kategori_lists/1.json
def destroy
@achievement_kategori_list.destroy!

respond_to do |format|
format.html { redirect_to achievement_kategori_lists_url, notice: "Achievement kategori list was successfully destroyed." }
format.json { head :no_content }
end
end

private
# Use callbacks to share common setup or constraints between actions.
def set_achievement_kategori_list
@achievement_kategori_list = AchievementKategoriList.find(params[:id])
end

# Only allow a list of trusted parameters through.
def achievement_kategori_list_params
params.require(:achievement_kategori_list).permit(:kategori)
end
end
70 changes: 70 additions & 0 deletions app/controllers/achievement_tingkat_lists_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
class AchievementTingkatListsController < ApplicationController
before_action :set_achievement_tingkat_list, only: %i[ show edit update destroy ]

# GET /achievement_tingkat_lists or /achievement_tingkat_lists.json
def index
@achievement_tingkat_lists = AchievementTingkatList.all
end

# GET /achievement_tingkat_lists/1 or /achievement_tingkat_lists/1.json
def show
end

# GET /achievement_tingkat_lists/new
def new
@achievement_tingkat_list = AchievementTingkatList.new
end

# GET /achievement_tingkat_lists/1/edit
def edit
end

# POST /achievement_tingkat_lists or /achievement_tingkat_lists.json
def create
@achievement_tingkat_list = AchievementTingkatList.new(achievement_tingkat_list_params)

respond_to do |format|
if @achievement_tingkat_list.save
format.html { redirect_to achievement_tingkat_list_url(@achievement_tingkat_list), notice: "Achievement tingkat list was successfully created." }
format.json { render :show, status: :created, location: @achievement_tingkat_list }
else
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @achievement_tingkat_list.errors, status: :unprocessable_entity }
end
end
end

# PATCH/PUT /achievement_tingkat_lists/1 or /achievement_tingkat_lists/1.json
def update
respond_to do |format|
if @achievement_tingkat_list.update(achievement_tingkat_list_params)
format.html { redirect_to achievement_tingkat_list_url(@achievement_tingkat_list), notice: "Achievement tingkat list was successfully updated." }
format.json { render :show, status: :ok, location: @achievement_tingkat_list }
else
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @achievement_tingkat_list.errors, status: :unprocessable_entity }
end
end
end

# DELETE /achievement_tingkat_lists/1 or /achievement_tingkat_lists/1.json
def destroy
@achievement_tingkat_list.destroy!

respond_to do |format|
format.html { redirect_to achievement_tingkat_lists_url, notice: "Achievement tingkat list was successfully destroyed." }
format.json { head :no_content }
end
end

private
# Use callbacks to share common setup or constraints between actions.
def set_achievement_tingkat_list
@achievement_tingkat_list = AchievementTingkatList.find(params[:id])
end

# Only allow a list of trusted parameters through.
def achievement_tingkat_list_params
params.require(:achievement_tingkat_list).permit(:tingkat)
end
end
2 changes: 2 additions & 0 deletions app/helpers/achievement_kategori_lists_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module AchievementKategoriListsHelper
end
2 changes: 2 additions & 0 deletions app/helpers/achievement_tingkat_lists_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module AchievementTingkatListsHelper
end
3 changes: 3 additions & 0 deletions app/models/achievement_kategori_list.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class AchievementKategoriList < ApplicationRecord
validates :kategori, presence: true, length: {minimum: 4, maximum: 15}, uniqueness: true
end
3 changes: 3 additions & 0 deletions app/models/achievement_tingkat_list.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class AchievementTingkatList < ApplicationRecord
validates :tingkat, presence: true, length: {minimum: 4, maximum: 15}, uniqueness: true
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div id="<%= dom_id achievement_kategori_list %>">
<p>
<strong>Kategori:</strong>
<%= achievement_kategori_list.kategori %>
</p>

</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
json.extract! achievement_kategori_list, :id, :kategori, :created_at, :updated_at
json.url achievement_kategori_list_url(achievement_kategori_list, format: :json)
22 changes: 22 additions & 0 deletions app/views/achievement_kategori_lists/_form.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<%= form_with(model: achievement_kategori_list) do |form| %>
<% if achievement_kategori_list.errors.any? %>
<div style="color: red">
<h2><%= pluralize(achievement_kategori_list.errors.count, "error") %> prohibited this achievement_kategori_list from being saved:</h2>

<ul>
<% achievement_kategori_list.errors.each do |error| %>
<li><%= error.full_message %></li>
<% end %>
</ul>
</div>
<% end %>

<div>
<%= form.label :kategori, style: "display: block" %>
<%= form.text_field :kategori %>
</div>

<div>
<%= form.submit %>
</div>
<% end %>
10 changes: 10 additions & 0 deletions app/views/achievement_kategori_lists/edit.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<h1>Editing achievement kategori list</h1>

<%= render "form", achievement_kategori_list: @achievement_kategori_list %>

<br>

<div>
<%= link_to "Show this achievement kategori list", @achievement_kategori_list %> |
<%= link_to "Back to achievement kategori lists", achievement_kategori_lists_path %>
</div>
14 changes: 14 additions & 0 deletions app/views/achievement_kategori_lists/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<p style="color: green"><%= notice %></p>

<h1>Achievement kategori lists</h1>

<div id="achievement_kategori_lists">
<% @achievement_kategori_lists.each do |achievement_kategori_list| %>
<%= render achievement_kategori_list %>
<p>
<%= link_to "Show this achievement kategori list", achievement_kategori_list %>
</p>
<% end %>
</div>

<%= link_to "New achievement kategori list", new_achievement_kategori_list_path %>
1 change: 1 addition & 0 deletions app/views/achievement_kategori_lists/index.json.jbuilder
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
json.array! @achievement_kategori_lists, partial: "achievement_kategori_lists/achievement_kategori_list", as: :achievement_kategori_list
9 changes: 9 additions & 0 deletions app/views/achievement_kategori_lists/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<h1>New achievement kategori list</h1>

<%= render "form", achievement_kategori_list: @achievement_kategori_list %>

<br>

<div>
<%= link_to "Back to achievement kategori lists", achievement_kategori_lists_path %>
</div>
10 changes: 10 additions & 0 deletions app/views/achievement_kategori_lists/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<p style="color: green"><%= notice %></p>

<%= render @achievement_kategori_list %>

<div>
<%= link_to "Edit this achievement kategori list", edit_achievement_kategori_list_path(@achievement_kategori_list) %> |
<%= link_to "Back to achievement kategori lists", achievement_kategori_lists_path %>

<%= button_to "Destroy this achievement kategori list", @achievement_kategori_list, method: :delete %>
</div>
1 change: 1 addition & 0 deletions app/views/achievement_kategori_lists/show.json.jbuilder
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
json.partial! "achievement_kategori_lists/achievement_kategori_list", achievement_kategori_list: @achievement_kategori_list
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div id="<%= dom_id achievement_tingkat_list %>">
<p>
<strong>Tingkat:</strong>
<%= achievement_tingkat_list.tingkat %>
</p>

</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
json.extract! achievement_tingkat_list, :id, :tingkat, :created_at, :updated_at
json.url achievement_tingkat_list_url(achievement_tingkat_list, format: :json)
22 changes: 22 additions & 0 deletions app/views/achievement_tingkat_lists/_form.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<%= form_with(model: achievement_tingkat_list) do |form| %>
<% if achievement_tingkat_list.errors.any? %>
<div style="color: red">
<h2><%= pluralize(achievement_tingkat_list.errors.count, "error") %> prohibited this achievement_tingkat_list from being saved:</h2>

<ul>
<% achievement_tingkat_list.errors.each do |error| %>
<li><%= error.full_message %></li>
<% end %>
</ul>
</div>
<% end %>

<div>
<%= form.label :tingkat, style: "display: block" %>
<%= form.text_field :tingkat %>
</div>

<div>
<%= form.submit %>
</div>
<% end %>
10 changes: 10 additions & 0 deletions app/views/achievement_tingkat_lists/edit.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<h1>Editing achievement tingkat list</h1>

<%= render "form", achievement_tingkat_list: @achievement_tingkat_list %>

<br>

<div>
<%= link_to "Show this achievement tingkat list", @achievement_tingkat_list %> |
<%= link_to "Back to achievement tingkat lists", achievement_tingkat_lists_path %>
</div>
14 changes: 14 additions & 0 deletions app/views/achievement_tingkat_lists/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<p style="color: green"><%= notice %></p>

<h1>Achievement tingkat lists</h1>

<div id="achievement_tingkat_lists">
<% @achievement_tingkat_lists.each do |achievement_tingkat_list| %>
<%= render achievement_tingkat_list %>
<p>
<%= link_to "Show this achievement tingkat list", achievement_tingkat_list %>
</p>
<% end %>
</div>

<%= link_to "New achievement tingkat list", new_achievement_tingkat_list_path %>
1 change: 1 addition & 0 deletions app/views/achievement_tingkat_lists/index.json.jbuilder
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
json.array! @achievement_tingkat_lists, partial: "achievement_tingkat_lists/achievement_tingkat_list", as: :achievement_tingkat_list
9 changes: 9 additions & 0 deletions app/views/achievement_tingkat_lists/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<h1>New achievement tingkat list</h1>

<%= render "form", achievement_tingkat_list: @achievement_tingkat_list %>

<br>

<div>
<%= link_to "Back to achievement tingkat lists", achievement_tingkat_lists_path %>
</div>
10 changes: 10 additions & 0 deletions app/views/achievement_tingkat_lists/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<p style="color: green"><%= notice %></p>

<%= render @achievement_tingkat_list %>

<div>
<%= link_to "Edit this achievement tingkat list", edit_achievement_tingkat_list_path(@achievement_tingkat_list) %> |
<%= link_to "Back to achievement tingkat lists", achievement_tingkat_lists_path %>

<%= button_to "Destroy this achievement tingkat list", @achievement_tingkat_list, method: :delete %>
</div>
1 change: 1 addition & 0 deletions app/views/achievement_tingkat_lists/show.json.jbuilder
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
json.partial! "achievement_tingkat_lists/achievement_tingkat_list", achievement_tingkat_list: @achievement_tingkat_list
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
Rails.application.routes.draw do
resources :achievement_kategori_lists
resources :achievement_tingkat_lists
resources :source_motivation_lists
resources :source_information_lists
resources :batch_lists
Expand Down
9 changes: 9 additions & 0 deletions db/migrate/20240124014244_create_achievement_tingkat_lists.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class CreateAchievementTingkatLists < ActiveRecord::Migration[7.1]
def change
create_table :achievement_tingkat_lists do |t|
t.string :tingkat

t.timestamps
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class CreateAchievementKategoriLists < ActiveRecord::Migration[7.1]
def change
create_table :achievement_kategori_lists do |t|
t.string :kategori

t.timestamps
end
end
end
14 changes: 13 additions & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b3a6458

Please sign in to comment.