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

44 lines
1 KiB
Ruby
Raw Normal View History

2019-07-31 22:56:46 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
require 'spec_helper'
2017-09-10 17:25:29 +05:30
describe WikiPages::UpdateService 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
let(:page) { create(:wiki_page) }
2017-08-17 22:00:37 +05:30
let(:opts) do
{
content: 'New content for wiki page',
format: 'markdown',
2017-09-10 17:25:29 +05:30
message: 'New wiki message',
title: 'New Title'
2017-08-17 22:00:37 +05:30
}
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 '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])
end
it 'executes webhooks' do
expect(service).to receive(:execute_hooks).once
.with(instance_of(WikiPage), 'update')
service.execute(page)
2017-08-17 22:00:37 +05:30
end
end
end