-
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 test: accreditation, all_sch, pmdk_sch
- Loading branch information
1 parent
9a2e506
commit 81cda93
Showing
10 changed files
with
110 additions
and
16 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,2 +1,5 @@ | ||
class AccreditationSchoolList < ApplicationRecord | ||
validates :akreditasi, presence: true, length: { | ||
minimum: 1, maximum: 15 | ||
}, 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,4 @@ | ||
class AllSchoolList < ApplicationRecord | ||
validates :sekolah, presence: true, | ||
length: {minimum: 5, maximum: 35}, 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,4 @@ | ||
class PmdkSchoolList < ApplicationRecord | ||
validates :sekolah, presence: true, | ||
length: {minimum: 5, maximum: 35}, uniqueness: true | ||
end |
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
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
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
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,22 @@ | ||
require "test_helper" | ||
|
||
class AccreditationSchoolListTest < ActiveSupport::TestCase | ||
# test "the truth" do | ||
# assert true | ||
# end | ||
def setup | ||
@accreditation = AccreditationSchoolList.new(akreditasi: 'A') | ||
end | ||
test "should accept for valid accreditation" do | ||
assert @accreditation.valid? | ||
end | ||
test "should reject for empty accreditation" do | ||
@accreditation.akreditasi = '' | ||
assert_not @accreditation.valid? | ||
end | ||
test "should reject for too long accreditation " do | ||
@accreditation.akreditasi ='a'*16 | ||
assert_not @accreditation.valid? | ||
end | ||
test "should reject for non unique accreditation" do | ||
@accreditation.akreditasi = accreditation_school_lists(:one).akreditasi | ||
assert_not @accreditation.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,26 @@ | ||
require "test_helper" | ||
|
||
class AllSchoolListTest < ActiveSupport::TestCase | ||
# test "the truth" do | ||
# assert true | ||
# end | ||
def setup | ||
@all_school = AllSchoolList.new(sekolah: 'sma pelita') | ||
end | ||
test "should accept the right school" do | ||
assert @all_school.valid? | ||
end | ||
test "should reject for empty school list" do | ||
@all_school.sekolah = '' | ||
assert_not @all_school.valid? | ||
end | ||
test "should reject for too short school name" do | ||
@all_school.sekolah = 'a'*4 | ||
assert_not @all_school.valid? | ||
end | ||
test "should reject for too long school name" do | ||
@all_school.sekolah = 'a'*36 | ||
assert_not @all_school.valid? | ||
end | ||
test "should reject for non unique school name" do | ||
@all_school.sekolah = all_school_lists(:one).sekolah | ||
assert_not @all_school.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,26 @@ | ||
require "test_helper" | ||
|
||
class PmdkSchoolListTest < ActiveSupport::TestCase | ||
# test "the truth" do | ||
# assert true | ||
# end | ||
def setup | ||
@pmdk_school = PmdkSchoolList.new(sekolah: 'sma pelita') | ||
end | ||
test "should accept the right school" do | ||
assert @pmdk_school.valid? | ||
end | ||
test "should reject for empty school list" do | ||
@pmdk_school.sekolah = '' | ||
assert_not @pmdk_school.valid? | ||
end | ||
test "should reject for too short school name" do | ||
@pmdk_school.sekolah = 'a'*4 | ||
assert_not @pmdk_school.valid? | ||
end | ||
test "should reject for too long school name" do | ||
@pmdk_school.sekolah = 'a'*36 | ||
assert_not @pmdk_school.valid? | ||
end | ||
test "should reject for non unique school name" do | ||
@pmdk_school.sekolah = pmdk_school_lists(:one).sekolah | ||
assert_not @pmdk_school.valid? | ||
end | ||
end |