hoodoo 1.12.0 → 1.12.3

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: 30fd454d84a35502e8c324645a1c8c981521aa7e
4
- data.tar.gz: fae766337e9034cf46e9c030c64d5d6ea0609827
3
+ metadata.gz: 9cd0bbca0d44ff8c52c354e140565325d8447f10
4
+ data.tar.gz: 5faa6103ed09143226c2d869069af59c0ea5a76f
5
5
  SHA512:
6
- metadata.gz: be4607dfff0f5f798b48eb83abbd3985562df696570137f1c7c9fa7fbaad5df227659c274c758c323fb12901365d665c9a1642d743c17103708cb1509b23db3f
7
- data.tar.gz: 0c35e38a6740d1e689c361fcf2f0ab07bac09540eb46a9bb1d7ac2f3ab40319c3711b26741fe85c0836e5b1d277208c9c06152f3aa5369745c936714de7a4bf7
6
+ metadata.gz: b3a8f6e8f61b54b65b9842fffe90aa1e0503fc4678a876ffcdf75de4075792cf8ff1c444bdb9b72c722a9ced24f4916ebfbdff338425c97dbe53c18e153bfd7a
7
+ data.tar.gz: 47ff963da7a1ff972fba27090290398bfcd35612d5657df877b3f623c3726dbd8e3fd2ed3668df1a43c6df5e3f5caf6b04ec0489bfd0f3ae441aa7ba387eab42
@@ -82,6 +82,14 @@ module Hoodoo
82
82
  #
83
83
  def self.instantiate( model )
84
84
  model.extend( ClassMethods )
85
+
86
+ framework_data = Hoodoo::ActiveRecord::Support.framework_search_and_filter_data()
87
+
88
+ model.nz_co_loyalty_hoodoo_search_with ||= {}
89
+ model.nz_co_loyalty_hoodoo_filter_with ||= {}
90
+
91
+ model.nz_co_loyalty_hoodoo_search_with.merge!( framework_data )
92
+ model.nz_co_loyalty_hoodoo_filter_with.merge!( framework_data )
85
93
  end
86
94
 
87
95
  # Collection of class methods that get defined on an including class via
@@ -711,7 +719,6 @@ module Hoodoo
711
719
  # which assist with filling in non-nil values for this Hash.
712
720
  #
713
721
  def search_with( hash )
714
- self.nz_co_loyalty_hoodoo_search_with ||= Hoodoo::ActiveRecord::Support.framework_search_and_filter_data()
715
722
  self.nz_co_loyalty_hoodoo_search_with.merge!( Hoodoo::ActiveRecord::Support.process_to_map( hash ) )
716
723
  end
717
724
 
@@ -733,7 +740,6 @@ module Hoodoo
733
740
  # +map+:: As #search_with.
734
741
  #
735
742
  def filter_with( hash )
736
- self.nz_co_loyalty_hoodoo_filter_with ||= Hoodoo::ActiveRecord::Support.framework_search_and_filter_data()
737
743
  self.nz_co_loyalty_hoodoo_filter_with.merge!( Hoodoo::ActiveRecord::Support.process_to_map( hash ) )
738
744
  end
739
745
 
@@ -67,7 +67,7 @@ module Hoodoo; module Services
67
67
  #
68
68
  attr_reader :filter
69
69
 
70
- # Array of prohibited framewor filter keys as Strings; empty for none
70
+ # Array of prohibited framework filter keys as Strings; empty for none
71
71
  # defined.
72
72
  #
73
73
  attr_reader :do_not_filter
@@ -12,6 +12,6 @@ module Hoodoo
12
12
  # The Hoodoo gem version. If this changes, ensure that the date in
13
13
  # "hoodoo.gemspec" is correct and run "bundle install" (or "update").
14
14
  #
15
- VERSION = '1.12.0'
15
+ VERSION = '1.12.3'
16
16
 
17
17
  end
@@ -85,6 +85,36 @@ describe Hoodoo::ActiveRecord::Finder do
85
85
  search_with( search_and_filter_map )
86
86
  filter_with( search_and_filter_map )
87
87
  end
88
+
89
+ class RSpecModelFinderWithoutSearchOrFilterTest < ActiveRecord::Base
90
+ include Hoodoo::ActiveRecord::Finder
91
+
92
+ self.primary_key = :id
93
+ self.table_name = :r_spec_model_finder_tests
94
+ end
95
+
96
+ class RSpecModelFinderSubclassTest < Hoodoo::ActiveRecord::Base
97
+ self.primary_key = :id
98
+ self.table_name = :r_spec_model_finder_tests
99
+
100
+ search_and_filter_map = {
101
+ 'mapped_code' => Hoodoo::ActiveRecord::Finder::SearchHelper.cs_match( 'code' )
102
+ }
103
+
104
+ search_with( search_and_filter_map )
105
+ filter_with( search_and_filter_map )
106
+ end
107
+
108
+ class RSpecModelFinderSubclassATest < RSpecModelFinderSubclassTest; end
109
+ class RSpecModelFinderSubclassBTest < RSpecModelFinderSubclassTest; end
110
+
111
+ class RSpecModelFinderSubclassWithoutSearchOrFilterTest < Hoodoo::ActiveRecord::Base
112
+ self.primary_key = :id
113
+ self.table_name = :r_spec_model_finder_tests
114
+ end
115
+
116
+ class RSpecModelFinderSubclassWithoutSearchOrFilterATest < RSpecModelFinderSubclassWithoutSearchOrFilterTest; end
117
+ class RSpecModelFinderSubclassWithoutSearchOrFilterBTest < RSpecModelFinderSubclassWithoutSearchOrFilterTest; end
88
118
  end
89
119
 
90
120
  before :each do
@@ -124,9 +154,37 @@ describe Hoodoo::ActiveRecord::Finder do
124
154
  @c.save!
125
155
  @code = @c.code
126
156
 
127
- @a_wh = RSpecModelFinderTestWithHelpers.find( @a.id )
128
- @b_wh = RSpecModelFinderTestWithHelpers.find( @b.id )
129
- @c_wh = RSpecModelFinderTestWithHelpers.find( @c.id )
157
+ @a_wh = RSpecModelFinderTestWithHelpers.find( @a.id )
158
+ @b_wh = RSpecModelFinderTestWithHelpers.find( @b.id )
159
+ @c_wh = RSpecModelFinderTestWithHelpers.find( @c.id )
160
+
161
+ @a_wosf = RSpecModelFinderWithoutSearchOrFilterTest.find( @a.id )
162
+ @b_wosf = RSpecModelFinderWithoutSearchOrFilterTest.find( @b.id )
163
+ @c_wosf = RSpecModelFinderWithoutSearchOrFilterTest.find( @c.id )
164
+
165
+ @a_sc = RSpecModelFinderSubclassTest.find( @a.id )
166
+ @b_sc = RSpecModelFinderSubclassTest.find( @b.id )
167
+ @c_sc = RSpecModelFinderSubclassTest.find( @c.id )
168
+
169
+ @a_sc_a = RSpecModelFinderSubclassATest.find( @a.id )
170
+ @b_sc_a = RSpecModelFinderSubclassATest.find( @b.id )
171
+ @c_sc_a = RSpecModelFinderSubclassATest.find( @c.id )
172
+
173
+ @a_sc_b = RSpecModelFinderSubclassBTest.find( @a.id )
174
+ @b_sc_b = RSpecModelFinderSubclassBTest.find( @b.id )
175
+ @c_sc_b = RSpecModelFinderSubclassBTest.find( @c.id )
176
+
177
+ @a_sc_wosf = RSpecModelFinderSubclassWithoutSearchOrFilterTest.find( @a.id )
178
+ @b_sc_wosf = RSpecModelFinderSubclassWithoutSearchOrFilterTest.find( @b.id )
179
+ @c_sc_wosf = RSpecModelFinderSubclassWithoutSearchOrFilterTest.find( @c.id )
180
+
181
+ @a_sc_wosf_a = RSpecModelFinderSubclassWithoutSearchOrFilterATest.find( @a.id )
182
+ @b_sc_wosf_a = RSpecModelFinderSubclassWithoutSearchOrFilterATest.find( @b.id )
183
+ @c_sc_wosf_a = RSpecModelFinderSubclassWithoutSearchOrFilterATest.find( @c.id )
184
+
185
+ @a_sc_wosf_b = RSpecModelFinderSubclassWithoutSearchOrFilterBTest.find( @a.id )
186
+ @b_sc_wosf_b = RSpecModelFinderSubclassWithoutSearchOrFilterBTest.find( @b.id )
187
+ @c_sc_wosf_b = RSpecModelFinderSubclassWithoutSearchOrFilterBTest.find( @c.id )
130
188
 
131
189
  @list_params = Hoodoo::Services::Request::ListParameters.new
132
190
  end
@@ -773,6 +831,81 @@ describe Hoodoo::ActiveRecord::Finder do
773
831
 
774
832
  # ==========================================================================
775
833
 
834
+ context 'pure framework search' do
835
+ it 'on created_after' do
836
+ @list_params.search_data = {
837
+ 'created_after' => @tn - 1.month
838
+ }
839
+
840
+ finder = RSpecModelFinderWithoutSearchOrFilterTest.list( @list_params )
841
+ expect( finder ).to eq( [ @c_wosf ] )
842
+ end
843
+
844
+ it 'on created_before' do
845
+ @list_params.search_data = {
846
+ 'created_before' => @tn - 1.month
847
+ }
848
+
849
+ finder = RSpecModelFinderWithoutSearchOrFilterTest.list( @list_params )
850
+ expect( finder ).to eq( [ @a_wosf ] )
851
+ end
852
+ end
853
+
854
+ # ==========================================================================
855
+
856
+ context 'as a Hoodoo::ActiveRecord::Base subclass and sub-subclass' do # (instead of explicitly including the Finder module)
857
+ context 'custom search' do
858
+ it 'on mapped_code' do
859
+ @list_params.search_data = {
860
+ 'mapped_code' => @code
861
+ }
862
+
863
+ finder = RSpecModelFinderSubclassTest.list( @list_params )
864
+ expect( finder ).to eq( [ @c_sc ] )
865
+
866
+ finder = RSpecModelFinderSubclassATest.list( @list_params )
867
+ expect( finder ).to eq( [ @c_sc_a ] )
868
+
869
+ finder = RSpecModelFinderSubclassBTest.list( @list_params )
870
+ expect( finder ).to eq( [ @c_sc_b ] )
871
+ end
872
+ end
873
+
874
+ context 'pure framework search' do
875
+ it 'on created_after' do
876
+ @list_params.search_data = {
877
+ 'created_after' => @tn - 1.month
878
+ }
879
+
880
+ finder = RSpecModelFinderSubclassWithoutSearchOrFilterTest.list( @list_params )
881
+ expect( finder ).to eq( [ @c_sc_wosf ] )
882
+
883
+ finder = RSpecModelFinderSubclassWithoutSearchOrFilterATest.list( @list_params )
884
+ expect( finder ).to eq( [ @c_sc_wosf_a ] )
885
+
886
+ finder = RSpecModelFinderSubclassWithoutSearchOrFilterBTest.list( @list_params )
887
+ expect( finder ).to eq( [ @c_sc_wosf_b ] )
888
+ end
889
+
890
+ it 'on created_before' do
891
+ @list_params.search_data = {
892
+ 'created_before' => @tn - 1.month
893
+ }
894
+
895
+ finder = RSpecModelFinderSubclassWithoutSearchOrFilterTest.list( @list_params )
896
+ expect( finder ).to eq( [ @a_sc_wosf ] )
897
+
898
+ finder = RSpecModelFinderSubclassWithoutSearchOrFilterATest.list( @list_params )
899
+ expect( finder ).to eq( [ @a_sc_wosf_a ] )
900
+
901
+ finder = RSpecModelFinderSubclassWithoutSearchOrFilterBTest.list( @list_params )
902
+ expect( finder ).to eq( [ @a_sc_wosf_b ] )
903
+ end
904
+ end
905
+ end
906
+
907
+ # ==========================================================================
908
+
776
909
  context 'filter' do
777
910
  it 'filters without chain' do
778
911
  @list_params.filter_data = {
@@ -978,6 +1111,81 @@ describe Hoodoo::ActiveRecord::Finder do
978
1111
 
979
1112
  # ==========================================================================
980
1113
 
1114
+ context 'pure framework filter' do
1115
+ it 'on created_after' do
1116
+ @list_params.filter_data = {
1117
+ 'created_after' => @tn - 1.month
1118
+ }
1119
+
1120
+ finder = RSpecModelFinderWithoutSearchOrFilterTest.list( @list_params )
1121
+ expect( finder ).to eq( [ @b_wosf, @a_wosf ] )
1122
+ end
1123
+
1124
+ it 'on created_before' do
1125
+ @list_params.filter_data = {
1126
+ 'created_before' => @tn - 1.month
1127
+ }
1128
+
1129
+ finder = RSpecModelFinderWithoutSearchOrFilterTest.list( @list_params )
1130
+ expect( finder ).to eq( [ @c_wosf, @b_wosf ] )
1131
+ end
1132
+ end
1133
+
1134
+ # ==========================================================================
1135
+
1136
+ context 'as a Hoodoo::ActiveRecord::Base subclass and sub-subclass' do # (instead of explicitly including the Finder module)
1137
+ context 'custom filter' do
1138
+ it 'on mapped_code' do
1139
+ @list_params.filter_data = {
1140
+ 'mapped_code' => @code
1141
+ }
1142
+
1143
+ finder = RSpecModelFinderSubclassTest.list( @list_params )
1144
+ expect( finder ).to eq( [ @b_sc, @a_sc ] )
1145
+
1146
+ finder = RSpecModelFinderSubclassATest.list( @list_params )
1147
+ expect( finder ).to eq( [ @b_sc_a, @a_sc_a ] )
1148
+
1149
+ finder = RSpecModelFinderSubclassBTest.list( @list_params )
1150
+ expect( finder ).to eq( [ @b_sc_b, @a_sc_b ] )
1151
+ end
1152
+ end
1153
+
1154
+ context 'pure framework filter' do
1155
+ it 'on created_after' do
1156
+ @list_params.filter_data = {
1157
+ 'created_after' => @tn - 1.month
1158
+ }
1159
+
1160
+ finder = RSpecModelFinderSubclassWithoutSearchOrFilterTest.list( @list_params )
1161
+ expect( finder ).to eq( [ @b_sc_wosf, @a_sc_wosf ] )
1162
+
1163
+ finder = RSpecModelFinderSubclassWithoutSearchOrFilterATest.list( @list_params )
1164
+ expect( finder ).to eq( [ @b_sc_wosf_a, @a_sc_wosf_a ] )
1165
+
1166
+ finder = RSpecModelFinderSubclassWithoutSearchOrFilterBTest.list( @list_params )
1167
+ expect( finder ).to eq( [ @b_sc_wosf_b, @a_sc_wosf_b ] )
1168
+ end
1169
+
1170
+ it 'on created_before' do
1171
+ @list_params.filter_data = {
1172
+ 'created_before' => @tn - 1.month
1173
+ }
1174
+
1175
+ finder = RSpecModelFinderSubclassWithoutSearchOrFilterTest.list( @list_params )
1176
+ expect( finder ).to eq( [ @c_sc_wosf, @b_sc_wosf ] )
1177
+
1178
+ finder = RSpecModelFinderSubclassWithoutSearchOrFilterATest.list( @list_params )
1179
+ expect( finder ).to eq( [ @c_sc_wosf_a, @b_sc_wosf_a ] )
1180
+
1181
+ finder = RSpecModelFinderSubclassWithoutSearchOrFilterBTest.list( @list_params )
1182
+ expect( finder ).to eq( [ @c_sc_wosf_b, @b_sc_wosf_b ] )
1183
+ end
1184
+ end
1185
+ end
1186
+
1187
+ # ==========================================================================
1188
+
981
1189
  context '#list_in' do
982
1190
  before :each do
983
1191
  @scoped_1 = RSpecModelFinderTest.new
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hoodoo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.12.0
4
+ version: 1.12.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Loyalty New Zealand
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-06 00:00:00.000000000 Z
11
+ date: 2016-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kgio