debian-mirror-gitlab/spec/lib/gitlab/data_builder/wiki_page_spec.rb

25 lines
1 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2017-09-10 17:25:29 +05:30
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe Gitlab::DataBuilder::WikiPage do
2020-04-08 14:13:33 +05:30
let_it_be(:project) { create(:project, :repository, :wiki_repo) }
2021-09-04 01:27:46 +05:30
let_it_be(:wiki_page) { create(:wiki_page, wiki: project.wiki) }
let_it_be(:user) { create(:user) }
2017-09-10 17:25:29 +05:30
describe '.build' do
let(:data) { described_class.build(wiki_page, user, 'create') }
it { expect(data).to be_a(Hash) }
it { expect(data[:object_kind]).to eq('wiki_page') }
it { expect(data[:user]).to eq(user.hook_attrs) }
it { expect(data[:project]).to eq(project.hook_attrs) }
it { expect(data[:wiki]).to eq(project.wiki.hook_attrs) }
it { expect(data[:object_attributes]).to include(wiki_page.hook_attrs) }
it { expect(data[:object_attributes]).to include(url: Gitlab::UrlBuilder.build(wiki_page)) }
it { expect(data[:object_attributes]).to include(action: 'create') }
2021-09-04 01:27:46 +05:30
it { expect(data[:object_attributes]).to include(diff_url: Gitlab::UrlBuilder.build(wiki_page, action: :diff, version_id: wiki_page.version.id)) }
2017-09-10 17:25:29 +05:30
end
end