Welcome to mirror list, hosted at ThFree Co, Russian Federation.

project_wiki_spec.rb « models « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2e82fcf5511fafbaaf30d78488145313b357349d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe ProjectWiki do
  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) }
    let(:wiki_lfs_enabled) { true }

    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) }

    describe '#disk_path' do
      it 'returns the repository storage path' do
        expect(subject.disk_path).to eq("#{subject.container.disk_path}.wiki")
      end
    end

    describe '#after_wiki_activity' do
      it 'updates project activity' do
        wiki_container.update!(
          last_activity_at: nil,
          last_repository_updated_at: nil
        )

        subject.send(:after_wiki_activity)
        wiki_container.reload

        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)
      end
    end

    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
  end
end