Commit 4d8f719c authored by Lee Tickett's avatar Lee Tickett

Imrpove model validation when adding spent time

We recently added support for setting timelog summary using the
API, but the validation error simply statse `invalid`. This MR
ensures the parent issuable validation error details the child
(timelog) error messsage e.g. timelog.summary: is too long
(maximum is 255 characters).

Changelog: changed
parent 0902a6f8
......@@ -20,7 +20,7 @@ module TimeTrackable
validates :time_estimate, numericality: { message: 'has an invalid format' }, allow_nil: false
validate :check_negative_time_spent
has_many :timelogs, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
has_many :timelogs, dependent: :destroy, autosave: true # rubocop:disable Cop/ActiveRecordDependent
end
# rubocop:disable Gitlab/ModuleWithInstanceVariables
......
......@@ -31,6 +31,7 @@ RSpec.describe Issue do
it { is_expected.to have_and_belong_to_many(:self_managed_prometheus_alert_events) }
it { is_expected.to have_many(:prometheus_alerts) }
it { is_expected.to have_many(:issue_email_participants) }
it { is_expected.to have_many(:timelogs).autosave(true) }
describe 'versions.most_recent' do
it 'returns the most recent version' do
......
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