maestrano-connector-rails 0.0.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -2
  3. data/Gemfile.lock +52 -45
  4. data/VERSION +1 -1
  5. data/app/controllers/maestrano/application_controller.rb +1 -1
  6. data/app/jobs/maestrano/connector/rails/synchronization_job.rb +3 -2
  7. data/app/models/maestrano/connector/rails/concerns/entity.rb +5 -0
  8. data/app/models/maestrano/connector/rails/id_map.rb +1 -0
  9. data/app/models/maestrano/connector/rails/organization.rb +2 -0
  10. data/app/models/maestrano/connector/rails/synchronization.rb +2 -0
  11. data/app/models/maestrano/connector/rails/user.rb +2 -0
  12. data/app/models/maestrano/connector/rails/user_organization_rel.rb +2 -0
  13. data/lib/generators/connector/templates/admin_controller.rb +1 -1
  14. data/maestrano-connector-rails.gemspec +14 -14
  15. data/pkg/maestrano-connector-rails-0.0.1.gem +0 -0
  16. data/spec/dummy/app/controllers/admin_controller.rb +1 -1
  17. data/spec/dummy/db/development.sqlite3 +0 -0
  18. data/spec/dummy/db/schema.rb +1 -1
  19. data/spec/dummy/db/test.sqlite3 +0 -0
  20. data/spec/jobs/syncrhonization_job_spec.rb +13 -11
  21. metadata +26 -15
  22. data/spec/dummy/db/migrate/20151209134445_create_maestrano_connector_rails_users.maestrano_connector_rails.rb +0 -17
  23. data/spec/dummy/db/migrate/20151209134446_create_maestrano_connector_rails_organizations.maestrano_connector_rails.rb +0 -22
  24. data/spec/dummy/db/migrate/20151209134447_create_maestrano_connector_rails_user_organization_rels.maestrano_connector_rails.rb +0 -13
  25. data/spec/dummy/db/migrate/20151209134448_create_maestrano_connector_rails_synchronizations.maestrano_connector_rails.rb +0 -14
  26. data/spec/dummy/db/migrate/20151209134449_create_maestrano_connector_rails_id_maps.maestrano_connector_rails.rb +0 -19
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2df2109ee451552dfa445e1887b5048b7a457906
4
- data.tar.gz: b85fbd4b76831b51093c99c757be09b722ae673b
3
+ metadata.gz: c188e34977256c1d84f9fd43bd026233acf2833f
4
+ data.tar.gz: d7cf8ca5aa83e6ab639fa1ca2b71ef7a48614f47
5
5
  SHA512:
6
- metadata.gz: aeb87f7f7db0490289fa878b39cc90c94be00ed471112420005da481b974fb7432820427cceb6725187de0b1fad87fb2c36a9d2cc3fce01ce667b02da27206cc
7
- data.tar.gz: fba4495fb0e7510eb329232668f5f0e8a789b531be03f09be3f90476777315fe323752e9ea6ea6864b9f224869baa378a8225b3a517999da62f6514d6774c75d
6
+ metadata.gz: 0ce346b75f378364d2d74922f6c0950713ec1b9f8f6dec9753e2194a2b2be0631d6acc8a6dfbd1c96b8d8c15dbfa638e8b58829eb62f98e6d2e2e705cb22e81e
7
+ data.tar.gz: 4d1c4050ee4ac5a88ed3c722d8ff3663de69ba5a69d105a60263d046d13b661bdce424c427f045ea9136cf6d27b4fd89cd6c7f8edd903eff622614964e189f78
data/Gemfile CHANGED
@@ -1,8 +1,9 @@
1
1
  source "http://rubygems.org"
2
2
 
3
3
  # Add dependencies required to use your gem here.
4
- gem 'maestrano-rails', '~> 0.14.0'
5
- gem 'hash_mapper', '~> 0.2.1'
4
+ gem 'maestrano-rails'
5
+ gem 'hash_mapper'
6
+ gem 'sidekiq'
6
7
 
7
8
  # Add dependencies to develop your gem here.
8
9
  group :development do
data/Gemfile.lock CHANGED
@@ -1,36 +1,36 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- actionmailer (4.2.5)
5
- actionpack (= 4.2.5)
6
- actionview (= 4.2.5)
7
- activejob (= 4.2.5)
4
+ actionmailer (4.2.5.1)
5
+ actionpack (= 4.2.5.1)
6
+ actionview (= 4.2.5.1)
7
+ activejob (= 4.2.5.1)
8
8
  mail (~> 2.5, >= 2.5.4)
9
9
  rails-dom-testing (~> 1.0, >= 1.0.5)
10
- actionpack (4.2.5)
11
- actionview (= 4.2.5)
12
- activesupport (= 4.2.5)
10
+ actionpack (4.2.5.1)
11
+ actionview (= 4.2.5.1)
12
+ activesupport (= 4.2.5.1)
13
13
  rack (~> 1.6)
14
14
  rack-test (~> 0.6.2)
15
15
  rails-dom-testing (~> 1.0, >= 1.0.5)
16
16
  rails-html-sanitizer (~> 1.0, >= 1.0.2)
17
- actionview (4.2.5)
18
- activesupport (= 4.2.5)
17
+ actionview (4.2.5.1)
18
+ activesupport (= 4.2.5.1)
19
19
  builder (~> 3.1)
20
20
  erubis (~> 2.7.0)
21
21
  rails-dom-testing (~> 1.0, >= 1.0.5)
22
22
  rails-html-sanitizer (~> 1.0, >= 1.0.2)
23
- activejob (4.2.5)
24
- activesupport (= 4.2.5)
23
+ activejob (4.2.5.1)
24
+ activesupport (= 4.2.5.1)
25
25
  globalid (>= 0.3.0)
26
- activemodel (4.2.5)
27
- activesupport (= 4.2.5)
26
+ activemodel (4.2.5.1)
27
+ activesupport (= 4.2.5.1)
28
28
  builder (~> 3.1)
29
- activerecord (4.2.5)
30
- activemodel (= 4.2.5)
31
- activesupport (= 4.2.5)
29
+ activerecord (4.2.5.1)
30
+ activemodel (= 4.2.5.1)
31
+ activesupport (= 4.2.5.1)
32
32
  arel (~> 6.0)
33
- activesupport (4.2.5)
33
+ activesupport (4.2.5.1)
34
34
  i18n (~> 0.7)
35
35
  json (~> 1.7, >= 1.7.7)
36
36
  minitest (~> 5.1)
@@ -40,16 +40,17 @@ GEM
40
40
  arel (6.0.3)
41
41
  builder (3.2.2)
42
42
  concurrent-ruby (1.0.0)
43
+ connection_pool (2.2.0)
43
44
  descendants_tracker (0.0.4)
44
45
  thread_safe (~> 0.3, >= 0.3.1)
45
46
  diff-lcs (1.2.5)
46
47
  docile (1.1.5)
47
- domain_name (0.5.25)
48
+ domain_name (0.5.20160128)
48
49
  unf (>= 0.0.5, < 1.0.0)
49
50
  erubis (2.7.0)
50
51
  factory_girl (4.5.0)
51
52
  activesupport (>= 3.0.0)
52
- factory_girl_rails (4.5.0)
53
+ factory_girl_rails (4.6.0)
53
54
  factory_girl (~> 4.5.0)
54
55
  railties (>= 3.0.0)
55
56
  faraday (0.9.2)
@@ -88,7 +89,7 @@ GEM
88
89
  railties (>= 4.2.0)
89
90
  thor (>= 0.14, < 2.0)
90
91
  json (1.8.3)
91
- jwt (1.5.2)
92
+ jwt (1.5.1)
92
93
  loofah (2.0.3)
93
94
  nokogiri (>= 1.5.9)
94
95
  macaddr (1.7.1)
@@ -108,32 +109,32 @@ GEM
108
109
  mime-types (>= 1.16, < 3)
109
110
  mime-types (1.25.1)
110
111
  mini_portile2 (2.0.0)
111
- minitest (5.8.3)
112
+ minitest (5.8.4)
112
113
  multi_json (1.11.2)
113
114
  multi_xml (0.5.5)
114
115
  multipart-post (2.0.0)
115
116
  netrc (0.11.0)
116
117
  nokogiri (1.6.7.2)
117
118
  mini_portile2 (~> 2.0.0.rc2)
118
- oauth2 (1.0.0)
119
+ oauth2 (1.1.0)
119
120
  faraday (>= 0.8, < 0.10)
120
- jwt (~> 1.0)
121
+ jwt (~> 1.0, < 1.5.2)
121
122
  multi_json (~> 1.3)
122
123
  multi_xml (~> 0.5)
123
- rack (~> 1.2)
124
+ rack (>= 1.2, < 3)
124
125
  rack (1.6.4)
125
126
  rack-test (0.6.3)
126
127
  rack (>= 1.0)
127
- rails (4.2.5)
128
- actionmailer (= 4.2.5)
129
- actionpack (= 4.2.5)
130
- actionview (= 4.2.5)
131
- activejob (= 4.2.5)
132
- activemodel (= 4.2.5)
133
- activerecord (= 4.2.5)
134
- activesupport (= 4.2.5)
128
+ rails (4.2.5.1)
129
+ actionmailer (= 4.2.5.1)
130
+ actionpack (= 4.2.5.1)
131
+ actionview (= 4.2.5.1)
132
+ activejob (= 4.2.5.1)
133
+ activemodel (= 4.2.5.1)
134
+ activerecord (= 4.2.5.1)
135
+ activesupport (= 4.2.5.1)
135
136
  bundler (>= 1.3.0, < 2.0)
136
- railties (= 4.2.5)
137
+ railties (= 4.2.5.1)
137
138
  sprockets-rails
138
139
  rails-deprecated_sanitizer (1.0.3)
139
140
  activesupport (>= 4.2.0.alpha)
@@ -141,29 +142,30 @@ GEM
141
142
  activesupport (>= 4.2.0.beta, < 5.0)
142
143
  nokogiri (~> 1.6.0)
143
144
  rails-deprecated_sanitizer (>= 1.0.1)
144
- rails-html-sanitizer (1.0.2)
145
+ rails-html-sanitizer (1.0.3)
145
146
  loofah (~> 2.0)
146
- railties (4.2.5)
147
- actionpack (= 4.2.5)
148
- activesupport (= 4.2.5)
147
+ railties (4.2.5.1)
148
+ actionpack (= 4.2.5.1)
149
+ activesupport (= 4.2.5.1)
149
150
  rake (>= 0.8.7)
150
151
  thor (>= 0.18.1, < 2.0)
151
152
  rake (10.5.0)
152
153
  rdoc (3.12.2)
153
154
  json (~> 1.4)
155
+ redis (3.2.2)
154
156
  rest-client (1.8.0)
155
157
  http-cookie (>= 1.0.2, < 2.0)
156
158
  mime-types (>= 1.16, < 3.0)
157
159
  netrc (~> 0.7)
158
- rspec-core (3.4.1)
160
+ rspec-core (3.4.2)
159
161
  rspec-support (~> 3.4.0)
160
162
  rspec-expectations (3.4.0)
161
163
  diff-lcs (>= 1.2.0, < 2.0)
162
164
  rspec-support (~> 3.4.0)
163
- rspec-mocks (3.4.0)
165
+ rspec-mocks (3.4.1)
164
166
  diff-lcs (>= 1.2.0, < 2.0)
165
167
  rspec-support (~> 3.4.0)
166
- rspec-rails (3.4.0)
168
+ rspec-rails (3.4.2)
167
169
  actionpack (>= 3.0, < 4.3)
168
170
  activesupport (>= 3.0, < 4.3)
169
171
  railties (>= 3.0, < 4.3)
@@ -178,7 +180,11 @@ GEM
178
180
  shoulda-context (1.2.1)
179
181
  shoulda-matchers (2.8.0)
180
182
  activesupport (>= 3.0.0)
181
- simplecov (0.11.1)
183
+ sidekiq (4.1.0)
184
+ concurrent-ruby (~> 1.0)
185
+ connection_pool (~> 2.2, >= 2.2.0)
186
+ redis (~> 3.2, >= 3.2.1)
187
+ simplecov (0.11.2)
182
188
  docile (~> 1.1.0)
183
189
  json (~> 1.8)
184
190
  simplecov-html (~> 0.10.0)
@@ -186,7 +192,7 @@ GEM
186
192
  sprockets (3.5.2)
187
193
  concurrent-ruby (~> 1.0)
188
194
  rack (> 1, < 3)
189
- sprockets-rails (3.0.0)
195
+ sprockets-rails (3.0.1)
190
196
  actionpack (>= 4.0)
191
197
  activesupport (>= 4.0)
192
198
  sprockets (>= 3.0.0)
@@ -198,7 +204,7 @@ GEM
198
204
  thread_safe (~> 0.1)
199
205
  unf (0.1.4)
200
206
  unf_ext
201
- unf_ext (0.0.7.1)
207
+ unf_ext (0.0.7.2)
202
208
  uuid (2.3.8)
203
209
  macaddr (~> 1.0)
204
210
 
@@ -208,13 +214,14 @@ PLATFORMS
208
214
  DEPENDENCIES
209
215
  bundler (~> 1.0)
210
216
  factory_girl_rails
211
- hash_mapper (~> 0.2.1)
217
+ hash_mapper
212
218
  jeweler (~> 2.0.1)
213
- maestrano-rails (~> 0.14.0)
219
+ maestrano-rails
214
220
  rdoc (~> 3.12)
215
221
  rspec-rails
216
222
  shoulda
217
223
  shoulda-matchers
224
+ sidekiq
218
225
  simplecov
219
226
  sqlite3
220
227
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.2.0
@@ -1,6 +1,6 @@
1
1
  module Maestrano
2
2
  class ApplicationController < ActionController::Base
3
- include SessionHelper
3
+ include Maestrano::Connector::Rails::SessionHelper
4
4
 
5
5
  protect_from_forgery with: :exception
6
6
  end
@@ -1,12 +1,13 @@
1
1
  module Maestrano::Connector::Rails
2
- class SynchronizationJob < Struct.new(:organization, :opts)
2
+ class SynchronizationJob < ::ActiveJob::Base
3
+ queue_as :default
3
4
 
4
5
  # Supported options:
5
6
  # * :forced => true synchronization has been triggered manually (for logging purposes only)
6
7
  # * :only_entities => [person, tasks_list]
7
8
  # * :full_sync => true synchronization is performed without date filtering
8
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)
9
- def perform
10
+ def perform(organization, opts)
10
11
  ConnectorLogger.log('info', organization, "Start synchronization, opts=#{opts}")
11
12
  current_synchronization = Synchronization.create_running(organization)
12
13
 
@@ -35,14 +35,17 @@ module Maestrano::Connector::Rails::Concerns::Entity
35
35
 
36
36
  # Fetch first page
37
37
  if last_synchronization.blank? || opts[:full_sync]
38
+ Maestrano::Connector::Rails::ConnectorLogger.log('debug', organization, "entity=#{self.connec_entity_name}, fetching all data")
38
39
  response = client.get("/#{self.connec_entity_name.downcase.pluralize}")
39
40
  else
41
+ Maestrano::Connector::Rails::ConnectorLogger.log('debug', organization, "entity=#{self.connec_entity_name}, fetching data since #{last_synchronization.updated_at.iso8601}")
40
42
  query_param = URI.encode("$filter=updated_at gt '#{last_synchronization.updated_at.iso8601}'")
41
43
  response = client.get("/#{self.connec_entity_name.downcase.pluralize}?#{query_param}")
42
44
  end
43
45
  raise "No data received from Connec! when trying to fetch #{self.connec_entity_name.pluralize}" unless response
44
46
 
45
47
  response_hash = JSON.parse(response.body)
48
+ Maestrano::Connector::Rails::ConnectorLogger.log('debug', organization, "received first page entity=#{self.connec_entity_name}, response=#{response.body}")
46
49
  if response_hash["#{self.connec_entity_name.downcase.pluralize}"]
47
50
  entities << response_hash["#{self.connec_entity_name.downcase.pluralize}"]
48
51
  else
@@ -56,6 +59,8 @@ module Maestrano::Connector::Rails::Concerns::Entity
56
59
  response = client.get(next_page)
57
60
 
58
61
  raise "No data received from Connec! when trying to fetch subsequent page of #{self.connec_entity_name.pluralize}" unless response
62
+ Maestrano::Connector::Rails::ConnectorLogger.log('debug', organization, "received next page entity=#{self.connec_entity_name}, response=#{response.body}")
63
+
59
64
  response_hash = JSON.parse(response.body)
60
65
  if response_hash["#{self.connec_entity_name.downcase.pluralize}"]
61
66
  entities << response_hash["#{self.connec_entity_name.downcase.pluralize}"]
@@ -1,5 +1,6 @@
1
1
  module Maestrano::Connector::Rails
2
2
  class IdMap < ActiveRecord::Base
3
+ self.table_name = "maestrano_connector_rails_id_maps"
3
4
 
4
5
  belongs_to :organization
5
6
  end
@@ -1,5 +1,7 @@
1
1
  module Maestrano::Connector::Rails
2
2
  class Organization < ActiveRecord::Base
3
+ self.table_name = "maestrano_connector_rails_organizations"
4
+
3
5
  # Enable Maestrano for this group
4
6
  maestrano_group_via :provider, :uid, :tenant do |group, maestrano|
5
7
  group.name = (maestrano.name.blank? ? "Default Group name" : maestrano.name)
@@ -1,5 +1,7 @@
1
1
  module Maestrano::Connector::Rails
2
2
  class Synchronization < ActiveRecord::Base
3
+ self.table_name = "maestrano_connector_rails_synchronizations"
4
+
3
5
  #===================================
4
6
  # Associations
5
7
  #===================================
@@ -1,5 +1,7 @@
1
1
  module Maestrano::Connector::Rails
2
2
  class User < ActiveRecord::Base
3
+ self.table_name = "maestrano_connector_rails_users"
4
+
3
5
  # Enable Maestrano for this user
4
6
  maestrano_user_via :provider, :uid, :tenant do |user, maestrano|
5
7
  user.uid = maestrano.uid
@@ -1,5 +1,7 @@
1
1
  module Maestrano::Connector::Rails
2
2
  class UserOrganizationRel < ActiveRecord::Base
3
+ self.table_name = "maestrano_connector_rails_user_organization_rels"
4
+
3
5
  #===================================
4
6
  # Associations
5
7
  #===================================
@@ -35,7 +35,7 @@ class AdminController < ApplicationController
35
35
 
36
36
  def synchronize
37
37
  if is_admin
38
- Delayed::Job.enqueue Maestrano::Connector::Rails::SynchronizationJob.new(current_organization, params['opts'] || {})
38
+ Maestrano::Connector::Rails::SynchronizationJob.perform_later(current_organization, params['opts'] || {})
39
39
  end
40
40
 
41
41
  redirect_to root_path
@@ -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 0.0.1 ruby lib
5
+ # stub: maestrano-connector-rails 0.2.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "maestrano-connector-rails"
9
- s.version = "0.0.1"
9
+ s.version = "0.2.0"
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-01-21"
14
+ s.date = "2016-02-05"
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"]
@@ -76,6 +76,7 @@ Gem::Specification.new do |s|
76
76
  "lib/maestrano/connector/rails.rb",
77
77
  "maestrano-connector-rails.gemspec",
78
78
  "maestrano.png",
79
+ "pkg/maestrano-connector-rails-0.0.1.gem",
79
80
  "spec/dummy/README.md",
80
81
  "spec/dummy/Rakefile",
81
82
  "spec/dummy/app/assets/images/.keep",
@@ -121,12 +122,8 @@ Gem::Specification.new do |s|
121
122
  "spec/dummy/config/routes.rb",
122
123
  "spec/dummy/config/secrets.yml",
123
124
  "spec/dummy/db/development.sqlite3",
124
- "spec/dummy/db/migrate/20151209134445_create_maestrano_connector_rails_users.maestrano_connector_rails.rb",
125
- "spec/dummy/db/migrate/20151209134446_create_maestrano_connector_rails_organizations.maestrano_connector_rails.rb",
126
- "spec/dummy/db/migrate/20151209134447_create_maestrano_connector_rails_user_organization_rels.maestrano_connector_rails.rb",
127
- "spec/dummy/db/migrate/20151209134448_create_maestrano_connector_rails_synchronizations.maestrano_connector_rails.rb",
128
- "spec/dummy/db/migrate/20151209134449_create_maestrano_connector_rails_id_maps.maestrano_connector_rails.rb",
129
125
  "spec/dummy/db/schema.rb",
126
+ "spec/dummy/db/test.sqlite3",
130
127
  "spec/dummy/lib/assets/.keep",
131
128
  "spec/dummy/log/.keep",
132
129
  "spec/dummy/public/404.html",
@@ -156,8 +153,9 @@ Gem::Specification.new do |s|
156
153
  s.specification_version = 4
157
154
 
158
155
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
159
- s.add_runtime_dependency(%q<maestrano-rails>, ["~> 0.14.0"])
160
- s.add_runtime_dependency(%q<hash_mapper>, ["~> 0.2.1"])
156
+ s.add_runtime_dependency(%q<maestrano-rails>, [">= 0"])
157
+ s.add_runtime_dependency(%q<hash_mapper>, [">= 0"])
158
+ s.add_runtime_dependency(%q<sidekiq>, [">= 0"])
161
159
  s.add_development_dependency(%q<shoulda>, [">= 0"])
162
160
  s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
163
161
  s.add_development_dependency(%q<bundler>, ["~> 1.0"])
@@ -168,8 +166,9 @@ Gem::Specification.new do |s|
168
166
  s.add_development_dependency(%q<sqlite3>, [">= 0"])
169
167
  s.add_development_dependency(%q<shoulda-matchers>, [">= 0"])
170
168
  else
171
- s.add_dependency(%q<maestrano-rails>, ["~> 0.14.0"])
172
- s.add_dependency(%q<hash_mapper>, ["~> 0.2.1"])
169
+ s.add_dependency(%q<maestrano-rails>, [">= 0"])
170
+ s.add_dependency(%q<hash_mapper>, [">= 0"])
171
+ s.add_dependency(%q<sidekiq>, [">= 0"])
173
172
  s.add_dependency(%q<shoulda>, [">= 0"])
174
173
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
175
174
  s.add_dependency(%q<bundler>, ["~> 1.0"])
@@ -181,8 +180,9 @@ Gem::Specification.new do |s|
181
180
  s.add_dependency(%q<shoulda-matchers>, [">= 0"])
182
181
  end
183
182
  else
184
- s.add_dependency(%q<maestrano-rails>, ["~> 0.14.0"])
185
- s.add_dependency(%q<hash_mapper>, ["~> 0.2.1"])
183
+ s.add_dependency(%q<maestrano-rails>, [">= 0"])
184
+ s.add_dependency(%q<hash_mapper>, [">= 0"])
185
+ s.add_dependency(%q<sidekiq>, [">= 0"])
186
186
  s.add_dependency(%q<shoulda>, [">= 0"])
187
187
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
188
188
  s.add_dependency(%q<bundler>, ["~> 1.0"])
@@ -35,7 +35,7 @@ class AdminController < ApplicationController
35
35
 
36
36
  def synchronize
37
37
  if is_admin
38
- Delayed::Job.enqueue Maestrano::Connector::Rails::SynchronizationJob.new(current_organization, params['opts'] || {})
38
+ Maestrano::Connector::Rails::SynchronizationJob.perform_later(current_organization, params['opts'] || {})
39
39
  end
40
40
 
41
41
  redirect_to root_path
Binary file
@@ -11,7 +11,7 @@
11
11
  #
12
12
  # It's strongly recommended that you check this file into your version control system.
13
13
 
14
- ActiveRecord::Schema.define(version: 20151209134449) do
14
+ ActiveRecord::Schema.define(version: 20151122163449) do
15
15
 
16
16
  create_table "maestrano_connector_rails_id_maps", force: :cascade do |t|
17
17
  t.string "connec_id"
Binary file
@@ -2,32 +2,32 @@ require 'spec_helper'
2
2
 
3
3
  describe Maestrano::Connector::Rails::SynchronizationJob do
4
4
  let(:organization) { create(:organization) }
5
- subject { Maestrano::Connector::Rails::SynchronizationJob.new(organization, {}) }
6
-
5
+ subject { Maestrano::Connector::Rails::SynchronizationJob.perform_now(organization, {}) }
6
+
7
7
  describe 'perform' do
8
8
  it 'creates a synchronization' do
9
- expect{
10
- subject.perform
11
- }.to change{ Maestrano::Connector::Rails::Synchronization.count }.by(1)
9
+ expect{ subject }.to change{ Maestrano::Connector::Rails::Synchronization.count }.by(1)
12
10
  end
13
11
 
14
12
  it 'calls sync entity on all the organization synchronized entities set to true' do
15
13
  organization.synchronized_entities[organization.synchronized_entities.keys.first] = false
16
- expect(subject).to receive(:sync_entity).exactly(organization.synchronized_entities.count - 1).times
17
- subject.perform
14
+ expect_any_instance_of(Maestrano::Connector::Rails::SynchronizationJob).to receive(:sync_entity).exactly(organization.synchronized_entities.count - 1).times
15
+
16
+ subject
18
17
  end
19
18
 
20
19
  context 'with options' do
21
20
  context 'with only_entities' do
22
- subject { Maestrano::Connector::Rails::SynchronizationJob.new(organization, {only_entities: %w(people price)}) }
21
+ subject { Maestrano::Connector::Rails::SynchronizationJob.perform_now(organization, {only_entities: %w(people price)}) }
23
22
 
24
23
  it 'calls sync entity on the specified entities' do
25
- expect(subject).to receive(:sync_entity).twice
26
- subject.perform
24
+ expect_any_instance_of(Maestrano::Connector::Rails::SynchronizationJob).to receive(:sync_entity).twice
25
+
26
+ subject
27
27
  end
28
28
 
29
29
  it 'set the current syncrhonization as partial' do
30
- subject.perform
30
+ subject
31
31
  expect(Maestrano::Connector::Rails::Synchronization.last.partial).to be(true)
32
32
  end
33
33
  end
@@ -41,6 +41,8 @@ describe Maestrano::Connector::Rails::SynchronizationJob do
41
41
  end
42
42
  }
43
43
 
44
+ subject { Maestrano::Connector::Rails::SynchronizationJob.new }
45
+
44
46
  it 'calls the five methods' do
45
47
  expect_any_instance_of(Entities::Person).to receive(:get_connec_entities)
46
48
  expect_any_instance_of(Entities::Person).to receive(:get_external_entities)
metadata CHANGED
@@ -1,43 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maestrano-connector-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.2.0
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-01-21 00:00:00.000000000 Z
11
+ date: 2016-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: maestrano-rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.14.0
19
+ version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.14.0
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: hash_mapper
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.2.1
33
+ version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 0.2.1
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: sidekiq
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: shoulda
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -230,6 +244,7 @@ files:
230
244
  - lib/maestrano/connector/rails.rb
231
245
  - maestrano-connector-rails.gemspec
232
246
  - maestrano.png
247
+ - pkg/maestrano-connector-rails-0.0.1.gem
233
248
  - spec/dummy/README.md
234
249
  - spec/dummy/Rakefile
235
250
  - spec/dummy/app/assets/images/.keep
@@ -275,12 +290,8 @@ files:
275
290
  - spec/dummy/config/routes.rb
276
291
  - spec/dummy/config/secrets.yml
277
292
  - spec/dummy/db/development.sqlite3
278
- - spec/dummy/db/migrate/20151209134445_create_maestrano_connector_rails_users.maestrano_connector_rails.rb
279
- - spec/dummy/db/migrate/20151209134446_create_maestrano_connector_rails_organizations.maestrano_connector_rails.rb
280
- - spec/dummy/db/migrate/20151209134447_create_maestrano_connector_rails_user_organization_rels.maestrano_connector_rails.rb
281
- - spec/dummy/db/migrate/20151209134448_create_maestrano_connector_rails_synchronizations.maestrano_connector_rails.rb
282
- - spec/dummy/db/migrate/20151209134449_create_maestrano_connector_rails_id_maps.maestrano_connector_rails.rb
283
293
  - spec/dummy/db/schema.rb
294
+ - spec/dummy/db/test.sqlite3
284
295
  - spec/dummy/lib/assets/.keep
285
296
  - spec/dummy/log/.keep
286
297
  - spec/dummy/public/404.html
@@ -1,17 +0,0 @@
1
- # This migration comes from maestrano_connector_rails (originally 20151122162100)
2
- class CreateMaestranoConnectorRailsUsers < ActiveRecord::Migration
3
- def change
4
- create_table :maestrano_connector_rails_users do |t|
5
- t.string :provider
6
- t.string :uid
7
- t.string :first_name
8
- t.string :last_name
9
- t.string :email
10
- t.string :tenant
11
-
12
- t.timestamps null: false
13
- end
14
-
15
- add_index :maestrano_connector_rails_users, [:uid, :tenant], name: 'user_uid_index'
16
- end
17
- end
@@ -1,22 +0,0 @@
1
- # This migration comes from maestrano_connector_rails (originally 20151122162414)
2
- class CreateMaestranoConnectorRailsOrganizations < ActiveRecord::Migration
3
- def change
4
- create_table :maestrano_connector_rails_organizations do |t|
5
- t.string :provider
6
- t.string :uid
7
- t.string :name
8
- t.string :tenant
9
-
10
- t.string :oauth_provider
11
- t.string :oauth_uid
12
- t.string :oauth_token
13
- t.string :refresh_token
14
- t.string :instance_url
15
-
16
- t.string :synchronized_entities
17
-
18
- t.timestamps null: false
19
- end
20
- add_index :maestrano_connector_rails_organizations, [:uid, :tenant], name: 'orga_uid_index'
21
- end
22
- end
@@ -1,13 +0,0 @@
1
- # This migration comes from maestrano_connector_rails (originally 20151122162613)
2
- class CreateMaestranoConnectorRailsUserOrganizationRels < ActiveRecord::Migration
3
- def change
4
- create_table :maestrano_connector_rails_user_organization_rels do |t|
5
- t.integer :user_id
6
- t.integer :organization_id
7
-
8
- t.timestamps
9
- end
10
- add_index :maestrano_connector_rails_user_organization_rels, :organization_id, name: 'rels_orga_index'
11
- add_index :maestrano_connector_rails_user_organization_rels, :user_id, name: 'rels_user_index'
12
- end
13
- end
@@ -1,14 +0,0 @@
1
- # This migration comes from maestrano_connector_rails (originally 20151122163325)
2
- class CreateMaestranoConnectorRailsSynchronizations < ActiveRecord::Migration
3
- def change
4
- create_table :maestrano_connector_rails_synchronizations do |t|
5
- t.integer :organization_id
6
- t.string :status
7
- t.text :message
8
- t.boolean :partial, default: false
9
-
10
- t.timestamps null: false
11
- end
12
- add_index :maestrano_connector_rails_synchronizations, :organization_id, name: 'synchronization_orga_id_index'
13
- end
14
- end
@@ -1,19 +0,0 @@
1
- # This migration comes from maestrano_connector_rails (originally 20151122163449)
2
- class CreateMaestranoConnectorRailsIdMaps < ActiveRecord::Migration
3
- def change
4
- create_table :maestrano_connector_rails_id_maps do |t|
5
- t.string :connec_id
6
- t.string :connec_entity
7
- t.string :external_id
8
- t.string :external_entity
9
- t.integer :organization_id
10
- t.datetime :last_push_to_connec
11
- t.datetime :last_push_to_external
12
-
13
- t.timestamps null: false
14
- end
15
- add_index :maestrano_connector_rails_id_maps, [:connec_id, :connec_entity, :organization_id], name: 'idmap_connec_index'
16
- add_index :maestrano_connector_rails_id_maps, [:external_id, :external_entity, :organization_id], name: 'idmap_external_index'
17
- add_index :maestrano_connector_rails_id_maps, :organization_id, name: 'idmap_organization_index'
18
- end
19
- end