Skip to content

Commit

Permalink
test(workflow) assert that edition state is still ready when publish …
Browse files Browse the repository at this point in the history
…transition fails
  • Loading branch information
FelixMarcusMillne committed Aug 21, 2023
1 parent b5abfbf commit 2e98cc7
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/models/workflow_test.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require "test_helper"
require "minitest/autorun"

class WorkflowTest < ActiveSupport::TestCase
def setup
Expand Down Expand Up @@ -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

0 comments on commit 2e98cc7

Please sign in to comment.