Sha256: 2b7e95926de8d13524549daeaee22d3eeabfbcc0d264bcf59eae7ff9ba0a1206

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

require "spec_helper"
require "digicert/base"

RSpec.describe "Digicert::Actions::Create" do
  describe ".create" do
    it "creates a new resource" do
      stub_digicert_container_create_api(**container_attributes)
      resource = Digicert::TestCreateAction.create(container_attributes)

      expect(resource.id).not_to be_nil
    end
  end

  module Digicert
    class TestCreateAction < Digicert::Base
      include Digicert::Actions::Create

      def initialize(attributes = {})
        @container_id = attributes.delete(:container_id)
        super
      end

      private

      def resource_creation_path
        ["container", @container_id, "children"].join("/")
      end

      def validate(name:, template_id:, **attributes)
        {
          name: name,
          template_id: template_id,

        }.merge(attributes)
      end
    end
  end

  def container_attributes
    {
      container_id: 123_456_789,
      name: "History Department",
      template_id: 5,
      description: "History, Civ, Ancient Languages",
    }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
digicert-1.0.0 spec/digicert/actions/create_spec.rb