Sha256: bc21276b4e4d8a10336d5073560138ad020bcf619dabc69b069f135888522446

Contents?: true

Size: 1.34 KB

Versions: 13

Compression:

Stored size: 1.34 KB

Contents

require 'spec_helper'

describe CobotClient::NavigationLinkService, '#install_links' do
  let(:service) { CobotClient::NavigationLinkService.new(api_client, 'co-up') }
  let(:api_client) { double(:api_client) }

  context 'when there are links already' do
    before(:each) do
      allow(api_client).to receive(:get).with(
        'co-up', '/navigation_links') { [{label: 'test link'}] }
    end

    it 'installs no links' do
      expect(api_client).to_not receive(:post)

      service.install_links [double(:link)]
    end

    it 'returns the links' do
      expect(service.install_links([double(:link)]).map(&:label)).to eql(['test link'])
    end
  end

  context 'when there are no links installed' do
    let(:link) { double(:link, section: 'admin/manage', label: 'test link', iframe_url: '/test') }

    before(:each) do
      allow(api_client).to receive(:get).with('co-up', '/navigation_links') { [] }
    end

    it 'installs the links' do
      expect(api_client).to receive(:post).with('co-up', '/navigation_links', {
        section: 'admin/manage', label: 'test link', iframe_url: '/test'
      }) { {} }

      service.install_links [link]
    end

    it 'returns the links created' do
      allow(api_client).to receive(:post) { {label: 'test link'} }

      expect(service.install_links([link]).map(&:label)).to eql(['test link'])
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
cobot_client-3.0.0 spec/cobot_client/navigation_link_service_spec.rb
cobot_client-2.1.0 spec/cobot_client/navigation_link_service_spec.rb
cobot_client-2.0.0 spec/cobot_client/navigation_link_service_spec.rb
cobot_client-1.4.2 spec/cobot_client/navigation_link_service_spec.rb
cobot_client-1.4.0 spec/cobot_client/navigation_link_service_spec.rb
cobot_client-1.3.1 spec/cobot_client/navigation_link_service_spec.rb
cobot_client-1.3.0 spec/cobot_client/navigation_link_service_spec.rb
cobot_client-1.2.4 spec/cobot_client/navigation_link_service_spec.rb
cobot_client-1.2.3 spec/cobot_client/navigation_link_service_spec.rb
cobot_client-1.2.2 spec/cobot_client/navigation_link_service_spec.rb
cobot_client-1.2.1 spec/cobot_client/navigation_link_service_spec.rb
cobot_client-1.2.0 spec/cobot_client/navigation_link_service_spec.rb
cobot_client-1.1.1 spec/cobot_client/navigation_link_service_spec.rb