ransack 2.4.2 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/codeql.yml +72 -0
- data/.github/workflows/cronjob.yml +6 -9
- data/.github/workflows/deploy.yml +35 -0
- data/.github/workflows/rubocop.yml +1 -1
- data/.github/workflows/test-deploy.yml +29 -0
- data/.github/workflows/test.yml +22 -48
- data/.nojekyll +0 -0
- data/.rubocop.yml +3 -0
- data/CHANGELOG.md +208 -11
- data/CONTRIBUTING.md +41 -18
- data/Gemfile +10 -10
- data/README.md +44 -977
- data/bug_report_templates/test-ransacker-arel-present-predicate.rb +4 -0
- data/docs/.gitignore +19 -0
- data/docs/.nojekyll +0 -0
- data/docs/babel.config.js +3 -0
- data/docs/blog/2022-03-27-ransack-3.0.0.md +20 -0
- data/docs/docs/getting-started/_category_.json +4 -0
- data/docs/docs/getting-started/advanced-mode.md +46 -0
- data/docs/docs/getting-started/configuration.md +47 -0
- data/docs/docs/getting-started/search-matches.md +67 -0
- data/docs/docs/getting-started/simple-mode.md +288 -0
- data/docs/docs/getting-started/sorting.md +79 -0
- data/docs/docs/getting-started/using-predicates.md +282 -0
- data/docs/docs/going-further/_category_.json +4 -0
- data/docs/docs/going-further/acts-as-taggable-on.md +114 -0
- data/docs/docs/going-further/associations.md +70 -0
- data/docs/docs/going-further/custom-predicates.md +52 -0
- data/docs/docs/going-further/documentation.md +43 -0
- data/docs/docs/going-further/exporting-to-csv.md +49 -0
- data/docs/docs/going-further/external-guides.md +57 -0
- data/docs/docs/going-further/form-customisation.md +63 -0
- data/docs/docs/going-further/i18n.md +53 -0
- data/docs/docs/going-further/merging-searches.md +41 -0
- data/docs/docs/going-further/other-notes.md +428 -0
- data/docs/docs/going-further/polymorphic-search.md +40 -0
- data/docs/docs/going-further/ransackers.md +331 -0
- data/docs/docs/going-further/release_process.md +36 -0
- data/docs/docs/going-further/saving-queries.md +82 -0
- data/docs/docs/going-further/searching-postgres.md +57 -0
- data/docs/docs/going-further/wiki-contributors.md +82 -0
- data/docs/docs/intro.md +99 -0
- data/docs/docusaurus.config.js +120 -0
- data/docs/package.json +42 -0
- data/docs/sidebars.js +31 -0
- data/docs/src/components/HomepageFeatures/index.js +64 -0
- data/docs/src/components/HomepageFeatures/styles.module.css +11 -0
- data/docs/src/css/custom.css +39 -0
- data/docs/src/pages/index.module.css +23 -0
- data/docs/src/pages/markdown-page.md +7 -0
- data/docs/static/.nojekyll +0 -0
- data/docs/static/img/docusaurus.png +0 -0
- data/docs/static/img/favicon.ico +0 -0
- data/docs/static/img/logo.svg +1 -0
- data/docs/static/img/tutorial/docsVersionDropdown.png +0 -0
- data/docs/static/img/tutorial/localeDropdown.png +0 -0
- data/docs/static/img/undraw_docusaurus_mountain.svg +171 -0
- data/docs/static/img/undraw_docusaurus_react.svg +170 -0
- data/docs/static/img/undraw_docusaurus_tree.svg +40 -0
- data/docs/yarn.lock +8790 -0
- data/lib/polyamorous/activerecord_6.1_ruby_2/join_association.rb +0 -4
- data/lib/polyamorous/activerecord_6.1_ruby_2/join_dependency.rb +0 -1
- data/lib/polyamorous/activerecord_6.1_ruby_2/reflection.rb +11 -1
- data/lib/polyamorous/activerecord_7.1_ruby_2/join_association.rb +1 -0
- data/lib/polyamorous/activerecord_7.1_ruby_2/join_dependency.rb +1 -0
- data/lib/polyamorous/activerecord_7.1_ruby_2/reflection.rb +1 -0
- data/lib/ransack/adapters/active_record/base.rb +79 -10
- data/lib/ransack/adapters/active_record/context.rb +24 -51
- data/lib/ransack/configuration.rb +39 -12
- data/lib/ransack/constants.rb +125 -3
- data/lib/ransack/context.rb +34 -5
- data/lib/ransack/helpers/form_builder.rb +3 -3
- data/lib/ransack/helpers/form_helper.rb +14 -5
- data/lib/ransack/locale/sv.yml +70 -0
- data/lib/ransack/nodes/attribute.rb +2 -2
- data/lib/ransack/nodes/condition.rb +80 -7
- data/lib/ransack/nodes/grouping.rb +3 -3
- data/lib/ransack/nodes/node.rb +1 -1
- data/lib/ransack/nodes/sort.rb +2 -2
- data/lib/ransack/nodes/value.rb +2 -2
- data/lib/ransack/predicate.rb +1 -1
- data/lib/ransack/ransacker.rb +1 -1
- data/lib/ransack/search.rb +13 -7
- data/lib/ransack/translate.rb +3 -3
- data/lib/ransack/version.rb +1 -1
- data/lib/ransack/visitor.rb +38 -2
- data/lib/ransack.rb +3 -6
- data/ransack.gemspec +5 -5
- data/spec/helpers/polyamorous_helper.rb +2 -8
- data/spec/polyamorous/activerecord_compatibility_spec.rb +15 -0
- data/spec/polyamorous/join_association_spec.rb +1 -6
- data/spec/polyamorous/join_dependency_spec.rb +0 -16
- data/spec/ransack/adapters/active_record/base_spec.rb +101 -11
- data/spec/ransack/configuration_spec.rb +23 -9
- data/spec/ransack/helpers/form_builder_spec.rb +8 -8
- data/spec/ransack/helpers/form_helper_spec.rb +93 -4
- data/spec/ransack/nodes/condition_spec.rb +37 -0
- data/spec/ransack/nodes/value_spec.rb +115 -0
- data/spec/ransack/predicate_spec.rb +36 -1
- data/spec/ransack/search_spec.rb +140 -27
- data/spec/ransack/translate_spec.rb +1 -1
- data/spec/support/schema.rb +75 -9
- metadata +83 -37
- data/docs/release_process.md +0 -20
- data/lib/polyamorous/activerecord_5.2_ruby_2/join_association.rb +0 -24
- data/lib/polyamorous/activerecord_5.2_ruby_2/join_dependency.rb +0 -79
- data/lib/polyamorous/activerecord_5.2_ruby_2/reflection.rb +0 -11
- data/lib/polyamorous/activerecord_6.0_ruby_2/join_association.rb +0 -1
- data/lib/polyamorous/activerecord_6.0_ruby_2/join_dependency.rb +0 -80
- data/lib/polyamorous/activerecord_6.0_ruby_2/reflection.rb +0 -1
- data/lib/ransack/adapters/active_record/ransack/constants.rb +0 -128
- data/lib/ransack/adapters/active_record/ransack/context.rb +0 -56
- data/lib/ransack/adapters/active_record/ransack/nodes/condition.rb +0 -68
- data/lib/ransack/adapters/active_record/ransack/translate.rb +0 -8
- data/lib/ransack/adapters/active_record/ransack/visitor.rb +0 -47
- data/lib/ransack/adapters.rb +0 -64
- data/lib/ransack/nodes.rb +0 -8
- /data/docs/{img → docs/going-further/img}/create_release.png +0 -0
- /data/{logo → docs/static/logo}/ransack-h.png +0 -0
- /data/{logo → docs/static/logo}/ransack-h.svg +0 -0
- /data/{logo → docs/static/logo}/ransack-v.png +0 -0
- /data/{logo → docs/static/logo}/ransack-v.svg +0 -0
- /data/{logo → docs/static/logo}/ransack.png +0 -0
- /data/{logo → docs/static/logo}/ransack.svg +0 -0
- /data/lib/polyamorous/{activerecord_6.2_ruby_2 → activerecord_7.0_ruby_2}/join_association.rb +0 -0
- /data/lib/polyamorous/{activerecord_6.2_ruby_2 → activerecord_7.0_ruby_2}/join_dependency.rb +0 -0
- /data/lib/polyamorous/{activerecord_6.2_ruby_2 → activerecord_7.0_ruby_2}/reflection.rb +0 -0
- /data/lib/ransack/{adapters/active_record.rb → active_record.rb} +0 -0
data/CONTRIBUTING.md
CHANGED
@@ -20,14 +20,14 @@ Steps:
|
|
20
20
|
reported.
|
21
21
|
|
22
22
|
2. **Check if the issue has been fixed** — try to reproduce it using the
|
23
|
-
`
|
23
|
+
`main` branch in the repository.
|
24
24
|
|
25
25
|
3. **Isolate the real problem** — make sure the issue is really a bug in
|
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://github.com/activerecord-hackery/ransack/blob/
|
30
|
-
[this](https://github.com/activerecord-hackery/ransack/blob/
|
29
|
+
gist like [this](https://github.com/activerecord-hackery/ransack/blob/main/bug_report_templates/test-ransack-scope-and-column-same-name.rb) or
|
30
|
+
[this](https://github.com/activerecord-hackery/ransack/blob/main/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,38 +64,56 @@ 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='
|
68
|
-
|
69
|
-
$ RAILS='5-2-stable' bundle install
|
67
|
+
To install rails other than latest (set in Gemfile): `RAILS='6-1-stable' bundle install`
|
70
68
|
|
71
69
|
4. Begin by running the tests. We only take pull requests with passing tests,
|
72
70
|
and it's great to know that you have a clean slate:
|
73
71
|
|
74
|
-
|
72
|
+
```sh
|
73
|
+
bundle exec rake spec
|
74
|
+
```
|
75
75
|
|
76
76
|
The test suite runs by default with SQLite3. To run the test suite with PostgreSQL or MySQL, use:
|
77
77
|
|
78
|
-
|
79
|
-
|
78
|
+
```sh
|
79
|
+
DB=pg bundle exec rake spec
|
80
|
+
DB=mysql bundle exec rake spec
|
81
|
+
```
|
82
|
+
|
83
|
+
A one-liner to run all three
|
84
|
+
|
85
|
+
```sh
|
86
|
+
bundle exec rake spec && DB=pg bundle exec rake spec && DB=mysql bundle exec rake spec
|
87
|
+
```
|
80
88
|
|
81
89
|
For Postgres and MySQL, databases are expected to exist, called 'ransack'. To create use these commands (assuming OS X and Homebrew):
|
82
90
|
|
83
91
|
### Postgres
|
84
|
-
|
92
|
+
|
93
|
+
```sh
|
94
|
+
createdb ransack
|
95
|
+
```
|
85
96
|
|
86
97
|
### MySQL
|
87
|
-
|
88
|
-
|
98
|
+
|
99
|
+
```sh
|
100
|
+
mysql -u root
|
101
|
+
mysql> create database ransack;
|
102
|
+
```
|
89
103
|
|
90
104
|
The test suite runs by default
|
91
105
|
|
92
106
|
To run only the tests in a particular file: `bundle exec rspec <path/to/filename>`
|
93
107
|
|
94
|
-
|
108
|
+
```sh
|
109
|
+
bundle exec rspec spec/ransack/search_spec.rb
|
110
|
+
```
|
95
111
|
|
96
112
|
To run a single test in that file: `bundle exec rspec <path/to/filename> -e "test name"`
|
97
113
|
|
98
|
-
|
114
|
+
```sh
|
115
|
+
bundle exec rspec spec/ransack/search_spec.rb -e "accepts a context option"
|
116
|
+
```
|
99
117
|
|
100
118
|
5. Hack away! Please use Ruby features that are compatible down to Ruby 2.3.
|
101
119
|
Since version 2.3.1, Ransack no longer maintains Ruby 2.2 compatibility.
|
@@ -111,10 +129,15 @@ Here's a quick guide:
|
|
111
129
|
|
112
130
|
9. Make sure git knows your name and email address in your `~/.gitconfig` file:
|
113
131
|
|
114
|
-
|
115
|
-
|
132
|
+
```sh
|
133
|
+
git config --global user.name "Your Name"
|
134
|
+
git config --global user.email "contributor@example.com"
|
135
|
+
```
|
116
136
|
|
117
137
|
10. Commit your changes (`git commit -am 'Add feature/fix bug/improve docs'`).
|
138
|
+
If your pull request only contains documentation changes, please remember
|
139
|
+
to add `[skip ci]` to the beginning of your commit message so the CI
|
140
|
+
test suite doesn't :runner: needlessly.
|
118
141
|
|
119
142
|
11. If necessary, rebase your commits into logical chunks, without errors. To
|
120
143
|
interactively rebase and cherry-pick from, say, the last 10 commits:
|
@@ -122,7 +145,7 @@ Here's a quick guide:
|
|
122
145
|
|
123
146
|
12. Push the branch up to your fork on GitHub
|
124
147
|
(`git push origin my-new-feature`) and from GitHub submit a pull request to
|
125
|
-
Ransack's `
|
148
|
+
Ransack's `main` branch.
|
126
149
|
|
127
150
|
At this point you're waiting on us. We like to at least comment on, if not
|
128
151
|
accept, pull requests within three business days (and, typically, one business
|
@@ -131,7 +154,7 @@ day). We may suggest some changes or improvements or alternatives.
|
|
131
154
|
Some things that will increase the chance that your pull request is accepted:
|
132
155
|
|
133
156
|
* Include tests that fail without your code, and pass with it.
|
134
|
-
* Update the README, the change log, the
|
157
|
+
* Update the README, the change log, the documentation... anything that is
|
135
158
|
affected by your contribution.
|
136
159
|
* Use idiomatic Ruby and follow the syntax conventions below.
|
137
160
|
|
data/Gemfile
CHANGED
@@ -3,7 +3,7 @@ gemspec
|
|
3
3
|
|
4
4
|
gem 'rake'
|
5
5
|
|
6
|
-
rails = ENV['RAILS'] || '6-
|
6
|
+
rails = ENV['RAILS'] || '6-1-stable'
|
7
7
|
|
8
8
|
rails_version = case rails
|
9
9
|
when /\// # A path
|
@@ -14,10 +14,10 @@ rails_version = case rails
|
|
14
14
|
rails
|
15
15
|
end
|
16
16
|
|
17
|
-
gem 'faker'
|
18
|
-
gem 'sqlite3'
|
19
|
-
gem 'pg'
|
20
|
-
gem 'pry'
|
17
|
+
gem 'faker'
|
18
|
+
gem 'sqlite3'
|
19
|
+
gem 'pg'
|
20
|
+
gem 'pry'
|
21
21
|
gem 'byebug'
|
22
22
|
|
23
23
|
case rails
|
@@ -28,26 +28,26 @@ when /\// # A path
|
|
28
28
|
gem 'actionpack', path: "#{rails}/actionpack"
|
29
29
|
gem 'actionview', path: "#{rails}/actionview"
|
30
30
|
when /^v/ # A tagged version
|
31
|
-
git 'https://github.com/rails/rails.git', :
|
31
|
+
git 'https://github.com/rails/rails.git', tag: rails do
|
32
32
|
gem 'activesupport'
|
33
33
|
gem 'activemodel'
|
34
34
|
gem 'activerecord', require: false
|
35
35
|
gem 'actionpack'
|
36
36
|
end
|
37
37
|
else
|
38
|
-
git 'https://github.com/rails/rails.git', :
|
38
|
+
git 'https://github.com/rails/rails.git', branch: rails do
|
39
39
|
gem 'activesupport'
|
40
40
|
gem 'activemodel'
|
41
41
|
gem 'activerecord', require: false
|
42
42
|
gem 'actionpack'
|
43
43
|
end
|
44
44
|
end
|
45
|
-
gem 'mysql2'
|
45
|
+
gem 'mysql2'
|
46
46
|
|
47
47
|
group :test do
|
48
48
|
gem 'machinist', '~> 1.0.6'
|
49
|
-
gem 'rspec'
|
50
|
-
gem 'simplecov', :
|
49
|
+
gem 'rspec'
|
50
|
+
gem 'simplecov', require: false
|
51
51
|
end
|
52
52
|
|
53
53
|
gem 'rubocop', require: false
|