Skip to content
This repository has been archived by the owner on Jun 16, 2021. It is now read-only.

Commit

Permalink
Eksik validasyon ve testi ekle
Browse files Browse the repository at this point in the history
  • Loading branch information
dilara committed Nov 14, 2018
1 parent 94dfca4 commit cab8953
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/available_course_lecturer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class AvailableCourseLecturer < ApplicationRecord
belongs_to :lecturer, class_name: 'Employee'

# validations
validates :coordinator, inclusion: { in: [true, false] }
validates :coordinator, presence: true, inclusion: { in: [true, false] }

# scopes
scope :coordinator, -> { where(coordinator: true) }
Expand Down
7 changes: 7 additions & 0 deletions test/models/course/available_course_lecturer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ class AvailableCourseLecturerTest < ActiveSupport::TestCase
end
end

# validations: presence
test 'should not save available_course_group without coordinator info' do
available_course_lecturers(:ati_group_1_lecturer_john).coordinator = nil
assert_not available_course_lecturers(:ati_group_1_lecturer_john).valid?
assert_not_empty available_course_lecturers(:ati_group_1_lecturer_john).errors[:coordinator]
end

# scopes
test 'coordinator scope returns coordinator lecturers' do
lecturers = available_course_groups(:ati_group_1).lecturers
Expand Down

0 comments on commit cab8953

Please sign in to comment.