ransack 1.7.0 → 2.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. checksums.yaml +5 -5
  2. data/.github/FUNDING.yml +3 -0
  3. data/.github/SECURITY.md +12 -0
  4. data/.github/workflows/test.yml +120 -0
  5. data/.gitignore +3 -0
  6. data/CHANGELOG.md +463 -27
  7. data/CONTRIBUTING.md +52 -22
  8. data/Gemfile +24 -24
  9. data/README.md +453 -126
  10. data/Rakefile +6 -25
  11. data/lib/polyamorous/activerecord_5.2_ruby_2/join_association.rb +24 -0
  12. data/lib/polyamorous/activerecord_5.2_ruby_2/join_dependency.rb +79 -0
  13. data/lib/polyamorous/activerecord_5.2_ruby_2/reflection.rb +11 -0
  14. data/lib/polyamorous/activerecord_6.0_ruby_2/join_association.rb +1 -0
  15. data/lib/polyamorous/activerecord_6.0_ruby_2/join_dependency.rb +80 -0
  16. data/lib/polyamorous/activerecord_6.0_ruby_2/reflection.rb +1 -0
  17. data/lib/polyamorous/activerecord_6.1_ruby_2/join_association.rb +74 -0
  18. data/lib/polyamorous/activerecord_6.1_ruby_2/join_dependency.rb +93 -0
  19. data/lib/polyamorous/activerecord_6.1_ruby_2/reflection.rb +1 -0
  20. data/lib/polyamorous/join.rb +70 -0
  21. data/lib/polyamorous/polyamorous.rb +24 -0
  22. data/lib/polyamorous/swapping_reflection_class.rb +11 -0
  23. data/lib/polyamorous/tree_node.rb +7 -0
  24. data/lib/ransack/adapters/active_record/base.rb +27 -2
  25. data/lib/ransack/adapters/active_record/context.rb +213 -139
  26. data/lib/ransack/adapters/active_record/ransack/constants.rb +70 -55
  27. data/lib/ransack/adapters/active_record/ransack/context.rb +10 -18
  28. data/lib/ransack/adapters/active_record/ransack/nodes/condition.rb +42 -32
  29. data/lib/ransack/adapters/active_record/ransack/translate.rb +1 -5
  30. data/lib/ransack/adapters/active_record/ransack/visitor.rb +23 -0
  31. data/lib/ransack/adapters/active_record.rb +11 -10
  32. data/lib/ransack/adapters.rb +45 -23
  33. data/lib/ransack/configuration.rb +107 -4
  34. data/lib/ransack/constants.rb +13 -26
  35. data/lib/ransack/context.rb +45 -33
  36. data/lib/ransack/helpers/form_builder.rb +21 -12
  37. data/lib/ransack/helpers/form_helper.rb +75 -70
  38. data/lib/ransack/locale/ar.yml +70 -0
  39. data/lib/ransack/locale/az.yml +70 -0
  40. data/lib/ransack/locale/bg.yml +70 -0
  41. data/lib/ransack/locale/ca.yml +70 -0
  42. data/lib/ransack/locale/da.yml +70 -0
  43. data/lib/ransack/locale/el.yml +70 -0
  44. data/lib/ransack/locale/es.yml +22 -22
  45. data/lib/ransack/locale/fa.yml +70 -0
  46. data/lib/ransack/locale/fi.yml +71 -0
  47. data/lib/ransack/locale/id.yml +70 -0
  48. data/lib/ransack/locale/it.yml +70 -0
  49. data/lib/ransack/locale/ja.yml +70 -0
  50. data/lib/ransack/locale/nl.yml +4 -4
  51. data/lib/ransack/locale/pt-BR.yml +70 -0
  52. data/lib/ransack/locale/ru.yml +70 -0
  53. data/lib/ransack/locale/sk.yml +70 -0
  54. data/lib/ransack/locale/tr.yml +70 -0
  55. data/lib/ransack/locale/{zh.yml → zh-CN.yml} +13 -13
  56. data/lib/ransack/locale/zh-TW.yml +70 -0
  57. data/lib/ransack/nodes/attribute.rb +5 -2
  58. data/lib/ransack/nodes/bindable.rb +18 -6
  59. data/lib/ransack/nodes/condition.rb +85 -28
  60. data/lib/ransack/nodes/grouping.rb +17 -11
  61. data/lib/ransack/nodes/sort.rb +9 -5
  62. data/lib/ransack/nodes/value.rb +74 -68
  63. data/lib/ransack/nodes.rb +1 -1
  64. data/lib/ransack/predicate.rb +17 -20
  65. data/lib/ransack/search.rb +17 -8
  66. data/lib/ransack/translate.rb +115 -115
  67. data/lib/ransack/version.rb +1 -1
  68. data/lib/ransack/visitor.rb +1 -12
  69. data/lib/ransack.rb +9 -9
  70. data/logo/ransack-h.png +0 -0
  71. data/logo/ransack-h.svg +34 -0
  72. data/logo/ransack-v.png +0 -0
  73. data/logo/ransack-v.svg +34 -0
  74. data/logo/ransack.png +0 -0
  75. data/logo/ransack.svg +21 -0
  76. data/ransack.gemspec +7 -24
  77. data/spec/console.rb +4 -0
  78. data/spec/helpers/polyamorous_helper.rb +19 -0
  79. data/spec/polyamorous/join_association_spec.rb +35 -0
  80. data/spec/polyamorous/join_dependency_spec.rb +97 -0
  81. data/spec/polyamorous/join_spec.rb +19 -0
  82. data/spec/ransack/adapters/active_record/base_spec.rb +370 -75
  83. data/spec/ransack/adapters/active_record/context_spec.rb +72 -34
  84. data/spec/ransack/configuration_spec.rb +97 -14
  85. data/spec/ransack/helpers/form_builder_spec.rb +2 -11
  86. data/spec/ransack/helpers/form_helper_spec.rb +481 -113
  87. data/spec/ransack/nodes/condition_spec.rb +24 -0
  88. data/spec/ransack/nodes/grouping_spec.rb +56 -0
  89. data/spec/ransack/predicate_spec.rb +79 -5
  90. data/spec/ransack/search_spec.rb +207 -81
  91. data/spec/spec_helper.rb +8 -0
  92. data/spec/support/schema.rb +100 -42
  93. metadata +57 -184
  94. data/.travis.yml +0 -69
  95. data/lib/ransack/adapters/active_record/3.0/compat.rb +0 -179
  96. data/lib/ransack/adapters/active_record/3.0/context.rb +0 -201
  97. data/lib/ransack/adapters/active_record/3.1/context.rb +0 -215
  98. data/lib/ransack/adapters/active_record/3.2/context.rb +0 -44
  99. data/lib/ransack/adapters/active_record/compat.rb +0 -14
  100. data/lib/ransack/adapters/mongoid/3.2/.gitkeep +0 -0
  101. data/lib/ransack/adapters/mongoid/attributes/attribute.rb +0 -37
  102. data/lib/ransack/adapters/mongoid/attributes/order_predications.rb +0 -17
  103. data/lib/ransack/adapters/mongoid/attributes/predications.rb +0 -141
  104. data/lib/ransack/adapters/mongoid/base.rb +0 -130
  105. data/lib/ransack/adapters/mongoid/context.rb +0 -208
  106. data/lib/ransack/adapters/mongoid/inquiry_hash.rb +0 -23
  107. data/lib/ransack/adapters/mongoid/ransack/constants.rb +0 -88
  108. data/lib/ransack/adapters/mongoid/ransack/context.rb +0 -60
  109. data/lib/ransack/adapters/mongoid/ransack/nodes/condition.rb +0 -27
  110. data/lib/ransack/adapters/mongoid/ransack/translate.rb +0 -13
  111. data/lib/ransack/adapters/mongoid/ransack/visitor.rb +0 -24
  112. data/lib/ransack/adapters/mongoid/table.rb +0 -35
  113. data/lib/ransack/adapters/mongoid.rb +0 -13
  114. data/spec/mongoid/adapters/mongoid/base_spec.rb +0 -276
  115. data/spec/mongoid/adapters/mongoid/context_spec.rb +0 -56
  116. data/spec/mongoid/configuration_spec.rb +0 -102
  117. data/spec/mongoid/dependencies_spec.rb +0 -8
  118. data/spec/mongoid/helpers/ransack_helper.rb +0 -11
  119. data/spec/mongoid/nodes/condition_spec.rb +0 -34
  120. data/spec/mongoid/nodes/grouping_spec.rb +0 -13
  121. data/spec/mongoid/predicate_spec.rb +0 -155
  122. data/spec/mongoid/search_spec.rb +0 -446
  123. data/spec/mongoid/support/mongoid.yml +0 -6
  124. data/spec/mongoid/support/schema.rb +0 -128
  125. data/spec/mongoid/translate_spec.rb +0 -14
  126. data/spec/mongoid_spec_helper.rb +0 -59
  127. data/spec/ransack/dependencies_spec.rb +0 -12
@@ -0,0 +1,34 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
3
+ <svg width="100%" height="100%" viewBox="0 0 519 114" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:1.41421;">
4
+ <g transform="matrix(1,0,0,1,-1217.17,-115.878)">
5
+ <g transform="matrix(1,0,0,1,1076.45,0)">
6
+ <g transform="matrix(1,0,0,1,-38.0018,0)">
7
+ <g transform="matrix(0.952133,0,0,0.952133,-804.114,-1490.95)">
8
+ <path d="M1032.25,1692.74C1032.25,1689.9 1034.55,1687.61 1037.38,1687.61C1052.29,1687.61 1094.52,1687.61 1094.52,1687.61L1094.52,1687.61C1117.36,1687.65 1135.89,1706.2 1135.89,1729.05C1135.89,1741.48 1128.4,1752.63 1119.73,1760.23C1119.73,1760.23 1136.6,1789.45 1143.57,1801.53C1144.18,1802.58 1144.18,1803.88 1143.57,1804.94C1142.96,1806 1141.83,1806.65 1140.61,1806.65C1130.61,1806.65 1110.85,1806.65 1104.56,1806.65C1103.34,1806.65 1102.21,1806 1101.6,1804.94C1097.46,1797.77 1081.71,1770.49 1081.71,1770.49L1073.76,1770.49C1073.76,1770.49 1073.76,1792.44 1073.76,1802.14C1073.76,1803.34 1073.29,1804.48 1072.44,1805.33C1071.6,1806.17 1070.45,1806.65 1069.25,1806.65C1061.27,1806.65 1044.74,1806.65 1036.76,1806.65C1035.56,1806.65 1034.41,1806.17 1033.57,1805.33C1032.72,1804.48 1032.25,1803.34 1032.25,1802.14C1032.25,1783.5 1032.25,1712.5 1032.25,1692.74Z" style="fill:url(#_Linear1);"/>
9
+ <clipPath id="_clip2">
10
+ <path d="M1032.25,1692.74C1032.25,1689.9 1034.55,1687.61 1037.38,1687.61C1052.29,1687.61 1094.52,1687.61 1094.52,1687.61L1094.52,1687.61C1117.36,1687.65 1135.89,1706.2 1135.89,1729.05C1135.89,1741.48 1128.4,1752.63 1119.73,1760.23C1119.73,1760.23 1136.6,1789.45 1143.57,1801.53C1144.18,1802.58 1144.18,1803.88 1143.57,1804.94C1142.96,1806 1141.83,1806.65 1140.61,1806.65C1130.61,1806.65 1110.85,1806.65 1104.56,1806.65C1103.34,1806.65 1102.21,1806 1101.6,1804.94C1097.46,1797.77 1081.71,1770.49 1081.71,1770.49L1073.76,1770.49C1073.76,1770.49 1073.76,1792.44 1073.76,1802.14C1073.76,1803.34 1073.29,1804.48 1072.44,1805.33C1071.6,1806.17 1070.45,1806.65 1069.25,1806.65C1061.27,1806.65 1044.74,1806.65 1036.76,1806.65C1035.56,1806.65 1034.41,1806.17 1033.57,1805.33C1032.72,1804.48 1032.25,1803.34 1032.25,1802.14C1032.25,1783.5 1032.25,1712.5 1032.25,1692.74Z"/>
11
+ </clipPath>
12
+ <g clip-path="url(#_clip2)">
13
+ <g transform="matrix(1.05537,0,0,1.05537,-56.2001,-93.6352)">
14
+ <path d="M1090.07,1757.11C1087.62,1757.78 1085.05,1758.14 1082.39,1758.14C1066.34,1758.14 1053.3,1745.1 1053.3,1729.05C1053.3,1712.99 1066.34,1699.96 1082.39,1699.96C1098.45,1699.96 1111.49,1712.99 1111.49,1729.05C1111.49,1738.8 1106.68,1747.44 1099.3,1752.72C1099.3,1752.72 1110.29,1771.75 1116.66,1782.78C1117.57,1784.36 1117.57,1786.31 1116.66,1787.89C1115.75,1789.47 1114.06,1790.44 1112.23,1790.44C1112.23,1790.44 1112.23,1790.44 1112.23,1790.44C1110.43,1790.44 1108.76,1789.48 1107.86,1787.92C1103.37,1780.15 1090.07,1757.11 1090.07,1757.11ZM1082.52,1708.18C1084.31,1708.32 1084.32,1708.88 1084.66,1709.62C1085.4,1711.22 1084.12,1713.13 1081.99,1713.18C1073.82,1713.44 1066.55,1720.54 1066.53,1729.05C1066.53,1729.05 1066.41,1730.38 1065.53,1731.04C1063.81,1732.34 1061.32,1730.94 1061.59,1727.44C1062.36,1717.22 1071.49,1708.34 1082.13,1708.18C1082.26,1708.18 1082.39,1708.18 1082.52,1708.18Z" style="fill:rgb(52,52,107);fill-opacity:0.4;"/>
15
+ </g>
16
+ <path d="M1090.07,1757.11C1087.62,1757.78 1085.05,1758.14 1082.39,1758.14C1066.34,1758.14 1053.3,1745.1 1053.3,1729.05C1053.3,1712.99 1066.34,1699.96 1082.39,1699.96C1098.45,1699.96 1111.49,1712.99 1111.49,1729.05C1111.49,1738.8 1106.68,1747.44 1099.3,1752.72C1099.3,1752.72 1110.19,1771.58 1116.57,1782.63C1117.5,1784.24 1117.5,1786.23 1116.57,1787.84C1115.64,1789.45 1113.92,1790.44 1112.06,1790.44C1112.06,1790.44 1112.06,1790.44 1112.06,1790.44C1110.36,1790.44 1108.79,1789.54 1107.94,1788.07C1103.54,1780.44 1090.07,1757.11 1090.07,1757.11ZM1082.52,1708.18C1084.31,1708.32 1084.32,1708.88 1084.66,1709.62C1085.4,1711.22 1084.12,1713.13 1081.99,1713.18C1073.82,1713.44 1066.55,1720.54 1066.53,1729.05C1066.53,1729.05 1066.41,1730.38 1065.53,1731.04C1063.81,1732.34 1061.32,1730.94 1061.59,1727.44C1062.36,1717.22 1071.49,1708.34 1082.13,1708.18C1082.26,1708.18 1082.39,1708.18 1082.52,1708.18Z" style="fill:rgb(251,248,255);"/>
17
+ </g>
18
+ </g>
19
+ <g transform="matrix(1,0,0,1,-37.1645,15.0997)">
20
+ <path d="M399.069,182.651L389.349,168.611L388.773,168.611L378.621,168.611L378.621,182.651L366.957,182.651L366.957,132.251L388.773,132.251C393.237,132.251 397.113,132.995 400.401,134.483C403.689,135.971 406.221,138.083 407.997,140.819C409.773,143.555 410.661,146.795 410.661,150.539C410.661,154.283 409.761,157.511 407.961,160.223C406.161,162.935 403.605,165.011 400.293,166.451L411.597,182.651L399.069,182.651ZM398.853,150.539C398.853,147.707 397.941,145.535 396.117,144.023C394.293,142.511 391.629,141.755 388.125,141.755L378.621,141.755L378.621,159.323L388.125,159.323C391.629,159.323 394.293,158.555 396.117,157.019C397.941,155.483 398.853,153.323 398.853,150.539Z" style="fill:rgb(5,5,14);fill-rule:nonzero;"/>
21
+ <path d="M453.069,171.851L429.669,171.851L425.205,182.651L413.253,182.651L435.717,132.251L447.237,132.251L469.773,182.651L457.533,182.651L453.069,171.851ZM449.397,162.995L441.405,143.699L433.413,162.995L449.397,162.995Z" style="fill:rgb(5,5,14);fill-rule:nonzero;"/>
22
+ <path d="M521.253,132.251L521.253,182.651L511.677,182.651L486.549,152.051L486.549,182.651L475.029,182.651L475.029,132.251L484.677,132.251L509.733,162.851L509.733,132.251L521.253,132.251Z" style="fill:rgb(5,5,14);fill-rule:nonzero;"/>
23
+ <path d="M549.765,183.515C545.781,183.515 541.929,182.975 538.209,181.895C534.489,180.815 531.501,179.411 529.245,177.683L533.205,168.899C535.365,170.483 537.933,171.755 540.909,172.715C543.885,173.675 546.861,174.155 549.837,174.155C553.149,174.155 555.597,173.663 557.181,172.679C558.765,171.695 559.557,170.387 559.557,168.755C559.557,167.555 559.089,166.559 558.153,165.767C557.217,164.975 556.017,164.339 554.553,163.859C553.089,163.379 551.109,162.851 548.613,162.275C544.773,161.363 541.629,160.451 539.181,159.539C536.733,158.627 534.633,157.163 532.881,155.147C531.129,153.131 530.253,150.443 530.253,147.083C530.253,144.155 531.045,141.503 532.629,139.127C534.213,136.751 536.601,134.867 539.793,133.475C542.985,132.083 546.885,131.387 551.493,131.387C554.709,131.387 557.853,131.771 560.925,132.539C563.997,133.307 566.685,134.411 568.989,135.851L565.389,144.707C560.733,142.067 556.077,140.747 551.421,140.747C548.157,140.747 545.745,141.275 544.185,142.331C542.625,143.387 541.845,144.779 541.845,146.507C541.845,148.235 542.745,149.519 544.545,150.359C546.345,151.199 549.093,152.027 552.789,152.843C556.629,153.755 559.773,154.667 562.221,155.579C564.669,156.491 566.769,157.931 568.521,159.899C570.273,161.867 571.149,164.531 571.149,167.891C571.149,170.771 570.345,173.399 568.737,175.775C567.129,178.151 564.717,180.035 561.501,181.427C558.285,182.819 554.373,183.515 549.765,183.515Z" style="fill:rgb(5,5,14);fill-rule:nonzero;"/>
24
+ <path d="M612.333,171.851L588.933,171.851L584.469,182.651L572.517,182.651L594.981,132.251L606.501,132.251L629.037,182.651L616.797,182.651L612.333,171.851ZM608.661,162.995L600.669,143.699L592.677,162.995L608.661,162.995Z" style="fill:rgb(5,5,14);fill-rule:nonzero;"/>
25
+ <path d="M657.693,183.515C652.557,183.515 647.913,182.399 643.761,180.167C639.609,177.935 636.345,174.839 633.969,170.879C631.593,166.919 630.405,162.443 630.405,157.451C630.405,152.459 631.593,147.983 633.969,144.023C636.345,140.063 639.609,136.967 643.761,134.735C647.913,132.503 652.581,131.387 657.765,131.387C662.133,131.387 666.081,132.155 669.609,133.691C673.137,135.227 676.101,137.435 678.501,140.315L671.013,147.227C667.605,143.291 663.381,141.323 658.341,141.323C655.221,141.323 652.437,142.007 649.989,143.375C647.541,144.743 645.633,146.651 644.265,149.099C642.897,151.547 642.213,154.331 642.213,157.451C642.213,160.571 642.897,163.355 644.265,165.803C645.633,168.251 647.541,170.159 649.989,171.527C652.437,172.895 655.221,173.579 658.341,173.579C663.381,173.579 667.605,171.587 671.013,167.603L678.501,174.515C676.101,177.443 673.125,179.675 669.573,181.211C666.021,182.747 662.061,183.515 657.693,183.515Z" style="fill:rgb(5,5,14);fill-rule:nonzero;"/>
26
+ <path d="M704.709,162.851L697.941,169.907L697.941,182.651L686.349,182.651L686.349,132.251L697.941,132.251L697.941,155.795L720.261,132.251L733.221,132.251L712.341,154.715L734.445,182.651L720.837,182.651L704.709,162.851Z" style="fill:rgb(5,5,14);fill-rule:nonzero;"/>
27
+ </g>
28
+ </g>
29
+ </g>
30
+ </g>
31
+ <defs>
32
+ <linearGradient id="_Linear1" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(121.538,125.482,-125.482,121.538,1032.25,1687.61)"><stop offset="0" style="stop-color:rgb(132,132,220);stop-opacity:1"/><stop offset="1" style="stop-color:rgb(51,51,180);stop-opacity:1"/></linearGradient>
33
+ </defs>
34
+ </svg>
Binary file
@@ -0,0 +1,34 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
3
+ <svg width="100%" height="100%" viewBox="0 0 291 223" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:1.41421;">
4
+ <g transform="matrix(1,0,0,1,-1132.77,-491.089)">
5
+ <g transform="matrix(1,0,0,1,1076.45,0)">
6
+ <g transform="matrix(1.25996,0,0,1.25996,-1171.73,-1635.23)">
7
+ <path d="M1032.25,1691.49C1032.25,1689.34 1033.99,1687.61 1036.13,1687.61C1049.74,1687.61 1094.52,1687.61 1094.52,1687.61L1094.52,1687.61C1117.36,1687.65 1135.89,1706.2 1135.89,1729.05C1135.89,1741.48 1128.4,1752.63 1119.73,1760.23C1119.73,1760.23 1137.85,1791.63 1144.29,1802.78C1144.75,1803.58 1144.75,1804.56 1144.29,1805.36C1143.83,1806.16 1142.98,1806.65 1142.05,1806.65C1132.41,1806.65 1110.05,1806.65 1104.08,1806.65C1103.15,1806.65 1102.3,1806.16 1101.84,1805.36C1098.12,1798.91 1081.71,1770.49 1081.71,1770.49L1073.76,1770.49C1073.76,1770.49 1073.76,1794.23 1073.76,1803.24C1073.76,1805.12 1072.24,1806.65 1070.35,1806.65C1062.55,1806.65 1043.46,1806.65 1035.66,1806.65C1034.75,1806.65 1033.89,1806.29 1033.25,1805.65C1032.61,1805.01 1032.25,1804.14 1032.25,1803.24C1032.25,1786.12 1032.25,1709.65 1032.25,1691.49Z" style="fill:url(#_Linear1);"/>
8
+ <clipPath id="_clip2">
9
+ <path d="M1032.25,1691.49C1032.25,1689.34 1033.99,1687.61 1036.13,1687.61C1049.74,1687.61 1094.52,1687.61 1094.52,1687.61L1094.52,1687.61C1117.36,1687.65 1135.89,1706.2 1135.89,1729.05C1135.89,1741.48 1128.4,1752.63 1119.73,1760.23C1119.73,1760.23 1137.85,1791.63 1144.29,1802.78C1144.75,1803.58 1144.75,1804.56 1144.29,1805.36C1143.83,1806.16 1142.98,1806.65 1142.05,1806.65C1132.41,1806.65 1110.05,1806.65 1104.08,1806.65C1103.15,1806.65 1102.3,1806.16 1101.84,1805.36C1098.12,1798.91 1081.71,1770.49 1081.71,1770.49L1073.76,1770.49C1073.76,1770.49 1073.76,1794.23 1073.76,1803.24C1073.76,1805.12 1072.24,1806.65 1070.35,1806.65C1062.55,1806.65 1043.46,1806.65 1035.66,1806.65C1034.75,1806.65 1033.89,1806.29 1033.25,1805.65C1032.61,1805.01 1032.25,1804.14 1032.25,1803.24C1032.25,1786.12 1032.25,1709.65 1032.25,1691.49Z"/>
10
+ </clipPath>
11
+ <g clip-path="url(#_clip2)">
12
+ <g transform="matrix(1.05537,0,0,1.05537,-56.2001,-93.6352)">
13
+ <path d="M1090.07,1757.11C1087.62,1757.78 1085.05,1758.14 1082.39,1758.14C1066.34,1758.14 1053.3,1745.1 1053.3,1729.05C1053.3,1712.99 1066.34,1699.96 1082.39,1699.96C1098.45,1699.96 1111.49,1712.99 1111.49,1729.05C1111.49,1738.8 1106.68,1747.44 1099.3,1752.72C1099.3,1752.72 1110.29,1771.75 1116.66,1782.78C1117.57,1784.36 1117.57,1786.31 1116.66,1787.89C1115.75,1789.47 1114.06,1790.44 1112.23,1790.44C1112.23,1790.44 1112.23,1790.44 1112.23,1790.44C1110.43,1790.44 1108.76,1789.48 1107.86,1787.92C1103.37,1780.15 1090.07,1757.11 1090.07,1757.11ZM1082.52,1708.18C1084.31,1708.32 1084.32,1708.88 1084.66,1709.62C1085.4,1711.22 1084.12,1713.13 1081.99,1713.18C1073.82,1713.44 1066.55,1720.54 1066.53,1729.05C1066.53,1729.05 1066.41,1730.38 1065.53,1731.04C1063.81,1732.34 1061.32,1730.94 1061.59,1727.44C1062.36,1717.22 1071.49,1708.34 1082.13,1708.18C1082.26,1708.18 1082.39,1708.18 1082.52,1708.18Z" style="fill:rgb(52,52,107);fill-opacity:0.4;"/>
14
+ </g>
15
+ <path d="M1090.07,1757.11C1087.62,1757.78 1085.05,1758.14 1082.39,1758.14C1066.34,1758.14 1053.3,1745.1 1053.3,1729.05C1053.3,1712.99 1066.34,1699.96 1082.39,1699.96C1098.45,1699.96 1111.49,1712.99 1111.49,1729.05C1111.49,1738.8 1106.68,1747.44 1099.3,1752.72C1099.3,1752.72 1110.19,1771.58 1116.57,1782.63C1117.5,1784.24 1117.5,1786.23 1116.57,1787.84C1115.64,1789.45 1113.92,1790.44 1112.06,1790.44C1112.06,1790.44 1112.06,1790.44 1112.06,1790.44C1110.36,1790.44 1108.79,1789.54 1107.94,1788.07C1103.54,1780.44 1090.07,1757.11 1090.07,1757.11ZM1082.52,1708.18C1084.31,1708.32 1084.32,1708.88 1084.66,1709.62C1085.4,1711.22 1084.12,1713.13 1081.99,1713.18C1073.82,1713.44 1066.55,1720.54 1066.53,1729.05C1066.53,1729.05 1066.41,1730.38 1065.53,1731.04C1063.81,1732.34 1061.32,1730.94 1061.59,1727.44C1062.36,1717.22 1071.49,1708.34 1082.13,1708.18C1082.26,1708.18 1082.39,1708.18 1082.52,1708.18Z" style="fill:rgb(251,248,255);"/>
16
+ </g>
17
+ </g>
18
+ </g>
19
+ <g transform="matrix(1,0,0,1,1076.45,0)">
20
+ <g transform="matrix(0.789583,0,0,0.789583,-233.422,568.437)">
21
+ <path d="M399.069,182.651L389.349,168.611L388.773,168.611L378.621,168.611L378.621,182.651L366.957,182.651L366.957,132.251L388.773,132.251C393.237,132.251 397.113,132.995 400.401,134.483C403.689,135.971 406.221,138.083 407.997,140.819C409.773,143.555 410.661,146.795 410.661,150.539C410.661,154.283 409.761,157.511 407.961,160.223C406.161,162.935 403.605,165.011 400.293,166.451L411.597,182.651L399.069,182.651ZM398.853,150.539C398.853,147.707 397.941,145.535 396.117,144.023C394.293,142.511 391.629,141.755 388.125,141.755L378.621,141.755L378.621,159.323L388.125,159.323C391.629,159.323 394.293,158.555 396.117,157.019C397.941,155.483 398.853,153.323 398.853,150.539Z" style="fill:rgb(5,5,14);fill-rule:nonzero;"/>
22
+ <path d="M453.069,171.851L429.669,171.851L425.205,182.651L413.253,182.651L435.717,132.251L447.237,132.251L469.773,182.651L457.533,182.651L453.069,171.851ZM449.397,162.995L441.405,143.699L433.413,162.995L449.397,162.995Z" style="fill:rgb(5,5,14);fill-rule:nonzero;"/>
23
+ <path d="M521.253,132.251L521.253,182.651L511.677,182.651L486.549,152.051L486.549,182.651L475.029,182.651L475.029,132.251L484.677,132.251L509.733,162.851L509.733,132.251L521.253,132.251Z" style="fill:rgb(5,5,14);fill-rule:nonzero;"/>
24
+ <path d="M549.765,183.515C545.781,183.515 541.929,182.975 538.209,181.895C534.489,180.815 531.501,179.411 529.245,177.683L533.205,168.899C535.365,170.483 537.933,171.755 540.909,172.715C543.885,173.675 546.861,174.155 549.837,174.155C553.149,174.155 555.597,173.663 557.181,172.679C558.765,171.695 559.557,170.387 559.557,168.755C559.557,167.555 559.089,166.559 558.153,165.767C557.217,164.975 556.017,164.339 554.553,163.859C553.089,163.379 551.109,162.851 548.613,162.275C544.773,161.363 541.629,160.451 539.181,159.539C536.733,158.627 534.633,157.163 532.881,155.147C531.129,153.131 530.253,150.443 530.253,147.083C530.253,144.155 531.045,141.503 532.629,139.127C534.213,136.751 536.601,134.867 539.793,133.475C542.985,132.083 546.885,131.387 551.493,131.387C554.709,131.387 557.853,131.771 560.925,132.539C563.997,133.307 566.685,134.411 568.989,135.851L565.389,144.707C560.733,142.067 556.077,140.747 551.421,140.747C548.157,140.747 545.745,141.275 544.185,142.331C542.625,143.387 541.845,144.779 541.845,146.507C541.845,148.235 542.745,149.519 544.545,150.359C546.345,151.199 549.093,152.027 552.789,152.843C556.629,153.755 559.773,154.667 562.221,155.579C564.669,156.491 566.769,157.931 568.521,159.899C570.273,161.867 571.149,164.531 571.149,167.891C571.149,170.771 570.345,173.399 568.737,175.775C567.129,178.151 564.717,180.035 561.501,181.427C558.285,182.819 554.373,183.515 549.765,183.515Z" style="fill:rgb(5,5,14);fill-rule:nonzero;"/>
25
+ <path d="M612.333,171.851L588.933,171.851L584.469,182.651L572.517,182.651L594.981,132.251L606.501,132.251L629.037,182.651L616.797,182.651L612.333,171.851ZM608.661,162.995L600.669,143.699L592.677,162.995L608.661,162.995Z" style="fill:rgb(5,5,14);fill-rule:nonzero;"/>
26
+ <path d="M657.693,183.515C652.557,183.515 647.913,182.399 643.761,180.167C639.609,177.935 636.345,174.839 633.969,170.879C631.593,166.919 630.405,162.443 630.405,157.451C630.405,152.459 631.593,147.983 633.969,144.023C636.345,140.063 639.609,136.967 643.761,134.735C647.913,132.503 652.581,131.387 657.765,131.387C662.133,131.387 666.081,132.155 669.609,133.691C673.137,135.227 676.101,137.435 678.501,140.315L671.013,147.227C667.605,143.291 663.381,141.323 658.341,141.323C655.221,141.323 652.437,142.007 649.989,143.375C647.541,144.743 645.633,146.651 644.265,149.099C642.897,151.547 642.213,154.331 642.213,157.451C642.213,160.571 642.897,163.355 644.265,165.803C645.633,168.251 647.541,170.159 649.989,171.527C652.437,172.895 655.221,173.579 658.341,173.579C663.381,173.579 667.605,171.587 671.013,167.603L678.501,174.515C676.101,177.443 673.125,179.675 669.573,181.211C666.021,182.747 662.061,183.515 657.693,183.515Z" style="fill:rgb(5,5,14);fill-rule:nonzero;"/>
27
+ <path d="M704.709,162.851L697.941,169.907L697.941,182.651L686.349,182.651L686.349,132.251L697.941,132.251L697.941,155.795L720.261,132.251L733.221,132.251L712.341,154.715L734.445,182.651L720.837,182.651L704.709,162.851Z" style="fill:rgb(5,5,14);fill-rule:nonzero;"/>
28
+ </g>
29
+ </g>
30
+ </g>
31
+ <defs>
32
+ <linearGradient id="_Linear1" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(121.538,125.482,-125.482,121.538,1032.25,1687.61)"><stop offset="0" style="stop-color:rgb(132,132,220);stop-opacity:1"/><stop offset="1" style="stop-color:rgb(51,51,180);stop-opacity:1"/></linearGradient>
33
+ </defs>
34
+ </svg>
data/logo/ransack.png ADDED
Binary file
data/logo/ransack.svg ADDED
@@ -0,0 +1,21 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
3
+ <svg width="100%" height="100%" viewBox="0 0 401 417" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:1.41421;">
4
+ <g transform="matrix(1,0,0,1,-199.992,-191.649)">
5
+ <g transform="matrix(3.50044,0,0,3.50044,-3413.33,-5715.71)">
6
+ <path d="M1032.25,1689C1032.25,1688.23 1032.87,1687.61 1033.64,1687.61C1042.86,1687.61 1094.52,1687.61 1094.52,1687.61L1094.52,1687.61C1117.36,1687.65 1135.89,1706.2 1135.89,1729.05C1135.89,1741.48 1128.4,1752.63 1119.73,1760.23C1119.73,1760.23 1141.26,1797.52 1145.72,1805.26C1145.88,1805.54 1145.88,1805.9 1145.72,1806.18C1145.55,1806.47 1145.25,1806.65 1144.91,1806.65C1137.59,1806.65 1107.52,1806.65 1103.12,1806.65C1102.79,1806.65 1102.49,1806.47 1102.32,1806.18C1099.89,1801.97 1081.71,1770.49 1081.71,1770.49L1073.76,1770.49C1073.76,1770.49 1073.76,1799.1 1073.76,1805.42C1073.76,1806.1 1073.21,1806.65 1072.54,1806.65C1066.45,1806.65 1039.56,1806.65 1033.47,1806.65C1032.8,1806.65 1032.25,1806.1 1032.25,1805.42C1032.25,1793.69 1032.25,1701.48 1032.25,1689Z" style="fill:url(#_Linear1);"/>
7
+ <clipPath id="_clip2">
8
+ <path d="M1032.25,1689C1032.25,1688.23 1032.87,1687.61 1033.64,1687.61C1042.86,1687.61 1094.52,1687.61 1094.52,1687.61L1094.52,1687.61C1117.36,1687.65 1135.89,1706.2 1135.89,1729.05C1135.89,1741.48 1128.4,1752.63 1119.73,1760.23C1119.73,1760.23 1141.26,1797.52 1145.72,1805.26C1145.88,1805.54 1145.88,1805.9 1145.72,1806.18C1145.55,1806.47 1145.25,1806.65 1144.91,1806.65C1137.59,1806.65 1107.52,1806.65 1103.12,1806.65C1102.79,1806.65 1102.49,1806.47 1102.32,1806.18C1099.89,1801.97 1081.71,1770.49 1081.71,1770.49L1073.76,1770.49C1073.76,1770.49 1073.76,1799.1 1073.76,1805.42C1073.76,1806.1 1073.21,1806.65 1072.54,1806.65C1066.45,1806.65 1039.56,1806.65 1033.47,1806.65C1032.8,1806.65 1032.25,1806.1 1032.25,1805.42C1032.25,1793.69 1032.25,1701.48 1032.25,1689Z"/>
9
+ </clipPath>
10
+ <g clip-path="url(#_clip2)">
11
+ <g transform="matrix(1.05537,0,0,1.05537,-56.2001,-93.6352)">
12
+ <path d="M1090.07,1757.11C1087.62,1757.78 1085.05,1758.14 1082.39,1758.14C1066.34,1758.14 1053.3,1745.1 1053.3,1729.05C1053.3,1712.99 1066.34,1699.96 1082.39,1699.96C1098.45,1699.96 1111.49,1712.99 1111.49,1729.05C1111.49,1738.8 1106.68,1747.44 1099.3,1752.72C1099.3,1752.72 1110.29,1771.75 1116.66,1782.78C1117.57,1784.36 1117.57,1786.31 1116.66,1787.89C1115.75,1789.47 1114.06,1790.44 1112.23,1790.44C1112.23,1790.44 1112.23,1790.44 1112.23,1790.44C1110.43,1790.44 1108.76,1789.48 1107.86,1787.92C1103.37,1780.15 1090.07,1757.11 1090.07,1757.11ZM1082.52,1708.18C1084.31,1708.32 1084.32,1708.88 1084.66,1709.62C1085.4,1711.22 1084.12,1713.13 1081.99,1713.18C1073.82,1713.44 1066.55,1720.54 1066.53,1729.05C1066.53,1729.05 1066.41,1730.38 1065.53,1731.04C1063.81,1732.34 1061.32,1730.94 1061.59,1727.44C1062.36,1717.22 1071.49,1708.34 1082.13,1708.18C1082.26,1708.18 1082.39,1708.18 1082.52,1708.18Z" style="fill:rgb(52,52,107);fill-opacity:0.4;"/>
13
+ </g>
14
+ <path d="M1090.07,1757.11C1087.62,1757.78 1085.05,1758.14 1082.39,1758.14C1066.34,1758.14 1053.3,1745.1 1053.3,1729.05C1053.3,1712.99 1066.34,1699.96 1082.39,1699.96C1098.45,1699.96 1111.49,1712.99 1111.49,1729.05C1111.49,1738.8 1106.68,1747.44 1099.3,1752.72C1099.3,1752.72 1110.19,1771.58 1116.57,1782.63C1117.5,1784.24 1117.5,1786.23 1116.57,1787.84C1115.64,1789.45 1113.92,1790.44 1112.06,1790.44C1112.06,1790.44 1112.06,1790.44 1112.06,1790.44C1110.36,1790.44 1108.79,1789.54 1107.94,1788.07C1103.54,1780.44 1090.07,1757.11 1090.07,1757.11ZM1082.52,1708.18C1084.31,1708.32 1084.32,1708.88 1084.66,1709.62C1085.4,1711.22 1084.12,1713.13 1081.99,1713.18C1073.82,1713.44 1066.55,1720.54 1066.53,1729.05C1066.53,1729.05 1066.41,1730.38 1065.53,1731.04C1063.81,1732.34 1061.32,1730.94 1061.59,1727.44C1062.36,1717.22 1071.49,1708.34 1082.13,1708.18C1082.26,1708.18 1082.39,1708.18 1082.52,1708.18Z" style="fill:rgb(251,248,255);"/>
15
+ </g>
16
+ </g>
17
+ </g>
18
+ <defs>
19
+ <linearGradient id="_Linear1" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(121.538,125.482,-125.482,121.538,1032.25,1687.61)"><stop offset="0" style="stop-color:rgb(132,132,220);stop-opacity:1"/><stop offset="1" style="stop-color:rgb(51,51,180);stop-opacity:1"/></linearGradient>
20
+ </defs>
21
+ </svg>
data/ransack.gemspec CHANGED
@@ -6,37 +6,20 @@ Gem::Specification.new do |s|
6
6
  s.name = "ransack"
7
7
  s.version = Ransack::VERSION
8
8
  s.platform = Gem::Platform::RUBY
9
- s.authors = ["Ernie Miller", "Ryan Bigg", "Jon Atack"]
10
- s.email = ["ernie@erniemiller.org", "radarlistener@gmail.com", "jonnyatack@gmail.com"]
9
+ s.authors = ["Ernie Miller", "Ryan Bigg", "Jon Atack","Sean Carroll"]
10
+ s.email = ["ernie@erniemiller.org", "radarlistener@gmail.com", "jonnyatack@gmail.com","sfcarroll@gmail.com"]
11
11
  s.homepage = "https://github.com/activerecord-hackery/ransack"
12
12
  s.summary = %q{Object-based searching for Active Record and Mongoid (currently).}
13
13
  s.description = %q{Ransack is the successor to the MetaSearch gem. It improves and expands upon MetaSearch's functionality, but does not have a 100%-compatible API.}
14
- s.required_ruby_version = '>= 1.9'
14
+ s.required_ruby_version = '>= 2.3'
15
15
  s.license = 'MIT'
16
16
 
17
- s.rubyforge_project = "ransack"
18
-
19
- s.add_dependency 'actionpack', '>= 3.0'
20
- s.add_dependency 'activerecord', '>= 3.0'
21
- s.add_dependency 'activesupport', '>= 3.0'
17
+ s.add_dependency 'activerecord', '>= 5.2.4'
18
+ s.add_dependency 'activesupport', '>= 5.2.4'
22
19
  s.add_dependency 'i18n'
23
- s.add_dependency 'polyamorous', '~> 1.2'
24
- s.add_development_dependency 'rspec', '~> 2'
25
- s.add_development_dependency 'machinist', '~> 1.0.6'
26
- s.add_development_dependency 'faker', '~> 0.9.5'
27
- s.add_development_dependency 'sqlite3', '~> 1.3.3'
28
- s.add_development_dependency 'pg'
29
- s.add_development_dependency 'mysql2', '0.3.18'
30
- s.add_development_dependency 'pry', '0.9.12.2'
31
20
 
32
21
  s.files = `git ls-files`.split("\n")
33
-
34
- s.test_files = `git ls-files -- {test,spec,features}/*`
35
- .split("\n")
36
-
37
- s.executables = `git ls-files -- bin/*`
38
- .split("\n")
39
- .map { |f| File.basename(f) }
40
-
22
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
23
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
41
24
  s.require_paths = ["lib"]
42
25
  end
data/spec/console.rb CHANGED
@@ -16,6 +16,10 @@ Sham.define do
16
16
  salary { |index| 30000 + (index * 1000) }
17
17
  tag_name { Faker::Lorem.words(3).join(' ') }
18
18
  note { Faker::Lorem.words(7).join(' ') }
19
+ only_admin { Faker::Lorem.words(3).join(' ') }
20
+ only_search { Faker::Lorem.words(3).join(' ') }
21
+ only_sort { Faker::Lorem.words(3).join(' ') }
22
+ notable_id { |id| id }
19
23
  end
20
24
 
21
25
  Schema.create
@@ -0,0 +1,19 @@
1
+ module PolyamorousHelper
2
+ def new_join_association(reflection, children, klass)
3
+ Polyamorous::JoinAssociation.new reflection, children, klass
4
+ end
5
+
6
+ if ActiveRecord.version >= ::Gem::Version.new("6.0.0.rc1")
7
+ def new_join_dependency(klass, associations = {})
8
+ Polyamorous::JoinDependency.new klass, klass.arel_table, associations, Polyamorous::InnerJoin
9
+ end
10
+ else
11
+ def new_join_dependency(klass, associations = {})
12
+ Polyamorous::JoinDependency.new klass, klass.arel_table, associations
13
+ end
14
+ end
15
+
16
+ def new_join(name, type = Polyamorous::InnerJoin, klass = nil)
17
+ Polyamorous::Join.new name, type, klass
18
+ end
19
+ end
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ module Polyamorous
4
+ describe JoinAssociation do
5
+
6
+ let(:join_dependency) { new_join_dependency Note, {} }
7
+ let(:reflection) { Note.reflect_on_association(:notable) }
8
+ let(:parent) { join_dependency.send(:join_root) }
9
+ let(:join_association) {
10
+ new_join_association(reflection, parent.children, Article)
11
+ }
12
+
13
+ subject { new_join_association(reflection, parent.children, Person) }
14
+
15
+ it 'respects polymorphism on equality test' do
16
+ expect(subject).to eq new_join_association(reflection, parent.children, Person)
17
+ expect(subject).not_to eq new_join_association(reflection, parent.children, Article)
18
+ end
19
+
20
+ it 'leaves the orginal reflection intact for thread safety' do
21
+ reflection.instance_variable_set(:@klass, Article)
22
+ join_association
23
+ .swapping_reflection_klass(reflection, Person) do |new_reflection|
24
+ expect(new_reflection.options).not_to equal reflection.options
25
+ expect(new_reflection.options).not_to have_key(:polymorphic)
26
+ expect(new_reflection.klass).to eq(Person)
27
+ expect(reflection.klass).to eq(Article)
28
+ end
29
+ end
30
+
31
+ it 'sets the polymorphic option to true after initializing' do
32
+ expect(join_association.reflection.options[:polymorphic]).to be true
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,97 @@
1
+ require 'spec_helper'
2
+
3
+ module Polyamorous
4
+ describe JoinDependency do
5
+
6
+ context 'with symbol joins' do
7
+ subject { new_join_dependency Person, articles: :comments }
8
+
9
+ specify { expect(subject.send(:join_root).drop(1).size)
10
+ .to eq(2) }
11
+ specify { expect(subject.send(:join_root).drop(1).map(&:join_type).uniq)
12
+ .to eq [Polyamorous::InnerJoin] }
13
+ end
14
+
15
+ context 'with has_many :through association' do
16
+ subject { new_join_dependency Person, :authored_article_comments }
17
+
18
+ specify { expect(subject.send(:join_root).drop(1).size)
19
+ .to eq 1 }
20
+ specify { expect(subject.send(:join_root).drop(1).first.table_name)
21
+ .to eq 'comments' }
22
+ end
23
+
24
+ context 'with outer join' do
25
+ subject { new_join_dependency Person, new_join(:articles, :outer) }
26
+
27
+ specify { expect(subject.send(:join_root).drop(1).size)
28
+ .to eq 1 }
29
+ specify { expect(subject.send(:join_root).drop(1).first.join_type)
30
+ .to eq Polyamorous::OuterJoin }
31
+ end
32
+
33
+ context 'with nested outer joins' do
34
+ subject { new_join_dependency Person,
35
+ new_join(:articles, :outer) => new_join(:comments, :outer) }
36
+
37
+ specify { expect(subject.send(:join_root).drop(1).size)
38
+ .to eq 2 }
39
+ specify { expect(subject.send(:join_root).drop(1).map(&:join_type))
40
+ .to eq [Polyamorous::OuterJoin, Polyamorous::OuterJoin] }
41
+ specify { expect(subject.send(:join_root).drop(1).map(&:join_type).uniq)
42
+ .to eq [Polyamorous::OuterJoin] }
43
+ end
44
+
45
+ context 'with polymorphic belongs_to join' do
46
+ subject { new_join_dependency Note, new_join(:notable, :inner, Person) }
47
+
48
+ specify { expect(subject.send(:join_root).drop(1).size)
49
+ .to eq 1 }
50
+ specify { expect(subject.send(:join_root).drop(1).first.join_type)
51
+ .to eq Polyamorous::InnerJoin }
52
+ specify { expect(subject.send(:join_root).drop(1).first.table_name)
53
+ .to eq 'people' }
54
+ end
55
+
56
+ context 'with polymorphic belongs_to join and nested symbol join' do
57
+ subject { new_join_dependency Note,
58
+ new_join(:notable, :inner, Person) => :comments }
59
+
60
+ specify { expect(subject.send(:join_root).drop(1).size)
61
+ .to eq 2 }
62
+ specify { expect(subject.send(:join_root).drop(1).map(&:join_type).uniq)
63
+ .to eq [Polyamorous::InnerJoin] }
64
+ specify { expect(subject.send(:join_root).drop(1).first.table_name)
65
+ .to eq 'people' }
66
+ specify { expect(subject.send(:join_root).drop(1)[1].table_name)
67
+ .to eq 'comments' }
68
+ end
69
+
70
+ context 'with polymorphic belongs_to join and nested join' do
71
+ subject { new_join_dependency Note,
72
+ new_join(:notable, :outer, Person) => :comments }
73
+ specify { expect(subject.send(:join_root).drop(1).size).to eq 2 }
74
+ specify { expect(subject.send(:join_root).drop(1).map(&:join_type)).to eq [Polyamorous::OuterJoin, Polyamorous::InnerJoin] }
75
+ specify { expect(subject.send(:join_root).drop(1).first.table_name)
76
+ .to eq 'people' }
77
+ specify { expect(subject.send(:join_root).drop(1)[1].table_name)
78
+ .to eq 'comments' }
79
+ end
80
+
81
+ context '#left_outer_join in Rails 5 overrides join type specified',
82
+ if: ActiveRecord::VERSION::MAJOR >= 5 && ActiveRecord::VERSION::MAJOR < 6 && ActiveRecord::VERSION::MINOR < 2 do
83
+
84
+ let(:join_type_class) do
85
+ new_join_dependency(
86
+ Person,
87
+ new_join(:articles)
88
+ ).join_constraints(
89
+ [],
90
+ Arel::Nodes::OuterJoin
91
+ ).first.joins.map(&:class)
92
+ end
93
+
94
+ specify { expect(join_type_class).to eq [Arel::Nodes::OuterJoin] }
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ module Polyamorous
4
+ describe Join do
5
+ it 'is a tree node' do
6
+ join = new_join(:articles, :outer)
7
+ expect(join).to be_kind_of(TreeNode)
8
+ end
9
+
10
+ it 'can be added to a tree' do
11
+ join = new_join(:articles, :outer)
12
+
13
+ tree_hash = {}
14
+ join.add_to_tree(tree_hash)
15
+
16
+ expect(tree_hash[join]).to be {}
17
+ end
18
+ end
19
+ end