-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
unit testing for source motivation&information
- Loading branch information
1 parent
c340ade
commit d3f1243
Showing
52 changed files
with
843 additions
and
26 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
class BatchListsController < ApplicationController | ||
before_action :set_batch_list, only: %i[ show edit update destroy ] | ||
|
||
# GET /batch_lists or /batch_lists.json | ||
def index | ||
@batch_lists = BatchList.all | ||
end | ||
|
||
# GET /batch_lists/1 or /batch_lists/1.json | ||
def show | ||
end | ||
|
||
# GET /batch_lists/new | ||
def new | ||
@batch_list = BatchList.new | ||
end | ||
|
||
# GET /batch_lists/1/edit | ||
def edit | ||
end | ||
|
||
# POST /batch_lists or /batch_lists.json | ||
def create | ||
@batch_list = BatchList.new(batch_list_params) | ||
|
||
respond_to do |format| | ||
if @batch_list.save | ||
format.html { redirect_to batch_list_url(@batch_list), notice: "Batch list was successfully created." } | ||
format.json { render :show, status: :created, location: @batch_list } | ||
else | ||
format.html { render :new, status: :unprocessable_entity } | ||
format.json { render json: @batch_list.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PATCH/PUT /batch_lists/1 or /batch_lists/1.json | ||
def update | ||
respond_to do |format| | ||
if @batch_list.update(batch_list_params) | ||
format.html { redirect_to batch_list_url(@batch_list), notice: "Batch list was successfully updated." } | ||
format.json { render :show, status: :ok, location: @batch_list } | ||
else | ||
format.html { render :edit, status: :unprocessable_entity } | ||
format.json { render json: @batch_list.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /batch_lists/1 or /batch_lists/1.json | ||
def destroy | ||
@batch_list.destroy! | ||
|
||
respond_to do |format| | ||
format.html { redirect_to batch_lists_url, notice: "Batch list was successfully destroyed." } | ||
format.json { head :no_content } | ||
end | ||
end | ||
|
||
private | ||
# Use callbacks to share common setup or constraints between actions. | ||
def set_batch_list | ||
@batch_list = BatchList.find(params[:id]) | ||
end | ||
|
||
# Only allow a list of trusted parameters through. | ||
def batch_list_params | ||
params.require(:batch_list).permit(:gelombang, :aktif) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
class SourceInformationListsController < ApplicationController | ||
before_action :set_source_information_list, only: %i[ show edit update destroy ] | ||
|
||
# GET /source_information_lists or /source_information_lists.json | ||
def index | ||
@source_information_lists = SourceInformationList.all | ||
end | ||
|
||
# GET /source_information_lists/1 or /source_information_lists/1.json | ||
def show | ||
end | ||
|
||
# GET /source_information_lists/new | ||
def new | ||
@source_information_list = SourceInformationList.new | ||
end | ||
|
||
# GET /source_information_lists/1/edit | ||
def edit | ||
end | ||
|
||
# POST /source_information_lists or /source_information_lists.json | ||
def create | ||
@source_information_list = SourceInformationList.new(source_information_list_params) | ||
|
||
respond_to do |format| | ||
if @source_information_list.save | ||
format.html { redirect_to source_information_list_url(@source_information_list), notice: "Source information list was successfully created." } | ||
format.json { render :show, status: :created, location: @source_information_list } | ||
else | ||
format.html { render :new, status: :unprocessable_entity } | ||
format.json { render json: @source_information_list.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PATCH/PUT /source_information_lists/1 or /source_information_lists/1.json | ||
def update | ||
respond_to do |format| | ||
if @source_information_list.update(source_information_list_params) | ||
format.html { redirect_to source_information_list_url(@source_information_list), notice: "Source information list was successfully updated." } | ||
format.json { render :show, status: :ok, location: @source_information_list } | ||
else | ||
format.html { render :edit, status: :unprocessable_entity } | ||
format.json { render json: @source_information_list.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /source_information_lists/1 or /source_information_lists/1.json | ||
def destroy | ||
@source_information_list.destroy! | ||
|
||
respond_to do |format| | ||
format.html { redirect_to source_information_lists_url, notice: "Source information list was successfully destroyed." } | ||
format.json { head :no_content } | ||
end | ||
end | ||
|
||
private | ||
# Use callbacks to share common setup or constraints between actions. | ||
def set_source_information_list | ||
@source_information_list = SourceInformationList.find(params[:id]) | ||
end | ||
|
||
# Only allow a list of trusted parameters through. | ||
def source_information_list_params | ||
params.require(:source_information_list).permit(:informasi) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
class SourceMotivationListsController < ApplicationController | ||
before_action :set_source_motivation_list, only: %i[ show edit update destroy ] | ||
|
||
# GET /source_motivation_lists or /source_motivation_lists.json | ||
def index | ||
@source_motivation_lists = SourceMotivationList.all | ||
end | ||
|
||
# GET /source_motivation_lists/1 or /source_motivation_lists/1.json | ||
def show | ||
end | ||
|
||
# GET /source_motivation_lists/new | ||
def new | ||
@source_motivation_list = SourceMotivationList.new | ||
end | ||
|
||
# GET /source_motivation_lists/1/edit | ||
def edit | ||
end | ||
|
||
# POST /source_motivation_lists or /source_motivation_lists.json | ||
def create | ||
@source_motivation_list = SourceMotivationList.new(source_motivation_list_params) | ||
|
||
respond_to do |format| | ||
if @source_motivation_list.save | ||
format.html { redirect_to source_motivation_list_url(@source_motivation_list), notice: "Source motivation list was successfully created." } | ||
format.json { render :show, status: :created, location: @source_motivation_list } | ||
else | ||
format.html { render :new, status: :unprocessable_entity } | ||
format.json { render json: @source_motivation_list.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PATCH/PUT /source_motivation_lists/1 or /source_motivation_lists/1.json | ||
def update | ||
respond_to do |format| | ||
if @source_motivation_list.update(source_motivation_list_params) | ||
format.html { redirect_to source_motivation_list_url(@source_motivation_list), notice: "Source motivation list was successfully updated." } | ||
format.json { render :show, status: :ok, location: @source_motivation_list } | ||
else | ||
format.html { render :edit, status: :unprocessable_entity } | ||
format.json { render json: @source_motivation_list.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /source_motivation_lists/1 or /source_motivation_lists/1.json | ||
def destroy | ||
@source_motivation_list.destroy! | ||
|
||
respond_to do |format| | ||
format.html { redirect_to source_motivation_lists_url, notice: "Source motivation list was successfully destroyed." } | ||
format.json { head :no_content } | ||
end | ||
end | ||
|
||
private | ||
# Use callbacks to share common setup or constraints between actions. | ||
def set_source_motivation_list | ||
@source_motivation_list = SourceMotivationList.find(params[:id]) | ||
end | ||
|
||
# Only allow a list of trusted parameters through. | ||
def source_motivation_list_params | ||
params.require(:source_motivation_list).permit(:motivasi) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module BatchListsHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module SourceInformationListsHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module SourceMotivationListsHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,9 @@ | ||
class BatchList < ApplicationRecord | ||
validates :gelombang, presence: true, length: {minimum: 4, maximum: 25}, uniqueness: true | ||
#aktif must boolean | ||
validate :aktif_is_boolean | ||
private | ||
def aktif_is_boolean | ||
errors.add(:aktif, "must be boolean") unless [true, false].include? aktif | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
class SourceInformationList < ApplicationRecord | ||
validates :informasi, presence: true, length: {minimum: 4, maximum: 25}, uniqueness: true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
class SourceMotivationList < ApplicationRecord | ||
validates :motivasi, presence: true, length: {minimum: 4, maximum: 20}, uniqueness: true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<div id="<%= dom_id batch_list %>"> | ||
<p> | ||
<strong>Gelombang:</strong> | ||
<%= batch_list.gelombang %> | ||
</p> | ||
|
||
<p> | ||
<strong>Aktif:</strong> | ||
<%= batch_list.aktif %> | ||
</p> | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
json.extract! batch_list, :id, :gelombang, :aktif, :created_at, :updated_at | ||
json.url batch_list_url(batch_list, format: :json) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<%= form_with(model: batch_list) do |form| %> | ||
<% if batch_list.errors.any? %> | ||
<div style="color: red"> | ||
<h2><%= pluralize(batch_list.errors.count, "error") %> prohibited this batch_list from being saved:</h2> | ||
|
||
<ul> | ||
<% batch_list.errors.each do |error| %> | ||
<li><%= error.full_message %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
|
||
<div> | ||
<%= form.label :gelombang, style: "display: block" %> | ||
<%= form.text_field :gelombang %> | ||
</div> | ||
|
||
<div> | ||
<%= form.label :aktif, style: "display: block" %> | ||
<%= form.check_box :aktif %> | ||
</div> | ||
|
||
<div> | ||
<%= form.submit %> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<h1>Editing batch list</h1> | ||
|
||
<%= render "form", batch_list: @batch_list %> | ||
|
||
<br> | ||
|
||
<div> | ||
<%= link_to "Show this batch list", @batch_list %> | | ||
<%= link_to "Back to batch lists", batch_lists_path %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<p style="color: green"><%= notice %></p> | ||
|
||
<h1>Batch lists</h1> | ||
|
||
<div id="batch_lists"> | ||
<% @batch_lists.each do |batch_list| %> | ||
<%= render batch_list %> | ||
<p> | ||
<%= link_to "Show this batch list", batch_list %> | ||
</p> | ||
<% end %> | ||
</div> | ||
|
||
<%= link_to "New batch list", new_batch_list_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
json.array! @batch_lists, partial: "batch_lists/batch_list", as: :batch_list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<h1>New batch list</h1> | ||
|
||
<%= render "form", batch_list: @batch_list %> | ||
|
||
<br> | ||
|
||
<div> | ||
<%= link_to "Back to batch lists", batch_lists_path %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<p style="color: green"><%= notice %></p> | ||
|
||
<%= render @batch_list %> | ||
|
||
<div> | ||
<%= link_to "Edit this batch list", edit_batch_list_path(@batch_list) %> | | ||
<%= link_to "Back to batch lists", batch_lists_path %> | ||
|
||
<%= button_to "Destroy this batch list", @batch_list, method: :delete %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
json.partial! "batch_lists/batch_list", batch_list: @batch_list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<%= form_with(model: source_information_list) do |form| %> | ||
<% if source_information_list.errors.any? %> | ||
<div style="color: red"> | ||
<h2><%= pluralize(source_information_list.errors.count, "error") %> prohibited this source_information_list from being saved:</h2> | ||
|
||
<ul> | ||
<% source_information_list.errors.each do |error| %> | ||
<li><%= error.full_message %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
|
||
<div> | ||
<%= form.label :informasi, style: "display: block" %> | ||
<%= form.text_field :informasi %> | ||
</div> | ||
|
||
<div> | ||
<%= form.submit %> | ||
</div> | ||
<% end %> |
7 changes: 7 additions & 0 deletions
7
app/views/source_information_lists/_source_information_list.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<div id="<%= dom_id source_information_list %>"> | ||
<p> | ||
<strong>Informasi:</strong> | ||
<%= source_information_list.informasi %> | ||
</p> | ||
|
||
</div> |
2 changes: 2 additions & 0 deletions
2
app/views/source_information_lists/_source_information_list.json.jbuilder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
json.extract! source_information_list, :id, :informasi, :created_at, :updated_at | ||
json.url source_information_list_url(source_information_list, format: :json) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<h1>Editing source information list</h1> | ||
|
||
<%= render "form", source_information_list: @source_information_list %> | ||
|
||
<br> | ||
|
||
<div> | ||
<%= link_to "Show this source information list", @source_information_list %> | | ||
<%= link_to "Back to source information lists", source_information_lists_path %> | ||
</div> |
Oops, something went wrong.