gitlab-org--gitlab-foss/spec/services/wiki_pages/update_service_spec.rb

42 lines
1,005 B
Ruby
Raw Normal View History

require 'spec_helper'
describe WikiPages::UpdateService do
let(:project) { create(:project) }
let(:user) { create(:user) }
2017-06-01 15:27:52 -04:00
let(:page) { create(:wiki_page) }
let(:opts) do
{
content: 'New content for wiki page',
format: 'markdown',
message: 'New wiki message',
title: 'New Title'
}
end
2017-06-01 15:27:52 -04:00
subject(:service) { described_class.new(project, user, opts) }
before do
project.add_developer(user)
end
describe '#execute' do
2017-06-01 15:27:52 -04:00
it 'updates the wiki page' do
updated_page = service.execute(page)
expect(updated_page).to be_valid
expect(updated_page.message).to eq(opts[:message])
expect(updated_page.content).to eq(opts[:content])
expect(updated_page.format).to eq(opts[:format].to_sym)
expect(updated_page.title).to eq(opts[:title])
2017-06-01 15:27:52 -04:00
end
it 'executes webhooks' do
expect(service).to receive(:execute_hooks).once
.with(instance_of(WikiPage), 'update')
service.execute(page)
end
end
end