diff --git a/test/models/workflow_test.rb b/test/models/workflow_test.rb index 449b387fe..8a0631c3d 100644 --- a/test/models/workflow_test.rb +++ b/test/models/workflow_test.rb @@ -1,4 +1,5 @@ require "test_helper" +require "minitest/autorun" class WorkflowTest < ActiveSupport::TestCase def setup @@ -521,4 +522,19 @@ def template_user_and_published_transaction assert_equal "schedule_for_publishing", edition.actions.last.request_type end end + + context "#publish" do + setup do + @user = FactoryBot.create(:user, :govuk_editor) + end + + should "not be in published state if the transition fails" do + edition = FactoryBot.create(:edition, state: "ready") + raise_exception = -> { raise ArgumentError.new } + edition.stub :was_published, raise_exception do + assert_raises(ArgumentError) { publish(@user, edition, "this should fail") } + end + assert_equal "ready", edition.state + end + end end