From 6c948a9d715e33758635a033c4f9b353474bed14 Mon Sep 17 00:00:00 2001 From: Michael Sipayung Date: Thu, 1 Feb 2024 09:24:07 +0700 Subject: [PATCH] fix non standart style in model --- app/controllers/microposts_controller.rb | 9 +- app/controllers/password_resets_controller.rb | 4 +- app/controllers/sessions_controller.rb | 4 - app/controllers/static_pages_controller.rb | 2 +- app/controllers/utbk_scores_controller.rb | 4 +- app/models/pmdk_each_score_information.rb | 23 +- app/models/pmdk_total_score_information.rb | 16 +- app/models/utbk_score.rb | 4 +- app/views/shared/_utbk_score_form.html.erb | 8 +- ...0240201000155_rename_column_total_score.rb | 2 + .../20240201001601_rename_column_usm.rb | 2 + .../20240201014932_rename_column_utbk.rb | 10 + db/schema.rb | 843 +++++++++--------- .../utbk_scores_controller_test.rb | 16 +- test/models/utbk_score_test.rb | 16 +- 15 files changed, 498 insertions(+), 465 deletions(-) create mode 100644 db/migrate/20240201014932_rename_column_utbk.rb diff --git a/app/controllers/microposts_controller.rb b/app/controllers/microposts_controller.rb index a7ff242..f2a70cf 100644 --- a/app/controllers/microposts_controller.rb +++ b/app/controllers/microposts_controller.rb @@ -5,12 +5,13 @@ class MicropostsController < ApplicationController # only login user could create and destroy it's post before_action :logged_in_user, only: %i[create destroy] before_action :correct_user, only: :destroy + # the present of current_user is to tell that create it by + # who already logged in and to make the current user post + # using build, since we work with collection, return new object of collection + # add image to newly created micropost object + def create - # the present of current_user is to tell that create it by - # who already logged in and to make the current user post - # using build, since we work with collection, return new object of collection @micropost = current_user.microposts.build(micropost_params) - # add image to newly created micropost object @micropost.image.attach(params[:micropost][:image]) if @micropost.save # save the post's current user flash[:success] = 'Micropost created!' diff --git a/app/controllers/password_resets_controller.rb b/app/controllers/password_resets_controller.rb index 80636bd..6895c66 100644 --- a/app/controllers/password_resets_controller.rb +++ b/app/controllers/password_resets_controller.rb @@ -5,7 +5,7 @@ class PasswordResetsController < ApplicationController # Because confirmation of the existence of a valid @user # is needed in both the update and edit actions before_action :logged_in_user, except: %i[update new create edit] - before_action :get_user, only: %i[edit update] + before_action :find_user, only: %i[edit update] before_action :valid_user, only: %i[edit update] # make sure the reset password is not expired before_action :check_expiration, only: %i[edit update] @@ -42,7 +42,7 @@ def edit; end private # only valid user can get request edit password - def get_user + def find_user @user = User.find_by(email: params[:email]) end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index d0c4098..55eaffc 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -10,18 +10,14 @@ def create if user&.authenticate(params[:session][:password]) if user.activated log_in user # log the user in (session) - # remember user only if the user clicked remember params[:session][:remember_me] == '1' ? remember(user) : forget(user) - # remember(user) redirect_back_or user # automatically convert to the route user_url(user) else message = 'Account not activated' - message += 'Check your email for activation link' flash[:warning] = message redirect_to root_url end else - # create an error message flash.now[:danger] = 'Invalid email/password combination' render 'new' end diff --git a/app/controllers/static_pages_controller.rb b/app/controllers/static_pages_controller.rb index 538be7f..324e05f 100644 --- a/app/controllers/static_pages_controller.rb +++ b/app/controllers/static_pages_controller.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true - +# static pages, serve static content class StaticPagesController < ApplicationController skip_before_action :logged_in_user, only: %i[home help about contact] def home diff --git a/app/controllers/utbk_scores_controller.rb b/app/controllers/utbk_scores_controller.rb index 2c012b5..b62aaab 100644 --- a/app/controllers/utbk_scores_controller.rb +++ b/app/controllers/utbk_scores_controller.rb @@ -37,8 +37,8 @@ def show; end def utbk_score_params params.require(:utbk_score).permit(:no_peserta, :tanggal_ujian, - :jumlah_nilai_semester_6, - :jumlah_pelajaran_semester_6, + :jumlah_nilai_semester6, + :jumlah_pelajaran_semester6, :nilai_penalaran_umum, :nilai_pengetahuan_kuantitatif, :nilai_kemampuan_memahami_bacaan_dan_menulis, diff --git a/app/models/pmdk_each_score_information.rb b/app/models/pmdk_each_score_information.rb index 3e4a35d..1269b4b 100644 --- a/app/models/pmdk_each_score_information.rb +++ b/app/models/pmdk_each_score_information.rb @@ -3,12 +3,23 @@ # model pmdk_each_score_information : handle pmdk_each_score_information class PmdkEachScoreInformation < ApplicationRecord belongs_to :user - validates :matematika_semester1, :matematika_semester2, :matematika_semester3, :matematika_semester4, - :matematika5, :kimia1, :kimia2, :kimia3, :kimia4, - :kimia5, :fisika1, :fisika2, :fisika3, :fisika4, - :fisika5, :inggris1, :inggris2, :inggris3, - :inggris4, :inggris5, presence: true, - numericality: { only_integer: false, greater_than_or_equal_to: 2, less_than_or_equal_to: 100 } + validates :matematika_semester1, + :matematika_semester2, + :matematika_semester3, + :matematika_semester4, + :matematika5, + :kimia1, + :kimia2, + :kimia3, + :kimia4, + :kimia5, + :fisika1, :fisika2, + :fisika3, :fisika4, + :fisika5, :inggris1, + :inggris2, :inggris3, + :inggris4, :inggris5, + presence: true, + numericality: { only_integer: false, greater_than_or_equal_to: 2, less_than_or_equal_to: 100 } has_one_attached :sertifikat validates :sertifikat, content_type: [:pdf], size: { less_than: 1.megabytes } end diff --git a/app/models/pmdk_total_score_information.rb b/app/models/pmdk_total_score_information.rb index 096f768..c98078d 100644 --- a/app/models/pmdk_total_score_information.rb +++ b/app/models/pmdk_total_score_information.rb @@ -3,11 +3,19 @@ # model PmdkTotalScoreInformation : handle pmdk_total_score_information class PmdkTotalScoreInformation < ApplicationRecord belongs_to :user - validates :jumlah_nilai_semester1, :jumlah_nilai_semester2, :jumlah_nilai_semester3, - :jumlah_nilai_semester4, :jumlah_nilai_semester5, presence: true, + validates :jumlah_nilai_semester1, + :jumlah_nilai_semester2, + :jumlah_nilai_semester3, + :jumlah_nilai_semester4, + :jumlah_nilai_semester5, + presence: true, numericality: { only_integer: false, greater_than_or_equal_to: 2, less_than_or_equal_to: 3000 } - validates :jumlah_pelajaran_semester1, :jumlah_pelajaran_semester2, :jumlah_pelajaran_semester3, - :jumlah_pelajaran_semester4, :jumlah_pelajaran_semester5, presence: true, + validates :jumlah_pelajaran_semester1, + :jumlah_pelajaran_semester2, + :jumlah_pelajaran_semester3, + :jumlah_pelajaran_semester4, + :jumlah_pelajaran_semester5, + presence: true, numericality: { only_integer: true, greater_than_or_equal_to: 2, less_than_or_equal_to: 30 } has_one_attached :surat_rekomendasi validates :surat_rekomendasi, content_type: [:pdf], size: { less_than: 1.megabytes } diff --git a/app/models/utbk_score.rb b/app/models/utbk_score.rb index 593b690..e66213e 100644 --- a/app/models/utbk_score.rb +++ b/app/models/utbk_score.rb @@ -12,10 +12,10 @@ class UtbkScore < ApplicationRecord :nilai_kemampuan_memahami_bacaan_dan_menulis, presence: true, numericality: { only_integer: false, greater_than_or_equal_to: 5, less_than_or_equal_to: 2000 } - validates :jumlah_nilai_semester_6, + validates :jumlah_nilai_semester6, presence: true, numericality: { only_integer: false, greater_than_or_equal_to: 2, less_than_or_equal_to: 2000 } - validates :jumlah_pelajaran_semester_6, + validates :jumlah_pelajaran_semester6, presence: true, numericality: { only_integer: true, greater_than_or_equal_to: 2, less_than_or_equal_to: 100 } has_one_attached :sertifikat_utbk # active storange api diff --git a/app/views/shared/_utbk_score_form.html.erb b/app/views/shared/_utbk_score_form.html.erb index 80ae365..2acccd3 100644 --- a/app/views/shared/_utbk_score_form.html.erb +++ b/app/views/shared/_utbk_score_form.html.erb @@ -14,10 +14,10 @@ placeholder: 'Nilai Pengetahuan Kuantitatif' %> <%= f.text_field :nilai_kemampuan_memahami_bacaan_dan_menulis, class: 'form-control', placeholder: 'Nilai Kemampuan Memahami Bacaan & Menulis' %> - <%= f.text_field :jumlah_nilai_semester_6, class: 'form-control', - placeholder: 'Jumlah Nilai Semester 6' %> - <%= f.number_field :jumlah_pelajaran_semester_6, class: 'form-control', - placeholder: 'Jumlah Pelajaran Semester 6' %> + <%= f.text_field :jumlah_nilai_semester6, class: 'form-control', + placeholder: 'Jumlah Nilai Semester 6' %> + <%= f.number_field :jumlah_pelajaran_semester6, class: 'form-control', + placeholder: 'Jumlah Pelajaran Semester 6' %> <%= f.file_field :sertifikat_utbk, accept: "application/pdf" %> diff --git a/db/migrate/20240201000155_rename_column_total_score.rb b/db/migrate/20240201000155_rename_column_total_score.rb index 7cd19d8..00cc785 100644 --- a/db/migrate/20240201000155_rename_column_total_score.rb +++ b/db/migrate/20240201000155_rename_column_total_score.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class RenameColumnTotalScore < ActiveRecord::Migration[7.1] def change rename_column :pmdk_total_score_informations, :jumlah_nilai_semester_1, diff --git a/db/migrate/20240201001601_rename_column_usm.rb b/db/migrate/20240201001601_rename_column_usm.rb index d90c566..e49ff13 100644 --- a/db/migrate/20240201001601_rename_column_usm.rb +++ b/db/migrate/20240201001601_rename_column_usm.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class RenameColumnUsm < ActiveRecord::Migration[7.1] def change rename_column :usm_school_informations, :jumlah_nilai_semester_5, diff --git a/db/migrate/20240201014932_rename_column_utbk.rb b/db/migrate/20240201014932_rename_column_utbk.rb new file mode 100644 index 0000000..671a37d --- /dev/null +++ b/db/migrate/20240201014932_rename_column_utbk.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +class RenameColumnUtbk < ActiveRecord::Migration[7.1] + def change + rename_column :utbk_scores, :jumlah_pelajaran_semester_6, + :jumlah_pelajaran_semester6 + rename_column :utbk_scores, :jumlah_nilai_semester_6, + :jumlah_nilai_semester6 + end +end diff --git a/db/schema.rb b/db/schema.rb index 06cdb43..5685ae0 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. @@ -10,451 +12,452 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2024_02_01_001601) do - create_table "accreditation_school_lists", force: :cascade do |t| - t.string "akreditasi" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - end +ActiveRecord::Schema[7.1].define(version: 20_240_201_014_932) do + create_table 'accreditation_school_lists', force: :cascade do |t| + t.string 'akreditasi' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + end + + 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_kategori_lists", force: :cascade do |t| - t.string "kategori" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + 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 "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" - t.string "tingkat" - t.string "kategori" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.integer "user_id", null: false - t.index ["user_id"], name: "index_achievements_on_user_id" + create_table 'achievements', force: :cascade do |t| + t.string 'nama_prestasi' + t.date 'tahun' + t.string 'tingkat' + t.string 'kategori' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + t.integer 'user_id', null: false + t.index ['user_id'], name: 'index_achievements_on_user_id' + end + + create_table 'active_storage_attachments', force: :cascade do |t| + t.string 'name', null: false + t.string 'record_type', null: false + t.bigint 'record_id', null: false + t.bigint 'blob_id', null: false + t.datetime 'created_at', null: false + t.index ['blob_id'], name: 'index_active_storage_attachments_on_blob_id' + t.index %w[record_type record_id name blob_id], name: 'index_active_storage_attachments_uniqueness', + unique: true end - create_table "active_storage_attachments", force: :cascade do |t| - t.string "name", null: false - t.string "record_type", null: false - t.bigint "record_id", null: false - t.bigint "blob_id", null: false - t.datetime "created_at", null: false - t.index ["blob_id"], name: "index_active_storage_attachments_on_blob_id" - t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true + create_table 'active_storage_blobs', force: :cascade do |t| + t.string 'key', null: false + t.string 'filename', null: false + t.string 'content_type' + t.text 'metadata' + t.string 'service_name', null: false + t.bigint 'byte_size', null: false + t.string 'checksum' + t.datetime 'created_at', null: false + t.index ['key'], name: 'index_active_storage_blobs_on_key', unique: true + end + + create_table 'active_storage_variant_records', force: :cascade do |t| + t.bigint 'blob_id', null: false + t.string 'variation_digest', null: false + t.index %w[blob_id variation_digest], name: 'index_active_storage_variant_records_uniqueness', unique: true end - - create_table "active_storage_blobs", force: :cascade do |t| - t.string "key", null: false - t.string "filename", null: false - t.string "content_type" - t.text "metadata" - t.string "service_name", null: false - t.bigint "byte_size", null: false - t.string "checksum" - t.datetime "created_at", null: false - t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true - end - - create_table "active_storage_variant_records", force: :cascade do |t| - t.bigint "blob_id", null: false - t.string "variation_digest", null: false - t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true + + create_table 'address_kabupaten_lists', force: :cascade do |t| + t.string 'kabupaten' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + t.integer 'address_province_list_id', null: false + t.index ['address_province_list_id'], name: 'index_address_kabupaten_lists_on_address_province_list_id' end - create_table "address_kabupaten_lists", force: :cascade do |t| - t.string "kabupaten" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.integer "address_province_list_id", null: false - t.index ["address_province_list_id"], name: "index_address_kabupaten_lists_on_address_province_list_id" + create_table 'address_kecamatan_lists', force: :cascade do |t| + t.string 'kecamatan' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + t.integer 'address_kabupaten_list_id', null: false + t.index ['address_kabupaten_list_id'], name: 'index_address_kecamatan_lists_on_address_kabupaten_list_id' end - create_table "address_kecamatan_lists", force: :cascade do |t| - t.string "kecamatan" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.integer "address_kabupaten_list_id", null: false - t.index ["address_kabupaten_list_id"], name: "index_address_kecamatan_lists_on_address_kabupaten_list_id" + create_table 'address_province_lists', force: :cascade do |t| + t.string 'provinsi' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false end - create_table "address_province_lists", force: :cascade do |t| - t.string "provinsi" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + create_table 'addresses', force: :cascade do |t| + t.string 'alamat' + t.string 'kelurahan' + t.string 'kecamatan' + t.integer 'kode_pos' + t.string 'provinsi' + t.integer 'no_telepon' + t.string 'kabupaten' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + t.integer 'user_id', null: false + t.index ['user_id'], name: 'index_addresses_on_user_id' end - create_table "addresses", force: :cascade do |t| - t.string "alamat" - t.string "kelurahan" - t.string "kecamatan" - t.integer "kode_pos" - t.string "provinsi" - t.integer "no_telepon" - t.string "kabupaten" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.integer "user_id", null: false - t.index ["user_id"], name: "index_addresses_on_user_id" - end - - create_table "all_school_lists", force: :cascade do |t| - t.string "sekolah" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + create_table 'all_school_lists', force: :cascade do |t| + t.string 'sekolah' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + end + + create_table 'batch_lists', force: :cascade do |t| + t.string 'gelombang' + t.boolean 'aktif' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false end - create_table "batch_lists", force: :cascade do |t| - t.string "gelombang" - t.boolean "aktif" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - end - - create_table "cost_lists", force: :cascade do |t| - t.integer "biaya" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - end - - create_table "cost_vourcher_lists", force: :cascade do |t| - t.string "voucher" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - end - - create_table "costs", force: :cascade do |t| - t.integer "biaya" - t.integer "virtual_account" - t.string "voucher" - t.integer "total_bayar" - t.boolean "status_pembayaran" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.integer "user_id", null: false - t.index ["user_id"], name: "index_costs_on_user_id" + create_table 'cost_lists', force: :cascade do |t| + t.integer 'biaya' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + end + + create_table 'cost_vourcher_lists', force: :cascade do |t| + t.string 'voucher' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + end + + create_table 'costs', force: :cascade do |t| + t.integer 'biaya' + t.integer 'virtual_account' + t.string 'voucher' + t.integer 'total_bayar' + t.boolean 'status_pembayaran' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + t.integer 'user_id', null: false + t.index ['user_id'], name: 'index_costs_on_user_id' end - create_table "extra_lists", force: :cascade do |t| - t.string "predikat" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + create_table 'extra_lists', force: :cascade do |t| + t.string 'predikat' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false end - create_table "extras", force: :cascade do |t| - t.string "nama_kegiatan" - t.date "mulai" - t.date "berakhir" - t.string "predikat" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.integer "user_id", null: false - t.index ["user_id"], name: "index_extras_on_user_id" + create_table 'extras', force: :cascade do |t| + t.string 'nama_kegiatan' + t.date 'mulai' + t.date 'berakhir' + t.string 'predikat' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + t.integer 'user_id', null: false + t.index ['user_id'], name: 'index_extras_on_user_id' end - create_table "high_school_majors", force: :cascade do |t| - t.string "jurusan" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + create_table 'high_school_majors', force: :cascade do |t| + t.string 'jurusan' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false end - create_table "language_degree_lists", force: :cascade do |t| - t.string "tingkat" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + create_table 'language_degree_lists', force: :cascade do |t| + t.string 'tingkat' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false end - create_table "language_name_lists", force: :cascade do |t| - t.string "bahasa" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + create_table 'language_name_lists', force: :cascade do |t| + t.string 'bahasa' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false end - - create_table "languages", force: :cascade do |t| - t.string "nama_bahasa" - t.string "tingkat" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.integer "user_id", null: false - t.index ["user_id"], name: "index_languages_on_user_id" - end - - create_table "major_lists", force: :cascade do |t| - t.string "jurusan" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - end - - create_table "majors", force: :cascade do |t| - t.string "jurusan1" - t.string "jurusan2" - t.string "jurusan3" - t.string "gelombang" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.integer "user_id", null: false - t.index ["user_id"], name: "index_majors_on_user_id" - end - - create_table "microposts", force: :cascade do |t| - t.text "content" - t.integer "user_id", null: false - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.index ["user_id", "created_at"], name: "index_microposts_on_user_id_and_created_at" - t.index ["user_id"], name: "index_microposts_on_user_id" - end - - create_table "organization_degree_lists", force: :cascade do |t| - t.string "jabatan" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - end - - create_table "organizations", force: :cascade do |t| - t.string "nama_organisasi" - t.date "mulai" - t.date "berakhir" - t.string "jabatan" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.integer "user_id", null: false - t.index ["user_id"], name: "index_organizations_on_user_id" - end - - create_table "parent_education_lists", force: :cascade do |t| - t.string "pendidikan" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - end - - create_table "parent_job_lists", force: :cascade do |t| - t.string "pekerjaan" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - end - - create_table "parents", force: :cascade do |t| - t.string "nama_ayah" - t.string "nama_ibu" - t.integer "nik_ayah" - t.integer "nik_ibu" - t.string "pendidikan_ayah" - t.string "pendidikan_ibu" - t.date "tanggal_lahir_ayah" - t.date "tanggal_lahir_ibu" - t.string "pekerjaan_ayah" - t.string "pekerjaan_ibu" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.integer "user_id", null: false - t.index ["user_id"], name: "index_parents_on_user_id" - end - - create_table "personal_gender_lists", force: :cascade do |t| - t.string "jenis_kelamin" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - end - - create_table "personal_religion_lists", force: :cascade do |t| - t.string "agama" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - end - - create_table "personals", force: :cascade do |t| - t.string "nama_lengkap" - t.string "agama" - t.integer "nik" - t.integer "nisn" - t.integer "no_kps" - t.date "tanggal_lahir" - t.string "tempat_lahir" - t.string "jenis_kelamin" - t.string "domisili" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.integer "user_id", null: false - t.index ["user_id"], name: "index_personals_on_user_id" - end - - create_table "pmdk_each_score_informations", force: :cascade do |t| - t.decimal "matematika_semester1" - t.decimal "matematika_semester2" - t.decimal "matematika_semester3" - t.decimal "matematika_semester4" - t.decimal "matematika5" - t.decimal "fisika1" - t.decimal "fisika2" - t.decimal "fisika3" - t.decimal "fisika4" - t.decimal "fisika5" - t.decimal "kimia1" - t.decimal "kimia2" - t.decimal "kimia3" - t.decimal "kimia4" - t.decimal "kimia5" - t.decimal "inggris1" - t.decimal "inggris2" - t.decimal "inggris3" - t.decimal "inggris4" - t.decimal "inggris5" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.integer "user_id", null: false - t.index ["user_id"], name: "index_pmdk_each_score_informations_on_user_id" - end - - create_table "pmdk_school_informations", force: :cascade do |t| - t.string "asal_sekolah" - t.string "akreditas" - t.integer "jumlah_pelajaran_un" - t.decimal "jumlah_nilai_un" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.integer "user_id", null: false - t.string "jurusan_sekolah" - t.index ["user_id"], name: "index_pmdk_school_informations_on_user_id" - end - - create_table "pmdk_school_lists", force: :cascade do |t| - t.string "sekolah" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - end - - create_table "pmdk_total_score_informations", force: :cascade do |t| - t.decimal "jumlah_nilai_semester1" - t.decimal "jumlah_nilai_semester2" - t.decimal "jumlah_nilai_semester3" - t.decimal "jumlah_nilai_semester4" - t.decimal "jumlah_nilai_semester5" - t.integer "jumlah_pelajaran_semester1" - t.integer "jumlah_pelajaran_semester2" - t.integer "jumlah_pelajaran_semester3" - t.integer "jumlah_pelajaran_semester4" - t.integer "jumlah_pelajaran_semester5" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.integer "user_id", null: false - t.index ["user_id"], name: "index_pmdk_total_score_informations_on_user_id" - end - - create_table "relationships", force: :cascade do |t| - t.integer "follower_id" - t.integer "followed_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.index ["followed_id"], name: "index_relationships_on_followed_id" - t.index ["follower_id", "followed_id"], name: "index_relationships_on_follower_id_and_followed_id", unique: true - t.index ["follower_id"], name: "index_relationships_on_follower_id" - end - - create_table "source_information_lists", force: :cascade do |t| - t.string "informasi" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - end - - create_table "source_motivation_lists", force: :cascade do |t| - t.string "motivasi" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - end - - create_table "sources", force: :cascade do |t| - t.integer "jumlah_n" - t.string "sumber_informasi" - t.string "motivasi" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.integer "user_id", null: false - t.index ["user_id"], name: "index_sources_on_user_id" - end - - create_table "users", force: :cascade do |t| - t.string "name" - t.string "email" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.string "password_digest" - t.string "remember_digest" - t.boolean "admin", default: false - t.string "activation_digest" - t.boolean "activated", default: false - t.datetime "activated_at" - t.string "reset_digest" - t.datetime "reset_sent_at" - t.index ["email"], name: "index_users_on_email", unique: true - end - - create_table "usm_school_informations", force: :cascade do |t| - t.string "asal_sekolah" - t.string "akreditas" - t.integer "jumlah_pelajaran_un" - t.decimal "jumlah_nilai_un" - t.string "jurusan_sekolah" - t.integer "jumlah_pelajaran_semester5" - t.decimal "jumlah_nilai_semester5" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.integer "user_id", null: false - t.index ["user_id"], name: "index_usm_school_informations_on_user_id" - end - - create_table "utbk_school_informations", force: :cascade do |t| - t.string "asal_sekolah" - t.string "akreditas" - t.integer "jumlah_pelajaran_un" - t.decimal "jumlah_nilai_un" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.integer "user_id", null: false - t.string "jurusan_sekolah" - t.index ["user_id"], name: "index_utbk_school_informations_on_user_id" - end - - create_table "utbk_scores", force: :cascade do |t| - t.string "no_peserta" - t.date "tanggal_ujian" - t.decimal "nilai_penalaran_umum" - t.decimal "nilai_pengetahuan_kuantitatif" - t.decimal "nilai_pengetahuan_dan_pemahaman_umum" - t.decimal "nilai_kemampuan_memahami_bacaan_dan_menulis" - t.integer "jumlah_pelajaran_semester_6" - t.decimal "jumlah_nilai_semester_6" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.integer "user_id", null: false - t.index ["user_id"], name: "index_utbk_scores_on_user_id" - end - - add_foreign_key "achievements", "users" - add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id" - add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id" - add_foreign_key "address_kabupaten_lists", "address_province_lists" - add_foreign_key "address_kecamatan_lists", "address_kabupaten_lists" - add_foreign_key "addresses", "users" - add_foreign_key "costs", "users" - add_foreign_key "extras", "users" - add_foreign_key "languages", "users" - add_foreign_key "majors", "users" - add_foreign_key "microposts", "users" - add_foreign_key "organizations", "users" - add_foreign_key "parents", "users" - add_foreign_key "personals", "users" - add_foreign_key "pmdk_each_score_informations", "users" - add_foreign_key "pmdk_school_informations", "users" - add_foreign_key "pmdk_total_score_informations", "users" - add_foreign_key "sources", "users" - add_foreign_key "usm_school_informations", "users" - add_foreign_key "utbk_school_informations", "users" - add_foreign_key "utbk_scores", "users" + + create_table 'languages', force: :cascade do |t| + t.string 'nama_bahasa' + t.string 'tingkat' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + t.integer 'user_id', null: false + t.index ['user_id'], name: 'index_languages_on_user_id' + end + + create_table 'major_lists', force: :cascade do |t| + t.string 'jurusan' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + end + + create_table 'majors', force: :cascade do |t| + t.string 'jurusan1' + t.string 'jurusan2' + t.string 'jurusan3' + t.string 'gelombang' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + t.integer 'user_id', null: false + t.index ['user_id'], name: 'index_majors_on_user_id' + end + + create_table 'microposts', force: :cascade do |t| + t.text 'content' + t.integer 'user_id', null: false + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + t.index %w[user_id created_at], name: 'index_microposts_on_user_id_and_created_at' + t.index ['user_id'], name: 'index_microposts_on_user_id' + end + + create_table 'organization_degree_lists', force: :cascade do |t| + t.string 'jabatan' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + end + + create_table 'organizations', force: :cascade do |t| + t.string 'nama_organisasi' + t.date 'mulai' + t.date 'berakhir' + t.string 'jabatan' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + t.integer 'user_id', null: false + t.index ['user_id'], name: 'index_organizations_on_user_id' + end + + create_table 'parent_education_lists', force: :cascade do |t| + t.string 'pendidikan' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + end + + create_table 'parent_job_lists', force: :cascade do |t| + t.string 'pekerjaan' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + end + + create_table 'parents', force: :cascade do |t| + t.string 'nama_ayah' + t.string 'nama_ibu' + t.integer 'nik_ayah' + t.integer 'nik_ibu' + t.string 'pendidikan_ayah' + t.string 'pendidikan_ibu' + t.date 'tanggal_lahir_ayah' + t.date 'tanggal_lahir_ibu' + t.string 'pekerjaan_ayah' + t.string 'pekerjaan_ibu' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + t.integer 'user_id', null: false + t.index ['user_id'], name: 'index_parents_on_user_id' + end + + create_table 'personal_gender_lists', force: :cascade do |t| + t.string 'jenis_kelamin' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + end + + create_table 'personal_religion_lists', force: :cascade do |t| + t.string 'agama' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + end + + create_table 'personals', force: :cascade do |t| + t.string 'nama_lengkap' + t.string 'agama' + t.integer 'nik' + t.integer 'nisn' + t.integer 'no_kps' + t.date 'tanggal_lahir' + t.string 'tempat_lahir' + t.string 'jenis_kelamin' + t.string 'domisili' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + t.integer 'user_id', null: false + t.index ['user_id'], name: 'index_personals_on_user_id' + end + + create_table 'pmdk_each_score_informations', force: :cascade do |t| + t.decimal 'matematika_semester1' + t.decimal 'matematika_semester2' + t.decimal 'matematika_semester3' + t.decimal 'matematika_semester4' + t.decimal 'matematika5' + t.decimal 'fisika1' + t.decimal 'fisika2' + t.decimal 'fisika3' + t.decimal 'fisika4' + t.decimal 'fisika5' + t.decimal 'kimia1' + t.decimal 'kimia2' + t.decimal 'kimia3' + t.decimal 'kimia4' + t.decimal 'kimia5' + t.decimal 'inggris1' + t.decimal 'inggris2' + t.decimal 'inggris3' + t.decimal 'inggris4' + t.decimal 'inggris5' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + t.integer 'user_id', null: false + t.index ['user_id'], name: 'index_pmdk_each_score_informations_on_user_id' + end + + create_table 'pmdk_school_informations', force: :cascade do |t| + t.string 'asal_sekolah' + t.string 'akreditas' + t.integer 'jumlah_pelajaran_un' + t.decimal 'jumlah_nilai_un' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + t.integer 'user_id', null: false + t.string 'jurusan_sekolah' + t.index ['user_id'], name: 'index_pmdk_school_informations_on_user_id' + end + + create_table 'pmdk_school_lists', force: :cascade do |t| + t.string 'sekolah' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + end + + create_table 'pmdk_total_score_informations', force: :cascade do |t| + t.decimal 'jumlah_nilai_semester1' + t.decimal 'jumlah_nilai_semester2' + t.decimal 'jumlah_nilai_semester3' + t.decimal 'jumlah_nilai_semester4' + t.decimal 'jumlah_nilai_semester5' + t.integer 'jumlah_pelajaran_semester1' + t.integer 'jumlah_pelajaran_semester2' + t.integer 'jumlah_pelajaran_semester3' + t.integer 'jumlah_pelajaran_semester4' + t.integer 'jumlah_pelajaran_semester5' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + t.integer 'user_id', null: false + t.index ['user_id'], name: 'index_pmdk_total_score_informations_on_user_id' + end + + create_table 'relationships', force: :cascade do |t| + t.integer 'follower_id' + t.integer 'followed_id' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + t.index ['followed_id'], name: 'index_relationships_on_followed_id' + t.index %w[follower_id followed_id], name: 'index_relationships_on_follower_id_and_followed_id', unique: true + t.index ['follower_id'], name: 'index_relationships_on_follower_id' + end + + create_table 'source_information_lists', force: :cascade do |t| + t.string 'informasi' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + end + + create_table 'source_motivation_lists', force: :cascade do |t| + t.string 'motivasi' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + end + + create_table 'sources', force: :cascade do |t| + t.integer 'jumlah_n' + t.string 'sumber_informasi' + t.string 'motivasi' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + t.integer 'user_id', null: false + t.index ['user_id'], name: 'index_sources_on_user_id' + end + + create_table 'users', force: :cascade do |t| + t.string 'name' + t.string 'email' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + t.string 'password_digest' + t.string 'remember_digest' + t.boolean 'admin', default: false + t.string 'activation_digest' + t.boolean 'activated', default: false + t.datetime 'activated_at' + t.string 'reset_digest' + t.datetime 'reset_sent_at' + t.index ['email'], name: 'index_users_on_email', unique: true + end + + create_table 'usm_school_informations', force: :cascade do |t| + t.string 'asal_sekolah' + t.string 'akreditas' + t.integer 'jumlah_pelajaran_un' + t.decimal 'jumlah_nilai_un' + t.string 'jurusan_sekolah' + t.integer 'jumlah_pelajaran_semester5' + t.decimal 'jumlah_nilai_semester5' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + t.integer 'user_id', null: false + t.index ['user_id'], name: 'index_usm_school_informations_on_user_id' + end + + create_table 'utbk_school_informations', force: :cascade do |t| + t.string 'asal_sekolah' + t.string 'akreditas' + t.integer 'jumlah_pelajaran_un' + t.decimal 'jumlah_nilai_un' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + t.integer 'user_id', null: false + t.string 'jurusan_sekolah' + t.index ['user_id'], name: 'index_utbk_school_informations_on_user_id' + end + + create_table 'utbk_scores', force: :cascade do |t| + t.string 'no_peserta' + t.date 'tanggal_ujian' + t.decimal 'nilai_penalaran_umum' + t.decimal 'nilai_pengetahuan_kuantitatif' + t.decimal 'nilai_pengetahuan_dan_pemahaman_umum' + t.decimal 'nilai_kemampuan_memahami_bacaan_dan_menulis' + t.integer 'jumlah_pelajaran_semester6' + t.decimal 'jumlah_nilai_semester6' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + t.integer 'user_id', null: false + t.index ['user_id'], name: 'index_utbk_scores_on_user_id' + end + + add_foreign_key 'achievements', 'users' + add_foreign_key 'active_storage_attachments', 'active_storage_blobs', column: 'blob_id' + add_foreign_key 'active_storage_variant_records', 'active_storage_blobs', column: 'blob_id' + add_foreign_key 'address_kabupaten_lists', 'address_province_lists' + add_foreign_key 'address_kecamatan_lists', 'address_kabupaten_lists' + add_foreign_key 'addresses', 'users' + add_foreign_key 'costs', 'users' + add_foreign_key 'extras', 'users' + add_foreign_key 'languages', 'users' + add_foreign_key 'majors', 'users' + add_foreign_key 'microposts', 'users' + add_foreign_key 'organizations', 'users' + add_foreign_key 'parents', 'users' + add_foreign_key 'personals', 'users' + add_foreign_key 'pmdk_each_score_informations', 'users' + add_foreign_key 'pmdk_school_informations', 'users' + add_foreign_key 'pmdk_total_score_informations', 'users' + add_foreign_key 'sources', 'users' + add_foreign_key 'usm_school_informations', 'users' + add_foreign_key 'utbk_school_informations', 'users' + add_foreign_key 'utbk_scores', 'users' end diff --git a/test/controllers/utbk_scores_controller_test.rb b/test/controllers/utbk_scores_controller_test.rb index 2baadf1..68a3658 100644 --- a/test/controllers/utbk_scores_controller_test.rb +++ b/test/controllers/utbk_scores_controller_test.rb @@ -24,15 +24,15 @@ def setup assert_response :success patch utbk_score_path, params: { utbk_score: { no_peserta: '200-1bx-2', tanggal_ujian: '2021-12-11', - jumlah_nilai_semester_6: 1000.5, jumlah_pelajaran_semester_6: 15, + jumlah_nilai_semester6: 1000.5, jumlah_pelajaran_semester6: 15, nilai_penalaran_umum: 190.5, nilai_pengetahuan_kuantitatif: 110.5, nilai_kemampuan_memahami_bacaan_dan_menulis: 100.5, nilai_pengetahuan_dan_pemahaman_umum: 150.5 } } assert_equal '200-1bx-2', utbk_scores(:utbk_score_one).reload.no_peserta - assert_equal 1000.5, utbk_scores(:utbk_score_one).jumlah_nilai_semester_6 - assert_equal 15, utbk_scores(:utbk_score_one).jumlah_pelajaran_semester_6 + assert_equal 1000.5, utbk_scores(:utbk_score_one).jumlah_nilai_semester6 + assert_equal 15, utbk_scores(:utbk_score_one).jumlah_pelajaran_semester6 assert_equal 190.5, utbk_scores(:utbk_score_one).reload.nilai_penalaran_umum assert_equal 110.5, utbk_scores(:utbk_score_one).reload.nilai_pengetahuan_kuantitatif @@ -45,7 +45,7 @@ def setup assert_difference 'UtbkScore.count' do post utbk_scores_path, params: { utbk_score: { no_peserta: '200-1bx-2', tanggal_ujian: '2020-12-11', - jumlah_nilai_semester_6: 1000.5, jumlah_pelajaran_semester_6: 15, + jumlah_nilai_semester6: 1000.5, jumlah_pelajaran_semester6: 15, nilai_penalaran_umum: 190.5, nilai_pengetahuan_kuantitatif: 110.5, nilai_kemampuan_memahami_bacaan_dan_menulis: 100.5, @@ -53,8 +53,8 @@ def setup } end assert_not_nil UtbkScore.find_by_no_peserta '200-1bx-2' - assert_not_nil UtbkScore.find_by_jumlah_pelajaran_semester_6 15 - assert_not_nil UtbkScore.find_by_jumlah_nilai_semester_6 1000.5 + assert_not_nil UtbkScore.find_by_jumlah_pelajaran_semester6 15 + assert_not_nil UtbkScore.find_by_jumlah_nilai_semester6 1000.5 assert_not_nil UtbkScore.find_by_nilai_penalaran_umum 190.5 assert_not_nil UtbkScore.find_by_nilai_pengetahuan_kuantitatif 110.5 assert_not_nil UtbkScore.find_by_nilai_kemampuan_memahami_bacaan_dan_menulis 100.5 @@ -75,7 +75,7 @@ def setup assert_difference 'UtbkScore.count' do post utbk_scores_path, params: { utbk_score: { no_peserta: '200-1bx-2', tanggal_ujian: '2020-12-11', - jumlah_nilai_semester_6: 1000.5, jumlah_pelajaran_semester_6: 15, + jumlah_nilai_semester6: 1000.5, jumlah_pelajaran_semester6: 15, nilai_penalaran_umum: 190.5, nilai_pengetahuan_kuantitatif: 110.5, nilai_kemampuan_memahami_bacaan_dan_menulis: 100.5, @@ -90,7 +90,7 @@ def setup assert_difference 'UtbkScore.count' do post utbk_scores_path, params: { utbk_score: { no_peserta: '200-1bx-2', tanggal_ujian: '2020-12-11', - jumlah_nilai_semester_6: 1000.5, jumlah_pelajaran_semester_6: 15, + jumlah_nilai_semester6: 1000.5, jumlah_pelajaran_semester6: 15, nilai_penalaran_umum: 190.5, nilai_pengetahuan_kuantitatif: 110.5, nilai_kemampuan_memahami_bacaan_dan_menulis: 100.5, diff --git a/test/models/utbk_score_test.rb b/test/models/utbk_score_test.rb index 1210ea8..660d8ce 100644 --- a/test/models/utbk_score_test.rb +++ b/test/models/utbk_score_test.rb @@ -5,7 +5,7 @@ class UtbkScoreTest < ActiveSupport::TestCase def setup @score_utbk = UtbkScore.new(user_id: users(:michael).id, no_peserta: '200-1bx', tanggal_ujian: '2020-12-11', - jumlah_nilai_semester_6: 1200.5, jumlah_pelajaran_semester_6: 11, + jumlah_nilai_semester6: 1200.5, jumlah_pelajaran_semester6: 11, nilai_penalaran_umum: 120.5, nilai_pengetahuan_kuantitatif: 150.5, nilai_kemampuan_memahami_bacaan_dan_menulis: 300.5, @@ -31,19 +31,19 @@ def setup assert_not @score_utbk.valid? end test 'should reject invalid jumlah_nilai_semester_6' do - @score_utbk.jumlah_nilai_semester_6 = -12 + @score_utbk.jumlah_nilai_semester6 = -12 assert_not @score_utbk.valid? - @score_utbk.jumlah_nilai_semester_6 = 3000 + @score_utbk.jumlah_nilai_semester6 = 3000 assert_not @score_utbk.valid? - @score_utbk.jumlah_nilai_semester_6 = 'abs' + @score_utbk.jumlah_nilai_semester6 = 'abs' assert_not @score_utbk.valid? end test 'should reject for invalid jumlah pelajaran semester 6' do - @score_utbk.jumlah_pelajaran_semester_6 = -1 + @score_utbk.jumlah_pelajaran_semester6 = -1 assert_not @score_utbk.valid? - @score_utbk.jumlah_pelajaran_semester_6 = 101 + @score_utbk.jumlah_pelajaran_semester6 = 101 assert_not @score_utbk.valid? - @score_utbk.jumlah_pelajaran_semester_6 = 'abs' + @score_utbk.jumlah_pelajaran_semester6 = 'abs' assert_not @score_utbk.valid? end test 'should reject for invalid nilai_penalaran_umum ' do @@ -86,7 +86,7 @@ def setup assert_equal 179.5, utbk_scores(:utbk_score_one).reload.nilai_penalaran_umum end test 'should reject jumlah matapelajaran un for non integer' do - @score_utbk.jumlah_pelajaran_semester_6 = 90.98 + @score_utbk.jumlah_pelajaran_semester6 = 90.98 assert_not @score_utbk.valid? end end