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

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: b84ee19b8cb4c3c76c762e3fdc902cc59e5e2ec6
4
- data.tar.gz: 8b828b5c3cdf10bcf1e7b65ff3991ad3f5cbc224
3
+ metadata.gz: 393f91e1248007d0b8d38c99280d466bd935f54f
4
+ data.tar.gz: d2e43d71732f2d7280d355e67484e18fc97c8b14
5
5
  SHA512:
6
- metadata.gz: 94dbd9143e6e01e37180ecf7ac329d56f1c3b88d28afc9cdb30a41c44dad5c3e1e0e884b24e2341effbfa1bb7b39b04620966300d86e62fb65e8fccb98154bf3
7
- data.tar.gz: 689d3157aa9a71533bbe9915e4a4005f2c9b4250f897452ba80a76bdccc3a8ceaf4b04d6ad96006d4829556a08734a81316f6c6fe9437200f0e1e358633ab67f
6
+ metadata.gz: e29765cb69956279f371bd227b44065d114a24cce99f1cf88242d4e5afb1e8d17cde78487b15bb866028668050660a770ae6ebbe01bb9752a64b89c2e6c447d0
7
+ data.tar.gz: a0a8dc357400da0362385decfa9e5d0432affd445611c86021bea1500621e10df1ca8f72fd2afed11fec46012d9a1331e0f427ccb4d63cb21630930aa8b15099
data/CHANGELOG.md CHANGED
@@ -6,7 +6,9 @@
6
6
  ### Migration guide
7
7
  * Follow migration steps up to framework version 1.5.0
8
8
  * Replace ocurrences of `@organizations` with `current_organization` in `home_index.haml`
9
- * Developer Platform registration to be detailed
9
+ * In spec_helper.rb add the line `require 'maestrano_connector_rails/factories.rb'`
10
+
11
+ ### Developer Platform registration to be detailed
10
12
 
11
13
  ## 1.5.0
12
14
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.0.pre.RC10
1
+ 2.0.0.pre.RC11
@@ -207,9 +207,6 @@ module Maestrano::Connector::Rails::Concerns::Entity
207
207
  query_params = {}
208
208
  query_params[:$orderby] = @opts[:$orderby] if @opts[:$orderby]
209
209
 
210
- # Fetch first page
211
- page_number = 0
212
-
213
210
  batched_fetch = @opts[:__limit] && @opts[:__skip]
214
211
  if batched_fetch
215
212
  query_params[:$top] = @opts[:__limit]
@@ -224,7 +221,7 @@ module Maestrano::Connector::Rails::Concerns::Entity
224
221
 
225
222
  Maestrano::Connector::Rails::ConnectorLogger.log('debug', @organization, "entity=#{self.class.connec_entity_name}, fetching data with #{query_params.to_query}")
226
223
  uri = "#{self.class.normalized_connec_entity_name}?#{query_params.to_query}"
227
- response_hash = fetch_connec(uri, 0)
224
+ response_hash = fetch_connec(uri)
228
225
  entities = response_hash[self.class.normalized_connec_entity_name]
229
226
  entities = [entities] if self.class.singleton?
230
227
 
@@ -232,11 +229,10 @@ module Maestrano::Connector::Rails::Concerns::Entity
232
229
  unless batched_fetch
233
230
  # Fetch subsequent pages
234
231
  while response_hash['pagination'] && response_hash['pagination']['next']
235
- page_number += 1
236
232
  # ugly way to convert https://api-connec/api/v2/group_id/organizations?next_page_params to /organizations?next_page_params
237
233
  next_page = response_hash['pagination']['next'].gsub(/^(.*)\/#{self.class.normalized_connec_entity_name}/, self.class.normalized_connec_entity_name)
238
234
 
239
- response_hash = fetch_connec(next_page, page_number)
235
+ response_hash = fetch_connec(next_page)
240
236
  entities.concat response_hash[self.class.normalized_connec_entity_name]
241
237
  end
242
238
  end
@@ -604,13 +600,15 @@ module Maestrano::Connector::Rails::Concerns::Entity
604
600
  {entity: map_to_connec(external_entity, idmap.last_push_to_connec.nil?), idmap: idmap}
605
601
  end
606
602
 
607
- def fetch_connec(uri, page_number)
603
+ def fetch_connec(uri)
604
+ Maestrano::Connector::Rails::ConnectorLogger.log('debug', @organization, "Fetching data from connec entity=#{self.class.connec_entity_name}, url=#{uri}")
608
605
  response = @connec_client.get(uri)
609
- raise "No data received from Connec! when trying to fetch page #{page_number} of #{self.class.normalized_connec_entity_name}" unless response && !response.body.blank?
606
+
607
+ raise "No data received from Connec! when trying to fetch #{self.class.normalized_connec_entity_name}" unless response && !response.body.blank?
610
608
 
611
609
  response_hash = JSON.parse(response.body)
612
- Maestrano::Connector::Rails::ConnectorLogger.log('debug', @organization, "Received page #{page_number} for entity=#{self.class.connec_entity_name}, response=#{response_hash}")
613
- raise "Received unrecognized Connec! data when trying to fetch page #{page_number} of #{self.class.normalized_connec_entity_name}: #{response_hash}" unless response_hash[self.class.normalized_connec_entity_name]
610
+ Maestrano::Connector::Rails::ConnectorLogger.log('debug', @organization, "Received response for entity=#{self.class.connec_entity_name}, response=#{response_hash}")
611
+ raise "Received unrecognized Connec! data when trying to fetch #{self.class.normalized_connec_entity_name}: #{response_hash}" unless response_hash[self.class.normalized_connec_entity_name]
614
612
 
615
613
  response_hash
616
614
  end
@@ -2,9 +2,8 @@ require 'spec_helper'
2
2
 
3
3
  describe HomeController, type: :controller do
4
4
  let(:back_path) { home_index_path }
5
- before(:each) do
6
- request.env['HTTP_REFERER'] = back_path
7
- end
5
+
6
+ before(:each) { request.env['HTTP_REFERER'] = back_path }
8
7
 
9
8
  describe 'index' do
10
9
  subject { get :index }
@@ -13,21 +12,22 @@ describe HomeController, type: :controller do
13
12
  end
14
13
 
15
14
  describe 'update' do
15
+ let(:user) { create(:user) }
16
16
  let(:organization) { create(:organization, synchronized_entities: {'people' => false, 'item' => true}) }
17
+
18
+ before { allow_any_instance_of(Maestrano::Connector::Rails::SessionHelper).to receive(:current_user).and_return(user) }
19
+ before { allow_any_instance_of(Maestrano::Connector::Rails::SessionHelper).to receive(:current_organization).and_return(organization) }
20
+
17
21
  subject { put :update, id: organization.id, 'people' => true, 'item' => false, 'lala' => true }
18
22
 
19
23
  context 'when user is not admin' do
20
- before do
21
- allow_any_instance_of(Maestrano::Connector::Rails::SessionHelper).to receive(:is_admin?).and_return(false)
22
- end
24
+ before { allow_any_instance_of(Maestrano::Connector::Rails::SessionHelper).to receive(:is_admin).and_return(false) }
23
25
 
24
26
  it { expect(subject).to redirect_to back_path }
25
27
  end
26
28
 
27
29
  context 'when user is admin' do
28
- before do
29
- allow_any_instance_of(Maestrano::Connector::Rails::SessionHelper).to receive(:is_admin?).and_return(true)
30
- end
30
+ before { allow_any_instance_of(Maestrano::Connector::Rails::SessionHelper).to receive(:is_admin).and_return(true) }
31
31
 
32
32
  it { expect(subject).to redirect_to back_path }
33
33
 
@@ -57,16 +57,16 @@ describe HomeController, type: :controller do
57
57
  end
58
58
 
59
59
  describe 'synchronize' do
60
+ let(:user) { create(:user) }
61
+ let(:organization) { create(:organization, synchronized_entities: {'people' => false, 'item' => true}) }
62
+
63
+ before { allow_any_instance_of(Maestrano::Connector::Rails::SessionHelper).to receive(:current_user).and_return(user) }
64
+ before { allow_any_instance_of(Maestrano::Connector::Rails::SessionHelper).to receive(:current_organization).and_return(organization) }
65
+
60
66
  subject { post :synchronize }
61
- let(:organization) { create(:organization) }
62
- before do
63
- allow_any_instance_of(Maestrano::Connector::Rails::SessionHelper).to receive(:current_organization).and_return(organization)
64
- end
65
67
 
66
68
  context 'when user is not admin' do
67
- before do
68
- allow_any_instance_of(Maestrano::Connector::Rails::SessionHelper).to receive(:is_admin).and_return(false)
69
- end
69
+ before { allow_any_instance_of(Maestrano::Connector::Rails::SessionHelper).to receive(:is_admin).and_return(false) }
70
70
 
71
71
  it { expect(subject).to redirect_to back_path }
72
72
 
@@ -77,9 +77,7 @@ describe HomeController, type: :controller do
77
77
  end
78
78
 
79
79
  context 'when user is admin' do
80
- before do
81
- allow_any_instance_of(Maestrano::Connector::Rails::SessionHelper).to receive(:is_admin).and_return(true)
82
- end
80
+ before { allow_any_instance_of(Maestrano::Connector::Rails::SessionHelper).to receive(:is_admin).and_return(true) }
83
81
 
84
82
  it { expect(subject).to redirect_to back_path }
85
83
 
@@ -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 2.0.0.pre.RC10 ruby lib
5
+ # stub: maestrano-connector-rails 2.0.0.pre.RC11 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.RC10"
9
+ s.version = "2.0.0.pre.RC11"
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"]
13
13
  s.authors = ["Maestrano"]
14
- s.date = "2016-10-12"
14
+ s.date = "2016-10-13"
15
15
  s.description = "Maestrano is the next generation marketplace for SME applications. See https://sme.maestrano.com for details."
16
16
  s.email = "developers@maestrano.com"
17
17
  s.executables = ["rails"]
@@ -76,7 +76,6 @@ after_bundle do
76
76
  remove_file 'app/assets/stylesheets/application.css'
77
77
  remove_file 'config/routes.rb'
78
78
  copy_file 'spec_helper.rb', 'spec/spec_helper.rb'
79
- copy_file 'factories.rb', 'spec/factories.rb'
80
79
  copy_file 'routes.rb', 'config/routes.rb'
81
80
 
82
81
  # Heroku and uat
@@ -8,6 +8,7 @@ require File.expand_path('../../config/environment', __FILE__)
8
8
  require 'rspec/rails'
9
9
  require 'factory_girl_rails'
10
10
  require 'shoulda/matchers'
11
+ require 'maestrano_connector_rails/factories.rb'
11
12
 
12
13
  Rails.backtrace_cleaner.remove_silencers!
13
14
 
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: 2.0.0.pre.RC10
4
+ version: 2.0.0.pre.RC11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maestrano
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-12 00:00:00.000000000 Z
11
+ date: 2016-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails