File: wikis_spec.rb

package info (click to toggle)
ruby-gitlab 5.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,660 kB
  • sloc: ruby: 12,582; makefile: 7; sh: 4
file content (79 lines) | stat: -rw-r--r-- 1,986 bytes parent folder | download
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::Client do
  describe '.wikis' do
    before do
      stub_get('/projects/1/wikis', 'wikis')
      @wikis = Gitlab.wikis(1)
    end

    it 'gets the correct resource' do
      expect(a_get('/projects/1/wikis')).to have_been_made
    end

    it "returns a response of a project's wikis" do
      expect(@wikis).to be_a Gitlab::PaginatedResponse
    end
  end

  describe '.wiki' do
    before do
      stub_get('/projects/1/wikis/home', 'wiki')
      @wiki = Gitlab.wiki(1, 'home')
    end

    it 'gets the correct resource' do
      expect(a_get('/projects/1/wikis/home')).to have_been_made
    end

    it 'returns correct information about the wiki' do
      expect(@wiki.slug).to eq 'home'
    end
  end

  describe '.create_wiki' do
    before do
      stub_post('/projects/1/wikis', 'wiki')
      @wiki = Gitlab.create_wiki(1, 'home', 'home page')
    end

    it 'gets the correct resource' do
      expect(a_post('/projects/1/wikis')
        .with(body: { content: 'home page', title: 'home' })).to have_been_made
    end

    it 'returns correct information about the created wiki' do
      expect(@wiki.content).to eq 'home page'
      expect(@wiki.title).to eq 'home'
    end
  end

  describe '.update_wiki' do
    before do
      stub_put('/projects/1/wikis/home', 'wiki')
      @wiki = Gitlab.update_wiki(1, 'home', format: 'markdown')
    end

    it 'gets the correct resource' do
      expect(a_put('/projects/1/wikis/home')
        .with(body: { format: 'markdown' })).to have_been_made
    end

    it 'returns correct information about the updated wiki' do
      expect(@wiki.format).to eq 'markdown'
    end
  end

  describe '.delete_wiki' do
    before do
      stub_delete('/projects/1/wikis/home', 'empty')
      @wiki = Gitlab.delete_wiki(1, 'home')
    end

    it 'gets the correct resource' do
      expect(a_delete('/projects/1/wikis/home')).to have_been_made
    end
  end
end