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

Upgrade to Rails 4.1 #244

Merged
merged 5 commits into from
May 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ gem 'browser'
gem 'coffee-rails'
gem 'exception_notification'
gem 'gon'
gem 'haml-rails', '~> 0.4.0'
gem 'haml-rails'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did we have a specific HAML version for any particular reason?

Copy link
Contributor

Choose a reason for hiding this comment

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

gem 'httparty'
gem "jquery-fileupload-rails"
gem 'jquery-rails'
Expand All @@ -20,7 +20,7 @@ gem 'nokogiri'
gem 'pg'
gem 'pg_search'
gem 'protected_attributes'
gem 'rails', '4.0.13'
gem 'rails', '4.1.16'
gem 'rack-pratchett'
gem 'redis-rails'
gem 'resque'
Expand All @@ -33,7 +33,7 @@ gem 'select2-rails'
gem 'test-unit', '~> 3.0' # required by Heroku for production console
gem 'tinymce-rails'
gem 'uglifier'
gem 'will_paginate', '~> 3.0.6'
gem 'will_paginate'

group :production do
gem 'puma'
Expand Down
125 changes: 70 additions & 55 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,52 +1,53 @@
GEM
remote: https://rubygems.org/
specs:
actionmailer (4.0.13)
actionpack (= 4.0.13)
actionmailer (4.1.16)
actionpack (= 4.1.16)
actionview (= 4.1.16)
mail (~> 2.5, >= 2.5.4)
actionpack (4.0.13)
activesupport (= 4.0.13)
builder (~> 3.1.0)
erubis (~> 2.7.0)
actionpack (4.1.16)
actionview (= 4.1.16)
activesupport (= 4.1.16)
rack (~> 1.5.2)
rack-test (~> 0.6.2)
activemodel (4.0.13)
activesupport (= 4.0.13)
builder (~> 3.1.0)
activerecord (4.0.13)
activemodel (= 4.0.13)
activerecord-deprecated_finders (~> 1.0.2)
activesupport (= 4.0.13)
arel (~> 4.0.0)
activerecord-deprecated_finders (1.0.4)
activesupport (4.0.13)
actionview (4.1.16)
activesupport (= 4.1.16)
builder (~> 3.1)
erubis (~> 2.7.0)
activemodel (4.1.16)
activesupport (= 4.1.16)
builder (~> 3.1)
activerecord (4.1.16)
activemodel (= 4.1.16)
activesupport (= 4.1.16)
arel (~> 5.0.0)
activesupport (4.1.16)
i18n (~> 0.6, >= 0.6.9)
minitest (~> 4.2)
multi_json (~> 1.3)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.1)
tzinfo (~> 0.3.37)
tzinfo (~> 1.1)
addressable (2.5.1)
public_suffix (~> 2.0, >= 2.0.2)
api-pagination (4.5.2)
apipie-rails (0.4.0)
json
rails (>= 4.0)
arel (4.0.2)
api-pagination (4.6.1)
apipie-rails (0.5.1)
rails (>= 4.1)
arel (5.0.1.20140414130214)
audited (4.2.2)
rails-observers (~> 0.1.2)
audited-activerecord (4.2.2)
activerecord (~> 4.0)
audited (= 4.2.2)
aws-sdk (2.9.21)
aws-sdk-resources (= 2.9.21)
aws-sdk-core (2.9.21)
aws-sdk (2.9.23)
aws-sdk-resources (= 2.9.23)
aws-sdk-core (2.9.23)
aws-sigv4 (~> 1.0)
jmespath (~> 1.0)
aws-sdk-resources (2.9.21)
aws-sdk-core (= 2.9.21)
aws-sdk-resources (2.9.23)
aws-sdk-core (= 2.9.23)
aws-sigv4 (1.0.0)
browser (2.4.0)
builder (3.1.4)
builder (3.2.3)
byebug (9.0.6)
capybara (2.14.0)
addressable
Expand Down Expand Up @@ -113,14 +114,21 @@ GEM
json
multi_json
request_store (>= 1.0)
haml (4.0.7)
haml (5.0.1)
temple (>= 0.8.0)
tilt
haml-rails (0.4)
actionpack (>= 3.1, < 4.1)
activesupport (>= 3.1, < 4.1)
haml (>= 3.1, < 4.1)
railties (>= 3.1, < 4.1)
haml-rails (1.0.0)
actionpack (>= 4.0.1)
activesupport (>= 4.0.1)
haml (>= 4.0.6, < 6.0)
html2haml (>= 1.0.1)
railties (>= 4.0.1)
hashdiff (0.3.4)
html2haml (2.2.0)
erubis (~> 2.7.0)
haml (>= 4.0, < 6)
nokogiri (>= 1.6.0)
ruby_parser (~> 3.5)
httparty (0.15.5)
multi_xml (>= 0.5.2)
i18n (0.8.1)
Expand All @@ -146,7 +154,7 @@ GEM
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_portile2 (2.1.0)
minitest (4.7.5)
minitest (5.10.2)
mono_logger (1.1.0)
multi_json (1.12.1)
multi_test (0.1.2)
Expand All @@ -165,7 +173,7 @@ GEM
activesupport (>= 3.1)
arel
power_assert (1.0.2)
protected_attributes (1.1.3)
protected_attributes (1.1.4)
activemodel (>= 4.0.1, < 5.0)
public_suffix (2.0.5)
puma (3.8.2)
Expand All @@ -177,13 +185,15 @@ GEM
rack-test (0.6.3)
rack (>= 1.0)
rack-timeout (0.4.2)
rails (4.0.13)
actionmailer (= 4.0.13)
actionpack (= 4.0.13)
activerecord (= 4.0.13)
activesupport (= 4.0.13)
rails (4.1.16)
actionmailer (= 4.1.16)
actionpack (= 4.1.16)
actionview (= 4.1.16)
activemodel (= 4.1.16)
activerecord (= 4.1.16)
activesupport (= 4.1.16)
bundler (>= 1.3.0, < 2.0)
railties (= 4.0.13)
railties (= 4.1.16)
sprockets-rails (~> 2.0)
rails-observers (0.1.2)
activemodel (~> 4.0)
Expand All @@ -192,9 +202,9 @@ GEM
rails_stdout_logging
rails_serve_static_assets (0.0.5)
rails_stdout_logging (0.0.5)
railties (4.0.13)
actionpack (= 4.0.13)
activesupport (= 4.0.13)
railties (4.1.16)
actionpack (= 4.1.16)
activesupport (= 4.1.16)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (10.4.2)
Expand Down Expand Up @@ -262,7 +272,9 @@ GEM
rspec-mocks (~> 3.6.0)
rspec-support (~> 3.6.0)
rspec-support (3.6.0)
rufus-scheduler (3.4.0)
ruby_parser (3.9.0)
sexp_processor (~> 4.1)
rufus-scheduler (3.4.2)
et-orbi (~> 1.0)
safe_yaml (1.0.4)
sanitize (4.4.0)
Expand All @@ -279,6 +291,7 @@ GEM
seed_dump (0.5.3)
select2-rails (4.0.3)
thor (~> 0.14)
sexp_processor (4.9.0)
simplecov (0.13.0)
docile (~> 1.1.0)
json (>= 1.8, < 3)
Expand All @@ -295,7 +308,8 @@ GEM
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
test-unit (3.2.3)
temple (0.8.0)
test-unit (3.2.4)
power_assert
thin (1.7.0)
daemons (~> 1.0, >= 1.0.9)
Expand All @@ -305,15 +319,16 @@ GEM
thread_safe (0.3.6)
tilt (2.0.7)
timecop (0.8.1)
tinymce-rails (4.6.1)
tinymce-rails (4.6.2)
railties (>= 3.1.1)
tunemygc (1.0.69)
twitter-bootstrap-rails (3.2.2)
actionpack (>= 3.1)
execjs (>= 2.2.2, >= 2.2)
less-rails (>= 2.5.0)
railties (>= 3.1)
tzinfo (0.3.53)
tzinfo (1.2.3)
thread_safe (~> 0.1)
uglifier (3.2.0)
execjs (>= 0.3.0, < 3)
vegas (0.1.11)
Expand All @@ -322,7 +337,7 @@ GEM
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff
will_paginate (3.0.12)
will_paginate (3.1.5)
xpath (2.0.0)
nokogiri (~> 1.3)

Expand All @@ -344,7 +359,7 @@ DEPENDENCIES
exception_notification
factory_girl_rails
gon
haml-rails (~> 0.4.0)
haml-rails
httparty
jquery-fileupload-rails
jquery-rails
Expand All @@ -359,7 +374,7 @@ DEPENDENCIES
rack-cors
rack-pratchett
rack-timeout
rails (= 4.0.13)
rails (= 4.1.16)
rails_12factor
rake (= 10.4.2)
redis-rails
Expand All @@ -381,7 +396,7 @@ DEPENDENCIES
tunemygc
uglifier
webmock
will_paginate (~> 3.0.6)
will_paginate

RUBY VERSION
ruby 2.3.3p222
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def posts_from_relation(relation, no_tests=true, with_pagination=true)
posts = posts.paginate(page: page, per_page: 25) if with_pagination
posts = posts.no_tests if no_tests

if (with_pagination && posts.total_pages <= 1) || posts.count <= 25
if (with_pagination && posts.total_pages <= 1) || posts.count(:all) <= 25
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Otherwise it calls COUNT(posts.*, board.name AS board_name, …) which triggers a syntax error. See rails/rails#10710

posts = posts.select {|post| post.visible_to?(current_user)}
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/posts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def unread

def mark
posts = Post.where(id: params[:marked_ids])
posts.select! do |post|
posts = posts.select do |post|
post.visible_to?(current_user)
end
if params[:commit] == "Mark Read"
Expand Down
5 changes: 5 additions & 0 deletions app/models/galleries_icon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@ class GalleriesIcon < ActiveRecord::Base
belongs_to :gallery
accepts_nested_attributes_for :icon, allow_destroy: true

after_create :set_has_gallery
after_destroy :unset_has_gallery

def set_has_gallery
icon.update_attributes(has_gallery: true)
end

def unset_has_gallery
return if icon.galleries.present?
icon.update_attributes(has_gallery: false)
Expand Down
15 changes: 2 additions & 13 deletions app/models/gallery.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
class Gallery < ActiveRecord::Base
belongs_to :user
belongs_to :cover_icon, class_name: Icon

has_many :galleries_icons
has_and_belongs_to_many :icons, -> { order('LOWER(keyword)') }, after_add: :set_has_gallery, after_remove: :unset_has_gallery
has_many :icons, -> { order('LOWER(keyword)') }, through: :galleries_icons

has_many :characters_galleries
has_many :characters, through: :characters_galleries
Expand All @@ -20,16 +21,4 @@ def default_icon
def character_gallery_for(character)
characters_galleries.where(character_id: character).first
end

private

def set_has_gallery(icon)
return unless valid? # don't change icon status unless the gallery being saved is valid
icon.update_attributes(has_gallery: true)
end

def unset_has_gallery(icon)
return if icon.galleries.present?
icon.update_attributes(has_gallery: false)
end
end
2 changes: 1 addition & 1 deletion app/views/posts/_generate_flat.haml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- 1.upto((replies.count / 250.0).ceil).each do |index|
- 1.upto((replies.count(:all) / 250.0).ceil).each do |index|
- replies.paginate(per_page: 250, page: index).each do |reply|
- klass = cycle('even'.freeze, 'odd'.freeze)
.post-container{class: klass}
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/cookies_serializer.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Be sure to restart your server when you modify this file.

Rails.application.config.action_dispatch.cookies_serializer = :json
Rails.application.config.action_dispatch.cookies_serializer = :hybrid
Copy link
Contributor

Choose a reason for hiding this comment

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

For my personal edification, whyfor?

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 think this commit message answers why? The details are basically "I'm not sure why this file existed before, I don't think it applied, this should be better?

"906de238867e9806c7d894d16ccc23937bd8fcd5

Copy link
Contributor Author

Choose a reason for hiding this comment

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

906de23

(Oops)

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, didn't see the commit message, thanks!