Upgrade rails 5 1 (#367)
* Upgrade to rails 5.1 - Update versions of dependencies - Switch before_filter to before_action - Use render plain rather than render text * Generate new rails 5.1 scripts
This commit is contained in:
parent
0cb4048dd6
commit
28c8217652
6
Gemfile
6
Gemfile
|
@ -1,6 +1,6 @@
|
|||
source "https://rubygems.org"
|
||||
|
||||
gem "rails", "4.2.8"
|
||||
gem "rails", "~> 5.1"
|
||||
|
||||
gem "unicorn"
|
||||
|
||||
|
@ -10,7 +10,7 @@ gem "mysql2", ">= 0.3.14"
|
|||
# gem "pg"
|
||||
|
||||
gem "uglifier", ">= 1.3.0"
|
||||
gem "jquery-rails", "~> 3.1.3"
|
||||
gem "jquery-rails", "~> 4.3"
|
||||
gem "dynamic_form"
|
||||
|
||||
gem "exception_notification"
|
||||
|
@ -32,7 +32,7 @@ gem "oauth"
|
|||
gem "mail"
|
||||
|
||||
group :test, :development do
|
||||
gem "rspec-rails", "~> 3.5", ">= 3.5.2"
|
||||
gem "rspec-rails", "~> 3.6"
|
||||
gem "machinist"
|
||||
gem "sqlite3"
|
||||
gem "faker"
|
||||
|
|
183
Gemfile.lock
183
Gemfile.lock
|
@ -1,129 +1,134 @@
|
|||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
actionmailer (4.2.8)
|
||||
actionpack (= 4.2.8)
|
||||
actionview (= 4.2.8)
|
||||
activejob (= 4.2.8)
|
||||
actioncable (5.1.1)
|
||||
actionpack (= 5.1.1)
|
||||
nio4r (~> 2.0)
|
||||
websocket-driver (~> 0.6.1)
|
||||
actionmailer (5.1.1)
|
||||
actionpack (= 5.1.1)
|
||||
actionview (= 5.1.1)
|
||||
activejob (= 5.1.1)
|
||||
mail (~> 2.5, >= 2.5.4)
|
||||
rails-dom-testing (~> 1.0, >= 1.0.5)
|
||||
actionpack (4.2.8)
|
||||
actionview (= 4.2.8)
|
||||
activesupport (= 4.2.8)
|
||||
rack (~> 1.6)
|
||||
rack-test (~> 0.6.2)
|
||||
rails-dom-testing (~> 1.0, >= 1.0.5)
|
||||
rails-dom-testing (~> 2.0)
|
||||
actionpack (5.1.1)
|
||||
actionview (= 5.1.1)
|
||||
activesupport (= 5.1.1)
|
||||
rack (~> 2.0)
|
||||
rack-test (~> 0.6.3)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||
actionview (4.2.8)
|
||||
activesupport (= 4.2.8)
|
||||
actionview (5.1.1)
|
||||
activesupport (= 5.1.1)
|
||||
builder (~> 3.1)
|
||||
erubis (~> 2.7.0)
|
||||
rails-dom-testing (~> 1.0, >= 1.0.5)
|
||||
erubi (~> 1.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
||||
activejob (4.2.8)
|
||||
activesupport (= 4.2.8)
|
||||
globalid (>= 0.3.0)
|
||||
activemodel (4.2.8)
|
||||
activesupport (= 4.2.8)
|
||||
builder (~> 3.1)
|
||||
activerecord (4.2.8)
|
||||
activemodel (= 4.2.8)
|
||||
activesupport (= 4.2.8)
|
||||
arel (~> 6.0)
|
||||
activerecord-typedstore (0.6.1)
|
||||
activerecord (>= 3.2, < 5)
|
||||
activesupport (4.2.8)
|
||||
activejob (5.1.1)
|
||||
activesupport (= 5.1.1)
|
||||
globalid (>= 0.3.6)
|
||||
activemodel (5.1.1)
|
||||
activesupport (= 5.1.1)
|
||||
activerecord (5.1.1)
|
||||
activemodel (= 5.1.1)
|
||||
activesupport (= 5.1.1)
|
||||
arel (~> 8.0)
|
||||
activerecord-typedstore (1.1.1)
|
||||
activerecord (>= 4.2, < 5.2)
|
||||
activesupport (5.1.1)
|
||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||
i18n (~> 0.7)
|
||||
minitest (~> 5.1)
|
||||
thread_safe (~> 0.3, >= 0.3.4)
|
||||
tzinfo (~> 1.1)
|
||||
arel (6.0.4)
|
||||
bcrypt (3.1.7)
|
||||
arel (8.0.0)
|
||||
bcrypt (3.1.11)
|
||||
builder (3.2.3)
|
||||
chunky_png (1.3.8)
|
||||
commonmarker (0.14.15)
|
||||
commonmarker (0.16.0)
|
||||
ruby-enum (~> 0.5)
|
||||
concurrent-ruby (1.0.5)
|
||||
diff-lcs (1.3)
|
||||
dynamic_form (1.1.4)
|
||||
erubis (2.7.0)
|
||||
exception_notification (4.0.1)
|
||||
actionmailer (>= 3.0.4)
|
||||
activesupport (>= 3.0.4)
|
||||
erubi (1.6.0)
|
||||
exception_notification (4.2.1)
|
||||
actionmailer (>= 4.0, < 6)
|
||||
activesupport (>= 4.0, < 6)
|
||||
execjs (2.7.0)
|
||||
faker (1.4.2)
|
||||
faker (1.7.3)
|
||||
i18n (~> 0.5)
|
||||
globalid (0.3.7)
|
||||
activesupport (>= 4.1.0)
|
||||
globalid (0.4.0)
|
||||
activesupport (>= 4.2.0)
|
||||
htmlentities (4.3.4)
|
||||
i18n (0.8.1)
|
||||
jquery-rails (3.1.4)
|
||||
railties (>= 3.0, < 5.0)
|
||||
i18n (0.8.4)
|
||||
jquery-rails (4.3.1)
|
||||
rails-dom-testing (>= 1, < 3)
|
||||
railties (>= 4.2.0)
|
||||
thor (>= 0.14, < 2.0)
|
||||
kgio (2.9.2)
|
||||
kgio (2.11.0)
|
||||
loofah (2.0.3)
|
||||
nokogiri (>= 1.5.9)
|
||||
machinist (2.0)
|
||||
mail (2.6.4)
|
||||
mail (2.6.6)
|
||||
mime-types (>= 1.16, < 4)
|
||||
method_source (0.8.2)
|
||||
mime-types (3.1)
|
||||
mime-types-data (~> 3.2015)
|
||||
mime-types-data (3.2016.0521)
|
||||
mini_portile2 (2.1.0)
|
||||
mini_portile2 (2.2.0)
|
||||
minitest (5.10.2)
|
||||
mysql2 (0.3.20)
|
||||
nokogiri (1.7.2)
|
||||
mini_portile2 (~> 2.1.0)
|
||||
oauth (0.4.7)
|
||||
rack (1.6.8)
|
||||
mysql2 (0.4.6)
|
||||
nio4r (2.1.0)
|
||||
nokogiri (1.8.0)
|
||||
mini_portile2 (~> 2.2.0)
|
||||
oauth (0.5.3)
|
||||
rack (2.0.3)
|
||||
rack-test (0.6.3)
|
||||
rack (>= 1.0)
|
||||
rails (4.2.8)
|
||||
actionmailer (= 4.2.8)
|
||||
actionpack (= 4.2.8)
|
||||
actionview (= 4.2.8)
|
||||
activejob (= 4.2.8)
|
||||
activemodel (= 4.2.8)
|
||||
activerecord (= 4.2.8)
|
||||
activesupport (= 4.2.8)
|
||||
rails (5.1.1)
|
||||
actioncable (= 5.1.1)
|
||||
actionmailer (= 5.1.1)
|
||||
actionpack (= 5.1.1)
|
||||
actionview (= 5.1.1)
|
||||
activejob (= 5.1.1)
|
||||
activemodel (= 5.1.1)
|
||||
activerecord (= 5.1.1)
|
||||
activesupport (= 5.1.1)
|
||||
bundler (>= 1.3.0, < 2.0)
|
||||
railties (= 4.2.8)
|
||||
sprockets-rails
|
||||
rails-deprecated_sanitizer (1.0.3)
|
||||
activesupport (>= 4.2.0.alpha)
|
||||
rails-dom-testing (1.0.8)
|
||||
activesupport (>= 4.2.0.beta, < 5.0)
|
||||
nokogiri (~> 1.6)
|
||||
rails-deprecated_sanitizer (>= 1.0.1)
|
||||
railties (= 5.1.1)
|
||||
sprockets-rails (>= 2.0.0)
|
||||
rails-dom-testing (2.0.3)
|
||||
activesupport (>= 4.2.0)
|
||||
nokogiri (>= 1.6)
|
||||
rails-html-sanitizer (1.0.3)
|
||||
loofah (~> 2.0)
|
||||
railties (4.2.8)
|
||||
actionpack (= 4.2.8)
|
||||
activesupport (= 4.2.8)
|
||||
railties (5.1.1)
|
||||
actionpack (= 5.1.1)
|
||||
activesupport (= 5.1.1)
|
||||
method_source
|
||||
rake (>= 0.8.7)
|
||||
thor (>= 0.18.1, < 2.0)
|
||||
raindrops (0.13.0)
|
||||
raindrops (0.18.0)
|
||||
rake (12.0.0)
|
||||
rotp (3.3.0)
|
||||
rqrcode (0.10.1)
|
||||
chunky_png (~> 1.0)
|
||||
rspec-core (3.5.4)
|
||||
rspec-support (~> 3.5.0)
|
||||
rspec-expectations (3.5.0)
|
||||
rspec-core (3.6.0)
|
||||
rspec-support (~> 3.6.0)
|
||||
rspec-expectations (3.6.0)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.5.0)
|
||||
rspec-mocks (3.5.0)
|
||||
rspec-support (~> 3.6.0)
|
||||
rspec-mocks (3.6.0)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.5.0)
|
||||
rspec-rails (3.5.2)
|
||||
rspec-support (~> 3.6.0)
|
||||
rspec-rails (3.6.0)
|
||||
actionpack (>= 3.0)
|
||||
activesupport (>= 3.0)
|
||||
railties (>= 3.0)
|
||||
rspec-core (~> 3.5.0)
|
||||
rspec-expectations (~> 3.5.0)
|
||||
rspec-mocks (~> 3.5.0)
|
||||
rspec-support (~> 3.5.0)
|
||||
rspec-support (3.5.0)
|
||||
rspec-core (~> 3.6.0)
|
||||
rspec-expectations (~> 3.6.0)
|
||||
rspec-mocks (~> 3.6.0)
|
||||
rspec-support (~> 3.6.0)
|
||||
rspec-support (3.6.0)
|
||||
ruby-enum (0.7.1)
|
||||
i18n
|
||||
sprockets (3.7.1)
|
||||
|
@ -133,17 +138,19 @@ GEM
|
|||
actionpack (>= 4.0)
|
||||
activesupport (>= 4.0)
|
||||
sprockets (>= 3.0.0)
|
||||
sqlite3 (1.3.9)
|
||||
sqlite3 (1.3.13)
|
||||
thor (0.19.4)
|
||||
thread_safe (0.3.6)
|
||||
tzinfo (1.2.3)
|
||||
thread_safe (~> 0.1)
|
||||
uglifier (3.2.0)
|
||||
execjs (>= 0.3.0, < 3)
|
||||
unicorn (4.8.3)
|
||||
unicorn (5.3.0)
|
||||
kgio (~> 2.6)
|
||||
rack
|
||||
raindrops (~> 0.7)
|
||||
websocket-driver (0.6.5)
|
||||
websocket-extensions (>= 0.1.0)
|
||||
websocket-extensions (0.1.2)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
@ -156,16 +163,16 @@ DEPENDENCIES
|
|||
exception_notification
|
||||
faker
|
||||
htmlentities
|
||||
jquery-rails (~> 3.1.3)
|
||||
jquery-rails (~> 4.3)
|
||||
machinist
|
||||
mail
|
||||
mysql2 (>= 0.3.14)
|
||||
nokogiri (>= 1.7.2)
|
||||
oauth
|
||||
rails (= 4.2.8)
|
||||
rails (~> 5.1)
|
||||
rotp
|
||||
rqrcode
|
||||
rspec-rails (~> 3.5, >= 3.5.2)
|
||||
rspec-rails (~> 3.6)
|
||||
sqlite3
|
||||
uglifier (>= 1.3.0)
|
||||
unicorn
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
class ApplicationController < ActionController::Base
|
||||
protect_from_forgery
|
||||
before_filter :authenticate_user
|
||||
before_filter :increase_traffic_counter
|
||||
before_action :authenticate_user
|
||||
before_action :increase_traffic_counter
|
||||
|
||||
TRAFFIC_DECREMENTER = 0.40
|
||||
|
||||
|
@ -92,7 +92,7 @@ class ApplicationController < ActionController::Base
|
|||
if @user
|
||||
true
|
||||
else
|
||||
render :text => "not logged in", :status => 400
|
||||
render :plain => "not logged in", :status => 400
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,17 +2,17 @@ class CommentsController < ApplicationController
|
|||
COMMENTS_PER_PAGE = 20
|
||||
|
||||
# for rss feeds, load the user's tag filters if a token is passed
|
||||
before_filter :find_user_from_rss_token, :only => [ :index ]
|
||||
before_filter :require_logged_in_user_or_400,
|
||||
before_action :find_user_from_rss_token, :only => [ :index ]
|
||||
before_action :require_logged_in_user_or_400,
|
||||
:only => [ :create, :preview, :upvote, :downvote, :unvote ]
|
||||
|
||||
# for rss feeds, load the user's tag filters if a token is passed
|
||||
before_filter :find_user_from_rss_token, :only => [ :index ]
|
||||
before_action :find_user_from_rss_token, :only => [ :index ]
|
||||
|
||||
def create
|
||||
if !(story = Story.where(:short_id => params[:story_id]).first) ||
|
||||
story.is_gone?
|
||||
return render :text => "can't find story", :status => 400
|
||||
return render :plain => "can't find story", :status => 400
|
||||
end
|
||||
|
||||
comment = story.comments.build
|
||||
|
@ -61,7 +61,7 @@ class CommentsController < ApplicationController
|
|||
|
||||
def show
|
||||
if !((comment = find_comment) && comment.is_editable_by_user?(@user))
|
||||
return render :text => "can't find comment", :status => 400
|
||||
return render :plain => "can't find comment", :status => 400
|
||||
end
|
||||
|
||||
render :partial => "comment", :layout => false,
|
||||
|
@ -70,7 +70,7 @@ class CommentsController < ApplicationController
|
|||
|
||||
def show_short_id
|
||||
if !(comment = find_comment)
|
||||
return render :text => "can't find comment", :status => 400
|
||||
return render :plain => "can't find comment", :status => 400
|
||||
end
|
||||
|
||||
render :json => comment.as_json
|
||||
|
@ -80,13 +80,13 @@ class CommentsController < ApplicationController
|
|||
if comment = find_comment
|
||||
return redirect_to comment.url
|
||||
else
|
||||
return render :text => "can't find comment", :status => 400
|
||||
return render :plain => "can't find comment", :status => 400
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
if !((comment = find_comment) && comment.is_editable_by_user?(@user))
|
||||
return render :text => "can't find comment", :status => 400
|
||||
return render :plain => "can't find comment", :status => 400
|
||||
end
|
||||
|
||||
render :partial => "commentbox", :layout => false,
|
||||
|
@ -95,7 +95,7 @@ class CommentsController < ApplicationController
|
|||
|
||||
def reply
|
||||
if !(parent_comment = find_comment)
|
||||
return render :text => "can't find comment", :status => 400
|
||||
return render :plain => "can't find comment", :status => 400
|
||||
end
|
||||
|
||||
comment = Comment.new
|
||||
|
@ -108,7 +108,7 @@ class CommentsController < ApplicationController
|
|||
|
||||
def delete
|
||||
if !((comment = find_comment) && comment.is_deletable_by_user?(@user))
|
||||
return render :text => "can't find comment", :status => 400
|
||||
return render :plain => "can't find comment", :status => 400
|
||||
end
|
||||
|
||||
comment.delete_for_user(@user, params[:reason])
|
||||
|
@ -119,7 +119,7 @@ class CommentsController < ApplicationController
|
|||
|
||||
def undelete
|
||||
if !((comment = find_comment) && comment.is_undeletable_by_user?(@user))
|
||||
return render :text => "can't find comment", :status => 400
|
||||
return render :plain => "can't find comment", :status => 400
|
||||
end
|
||||
|
||||
comment.undelete_for_user(@user)
|
||||
|
@ -130,7 +130,7 @@ class CommentsController < ApplicationController
|
|||
|
||||
def update
|
||||
if !((comment = find_comment) && comment.is_editable_by_user?(@user))
|
||||
return render :text => "can't find comment", :status => 400
|
||||
return render :plain => "can't find comment", :status => 400
|
||||
end
|
||||
|
||||
comment.comment = params[:comment]
|
||||
|
@ -155,43 +155,43 @@ class CommentsController < ApplicationController
|
|||
|
||||
def unvote
|
||||
if !(comment = find_comment)
|
||||
return render :text => "can't find comment", :status => 400
|
||||
return render :plain => "can't find comment", :status => 400
|
||||
end
|
||||
|
||||
Vote.vote_thusly_on_story_or_comment_for_user_because(0, comment.story_id,
|
||||
comment.id, @user.id, nil)
|
||||
|
||||
render :text => "ok"
|
||||
render :plain => "ok"
|
||||
end
|
||||
|
||||
def upvote
|
||||
if !(comment = find_comment)
|
||||
return render :text => "can't find comment", :status => 400
|
||||
return render :plain => "can't find comment", :status => 400
|
||||
end
|
||||
|
||||
Vote.vote_thusly_on_story_or_comment_for_user_because(1, comment.story_id,
|
||||
comment.id, @user.id, params[:reason])
|
||||
|
||||
render :text => "ok"
|
||||
render :plain => "ok"
|
||||
end
|
||||
|
||||
def downvote
|
||||
if !(comment = find_comment)
|
||||
return render :text => "can't find comment", :status => 400
|
||||
return render :plain => "can't find comment", :status => 400
|
||||
end
|
||||
|
||||
if !Vote::COMMENT_REASONS[params[:reason]]
|
||||
return render :text => "invalid reason", :status => 400
|
||||
return render :plain => "invalid reason", :status => 400
|
||||
end
|
||||
|
||||
if !@user.can_downvote?(comment)
|
||||
return render :text => "not permitted to downvote", :status => 400
|
||||
return render :plain => "not permitted to downvote", :status => 400
|
||||
end
|
||||
|
||||
Vote.vote_thusly_on_story_or_comment_for_user_because(-1, comment.story_id,
|
||||
comment.id, @user.id, params[:reason])
|
||||
|
||||
render :text => "ok"
|
||||
render :plain => "ok"
|
||||
end
|
||||
|
||||
def index
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class FiltersController < ApplicationController
|
||||
before_filter :authenticate_user
|
||||
before_action :authenticate_user
|
||||
|
||||
def index
|
||||
@cur_url = "/filters"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class HatsController < ApplicationController
|
||||
before_filter :require_logged_in_user, :except => [ :index ]
|
||||
before_filter :require_logged_in_moderator,
|
||||
before_action :require_logged_in_user, :except => [ :index ]
|
||||
before_action :require_logged_in_moderator,
|
||||
:except => [ :build_request, :index, :create_request ]
|
||||
|
||||
def build_request
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
class HomeController < ApplicationController
|
||||
# for rss feeds, load the user's tag filters if a token is passed
|
||||
before_filter :find_user_from_rss_token, :only => [ :index, :newest ]
|
||||
before_filter { @page = page }
|
||||
before_filter :require_logged_in_user, :only => [ :upvoted ]
|
||||
before_action :find_user_from_rss_token, :only => [ :index, :newest ]
|
||||
before_action { @page = page }
|
||||
before_action :require_logged_in_user, :only => [ :upvoted ]
|
||||
|
||||
def four_oh_four
|
||||
begin
|
||||
@title = "Resource Not Found"
|
||||
render :action => "404", :status => 404
|
||||
rescue ActionView::MissingTemplate
|
||||
render :text => "<div class=\"box wide\">" <<
|
||||
render :plain => "<div class=\"box wide\">" <<
|
||||
"<div class=\"legend\">404</div>" <<
|
||||
"Resource not found" <<
|
||||
"</div>", :layout => "application"
|
||||
|
@ -21,7 +21,7 @@ class HomeController < ApplicationController
|
|||
@title = "About"
|
||||
render :action => "about"
|
||||
rescue ActionView::MissingTemplate
|
||||
render :text => "<div class=\"box wide\">" <<
|
||||
render :plain => "<div class=\"box wide\">" <<
|
||||
"A mystery." <<
|
||||
"</div>", :layout => "application"
|
||||
end
|
||||
|
@ -32,7 +32,7 @@ class HomeController < ApplicationController
|
|||
@title = "Chat"
|
||||
render :action => "chat"
|
||||
rescue ActionView::MissingTemplate
|
||||
render :text => "<div class=\"box wide\">" <<
|
||||
render :plain => "<div class=\"box wide\">" <<
|
||||
"<div class=\"legend\">Chat</div>" <<
|
||||
"Keep it on-site" <<
|
||||
"</div>", :layout => "application"
|
||||
|
@ -44,7 +44,7 @@ class HomeController < ApplicationController
|
|||
@title = "Privacy"
|
||||
render :action => "privacy"
|
||||
rescue ActionView::MissingTemplate
|
||||
render :text => "<div class=\"box wide\">" <<
|
||||
render :plain => "<div class=\"box wide\">" <<
|
||||
"You apparently have no privacy." <<
|
||||
"</div>", :layout => "application"
|
||||
end
|
||||
|
@ -84,7 +84,7 @@ class HomeController < ApplicationController
|
|||
content = Rails.cache.fetch("rss", :expires_in => (60 * 2)) {
|
||||
render_to_string :action => "rss", :layout => false
|
||||
}
|
||||
render :text => content, :layout => false
|
||||
render :plain => content, :layout => false
|
||||
end
|
||||
}
|
||||
format.json { render :json => @stories }
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class InvitationsController < ApplicationController
|
||||
before_filter :require_logged_in_user,
|
||||
before_action :require_logged_in_user,
|
||||
:except => [ :build, :create_by_request, :confirm_email ]
|
||||
|
||||
def build
|
||||
|
|
|
@ -4,7 +4,7 @@ class LoginTOTPFailedError < StandardError; end
|
|||
class LoginFailedError < StandardError; end
|
||||
|
||||
class LoginController < ApplicationController
|
||||
before_filter :authenticate_user
|
||||
before_action :authenticate_user
|
||||
|
||||
def logout
|
||||
if @user
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class MessagesController < ApplicationController
|
||||
before_filter :require_logged_in_user
|
||||
before_filter :find_message, :only => [ :show, :destroy, :keep_as_new ]
|
||||
before_action :require_logged_in_user
|
||||
before_action :find_message, :only => [ :show, :destroy, :keep_as_new ]
|
||||
|
||||
def index
|
||||
@cur_url = "/messages"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class SettingsController < ApplicationController
|
||||
before_filter :require_logged_in_user
|
||||
before_action :require_logged_in_user
|
||||
|
||||
TOTP_SESSION_TIMEOUT = (60 * 15)
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class SignupController < ApplicationController
|
||||
before_filter :require_logged_in_user, :only => :invite
|
||||
before_action :require_logged_in_user, :only => :invite
|
||||
|
||||
def index
|
||||
if @user
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
class StoriesController < ApplicationController
|
||||
before_filter :require_logged_in_user_or_400,
|
||||
before_action :require_logged_in_user_or_400,
|
||||
:only => [ :upvote, :downvote, :unvote, :hide, :unhide, :preview ]
|
||||
before_filter :require_logged_in_user, :only => [ :destroy, :create, :edit,
|
||||
before_action :require_logged_in_user, :only => [ :destroy, :create, :edit,
|
||||
:fetch_url_attributes, :new, :suggest ]
|
||||
before_filter :verify_user_can_submit_stories, :only => [ :new, :create ]
|
||||
before_filter :find_user_story, :only => [ :destroy, :edit, :undelete,
|
||||
before_action :verify_user_can_submit_stories, :only => [ :new, :create ]
|
||||
before_action :find_user_story, :only => [ :destroy, :edit, :undelete,
|
||||
:update ]
|
||||
before_filter :find_story!, :only => [ :suggest, :submit_suggestions ]
|
||||
before_action :find_story!, :only => [ :suggest, :submit_suggestions ]
|
||||
|
||||
def create
|
||||
@title = "Submit Story"
|
||||
|
@ -249,63 +249,63 @@ class StoriesController < ApplicationController
|
|||
|
||||
def unvote
|
||||
if !(story = find_story)
|
||||
return render :text => "can't find story", :status => 400
|
||||
return render :plain => "can't find story", :status => 400
|
||||
end
|
||||
|
||||
Vote.vote_thusly_on_story_or_comment_for_user_because(0, story.id,
|
||||
nil, @user.id, nil)
|
||||
|
||||
render :text => "ok"
|
||||
render :plain => "ok"
|
||||
end
|
||||
|
||||
def upvote
|
||||
if !(story = find_story)
|
||||
return render :text => "can't find story", :status => 400
|
||||
return render :plain => "can't find story", :status => 400
|
||||
end
|
||||
|
||||
Vote.vote_thusly_on_story_or_comment_for_user_because(1, story.id,
|
||||
nil, @user.id, nil)
|
||||
|
||||
render :text => "ok"
|
||||
render :plain => "ok"
|
||||
end
|
||||
|
||||
def downvote
|
||||
if !(story = find_story)
|
||||
return render :text => "can't find story", :status => 400
|
||||
return render :plain => "can't find story", :status => 400
|
||||
end
|
||||
|
||||
if !Vote::STORY_REASONS[params[:reason]]
|
||||
return render :text => "invalid reason", :status => 400
|
||||
return render :plain => "invalid reason", :status => 400
|
||||
end
|
||||
|
||||
if !@user.can_downvote?(story)
|
||||
return render :text => "not permitted to downvote", :status => 400
|
||||
return render :plain => "not permitted to downvote", :status => 400
|
||||
end
|
||||
|
||||
Vote.vote_thusly_on_story_or_comment_for_user_because(-1, story.id,
|
||||
nil, @user.id, params[:reason])
|
||||
|
||||
render :text => "ok"
|
||||
render :plain => "ok"
|
||||
end
|
||||
|
||||
def hide
|
||||
if !(story = find_story)
|
||||
return render :text => "can't find story", :status => 400
|
||||
return render :plain => "can't find story", :status => 400
|
||||
end
|
||||
|
||||
HiddenStory.hide_story_for_user(story.id, @user.id)
|
||||
|
||||
render :text => "ok"
|
||||
render :plain => "ok"
|
||||
end
|
||||
|
||||
def unhide
|
||||
if !(story = find_story)
|
||||
return render :text => "can't find story", :status => 400
|
||||
return render :plain => "can't find story", :status => 400
|
||||
end
|
||||
|
||||
HiddenStory.where(:user_id => @user.id, :story_id => story.id).delete_all
|
||||
|
||||
render :text => "ok"
|
||||
render :plain => "ok"
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class UsersController < ApplicationController
|
||||
before_filter :require_logged_in_moderator,
|
||||
before_action :require_logged_in_moderator,
|
||||
:only => [ :enable_invitation, :disable_invitation, :ban, :unban ]
|
||||
|
||||
def show
|
||||
|
@ -25,7 +25,7 @@ class UsersController < ApplicationController
|
|||
@title << " By Karma"
|
||||
render_to_string :action => "list", :layout => nil
|
||||
}
|
||||
render :text => content, :layout => "application"
|
||||
render :plain => content, :layout => "application"
|
||||
elsif params[:moderators]
|
||||
@users = User.where("is_admin = ? OR is_moderator = ?", true, true).
|
||||
order("id ASC").to_a
|
||||
|
@ -41,7 +41,7 @@ class UsersController < ApplicationController
|
|||
@newest = User.order("id DESC").limit(10)
|
||||
render_to_string :action => "tree", :layout => nil
|
||||
}
|
||||
render :text => content, :layout => "application"
|
||||
render :plain => content, :layout => "application"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
#!/usr/bin/env ruby
|
||||
require 'pathname'
|
||||
require 'fileutils'
|
||||
include FileUtils
|
||||
|
||||
# path to your application root.
|
||||
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
|
||||
|
||||
def system!(*args)
|
||||
system(*args) || abort("\n== Command #{args} failed ==")
|
||||
end
|
||||
|
||||
chdir APP_ROOT do
|
||||
# This script is a starting point to setup your application.
|
||||
# Add necessary setup steps to this file.
|
||||
|
||||
puts '== Installing dependencies =='
|
||||
system! 'gem install bundler --conservative'
|
||||
system('bundle check') || system!('bundle install')
|
||||
|
||||
# Install JavaScript dependencies if using Yarn
|
||||
# system('bin/yarn')
|
||||
|
||||
|
||||
# puts "\n== Copying sample files =="
|
||||
# unless File.exist?('config/database.yml')
|
||||
# cp 'config/database.yml.sample', 'config/database.yml'
|
||||
# end
|
||||
|
||||
puts "\n== Preparing database =="
|
||||
system! 'bin/rails db:setup'
|
||||
|
||||
puts "\n== Removing old logs and tempfiles =="
|
||||
system! 'bin/rails log:clear tmp:clear'
|
||||
|
||||
puts "\n== Restarting application server =="
|
||||
system! 'bin/rails restart'
|
||||
end
|
|
@ -0,0 +1,29 @@
|
|||
#!/usr/bin/env ruby
|
||||
require 'pathname'
|
||||
require 'fileutils'
|
||||
include FileUtils
|
||||
|
||||
# path to your application root.
|
||||
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
|
||||
|
||||
def system!(*args)
|
||||
system(*args) || abort("\n== Command #{args} failed ==")
|
||||
end
|
||||
|
||||
chdir APP_ROOT do
|
||||
# This script is a way to update your development environment automatically.
|
||||
# Add necessary update steps to this file.
|
||||
|
||||
puts '== Installing dependencies =='
|
||||
system! 'gem install bundler --conservative'
|
||||
system('bundle check') || system!('bundle install')
|
||||
|
||||
puts "\n== Updating database =="
|
||||
system! 'bin/rails db:migrate'
|
||||
|
||||
puts "\n== Removing old logs and tempfiles =="
|
||||
system! 'bin/rails log:clear tmp:clear'
|
||||
|
||||
puts "\n== Restarting application server =="
|
||||
system! 'bin/rails restart'
|
||||
end
|
|
@ -0,0 +1,11 @@
|
|||
#!/usr/bin/env ruby
|
||||
VENDOR_PATH = File.expand_path('..', __dir__)
|
||||
Dir.chdir(VENDOR_PATH) do
|
||||
begin
|
||||
exec "yarnpkg #{ARGV.join(" ")}"
|
||||
rescue Errno::ENOENT
|
||||
$stderr.puts "Yarn executable was not detected in the system."
|
||||
$stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
|
||||
exit 1
|
||||
end
|
||||
end
|
|
@ -26,7 +26,7 @@ module Lobsters
|
|||
# Raise an exception when using mass assignment with unpermitted attributes
|
||||
config.action_controller.action_on_unpermitted_parameters = :raise
|
||||
|
||||
config.active_record.raise_in_transactional_callbacks = true
|
||||
# config.active_record.raise_in_transactional_callbacks = true
|
||||
|
||||
config.cache_store = :file_store, "#{config.root}/tmp/cache/"
|
||||
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
development:
|
||||
adapter: async
|
||||
|
||||
test:
|
||||
adapter: async
|
||||
|
||||
production:
|
||||
adapter: redis
|
||||
url: redis://localhost:6379/1
|
||||
channel_prefix: lobsters_production
|
|
@ -0,0 +1,6 @@
|
|||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# ApplicationController.renderer.defaults.merge!(
|
||||
# http_host: 'example.org',
|
||||
# https: false
|
||||
# )
|
|
@ -0,0 +1,14 @@
|
|||
# Be sure to restart your server when you modify this file.
|
||||
#
|
||||
# This file contains migration options to ease your Rails 5.1 upgrade.
|
||||
#
|
||||
# Once upgraded flip defaults one by one to migrate to the new default.
|
||||
#
|
||||
# Read the Guide for Upgrading Ruby on Rails for more info on each option.
|
||||
|
||||
# Make `form_with` generate non-remote forms.
|
||||
Rails.application.config.action_view.form_with_generates_remote_forms = false
|
||||
|
||||
# Unknown asset fallback will return the path passed in when the given
|
||||
# asset is not present in the asset pipeline.
|
||||
# Rails.application.config.assets.unknown_asset_fallback = false
|
|
@ -0,0 +1,33 @@
|
|||
# Files in the config/locales directory are used for internationalization
|
||||
# and are automatically loaded by Rails. If you want to use locales other
|
||||
# than English, add the necessary files in this directory.
|
||||
#
|
||||
# To use the locales, use `I18n.t`:
|
||||
#
|
||||
# I18n.t 'hello'
|
||||
#
|
||||
# In views, this is aliased to just `t`:
|
||||
#
|
||||
# <%= t('hello') %>
|
||||
#
|
||||
# To use a different locale, set it with `I18n.locale`:
|
||||
#
|
||||
# I18n.locale = :es
|
||||
#
|
||||
# This would use the information in config/locales/es.yml.
|
||||
#
|
||||
# The following keys must be escaped otherwise they will not be retrieved by
|
||||
# the default I18n backend:
|
||||
#
|
||||
# true, false, on, off, yes, no
|
||||
#
|
||||
# Instead, surround them with single quotes.
|
||||
#
|
||||
# en:
|
||||
# 'true': 'foo'
|
||||
#
|
||||
# To learn more, please read the Rails Internationalization guide
|
||||
# available at http://guides.rubyonrails.org/i18n.html.
|
||||
|
||||
en:
|
||||
hello: "Hello world"
|
|
@ -0,0 +1,56 @@
|
|||
# Puma can serve each request in a thread from an internal thread pool.
|
||||
# The `threads` method setting takes two numbers: a minimum and maximum.
|
||||
# Any libraries that use thread pools should be configured to match
|
||||
# the maximum value specified for Puma. Default is set to 5 threads for minimum
|
||||
# and maximum; this matches the default thread size of Active Record.
|
||||
#
|
||||
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
|
||||
threads threads_count, threads_count
|
||||
|
||||
# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
|
||||
#
|
||||
port ENV.fetch("PORT") { 3000 }
|
||||
|
||||
# Specifies the `environment` that Puma will run in.
|
||||
#
|
||||
environment ENV.fetch("RAILS_ENV") { "development" }
|
||||
|
||||
# Specifies the number of `workers` to boot in clustered mode.
|
||||
# Workers are forked webserver processes. If using threads and workers together
|
||||
# the concurrency of the application would be max `threads` * `workers`.
|
||||
# Workers do not work on JRuby or Windows (both of which do not support
|
||||
# processes).
|
||||
#
|
||||
# workers ENV.fetch("WEB_CONCURRENCY") { 2 }
|
||||
|
||||
# Use the `preload_app!` method when specifying a `workers` number.
|
||||
# This directive tells Puma to first boot the application and load code
|
||||
# before forking the application. This takes advantage of Copy On Write
|
||||
# process behavior so workers use less memory. If you use this option
|
||||
# you need to make sure to reconnect any threads in the `on_worker_boot`
|
||||
# block.
|
||||
#
|
||||
# preload_app!
|
||||
|
||||
# If you are preloading your application and using Active Record, it's
|
||||
# recommended that you close any connections to the database before workers
|
||||
# are forked to prevent connection leakage.
|
||||
#
|
||||
# before_fork do
|
||||
# ActiveRecord::Base.connection_pool.disconnect! if defined?(ActiveRecord)
|
||||
# end
|
||||
|
||||
# The code in the `on_worker_boot` will be called if you are using
|
||||
# clustered mode by specifying a number of `workers`. After each worker
|
||||
# process is booted, this block will be run. If you are using the `preload_app!`
|
||||
# option, you will want to use this block to reconnect to any threads
|
||||
# or connections that may have been created at application boot, as Ruby
|
||||
# cannot share connections between processes.
|
||||
#
|
||||
# on_worker_boot do
|
||||
# ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
|
||||
# end
|
||||
#
|
||||
|
||||
# Allow puma to be restarted by `rails restart` command.
|
||||
plugin :tmp_restart
|
|
@ -0,0 +1,6 @@
|
|||
%w(
|
||||
.ruby-version
|
||||
.rbenv-vars
|
||||
tmp/restart.txt
|
||||
tmp/caching-dev.txt
|
||||
).each { |path| Spring.watch(path) }
|
|
@ -7,12 +7,11 @@ class EmailParser
|
|||
@email_text = email_text.forcibly_convert_to_utf8
|
||||
|
||||
@email = nil
|
||||
|
||||
begin
|
||||
# the mail gem stupidly spams STDERR while parsing e-mail, so silence
|
||||
# that stream to avoid anything getting back to postfix
|
||||
Utils.silence_stream(STDERR) do
|
||||
@email = Mail.read_from_string(email_text)
|
||||
end
|
||||
Utils.silence_stream(STDERR) do
|
||||
@email = Mail.read_from_string(email_text)
|
||||
end
|
||||
rescue
|
||||
end
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ class Utils
|
|||
return str
|
||||
end
|
||||
|
||||
def silence_stream(*streams)
|
||||
def self.silence_stream(*streams)
|
||||
on_hold = streams.collect {|stream| stream.dup }
|
||||
streams.each do |stream|
|
||||
stream.reopen("/dev/null")
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
require "spec_helper"
|
||||
|
||||
describe Utils do
|
||||
describe ".silence_streams" do
|
||||
it "is defined" do
|
||||
expect(Utils.methods).to include(:silence_stream)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue