debian-mirror-gitlab/spec/services/wiki_pages/create_service_spec.rb

39 lines
835 B
Ruby
Raw Normal View History

2017-08-17 22:00:37 +05:30
require 'spec_helper'
2017-09-10 17:25:29 +05:30
describe WikiPages::CreateService do
let(:project) { create(:project) }
2017-08-17 22:00:37 +05:30
let(:user) { create(:user) }
2017-09-10 17:25:29 +05:30
2017-08-17 22:00:37 +05:30
let(:opts) do
{
title: 'Title',
content: 'Content for wiki page',
format: 'markdown'
}
end
2017-09-10 17:25:29 +05:30
subject(:service) { described_class.new(project, user, opts) }
before do
project.add_developer(user)
end
2017-08-17 22:00:37 +05:30
describe '#execute' do
2017-09-10 17:25:29 +05:30
it 'creates wiki page with valid attributes' do
page = service.execute
expect(page).to be_valid
expect(page.title).to eq(opts[:title])
expect(page.content).to eq(opts[:content])
expect(page.format).to eq(opts[:format].to_sym)
end
it 'executes webhooks' do
expect(service).to receive(:execute_hooks).once
.with(instance_of(WikiPage), 'create')
service.execute
2017-08-17 22:00:37 +05:30
end
end
end