Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix for support of Rails 7.2.0 #1485

Merged
merged 8 commits into from
Sep 8, 2024

Conversation

kalashnikovisme
Copy link
Contributor

@kalashnikovisme kalashnikovisme commented Aug 10, 2024

This is just a hotfix. I didn't make big changes. So, the core team of the gem should make these updates:

  • Change using of ActiveSupport::Deprecation._instance.warn. Rails contributors suggest creating own deprecation class. More here
  • Review the use of schema_migration in tests. Looks like, I made the needed change, but maybe I didn't understand the purpose of the test.
  • Decide what to do with Ruby 3.0 tests. Rails 7.2.0 does not support this version, so you should completely change test workflow. I temporarily removed it.

Check the following boxes:

  • Wrote good commit messages.
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Added an entry to the Changelog if the new
    code introduces user-observable changes.
  • The PR relates to only one subject with a clear title
    and description in grammatically correct, complete sentences.
  • Decreased line coverage by 0.07% - sorry 🙂

@kalashnikovisme kalashnikovisme force-pushed the rails_7.2.0 branch 2 times, most recently from a6c0107 to 2a5da16 Compare August 10, 2024 13:41
@kalashnikovisme kalashnikovisme changed the title Hotfix for support of Rails 7.2.0 WIP: Hotfix for support of Rails 7.2.0 Aug 10, 2024
@kalashnikovisme kalashnikovisme force-pushed the rails_7.2.0 branch 5 times, most recently from 29b952b to 12fa951 Compare August 10, 2024 14:17
@kalashnikovisme kalashnikovisme changed the title WIP: Hotfix for support of Rails 7.2.0 Hotfix for support of Rails 7.2.0 Aug 10, 2024
@fatkodima
Copy link
Contributor

Duplicate of #1477.

But either version should be merged, since we already have rails 7.2.

@olivierbuffon
Copy link

This is the last blocker for our app to be upgraded to 7.2, can wait to have this merged 🙏🏻 ! 😃

@fatkodima
Copy link
Contributor

Same for us, the only blocker thats left.

@arikarim
Copy link

any update on this please?

@@ -18,7 +18,7 @@ module PaperTrail
# versions.
module Compatibility
ACTIVERECORD_GTE = ">= 6.1" # enforced in gemspec
ACTIVERECORD_LT = "< 7.2" # not enforced in gemspec
ACTIVERECORD_LT = "< 8" # not enforced in gemspec

Choose a reason for hiding this comment

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

This should most likely be 7.3, as we're cautious with Rails introducing breaking changes in minor versions.

Copy link
Contributor

Choose a reason for hiding this comment

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

There won't be 7.3, only 8 as a next.

Copy link
Contributor Author

@kalashnikovisme kalashnikovisme Aug 16, 2024

Choose a reason for hiding this comment

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

Nice catch!

I decided to use 8 because looks like there won't be Rails 7.3.

We can see it here and here

Copy link
Contributor Author

@kalashnikovisme kalashnikovisme Aug 16, 2024

Choose a reason for hiding this comment

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

Anyway, changed it 🙂

So many people wait for the update 🙂

@denysivanov
Copy link

Any update on this?

@ryansdwilson
Copy link

Stoked to see this merge. Let us know if we can help!

@Halphas
Copy link

Halphas commented Aug 19, 2024

please merge

Copy link

@ronnqvistandreas ronnqvistandreas left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@kalashnikovisme
Copy link
Contributor Author

kalashnikovisme commented Aug 19, 2024

@jaredbeck hey! Sorry for the mention. Could you please help us and merge it or add comments 🙂

@chrisjeon
Copy link

Can we get this in?

@benkruger
Copy link

Why is it taking so long to merge this?

@denysivanov
Copy link

@jaredbeck could you help?

@cisolarix
Copy link

Looking forward to seeing this PR being merged.

@dip00dip
Copy link

Are there any blockers to merge this?

@denysivanov
Copy link

Any update here?

@veganstraightedge
Copy link

Hi paper trail gem folks 👋🏻 i'm adding my voice to the chorus of encouragement to merging this PR or the other one #1477

@veganstraightedge veganstraightedge mentioned this pull request Aug 28, 2024
6 tasks
@zhandao
Copy link

zhandao commented Aug 29, 2024

We've been waiting for this PR for a long time. 😭

@capripot
Copy link

capripot commented Aug 29, 2024

Could we release a beta to test it out in larger scale than using this branch directly?


# To keep matrix size down, only test highest and lowest rubies.
# See "Lowest supported ruby version" in CONTRIBUTING.md
ruby: [ '3.0', '3.2' ]
ruby: [ '3.2', '3.3' ]

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice catch! Thanks!

Choose a reason for hiding this comment

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

@kalashnikovisme looks like the following need updating as well according to CONTRIBUTING:

Copy link
Member

@gurgelrenan gurgelrenan Sep 1, 2024

Choose a reason for hiding this comment

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

@joshRpowell is right. This 3 files should be updated, @kalashnikovisme . And why have you removed 3.2?

@@ -18,7 +18,7 @@ module PaperTrail
# versions.
module Compatibility
ACTIVERECORD_GTE = ">= 6.1" # enforced in gemspec
ACTIVERECORD_LT = "< 7.2" # not enforced in gemspec
ACTIVERECORD_LT = "< 7.3" # not enforced in gemspec
Copy link

@joshRpowell joshRpowell Aug 29, 2024

Choose a reason for hiding this comment

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

8.0 ?

ACTIVERECORD_LT = "< 8.0"

see https://github.com/rails/rails/milestones

Choose a reason for hiding this comment

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

It was set to < 8 originally but there was a request to set to < 7.3 here.

README.md Outdated
@@ -92,7 +92,7 @@ Choose version:

| paper_trail | ruby | activerecord |
|-------------|----------|---------------|
| unreleased | >= 3.0.0 | >= 6.1, < 7.2 |
| unreleased | >= 3.0.0 | >= 6.1, <= 7.2 |

Choose a reason for hiding this comment

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

@kalashnikovisme and >= 3.1.0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it 🙂 Thanks!

@bvogel
Copy link

bvogel commented Sep 2, 2024

Now that #1477 has been closed, I'd really prefer their definition for the deprecation object in the PR rather than relying on some internal method that isn't part of the official API AFAIK. could we recover that piece of code to this PR?

@tbrammar
Copy link
Contributor

tbrammar commented Sep 3, 2024

@kalashnikovisme I've created a PR on your fork to adjust the deprecator definition as per @bvogel request above.

If you're good with it can we merge and then hopefully the Paper Trail Gem folks can then get this PR merged? 🙏👍

tbrammar and others added 2 commits September 3, 2024 14:39
Adjust deprecator definition to be more inline with the official API
@kalashnikovisme
Copy link
Contributor Author

Merged it!

thanks @tbrammar 🙂

@@ -14,7 +14,7 @@ module PaperTrail

context "when incompatible" do
it "writes a warning to stderr" do
ar_version = ::Gem::Version.new("7.2.0")
ar_version = ::Gem::Version.new("8.0.0")
Copy link

Choose a reason for hiding this comment

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

Should this be 7.3 in line with the other changes?

Suggested change
ar_version = ::Gem::Version.new("8.0.0")
ar_version = ::Gem::Version.new("7.3.0")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a pretty interesting question.

I think no because there is > method in other places to compare versions. But in this place we have exact version to test with.

At the first version of this pull request, I used 7.3 because of these commits in the rails repository here and here. But I changed it to 8.0 because of this comment.

So, I think that we should use 7.3 in cases with >.

@kalashnikovisme
Copy link
Contributor Author

I tested it with Rails 7.2.1. Everything works fine.

@Migoo
Copy link

Migoo commented Sep 5, 2024

Hello everyone,
Thanks for the job.

I try this PR and I have some issue in tests related to Papertrail.

we have the following helper:

 module Versioning
  def with_versioning
    was_enabled = PaperTrail.enabled?
    was_enabled_for_request = PaperTrail.request.enabled?
    PaperTrail.enabled = true
    PaperTrail.request.enabled = true
    begin
      yield
    ensure
      PaperTrail.enabled = was_enabled
      PaperTrail.request.enabled = was_enabled_for_request
    end
  end
end

And when we use in test with the following pattern:

# Model
class MyModel < ApplicationRecord
  include Discard::Model
  self.discard_column = :deleted_at
  
  has_paper_trail ignore: [:updated_at, :data_fetched_at],
                  versions: { class_name: "MyModelVersion" },
                  on: [:update]
end  

# Test

require 'test_helper'

class MyModelTest < ActiveSupport::TestCase
  include ActiveJob::TestHelper
  include Versioning
  test 'should have versioning' do
    with_versioning do
      my_model = create(:my_model)

      assert_equal 0, MyModelVersion.count

      my_model.update!(price: 1000)

      assert_equal 1, MyModelVersion.count

      my_model.update!(data_fetched_at: Time.zone.now)

      assert_equal 1, MyModelVersion.count
    end
  end
end

we have the following error:

Failure:
test_should_have_versioning(Minitest::Result) [/usr/local/bundle/gems/activerecord-7.2.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:19]:
ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR:  relation "versions" does not exist
LINE 10:  WHERE a.attrelid = '"versions"'::regclass

For us Papertrail is not well working with RoR 7.2 and it's blocking our upgrade.
Any help is welcoming

Regards

@spickermann
Copy link

@Migoo The issue is probably caused by how theMyModelVersion model inherits from PaperTrail::Version or configures the table name. Please see my comment above for how to fix that.

@Migoo
Copy link

Migoo commented Sep 5, 2024

@spickermann Thanks for the quick answer ! I didn't see you reply above. I juste update the code and it's working 🙌

@schinery
Copy link

schinery commented Sep 5, 2024

I tested it with Rails 7.2.1. Everything works fine.

Same, all good for me too. Ship it?

image

@arikarim
Copy link

arikarim commented Sep 5, 2024

this one takes too long, i bet Rails 8 comes ahead of this merge 😑

@tbrammar
Copy link
Contributor

tbrammar commented Sep 7, 2024

Pretty please @seanlinsley @gurgelrenan @aried3r @jaredbeck - can we get this PR merged and released? 🙏🫠

Copy link
Member

@jaredbeck jaredbeck left a comment

Choose a reason for hiding this comment

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

Looks good, thanks everyone who contributed.

@jaredbeck jaredbeck merged commit d304bd5 into paper-trail-gem:master Sep 8, 2024
9 checks passed
@jaredbeck
Copy link
Member

Released as 15.2.0

@kalashnikovisme kalashnikovisme deleted the rails_7.2.0 branch September 8, 2024 22:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.