forest_liana 7.5.0 → 7.5.1

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
  SHA256:
3
- metadata.gz: 70e79aed5a598ec4ac195b6281431084b65bac321fba53477944e5050e3e9e09
4
- data.tar.gz: ecfb92ede45086a4b81b17d4d6d6ac4042a3f88bd1b791a1eec8d497a764e12e
3
+ metadata.gz: c97d05c2880b945fbcf8dedbdc4f6b5a131bd2554fbe6cc96893f138605ee251
4
+ data.tar.gz: 436dbead1e46549772e63a53d1b24effa6c0f66e49bb2b8829bded39b3c9efdc
5
5
  SHA512:
6
- metadata.gz: 70e36b8a47900a631c1aef01dfffad903817dbd97d73dde936ef047734204c5d316f37faf5aa9a0ce79a263aa911a1868fe32e06e162a52094d8370da3ab6d76
7
- data.tar.gz: 9840f9d3a40822447b348880cc9976be797e254ceda1e779c92d2552f5e51cf6fbcebf7a21ef988162cf4cdf3fcb66a2a701062e6dbe8fbb9af3b8d4dac42996
6
+ metadata.gz: ae51cf5c7bbbd52021d604f871de5f880a6de198fd08da6c09f9b1255925a5174e26a10baa2dfa59e6380970d7400dc3b75ac4376e32f9a6e9146f74e0572ff0
7
+ data.tar.gz: 297718c752c3d6522295a6a513ed89c679b20c57c3d66f6ee3997a32ed5f34fdbf6deaa4bbbaa8d062bd09689c5cc8aef33d895a741772e669cc1fadf455466b
@@ -90,6 +90,10 @@ module ForestLiana
90
90
  head :internal_server_error
91
91
  end
92
92
 
93
+ def deactivate_count_response
94
+ render serializer: nil, json: { meta: { count: 'deactivated '} }
95
+ end
96
+
93
97
  private
94
98
 
95
99
  def force_utf8_encoding(json)
@@ -1,11 +1,11 @@
1
1
  module ForestLiana
2
2
  class AssociationsController < ForestLiana::ApplicationController
3
3
  if Rails::VERSION::MAJOR < 4
4
- before_filter :find_resource
5
- before_filter :find_association
4
+ before_filter :find_resource, except: :count
5
+ before_filter :find_association, except: :count
6
6
  else
7
- before_action :find_resource
8
- before_action :find_association
7
+ before_action :find_resource, except: :count
8
+ before_action :find_association, except: :count
9
9
  end
10
10
 
11
11
  def index
@@ -25,6 +25,8 @@ module ForestLiana
25
25
  end
26
26
 
27
27
  def count
28
+ find_resource
29
+ find_association
28
30
  begin
29
31
  getter = HasManyGetter.new(@resource, @association, params, forest_user)
30
32
  getter.count
@@ -13,10 +13,6 @@ module ForestLiana
13
13
  before_action :find_resource, except: :count
14
14
  end
15
15
 
16
- def deactivate_count_response
17
- render serializer: nil, json: { meta: { count: 'deactivated '} }
18
- end
19
-
20
16
  def index
21
17
  begin
22
18
  if request.format == 'csv'
@@ -1,3 +1,3 @@
1
1
  module ForestLiana
2
- VERSION = "7.5.0"
2
+ VERSION = "7.5.1"
3
3
  end
@@ -1,2 +1,3 @@
1
1
  class Owner < ActiveRecord::Base
2
+ has_many :trees
2
3
  end
@@ -2,6 +2,7 @@ Rails.application.routes.draw do
2
2
  namespace :forest do
3
3
  post '/actions/test' => 'islands#test'
4
4
  get '/Owner/count' , to: 'owners#count'
5
+ get '/Owner/:id/relationships/trees/count' , to: 'owner_trees#count'
5
6
  end
6
7
 
7
8
  mount ForestLiana::Engine => "/forest"
@@ -0,0 +1,11 @@
1
+ class Forest::OwnerTreesController < ForestLiana::AssociationsController
2
+ def count
3
+ if (params[:search])
4
+ deactivate_count_response
5
+ else
6
+ params[:collection] = 'Owner'
7
+ params[:association_name] = 'trees'
8
+ super
9
+ end
10
+ end
11
+ end
@@ -3,7 +3,8 @@ require 'rails_helper'
3
3
  describe 'Requesting Owner', :type => :request do
4
4
  before(:each) do
5
5
  1.upto(10) do |i|
6
- Owner.create(name: "Owner #{i}")
6
+ owner = Owner.create(name: "Owner #{i}")
7
+ Tree.create(name: "Tree #{i}", owner_id: owner.id)
7
8
  end
8
9
  end
9
10
 
@@ -52,13 +53,33 @@ describe 'Requesting Owner', :type => :request do
52
53
 
53
54
  it 'should equal to 10' do
54
55
  get '/forest/Owner/count', params: params, headers: headers
56
+ expect(response.body).to eq('{"count":10}')
57
+ end
58
+ end
59
+
60
+ describe 'count on relationships' do
61
+ params = {
62
+ fields: { 'Tree' => 'id,name,owner' },
63
+ page: { 'number' => '1', 'size' => '10' },
64
+ searchExtended: '0',
65
+ sort: '-id',
66
+ timezone: 'Europe/Paris'
67
+ }
68
+
69
+ it 'should respond 200' do
70
+ get '/forest/Owner/1/relationships/trees/count', params: params, headers: headers
55
71
  expect(response.status).to eq(200)
56
72
  end
73
+
74
+ it 'should equal to 1' do
75
+ get '/forest/Owner/1/relationships/trees/count', params: params, headers: headers
76
+ expect(response.body).to eq('{"count":1}')
77
+ end
57
78
  end
58
79
 
59
80
  describe 'deactivate_count_response' do
60
81
  params = {
61
- fields: { 'Product' => 'id,name' },
82
+ fields: { 'Owner' => 'id,name' },
62
83
  page: { 'number' => '1', 'size' => '10' },
63
84
  search: 'foo',
64
85
  searchExtended: '0',
@@ -76,4 +97,25 @@ describe 'Requesting Owner', :type => :request do
76
97
  expect(response.body).to eq('{"meta":{"count":"deactivated "}}')
77
98
  end
78
99
  end
100
+
101
+ describe 'deactivate_count_response' do
102
+ params = {
103
+ fields: { 'Tree' => 'id,name,owner' },
104
+ page: { 'number' => '1', 'size' => '10' },
105
+ search: 'foo',
106
+ searchExtended: '0',
107
+ sort: '-id',
108
+ timezone: 'Europe/Paris'
109
+ }
110
+
111
+ it 'should respond 200' do
112
+ get '/forest/Owner/1/relationships/trees/count', params: params, headers: headers
113
+ expect(response.status).to eq(200)
114
+ end
115
+
116
+ it 'should equal to deactivated response' do
117
+ get '/forest/Owner/1/relationships/trees/count', params: params, headers: headers
118
+ expect(response.body).to eq('{"meta":{"count":"deactivated "}}')
119
+ end
120
+ end
79
121
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forest_liana
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.5.0
4
+ version: 7.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sandro Munda
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-29 00:00:00.000000000 Z
11
+ date: 2022-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -372,6 +372,7 @@ files:
372
372
  - spec/dummy/lib/forest_liana/collections/island.rb
373
373
  - spec/dummy/lib/forest_liana/collections/location.rb
374
374
  - spec/dummy/lib/forest_liana/collections/user.rb
375
+ - spec/dummy/lib/forest_liana/controllers/owner_trees_controller.rb
375
376
  - spec/dummy/lib/forest_liana/controllers/owners_controller.rb
376
377
  - spec/helpers/forest_liana/query_helper_spec.rb
377
378
  - spec/helpers/forest_liana/schema_helper_spec.rb
@@ -667,6 +668,7 @@ test_files:
667
668
  - spec/dummy/app/controllers/forest/islands_controller.rb
668
669
  - spec/dummy/app/helpers/application_helper.rb
669
670
  - spec/dummy/Rakefile
671
+ - spec/dummy/lib/forest_liana/controllers/owner_trees_controller.rb
670
672
  - spec/dummy/lib/forest_liana/controllers/owners_controller.rb
671
673
  - spec/dummy/lib/forest_liana/collections/user.rb
672
674
  - spec/dummy/lib/forest_liana/collections/location.rb