maestrano-connector-rails 1.3.4 → 1.3.5

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 (50) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +9 -3
  3. data/.rubocop_todo.yml +1 -18
  4. data/VERSION +1 -1
  5. data/app/jobs/maestrano/connector/rails/synchronization_job.rb +13 -2
  6. data/app/models/maestrano/connector/rails/concerns/complex_entity.rb +4 -2
  7. data/app/models/maestrano/connector/rails/concerns/entity.rb +13 -7
  8. data/app/models/maestrano/connector/rails/exceptions/entity_not_found_error.rb +3 -0
  9. data/app/models/maestrano/connector/rails/organization.rb +20 -0
  10. data/lib/generators/connector/complex_entity_generator.rb +2 -2
  11. data/lib/generators/connector/install_generator.rb +3 -3
  12. data/lib/generators/connector/templates/complex_entity_example/contact.rb +2 -1
  13. data/lib/generators/connector/templates/complex_entity_example/contact_and_lead.rb +2 -1
  14. data/lib/generators/connector/templates/complex_entity_example/contact_mapper.rb +2 -1
  15. data/lib/generators/connector/templates/complex_entity_example/lead.rb +2 -1
  16. data/lib/generators/connector/templates/complex_entity_example/lead_mapper.rb +2 -1
  17. data/lib/generators/connector/templates/complex_entity_example/person.rb +2 -1
  18. data/lib/generators/connector/templates/entity.rb +1 -0
  19. data/lib/generators/connector/templates/example_entity.rb +2 -1
  20. data/lib/generators/connector/templates/example_entity_spec.rb +1 -0
  21. data/lib/generators/connector/templates/external.rb +2 -1
  22. data/lib/generators/connector/templates/home_controller.rb +19 -30
  23. data/lib/generators/connector/templates/home_controller_spec.rb +18 -19
  24. data/lib/generators/connector/templates/oauth_controller.rb +13 -24
  25. data/lib/generators/connector/templates/shared_entities_controller.rb +4 -4
  26. data/lib/generators/connector/templates/shared_entities_controller_spec.rb +5 -5
  27. data/lib/generators/connector/templates/stylesheets/layout.sass +16 -3
  28. data/lib/generators/connector/templates/stylesheets/variables.sass +22 -4
  29. data/lib/generators/connector/templates/synchronizations_controller.rb +4 -4
  30. data/lib/generators/connector/templates/synchronizations_controller_spec.rb +4 -4
  31. data/maestrano-connector-rails.gemspec +7 -8
  32. data/release_notes.md +15 -0
  33. data/spec/dummy/tmp/cache/.keep +1 -0
  34. data/spec/factories.rb +7 -8
  35. data/spec/jobs/synchronization_job_spec.rb +34 -12
  36. data/spec/models/complex_entity_spec.rb +5 -5
  37. data/spec/models/entity_spec.rb +18 -12
  38. data/spec/spec_helper.rb +2 -2
  39. data/template/{application.yml.sample → application-sample.yml} +0 -0
  40. data/template/factories.rb +4 -5
  41. data/template/maestrano.rb +3 -3
  42. data/template/{maestrano-connector-template.rb → maestrano_connector_template.rb} +27 -25
  43. data/template/routes.rb +2 -8
  44. data/template/rubocop.yml +55 -0
  45. data/template/sidekiq.rb +8 -0
  46. data/template/spec_helper.rb +4 -3
  47. metadata +6 -7
  48. data/spec/dummy/app/controllers/admin_controller.rb +0 -48
  49. data/spec/dummy/app/controllers/home_controller.rb +0 -17
  50. data/spec/dummy/app/controllers/oauth_controller.rb +0 -45
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2a82734a77d8a8231e8a01d8c9c9e0f62e684cad
4
- data.tar.gz: 73ce17a1cacbd9f5c0c988e4c132b1f7c8769b63
3
+ metadata.gz: c4122749ba27964c095c26a00e030bdbd3b2d7fa
4
+ data.tar.gz: a48edb359406db70378f8f361ae1285ec9f51cc7
5
5
  SHA512:
6
- metadata.gz: a092e0cfcecc3f1f6745ad6ad49970a8cfdd5e0e1887f5a29f2e79fa5e23502b893e15d81e57f3d0d89e15b6392b9a5b9dee0d044177334c304913b69db4b023
7
- data.tar.gz: 9b9232cd104ec556d91ddcda3af1eeb12e3db8be65371ccc98a81b6d67b38dd5f48fb52974999eb854562416a601293b3bd3e65f3f511509288f83295076ccd7
6
+ metadata.gz: 693be8a01d2ebe2eb99679cee99352398bad9b4a0a567a78d6dbade564d37d05702137397e5ac5871f8c3095fb14e062930c34b95bf33ed83707cfbd1d626c6a
7
+ data.tar.gz: 34cadd784f2410b2dfbb44e6a05e39ed17fb097729da1d04d4f5870494dd9dd372968ea882b6c1606a1a13ce61c0482653ccea01592c3dbee0c83bb2b87b1eda
data/.rubocop.yml CHANGED
@@ -12,8 +12,6 @@ AllCops:
12
12
  - 'db/migrate/*'
13
13
  - 'bin/*'
14
14
  - 'spec/**/*'
15
- - 'template/**/*'
16
- - 'lib/generators/connector/**/*'
17
15
 
18
16
  # Enabled disabled Cops
19
17
  Style/CollectionMethods:
@@ -36,6 +34,14 @@ Style/ClassAndModuleChildren:
36
34
  Style/SpaceInsideHashLiteralBraces:
37
35
  EnforcedStyle: no_space
38
36
 
37
+ # Checks for unused block arguments
38
+ Lint/UnusedBlockArgument:
39
+ Enabled: false
40
+
41
+ # Checks for unused method arguments.
42
+ Lint/UnusedMethodArgument:
43
+ Enabled: false
44
+
39
45
  # RSpec/FilePath:
40
46
  # Exclude:
41
- # - 'spec/routing/**/*_routing_spec.rb'
47
+ # - 'spec/routing/**/*_routing_spec.rb'
data/.rubocop_todo.yml CHANGED
@@ -12,23 +12,6 @@ Lint/AssignmentInCondition:
12
12
  Exclude:
13
13
  - 'app/jobs/maestrano/connector/rails/push_to_connec_job.rb'
14
14
 
15
- # Offense count: 1
16
- # Cop supports --auto-correct.
17
- # Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments.
18
- Lint/UnusedBlockArgument:
19
- Exclude:
20
- - 'app/jobs/maestrano/connector/rails/synchronization_job.rb'
21
-
22
- # Offense count: 17
23
- # Cop supports --auto-correct.
24
- # Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods.
25
- Lint/UnusedMethodArgument:
26
- Exclude:
27
- - 'app/jobs/maestrano/connector/rails/all_synchronizations_job.rb'
28
- - 'app/models/maestrano/connector/rails/concerns/complex_entity.rb'
29
- - 'app/models/maestrano/connector/rails/concerns/entity.rb'
30
- - 'app/models/maestrano/connector/rails/concerns/external.rb'
31
-
32
15
  # Offense count: 23
33
16
  Metrics/AbcSize:
34
17
  Max: 70
@@ -45,7 +28,7 @@ Metrics/MethodLength:
45
28
  # Offense count: 2
46
29
  # Configuration parameters: CountComments.
47
30
  Metrics/ModuleLength:
48
- Max: 264
31
+ Max: 278
49
32
 
50
33
  # Offense count: 2
51
34
  # Configuration parameters: CountKeywordArgs.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.4
1
+ 1.3.5
@@ -76,6 +76,7 @@ module Maestrano::Connector::Rails
76
76
  limit = Settings.first_sync_batch_size || 50
77
77
  skip = 0
78
78
  entities_count = limit
79
+ last_first_record = nil
79
80
 
80
81
  h = {__limit: limit}
81
82
  external ? h[:__skip_connec] = true : h[:__skip_external] = true
@@ -89,7 +90,17 @@ module Maestrano::Connector::Rails
89
90
  # No more entities to fetch
90
91
  while entities_count == limit
91
92
  entity_instance.opts_merge!(__skip: skip)
92
- entities_count = perform_sync(entity_instance, last_synchronization_date, external)
93
+
94
+ perform_hash = perform_sync(entity_instance, last_synchronization_date, external)
95
+ entities_count = perform_hash[:count]
96
+
97
+ # Safety: if the connector does not implement batched calls but has exactly limit entities
98
+ # There is a risk of infinite loop
99
+ # We're comparing the first record to check that it is different
100
+ first_record = Digest::MD5.hexdigest(perform_hash[:first].to_s)
101
+ break if last_first_record && first_record == last_first_record
102
+ last_first_record = first_record
103
+
93
104
  skip += limit
94
105
  end
95
106
  end
@@ -110,7 +121,7 @@ module Maestrano::Connector::Rails
110
121
  entity_instance.push_entities_to_connec(mapped_entities[:external_entities])
111
122
  entity_instance.after_sync(last_synchronization_date)
112
123
 
113
- external ? entity_instance.class.count_entities(external_entities) : entity_instance.class.count_entities(connec_entities)
124
+ entity_instance.class.count_and_first(external ? external_entities : connec_entities)
114
125
  end
115
126
  end
116
127
  end
@@ -27,8 +27,10 @@ module Maestrano::Connector::Rails::Concerns::ComplexEntity
27
27
  names.index_by { |name| name }.with_indifferent_access
28
28
  end
29
29
 
30
- def count_entities(entities)
31
- entities.values.map(&:size).max
30
+ # For complex entities, we take the size of the biggest array
31
+ # And the first record we can find (even if it's not in the first array)
32
+ def count_and_first(entities)
33
+ {count: entities.values.map(&:size).max, first: entities.values.flatten.first}
32
34
  end
33
35
 
34
36
  def public_connec_entity_name
@@ -131,8 +131,8 @@ module Maestrano::Connector::Rails::Concerns::Entity
131
131
  # ----------------------------------------------
132
132
  # Helper methods
133
133
  # ----------------------------------------------
134
- def count_entities(entities)
135
- entities.size
134
+ def count_and_first(entities)
135
+ {count: entities.size, first: entities.first}
136
136
  end
137
137
 
138
138
  def public_connec_entity_name
@@ -313,10 +313,16 @@ module Maestrano::Connector::Rails::Concerns::Entity
313
313
  idmap.update(last_push_to_external: Time.now, message: nil)
314
314
  end
315
315
  rescue => e
316
- # Store External error
317
- Maestrano::Connector::Rails::ConnectorLogger.log('error', @organization, "Error while pushing to #{Maestrano::Connector::Rails::External.external_name}: #{e}")
318
- Maestrano::Connector::Rails::ConnectorLogger.log('debug', @organization, "Error while pushing backtrace: #{e.backtrace.join("\n\t")}")
319
- idmap.update(message: e.message.truncate(255))
316
+ # TODO: improve the flexibility by adding the option for the developer to pass a custom/gem-dependent error
317
+ if e.class == Maestrano::Connector::Rails::Exceptions::EntityNotFoundError
318
+ idmap.update!(message: "The #{external_entity_name} record has been deleted in #{Maestrano::Connector::Rails::External.external_name}. Last attempt to sync on #{Time.now}", external_inactive: true)
319
+ Rails.logger.info "The #{idmap.external_entity} - #{idmap.external_id} record has been deleted. It is now set to inactive."
320
+ else
321
+ # Store External error
322
+ Maestrano::Connector::Rails::ConnectorLogger.log('error', @organization, "Error while pushing to #{Maestrano::Connector::Rails::External.external_name}: #{e}")
323
+ Maestrano::Connector::Rails::ConnectorLogger.log('debug', @organization, "Error while pushing backtrace: #{e.backtrace.join("\n\t")}")
324
+ idmap.update(message: e.message.truncate(255))
325
+ end
320
326
  end
321
327
  nil
322
328
  end
@@ -359,7 +365,7 @@ module Maestrano::Connector::Rails::Concerns::Entity
359
365
  end
360
366
 
361
367
  def consolidate_and_map_connec_entities(connec_entities, external_entities, references, external_entity_name)
362
- connec_entities.map{|entity|
368
+ connec_entities.map { |entity|
363
369
  # Entity has been created before date filtering limit
364
370
  next nil if before_date_filtering_limit?(entity, false) && !@opts[:full_sync]
365
371
 
@@ -0,0 +1,3 @@
1
+ module Maestrano::Connector::Rails::Exceptions
2
+ class EntityNotFoundError < StandardError; end
3
+ end
@@ -78,6 +78,26 @@ module Maestrano::Connector::Rails
78
78
  save!
79
79
  end
80
80
 
81
+ def clear_omniauth
82
+ self.oauth_uid = nil
83
+ self.oauth_token = nil
84
+ self.refresh_token = nil
85
+ self.sync_enabled = false
86
+ self.save
87
+ end
88
+
89
+ def check_historical_data(checkbox_ticked)
90
+ return if self.historical_data
91
+ # checkbox_ticked is a boolean
92
+ if checkbox_ticked
93
+ self.date_filtering_limit = nil
94
+ self.historical_data = true
95
+ else
96
+ self.date_filtering_limit ||= Time.now.getlocal
97
+ end
98
+ self.save
99
+ end
100
+
81
101
  def last_three_synchronizations_failed?
82
102
  arr = synchronizations.last(3).map(&:error?)
83
103
  arr.count == 3 && arr.uniq == [true]
@@ -1,7 +1,7 @@
1
1
  module Connector
2
2
  module Generators
3
3
  class ComplexEntityGenerator < ::Rails::Generators::Base
4
- source_root File.expand_path("../templates", __FILE__)
4
+ source_root File.expand_path('../templates', __FILE__)
5
5
 
6
6
  def copy_example_files
7
7
  copy_file 'complex_entity_example/contact_and_lead.rb', 'app/models/entities/example_contact_and_lead.rb'
@@ -16,4 +16,4 @@ module Connector
16
16
  end
17
17
  end
18
18
  end
19
- end
19
+ end
@@ -1,7 +1,7 @@
1
1
  module Connector
2
2
  module Generators
3
3
  class InstallGenerator < ::Rails::Generators::Base
4
- source_root File.expand_path("../templates", __FILE__)
4
+ source_root File.expand_path('../templates', __FILE__)
5
5
 
6
6
  def maestrano_generator
7
7
  generate 'maestrano:initializer'
@@ -10,7 +10,7 @@ module Connector
10
10
  def include_helpers
11
11
  sentinel = 'class ApplicationController < ActionController::Base'
12
12
  code_lines = [
13
- "include Maestrano::Connector::Rails::SessionHelper"
13
+ 'include Maestrano::Connector::Rails::SessionHelper'
14
14
  ]
15
15
 
16
16
  in_root do
@@ -63,4 +63,4 @@ module Connector
63
63
  end
64
64
  end
65
65
  end
66
- end
66
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # TODO
2
3
  # This file is provided as an example and should be removed
3
4
  # See doc for explanation
@@ -24,4 +25,4 @@
24
25
  # def self.object_name_from_external_entity_hash(entity)
25
26
  # "#{entity['FirstName']} #{entity['LastName']}"
26
27
  # end
27
- # end
28
+ # end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # TODO
2
3
  # This file is provided as an example and should be removed
3
4
  # See documentation (https://maestrano.atlassian.net/wiki/display/DEV/Mapping+and+synchronization) for explanation
@@ -53,4 +54,4 @@
53
54
  # def external_model_to_connec_model(external_hash_of_entities)
54
55
  # return {'lead' => {'person' => external_hash_of_entities['lead']}, 'contact' => {'person' => external_hash_of_entities['contact']}}
55
56
  # end
56
- # end
57
+ # end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # TODO
2
3
  # This file is provided as an example and should be removed
3
4
  # See README for explanation
@@ -14,4 +15,4 @@
14
15
  # map from('address_work/billing/region'), to('MailingState')
15
16
  # map from('address_work/billing/postal_code'), to('MailingPostalCode')
16
17
  # map from('address_work/billing/country'), to('MailingCountry')
17
- # end
18
+ # end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # TODO
2
3
  # This file is provided as an example and should be removed
3
4
  # See README for explanation
@@ -24,4 +25,4 @@
24
25
  # def self.object_name_from_external_entity_hash(entity)
25
26
  # "#{entity['FirstName']} #{entity['LastName']}"
26
27
  # end
27
- # end
28
+ # end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # TODO
2
3
  # This file is provided as an example and should be removed
3
4
  # See README for explanation
@@ -17,4 +18,4 @@
17
18
  # map from('lead_source'), to('LeadSource')
18
19
  # map from('lead_status'), to('Status')
19
20
  # map from('lead_conversion_date'), to('ConvertedDate')
20
- # end
21
+ # end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # TODO
2
3
  # This file is provided as an example and should be removed
3
4
  # See README for explanation
@@ -24,4 +25,4 @@
24
25
  # def self.object_name_from_external_entity_hash(entity)
25
26
  # "#{entity['FirstName']} #{entity['LastName']}"
26
27
  # end
27
- # end
28
+ # end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  class Maestrano::Connector::Rails::Entity < Maestrano::Connector::Rails::EntityBase
2
3
  include Maestrano::Connector::Rails::Concerns::Entity
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # TODO
2
3
  # This file is provided as an example and should be removed
3
4
  # One such file needs to be created for each synchronizable entity,
@@ -32,4 +33,4 @@
32
33
  # map from('title'), to('Salutation')
33
34
  # map from('first_name'), to('FirstName')
34
35
  # map from('address_work/billing2/city'), to('City')
35
- # end
36
+ # end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # TODO
2
3
  # This file is provided as an example and should be removed
3
4
  # require 'spec_helper'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  class Maestrano::Connector::Rails::External
2
3
  include Maestrano::Connector::Rails::Concerns::External
3
4
 
@@ -33,4 +34,4 @@ class Maestrano::Connector::Rails::External
33
34
  # will synchronized Entities::Person and Entities::TasksList
34
35
  []
35
36
  end
36
- end
37
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  class HomeController < ApplicationController
2
3
  def index
3
4
  @organization = current_organization
@@ -7,41 +8,23 @@ class HomeController < ApplicationController
7
8
  def update
8
9
  organization = Maestrano::Connector::Rails::Organization.find_by_id(params[:id])
9
10
 
10
- if organization && is_admin?(current_user, organization)
11
- old_sync_state = organization.sync_enabled
12
-
13
- organization.synchronized_entities.keys.each do |entity|
14
- organization.synchronized_entities[entity] = !!params["#{entity}"]
15
- end
16
- organization.sync_enabled = organization.synchronized_entities.values.any?
17
-
18
- unless organization.historical_data
19
- historical_data = !!params['historical-data']
20
- if historical_data
21
- organization.date_filtering_limit = nil
22
- organization.historical_data = true
23
- else
24
- organization.date_filtering_limit ||= Time.now
25
- end
26
- end
27
-
28
- organization.save
29
-
30
- if !old_sync_state && organization.sync_enabled
31
- Maestrano::Connector::Rails::SynchronizationJob.perform_later(organization, {})
32
- flash[:info] = 'Congrats, you\'re all set up! Your data are now being synced'
33
- end
11
+ return redirect_to(:back) unless organization && is_admin?(current_user, organization)
12
+ old_sync_state = organization.sync_enabled
13
+ organization.synchronized_entities.keys.each do |entity|
14
+ organization.synchronized_entities[entity] = params[entity.to_s].present?
34
15
  end
16
+ organization.sync_enabled = organization.synchronized_entities.values.any?
17
+ organization.check_historical_data(params['historical-data'].present?)
18
+
19
+ start_synchronization(old_sync_state, organization) unless !old_sync_state && organization.sync_enabled
35
20
 
36
21
  redirect_to(:back)
37
22
  end
38
23
 
39
24
  def synchronize
40
- if is_admin
41
- Maestrano::Connector::Rails::SynchronizationJob.perform_later(current_organization, (params['opts'] || {}).merge(forced: true))
42
- flash[:info] = 'Synchronization requested'
43
- end
44
-
25
+ return redirect_to(:back) unless is_admin
26
+ Maestrano::Connector::Rails::SynchronizationJob.perform_later(current_organization, (params['opts'] || {}).merge(forced: true))
27
+ flash[:info] = 'Synchronization requested'
45
28
  redirect_to(:back)
46
29
  end
47
30
 
@@ -49,4 +32,10 @@ class HomeController < ApplicationController
49
32
  redirect_to 'https://path/to/external/app'
50
33
  end
51
34
 
52
- end
35
+ private
36
+
37
+ def start_synchronization(old_sync_state, organization)
38
+ Maestrano::Connector::Rails::SynchronizationJob.perform_later(organization, {})
39
+ flash[:info] = 'Congrats, you\'re all set up! Your data are now being synced'
40
+ end
41
+ end
@@ -1,9 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe HomeController, :type => :controller do
3
+ describe HomeController, type: :controller do
4
4
  let(:back_path) { home_index_path }
5
5
  before(:each) do
6
- request.env["HTTP_REFERER"] = back_path
6
+ request.env['HTTP_REFERER'] = back_path
7
7
  end
8
8
 
9
9
  describe 'index' do
@@ -16,26 +16,25 @@ describe HomeController, :type => :controller do
16
16
  let(:organization) { create(:organization, synchronized_entities: {'people' => false, 'item' => true}) }
17
17
  subject { put :update, id: organization.id, 'people' => true, 'item' => false, 'lala' => true }
18
18
 
19
-
20
19
  context 'when user is not admin' do
21
- before {
20
+ before do
22
21
  allow_any_instance_of(Maestrano::Connector::Rails::SessionHelper).to receive(:is_admin?).and_return(false)
23
- }
22
+ end
24
23
 
25
24
  it { expect(subject).to redirect_to back_path }
26
25
  end
27
26
 
28
27
  context 'when user is admin' do
29
- before {
28
+ before do
30
29
  allow_any_instance_of(Maestrano::Connector::Rails::SessionHelper).to receive(:is_admin?).and_return(true)
31
- }
30
+ end
32
31
 
33
32
  it { expect(subject).to redirect_to back_path }
34
33
 
35
34
  it 'updates organization synchronized_entities' do
36
35
  subject
37
36
  organization.reload
38
- expect(organization.synchronized_entities).to eq({'people' => true, 'item' => false})
37
+ expect(organization.synchronized_entities).to eq('people' => true, 'item' => false)
39
38
  end
40
39
 
41
40
  it 'updates organization sync_enabled' do
@@ -60,14 +59,14 @@ describe HomeController, :type => :controller do
60
59
  describe 'synchronize' do
61
60
  subject { post :synchronize }
62
61
  let(:organization) { create(:organization) }
63
- before {
62
+ before do
64
63
  allow_any_instance_of(Maestrano::Connector::Rails::SessionHelper).to receive(:current_organization).and_return(organization)
65
- }
64
+ end
66
65
 
67
66
  context 'when user is not admin' do
68
- before {
67
+ before do
69
68
  allow_any_instance_of(Maestrano::Connector::Rails::SessionHelper).to receive(:is_admin).and_return(false)
70
- }
69
+ end
71
70
 
72
71
  it { expect(subject).to redirect_to back_path }
73
72
 
@@ -78,9 +77,9 @@ describe HomeController, :type => :controller do
78
77
  end
79
78
 
80
79
  context 'when user is admin' do
81
- before {
80
+ before do
82
81
  allow_any_instance_of(Maestrano::Connector::Rails::SessionHelper).to receive(:is_admin).and_return(true)
83
- }
82
+ end
84
83
 
85
84
  it { expect(subject).to redirect_to back_path }
86
85
 
@@ -88,16 +87,16 @@ describe HomeController, :type => :controller do
88
87
  subject { post :synchronize, opts: {'opts' => 'some_opts'} }
89
88
 
90
89
  it 'calls perform_later with opts' do
91
- expect(Maestrano::Connector::Rails::SynchronizationJob).to receive(:perform_later).with(organization, {'opts' => 'some_opts', forced: true})
90
+ expect(Maestrano::Connector::Rails::SynchronizationJob).to receive(:perform_later).with(organization, 'opts' => 'some_opts', forced: true)
92
91
  subject
93
92
  end
94
93
  end
95
94
 
96
95
  context 'without opts' do
97
- subject { post :synchronize}
96
+ subject { post :synchronize }
98
97
 
99
98
  it 'calls perform_later with empty opts hash' do
100
- expect(Maestrano::Connector::Rails::SynchronizationJob).to receive(:perform_later).with(organization, {forced: true})
99
+ expect(Maestrano::Connector::Rails::SynchronizationJob).to receive(:perform_later).with(organization, forced: true)
101
100
  subject
102
101
  end
103
102
  end
@@ -108,7 +107,7 @@ describe HomeController, :type => :controller do
108
107
  subject { get :redirect_to_external }
109
108
 
110
109
  context 'otherwise' do
111
- it {expect(subject).to redirect_to('somewhere')}
110
+ it { expect(subject).to redirect_to('somewhere') }
112
111
  end
113
112
  end
114
- end
113
+ end