cobot_client 3.1.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1e33543f24073fe4a3c349c97874dd846533bea1
4
- data.tar.gz: 3c9818a5755292537b3fb8fbf0fa566c780dc382
3
+ metadata.gz: 0a30b5eca1e0c962124b7b58a2b2028b6844a74c
4
+ data.tar.gz: d9d307e97fda81cde1e3c857f22e159f9b995d42
5
5
  SHA512:
6
- metadata.gz: afc679f1b10dd8a731a46cb43e97f0858a3e8827c87b6293308597ec2edaa8af6883917e90464e8056533094ee4141c77098667137ed787c7224b2d3860ab0c9
7
- data.tar.gz: 7923351ded252310bed7277ba5d93a65021f261cb9bcc0c3f8710d1bd909697360bd596e0a423ded6d1b62097087eef2691a951eb34812050048c658ad417170
6
+ metadata.gz: 43f4f96b21d31aade0f682f2feb5e65c132663b2de2b3d6449697d9910e55cc789c94169c0305e5afd0a55495813e982799ee9aefea58c74b252572a71ca07d8
7
+ data.tar.gz: cc89589edc277e10173a2b1ce8a40e91b058de20afcac50ce6f93e759bb55ba7cb5472052430caf86ea221d6732e926055492b38c83ed4e752a5e139062005d5
@@ -1,3 +1,6 @@
1
+ # 4.0.0
2
+
3
+ * changed navigation link service to add missing links and return all if there are links already (before it would do nothing if there were any links already)
1
4
 
2
5
  # 3.1.0
3
6
 
@@ -16,18 +16,22 @@ module CobotClient
16
16
  #
17
17
  # Returns the links as `[CobotClient::NavigationLink]`
18
18
  def install_links(new_links)
19
- if (links = get_links).empty?
20
- new_links.each do |link|
21
- links << create_link(link)
19
+ existing_links = get_links
20
+ missing_links = new_links.reject do |new_link|
21
+ existing_links.find do |existing_link|
22
+ existing_link.section == new_link.section && existing_link.iframe_url == new_link.iframe_url
22
23
  end
23
24
  end
24
- links
25
+ created_links = missing_links.map do |link|
26
+ create_link(link)
27
+ end
28
+ existing_links + created_links
25
29
  end
26
30
 
27
31
  private
28
32
 
29
33
  def get_links
30
- @api_client.get(@subdomain, "/navigation_links").map do |attributes|
34
+ @api_client.get(@subdomain, '/navigation_links').map do |attributes|
31
35
  NavigationLink.new attributes
32
36
  end
33
37
  end
@@ -37,8 +41,7 @@ module CobotClient
37
41
  section: link.section,
38
42
  label: link.label,
39
43
  iframe_url: link.iframe_url,
40
- user_editable: link.user_editable
41
- )
44
+ user_editable: link.user_editable)
42
45
 
43
46
  NavigationLink.new response
44
47
  end
@@ -1,3 +1,3 @@
1
1
  module CobotClient
2
- VERSION = '3.1.0'
2
+ VERSION = '4.0.0'
3
3
  end
@@ -5,19 +5,34 @@ describe CobotClient::NavigationLinkService, '#install_links' do
5
5
  let(:api_client) { instance_double(CobotClient::ApiClient) }
6
6
 
7
7
  context 'when there are links already' do
8
+ let(:existing_link) do
9
+ instance_double(CobotClient::NavigationLink, label: 'existing link',
10
+ section: 'admin/setup', iframe_url: 'http://example.com/1').as_null_object
11
+ end
12
+ let(:new_link) do
13
+ instance_double(CobotClient::NavigationLink, label: 'new link',
14
+ section: 'admin/setup', iframe_url: 'http://example.com/2').as_null_object
15
+ end
16
+
8
17
  before(:each) do
9
18
  allow(api_client).to receive(:get)
10
- .with('co-up', '/navigation_links') { [{label: 'test link'}] }
19
+ .with('co-up', '/navigation_links')
20
+ .and_return([{label: 'existing link',
21
+ section: 'admin/setup', iframe_url: 'http://example.com/1'}])
11
22
  end
12
23
 
13
- it 'installs no links' do
14
- expect(api_client).to_not receive(:post)
24
+ it 'installs the missing links' do
25
+ expect(api_client).to receive(:post)
26
+ .with('co-up', '/navigation_links', hash_including(label: 'new link',
27
+ section: 'admin/setup', iframe_url: 'http://example.com/2')) { {} }
15
28
 
16
- service.install_links [double(:link)]
29
+ service.install_links [existing_link, new_link]
17
30
  end
18
31
 
19
- it 'returns the links' do
20
- expect(service.install_links([double(:link)]).map(&:label)).to eql(['test link'])
32
+ it 'returns all the links' do
33
+ allow(api_client).to receive(:post) { {label: 'new link'} }
34
+
35
+ expect(service.install_links([existing_link, new_link]).map(&:label)).to eql(['existing link', 'new link'])
21
36
  end
22
37
  end
23
38
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cobot_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Lang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-21 00:00:00.000000000 Z
11
+ date: 2018-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: virtus