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

Support rails 6.0.0 #1172

Merged
merged 14 commits into from
Dec 4, 2018
Merged

Conversation

Edouard-chin
Copy link
Contributor

Supersede #1159

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.

iggant and others added 4 commits December 3, 2018 17:56
We are trying to test our application on rails 6.0.0.alpha but we can't install this because of the version lock
Probably this will be helpful that we can try and report any issues with edge rails
In Rails 6.0 update_attributes/update_attributes! is considered deprecated. Method update/update! is the samish replacement.
- The conditional wasn't correct, any version with a `0` minor and
  `< 2` patch (which is true for 6.0.0) would return that the version
  was `< 5.0.2`.
- Bundler 1.16.1 has bug where dependencies can't be resolved properly
  when a gem is a release candidate or an alpha version.
  The underlying bundler issue can be found here rubygems/bundler#6449

  You can see a failing build here https://travis-ci.org/paper-trail-gem/paper_trail/jobs/463055122

  This commit updates bundler to latest version before installing deps
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.

gettin' close!

CHANGELOG.md Outdated Show resolved Hide resolved
paper_trail.gemspec Outdated Show resolved Hide resolved
end

serialize :time_zone, TimeZoneSerializer.new
end
Copy link
Member

Choose a reason for hiding this comment

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

Does rails 6 change how serialize works? If so, can you point me to some reading on the subject?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I know the ActiveModel Attribute API was released in 5.1 but I don't know why @iggant made that change. I'll have to dig, or maybe @iggant you can explain

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Dug into this and the TimeZone Attribute is technically not a requirement to make tests pass on AR 6.0.
Without it, some tests were failing but the reason for the failures weren't directly related do that. I explained the reason in detail in ac12912

That being said, even though adding a new TimeZone Attribute isn't a requirement, it makes the code cleaner. It's not a new 6.0 thing, we could have used it since Rails 5.0 when the Attribute API got released https://api.rubyonrails.org/classes/ActiveRecord/Attributes/ClassMethods.html

Let me know if you prefer to stick with our old serializer.

Copy link
Member

Choose a reason for hiding this comment

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

Dug into this and the TimeZone Attribute is technically not a requirement to make tests pass on AR 6.0.

Thanks for investigating. For now, I have removed this. Let's discuss it in a separate PR.

- In Rails 6.0, rails/rails@3b95478 made a change to eagerly define
  attribute methods of a Model when `eager_load` is enabled.
  This breaks our test suite because of the way we run migration.

  The TL;DR is that doing `People.attribute_names` will return an
  empty array instead of `[:id, time_zone, ...]`.
  You can find a failing build here https://travis-ci.org/paper-trail-gem/paper_trail/jobs/463369634

  Basically what happens is:

  1) The dummy app boot, attribute methods of each model are defined
     but since migration didn't run yet, the tables aren't even
     created resulting in a empty attribute set.
  2) Migration runs, but it's already too late.

  In this commit I disabled eager_loading in test, AFAIT there isn't
  much benefit in eager_loading the dummy app anyway.
  Also renaming the `user.rb` file to `postgres_user.rb` in order for
  rails autoloading to work correctly.
@Edouard-chin
Copy link
Contributor Author

CI is green, each commit should explain the changes. I will squash everything once you give your ✅ .

Thanks!

Edouard-chin added a commit to Edouard-chin/paper_trail that referenced this pull request Dec 4, 2018
@jaredbeck jaredbeck merged commit 2b479a7 into paper-trail-gem:master Dec 4, 2018
@jaredbeck
Copy link
Member

Thanks Anton and Edouard for your work on this. @iggant @Edouard-chin.

I think I'll release this as PT 10.1.0

@Edouard-chin
Copy link
Contributor Author

Thanks a lot for your quick review and help on this, much appreciated ❤️

@Edouard-chin Edouard-chin deleted the ec-support-rails-6 branch December 4, 2018 21:16
aried3r pushed a commit to aried3r/paper_trail that referenced this pull request Dec 14, 2020
* Change update_attributes to update

In Rails 6.0 update_attributes/update_attributes! is considered deprecated. Method update/update! is the replacement.

* CI: Don't use Bundler 1.16.1

- Bundler 1.16.1 has bug where dependencies can't be resolved properly
  when a gem is a release candidate or an alpha version.
  The underlying bundler issue can be found here rubygems/bundler#6449

* Disable eager_load in test env:

- In Rails 6.0, rails/rails@3b95478 made a change to eagerly define
  attribute methods of a Model when `eager_load` is enabled.
  This breaks our test suite because of the way we run migration.

  The TL;DR is that doing `People.attribute_names` will return an
  empty array instead of `[:id, time_zone, ...]`.
  You can find a failing build here https://travis-ci.org/paper-trail-gem/paper_trail/jobs/463369634

  Basically what happens is:

  1) The dummy app boot, attribute methods of each model are defined
     but since migration didn't run yet, the tables aren't even
     created resulting in a empty attribute set.
  2) Migration runs, but it's already too late.

  In this commit I disabled eager_loading in test, AFAIT there isn't
  much benefit in eager_loading the dummy app anyway.
  Also renaming the `user.rb` file to `postgres_user.rb` in order for
  rails autoloading to work correctly.
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.

3 participants