2016-12-20 13:31:21 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-07-10 14:24:02 +00:00
|
|
|
describe WikiPages::UpdateService do
|
2016-12-20 13:31:21 +00:00
|
|
|
let(:project) { create(:empty_project) }
|
|
|
|
let(:user) { create(:user) }
|
2017-06-01 19:27:52 +00:00
|
|
|
let(:page) { create(:wiki_page) }
|
|
|
|
|
2016-12-20 13:31:21 +00:00
|
|
|
let(:opts) do
|
|
|
|
{
|
|
|
|
content: 'New content for wiki page',
|
|
|
|
format: 'markdown',
|
|
|
|
message: 'New wiki message'
|
|
|
|
}
|
|
|
|
end
|
2017-06-01 19:27:52 +00:00
|
|
|
|
|
|
|
subject(:service) { described_class.new(project, user, opts) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
project.add_developer(user)
|
|
|
|
end
|
2016-12-20 13:31:21 +00:00
|
|
|
|
|
|
|
describe '#execute' do
|
2017-06-01 19:27:52 +00: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)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'executes webhooks' do
|
|
|
|
expect(service).to receive(:execute_hooks).once
|
|
|
|
.with(instance_of(WikiPage), 'update')
|
|
|
|
|
|
|
|
service.execute(page)
|
2016-12-20 13:31:21 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|