Commit ce33b660 authored by Peter Leitzen's avatar Peter Leitzen

Add shared example 'trigger status page publish'

parent 0ff9e429
# frozen_string_literal: true
RSpec.shared_context 'status page enabled' do
before do
project.add_maintainer(user)
stub_feature_flags(status_page: true)
stub_licensed_features(status_page: true)
unless project.status_page_setting
create(:status_page_setting, :enabled, project: project)
end
end
end
# frozen_string_literal: true
# This shared_example requires the following variables:
# - execute: Executes the service
# - issue_id: The issue id to be published
# - project: The project related to published issue
# - user: The user who triggers the publish
#
# Usage:
#
# include_examples 'trigger status page publish' do
# let(:execute) { service.execute }
# let(:issue_id) { execute.id }
# end
RSpec.shared_examples 'trigger status page publish' do
include_context 'status page enabled'
it 'triggers status page publish' do
allow(StatusPage::PublishWorker)
.to receive(:perform_async)
.with(user.id, project.id, kind_of(Integer))
execute
expect(StatusPage::PublishWorker)
.to have_received(:perform_async)
.with(user.id, project.id, issue_id)
end
end
# This shared_example requires the following variables:
# - execute: Executes the service
# - project: The project related to published issue
# - user: The user who triggers the publish
#
# Usage:
#
# include_examples 'no trigger status page publish' do
# let(:execute) { service.execute }
# end
RSpec.shared_examples 'no trigger status page publish' do
include_context 'status page enabled'
it 'does not trigger status page publish service' do
expect(StatusPage::PublishWorker).not_to receive(:perform_async)
execute
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment