maestrano-connector-rails 1.3.1 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6f89f758823b4cd6fa2ad8124eb8764c217c459c
4
- data.tar.gz: 6302aa155673536e7d4db81abef9e74972c02f0e
3
+ metadata.gz: cfff81420a6741ea4266fed785dce4f76c29c690
4
+ data.tar.gz: fdd3b60473284591c2eb525cc18c262e9d04d20b
5
5
  SHA512:
6
- metadata.gz: 19f2d1ae020d5f16c44224c3a8ee26d5e8ac41fc69fb55f7fe6a88dcb6c52254e912c0a2ddf69caee54667aeffdcb055dee6d53883685c5c2ab1d41855878b9b
7
- data.tar.gz: a0d412871c75c0c71ff661c20f13023b8b26b7c1a5683ee84c6643eed720ddff0e13829224c549f0c5c52fb5390718a7af3e0489dfe94a4f3249be31c0272116
6
+ metadata.gz: 7caeee0e3b32d1fb42b2003a2bcfbf8fc9b326f9839d0c4b538eca420f6b582ba38f106c6a6d1cd7328abed02642337443251de698024440d3334d936f1c15e1
7
+ data.tar.gz: 5ecc8fe7963ef79db58d4def70cca3bb709f9f585500d76b0179a410e1ddcc1a542792ffef94e87c6843b9633a1f70c5a6236bbccbd77308b86d813d47309510
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.1
1
+ 1.3.2
@@ -30,6 +30,20 @@ module Maestrano::Connector::Rails::Concerns::ComplexEntity
30
30
  def count_entities(entities)
31
31
  entities.values.map(&:size).max
32
32
  end
33
+
34
+ def public_connec_entity_name
35
+ public_name(formatted_connec_entities_names)
36
+ end
37
+
38
+ def public_external_entity_name
39
+ public_name(formatted_external_entities_names)
40
+ end
41
+
42
+ def public_name(formatted_names)
43
+ names = formatted_names.keys.map(&:pluralize)
44
+ return names.first.humanize if names.size == 1
45
+ (names[0..-2].join(', ') + " and #{names.last}").humanize
46
+ end
33
47
  end
34
48
 
35
49
  # input : {
@@ -134,6 +134,14 @@ module Maestrano::Connector::Rails::Concerns::Entity
134
134
  def count_entities(entities)
135
135
  entities.size
136
136
  end
137
+
138
+ def public_connec_entity_name
139
+ connec_entity_name.pluralize
140
+ end
141
+
142
+ def public_external_entity_name
143
+ external_entity_name.pluralize
144
+ end
137
145
  end
138
146
 
139
147
  # ==============================================
@@ -44,6 +44,19 @@ module Maestrano::Connector::Rails
44
44
  #===================================
45
45
  serialize :synchronized_entities
46
46
 
47
+ def displayable_synchronized_entities
48
+ result = {}
49
+ synchronized_entities.each do |entity, boolean|
50
+ begin
51
+ clazz = "Entities::#{entity.to_s.titleize.split.join}".constantize
52
+ rescue
53
+ next
54
+ end
55
+ result[entity] = {value: boolean, connec_name: clazz.public_connec_entity_name, external_name: clazz.public_external_entity_name}
56
+ end
57
+ result
58
+ end
59
+
47
60
  def add_member(user)
48
61
  user_organization_rels.create(user: user) if tenant == user.tenant && !member?(user)
49
62
  end
@@ -8,4 +8,9 @@ function historicalDataDisplay()
8
8
  document.getElementById('historical-data-display-unchecked').style.display = 'block';
9
9
  document.getElementById('historical-data-display-checked').style.display = 'none';
10
10
  }
11
- }
11
+ }
12
+
13
+
14
+ $(function () {
15
+ $('[data-toggle="tooltip"]').tooltip()
16
+ })
@@ -1,6 +1,7 @@
1
1
  class HomeController < ApplicationController
2
2
  def index
3
3
  @organization = current_organization
4
+ @displayable_synchronized_entities = @organization.displayable_synchronized_entities if @organization
4
5
  end
5
6
 
6
7
  def update
@@ -42,35 +42,47 @@
42
42
  .row.link-step{class: "#{(@organization.sync_enabled && @organization.synchronized_entities.values.any?) ? 'done' : 'todo'}"}
43
43
  = form_tag home_update_path(id: @organization.id), method: :put do
44
44
  .col-md-1.text-center.link-step-number
45
- %span.badge.link-step-badge
46
- 2
45
+ %span.badge.link-step-badge 2
47
46
  .col-md-9.link-step-description
48
- %h
49
- You can customize which entities are synchronized by the connector:
47
+ %h You can customize which entities are synchronized by the connector:
48
+ .spacer1
49
+ .row
50
+ .col-md-11.col-md-offset-1.center
51
+ .col-md-4.col-md-offset-1
52
+ ApplicationName wording
53
+ .col-md-4
54
+ Universal wording
50
55
  .spacer1
51
56
  .row
52
57
  .col-md-11.col-md-offset-1
53
- - @organization.synchronized_entities.each do |k, v|
58
+ - @displayable_synchronized_entities.each do |k, v|
54
59
  .row.sync-entity
55
60
  .col-md-1.link-step-action
56
- %input{type: "checkbox", id: "#{k}", name: "#{k}", checked: v}
57
- .col-md-6{style: 'padding-top: 5px;'}
58
- %label{:for => "#{k}"} #{k.to_s.humanize.pluralize}
59
- - if is_admin
60
- .col-md-5.text-right
61
+ %input{type: "checkbox", id: "#{k}", name: "#{k}", checked: v[:value]}
62
+ %label.col-md-8{:for => "#{k}", style: 'padding-top: 5px;'}
63
+ .col-md-6
64
+ #{v[:external_name]}
65
+ .col-md-6
66
+ #{v[:connec_name]}
67
+ -if is_admin
68
+ .col-md-3.text-right
61
69
  - if v && @organization.oauth_uid && @organization.sync_enabled
62
- = link_to "Force a synchronization for #{k.to_s.humanize.pluralize} only", home_synchronize_path(opts: {only_entities: [k.to_s]}), method: :post, class: 'btn btn-warning btn-sm'
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
+
72
+ .spacer2
73
+ .row
74
+ %h Chose whether to synchronize your historical data:
63
75
  .spacer1
64
76
  .row
65
- .col-md-4
77
+ .col-md-4.col-md-offset-1
66
78
  %label{:for => 'historical-data'} Synchronize my historical data
67
- .col-md-2
79
+ .col-md-1
68
80
  %input{type: 'checkbox', id: 'historical-data', name: 'historical-data', checked: @organization.historical_data, onchange: 'historicalDataDisplay();', disabled: @organization.historical_data}
69
81
  .col-md-6
70
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
71
83
  %small#historical-data-display-checked{style: "display: #{!@organization.historical_data ? 'none' : 'block'}"}
72
- Synchronizing your historical data will share all data, including the one created prior to #{Time.now.utc} in ApplicationName. This action is <strong>not reversible</strong>. Want to know more? Check
73
- = link_to 'here', 'https://maestrano.atlassian.net/wiki/display/UKB/How+Connec%21+manages+Historical+Data+Sharing'
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
+
74
86
  .spacer1
75
87
  .row
76
88
  .col-md-2.col-md-offset-10.text-center.link-step-action
@@ -6,6 +6,7 @@
6
6
  %title ApplicationName Connector
7
7
  = stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true
8
8
  = javascript_include_tag 'application', 'data-turbolinks-track' => true
9
+ %script{src: 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js', integrity: 'sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa', crossorigin: 'anonymous'}
9
10
  = csrf_meta_tags
10
11
  %body
11
12
  .navbar.navbar-fixed-top.navbar-inverse
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: maestrano-connector-rails 1.3.1 ruby lib
5
+ # stub: maestrano-connector-rails 1.3.2 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "maestrano-connector-rails"
9
- s.version = "1.3.1"
9
+ s.version = "1.3.2"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Pierre Berard"]
14
- s.date = "2016-07-26"
14
+ s.date = "2016-07-27"
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"]
data/release_notes.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 1.3.1
2
+
3
+ ### Fixes
4
+ * Fix method in organization class that caused issue with authentication
5
+
1
6
  ## 1.3.0
2
7
  * Methods `create_external_entity` and `update_external_entity` should now returns the created/updated entity
3
8
  * Home page should now include a link populated from `external.rb` to create an account
@@ -22,6 +22,42 @@ describe Maestrano::Connector::Rails::ComplexEntity do
22
22
  expect(subject.count_entities(entities)).to eql(39)
23
23
  end
24
24
  end
25
+
26
+ describe 'public_connec_entity_name' do
27
+ it 'calls public name' do
28
+ allow(subject).to receive(:formatted_connec_entities_names).and_return(a: 2)
29
+ expect(subject).to receive(:public_name).with(a: 2)
30
+ subject.public_connec_entity_name
31
+ end
32
+ end
33
+ describe 'public_external_entity_name' do
34
+ it 'calls public name' do
35
+ allow(subject).to receive(:formatted_external_entities_names).and_return(a: 2)
36
+ expect(subject).to receive(:public_name).with(a: 2)
37
+ subject.public_external_entity_name
38
+ end
39
+ end
40
+
41
+
42
+ describe 'public_name' do
43
+ context 'when one entity' do
44
+ it 'returns the pluralized entity name' do
45
+ expect(subject.public_name({'sales_order' => 'Sales order'})).to eql('Sales orders')
46
+ end
47
+ end
48
+
49
+ context 'when two entities' do
50
+ it 'returns the pluralized entity names separeted by a and' do
51
+ expect(subject.public_name({'Sales order' => 'Sales order', 'Purchase order' => 'Purchase order'})).to eql('Sales orders and purchase orders')
52
+ end
53
+ end
54
+
55
+ context 'when more than two' do
56
+ it 'returns the pluralized entity names separeted by commas and a and' do
57
+ expect(subject.public_name({'Sales order' => 'Sales order', 'Purchase order' => 'Purchase order', 'Order' => 'Order'})).to eql('Sales orders, purchase orders and orders')
58
+ end
59
+ end
60
+ end
25
61
  end
26
62
 
27
63
  describe 'instance methods' do
@@ -116,6 +116,20 @@ describe Maestrano::Connector::Rails::Entity do
116
116
  expect(subject.count_entities([*1..27])).to eql(27)
117
117
  end
118
118
  end
119
+
120
+ describe 'public_connec_entity_name' do
121
+ it 'returns the connec_entity_name' do
122
+ allow(subject).to receive(:connec_entity_name).and_return('tree')
123
+ expect(subject.public_connec_entity_name).to eql('trees')
124
+ end
125
+ end
126
+
127
+ describe 'public_external_entity_name' do
128
+ it 'returns the external_entity_name' do
129
+ allow(subject).to receive(:external_entity_name).and_return('tree')
130
+ expect(subject.public_external_entity_name).to eql('trees')
131
+ end
132
+ end
119
133
  end
120
134
 
121
135
  describe 'instance methods' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maestrano-connector-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pierre Berard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-26 00:00:00.000000000 Z
11
+ date: 2016-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails