Sha256: 7b5584f3fbae35565e97f6c4cbd36edee3f10d7ed87bc8e4bb63308d781ffae7

Contents?: true

Size: 1.71 KB

Versions: 17

Compression:

Stored size: 1.71 KB

Contents

require_relative "../test_helper"

class WorkflowActorTest < ActiveSupport::TestCase

  context "creating a new version of an edition" do
    setup do
      @user = User.new
      @user.stubs(:record_action)
      @edition = stub("AnswerEdition", :published? => true, :build_clone => :new_version)
    end

    should "return false if the edition is not published" do
      @edition.stubs(:published?).returns(false)
      @edition.expects(:build_clone).never
      @user.expects(:record_action).never
      assert_equal false, @user.new_version(@edition)
    end

    should "build a clone" do
      @edition.expects(:build_clone).with(nil).returns(:new_verison)
      @user.new_version(@edition)
    end

    should "record the action" do
      @user.expects(:record_action).with(:new_version, Action::NEW_VERSION)
      @user.new_version(@edition)
    end

    should "return the new edition" do
      assert_equal :new_version, @user.new_version(@edition)
    end

    context "creating an edition of a different type" do
      should "build a clone of a new type" do
        @edition.expects(:build_clone).with(GuideEdition).returns(:new_verison)
        @user.new_version(@edition, "GuideEdition")
      end

      should "record the action" do
        @user.expects(:record_action).with(:new_version, Action::NEW_VERSION)
        @user.new_version(@edition)
      end
    end

    context "when building the edition fails" do
      setup do
        @edition.stubs(:build_clone).returns(nil)
      end

      should "not record the action" do
        @user.expects(:record_action).never
        @user.new_version(@edition)
      end

      should "return false" do
        assert_equal false, @user.new_version(@edition)
      end
    end
  end

end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
govuk_content_models-8.1.0 test/models/workflow_actor_test.rb
govuk_content_models-8.0.0 test/models/workflow_actor_test.rb
govuk_content_models-7.3.1 test/models/workflow_actor_test.rb
govuk_content_models-7.3.0 test/models/workflow_actor_test.rb
govuk_content_models-7.2.1 test/models/workflow_actor_test.rb
govuk_content_models-7.2.0 test/models/workflow_actor_test.rb
govuk_content_models-7.1.1 test/models/workflow_actor_test.rb
govuk_content_models-7.1.0 test/models/workflow_actor_test.rb
govuk_content_models-7.0.0 test/models/workflow_actor_test.rb
govuk_content_models-6.4.0 test/models/workflow_actor_test.rb
govuk_content_models-6.3.0 test/models/workflow_actor_test.rb
govuk_content_models-6.1.0 test/models/workflow_actor_test.rb
govuk_content_models-6.0.6 test/models/workflow_actor_test.rb
govuk_content_models-6.0.5 test/models/workflow_actor_test.rb
govuk_content_models-6.0.4 test/models/workflow_actor_test.rb
govuk_content_models-6.0.3 test/models/workflow_actor_test.rb
govuk_content_models-6.0.2 test/models/workflow_actor_test.rb