maestrano-connector-rails 2.0.0.pre.RC9 → 2.0.0.pre.RC10

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e4034931c4f557a653f429fe27c03144246429d3
4
- data.tar.gz: 8ac0745b563b712d1858bc4a0ea952d033a08a09
3
+ metadata.gz: b84ee19b8cb4c3c76c762e3fdc902cc59e5e2ec6
4
+ data.tar.gz: 8b828b5c3cdf10bcf1e7b65ff3991ad3f5cbc224
5
5
  SHA512:
6
- metadata.gz: 9c2c00231f6c47fd978dce08bb9750118314497f386d5c9c99b5d34c4e927bd92bf66e6416fbcbb2e8a41d7425a2d599e7aafdb4e095c48280438552c7ed0e2a
7
- data.tar.gz: f3cfec868108174a4de89d53803987d1e8058f8561c4eb0bff59cb46685e36dfa852ae0def32e58fbedbcc334e72ed4c20a2acedf34ca1464c769bbfa9433681
6
+ metadata.gz: 94dbd9143e6e01e37180ecf7ac329d56f1c3b88d28afc9cdb30a41c44dad5c3e1e0e884b24e2341effbfa1bb7b39b04620966300d86e62fb65e8fccb98154bf3
7
+ data.tar.gz: 689d3157aa9a71533bbe9915e4a4005f2c9b4250f897452ba80a76bdccc3a8ceaf4b04d6ad96006d4829556a08734a81316f6c6fe9437200f0e1e358633ab67f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## 2.0.0
2
+
3
+ ### Features
4
+ * Configuration driven from the [Maestrano Developer Platform](https://dev-platform.maestrano.com)
5
+
6
+ ### Migration guide
7
+ * Follow migration steps up to framework version 1.5.0
8
+ * Replace ocurrences of `@organizations` with `current_organization` in `home_index.haml`
9
+ * Developer Platform registration to be detailed
10
+
1
11
  ## 1.5.0
2
12
 
3
13
  ### Breaking changes
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.0.pre.RC9
1
+ 2.0.0.pre.RC10
@@ -38,7 +38,7 @@ module Maestrano::Connector::Rails
38
38
  validates :name, presence: true
39
39
  validates :tenant, presence: true
40
40
  validates :uid, uniqueness: {scope: :tenant}
41
- validates :oauth_uid, uniqueness: {message: 'This account has already been linked'}
41
+ validates :oauth_uid, uniqueness: {allow_blank: true, message: 'This account has already been linked'}
42
42
 
43
43
  #===================================
44
44
  # Serialized field
@@ -1,25 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
  class HomeController < ApplicationController
3
- def index
4
- @organization = current_organization
5
- @displayable_synchronized_entities = @organization.displayable_synchronized_entities if @organization
6
- end
7
-
8
3
  def update
9
- organization = Maestrano::Connector::Rails::Organization.find_by_id(params[:id])
10
- return redirect_to(:back) unless organization && is_admin?(current_user, organization)
4
+ return redirect_to(:back) unless is_admin
11
5
 
12
6
  # Update list of entities to synchronize
13
- organization.synchronized_entities.keys.each do |entity|
14
- organization.synchronized_entities[entity] = params[entity.to_s].present?
7
+ current_organization.synchronized_entities.keys.each do |entity|
8
+ current_organization.synchronized_entities[entity] = params[entity.to_s].present?
15
9
  end
16
- organization.sync_enabled = organization.synchronized_entities.values.any?
17
- organization.enable_historical_data(params['historical-data'].present?)
18
- trigger_sync = organization.sync_enabled && organization.sync_enabled_changed?
19
- organization.save
10
+ current_organization.sync_enabled = current_organization.synchronized_entities.values.any?
11
+ current_organization.enable_historical_data(params['historical-data'].present?)
12
+ trigger_sync = current_organization.sync_enabled && current_organization.sync_enabled_changed?
13
+ current_organization.save
20
14
 
21
15
  # Trigger sync only if the sync has been enabled
22
- start_synchronization(organization) if trigger_sync
16
+ start_synchronization if trigger_sync
23
17
 
24
18
  redirect_to(:back)
25
19
  end
@@ -38,8 +32,8 @@ class HomeController < ApplicationController
38
32
 
39
33
  private
40
34
 
41
- def start_synchronization(organization)
42
- Maestrano::Connector::Rails::SynchronizationJob.perform_later(organization.id, {})
35
+ def start_synchronization
36
+ Maestrano::Connector::Rails::SynchronizationJob.perform_later(current_organization.id, {})
43
37
  flash[:info] = 'Congrats, you\'re all set up! Your data are now being synced'
44
38
  end
45
39
  end
@@ -6,8 +6,8 @@
6
6
  .col-md-10.col-md-offset-2
7
7
  %h2 ApplicationName Connector
8
8
  %p
9
- -if @organization
10
- Link your company <strong>#{@organization.name} (#{@organization.uid})</strong> to ApplicationName to get your business in synch. Check the status of your connection on this screen.
9
+ -if current_organization
10
+ Link your company <strong>#{current_organization.name} (#{current_organization.uid})</strong> to ApplicationName to get your business in synch. Check the status of your connection on this screen.
11
11
  -else
12
12
  Link your account to ApplicationName to get your business in synch. Check the status of your connection on this screen.
13
13
 
@@ -18,29 +18,29 @@
18
18
  .col-md-12.alert.alert-warning
19
19
  Only administrators can modify the application settings
20
20
 
21
- .row.link-step{class: "#{@organization.oauth_uid ? 'done' : 'todo'}"}
21
+ .row.link-step{class: "#{current_organization.oauth_uid ? 'done' : 'todo'}"}
22
22
  .col-md-1.text-center.link-step-number
23
23
  %span.badge.link-step-badge
24
24
  1
25
25
  .col-md-6.link-step-description
26
26
  %h
27
- - if @organization.oauth_uid
28
- Your ApplicationName account <strong>#{@organization.oauth_name} (#{@organization.oauth_uid})</strong> is currently linked
27
+ - if current_organization.oauth_uid
28
+ Your ApplicationName account <strong>#{current_organization.oauth_name} (#{current_organization.oauth_uid})</strong> is currently linked
29
29
  - else
30
30
  Your ApplicationName account is not linked
31
31
  .col-md-2.col-md-offset-3.text-center.link-step-action
32
- - if @organization.oauth_uid
33
- = link_to "Disconnect", signout_omniauth_path(organization_id: @organization.id), class: "btn btn-warning btn-lg #{is_admin ? '' : 'disabled'}"
32
+ - if current_organization.oauth_uid
33
+ = link_to "Disconnect", signout_omniauth_path(organization_id: current_organization.id), class: "btn btn-warning btn-lg #{is_admin ? '' : 'disabled'}"
34
34
  - else
35
35
  - if is_admin
36
- = link_to "Link to ApplicationName", "/auth/ApplicationName/request?org_uid=#{@organization.uid}", class: 'btn btn-warning btn-lg'
36
+ = link_to "Link to ApplicationName", "/auth/ApplicationName/request?org_uid=#{current_organization.uid}", class: 'btn btn-warning btn-lg'
37
37
  %br
38
38
  %small If you don’t have an account #{link_to 'create yours here', Maestrano::Connector::Rails::External.create_account_link(current_organization || nil)}
39
39
 
40
40
  .spacer1
41
41
 
42
- .row.link-step{class: "#{(@organization.sync_enabled && @organization.synchronized_entities.values.any?) ? 'done' : 'todo'}"}
43
- = form_tag home_update_path(id: @organization.id), method: :put do
42
+ .row.link-step{class: "#{(current_organization.sync_enabled && current_organization.synchronized_entities.values.any?) ? 'done' : 'todo'}"}
43
+ = form_tag home_update_path(id: current_organization.id), method: :put do
44
44
  .col-md-1.text-center.link-step-number
45
45
  %span.badge.link-step-badge 2
46
46
  .col-md-9.link-step-description
@@ -55,7 +55,7 @@
55
55
  .spacer1
56
56
  .row
57
57
  .col-md-11.col-md-offset-1
58
- - @displayable_synchronized_entities.each do |k, v|
58
+ - current_organization.displayable_synchronized_entities.each do |k, v|
59
59
  .row.sync-entity
60
60
  .col-md-1.link-step-action
61
61
  %input{type: "checkbox", id: "#{k}", name: "#{k}", checked: v[:value]}
@@ -66,7 +66,7 @@
66
66
  #{v[:connec_name]}
67
67
  -if is_admin
68
68
  .col-md-3.text-right
69
- - if v && @organization.oauth_uid && @organization.sync_enabled
69
+ - if v && current_organization.oauth_uid && current_organization.sync_enabled
70
70
  = link_to 'Force a synchronization', home_synchronize_path(opts: {only_entities: [k.to_s]}), method: :post, class: 'btn btn-warning btn-sm', title: "Force a synchronization for #{v[:external_name]} only", 'data-toggle' => 'tooltip', 'data-placement' => 'right'
71
71
 
72
72
  .spacer2
@@ -77,18 +77,18 @@
77
77
  .col-md-4.col-md-offset-1
78
78
  %label{:for => 'historical-data'} Synchronize my historical data
79
79
  .col-md-1
80
- %input{type: 'checkbox', id: 'historical-data', name: 'historical-data', checked: @organization.historical_data, onchange: 'historicalDataDisplay();', disabled: @organization.historical_data}
80
+ %input{type: 'checkbox', id: 'historical-data', name: 'historical-data', checked: current_organization.historical_data, onchange: 'historicalDataDisplay();', disabled: current_organization.historical_data}
81
81
  .col-md-6
82
- %small#historical-data-display-unchecked{style: "display: #{@organization.historical_data ? 'none' : 'block'}"} Only data created after #{(@organization.date_filtering_limit && @organization.date_filtering_limit.utc || Time.now.utc).to_formatted_s(:long_ordinal)} will be synchronized
83
- %small#historical-data-display-checked{style: "display: #{!@organization.historical_data ? 'none' : 'block'}"}
82
+ %small#historical-data-display-unchecked{style: "display: #{current_organization.historical_data ? 'none' : 'block'}"} Only data created after #{(current_organization.date_filtering_limit && current_organization.date_filtering_limit.utc || Time.now.utc).to_formatted_s(:long_ordinal)} will be synchronized
83
+ %small#historical-data-display-checked{style: "display: #{!current_organization.historical_data ? 'none' : 'block'}"}
84
84
  Synchronizing your historical data will share all data in ApplicationName. This action is not reversible. Want to know more? Check #{link_to 'here', 'https://maestrano.atlassian.net/wiki/display/UKB/How+Connec%21+manages+Historical+Data+Sharing'}
85
-
85
+
86
86
  .spacer1
87
87
  .row
88
88
  .col-md-2.col-md-offset-10.text-center.link-step-action
89
- =submit_tag "#{@organization.sync_enabled ? 'Update' : 'Start synchronizing!'}", class: "btn btn-lg btn-warning #{@organization.oauth_uid ? '' : 'disabled'} text-sm"
89
+ =submit_tag "#{current_organization.sync_enabled ? 'Update' : 'Start synchronizing!'}", class: "btn btn-lg btn-warning #{current_organization.oauth_uid ? '' : 'disabled'} text-sm"
90
90
 
91
- -if @organization.oauth_uid && @organization.sync_enabled
91
+ -if current_organization.oauth_uid && current_organization.sync_enabled
92
92
  .spacer2
93
93
  .row
94
94
  .col-md-4.col-md-offset-4.text-center
@@ -14,19 +14,17 @@ class OauthController < ApplicationController
14
14
  end
15
15
 
16
16
  def create_omniauth
17
- org_uid = '' # TODO
18
- organization = Maestrano::Connector::Rails::Organization.find_by_uid_and_tenant(org_uid, current_user.tenant)
19
-
20
- return redirect_to root_url unless organization && is_admin?(current_user, organization)
17
+ return redirect_to root_url unless is_admin
21
18
 
22
19
  # TODO
23
- # Update organization with oauth params
20
+ # Update current_organization with oauth params
24
21
  # Should at least set oauth_uid, oauth_token and oauth_provider
25
22
  end
26
23
 
27
24
  def destroy_omniauth
28
- organization = Maestrano::Connector::Rails::Organization.find_by_id(params[:organization_id])
29
- organization.clear_omniauth if organization && is_admin?(current_user, organization)
25
+ return redirect_to root_url unless is_admin
26
+
27
+ current_organization.clear_omniauth
30
28
 
31
29
  redirect_to root_url
32
30
  end
@@ -2,11 +2,11 @@
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 2.0.0.pre.RC9 ruby lib
5
+ # stub: maestrano-connector-rails 2.0.0.pre.RC10 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "maestrano-connector-rails"
9
- s.version = "2.0.0.pre.RC9"
9
+ s.version = "2.0.0.pre.RC10"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
@@ -31,6 +31,12 @@ describe Maestrano::Connector::Rails::Organization do
31
31
  organization2 = build(:organization, oauth_provider: 'myapp', oauth_uid: 'ABC')
32
32
  expect(organization2).not_to be_valid
33
33
  end
34
+
35
+ it 'allows several organizations without oauth UID' do
36
+ organization1 = create(:organization, oauth_provider: 'myapp', oauth_uid: nil)
37
+ organization2 = build(:organization, oauth_provider: 'myapp', oauth_uid: nil)
38
+ expect(organization2).to be_valid
39
+ end
34
40
  end
35
41
 
36
42
  describe "instance methods" do
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: 2.0.0.pre.RC9
4
+ version: 2.0.0.pre.RC10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maestrano