iknow_view_models 3.2.11 → 3.2.12

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: 2a75096a1b8ac47eee4ff5b2a303a0d447cfe8e93668f579bb697b863947eaa5
4
- data.tar.gz: ca0edc9b15a0b436d36d7b12dbd8f4255008ad4a6cd6d1ed23a352a989013fa1
3
+ metadata.gz: 284af292a0f1a70b761afd2e3ef084ad9f8f5853f00c8af8ac2d3b1227eb9cb5
4
+ data.tar.gz: 61fdea22a0b13db50e7b237e472900eef376e95d04fed5f21a8c1ef7422aaa56
5
5
  SHA512:
6
- metadata.gz: 683a95fe51734a420f87f4709942314ec03ee32a8a95a63487bb4495eaad7a61c0f6ba4216d67ee31f33acf9f593607833eebcd3fd9e1dfd8a4f3440a337f249
7
- data.tar.gz: e889492e1e0b76a3f8b3ed8775c16fa6f67f6a45eb9ed14e09f53f41b3dc6a1675d093eec75ba2b94d79567238d22d4996236a5388dafb5ee078fb9760d0c97e
6
+ metadata.gz: 64ffd808756c298236f4e00b11cdf7f1410019bc506f306c6cfbaa97b953212a5c58e7b56263deac0aac5e80398fa2d551922d6b90d7a3c60732a50b66467384
7
+ data.tar.gz: ccd3301209a94c8e9cd9a44166b153ae3edafab81cfe49498849e6c22dc413956d33e3cdba0ab001456122f47400df47dfbe327d9a9005f1947c512da3d9e523
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module IknowViewModels
4
- VERSION = '3.2.11'
4
+ VERSION = '3.2.12'
5
5
  end
@@ -340,12 +340,15 @@ class ViewModel::ActiveRecord < ViewModel::Record
340
340
 
341
341
  case
342
342
  when association_data.through?
343
- # associated here are join_table models; we need to get the far side out
343
+ # associated here are join-table models; we need to get the far side out
344
+ join_models = associated
345
+
344
346
  if association_data.direct_viewmodel._list_member?
345
- associated.order(association_data.direct_viewmodel._list_attribute_name)
347
+ attr = association_data.direct_viewmodel._list_attribute_name
348
+ join_models = join_models.sort_by { |j| j[attr] }
346
349
  end
347
350
 
348
- associated.map do |through_model|
351
+ join_models.map do |through_model|
349
352
  model = through_model.public_send(association_data.indirect_reflection.name)
350
353
  association_data.viewmodel_class_for_model!(model.class).new(model)
351
354
  end
@@ -101,8 +101,10 @@ class ViewModel::ActiveRecord::HasManyThroughTest < ActiveSupport::TestCase
101
101
  @tag1, @tag2, @tag3 = (1..3).map { |x| Tag.create!(name: "tag#{x}") }
102
102
 
103
103
  @parent1 = Parent.create(name: 'p1',
104
- parents_tags: [ParentsTag.new(tag: @tag1, position: 1.0),
105
- ParentsTag.new(tag: @tag2, position: 2.0),])
104
+ parents_tags: [
105
+ ParentsTag.new(tag: @tag2, position: 2.0),
106
+ ParentsTag.new(tag: @tag1, position: 1.0),
107
+ ])
106
108
 
107
109
  enable_logging!
108
110
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iknow_view_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.11
4
+ version: 3.2.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - iKnow Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-27 00:00:00.000000000 Z
11
+ date: 2021-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord