2016-09-13 17:45:13 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe MergeRequests::MergeRequestDiffCacheService do
|
2017-08-17 22:00:37 +05:30
|
|
|
let(:subject) { described_class.new }
|
2016-09-13 17:45:13 +05:30
|
|
|
|
|
|
|
describe '#execute' do
|
|
|
|
it 'retrieves the diff files to cache the highlighted result' do
|
|
|
|
merge_request = create(:merge_request)
|
2016-09-29 09:46:39 +05:30
|
|
|
cache_key = [merge_request.merge_request_diff, 'highlighted-diff-files', Gitlab::Diff::FileCollection::MergeRequestDiff.default_options]
|
2016-09-13 17:45:13 +05:30
|
|
|
|
|
|
|
expect(Rails.cache).to receive(:read).with(cache_key).and_return({})
|
|
|
|
expect(Rails.cache).to receive(:write).with(cache_key, anything)
|
2017-09-10 17:25:29 +05:30
|
|
|
allow_any_instance_of(Gitlab::Diff::File).to receive(:text?).and_return(true)
|
|
|
|
allow_any_instance_of(Gitlab::Diff::File).to receive(:diffable?).and_return(true)
|
2016-09-13 17:45:13 +05:30
|
|
|
|
|
|
|
subject.execute(merge_request)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|