ransack 2.3.0 → 2.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/.github/FUNDING.yml +3 -0
  3. data/.github/SECURITY.md +12 -0
  4. data/.github/workflows/cronjob.yml +105 -0
  5. data/.github/workflows/rubocop.yml +20 -0
  6. data/.github/workflows/test.yml +154 -0
  7. data/.rubocop.yml +44 -0
  8. data/CHANGELOG.md +31 -1
  9. data/CONTRIBUTING.md +13 -11
  10. data/Gemfile +19 -5
  11. data/README.md +119 -54
  12. data/bug_report_templates/test-ransack-scope-and-column-same-name.rb +78 -0
  13. data/bug_report_templates/test-ransacker-arel-present-predicate.rb +71 -0
  14. data/docs/img/create_release.png +0 -0
  15. data/docs/release_process.md +20 -0
  16. data/{polyamorous/lib/polyamorous/activerecord_5.2.1_ruby_2 → lib/polyamorous/activerecord_5.2_ruby_2}/join_association.rb +4 -2
  17. data/{polyamorous/lib/polyamorous/activerecord_5.2.1_ruby_2 → lib/polyamorous/activerecord_5.2_ruby_2}/join_dependency.rb +0 -2
  18. data/lib/polyamorous/activerecord_5.2_ruby_2/reflection.rb +11 -0
  19. data/lib/polyamorous/activerecord_6.0_ruby_2/join_association.rb +1 -0
  20. data/{polyamorous/lib → lib}/polyamorous/activerecord_6.0_ruby_2/join_dependency.rb +0 -1
  21. data/lib/polyamorous/activerecord_6.0_ruby_2/reflection.rb +1 -0
  22. data/lib/polyamorous/activerecord_6.1_ruby_2/join_association.rb +74 -0
  23. data/lib/polyamorous/activerecord_6.1_ruby_2/join_dependency.rb +93 -0
  24. data/{polyamorous/lib → lib}/polyamorous/activerecord_6.1_ruby_2/reflection.rb +0 -1
  25. data/lib/polyamorous/activerecord_6.2_ruby_2/join_association.rb +1 -0
  26. data/lib/polyamorous/activerecord_6.2_ruby_2/join_dependency.rb +1 -0
  27. data/lib/polyamorous/activerecord_6.2_ruby_2/reflection.rb +1 -0
  28. data/{polyamorous/lib → lib}/polyamorous/join.rb +0 -0
  29. data/{polyamorous/lib → lib/polyamorous}/polyamorous.rb +3 -8
  30. data/{polyamorous/lib → lib}/polyamorous/swapping_reflection_class.rb +0 -0
  31. data/{polyamorous/lib → lib}/polyamorous/tree_node.rb +0 -0
  32. data/lib/ransack.rb +3 -4
  33. data/lib/ransack/adapters/active_record/base.rb +4 -0
  34. data/lib/ransack/adapters/active_record/context.rb +51 -80
  35. data/lib/ransack/adapters/active_record/ransack/constants.rb +13 -1
  36. data/lib/ransack/adapters/active_record/ransack/context.rb +2 -6
  37. data/lib/ransack/adapters/active_record/ransack/nodes/condition.rb +11 -4
  38. data/lib/ransack/configuration.rb +17 -1
  39. data/lib/ransack/constants.rb +2 -5
  40. data/lib/ransack/helpers.rb +1 -1
  41. data/lib/ransack/helpers/form_builder.rb +8 -14
  42. data/lib/ransack/locale/sk.yml +70 -0
  43. data/lib/ransack/nodes/attribute.rb +1 -1
  44. data/lib/ransack/nodes/condition.rb +7 -1
  45. data/lib/ransack/nodes/grouping.rb +1 -1
  46. data/lib/ransack/nodes/sort.rb +1 -1
  47. data/lib/ransack/nodes/value.rb +1 -1
  48. data/lib/ransack/predicate.rb +2 -1
  49. data/lib/ransack/search.rb +3 -1
  50. data/lib/ransack/translate.rb +3 -3
  51. data/lib/ransack/version.rb +1 -1
  52. data/ransack.gemspec +8 -23
  53. data/spec/blueprints/articles.rb +1 -1
  54. data/spec/blueprints/comments.rb +1 -1
  55. data/spec/blueprints/notes.rb +1 -1
  56. data/spec/blueprints/tags.rb +1 -1
  57. data/spec/console.rb +5 -5
  58. data/spec/helpers/polyamorous_helper.rb +1 -10
  59. data/spec/helpers/ransack_helper.rb +1 -1
  60. data/spec/{ransack → polyamorous}/join_association_spec.rb +7 -0
  61. data/spec/{ransack → polyamorous}/join_dependency_spec.rb +0 -0
  62. data/spec/{ransack → polyamorous}/join_spec.rb +0 -0
  63. data/spec/ransack/adapters/active_record/base_spec.rb +9 -6
  64. data/spec/ransack/adapters/active_record/context_spec.rb +19 -18
  65. data/spec/ransack/configuration_spec.rb +10 -0
  66. data/spec/ransack/helpers/form_helper_spec.rb +16 -16
  67. data/spec/ransack/nodes/grouping_spec.rb +2 -2
  68. data/spec/ransack/predicate_spec.rb +39 -1
  69. data/spec/ransack/search_spec.rb +105 -17
  70. data/spec/spec_helper.rb +9 -5
  71. data/spec/support/schema.rb +8 -3
  72. metadata +41 -177
  73. data/.travis.yml +0 -49
  74. data/polyamorous/lib/polyamorous/activerecord_5.0_ruby_2/join_association.rb +0 -2
  75. data/polyamorous/lib/polyamorous/activerecord_5.0_ruby_2/join_dependency.rb +0 -2
  76. data/polyamorous/lib/polyamorous/activerecord_5.1_ruby_2/join_association.rb +0 -31
  77. data/polyamorous/lib/polyamorous/activerecord_5.1_ruby_2/join_dependency.rb +0 -112
  78. data/polyamorous/lib/polyamorous/activerecord_5.2.0_ruby_2/join_association.rb +0 -31
  79. data/polyamorous/lib/polyamorous/activerecord_5.2.0_ruby_2/join_dependency.rb +0 -112
  80. data/polyamorous/lib/polyamorous/activerecord_5.2.0_ruby_2/reflection.rb +0 -12
  81. data/polyamorous/lib/polyamorous/activerecord_5.2.1_ruby_2/reflection.rb +0 -2
  82. data/polyamorous/lib/polyamorous/activerecord_6.0_ruby_2/join_association.rb +0 -2
  83. data/polyamorous/lib/polyamorous/activerecord_6.0_ruby_2/reflection.rb +0 -2
  84. data/polyamorous/lib/polyamorous/activerecord_6.1_ruby_2/join_association.rb +0 -2
  85. data/polyamorous/lib/polyamorous/activerecord_6.1_ruby_2/join_dependency.rb +0 -2
  86. data/polyamorous/lib/polyamorous/version.rb +0 -3
  87. data/polyamorous/polyamorous.gemspec +0 -35
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: be6fda6bbab697d2f125847b2761df81991190d8d9799b5480ac2044441978a0
4
- data.tar.gz: 9f39f157e148aa2c4638b8e9c7ab5a8b14221f315e880c04e5f76f3db2a1b473
3
+ metadata.gz: a7e53f2a86ba264e751c3311254c7cb4b25efdb0c876310835b6f6221ab24928
4
+ data.tar.gz: 161ca5255a24fa42c63d6afbbf38e518581189db773e7e43940b31b1b8d86850
5
5
  SHA512:
6
- metadata.gz: 2fc2082431692f609ddb39171876ade4e1eb4ce715ad917f196db6714a1f55872852c61dec20a047bf48b31f9cab812417fb94f1e9ae9786771320cbd6bc54a4
7
- data.tar.gz: ea1ed1a393fe699432f7012facf66e01b48725d73eb7c8956f17435b447ce745fb65c235425cc28079ba1b1c74d64ba758710f25793f738ea92a49f5409abb68
6
+ metadata.gz: 17c4701dbf3523dfa16feae0dd0dddc8bd077237d7e695eb69664f1b9c5ab5e2fea4a59b5878fe8e607b135ea834f12284f03c42a9ce2971f2f9c9b65d347205
7
+ data.tar.gz: 4c9d09980609ffc43bc505a947781b9fcdc97efb7897c3bbc3278d8391ab219e4fdffd8a813272a3af7403eefc162fddb6f9f379b713894d3951ff2fc7a141f3
@@ -0,0 +1,3 @@
1
+ ---
2
+
3
+ tidelift: rubygems/ransack
@@ -0,0 +1,12 @@
1
+ # Security Policy
2
+
3
+ ## Supported Versions
4
+
5
+ At the moment, only the latest major.minor release stream is supported with
6
+ security updates.
7
+
8
+ ## Reporting a Vulnerability
9
+
10
+ Please use the Tidelift security contact to [report a security
11
+ vulnerability](https://tidelift.com/security). Tidelift will coordinate the fix
12
+ and disclosure.
@@ -0,0 +1,105 @@
1
+ name: cronjob
2
+
3
+ on:
4
+ schedule:
5
+ - cron: "0 0 * * *"
6
+
7
+ jobs:
8
+ sqlite3:
9
+ runs-on: ubuntu-20.04
10
+ strategy:
11
+ fail-fast: false
12
+ matrix:
13
+ ruby:
14
+ - 3.0.0
15
+ - 2.7.2
16
+ - 2.6.6
17
+ env:
18
+ DB: sqlite3
19
+ RAILS: main
20
+ steps:
21
+ - uses: actions/checkout@v2
22
+ - name: Set up Ruby
23
+ uses: ruby/setup-ruby@v1
24
+ with:
25
+ ruby-version: ${{ matrix.ruby }}
26
+ - name: Install dependencies
27
+ run: bundle install
28
+ - name: Run tests
29
+ run: bundle exec rspec
30
+
31
+ mysql:
32
+ runs-on: ubuntu-20.04
33
+ strategy:
34
+ fail-fast: false
35
+ matrix:
36
+ ruby:
37
+ - 3.0.0
38
+ - 2.7.2
39
+ - 2.6.6
40
+ env:
41
+ DB: mysql
42
+ RAILS: main
43
+ MYSQL_USERNAME: root
44
+ MYSQL_PASSWORD: root
45
+ steps:
46
+ - uses: actions/checkout@v2
47
+ - name: Set up Ruby
48
+ uses: ruby/setup-ruby@v1
49
+ with:
50
+ ruby-version: ${{ matrix.ruby }}
51
+ - name: Startup MySQL
52
+ run: |
53
+ sudo systemctl start mysql.service
54
+ - name: Setup databases
55
+ run: |
56
+ mysql --user=root --password=root --host=127.0.0.1 -e 'create database ransack collate utf8_general_ci;';
57
+ mysql --user=root --password=root --host=127.0.0.1 -e 'use ransack;show variables like "%character%";show variables like "%collation%";';
58
+ - name: Install dependencies
59
+ run: bundle install
60
+ - name: Run tests
61
+ run: bundle exec rspec
62
+
63
+ postgres:
64
+ runs-on: ubuntu-20.04
65
+ strategy:
66
+ fail-fast: false
67
+ matrix:
68
+ ruby:
69
+ - 3.0.0
70
+ - 2.7.2
71
+ - 2.6.6
72
+ env:
73
+ DB: postgres
74
+ RAILS: main
75
+ DATABASE_USERNAME: postgres
76
+ DATABASE_PASSWORD: postgres
77
+ DATABASE_HOST: 127.0.0.1
78
+ services:
79
+ postgres:
80
+ image: postgres
81
+ ports:
82
+ - 5432:5432
83
+ env:
84
+ POSTGRES_PASSWORD: postgres
85
+ POSTGRES_HOST_AUTH_METHOD: trust
86
+ # Set health checks to wait until postgres has started
87
+ options: >-
88
+ --health-cmd pg_isready
89
+ --health-interval 10s
90
+ --health-timeout 5s
91
+ --health-retries 5
92
+
93
+ steps:
94
+ - uses: actions/checkout@v2
95
+ - name: Set up Ruby
96
+ uses: ruby/setup-ruby@v1
97
+ with:
98
+ ruby-version: ${{ matrix.ruby }}
99
+ - name: Setup databases
100
+ run: |
101
+ psql -h localhost -p 5432 -W postgres -c 'create database ransack;' -U postgres;
102
+ - name: Install dependencies
103
+ run: bundle install
104
+ - name: Run tests
105
+ run: bundle exec rspec
@@ -0,0 +1,20 @@
1
+ name: rubocop
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+
7
+ jobs:
8
+ build:
9
+ runs-on: ubuntu-20.04
10
+
11
+ steps:
12
+ - uses: actions/checkout@v2
13
+ - name: Set up Ruby
14
+ uses: ruby/setup-ruby@v1
15
+ with:
16
+ ruby-version: 3.0.0
17
+ - name: Install gems
18
+ run: bundle install --jobs 4 --retry 3
19
+ - name: Run RuboCop
20
+ run: bundle exec rubocop --parallel
@@ -0,0 +1,154 @@
1
+ name: test
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+
7
+ jobs:
8
+ sqlite3:
9
+ runs-on: ubuntu-20.04
10
+ strategy:
11
+ fail-fast: false
12
+ matrix:
13
+ rails:
14
+ - v6.1.1
15
+ - v6.0.3
16
+ - 6-0-stable
17
+ - 5-2-stable
18
+ - v5.2.4
19
+ ruby:
20
+ - 3.0.0
21
+ - 2.7.2
22
+ - 2.6.6
23
+ exclude:
24
+ - rails: v5.2.4
25
+ ruby: 3.0.0
26
+ - rails: 5-2-stable
27
+ ruby: 3.0.0
28
+ env:
29
+ DB: sqlite3
30
+ RAILS: ${{ matrix.rails }}
31
+ steps:
32
+ - uses: actions/checkout@v2
33
+ - name: Set up Ruby
34
+ uses: ruby/setup-ruby@v1
35
+ with:
36
+ ruby-version: ${{ matrix.ruby }}
37
+ - name: Install dependencies
38
+ run: bundle install
39
+ - name: Run tests
40
+ run: bundle exec rspec
41
+
42
+ mysql:
43
+ runs-on: ubuntu-20.04
44
+ strategy:
45
+ fail-fast: false
46
+ matrix:
47
+ rails:
48
+ - v6.1.1
49
+ - v6.0.3
50
+ - 6-0-stable
51
+ - 5-2-stable
52
+ - v5.2.4
53
+ ruby:
54
+ - 3.0.0
55
+ - 2.7.2
56
+ - 2.6.6
57
+ exclude:
58
+ - rails: v5.2.4
59
+ ruby: 3.0.0
60
+ - rails: 5-2-stable
61
+ ruby: 3.0.0
62
+ env:
63
+ DB: mysql
64
+ RAILS: ${{ matrix.rails }}
65
+ MYSQL_USERNAME: root
66
+ MYSQL_PASSWORD: root
67
+ steps:
68
+ - uses: actions/checkout@v2
69
+ - name: Set up Ruby
70
+ uses: ruby/setup-ruby@v1
71
+ with:
72
+ ruby-version: ${{ matrix.ruby }}
73
+ - name: Startup MySQL
74
+ run: |
75
+ sudo systemctl start mysql.service
76
+ - name: Setup databases
77
+ run: |
78
+ mysql --user=root --password=root --host=127.0.0.1 -e 'create database ransack collate utf8_general_ci;';
79
+ mysql --user=root --password=root --host=127.0.0.1 -e 'use ransack;show variables like "%character%";show variables like "%collation%";';
80
+ - name: Install dependencies
81
+ run: bundle install
82
+ - name: Run tests
83
+ run: bundle exec rspec
84
+
85
+ postgres:
86
+ runs-on: ubuntu-20.04
87
+ strategy:
88
+ fail-fast: false
89
+ matrix:
90
+ rails:
91
+ - v6.1.1
92
+ - v6.0.3
93
+ - 6-0-stable
94
+ - 5-2-stable
95
+ - v5.2.4
96
+ ruby:
97
+ - 3.0.0
98
+ - 2.7.2
99
+ - 2.6.6
100
+ exclude:
101
+ - rails: v5.2.4
102
+ ruby: 3.0.0
103
+ - rails: 5-2-stable
104
+ ruby: 3.0.0
105
+ env:
106
+ DB: postgres
107
+ RAILS: ${{ matrix.rails }}
108
+ DATABASE_USERNAME: postgres
109
+ DATABASE_PASSWORD: postgres
110
+ DATABASE_HOST: 127.0.0.1
111
+ services:
112
+ postgres:
113
+ image: postgres
114
+ ports:
115
+ - 5432:5432
116
+ env:
117
+ POSTGRES_PASSWORD: postgres
118
+ POSTGRES_HOST_AUTH_METHOD: trust
119
+ # Set health checks to wait until postgres has started
120
+ options: >-
121
+ --health-cmd pg_isready
122
+ --health-interval 10s
123
+ --health-timeout 5s
124
+ --health-retries 5
125
+
126
+ steps:
127
+ - uses: actions/checkout@v2
128
+ - name: Set up Ruby
129
+ uses: ruby/setup-ruby@v1
130
+ with:
131
+ ruby-version: ${{ matrix.ruby }}
132
+ - name: Setup databases
133
+ run: |
134
+ psql -h localhost -p 5432 -W postgres -c 'create database ransack;' -U postgres;
135
+ - name: Install dependencies
136
+ run: bundle install
137
+ - name: Run tests
138
+ run: bundle exec rspec
139
+
140
+ bug-report-templates:
141
+ runs-on: ubuntu-20.04
142
+ steps:
143
+ - uses: actions/checkout@v2
144
+ - name: Set up Ruby
145
+ uses: ruby/setup-ruby@v1
146
+ with:
147
+ ruby-version: 3.0.0
148
+ - name: Install dependencies
149
+ run: bundle install
150
+ - name: Run bug report templates
151
+ run: |
152
+ ruby bug_report_templates/test-ransacker-arel-present-predicate.rb
153
+ ruby bug_report_templates/test-ransack-scope-and-column-same-name.rb
154
+ rm Gemfile Gemfile.lock
@@ -0,0 +1,44 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+
4
+ DisabledByDefault: true
5
+
6
+ Layout/EmptyLineAfterMagicComment:
7
+ Enabled: true
8
+
9
+ Layout/EmptyLineBetweenDefs:
10
+ Enabled: true
11
+
12
+ Layout/EmptyLines:
13
+ Enabled: true
14
+
15
+ Layout/FirstArrayElementIndentation:
16
+ EnforcedStyle: consistent
17
+
18
+ Layout/SpaceAfterComma:
19
+ Enabled: true
20
+
21
+ Layout/SpaceInsideBlockBraces:
22
+ Enabled: true
23
+
24
+ Layout/SpaceInsideHashLiteralBraces:
25
+ Enabled: true
26
+
27
+ Layout/SpaceInsideParens:
28
+ Enabled: true
29
+
30
+ Layout/TrailingEmptyLines:
31
+ Enabled: true
32
+
33
+ Style/RedundantFileExtensionInRequire:
34
+ Enabled: true
35
+
36
+ Style/RedundantReturn:
37
+ Enabled: true
38
+
39
+ Style/SelfAssignment:
40
+ Enabled: true
41
+
42
+ Style/Semicolon:
43
+ Enabled: true
44
+
@@ -1,6 +1,36 @@
1
1
  # Change Log
2
2
 
3
- ## Unreleased
3
+ * Drop support for rubies under 2.5. PR #1189
4
+
5
+ ## 2.4.1 - 2020-12-21
6
+
7
+ * Add `ActiveRecord::Base.ransack!` which raises error if passed unknown condition
8
+
9
+ *Aaron Lipman*
10
+
11
+ ## 2.4.0 - 2020-11-27
12
+
13
+ * Support ActiveRecord 6.1.0.rc1.
14
+ PR [1172](https://github.com/activerecord-hackery/ransack/pull/1172)
15
+
16
+ * Fix for ActiveRecord 5.2.4 (note security fix in 5.2.4.2 for ActiveView's escape_javascript CVE-2020-5267 for all earlier versions)
17
+
18
+ * Drop support for ActiveRecord older than 5.2.4.
19
+ PR [1166](https://github.com/activerecord-hackery/ransack/pull/1166)
20
+
21
+ ## 2.3.2 - 2020-01-11
22
+
23
+ * Breakfix to bump Polyamorous
24
+
25
+ ## 2.3.1 - 2020-01-11
26
+
27
+ * Drop support for Active Record 5.0, 5.1, and 5.2.0.
28
+ PR [#1073](https://github.com/activerecord-hackery/ransack/pull/1073)
29
+
30
+ * Drop support for rubies under 2.3.
31
+ PR [#1070](https://github.com/activerecord-hackery/ransack/pull/1070)
32
+
33
+ ... and others
4
34
 
5
35
  ## 2.3.0 - 2019-08-18
6
36
 
@@ -26,8 +26,8 @@ Steps:
26
26
  Ransack and not in your code or another gem.
27
27
 
28
28
  4. **Report the issue** by providing the link to a self-contained
29
- gist like [this](https://gist.github.com/jonatack/63048bc5062a84ba9e09) or
30
- [this](https://gist.github.com/jonatack/5df41a0edb53b7bad989). Please use
29
+ gist like [this](https://github.com/activerecord-hackery/ransack/blob/run_bug_report_templates/bug_report_templates/test-ransack-scope-and-column-same-name.rb) or
30
+ [this](https://github.com/activerecord-hackery/ransack/blob/run_bug_report_templates/bug_report_templates/test-ransacker-arel-present-predicate.rb). Please use
31
31
  these code examples as a bug-report template for your Ransack issue!
32
32
 
33
33
  If you do not provide a self-contained gist and would like your issue to be reviewed, do provide at a minimum:
@@ -64,6 +64,9 @@ Here's a quick guide:
64
64
  2. Create a thoughtfully-named branch for your changes (`git checkout -b my-new-feature`).
65
65
 
66
66
  3. Install the development dependencies by running `bundle install`.
67
+ To install rails other than latest (set in Gemfile): `RAILS='5-2-stable' bundle install`
68
+
69
+ $ RAILS='5-2-stable' bundle install
67
70
 
68
71
  4. Begin by running the tests. We only take pull requests with passing tests,
69
72
  and it's great to know that you have a clean slate:
@@ -84,16 +87,18 @@ Here's a quick guide:
84
87
  $ mysql -u root
85
88
  mysql> create database ransack;
86
89
 
87
- To run only the tests in a particular file: `rspec <path/to/filename>`
90
+ The test suite runs by default
91
+
92
+ To run only the tests in a particular file: `bundle exec rspec <path/to/filename>`
88
93
 
89
- $ rspec spec/ransack/search_spec.rb
94
+ $ bundle exec rspec spec/ransack/search_spec.rb
90
95
 
91
- To run a single test in that file: `rspec <path/to/filename> -e "test name"`
96
+ To run a single test in that file: `bundle exec rspec <path/to/filename> -e "test name"`
92
97
 
93
- $ rspec spec/ransack/search_spec.rb -e "accepts a context option"
98
+ $ bundle exec rspec spec/ransack/search_spec.rb -e "accepts a context option"
94
99
 
95
- 5. Hack away! Please use Ruby features that are compatible down to Ruby 1.9.
96
- Since version 1.5, Ransack no longer maintains Ruby 1.8 compatibility.
100
+ 5. Hack away! Please use Ruby features that are compatible down to Ruby 2.3.
101
+ Since version 2.3.1, Ransack no longer maintains Ruby 2.2 compatibility.
97
102
 
98
103
  6. Add tests for your changes. Only refactoring and documentation changes
99
104
  require no new tests. If you are adding functionality or fixing a bug, we
@@ -110,9 +115,6 @@ Here's a quick guide:
110
115
  $ git config --global user.email "contributor@example.com"
111
116
 
112
117
  10. Commit your changes (`git commit -am 'Add feature/fix bug/improve docs'`).
113
- If your pull request only contains documentation changes, please remember
114
- to add `[skip ci]` to the beginning of your commit message so the Travis
115
- test suite doesn't :runner: needlessly.
116
118
 
117
119
  11. If necessary, rebase your commits into logical chunks, without errors. To
118
120
  interactively rebase and cherry-pick from, say, the last 10 commits: