-
Notifications
You must be signed in to change notification settings - Fork 422
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
Rails 4.2 support (waiting on rails/rails#19042) #640
Comments
Hi yan-hoose, If you'd like to see it updated then the best way to get that to happen would be to submit a PR which did the updating. Could you please work on that? I will review it when you're done. Thanks
|
@yan-hoose please find the time to do this! |
I have taken this on and it's about half done. |
Yay! Thanks :)
|
About the one failing test. It seems that Rails 4.2 thinks that the #app/models/forem/concerns/viewable.rb:19
view = views.find_or_create_by(user_id: user.id) That did not happen in Rails 4.1 and lower. Setting the I'm not sure if this is intended or not but probably the easiest solution would be to just rename the column to something like Besides this one thing everything else is done. |
Wat? Can you reproduce this issue in a new app? Counter caches are not mentioned in the 4.2 changelog and so for this to change seems unnatural. |
I'll try in the morning. |
I can reproduce it with the following test. # Activate the gem you are reporting the issue against.
gem 'activerecord', '4.1.9'
#gem 'activerecord', '4.2.0'
require 'active_record'
require 'minitest/autorun'
require 'logger'
# Ensure backward compatibility with Minitest 4
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)
# This connection will do for database-independent bug reports.
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Schema.define do
create_table :posts, force: true do |t|
t.integer :comments_count, default: 0
end
create_table :comments, force: true do |t|
t.integer :post_id
end
end
class Post < ActiveRecord::Base
has_many :comments
end
class Comment < ActiveRecord::Base
belongs_to :post
end
class BugTest < Minitest::Test
def test_association_stuff
post = Post.create!
assert_equal 0, post.comments_count
post.comments << Comment.create!
assert_equal 1, post.comments.count
assert_equal 0, post.comments_count
end
end With 4.1.9 it works as expected and with 4.2.0 it fails on the last assertion. I took a look at the 4.2 release notes again and indeed, the only mention of counter caches was about deprecating broken automatic detection when using has_many :through associations, so it seems like a Rails bug. Let me know if you get the same result with this test. |
The bug is marked with the milestone 4.2.2, so we'll have to wait until Rails 4.2.2 to have Forem support for 4.2.x. |
Good job investigating this issue. It is very strange that setting |
Unfortunately Rails 4.2.2 does not include a fix for this issue, so we'll have to wait for 4.2.3. |
So, 4.2.2 is here, and looks like the problem with counter_cache is fixed: |
Nope, the Rails bug has not been fixed yet and is marked with the milestone 4.2.4. The bug that you are talking about is not the same bug we ran into with Forem (has_many :through vs simple has_many and belongs_to association). |
Made it more obvious in the issue title and OP. |
I went ahead and created the PR so you can start reviewing it when you have time: #668 |
This issue will need to be addressed before a proper gem release (as we talked about in #666) |
Rails 4.2.4 has been released. Let's get this version bumped! Please submit a PR for that. |
Nice, I'll do it in the evening today! |
So, did anything get fixed? |
Radar: asks for pull requests And so the cycle continues...
|
@yan-hoose How goes this PR? |
It's already done a few days ago: #668 |
Merged, thanks!
|
[Ed (Radar): We are waiting for this bug to be fixed in rails: rails/rails#19042]
Hi,
I'd like to see Forem updated to support Rails 4.2. I took a look at it and at first glance there does not seem to be very much needed to do. There are a ton of deprecation warnings when running specs but most of them are repetitive. However, there are a few strange issues.
BTW, currently Travis CI is running Forem tests in Rails 4.2 mode, so you can see the warnings easily yourself. In Rails 4.2 mode because in the gemspec there is currently
s.add_dependency 'rails', '~> 4.0', '<= 4.2'
instead of
s.add_dependency 'rails', '~> 4.0', '< 4.2'
.Anyway, when running tests, there is one failing test and three main sources of warnings:
use_route
inforem/spec/support/controller_hacks.rb:27
#deliver
instead of#deliver_now
or#deliver_later
inforem/app/models/forem/subscription.rb:12
#column_for_attribute
change warnings from Simple Form:forem/app/views/forem/admin/forums/_form.html.erb:8
. This warning will be resolved if the gem dependency is changed from '> 3.0.1' to '> 3.0'.I'm not sure if in addition to fixing the
use_route
deprecation warning, RSpec gem dependency should be raised from '> 2.14.0' to '> 3.1.0' (since 3.1 is the one with official Rails 4.2 support). Somebody with more experience in RSpec might know the answer to this.There is also a question about how to support both #deliver and #deliver_later depending on the Rails version.
About the failing test:
rspec ./spec/models/topic_spec.rb:87 # Forem::Topic helper methods #register_view_by increments the overall topic view count
It seems that this code in forem/models/forem/concerns/viewable.rb
is incrementing topic.views_count by 2 instead of 1 - first increment in
views.find_or_create_by
(I'm not sure why) and the second one inincrement!(:views_count)
.Has anybody else taken a look at 4.2 support and knows the answers/solutions to these issues already? Unfortunately I don't have too much time to spend on this.
The text was updated successfully, but these errors were encountered: