maestrano-connector-rails 1.5.0 → 2.0.0.pre.RC1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +0 -3
- data/.rubocop_todo.yml +8 -0
- data/Gemfile +5 -4
- data/VERSION +1 -1
- data/app/controllers/maestrano/auth/saml_controller.rb +1 -1
- data/app/controllers/maestrano/connec_controller.rb +1 -1
- data/app/controllers/maestrano/synchronizations_controller.rb +22 -44
- data/app/jobs/maestrano/connector/rails/all_synchronizations_job.rb +1 -1
- data/app/jobs/maestrano/connector/rails/synchronization_job.rb +4 -23
- data/app/models/maestrano/connector/rails/concerns/entity.rb +2 -2
- data/app/models/maestrano/connector/rails/organization.rb +2 -2
- data/lib/generators/connector/templates/home_controller.rb +2 -2
- data/lib/generators/connector/templates/home_controller_spec.rb +2 -2
- data/maestrano-connector-rails.gemspec +13 -11
- data/release_notes.md +16 -5
- data/spec/controllers/synchronizations_controller_spec.rb +2 -3
- data/spec/jobs/all_synchronizations_job_spec.rb +3 -3
- data/spec/jobs/synchronization_job_spec.rb +8 -9
- metadata +26 -13
- data/spec/dummy/tmp/cache/.keep +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20af245e9479b89f2432aaedc8bfdf6648314631
|
4
|
+
data.tar.gz: f5d2c1d4222c0a7d8cdd3736aecaf4acc44d96b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c460c160a31c3372dcbfa6ea34184668a28b249ec527a62582651db6a198a57985969571b987d64ed43b7c05909a7bc6f1969ce070f8160424a1172f4fdaadfa
|
7
|
+
data.tar.gz: 09dc98a9f479db3080e2b9dc1dd10e6d717cbd99f121a11d983b5d3deda5983a0efcae420da051501631f5a87540232802576367a7d1cb679fd22f89bee13d5c
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -102,6 +102,14 @@ Style/EmptyLinesAroundModuleBody:
|
|
102
102
|
Style/FrozenStringLiteralComment:
|
103
103
|
Enabled: false
|
104
104
|
|
105
|
+
# Offense count: 1
|
106
|
+
# Cop supports --auto-correct.
|
107
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
108
|
+
# SupportedStyles: predicate, comparison
|
109
|
+
Style/NumericPredicate:
|
110
|
+
Exclude:
|
111
|
+
- 'app/models/maestrano/connector/rails/organization.rb'
|
112
|
+
|
105
113
|
# Offense count: 3
|
106
114
|
# Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist.
|
107
115
|
# NamePrefix: is_, has_, have_
|
data/Gemfile
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
source 'http://rubygems.org'
|
2
2
|
|
3
3
|
# Add dependencies required to use your gem here.
|
4
|
-
gem 'rails'
|
5
|
-
gem 'maestrano-rails'
|
4
|
+
gem 'rails'
|
5
|
+
gem 'maestrano-rails', '1.0.0.pre.RC2'
|
6
6
|
|
7
7
|
gem 'hash_mapper', '>= 0.2.2'
|
8
8
|
gem 'haml-rails'
|
@@ -15,7 +15,7 @@ gem 'figaro'
|
|
15
15
|
gem 'sidekiq'
|
16
16
|
# The missing unique jobs for sidekiq
|
17
17
|
gem 'sidekiq-unique-jobs'
|
18
|
-
gem 'sinatra', require:
|
18
|
+
gem 'sinatra', require: nil
|
19
19
|
gem 'sidekiq-cron'
|
20
20
|
gem 'slim'
|
21
21
|
|
@@ -28,7 +28,8 @@ group :development do
|
|
28
28
|
gem 'simplecov', '>= 0'
|
29
29
|
gem 'rspec-rails'
|
30
30
|
gem 'factory_girl_rails'
|
31
|
-
gem '
|
31
|
+
gem 'activerecord-jdbcsqlite3-adapter', :platforms => :jruby
|
32
|
+
gem 'sqlite3', :platforms => :ruby
|
32
33
|
gem 'shoulda-matchers'
|
33
34
|
gem 'rubocop'
|
34
35
|
gem 'timecop'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
2.0.0.pre.RC1
|
@@ -24,7 +24,7 @@ class Maestrano::Auth::SamlController < Maestrano::Rails::SamlBaseController
|
|
24
24
|
if session[:settings]
|
25
25
|
session.delete(:settings)
|
26
26
|
redirect_to main_app.root_path
|
27
|
-
elsif current_organization
|
27
|
+
elsif current_organization && current_organization.oauth_uid && current_organization.sync_enabled
|
28
28
|
redirect_to main_app.home_redirect_to_external_path
|
29
29
|
else
|
30
30
|
redirect_to main_app.root_path
|
@@ -9,7 +9,7 @@ class Maestrano::ConnecController < Maestrano::Rails::WebHookController
|
|
9
9
|
|
10
10
|
entities.each do |entity|
|
11
11
|
organization = Maestrano::Connector::Rails::Organization.find_by_uid_and_tenant(entity[:group_id], params[:tenant])
|
12
|
-
next Rails.logger.warn "Received notification from Connec! for unknown group or group without oauth: #{entity['group_id']} (tenant: #{params[:tenant]})" unless organization
|
12
|
+
next Rails.logger.warn "Received notification from Connec! for unknown group or group without oauth: #{entity['group_id']} (tenant: #{params[:tenant]})" unless organization && organization.oauth_uid
|
13
13
|
next unless organization.sync_enabled && organization.synchronized_entities[entity_class_hash[:name].to_sym]
|
14
14
|
|
15
15
|
Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, "Received entity from Connec! webhook: Entity=#{entity_name}, Data=#{entity}")
|
@@ -3,11 +3,23 @@ class Maestrano::SynchronizationsController < Maestrano::Rails::WebHookControlle
|
|
3
3
|
tenant = params[:tenant]
|
4
4
|
uid = params[:id]
|
5
5
|
organization = Maestrano::Connector::Rails::Organization.find_by_uid_and_tenant(uid, tenant)
|
6
|
-
return render json: {errors: [{message:
|
7
|
-
|
8
|
-
|
6
|
+
return render json: {errors: [{message: "Organization not found", code: 404}]}, status: :not_found unless organization
|
7
|
+
|
8
|
+
h = {
|
9
|
+
group_id: organization.uid,
|
10
|
+
sync_enabled: organization.sync_enabled
|
11
|
+
}
|
12
|
+
|
13
|
+
last_sync = organization.synchronizations.last
|
14
|
+
if last_sync
|
15
|
+
h.merge!(
|
16
|
+
status: last_sync.status,
|
17
|
+
message: last_sync.message,
|
18
|
+
updated_at: last_sync.updated_at
|
19
|
+
)
|
20
|
+
end
|
9
21
|
|
10
|
-
|
22
|
+
render json: h
|
11
23
|
end
|
12
24
|
|
13
25
|
def create
|
@@ -15,55 +27,21 @@ class Maestrano::SynchronizationsController < Maestrano::Rails::WebHookControlle
|
|
15
27
|
uid = params[:group_id]
|
16
28
|
opts = params[:opts] || {}
|
17
29
|
organization = Maestrano::Connector::Rails::Organization.find_by_uid_and_tenant(uid, tenant)
|
18
|
-
return render json: {errors: [{message:
|
19
|
-
|
20
|
-
status = organization_status(organization)
|
30
|
+
return render json: {errors: [{message: "Organization not found", code: 404}]}, status: :not_found unless organization
|
21
31
|
|
22
|
-
|
23
|
-
|
24
|
-
status = 'ENQUEUED'
|
25
|
-
end
|
26
|
-
|
27
|
-
render_organization_sync(organization, status, 201)
|
32
|
+
Maestrano::Connector::Rails::SynchronizationJob.perform_later(organization, opts.with_indifferent_access)
|
33
|
+
head :created
|
28
34
|
end
|
29
35
|
|
30
36
|
def toggle_sync
|
31
37
|
tenant = params[:tenant]
|
32
38
|
uid = params[:group_id]
|
33
39
|
organization = Maestrano::Connector::Rails::Organization.find_by_uid_and_tenant(uid, tenant)
|
34
|
-
return render json: {errors: [{message:
|
40
|
+
return render json: {errors: [{message: "Organization not found", code: 404}]}, status: :not_found unless organization
|
35
41
|
|
36
42
|
organization.toggle(:sync_enabled)
|
37
43
|
organization.save
|
38
|
-
status = organization_status organization
|
39
|
-
render_organization_sync(organization, status, 200)
|
40
|
-
end
|
41
44
|
|
42
|
-
|
43
|
-
|
44
|
-
def render_organization_sync(organization, status, code)
|
45
|
-
h = {
|
46
|
-
group_id: organization.uid,
|
47
|
-
sync_enabled: organization.sync_enabled,
|
48
|
-
status: status
|
49
|
-
}
|
50
|
-
last_sync = organization.synchronizations.last
|
51
|
-
if last_sync
|
52
|
-
h[:message] = last_sync.message
|
53
|
-
h[:updated_at] = last_sync.updated_at
|
54
|
-
end
|
55
|
-
|
56
|
-
render json: h, status: code
|
57
|
-
end
|
58
|
-
|
59
|
-
def organization_status(organization)
|
60
|
-
last_sync = organization.synchronizations.last
|
61
|
-
if Maestrano::Connector::Rails::SynchronizationJob.find_running_job(organization.id)
|
62
|
-
'RUNNING'
|
63
|
-
elsif Maestrano::Connector::Rails::SynchronizationJob.find_job(organization.id)
|
64
|
-
'ENQUEUED'
|
65
|
-
else
|
66
|
-
last_sync&.status || 'DISABLED'
|
67
|
-
end
|
68
|
-
end
|
45
|
+
render json: {sync_enabled: organization.sync_enabled}
|
46
|
+
end
|
69
47
|
end
|
@@ -6,7 +6,7 @@ module Maestrano::Connector::Rails
|
|
6
6
|
def perform(name = nil, count = nil)
|
7
7
|
Maestrano::Connector::Rails::Organization.where.not(oauth_provider: nil, encrypted_oauth_token: nil).each do |o|
|
8
8
|
next unless [true, 1].include?(o.sync_enabled)
|
9
|
-
Maestrano::Connector::Rails::SynchronizationJob.perform_later(o
|
9
|
+
Maestrano::Connector::Rails::SynchronizationJob.perform_later(o, {})
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
@@ -7,9 +7,9 @@ module Maestrano::Connector::Rails
|
|
7
7
|
# * :only_entities => [person, tasks_list]
|
8
8
|
# * :full_sync => true synchronization is performed without date filtering
|
9
9
|
# * :connec_preemption => true|false : preemption is always|never given to connec in case of conflict (if not set, the most recently updated entity is kept)
|
10
|
-
def perform(
|
11
|
-
|
12
|
-
|
10
|
+
def perform(organization, opts = {})
|
11
|
+
return unless organization.sync_enabled
|
12
|
+
|
13
13
|
# Check if previous synchronization is still running
|
14
14
|
if Synchronization.where(organization_id: organization.id, status: 'RUNNING').where(created_at: (30.minutes.ago..Time.now)).exists?
|
15
15
|
ConnectorLogger.log('info', organization, 'Synchronization skipped: Previous synchronization is still running')
|
@@ -105,25 +105,6 @@ module Maestrano::Connector::Rails
|
|
105
105
|
end
|
106
106
|
end
|
107
107
|
|
108
|
-
def self.enqueued?(organization_id)
|
109
|
-
SynchronizationJob.find_job(organization_id).present? || SynchronizationJob.find_running_job(organization_id).present?
|
110
|
-
end
|
111
|
-
|
112
|
-
def self.find_job(organization_id)
|
113
|
-
queue = Sidekiq::Queue.new(:default)
|
114
|
-
queue.find do |job|
|
115
|
-
organization_id == job.item['args'][0]['arguments'].first
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
def self.find_running_job(organization_id)
|
120
|
-
Sidekiq::Workers.new.find do |_, _, work|
|
121
|
-
work['queue'] == 'default' && work['payload']['args'][0]['arguments'].first == organization_id
|
122
|
-
end
|
123
|
-
rescue
|
124
|
-
nil
|
125
|
-
end
|
126
|
-
|
127
108
|
private
|
128
109
|
|
129
110
|
def instanciate_entity(entity_name, organization, connec_client, external_client, opts)
|
@@ -139,7 +120,7 @@ module Maestrano::Connector::Rails
|
|
139
120
|
entity_instance.push_entities_to_external(mapped_entities[:connec_entities])
|
140
121
|
entity_instance.push_entities_to_connec(mapped_entities[:external_entities])
|
141
122
|
entity_instance.after_sync(last_synchronization_date)
|
142
|
-
|
123
|
+
|
143
124
|
entity_instance.class.count_and_first(external ? external_entities : connec_entities)
|
144
125
|
end
|
145
126
|
end
|
@@ -312,7 +312,7 @@ module Maestrano::Connector::Rails::Concerns::Entity
|
|
312
312
|
|
313
313
|
Maestrano::Connector::Rails::ConnectorLogger.log('info', @organization, "Sending Connec! #{self.class.connec_entity_name.pluralize} to #{Maestrano::Connector::Rails::External.external_name} #{external_entity_name.pluralize}")
|
314
314
|
|
315
|
-
entities_to_send_to_connec = mapped_connec_entities_with_idmaps.map
|
315
|
+
entities_to_send_to_connec = mapped_connec_entities_with_idmaps.map{ |mapped_connec_entity_with_idmap|
|
316
316
|
push_entity_to_external(mapped_connec_entity_with_idmap, external_entity_name)
|
317
317
|
}.compact
|
318
318
|
|
@@ -324,7 +324,7 @@ module Maestrano::Connector::Rails::Concerns::Entity
|
|
324
324
|
# with either only the id, or the id + id references
|
325
325
|
proc = lambda do |entity|
|
326
326
|
id = {id: [Maestrano::Connector::Rails::ConnecHelper.id_hash(entity[:idmap].external_id, @organization)]}
|
327
|
-
body = entity[:completed_hash]
|
327
|
+
body = entity[:completed_hash] ? entity[:completed_hash].merge(id) : id
|
328
328
|
batch_op('put', body, entity[:idmap].connec_id, self.class.normalized_connec_entity_name)
|
329
329
|
end
|
330
330
|
batch_calls(entities_to_send_to_connec, proc, self.class.connec_entity_name, true)
|
@@ -62,7 +62,7 @@ module Maestrano::Connector::Rails
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def member?(user)
|
65
|
-
user_organization_rels.where(user_id: user.id).count
|
65
|
+
user_organization_rels.where(user_id: user.id).count > 0
|
66
66
|
end
|
67
67
|
|
68
68
|
def remove_member(user)
|
@@ -108,7 +108,7 @@ module Maestrano::Connector::Rails
|
|
108
108
|
end
|
109
109
|
|
110
110
|
def last_synchronization_date
|
111
|
-
last_successful_synchronization
|
111
|
+
(last_successful_synchronization && last_successful_synchronization.updated_at) || date_filtering_limit
|
112
112
|
end
|
113
113
|
end
|
114
114
|
end
|
@@ -23,7 +23,7 @@ class HomeController < ApplicationController
|
|
23
23
|
|
24
24
|
def synchronize
|
25
25
|
return redirect_to(:back) unless is_admin
|
26
|
-
Maestrano::Connector::Rails::SynchronizationJob.perform_later(current_organization
|
26
|
+
Maestrano::Connector::Rails::SynchronizationJob.perform_later(current_organization, (params['opts'] || {}).merge(forced: true))
|
27
27
|
flash[:info] = 'Synchronization requested'
|
28
28
|
redirect_to(:back)
|
29
29
|
end
|
@@ -35,7 +35,7 @@ class HomeController < ApplicationController
|
|
35
35
|
private
|
36
36
|
|
37
37
|
def start_synchronization(old_sync_state, organization)
|
38
|
-
Maestrano::Connector::Rails::SynchronizationJob.perform_later(organization
|
38
|
+
Maestrano::Connector::Rails::SynchronizationJob.perform_later(organization, {})
|
39
39
|
flash[:info] = 'Congrats, you\'re all set up! Your data are now being synced'
|
40
40
|
end
|
41
41
|
end
|
@@ -87,7 +87,7 @@ describe HomeController, type: :controller do
|
|
87
87
|
subject { post :synchronize, opts: {'opts' => 'some_opts'} }
|
88
88
|
|
89
89
|
it 'calls perform_later with opts' do
|
90
|
-
expect(Maestrano::Connector::Rails::SynchronizationJob).to receive(:perform_later).with(organization
|
90
|
+
expect(Maestrano::Connector::Rails::SynchronizationJob).to receive(:perform_later).with(organization, 'opts' => 'some_opts', forced: true)
|
91
91
|
subject
|
92
92
|
end
|
93
93
|
end
|
@@ -96,7 +96,7 @@ describe HomeController, type: :controller do
|
|
96
96
|
subject { post :synchronize }
|
97
97
|
|
98
98
|
it 'calls perform_later with empty opts hash' do
|
99
|
-
expect(Maestrano::Connector::Rails::SynchronizationJob).to receive(:perform_later).with(organization
|
99
|
+
expect(Maestrano::Connector::Rails::SynchronizationJob).to receive(:perform_later).with(organization, forced: true)
|
100
100
|
subject
|
101
101
|
end
|
102
102
|
end
|
@@ -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
|
5
|
+
# stub: maestrano-connector-rails 2.0.0.pre.RC1 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "maestrano-connector-rails"
|
9
|
-
s.version = "
|
9
|
+
s.version = "2.0.0.pre.RC1"
|
10
10
|
|
11
|
-
s.required_rubygems_version = Gem::Requirement.new("
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Maestrano", "Pierre Berard", "Marco Bagnasco"]
|
14
|
-
s.date = "2016-09-
|
14
|
+
s.date = "2016-09-01"
|
15
15
|
s.description = "Maestrano is the next generation marketplace for SME applications. See https://maestrano.com for details."
|
16
16
|
s.email = "developers@maestrano.com"
|
17
17
|
s.executables = ["rails"]
|
@@ -168,7 +168,6 @@ Gem::Specification.new do |s|
|
|
168
168
|
"spec/dummy/public/422.html",
|
169
169
|
"spec/dummy/public/500.html",
|
170
170
|
"spec/dummy/public/favicon.ico",
|
171
|
-
"spec/dummy/tmp/cache/.keep",
|
172
171
|
"spec/factories.rb",
|
173
172
|
"spec/integration/complex_id_references_spec.rb",
|
174
173
|
"spec/integration/complex_naming_spec.rb",
|
@@ -222,8 +221,8 @@ Gem::Specification.new do |s|
|
|
222
221
|
s.specification_version = 4
|
223
222
|
|
224
223
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
225
|
-
s.add_runtime_dependency(%q<rails>, ["
|
226
|
-
s.add_runtime_dependency(%q<maestrano-rails>, ["
|
224
|
+
s.add_runtime_dependency(%q<rails>, [">= 0"])
|
225
|
+
s.add_runtime_dependency(%q<maestrano-rails>, ["= 1.0.0.pre.RC2"])
|
227
226
|
s.add_runtime_dependency(%q<hash_mapper>, [">= 0.2.2"])
|
228
227
|
s.add_runtime_dependency(%q<haml-rails>, [">= 0"])
|
229
228
|
s.add_runtime_dependency(%q<bootstrap-sass>, [">= 0"])
|
@@ -243,13 +242,14 @@ Gem::Specification.new do |s|
|
|
243
242
|
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
244
243
|
s.add_development_dependency(%q<rspec-rails>, [">= 0"])
|
245
244
|
s.add_development_dependency(%q<factory_girl_rails>, [">= 0"])
|
245
|
+
s.add_development_dependency(%q<activerecord-jdbcsqlite3-adapter>, [">= 0"])
|
246
246
|
s.add_development_dependency(%q<sqlite3>, [">= 0"])
|
247
247
|
s.add_development_dependency(%q<shoulda-matchers>, [">= 0"])
|
248
248
|
s.add_development_dependency(%q<rubocop>, [">= 0"])
|
249
249
|
s.add_development_dependency(%q<timecop>, [">= 0"])
|
250
250
|
else
|
251
|
-
s.add_dependency(%q<rails>, ["
|
252
|
-
s.add_dependency(%q<maestrano-rails>, ["
|
251
|
+
s.add_dependency(%q<rails>, [">= 0"])
|
252
|
+
s.add_dependency(%q<maestrano-rails>, ["= 1.0.0.pre.RC2"])
|
253
253
|
s.add_dependency(%q<hash_mapper>, [">= 0.2.2"])
|
254
254
|
s.add_dependency(%q<haml-rails>, [">= 0"])
|
255
255
|
s.add_dependency(%q<bootstrap-sass>, [">= 0"])
|
@@ -269,14 +269,15 @@ Gem::Specification.new do |s|
|
|
269
269
|
s.add_dependency(%q<simplecov>, [">= 0"])
|
270
270
|
s.add_dependency(%q<rspec-rails>, [">= 0"])
|
271
271
|
s.add_dependency(%q<factory_girl_rails>, [">= 0"])
|
272
|
+
s.add_dependency(%q<activerecord-jdbcsqlite3-adapter>, [">= 0"])
|
272
273
|
s.add_dependency(%q<sqlite3>, [">= 0"])
|
273
274
|
s.add_dependency(%q<shoulda-matchers>, [">= 0"])
|
274
275
|
s.add_dependency(%q<rubocop>, [">= 0"])
|
275
276
|
s.add_dependency(%q<timecop>, [">= 0"])
|
276
277
|
end
|
277
278
|
else
|
278
|
-
s.add_dependency(%q<rails>, ["
|
279
|
-
s.add_dependency(%q<maestrano-rails>, ["
|
279
|
+
s.add_dependency(%q<rails>, [">= 0"])
|
280
|
+
s.add_dependency(%q<maestrano-rails>, ["= 1.0.0.pre.RC2"])
|
280
281
|
s.add_dependency(%q<hash_mapper>, [">= 0.2.2"])
|
281
282
|
s.add_dependency(%q<haml-rails>, [">= 0"])
|
282
283
|
s.add_dependency(%q<bootstrap-sass>, [">= 0"])
|
@@ -296,6 +297,7 @@ Gem::Specification.new do |s|
|
|
296
297
|
s.add_dependency(%q<simplecov>, [">= 0"])
|
297
298
|
s.add_dependency(%q<rspec-rails>, [">= 0"])
|
298
299
|
s.add_dependency(%q<factory_girl_rails>, [">= 0"])
|
300
|
+
s.add_dependency(%q<activerecord-jdbcsqlite3-adapter>, [">= 0"])
|
299
301
|
s.add_dependency(%q<sqlite3>, [">= 0"])
|
300
302
|
s.add_dependency(%q<shoulda-matchers>, [">= 0"])
|
301
303
|
s.add_dependency(%q<rubocop>, [">= 0"])
|
data/release_notes.md
CHANGED
@@ -1,25 +1,36 @@
|
|
1
|
+
## 1.4.0
|
2
|
+
|
3
|
+
### Breaking changes
|
4
|
+
* `map_to`, `map_to_connec` and `map_to_external` method have changed and now take two arguments.
|
5
|
+
Additionally you should be able to remove all overloading to those methods using the new argument in hash mapper. See [documentation](https://maestrano.atlassian.net/wiki/display/DEV/Mapping+and+synchronization#Mappingandsynchronization-FAQ) for more details
|
6
|
+
|
7
|
+
### Features
|
8
|
+
* Possibility to use an extended mapper for creation only
|
9
|
+
* Possibility to pass additional arguments to hash mapper to use in the after/before hooks
|
10
|
+
|
1
11
|
## 1.3.5
|
2
12
|
|
3
|
-
|
13
|
+
|
14
|
+
### Features
|
4
15
|
* Improve generated files
|
5
16
|
* Adds a built-in way to handle error when updating a deleted record
|
6
17
|
|
7
|
-
|
18
|
+
### Fixes
|
8
19
|
* Adds safety against potential infinite loop
|
9
20
|
|
10
21
|
## 1.3.4
|
11
22
|
`maestrano.rb` file should be updated with new synchronization paths.
|
12
23
|
|
13
|
-
|
24
|
+
### Features
|
14
25
|
* `connec_version_lt?` method
|
15
26
|
|
16
|
-
|
27
|
+
### Fixes
|
17
28
|
* Fixes multi-tenancy of synchronization endpoints
|
18
29
|
* Fixes display of singleton entity
|
19
30
|
|
20
31
|
## 1.3.3
|
21
32
|
|
22
|
-
|
33
|
+
### Fixes
|
23
34
|
* Fixes `connec_version` method
|
24
35
|
|
25
36
|
## 1.3.2
|
@@ -61,7 +61,6 @@ describe Maestrano::SynchronizationsController, type: :controller do
|
|
61
61
|
JSON.parse({
|
62
62
|
group_id: organization.uid,
|
63
63
|
sync_enabled: organization.sync_enabled,
|
64
|
-
status: 'DISABLED'
|
65
64
|
}.to_json)
|
66
65
|
)
|
67
66
|
end
|
@@ -79,7 +78,7 @@ describe Maestrano::SynchronizationsController, type: :controller do
|
|
79
78
|
sync_enabled: organization.sync_enabled,
|
80
79
|
status: sync2.status,
|
81
80
|
message: sync2.message,
|
82
|
-
updated_at: sync2.updated_at
|
81
|
+
updated_at: sync2.updated_at
|
83
82
|
}.to_json)
|
84
83
|
)
|
85
84
|
end
|
@@ -136,7 +135,7 @@ describe Maestrano::SynchronizationsController, type: :controller do
|
|
136
135
|
end
|
137
136
|
|
138
137
|
it 'queues a sync' do
|
139
|
-
expect(Maestrano::Connector::Rails::SynchronizationJob).to receive(:perform_later).with(organization
|
138
|
+
expect(Maestrano::Connector::Rails::SynchronizationJob).to receive(:perform_later).with(organization, opts)
|
140
139
|
subject
|
141
140
|
end
|
142
141
|
end
|
@@ -14,9 +14,9 @@ describe Maestrano::Connector::Rails::AllSynchronizationsJob do
|
|
14
14
|
|
15
15
|
describe 'perform' do
|
16
16
|
it 'does not calls sync entity' do
|
17
|
-
expect(Maestrano::Connector::Rails::SynchronizationJob).to_not receive(:perform_later).with(organization_not_linked
|
18
|
-
expect(Maestrano::Connector::Rails::SynchronizationJob).to_not receive(:perform_later).with(organization_not_active
|
19
|
-
expect(Maestrano::Connector::Rails::SynchronizationJob).to receive(:perform_later).with(organization_to_process
|
17
|
+
expect(Maestrano::Connector::Rails::SynchronizationJob).to_not receive(:perform_later).with(organization_not_linked, anything)
|
18
|
+
expect(Maestrano::Connector::Rails::SynchronizationJob).to_not receive(:perform_later).with(organization_not_active, anything)
|
19
|
+
expect(Maestrano::Connector::Rails::SynchronizationJob).to receive(:perform_later).with(organization_to_process, anything)
|
20
20
|
|
21
21
|
subject
|
22
22
|
end
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe Maestrano::Connector::Rails::SynchronizationJob do
|
4
4
|
let(:organization) { create(:organization) }
|
5
5
|
let(:opts) { {} }
|
6
|
-
subject { Maestrano::Connector::Rails::SynchronizationJob.perform_now(organization
|
6
|
+
subject { Maestrano::Connector::Rails::SynchronizationJob.perform_now(organization, opts) }
|
7
7
|
|
8
8
|
def does_not_perform
|
9
9
|
expect_any_instance_of(Maestrano::Connector::Rails::SynchronizationJob).to_not receive(:sync_entity)
|
@@ -20,7 +20,7 @@ describe Maestrano::Connector::Rails::SynchronizationJob do
|
|
20
20
|
end
|
21
21
|
|
22
22
|
context 'with sync_enabled set to true' do
|
23
|
-
before { organization.update(sync_enabled: true)}
|
23
|
+
before { organization.update(sync_enabled: true)}
|
24
24
|
|
25
25
|
context 'with a sync still running for less than 30 minutes' do
|
26
26
|
let!(:running_sync) { create(:synchronization, organization: organization, status: 'RUNNING', created_at: 29.minutes.ago) }
|
@@ -77,12 +77,11 @@ describe Maestrano::Connector::Rails::SynchronizationJob do
|
|
77
77
|
|
78
78
|
context 'subsequent sync' do
|
79
79
|
let!(:old_sync) { create(:synchronization, partial: false, status: 'SUCCESS', organization: organization) }
|
80
|
-
|
80
|
+
|
81
81
|
it { performes }
|
82
82
|
|
83
83
|
it 'calls sync entity on all the organization synchronized entities set to true' do
|
84
84
|
organization.synchronized_entities[organization.synchronized_entities.keys.first] = false
|
85
|
-
organization.save
|
86
85
|
expect_any_instance_of(Maestrano::Connector::Rails::SynchronizationJob).to receive(:sync_entity).exactly(organization.synchronized_entities.count - 1).times
|
87
86
|
|
88
87
|
subject
|
@@ -173,11 +172,11 @@ describe Maestrano::Connector::Rails::SynchronizationJob do
|
|
173
172
|
context 'with more than 50 entities' do
|
174
173
|
let(:external_entities1) { [*1..50] }
|
175
174
|
let(:external_entities2) { [*51..60] }
|
176
|
-
|
175
|
+
|
177
176
|
it 'calls perform_sync several time' do
|
178
177
|
expect_any_instance_of(Entities::Person).to receive(:opts_merge!).twice
|
179
178
|
expect(subject).to receive(:perform_sync).twice.and_call_original
|
180
|
-
|
179
|
+
|
181
180
|
subject.first_sync_entity('person', organization, nil, nil, nil, {}, true)
|
182
181
|
end
|
183
182
|
end
|
@@ -188,7 +187,7 @@ describe Maestrano::Connector::Rails::SynchronizationJob do
|
|
188
187
|
it 'calls perform_sync once' do
|
189
188
|
expect_any_instance_of(Entities::Person).to receive(:opts_merge!).once.with({__skip: 0})
|
190
189
|
expect(subject).to receive(:perform_sync).once.and_call_original
|
191
|
-
|
190
|
+
|
192
191
|
subject.first_sync_entity('person', organization, nil, nil, nil, {}, true)
|
193
192
|
end
|
194
193
|
end
|
@@ -201,7 +200,7 @@ describe Maestrano::Connector::Rails::SynchronizationJob do
|
|
201
200
|
it 'calls perform_sync once' do
|
202
201
|
expect_any_instance_of(Entities::Person).to receive(:opts_merge!).once.with({__skip: 0})
|
203
202
|
expect(subject).to receive(:perform_sync).once.and_call_original
|
204
|
-
|
203
|
+
|
205
204
|
subject.first_sync_entity('person', organization, nil, nil, nil, {}, true)
|
206
205
|
end
|
207
206
|
end
|
@@ -221,4 +220,4 @@ describe Maestrano::Connector::Rails::SynchronizationJob do
|
|
221
220
|
end
|
222
221
|
end
|
223
222
|
end
|
224
|
-
end
|
223
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: maestrano-connector-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0.pre.RC1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maestrano
|
@@ -10,36 +10,36 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-09-
|
13
|
+
date: 2016-09-01 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
18
|
requirements:
|
19
|
-
- - "
|
19
|
+
- - ">="
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
21
|
+
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
|
-
- - "
|
26
|
+
- - ">="
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version: '
|
28
|
+
version: '0'
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: maestrano-rails
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
|
-
- -
|
33
|
+
- - '='
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version:
|
35
|
+
version: 1.0.0.pre.RC2
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
|
-
- -
|
40
|
+
- - '='
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version:
|
42
|
+
version: 1.0.0.pre.RC2
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: hash_mapper
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
@@ -306,6 +306,20 @@ dependencies:
|
|
306
306
|
- - ">="
|
307
307
|
- !ruby/object:Gem::Version
|
308
308
|
version: '0'
|
309
|
+
- !ruby/object:Gem::Dependency
|
310
|
+
name: activerecord-jdbcsqlite3-adapter
|
311
|
+
requirement: !ruby/object:Gem::Requirement
|
312
|
+
requirements:
|
313
|
+
- - ">="
|
314
|
+
- !ruby/object:Gem::Version
|
315
|
+
version: '0'
|
316
|
+
type: :development
|
317
|
+
prerelease: false
|
318
|
+
version_requirements: !ruby/object:Gem::Requirement
|
319
|
+
requirements:
|
320
|
+
- - ">="
|
321
|
+
- !ruby/object:Gem::Version
|
322
|
+
version: '0'
|
309
323
|
- !ruby/object:Gem::Dependency
|
310
324
|
name: sqlite3
|
311
325
|
requirement: !ruby/object:Gem::Requirement
|
@@ -520,7 +534,6 @@ files:
|
|
520
534
|
- spec/dummy/public/422.html
|
521
535
|
- spec/dummy/public/500.html
|
522
536
|
- spec/dummy/public/favicon.ico
|
523
|
-
- spec/dummy/tmp/cache/.keep
|
524
537
|
- spec/factories.rb
|
525
538
|
- spec/integration/complex_id_references_spec.rb
|
526
539
|
- spec/integration/complex_naming_spec.rb
|
@@ -579,9 +592,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
579
592
|
version: '0'
|
580
593
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
581
594
|
requirements:
|
582
|
-
- - "
|
595
|
+
- - ">"
|
583
596
|
- !ruby/object:Gem::Version
|
584
|
-
version:
|
597
|
+
version: 1.3.1
|
585
598
|
requirements: []
|
586
599
|
rubyforge_project:
|
587
600
|
rubygems_version: 2.5.1
|
data/spec/dummy/tmp/cache/.keep
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
|