Skip to content

Upgrade ransack from 3.2.1 to 4.2.0#13196

Merged
andreslucena merged 21 commits intodevelopfrom
chore/dependencies/ransack
Sep 20, 2024
Merged

Upgrade ransack from 3.2.1 to 4.2.0#13196
andreslucena merged 21 commits intodevelopfrom
chore/dependencies/ransack

Conversation

@alecslupu
Copy link
Copy Markdown
Contributor

@alecslupu alecslupu commented Jul 23, 2024

🎩 What? Why?

This PR updates Ransack to version 4.2.0 to add support for the upcoming rails 7.1 upgrade.

Testing

  1. Pipeline is green
  2. Browse Various search forms and try to perform searches.

♥️ Thank you!

@alecslupu alecslupu added dependencies Pull requests that update a dependency file or issues that talk about updating dependencies type: change PRs that implement a change for an existing feature labels Jul 23, 2024
github-actions[bot]
github-actions bot previously approved these changes Jul 23, 2024
github-actions[bot]
github-actions bot previously approved these changes Jul 23, 2024
github-actions[bot]
github-actions bot previously approved these changes Jul 23, 2024
github-actions[bot]
github-actions bot previously approved these changes Jul 24, 2024
github-actions[bot]
github-actions bot previously approved these changes Jul 24, 2024
github-actions[bot]
github-actions bot previously approved these changes Jul 24, 2024
@ahukkanen
Copy link
Copy Markdown
Contributor

Just a note here is that Decidim currently also ships its own limitation layer for the public attributes that can be used to filter resources through the HTTP requests. There's a couple of words mentioned about that at #10753.

I think this layer becomes unnecessary after the update is done to Ransack 4. Not saying the refactor should be done in this PR alone but just noting it here since it was one issue when doing the Ransack migration.

@alecslupu
Copy link
Copy Markdown
Contributor Author

Just a note here is that Decidim currently also ships its own limitation layer for the public attributes that can be used to filter resources through the HTTP requests. There's a couple of words mentioned about that at #10753.

I think this layer becomes unnecessary after the update is done to Ransack 4. Not saying the refactor should be done in this PR alone but just noting it here since it was one issue when doing the Ransack migration.

To be honest, the layer added by #8748 , should be complementary. For instance in admin we filter the user by various fields that we may not want to be injectable in general search. I will investigate further next week.

The work in this PR is done to facilitate the rails 7.1 upgrade.

@ahukkanen
Copy link
Copy Markdown
Contributor

To be honest, the layer added by #8748 , should be complementary. For instance in admin we filter the user by various fields that we may not want to be injectable in general search. I will investigate further next week.

For such cases, you can do the checks over the auth_object provided to the ransackable_n methods, see e.g.

def self.ransackable_scopes(auth_object = nil)
base = [:with_resource_type]
return base unless auth_object&.admin?
# Add extra scopes for admins for the admin panel searches
base + [:with_participatory_space]
end

The layer was actually already there prior to #8748 but the implementation was changed to work better with Ransack. I would see that when the security defaults are changed, that layer probably becomes unnecessary. Although, I may not know all the details but typically less code is better.

The work in this PR is done to facilitate the rails 7.1 upgrade.

Yes, I know. I was just pointing this out as I saw this PR (and related to that). As said, that is another issue and just wanted to point it out because of related development.

* Refactor Accountability

* Refactor assemblies

* Refactor Budgets

* Refactor Conferences

* Refactor debates

* Fix specs

* Refactor initiatives

* Refactor

* Refactor

* Refactor

* Refactor

* Refactor proposals

* Refactor

* Fix conferences

* fix invites

* Fix meeting

* Final refactor
github-actions[bot]
github-actions bot previously approved these changes Sep 2, 2024
Copy link
Copy Markdown
Member

@andreslucena andreslucena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a doubt about the comments with the fields. If they're no necessary, I'd prefer to drop them

Co-authored-by: Andrés Pereira de Lucena <andreslucena@users.noreply.github.com>
github-actions[bot]
github-actions bot previously approved these changes Sep 5, 2024
github-actions[bot]
github-actions bot previously approved these changes Sep 5, 2024
github-actions[bot]
github-actions bot previously approved these changes Sep 9, 2024
github-actions[bot]
github-actions bot previously approved these changes Sep 16, 2024
Copy link
Copy Markdown
Member

@andreslucena andreslucena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just checked it out locally once again and it works as expected. Thanks for the PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

No open projects
Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants