Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix a bunch of things for rails 5 migration
  • Loading branch information
nono committed Apr 15, 2018
1 parent 08d712e commit 17240a9
Show file tree
Hide file tree
Showing 29 changed files with 105 additions and 117 deletions.
18 changes: 12 additions & 6 deletions Gemfile
@@ -1,5 +1,10 @@
source 'https://rubygems.org'

git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end

gem "rails", "5.0.5"

gem "actionpack-page_caching", "~>1.1"
Expand All @@ -9,9 +14,9 @@ gem "bitfields", "~>0.4"
gem "canable", "~>0.1"
gem "carrierwave", "~>1.1"
gem "devise", "~>4.3"
gem "diff_match_patch", git: "https://github.com/nono/diff_match_patch-ruby.git", require: "diff_match_patch"
gem "doorkeeper", "~>2.1"
gem "ffi-hunspell", git: "https://github.com/postmodern/ffi-hunspell.git"
gem "diff_match_patch", github: "nono/diff_match_patch-ruby", require: "diff_match_patch"
gem "doorkeeper", "~>4.2"
gem "ffi-hunspell", github: "postmodern/ffi-hunspell"
gem "french_rails", "~>0.4"
gem "friendly_id", "~>5.1"
gem "haml", "~>4.0"
Expand Down Expand Up @@ -46,16 +51,17 @@ group :development do
gem "annotate"
gem "better_errors"
gem "binding_of_caller"
gem "byebug"
gem "capistrano", "~>2.15", git: 'https://github.com/capistrano/capistrano.git', branch: 'legacy-v2'
gem "byebug", platform: :mri
gem "capistrano", "~>2.15", github: 'capistrano', branch: 'legacy-v2'
gem "capistrano-maintenance"
gem "letter_opener"
gem "listen"
gem "mo"
gem "pry-rails"
gem "spring"
gem "sushi"
gem "thin"
gem "web-console", "~> 2.1"
gem "web-console"
end

group :test do
Expand Down
50 changes: 28 additions & 22 deletions Gemfile.lock
Expand Up @@ -18,9 +18,9 @@ GIT

GIT
remote: https://github.com/postmodern/ffi-hunspell.git
revision: c5c98da6f39dace66ef2522ab75bb147dd7ddd27
revision: d3dcb5d17ef12c955e957573ca98a0fbaf655e14
specs:
ffi-hunspell (0.3.1)
ffi-hunspell (0.4.0)
ffi (~> 1.0)

GEM
Expand Down Expand Up @@ -75,10 +75,11 @@ GEM
ansi (1.5.0)
arel (7.1.4)
bcrypt (3.1.11)
better_errors (2.1.1)
better_errors (2.3.0)
coderay (>= 1.0.0)
erubis (>= 2.6.6)
erubi (>= 1.0.0)
rack (>= 0.9.0)
bindex (0.5.0)
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
bitfields (0.7.0)
Expand Down Expand Up @@ -119,11 +120,12 @@ GEM
responders
warden (~> 1.2.3)
diff-lcs (1.3)
doorkeeper (2.2.2)
railties (>= 3.2)
doorkeeper (4.2.6)
railties (>= 4.2)
erubi (1.6.1)
erubis (2.7.0)
escape_utils (1.2.1)
eventmachine (1.2.1)
eventmachine (1.2.5)
execjs (2.7.0)
factory_girl (2.6.4)
activesupport (>= 2.3.9)
Expand Down Expand Up @@ -156,8 +158,8 @@ GEM
pygments.rb (~> 1.1)
redcarpet (~> 3.4)
sanitize (~> 4.0)
html_spellchecker (0.1.8)
ffi-hunspell (= 0.3.1)
html_spellchecker (0.1.9)
ffi-hunspell (~> 0.4)
nokogiri (~> 1.4)
html_truncator (0.4.1)
nokogiri (~> 1.5)
Expand All @@ -182,6 +184,9 @@ GEM
letter_opener (1.4.1)
launchy (~> 2.2)
libv8 (3.16.14.19)
listen (3.0.8)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
loofah (2.0.3)
nokogiri (>= 1.5.9)
mail (2.6.6)
Expand All @@ -198,7 +203,7 @@ GEM
mo (1.4.0)
boson
multi_json (1.12.2)
mysql2 (0.4.5)
mysql2 (0.4.9)
net-scp (1.2.1)
net-ssh (>= 2.6.5)
net-sftp (2.1.2)
Expand All @@ -217,8 +222,8 @@ GEM
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
pry-rails (0.3.4)
pry (>= 0.9.10)
pry-rails (0.3.6)
pry (>= 0.10.4)
public_suffix (2.0.5)
multi_json (>= 1.0.0)
pygments.rb (1.2.1)
Expand Down Expand Up @@ -249,7 +254,7 @@ GEM
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
raindrops (0.17.0)
raindrops (0.19.0)
rake (12.0.0)
rb-fsevent (0.10.2)
rb-inotify (0.9.10)
Expand Down Expand Up @@ -316,7 +321,7 @@ GEM
therubyracer (0.12.3)
libv8 (~> 3.16.14.15)
ref
thin (1.7.0)
thin (1.7.2)
daemons (~> 1.0, >= 1.0.9)
eventmachine (~> 1.0, >= 1.0.4)
rack (>= 1, < 3)
Expand All @@ -327,16 +332,16 @@ GEM
thread_safe (~> 0.1)
uglifier (3.2.0)
execjs (>= 0.3.0, < 3)
unicorn (5.2.0)
unicorn (5.3.0)
kgio (~> 2.6)
raindrops (~> 0.7)
warden (1.2.7)
rack (>= 1.0)
web-console (2.3.0)
activemodel (>= 4.0)
binding_of_caller (>= 0.7.2)
railties (>= 4.0)
sprockets-rails (>= 2.0, < 4.0)
web-console (3.5.1)
actionview (>= 5.0)
activemodel (>= 5.0)
bindex (>= 0.4.0)
railties (>= 5.0)
websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.2)
Expand Down Expand Up @@ -364,7 +369,7 @@ DEPENDENCIES
database_cleaner (~> 1.2)
devise (~> 4.3)
diff_match_patch!
doorkeeper (~> 2.1)
doorkeeper (~> 4.2)
factory_girl_rails (~> 1.6)
ffi-hunspell!
french_rails (~> 0.4)
Expand All @@ -381,6 +386,7 @@ DEPENDENCIES
jquery-rails (~> 4.0)
kaminari (~> 0.15)
letter_opener
listen
mini_magick (~> 3.8)
mo
mysql2 (~> 0.3)
Expand All @@ -400,7 +406,7 @@ DEPENDENCIES
thin
uglifier
unicorn (~> 5.1)
web-console (~> 2.1)
web-console

BUNDLED WITH
1.15.4
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -61,7 +61,7 @@ $ bundle install
5) Finish to configure:

```
$ bin/rake db:setup
$ bin/rails db:setup
(if you're updating, you'll need an other step: redis-cli flushdb)
```

Expand Down
3 changes: 1 addition & 2 deletions Rakefile
@@ -1,7 +1,6 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require "rake"
require File.expand_path('../config/application', __FILE__)
require_relative 'config/application'

Rails.application.load_tasks
2 changes: 2 additions & 0 deletions app/assets/config/manifest.js
@@ -0,0 +1,2 @@
//= link_directory ../javascripts .js
//= link_directory ../stylesheets .css
4 changes: 2 additions & 2 deletions app/controllers/admin/accounts_controller.rb
Expand Up @@ -42,10 +42,10 @@ def karma
def update
if @account.inactive?
@account.reactivate!
redirect_to :back, notice: "Compte réactivé"
redirect_back notice: "Compte réactivé", fallback_location: admin_accounts_url
else
@account.inactivate!
redirect_to :back, notice: "Compte désactivé"
redirect_back notice: "Compte désactivé", fallback_location: admin_accounts_url
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/v1/board_controller.rb
Expand Up @@ -17,7 +17,7 @@ def create
protected

def board_params
params.slice(:object_type, :object_id, :message)
params.permit(:object_type, :object_id, :message)
end

def expire_cache
Expand Down
16 changes: 8 additions & 8 deletions app/controllers/application_controller.rb
Expand Up @@ -49,14 +49,14 @@ def dont_index?
end

def configure_permitted_parameters
devise_parameter_sanitizer.for(:sign_up) << :email
devise_parameter_sanitizer.for(:account_update) do |u|
u.permit(:login, :email, :password, :password_confirmation, :current_password,
:hide_avatar, :news_on_home, :diaries_on_home, :posts_on_home,
:polls_on_home, :wiki_pages_on_home, :trackers_on_home, :bookmarks_on_home,
:sort_by_date_on_home, :hide_signature, :show_negative_nodes,
user_attributes: [:id, :name, :homesite, :jabber_id, :signature, :avatar, :custom_avatar_url])
end
devise_parameter_sanitizer.permit(:sign_up, keys: [:email])
devise_parameter_sanitizer.permit(:account_update, keys: [
:login, :email, :password, :password_confirmation, :current_password,
:hide_avatar, :news_on_home, :diaries_on_home, :posts_on_home,
:polls_on_home, :wiki_pages_on_home, :trackers_on_home, :bookmarks_on_home,
:sort_by_date_on_home, :hide_signature, :show_negative_nodes,
user_attributes: [:id, :name, :homesite, :jabber_id, :signature, :avatar, :custom_avatar_url]
])
end

### Content ###
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/boards_controller.rb
Expand Up @@ -20,7 +20,7 @@ def create
board.save
board.news.tap {|news| news.node.read_by current_account.id if news }
respond_to do |wants|
wants.html { redirect_to :back rescue redirect_to root_url }
wants.html { redirect_back fallback_location: root_url }
wants.js { render nothing: true }
wants.xml { render nothing: true }
wants.tsv { render nothing: true }
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/moderation/news_controller.rb
Expand Up @@ -52,7 +52,7 @@ def accept
elsif @news.unlocked?
@news.moderator_id = current_user.id
@news.accept!
NewsNotifications.accept(@news).deliver
NewsNotifications.accept(@news).deliver_now
redirect_to @news, alert: "Dépêche acceptée"
else
redirect_to [:moderation, @news], alert: "Impossible de modérer la dépêche tant que quelqu'un est en train de la modifier"
Expand All @@ -66,7 +66,7 @@ def refuse
@news.put_paragraphs_together
@news.refuse!
notif = NewsNotifications.refuse_with_message(@news, params[:message], params[:template])
notif.deliver if notif
notif.deliver_now if notif
redirect_to '/'
elsif @news.unlocked?
@boards = Board.all(Board.news, @news.id)
Expand All @@ -80,7 +80,7 @@ def rewrite
if @news.unlocked?
@news.moderator_id = current_user.id
@news.rewrite!
NewsNotifications.rewrite(@news).deliver
NewsNotifications.rewrite(@news).deliver_now
redirect_to @news, alert: "Dépêche renvoyée en rédaction"
else
redirect_to [:moderation, @news], alert: "Impossible de modérer la dépêche tant que quelqu'un est en train de la modifier"
Expand Down
8 changes: 3 additions & 5 deletions app/controllers/polls_controller.rb
Expand Up @@ -11,11 +11,9 @@ class PollsController < ApplicationController
def index
@order = params[:order]
@order = "created_at" unless VALID_ORDERS.include?(@order)
@polls = Poll.archived.joins(:node).order("nodes.#{@order} DESC").page(params[:page])
if on_the_first_page?
poll = Poll.current
@polls.unshift(poll) if poll
end
@polls = Poll.archived
@polls = Poll.published.or(@polls) if on_the_first_page?
@polls = @polls.joins(:node).order("nodes.#{@order} DESC").page(params[:page])
respond_with(@polls)
end

Expand Down
4 changes: 2 additions & 2 deletions app/controllers/relevances_controller.rb
Expand Up @@ -14,7 +14,7 @@ def for
end
respond_to do |wants|
wants.json { render json: { notice: notice, nb_votes: current_account.nb_votes } }
wants.html { redirect_to :back rescue redirect_to root_url }
wants.html { redirect_back fallback_location: root_url }
end
end

Expand All @@ -27,7 +27,7 @@ def against
end
respond_to do |wants|
wants.json { render json: { notice: notice, nb_votes: current_account.nb_votes } }
wants.html { redirect_to :back rescue redirect_to root_url }
wants.html { redirect_back :back fallback_location: root_url }
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/sessions_controller.rb
Expand Up @@ -12,7 +12,7 @@ def create
cookies.permanent[:https] = { value: "1", secure: false } if request.ssl?
@account = warden.authenticate!(scope: :account, recall: "#{controller_path}#new")
sign_in :account, @account
redirect_to stored_location_for(:account) || :back, notice: I18n.t("devise.sessions.signed_in")
redirect_to after_sign_in_path_for(:account), notice: I18n.t("devise.sessions.signed_in")
rescue ActionController::RedirectBackError
redirect_to '/'
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/tags_controller.rb
Expand Up @@ -78,7 +78,7 @@ def public
def hide
enforce_update_permission(@tag)
@tag.toggle!("public")
redirect_to :back, notice: "La visibilité du tag a bien été modifiée"
redirect_back, fallback_location: root_url, notice: "La visibilité du tag a bien été modifiée"
rescue
redirect_to root_url
end
Expand Down
5 changes: 3 additions & 2 deletions app/helpers/news_helper.rb
Expand Up @@ -19,8 +19,9 @@ def news_posted_by(news)
end

def edited_by(news)
return "" if news.edited_by.none?
users = news.edited_by.map {|u| link_to u.name, u }.to_sentence
editors = news.edited_by.to_a
return "" if editors.none?
users = editors.map {|u| link_to u.name, u }.to_sentence
caption = content_tag(:span, "Édité par #{content_tag :span, users.html_safe, class: "edited_by"}.".html_safe, class: "edited_by_spanblock");
caption.html_safe
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/diary.rb
Expand Up @@ -94,7 +94,7 @@ def move_to_forum(attrs)
ELSE 'Diary' END
WHERE id=#{node.id} OR id=#{@post.node.id}
EOS
Node.connection.update_sql(stmt)
Node.connection.update(stmt)
node.compute_interest
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/news.rb
Expand Up @@ -140,7 +140,7 @@ def self.create_for_redaction(account)
end

def followup(message, user)
NewsNotifications.followup(self, message).deliver
NewsNotifications.followup(self, message).deliver_now
msg = "<b>Relance :</b> #{message}"
Board.new(object_type: Board.news, object_id: self.id, message: msg, user_name: user.name).save
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/node.rb
Expand Up @@ -63,7 +63,7 @@ def on_ppp?
def compute_interest
coeff = content_type.constantize.interest_coefficient
stmt = "UPDATE nodes SET interest=(score * #{coeff} + UNIX_TIMESTAMP(created_at) / 1000) WHERE id=#{self.id}"
Node.connection.update_sql(stmt)
Node.connection.update(stmt)
end

def make_visible
Expand Down
2 changes: 1 addition & 1 deletion config.ru
@@ -1,6 +1,6 @@
# This file is used by Rack-based servers to start the application.

require ::File.expand_path('../config/environment', __FILE__)
require_relative 'config/environment'

if defined?(Unicorn::HttpRequest)
require 'gctools/oobgc'
Expand Down

0 comments on commit 17240a9

Please sign in to comment.