-
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.
- Loading branch information
1 parent
694a0e3
commit 865bc1c
Showing
11 changed files
with
193 additions
and
55 deletions.
There are no files selected for viewing
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,16 +1,40 @@ | ||
class UtbkScoresController < ApplicationController | ||
def new | ||
@utbk_score = current_user.build_utbk_score | ||
end | ||
|
||
def update | ||
@utbk_score = current_user.utbk_score | ||
if @utbk_score.update(utbk_score_params) | ||
flash[:success] = " utbk score is updated" | ||
else | ||
render 'edit' | ||
end | ||
end | ||
|
||
def create | ||
@utbk_score = current_user.build_utbk_score(utbk_score_params) | ||
if @utbk_score.save | ||
flash[:success] = "utbk score is saved" | ||
else | ||
render 'new' | ||
end | ||
end | ||
|
||
def edit | ||
@utbk_score = current_user.utbk_score | ||
end | ||
|
||
def show | ||
end | ||
private | ||
def utbk_score_params | ||
params.require(:utbk_score).permit(:no_peserta, :tanggal_ujian, | ||
:jumlah_nilai_semester_6, | ||
:jumlah_pelajaran_semester_6, | ||
:nilai_penalaran_umum, | ||
:nilai_pengetahuan_kuantitatif, | ||
:nilai_kemampuan_memahami_bacaan_dan_menulis, | ||
:nilai_pengetahuan_dan_pemahaman_umum) | ||
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,3 +1,16 @@ | ||
class UtbkScore < ApplicationRecord | ||
belongs_to :user | ||
validates :no_peserta, presence: true, | ||
length: {minimum: 4, maximum: 30} | ||
validates :tanggal_ujian, presence: true, length:{ minimum: 4, maximum: 10} | ||
validates :nilai_penalaran_umum, | ||
:nilai_pengetahuan_dan_pemahaman_umum, | ||
:nilai_pengetahuan_kuantitatif, | ||
: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, presence: true, numericality: {only_integer: false, | ||
greater_than_or_equal_to: 2, less_than_or_equal_to: 2000} | ||
validates :jumlah_pelajaran_semester_6, presence: true, numericality: {only_integer: true, | ||
greater_than_or_equal_to: 2, less_than_or_equal_to: 100} | ||
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,28 +1,36 @@ | ||
require "test_helper" | ||
|
||
class UtbkScoresControllerTest < ActionDispatch::IntegrationTest | ||
test "should get new" do | ||
get utbk_scores_new_url | ||
assert_response :success | ||
end | ||
|
||
test "should get update" do | ||
get utbk_scores_update_url | ||
assert_response :success | ||
def setup | ||
get login_path | ||
post login_path, params: {session: { | ||
email: users(:michael).email, password: 'password' | ||
}} | ||
end | ||
|
||
test "should get create" do | ||
get utbk_scores_create_url | ||
test "should get new" do | ||
assert is_logged_in? | ||
get new_utbk_score_url | ||
assert_response :success | ||
end | ||
|
||
# test "should get update" do | ||
# get utbk_scores_update_url | ||
# assert_response :success | ||
# end | ||
# | ||
# test "should get create" do | ||
# get utbk_scores_create_url | ||
# assert_response :success | ||
# end | ||
# | ||
test "should get edit" do | ||
get utbk_scores_edit_url | ||
assert_response :success | ||
end | ||
|
||
test "should get show" do | ||
get utbk_scores_show_url | ||
assert is_logged_in? | ||
get edit_utbk_score_url(utbk_scores(:utbk_score_two)) | ||
assert_response :success | ||
end | ||
# | ||
# test "should get show" do | ||
# get utbk_scores_show_url | ||
# assert_response :success | ||
# 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,7 +1,7 @@ | ||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html | ||
|
||
one: | ||
matematika_semester_1: MyString | ||
#one: | ||
# matematika_semester_1: MyString | ||
|
||
two: | ||
matematika_semester_1: MyString | ||
#two: | ||
# matematika_semester_1: MyString |
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,13 +1,13 @@ | ||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html | ||
|
||
one: | ||
asal_sekolah: MyString | ||
akreditas: MyString | ||
jumlah_pelajaran_un: MyString | ||
jumlah_nilai_un: MyString | ||
#one: | ||
# asal_sekolah: MyString | ||
# akreditas: MyString | ||
# jumlah_pelajaran_un: MyString | ||
# jumlah_nilai_un: MyString | ||
|
||
two: | ||
asal_sekolah: MyString | ||
akreditas: MyString | ||
jumlah_pelajaran_un: MyString | ||
jumlah_nilai_un: MyString | ||
#two: | ||
# asal_sekolah: MyString | ||
# akreditas: MyString | ||
# jumlah_pelajaran_un: MyString | ||
# jumlah_nilai_un: MyString |
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,7 +1,7 @@ | ||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html | ||
|
||
one: | ||
sekolah: MyString | ||
#one: | ||
# sekolah: MyString | ||
|
||
two: | ||
sekolah: MyString | ||
#two: | ||
# sekolah: MyString |
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,7 +1,7 @@ | ||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html | ||
|
||
one: | ||
jumlah_nilai_semester_1: MyString | ||
#one: | ||
# jumlah_nilai_semester_1: MyString | ||
|
||
two: | ||
jumlah_nilai_semester_1: MyString | ||
#two: | ||
# jumlah_nilai_semester_1: MyString |
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,13 +1,13 @@ | ||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html | ||
|
||
one: | ||
asal_sekolah: MyString | ||
akreditas: MyString | ||
jumlah_pelajaran_un: MyString | ||
jumlah_nilai_un: MyString | ||
#one: | ||
# asal_sekolah: MyString | ||
# akreditas: MyString | ||
# jumlah_pelajaran_un: MyString | ||
# jumlah_nilai_un: MyString | ||
|
||
two: | ||
asal_sekolah: MyString | ||
akreditas: MyString | ||
jumlah_pelajaran_un: MyString | ||
jumlah_nilai_un: MyString | ||
#two: | ||
# asal_sekolah: MyString | ||
# akreditas: MyString | ||
# jumlah_pelajaran_un: MyString | ||
# jumlah_nilai_un: MyString |
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,9 +1,14 @@ | ||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html | ||
|
||
one: | ||
utbk_score_one: | ||
user: archer | ||
no_peserta: MyString | ||
tanggal_ujian: 2024-01-25 | ||
nilai_penalaran_umum: 179.5 | ||
|
||
two: | ||
utbk_score_two: | ||
user: iana | ||
no_peserta: MyString | ||
tanggal_ujian: 2024-01-25 | ||
nilai_penalaran_umum: 189.5 | ||
|
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,7 +1,95 @@ | ||
require "test_helper" | ||
|
||
class UtbkScoreTest < ActiveSupport::TestCase | ||
# test "the truth" do | ||
# assert true | ||
# end | ||
def setup | ||
@score_utbk = UtbkScore.create!(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, | ||
nilai_penalaran_umum: 120.5, | ||
nilai_pengetahuan_kuantitatif: 150.5, | ||
nilai_kemampuan_memahami_bacaan_dan_menulis: 300.5, | ||
nilai_pengetahuan_dan_pemahaman_umum: 250.5) | ||
end | ||
test "should valid utbk score" do | ||
assert_not_nil UtbkScore.find_by_jumlah_nilai_semester_6 1200.5 | ||
assert_not_nil UtbkScore.find_by_nilai_penalaran_umum 120.5 | ||
assert_not_nil UtbkScore.find_by_nilai_pengetahuan_kuantitatif 150.5 | ||
assert_not_nil UtbkScore.find_by_nilai_pengetahuan_dan_pemahaman_umum 250.5 | ||
assert_not_nil UtbkScore.find_by_nilai_kemampuan_memahami_bacaan_dan_menulis 300.5 | ||
assert @score_utbk.valid? | ||
end | ||
test "should reject invalid no_peserta" do | ||
@score_utbk.no_peserta =' ' | ||
assert_not @score_utbk.valid? | ||
@score_utbk.no_peserta = 'a'*3 | ||
assert_not @score_utbk.valid? | ||
@score_utbk.no_peserta = 'a' * 31 | ||
assert_not @score_utbk.valid? | ||
end | ||
test "should reject invalid tanggal" do | ||
@score_utbk.tanggal_ujian = ' ' | ||
assert_not @score_utbk.valid? | ||
@score_utbk.tanggal_ujian = '20000-290-90' | ||
assert_not @score_utbk.valid? | ||
@score_utbk.tanggal_ujian = '201' | ||
assert_not @score_utbk.valid? | ||
end | ||
test "should reject invalid jumlah_nilai_semester_6" do | ||
@score_utbk.jumlah_nilai_semester_6 = -12 | ||
assert_not @score_utbk.valid? | ||
@score_utbk.jumlah_nilai_semester_6 = 3000 | ||
assert_not @score_utbk.valid? | ||
@score_utbk.jumlah_nilai_semester_6 = 'abs' | ||
assert_not @score_utbk.valid? | ||
end | ||
test "should reject for invalid jumlah pelajaran semester 6" do | ||
@score_utbk.jumlah_pelajaran_semester_6 = -1 | ||
assert_not @score_utbk.valid? | ||
@score_utbk.jumlah_pelajaran_semester_6 = 101 | ||
assert_not @score_utbk.valid? | ||
@score_utbk.jumlah_pelajaran_semester_6 = 'abs' | ||
assert_not @score_utbk.valid? | ||
end | ||
test "should reject for invalid nilai_penalaran_umum " do | ||
@score_utbk.nilai_penalaran_umum = -1 | ||
assert_not @score_utbk.valid? | ||
@score_utbk.nilai_penalaran_umum = 2001 | ||
assert_not @score_utbk.valid? | ||
@score_utbk.nilai_penalaran_umum = 'abs' | ||
assert_not @score_utbk.valid? | ||
end | ||
test "should reject for invalid nilai_pengetahuan_kuantitatif " do | ||
@score_utbk.nilai_pengetahuan_kuantitatif = -1 | ||
assert_not @score_utbk.valid? | ||
@score_utbk.nilai_pengetahuan_kuantitatif = 2001 | ||
assert_not @score_utbk.valid? | ||
@score_utbk.nilai_pengetahuan_kuantitatif = 'abs' | ||
assert_not @score_utbk.valid? | ||
end | ||
test "should reject for invalid nilai_kemampuan_memahami_bacaan_dan_menulis " do | ||
@score_utbk.nilai_kemampuan_memahami_bacaan_dan_menulis = -1 | ||
assert_not @score_utbk.valid? | ||
@score_utbk.nilai_kemampuan_memahami_bacaan_dan_menulis = 2001 | ||
assert_not @score_utbk.valid? | ||
@score_utbk.nilai_kemampuan_memahami_bacaan_dan_menulis = 'abs' | ||
assert_not @score_utbk.valid? | ||
end | ||
test "should reject for invalid nilai_pengetahuan_dan_pemahaman_umum " do | ||
@score_utbk.nilai_pengetahuan_dan_pemahaman_umum = -1 | ||
assert_not @score_utbk.valid? | ||
@score_utbk.nilai_pengetahuan_dan_pemahaman_umum = 2001 | ||
assert_not @score_utbk.valid? | ||
@score_utbk.nilai_pengetahuan_dan_pemahaman_umum = 'abs' | ||
assert_not @score_utbk.valid? | ||
end | ||
test "should accept decimal point to utbk score" do | ||
@score_utbk.nilai_penalaran_umum = 149.98 | ||
assert @score_utbk.valid? | ||
assert_equal 149.98, @score_utbk.nilai_penalaran_umum | ||
assert_equal 189.5, utbk_scores(:utbk_score_two).reload.nilai_penalaran_umum | ||
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 | ||
assert_not @score_utbk.valid? | ||
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