diff --git a/app/commands/v2/unpublish.rb b/app/commands/v2/unpublish.rb index f0947692c..7cfb7414c 100644 --- a/app/commands/v2/unpublish.rb +++ b/app/commands/v2/unpublish.rb @@ -3,7 +3,7 @@ module V2 class Unpublish < BaseCommand def call validate - previous_item.update_attributes!(state: 'superseded') if previous_item + previous_item.supersede if previous_item transition_state after_transaction_commit do diff --git a/spec/commands/v2/unpublish_spec.rb b/spec/commands/v2/unpublish_spec.rb index 785b66ae1..b98081968 100644 --- a/spec/commands/v2/unpublish_spec.rb +++ b/spec/commands/v2/unpublish_spec.rb @@ -261,15 +261,18 @@ context "when the system is in an inconsistent state" do let!(:published_item) do - FactoryGirl.create(:live_content_item, + FactoryGirl.create(:superseded_content_item, content_id: content_id, base_path: "/different", user_facing_version: 2, - state: "superseded", ) end before do - published_item.update_columns(state: "published", base_path: base_path) + published_item.update_columns( + state: "published", + content_store: "live", + base_path: base_path + ) end it "raises an error stating the inconsistency" do