2021-08-04 16:29:09 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
RSpec.describe LegacyDiffNote do
|
|
|
|
describe '#to_ability_name' do
|
|
|
|
subject { described_class.new.to_ability_name }
|
|
|
|
|
|
|
|
it { is_expected.to eq('note') }
|
|
|
|
end
|
2021-11-18 22:05:49 +05:30
|
|
|
|
|
|
|
describe 'callbacks' do
|
|
|
|
describe '#set_diff' do
|
|
|
|
let(:note) do
|
|
|
|
build(:legacy_diff_note_on_merge_request, st_diff: '_st_diff_').tap do |record|
|
|
|
|
record.instance_variable_set(:@diff, {})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when not importing' do
|
|
|
|
it 'updates st_diff' do
|
|
|
|
note.save!(validate: false)
|
|
|
|
|
|
|
|
expect(note.st_diff).to eq({})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when importing' do
|
|
|
|
before do
|
|
|
|
note.importing = true
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not update st_diff' do
|
|
|
|
note.save!(validate: false)
|
|
|
|
|
|
|
|
expect(note.st_diff).to eq('_st_diff_')
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when st_diff is blank' do
|
|
|
|
before do
|
|
|
|
note.st_diff = nil
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'updates st_diff' do
|
|
|
|
note.save!(validate: false)
|
|
|
|
|
|
|
|
expect(note.st_diff).to eq({})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2021-08-04 16:29:09 +05:30
|
|
|
end
|