Commit bb8fdcc1 authored by Brett Walker's avatar Brett Walker

Address review comments

parent 0e6c08f5
...@@ -239,8 +239,9 @@ class IssuableBaseService < BaseService ...@@ -239,8 +239,9 @@ class IssuableBaseService < BaseService
filter_params(issuable) filter_params(issuable)
if issuable.changed? || params.present? if issuable.changed? || params.present?
issuable.assign_attributes(params.merge(updated_by: current_user)) issuable.assign_attributes(params.merge(updated_by: current_user,
issuable.assign_attributes(last_edited_at: Time.now, last_edited_by: current_user) last_edited_at: Time.now,
last_edited_by: current_user))
before_update(issuable) before_update(issuable)
...@@ -268,12 +269,16 @@ class IssuableBaseService < BaseService ...@@ -268,12 +269,16 @@ class IssuableBaseService < BaseService
tasklist_toggler = TaskListToggleService.new(issuable.description, issuable.description_html, tasklist_toggler = TaskListToggleService.new(issuable.description, issuable.description_html,
line_source: update_task_params[:line_source], line_source: update_task_params[:line_source],
line_number: update_task_params[:line_number], line_number: update_task_params[:line_number].to_i,
toggle_as_checked: update_task_params[:checked], toggle_as_checked: update_task_params[:checked],
index: update_task_params[:index], index: update_task_params[:index].to_i,
sourcepos: !issuable.legacy_markdown?) sourcepos: !issuable.legacy_markdown?)
if tasklist_toggler.execute unless tasklist_toggler.execute
# if we make it here, the data is much newer than we thought it was - fail fast
raise ActiveRecord::StaleObjectError
end
# by updating the description_html field at the same time, # by updating the description_html field at the same time,
# the markdown cache won't be considered invalid # the markdown cache won't be considered invalid
params[:description] = tasklist_toggler.updated_markdown params[:description] = tasklist_toggler.updated_markdown
...@@ -285,10 +290,6 @@ class IssuableBaseService < BaseService ...@@ -285,10 +290,6 @@ class IssuableBaseService < BaseService
params[:lock_version] = issuable.lock_version params[:lock_version] = issuable.lock_version
update_task(issuable) update_task(issuable)
else
# if we make it here, the data is much newer than we thought it was - fail fast
raise ActiveRecord::StaleObjectError
end
end end
def labels_changing?(old_label_ids, new_label_ids) def labels_changing?(old_label_ids, new_label_ids)
......
...@@ -23,7 +23,7 @@ class TaskListToggleService ...@@ -23,7 +23,7 @@ class TaskListToggleService
def execute def execute
return false unless markdown && markdown_html return false unless markdown && markdown_html
!!(toggle_markdown && toggle_markdown_html) toggle_markdown && toggle_markdown_html
end end
private private
......
...@@ -133,7 +133,7 @@ describe CacheMarkdownField do ...@@ -133,7 +133,7 @@ describe CacheMarkdownField do
end end
end end
context 'when a markdown field and html field are both set' do context 'when a markdown field and html field are both changed' do
it do it do
expect(thing).not_to receive(:refresh_markdown_cache) expect(thing).not_to receive(:refresh_markdown_cache)
thing.foo = '_look over there!_' thing.foo = '_look over there!_'
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
require 'spec_helper' require 'spec_helper'
describe TaskListToggleService do describe TaskListToggleService do
context 'when ' do
let(:sourcepos) { true } let(:sourcepos) { true }
let(:markdown) do let(:markdown) do
<<-EOT.strip_heredoc <<-EOT.strip_heredoc
...@@ -124,5 +123,4 @@ describe TaskListToggleService do ...@@ -124,5 +123,4 @@ describe TaskListToggleService do
it_behaves_like 'task lists' it_behaves_like 'task lists'
end end
end
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