gitlab-org--gitlab-foss/spec/services/wiki_pages/create_service_spec.rb
Mark Fletcher a616b475b1 Add tests for WikiPages services
* Alter wiki_pages factory with custom creation operation
2017-02-14 11:16:34 +05:30

36 lines
925 B
Ruby

require 'spec_helper'
describe WikiPages::CreateService, services: true do
let(:project) { create(:empty_project) }
let(:user) { create(:user) }
let(:opts) do
{
title: 'Title',
content: 'Content for wiki page',
format: 'markdown'
}
end
let(:service) { described_class.new(project, user, opts) }
describe '#execute' do
context "valid params" do
before do
allow(service).to receive(:execute_hooks)
project.add_master(user)
end
subject { service.execute }
it 'creates a valid wiki page' do
is_expected.to be_valid
expect(subject.title).to eq(opts[:title])
expect(subject.content).to eq(opts[:content])
expect(subject.format).to eq(opts[:format].to_sym)
end
it 'executes webhooks' do
expect(service).to have_received(:execute_hooks).once.with(subject, 'create')
end
end
end
end