Commit 8eaac9ba authored by Brett Walker's avatar Brett Walker

Address review comments

just small style changes and sanitizing a parameter
parent aecb4ef6
......@@ -241,8 +241,9 @@ class IssuableBaseService < BaseService
filter_params(issuable)
if issuable.changed? || params.present?
issuable.assign_attributes(params.merge(updated_by: current_user))
issuable.assign_attributes(last_edited_at: Time.now, last_edited_by: current_user)
issuable.assign_attributes(params.merge(updated_by: current_user,
last_edited_at: Time.now,
last_edited_by: current_user))
before_update(issuable)
......@@ -270,12 +271,16 @@ class IssuableBaseService < BaseService
tasklist_toggler = TaskListToggleService.new(issuable.description, issuable.description_html,
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],
index: update_task_params[:index],
index: update_task_params[:index].to_i,
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,
# the markdown cache won't be considered invalid
params[:description] = tasklist_toggler.updated_markdown
......@@ -287,10 +292,6 @@ class IssuableBaseService < BaseService
params[:lock_version] = issuable.lock_version
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
def labels_changing?(old_label_ids, new_label_ids)
......
......@@ -23,7 +23,7 @@ class TaskListToggleService
def execute
return false unless markdown && markdown_html
!!(toggle_markdown && toggle_markdown_html)
toggle_markdown && toggle_markdown_html
end
private
......
......@@ -133,7 +133,7 @@ describe CacheMarkdownField do
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
expect(thing).not_to receive(:refresh_markdown_cache)
thing.foo = '_look over there!_'
......
......@@ -3,7 +3,6 @@
require 'spec_helper'
describe TaskListToggleService do
context 'when ' do
let(:sourcepos) { true }
let(:markdown) do
<<-EOT.strip_heredoc
......@@ -124,5 +123,4 @@ describe TaskListToggleService do
it_behaves_like 'task lists'
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