maestrano-connector-rails 1.2.2 → 1.2.3

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: 33ca5ce6a87c49a85d92343cd1ca3fc95aa40f5a
4
- data.tar.gz: 3f152361f671a50af5c3b6de00f70e5e5b4ecdc3
3
+ metadata.gz: dc59b725143370fc5d008c5ac038245a3e35616a
4
+ data.tar.gz: 589185264707571da796f97d3672223109136a8f
5
5
  SHA512:
6
- metadata.gz: 5b4e1d85bb3002e08842c4bcd0465e8580c733cda97b4174de3bb3608b49a6a677293d5b4473bf01abb694eb19c6e733d6b091ec76df2d1e3c782b9aaea671c7
7
- data.tar.gz: e1ad34efc0df915117050afbb547e1dbbcb6a8b178081518749c9bd7675b39f32d3de969cd34bf2e323c0498eace1f6b6c1048bbdc40757ec54934b600109dad
6
+ metadata.gz: dac38cc67856ecd00562faa4e09882af3b10c59a17a575b69724f375b0aedc4efa2cef0912b30d9423d67d9207824457b6883e38f3436d916401dde42e76dac3
7
+ data.tar.gz: a5a72a4b5a460d0401e0b060552451db1db5ef50c4871fee66a1bc9305e7e4352a0df8a83e08791bc639bf87fa57379d815ea5d37cd934a2059b9aa0e0a74c3e
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.2
1
+ 1.2.3
@@ -18,7 +18,7 @@ module Maestrano::Connector::Rails::Concerns::ConnecHelper
18
18
  end
19
19
 
20
20
  def connec_version(organization)
21
- @@connec_version = Rails.cache.fetch('connec_version', namespace: 'maestrano', expires_in: 1.day) do
21
+ @@connec_version = Rails.cache.fetch("connec_version_#{organization.tenant}", namespace: 'maestrano', expires_in: 1.day) do
22
22
  response = get_client(organization).class.get("#{Maestrano[organization.tenant].param('connec.host')}/version")
23
23
  response = JSON.parse(response.body)
24
24
  @@connec_version = response['ci_branch']
@@ -27,7 +27,7 @@ module Maestrano::Connector::Rails::Concerns::ConnecHelper
27
27
  end
28
28
 
29
29
  # Replace the ids arrays by the external id
30
- # If a reference has no id for this oauth_provider and oauth_uid but has one for connec returns nil
30
+ # If a reference has no id for this oauth_provider and oauth_uid but has one for connec, returns nil
31
31
  def unfold_references(connec_entity, references, organization)
32
32
  unfolded_connec_entity = connec_entity.with_indifferent_access
33
33
  not_nil = true
@@ -85,6 +85,7 @@ module Maestrano::Connector::Rails::Concerns::ConnecHelper
85
85
 
86
86
  # Unfold the id
87
87
  if array_of_refs.empty? && field
88
+ return entity.delete(ref) if field.is_a?(String) # ~retro-compatibility to ease transition aroud Connec! idmaps rework. Should be removed eventually.
88
89
  id_hash = field.find { |id| id[:provider] == organization.oauth_provider && id[:realm] == organization.oauth_uid }
89
90
  if id_hash
90
91
  entity[ref] = id_hash['id']
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: maestrano-connector-rails 1.2.2 ruby lib
5
+ # stub: maestrano-connector-rails 1.2.3 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "maestrano-connector-rails"
9
- s.version = "1.2.2"
9
+ s.version = "1.2.3"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Pierre Berard"]
14
- s.date = "2016-07-05"
14
+ s.date = "2016-07-12"
15
15
  s.description = "Maestrano is the next generation marketplace for SME applications. See https://maestrano.com for details."
16
16
  s.email = "pierre.berard@maestrano.com"
17
17
  s.executables = ["rails"]
@@ -170,6 +170,7 @@ Gem::Specification.new do |s|
170
170
  "spec/dummy/public/422.html",
171
171
  "spec/dummy/public/500.html",
172
172
  "spec/dummy/public/favicon.ico",
173
+ "spec/dummy/tmp/cache/.keep",
173
174
  "spec/factories.rb",
174
175
  "spec/integration/connec_to_external_spec.rb",
175
176
  "spec/integration/external_to_connec_spec.rb",
data/release_notes.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## 1.2.2
2
+
3
+ ### Fixes
4
+ * Fix PushToConnecWork to take an organization_id insteand of an organization object
5
+
6
+ ### Features
7
+ * Add a version endpoint with the framework version
8
+
9
+ ### Improvments
10
+ * Add rubocop in the framework for better code quality
11
+ * Improve framework dependancies handling and update template accordingly
12
+
1
13
  ## 1.2.1
2
14
 
3
15
  ### Features
File without changes
@@ -17,12 +17,17 @@ describe Maestrano::Connector::Rails::ConnecHelper do
17
17
 
18
18
  describe 'connec_version' do
19
19
  let!(:organization) { create(:organization, tenant: 'default') }
20
+ let!(:organization2) { create(:organization, tenant: 'default2') }
20
21
  before {
21
- allow(Maestrano::Connec::Client[organization.tenant]).to receive(:get).and_return(ActionDispatch::Response.new(200, {}, {ci_build_number: '111', ci_branch: '1.1', ci_commit: '111'}.to_json, {}))
22
+ allow(Maestrano::Connec::Client).to receive(:get).and_return(ActionDispatch::Response.new(200, {}, {ci_build_number: '111', ci_branch: '1.1', ci_commit: '111'}.to_json, {}), ActionDispatch::Response.new(200, {}, {ci_build_number: '112', ci_branch: '1.2', ci_commit: '112'}.to_json, {}))
22
23
  }
23
24
 
24
25
  it 'returns the connec_version' do
26
+ expect(Maestrano::Connec::Client).to receive(:get).twice
25
27
  expect(subject.connec_version(organization)).to eql('1.1')
28
+ expect(subject.connec_version(organization2)).to eql('1.2')
29
+ expect(subject.connec_version(organization)).to eql('1.1')
30
+ expect(subject.connec_version(organization2)).to eql('1.2')
26
31
  end
27
32
 
28
33
  end
@@ -113,6 +118,26 @@ describe Maestrano::Connector::Rails::ConnecHelper do
113
118
  expect(subject.unfold_references(connec_hash, ['organization_id', 'lines/linked_transaction/id'], organization)).to eql(output_hash.merge(organization_id: nil).with_indifferent_access)
114
119
  end
115
120
  end
121
+
122
+ describe 'when reference field is a string instead of an array' do
123
+ let(:connec_hash) {
124
+ {
125
+ id: [subject.id_hash('123', organization), {'provider' => 'connec', 'id' => 'abcd'}],
126
+ organization_id: 'an unexpected string id',
127
+ }
128
+ }
129
+
130
+ let(:output_hash) {
131
+ {
132
+ __connec_id: 'abcd',
133
+ id: '123'
134
+ }
135
+ }
136
+
137
+ it 'let the string as it is' do
138
+ expect(subject.unfold_references(connec_hash, ['organization_id'], organization)).to eql(output_hash.with_indifferent_access)
139
+ end
140
+ end
116
141
  end
117
142
 
118
143
  describe 'fold_references' do
data/spec/spec_helper.rb CHANGED
@@ -25,5 +25,6 @@ RSpec.configure do |config|
25
25
  allow(Maestrano::Connector::Rails::External).to receive(:external_name).and_return('External app')
26
26
  allow(Maestrano::Connector::Rails::External).to receive(:get_client).and_return(Object.new)
27
27
  allow(Maestrano::Connector::Rails::External).to receive(:entities_list).and_return(%w(entity1 entity2))
28
+ Rails.cache.clear
28
29
  end
29
30
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maestrano-connector-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pierre Berard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-05 00:00:00.000000000 Z
11
+ date: 2016-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -520,6 +520,7 @@ files:
520
520
  - spec/dummy/public/422.html
521
521
  - spec/dummy/public/500.html
522
522
  - spec/dummy/public/favicon.ico
523
+ - spec/dummy/tmp/cache/.keep
523
524
  - spec/factories.rb
524
525
  - spec/integration/connec_to_external_spec.rb
525
526
  - spec/integration/external_to_connec_spec.rb