flatten_record 1.0.2 → 1.0.3

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.
@@ -134,6 +134,67 @@ describe FlattenRecord::Flattener do
134
134
 
135
135
  end
136
136
  end #/context
137
+
138
+ context 'when :except option is defined' do
139
+ let(:klass) do
140
+ Order.class_eval { def grand_total;50;end }
141
+
142
+ Denormalized.class_eval do
143
+ denormalize :order, {
144
+ compute: [:total_in_usd],
145
+ methods: [:grand_total],
146
+ include: {
147
+ customer: {
148
+ include: {
149
+ children: {
150
+ except: [:name],
151
+ include: {
152
+ cats: {
153
+ except: [:name],
154
+ include: {
155
+ owner: { class_name: 'Child', except: [:name] }
156
+ }
157
+ }
158
+ }
159
+ }
160
+ }
161
+ }
162
+ },
163
+ }
164
+ def compute_total_in_usd(item);1000;end
165
+ end
166
+
167
+ Denormalized
168
+ end
169
+
170
+ it 'should construct columns' do
171
+ meta = klass.flattener_meta
172
+ expect(meta).to_not be_nil
173
+
174
+ expect(meta.all_columns).to_not be_empty
175
+ column_names = meta.all_columns.map(&:name)
176
+
177
+ expect(column_names.count).to eq(15)
178
+
179
+ expect(column_names).to be_include("order_id")
180
+ expect(column_names).to be_include("total")
181
+ expect(column_names).to be_include("grand_total")
182
+ expect(column_names).to be_include("total_in_usd")
183
+ expect(column_names).to be_include("customer_id")
184
+ expect(column_names).to be_include("customer_name")
185
+ expect(column_names).to be_include("customer_child_id")
186
+ expect(column_names).to be_include("customer_child_parent_id")
187
+ expect(column_names).to be_include("customer_child_description")
188
+ expect(column_names).to be_include("customer_child_cat_id")
189
+ expect(column_names).to be_include("customer_child_cat_description")
190
+ expect(column_names).to be_include("customer_child_cat_owner_type")
191
+ expect(column_names).to be_include("customer_child_cat_owner_child_id")
192
+ expect(column_names).to be_include("customer_child_cat_owner_child_parent_id")
193
+ expect(column_names).to be_include("customer_child_cat_owner_child_description")
194
+ end
195
+ end #/context
196
+
197
+
137
198
 
138
199
 
139
200
  end
@@ -14,10 +14,12 @@ class FlattenRecord::Flattener::Test
14
14
  end
15
15
  create_table :children do |t|
16
16
  t.string :name
17
+ t.string :description
17
18
  t.integer :parent_id
18
19
  end
19
20
  create_table :cats do |t|
20
21
  t.string :name
22
+ t.string :description
21
23
  t.string :owner_type
22
24
  t.integer :owner_id
23
25
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flatten_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alvin S.J. Ng