From b3a6458ca3e02089b072fc9365cd674c56aac81b Mon Sep 17 00:00:00 2001 From: Michael Sipayung Date: Wed, 24 Jan 2024 09:05:34 +0700 Subject: [PATCH] unit testing for achievement list --- .../achievement_kategori_lists_controller.rb | 70 +++++++++++++++++++ .../achievement_tingkat_lists_controller.rb | 70 +++++++++++++++++++ .../achievement_kategori_lists_helper.rb | 2 + .../achievement_tingkat_lists_helper.rb | 2 + app/models/achievement_kategori_list.rb | 3 + app/models/achievement_tingkat_list.rb | 3 + .../_achievement_kategori_list.html.erb | 7 ++ .../_achievement_kategori_list.json.jbuilder | 2 + .../achievement_kategori_lists/_form.html.erb | 22 ++++++ .../achievement_kategori_lists/edit.html.erb | 10 +++ .../achievement_kategori_lists/index.html.erb | 14 ++++ .../index.json.jbuilder | 1 + .../achievement_kategori_lists/new.html.erb | 9 +++ .../achievement_kategori_lists/show.html.erb | 10 +++ .../show.json.jbuilder | 1 + .../_achievement_tingkat_list.html.erb | 7 ++ .../_achievement_tingkat_list.json.jbuilder | 2 + .../achievement_tingkat_lists/_form.html.erb | 22 ++++++ .../achievement_tingkat_lists/edit.html.erb | 10 +++ .../achievement_tingkat_lists/index.html.erb | 14 ++++ .../index.json.jbuilder | 1 + .../achievement_tingkat_lists/new.html.erb | 9 +++ .../achievement_tingkat_lists/show.html.erb | 10 +++ .../show.json.jbuilder | 1 + config/routes.rb | 2 + ...014244_create_achievement_tingkat_lists.rb | 9 +++ ...14337_create_achievement_kategori_lists.rb | 9 +++ db/schema.rb | 14 +++- ...ievement_kategori_lists_controller_test.rb | 54 ++++++++++++++ ...hievement_tingkat_lists_controller_test.rb | 54 ++++++++++++++ test/fixtures/achievement_kategori_lists.yml | 7 ++ test/fixtures/achievement_tingkat_lists.yml | 7 ++ test/models/achievement_kategori_list_test.rb | 26 +++++++ test/models/achievement_tingkat_list_test.rb | 26 +++++++ .../system/achievement_kategori_lists_test.rb | 41 +++++++++++ test/system/achievement_tingkat_lists_test.rb | 41 +++++++++++ 36 files changed, 591 insertions(+), 1 deletion(-) create mode 100644 app/controllers/achievement_kategori_lists_controller.rb create mode 100644 app/controllers/achievement_tingkat_lists_controller.rb create mode 100644 app/helpers/achievement_kategori_lists_helper.rb create mode 100644 app/helpers/achievement_tingkat_lists_helper.rb create mode 100644 app/models/achievement_kategori_list.rb create mode 100644 app/models/achievement_tingkat_list.rb create mode 100644 app/views/achievement_kategori_lists/_achievement_kategori_list.html.erb create mode 100644 app/views/achievement_kategori_lists/_achievement_kategori_list.json.jbuilder create mode 100644 app/views/achievement_kategori_lists/_form.html.erb create mode 100644 app/views/achievement_kategori_lists/edit.html.erb create mode 100644 app/views/achievement_kategori_lists/index.html.erb create mode 100644 app/views/achievement_kategori_lists/index.json.jbuilder create mode 100644 app/views/achievement_kategori_lists/new.html.erb create mode 100644 app/views/achievement_kategori_lists/show.html.erb create mode 100644 app/views/achievement_kategori_lists/show.json.jbuilder create mode 100644 app/views/achievement_tingkat_lists/_achievement_tingkat_list.html.erb create mode 100644 app/views/achievement_tingkat_lists/_achievement_tingkat_list.json.jbuilder create mode 100644 app/views/achievement_tingkat_lists/_form.html.erb create mode 100644 app/views/achievement_tingkat_lists/edit.html.erb create mode 100644 app/views/achievement_tingkat_lists/index.html.erb create mode 100644 app/views/achievement_tingkat_lists/index.json.jbuilder create mode 100644 app/views/achievement_tingkat_lists/new.html.erb create mode 100644 app/views/achievement_tingkat_lists/show.html.erb create mode 100644 app/views/achievement_tingkat_lists/show.json.jbuilder create mode 100644 db/migrate/20240124014244_create_achievement_tingkat_lists.rb create mode 100644 db/migrate/20240124014337_create_achievement_kategori_lists.rb create mode 100644 test/controllers/achievement_kategori_lists_controller_test.rb create mode 100644 test/controllers/achievement_tingkat_lists_controller_test.rb create mode 100644 test/fixtures/achievement_kategori_lists.yml create mode 100644 test/fixtures/achievement_tingkat_lists.yml create mode 100644 test/models/achievement_kategori_list_test.rb create mode 100644 test/models/achievement_tingkat_list_test.rb create mode 100644 test/system/achievement_kategori_lists_test.rb create mode 100644 test/system/achievement_tingkat_lists_test.rb diff --git a/app/controllers/achievement_kategori_lists_controller.rb b/app/controllers/achievement_kategori_lists_controller.rb new file mode 100644 index 0000000..070f98e --- /dev/null +++ b/app/controllers/achievement_kategori_lists_controller.rb @@ -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 diff --git a/app/controllers/achievement_tingkat_lists_controller.rb b/app/controllers/achievement_tingkat_lists_controller.rb new file mode 100644 index 0000000..2ecb93b --- /dev/null +++ b/app/controllers/achievement_tingkat_lists_controller.rb @@ -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 diff --git a/app/helpers/achievement_kategori_lists_helper.rb b/app/helpers/achievement_kategori_lists_helper.rb new file mode 100644 index 0000000..a97aedb --- /dev/null +++ b/app/helpers/achievement_kategori_lists_helper.rb @@ -0,0 +1,2 @@ +module AchievementKategoriListsHelper +end diff --git a/app/helpers/achievement_tingkat_lists_helper.rb b/app/helpers/achievement_tingkat_lists_helper.rb new file mode 100644 index 0000000..a808770 --- /dev/null +++ b/app/helpers/achievement_tingkat_lists_helper.rb @@ -0,0 +1,2 @@ +module AchievementTingkatListsHelper +end diff --git a/app/models/achievement_kategori_list.rb b/app/models/achievement_kategori_list.rb new file mode 100644 index 0000000..27d52e7 --- /dev/null +++ b/app/models/achievement_kategori_list.rb @@ -0,0 +1,3 @@ +class AchievementKategoriList < ApplicationRecord + validates :kategori, presence: true, length: {minimum: 4, maximum: 15}, uniqueness: true +end diff --git a/app/models/achievement_tingkat_list.rb b/app/models/achievement_tingkat_list.rb new file mode 100644 index 0000000..06c7f11 --- /dev/null +++ b/app/models/achievement_tingkat_list.rb @@ -0,0 +1,3 @@ +class AchievementTingkatList < ApplicationRecord + validates :tingkat, presence: true, length: {minimum: 4, maximum: 15}, uniqueness: true +end diff --git a/app/views/achievement_kategori_lists/_achievement_kategori_list.html.erb b/app/views/achievement_kategori_lists/_achievement_kategori_list.html.erb new file mode 100644 index 0000000..a0e6f8d --- /dev/null +++ b/app/views/achievement_kategori_lists/_achievement_kategori_list.html.erb @@ -0,0 +1,7 @@ +
+

+ Kategori: + <%= achievement_kategori_list.kategori %> +

+ +
diff --git a/app/views/achievement_kategori_lists/_achievement_kategori_list.json.jbuilder b/app/views/achievement_kategori_lists/_achievement_kategori_list.json.jbuilder new file mode 100644 index 0000000..196dc99 --- /dev/null +++ b/app/views/achievement_kategori_lists/_achievement_kategori_list.json.jbuilder @@ -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) diff --git a/app/views/achievement_kategori_lists/_form.html.erb b/app/views/achievement_kategori_lists/_form.html.erb new file mode 100644 index 0000000..46582b0 --- /dev/null +++ b/app/views/achievement_kategori_lists/_form.html.erb @@ -0,0 +1,22 @@ +<%= form_with(model: achievement_kategori_list) do |form| %> + <% if achievement_kategori_list.errors.any? %> +
+

<%= pluralize(achievement_kategori_list.errors.count, "error") %> prohibited this achievement_kategori_list from being saved:

+ + +
+ <% end %> + +
+ <%= form.label :kategori, style: "display: block" %> + <%= form.text_field :kategori %> +
+ +
+ <%= form.submit %> +
+<% end %> diff --git a/app/views/achievement_kategori_lists/edit.html.erb b/app/views/achievement_kategori_lists/edit.html.erb new file mode 100644 index 0000000..244c495 --- /dev/null +++ b/app/views/achievement_kategori_lists/edit.html.erb @@ -0,0 +1,10 @@ +

Editing achievement kategori list

+ +<%= render "form", achievement_kategori_list: @achievement_kategori_list %> + +
+ +
+ <%= link_to "Show this achievement kategori list", @achievement_kategori_list %> | + <%= link_to "Back to achievement kategori lists", achievement_kategori_lists_path %> +
diff --git a/app/views/achievement_kategori_lists/index.html.erb b/app/views/achievement_kategori_lists/index.html.erb new file mode 100644 index 0000000..6a6b38e --- /dev/null +++ b/app/views/achievement_kategori_lists/index.html.erb @@ -0,0 +1,14 @@ +

<%= notice %>

+ +

Achievement kategori lists

+ +
+ <% @achievement_kategori_lists.each do |achievement_kategori_list| %> + <%= render achievement_kategori_list %> +

+ <%= link_to "Show this achievement kategori list", achievement_kategori_list %> +

+ <% end %> +
+ +<%= link_to "New achievement kategori list", new_achievement_kategori_list_path %> diff --git a/app/views/achievement_kategori_lists/index.json.jbuilder b/app/views/achievement_kategori_lists/index.json.jbuilder new file mode 100644 index 0000000..21687c1 --- /dev/null +++ b/app/views/achievement_kategori_lists/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @achievement_kategori_lists, partial: "achievement_kategori_lists/achievement_kategori_list", as: :achievement_kategori_list diff --git a/app/views/achievement_kategori_lists/new.html.erb b/app/views/achievement_kategori_lists/new.html.erb new file mode 100644 index 0000000..7d59830 --- /dev/null +++ b/app/views/achievement_kategori_lists/new.html.erb @@ -0,0 +1,9 @@ +

New achievement kategori list

+ +<%= render "form", achievement_kategori_list: @achievement_kategori_list %> + +
+ +
+ <%= link_to "Back to achievement kategori lists", achievement_kategori_lists_path %> +
diff --git a/app/views/achievement_kategori_lists/show.html.erb b/app/views/achievement_kategori_lists/show.html.erb new file mode 100644 index 0000000..cd09414 --- /dev/null +++ b/app/views/achievement_kategori_lists/show.html.erb @@ -0,0 +1,10 @@ +

<%= notice %>

+ +<%= render @achievement_kategori_list %> + +
+ <%= 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 %> +
diff --git a/app/views/achievement_kategori_lists/show.json.jbuilder b/app/views/achievement_kategori_lists/show.json.jbuilder new file mode 100644 index 0000000..8fea84d --- /dev/null +++ b/app/views/achievement_kategori_lists/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "achievement_kategori_lists/achievement_kategori_list", achievement_kategori_list: @achievement_kategori_list diff --git a/app/views/achievement_tingkat_lists/_achievement_tingkat_list.html.erb b/app/views/achievement_tingkat_lists/_achievement_tingkat_list.html.erb new file mode 100644 index 0000000..535bc9a --- /dev/null +++ b/app/views/achievement_tingkat_lists/_achievement_tingkat_list.html.erb @@ -0,0 +1,7 @@ +
+

+ Tingkat: + <%= achievement_tingkat_list.tingkat %> +

+ +
diff --git a/app/views/achievement_tingkat_lists/_achievement_tingkat_list.json.jbuilder b/app/views/achievement_tingkat_lists/_achievement_tingkat_list.json.jbuilder new file mode 100644 index 0000000..ea4e64a --- /dev/null +++ b/app/views/achievement_tingkat_lists/_achievement_tingkat_list.json.jbuilder @@ -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) diff --git a/app/views/achievement_tingkat_lists/_form.html.erb b/app/views/achievement_tingkat_lists/_form.html.erb new file mode 100644 index 0000000..bbf46c0 --- /dev/null +++ b/app/views/achievement_tingkat_lists/_form.html.erb @@ -0,0 +1,22 @@ +<%= form_with(model: achievement_tingkat_list) do |form| %> + <% if achievement_tingkat_list.errors.any? %> +
+

<%= pluralize(achievement_tingkat_list.errors.count, "error") %> prohibited this achievement_tingkat_list from being saved:

+ + +
+ <% end %> + +
+ <%= form.label :tingkat, style: "display: block" %> + <%= form.text_field :tingkat %> +
+ +
+ <%= form.submit %> +
+<% end %> diff --git a/app/views/achievement_tingkat_lists/edit.html.erb b/app/views/achievement_tingkat_lists/edit.html.erb new file mode 100644 index 0000000..a04a3c4 --- /dev/null +++ b/app/views/achievement_tingkat_lists/edit.html.erb @@ -0,0 +1,10 @@ +

Editing achievement tingkat list

+ +<%= render "form", achievement_tingkat_list: @achievement_tingkat_list %> + +
+ +
+ <%= link_to "Show this achievement tingkat list", @achievement_tingkat_list %> | + <%= link_to "Back to achievement tingkat lists", achievement_tingkat_lists_path %> +
diff --git a/app/views/achievement_tingkat_lists/index.html.erb b/app/views/achievement_tingkat_lists/index.html.erb new file mode 100644 index 0000000..3d8e24c --- /dev/null +++ b/app/views/achievement_tingkat_lists/index.html.erb @@ -0,0 +1,14 @@ +

<%= notice %>

+ +

Achievement tingkat lists

+ +
+ <% @achievement_tingkat_lists.each do |achievement_tingkat_list| %> + <%= render achievement_tingkat_list %> +

+ <%= link_to "Show this achievement tingkat list", achievement_tingkat_list %> +

+ <% end %> +
+ +<%= link_to "New achievement tingkat list", new_achievement_tingkat_list_path %> diff --git a/app/views/achievement_tingkat_lists/index.json.jbuilder b/app/views/achievement_tingkat_lists/index.json.jbuilder new file mode 100644 index 0000000..99807ae --- /dev/null +++ b/app/views/achievement_tingkat_lists/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @achievement_tingkat_lists, partial: "achievement_tingkat_lists/achievement_tingkat_list", as: :achievement_tingkat_list diff --git a/app/views/achievement_tingkat_lists/new.html.erb b/app/views/achievement_tingkat_lists/new.html.erb new file mode 100644 index 0000000..5bd2ce5 --- /dev/null +++ b/app/views/achievement_tingkat_lists/new.html.erb @@ -0,0 +1,9 @@ +

New achievement tingkat list

+ +<%= render "form", achievement_tingkat_list: @achievement_tingkat_list %> + +
+ +
+ <%= link_to "Back to achievement tingkat lists", achievement_tingkat_lists_path %> +
diff --git a/app/views/achievement_tingkat_lists/show.html.erb b/app/views/achievement_tingkat_lists/show.html.erb new file mode 100644 index 0000000..6ca7c7d --- /dev/null +++ b/app/views/achievement_tingkat_lists/show.html.erb @@ -0,0 +1,10 @@ +

<%= notice %>

+ +<%= render @achievement_tingkat_list %> + +
+ <%= 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 %> +
diff --git a/app/views/achievement_tingkat_lists/show.json.jbuilder b/app/views/achievement_tingkat_lists/show.json.jbuilder new file mode 100644 index 0000000..be19cfe --- /dev/null +++ b/app/views/achievement_tingkat_lists/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "achievement_tingkat_lists/achievement_tingkat_list", achievement_tingkat_list: @achievement_tingkat_list diff --git a/config/routes.rb b/config/routes.rb index 6ee9ab0..38ea8a6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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 diff --git a/db/migrate/20240124014244_create_achievement_tingkat_lists.rb b/db/migrate/20240124014244_create_achievement_tingkat_lists.rb new file mode 100644 index 0000000..01a271d --- /dev/null +++ b/db/migrate/20240124014244_create_achievement_tingkat_lists.rb @@ -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 diff --git a/db/migrate/20240124014337_create_achievement_kategori_lists.rb b/db/migrate/20240124014337_create_achievement_kategori_lists.rb new file mode 100644 index 0000000..4bc066e --- /dev/null +++ b/db/migrate/20240124014337_create_achievement_kategori_lists.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index be62ce2..b8b9701 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,19 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2024_01_23_231407) do +ActiveRecord::Schema[7.1].define(version: 2024_01_24_014337) do + create_table "achievement_kategori_lists", force: :cascade do |t| + t.string "kategori" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "achievement_tingkat_lists", force: :cascade do |t| + t.string "tingkat" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + create_table "achievements", force: :cascade do |t| t.string "nama_prestasi" t.date "tahun" diff --git a/test/controllers/achievement_kategori_lists_controller_test.rb b/test/controllers/achievement_kategori_lists_controller_test.rb new file mode 100644 index 0000000..967975f --- /dev/null +++ b/test/controllers/achievement_kategori_lists_controller_test.rb @@ -0,0 +1,54 @@ +require "test_helper" + +class AchievementKategoriListsControllerTest < ActionDispatch::IntegrationTest + setup do + get login_path + post login_path, params: {session: { + email: users(:michael).email, password: 'password' + }} + @achievement_kategori_list = achievement_kategori_lists(:one) + end + + test "should get index" do + get achievement_kategori_lists_url + assert_response :success + end + + test "should get new" do + get new_achievement_kategori_list_url + assert_response :success + end + + test "should create achievement_kategori_list" do + assert_difference("AchievementKategoriList.count") do + post achievement_kategori_lists_url, + params: { achievement_kategori_list: { kategori: 'non akademik' } } + end + + assert_redirected_to achievement_kategori_list_url(AchievementKategoriList.last) + end + + test "should show achievement_kategori_list" do + get achievement_kategori_list_url(@achievement_kategori_list) + assert_response :success + end + + test "should get edit" do + get edit_achievement_kategori_list_url(@achievement_kategori_list) + assert_response :success + end + + test "should update achievement_kategori_list" do + patch achievement_kategori_list_url(@achievement_kategori_list), + params: { achievement_kategori_list: { kategori: 'non akademik 2' } } + assert_redirected_to achievement_kategori_list_url(@achievement_kategori_list) + end + + test "should destroy achievement_kategori_list" do + assert_difference("AchievementKategoriList.count", -1) do + delete achievement_kategori_list_url(@achievement_kategori_list) + end + + assert_redirected_to achievement_kategori_lists_url + end +end diff --git a/test/controllers/achievement_tingkat_lists_controller_test.rb b/test/controllers/achievement_tingkat_lists_controller_test.rb new file mode 100644 index 0000000..82e6c30 --- /dev/null +++ b/test/controllers/achievement_tingkat_lists_controller_test.rb @@ -0,0 +1,54 @@ +require "test_helper" + +class AchievementTingkatListsControllerTest < ActionDispatch::IntegrationTest + setup do + get login_path + post login_path, params: {session: { + email: users(:michael).email, password: 'password' + }} + @achievement_tingkat_list = achievement_tingkat_lists(:one) + end + + test "should get index" do + get achievement_tingkat_lists_url + assert_response :success + end + + test "should get new" do + get new_achievement_tingkat_list_url + assert_response :success + end + + test "should create achievement_tingkat_list" do + assert_difference("AchievementTingkatList.count") do + post achievement_tingkat_lists_url, + params: { achievement_tingkat_list: { tingkat: 'nasional' } } + end + + assert_redirected_to achievement_tingkat_list_url(AchievementTingkatList.last) + end + + test "should show achievement_tingkat_list" do + get achievement_tingkat_list_url(@achievement_tingkat_list) + assert_response :success + end + + test "should get edit" do + get edit_achievement_tingkat_list_url(@achievement_tingkat_list) + assert_response :success + end + + test "should update achievement_tingkat_list" do + patch achievement_tingkat_list_url(@achievement_tingkat_list), + params: { achievement_tingkat_list: { tingkat: 'internasional' } } + assert_redirected_to achievement_tingkat_list_url(@achievement_tingkat_list) + end + + test "should destroy achievement_tingkat_list" do + assert_difference("AchievementTingkatList.count", -1) do + delete achievement_tingkat_list_url(@achievement_tingkat_list) + end + + assert_redirected_to achievement_tingkat_lists_url + end +end diff --git a/test/fixtures/achievement_kategori_lists.yml b/test/fixtures/achievement_kategori_lists.yml new file mode 100644 index 0000000..a73ebfd --- /dev/null +++ b/test/fixtures/achievement_kategori_lists.yml @@ -0,0 +1,7 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + kategori: MyString + +two: + kategori: MyString diff --git a/test/fixtures/achievement_tingkat_lists.yml b/test/fixtures/achievement_tingkat_lists.yml new file mode 100644 index 0000000..c49bfb1 --- /dev/null +++ b/test/fixtures/achievement_tingkat_lists.yml @@ -0,0 +1,7 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + tingkat: MyString + +two: + tingkat: MyString diff --git a/test/models/achievement_kategori_list_test.rb b/test/models/achievement_kategori_list_test.rb new file mode 100644 index 0000000..fefc1ec --- /dev/null +++ b/test/models/achievement_kategori_list_test.rb @@ -0,0 +1,26 @@ +require "test_helper" + +class AchievementKategoriListTest < ActiveSupport::TestCase + def setup + @kategori_achivement = AchievementKategoriList.new(kategori: 'akademik') + end + test "should accept for right achievement-kategori" do + assert @kategori_achivement.valid? + end + test "should reject for empty achievement-kategori" do + @kategori_achivement.kategori=' ' + assert_not @kategori_achivement.valid? + end + test "should reject for too short achievement-kategori" do + @kategori_achivement.kategori = 'a'*3 + assert_not @kategori_achivement.valid? + end + test "should reject fot too long achievement-kategori" do + @kategori_achivement.kategori = 'a'*16 + assert_not @kategori_achivement.valid? + end + test "should reject for non unique achievement-kategori" do + @kategori_achivement.kategori = achievement_kategori_lists(:one).kategori + assert_not @kategori_achivement.valid? + end +end diff --git a/test/models/achievement_tingkat_list_test.rb b/test/models/achievement_tingkat_list_test.rb new file mode 100644 index 0000000..c803f2a --- /dev/null +++ b/test/models/achievement_tingkat_list_test.rb @@ -0,0 +1,26 @@ +require "test_helper" + +class AchievementTingkatListTest < ActiveSupport::TestCase + def setup + @tingkat_achivement = AchievementTingkatList.new(tingkat: 'kecamatan') + end + test "should accept for right achievement-tingkat" do + assert @tingkat_achivement.valid? + end + test "should reject for empty achievement-tingkat" do + @tingkat_achivement.tingkat=' ' + assert_not @tingkat_achivement.valid? + end + test "should reject for too short achievement-tigkat" do + @tingkat_achivement.tingkat = 'a'*3 + assert_not @tingkat_achivement.valid? + end + test "should reject fot too long achievement-tingkat" do + @tingkat_achivement.tingkat = 'a'*16 + assert_not @tingkat_achivement.valid? + end + test "should reject for non unique achievement-tingkat" do + @tingkat_achivement.tingkat = achievement_tingkat_lists(:one).tingkat + assert_not @tingkat_achivement.valid? + end +end diff --git a/test/system/achievement_kategori_lists_test.rb b/test/system/achievement_kategori_lists_test.rb new file mode 100644 index 0000000..da1aeda --- /dev/null +++ b/test/system/achievement_kategori_lists_test.rb @@ -0,0 +1,41 @@ +require "application_system_test_case" + +class AchievementKategoriListsTest < ApplicationSystemTestCase + setup do + @achievement_kategori_list = achievement_kategori_lists(:one) + end + + test "visiting the index" do + visit achievement_kategori_lists_url + assert_selector "h1", text: "Achievement kategori lists" + end + + test "should create achievement kategori list" do + visit achievement_kategori_lists_url + click_on "New achievement kategori list" + + fill_in "Kategori", with: @achievement_kategori_list.kategori + click_on "Create Achievement kategori list" + + assert_text "Achievement kategori list was successfully created" + click_on "Back" + end + + test "should update Achievement kategori list" do + visit achievement_kategori_list_url(@achievement_kategori_list) + click_on "Edit this achievement kategori list", match: :first + + fill_in "Kategori", with: @achievement_kategori_list.kategori + click_on "Update Achievement kategori list" + + assert_text "Achievement kategori list was successfully updated" + click_on "Back" + end + + test "should destroy Achievement kategori list" do + visit achievement_kategori_list_url(@achievement_kategori_list) + click_on "Destroy this achievement kategori list", match: :first + + assert_text "Achievement kategori list was successfully destroyed" + end +end diff --git a/test/system/achievement_tingkat_lists_test.rb b/test/system/achievement_tingkat_lists_test.rb new file mode 100644 index 0000000..530439e --- /dev/null +++ b/test/system/achievement_tingkat_lists_test.rb @@ -0,0 +1,41 @@ +require "application_system_test_case" + +class AchievementTingkatListsTest < ApplicationSystemTestCase + setup do + @achievement_tingkat_list = achievement_tingkat_lists(:one) + end + + test "visiting the index" do + visit achievement_tingkat_lists_url + assert_selector "h1", text: "Achievement tingkat lists" + end + + test "should create achievement tingkat list" do + visit achievement_tingkat_lists_url + click_on "New achievement tingkat list" + + fill_in "Tingkat", with: @achievement_tingkat_list.tingkat + click_on "Create Achievement tingkat list" + + assert_text "Achievement tingkat list was successfully created" + click_on "Back" + end + + test "should update Achievement tingkat list" do + visit achievement_tingkat_list_url(@achievement_tingkat_list) + click_on "Edit this achievement tingkat list", match: :first + + fill_in "Tingkat", with: @achievement_tingkat_list.tingkat + click_on "Update Achievement tingkat list" + + assert_text "Achievement tingkat list was successfully updated" + click_on "Back" + end + + test "should destroy Achievement tingkat list" do + visit achievement_tingkat_list_url(@achievement_tingkat_list) + click_on "Destroy this achievement tingkat list", match: :first + + assert_text "Achievement tingkat list was successfully destroyed" + end +end