Commit d6a60e68 authored by Kaspar Vollenweider's avatar Kaspar Vollenweider Committed by Kaspar
Browse files

feedbacks have now required comments and a model test for it

parent 69d25d41
......@@ -5,6 +5,8 @@ class Feedback < ApplicationRecord
belongs_to :author, class_name: 'User'
belongs_to :feedbackable, polymorphic: true, optional: true
validates :comments, presence: true
def assignment?
feedbackable_type == 'Assignment'
end
......
require 'test_helper'
class FeedbackTest < ActiveSupport::TestCase
test 'feedback is valid' do
feedback = build :feedback
assert feedback.valid?
end
test 'feedback with no comments is invalid' do
volunteer = create :volunteer, user: create(:user_volunteer)
invalid_feedback = Feedback.new(volunteer: volunteer, author: volunteer.user)
refute invalid_feedback.valid?
assert_equal ["can't be blank"], invalid_feedback.errors.messages[:comments]
end
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment