2019-03-30 03:23:56 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-04-22 08:09:29 -04:00
|
|
|
require 'spec_helper'
|
2013-03-03 22:43:52 -05:00
|
|
|
|
2020-06-24 14:09:03 -04:00
|
|
|
RSpec.describe ProjectWiki do
|
2020-04-22 08:09:29 -04:00
|
|
|
it_behaves_like 'wiki model' do
|
|
|
|
let(:wiki_container) { create(:project, :wiki_repo, namespace: user.namespace) }
|
|
|
|
let(:wiki_container_without_repo) { create(:project, namespace: user.namespace) }
|
2020-10-05 11:08:56 -04:00
|
|
|
let(:wiki_lfs_enabled) { true }
|
2013-03-03 22:43:52 -05:00
|
|
|
|
2020-04-22 08:09:29 -04:00
|
|
|
it { is_expected.to delegate_method(:storage).to(:container) }
|
|
|
|
it { is_expected.to delegate_method(:repository_storage).to(:container) }
|
|
|
|
it { is_expected.to delegate_method(:hashed_storage?).to(:container) }
|
2017-06-14 14:18:56 -04:00
|
|
|
|
2020-04-22 08:09:29 -04:00
|
|
|
describe '#disk_path' do
|
|
|
|
it 'returns the repository storage path' do
|
|
|
|
expect(subject.disk_path).to eq("#{subject.container.disk_path}.wiki")
|
2018-11-20 07:29:56 -05:00
|
|
|
end
|
2013-03-03 22:43:52 -05:00
|
|
|
end
|
2018-03-26 05:16:01 -04:00
|
|
|
|
2020-09-09 17:08:33 -04:00
|
|
|
describe '#after_wiki_activity' do
|
2020-04-22 08:09:29 -04:00
|
|
|
it 'updates project activity' do
|
|
|
|
wiki_container.update!(
|
|
|
|
last_activity_at: nil,
|
|
|
|
last_repository_updated_at: nil
|
|
|
|
)
|
2017-10-23 16:12:11 -04:00
|
|
|
|
2020-09-09 17:08:33 -04:00
|
|
|
subject.send(:after_wiki_activity)
|
2020-04-22 08:09:29 -04:00
|
|
|
wiki_container.reload
|
2018-04-11 10:08:23 -04:00
|
|
|
|
2020-05-22 05:08:09 -04:00
|
|
|
expect(wiki_container.last_activity_at).to be_within(1.minute).of(Time.current)
|
|
|
|
expect(wiki_container.last_repository_updated_at).to be_within(1.minute).of(Time.current)
|
2018-11-20 05:36:52 -05:00
|
|
|
end
|
2018-11-20 07:29:56 -05:00
|
|
|
end
|
2020-09-09 17:08:33 -04:00
|
|
|
|
|
|
|
describe '#after_post_receive' do
|
|
|
|
it 'updates project activity and expires caches' do
|
|
|
|
expect(wiki).to receive(:after_wiki_activity)
|
|
|
|
expect(ProjectCacheWorker).to receive(:perform_async).with(wiki_container.id, [], [:wiki_size])
|
|
|
|
|
|
|
|
subject.send(:after_post_receive)
|
|
|
|
end
|
|
|
|
end
|
2014-07-31 12:24:53 -04:00
|
|
|
end
|
2013-03-03 22:43:52 -05:00
|
|
|
end
|