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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a30b5eca1e0c962124b7b58a2b2028b6844a74c
|
4
|
+
data.tar.gz: d9d307e97fda81cde1e3c857f22e159f9b995d42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43f4f96b21d31aade0f682f2feb5e65c132663b2de2b3d6449697d9910e55cc789c94169c0305e5afd0a55495813e982799ee9aefea58c74b252572a71ca07d8
|
7
|
+
data.tar.gz: cc89589edc277e10173a2b1ce8a40e91b058de20afcac50ce6f93e759bb55ba7cb5472052430caf86ea221d6732e926055492b38c83ed4e752a5e139062005d5
|
data/CHANGELOG.md
CHANGED
@@ -16,18 +16,22 @@ module CobotClient
|
|
16
16
|
#
|
17
17
|
# Returns the links as `[CobotClient::NavigationLink]`
|
18
18
|
def install_links(new_links)
|
19
|
-
|
20
|
-
|
21
|
-
|
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
|
-
|
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,
|
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
|
data/lib/cobot_client/version.rb
CHANGED
@@ -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')
|
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
|
14
|
-
expect(api_client).
|
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 [
|
29
|
+
service.install_links [existing_link, new_link]
|
17
30
|
end
|
18
31
|
|
19
|
-
it 'returns the links' do
|
20
|
-
|
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:
|
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-
|
11
|
+
date: 2018-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: virtus
|