Sha256: fb6e754582e7f542f49e02b9c64383f1680d7925f93dc2f1de17f62c75867bc7

Contents?: true

Size: 1.28 KB

Versions: 1

Compression:

Stored size: 1.28 KB

Contents

require_relative '../../spec_helper'

describe Core::Commands::Domain::ByIdentifier do
  is_required :identifier
  is_optional :includes

  let(:response) { subject.class.run(params) }

  before do
    @domain = create(:domain)
  end

  context 'with valid params' do
    let(:params) { {
      identifier: @domain.identifier,
      includes: 'applications'
    } }

    it 'is valid' do
      response.success?.should == true
    end

    it 'includes identifier' do
      response.result[:domains].length.should == 1
      response.result[:domains].first[:identifier].should == @domain.identifier
    end

    it 'includes related application' do
      response.result[:applications].length.should == 1
      response.result[:applications].first[:id].should == @domain.application_id.to_s
    end

    context 'with subdomain in identifier' do
      let(:params) { {
        identifier: "www.#{@domain.identifier}",
        includes: 'applications'
      } }

      it 'is valid' do
        response.success?.should == true
      end
    end
  end

  context 'with invalid :identifier' do
    let(:params) { {
      identifier: 'invalid'
    }}

    it 'is :not_found' do
      response.success?.should == false
      response.result.should == {}
      response.status.should == :not_found
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
restpack_core_service-0.0.11 spec/services/domain/by_identifier_spec.rb