Fix rubocop warnings
This commit is contained in:
parent
9d106676b8
commit
e17b89e89f
17 changed files with 105 additions and 80 deletions
|
@ -37,3 +37,6 @@ Style/HashSyntax:
|
||||||
|
|
||||||
Style/StringLiterals:
|
Style/StringLiterals:
|
||||||
EnforcedStyle: double_quotes
|
EnforcedStyle: double_quotes
|
||||||
|
|
||||||
|
Rails/HttpPositionalArguments:
|
||||||
|
Enabled: false
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# This configuration was generated by
|
# This configuration was generated by
|
||||||
# `rubocop --auto-gen-config`
|
# `rubocop --auto-gen-config`
|
||||||
# on 2016-09-07 11:03:27 +0100 using RuboCop version 0.41.2.
|
# on 2016-10-20 21:45:27 +0100 using RuboCop version 0.44.1.
|
||||||
# The point is for the user to remove these configuration records
|
# The point is for the user to remove these configuration records
|
||||||
# one by one as the offenses are removed from the code base.
|
# one by one as the offenses are removed from the code base.
|
||||||
# Note that changes in the inspected code, or installation of new
|
# Note that changes in the inspected code, or installation of new
|
||||||
|
@ -48,9 +48,14 @@ Lint/ShadowingOuterLocalVariable:
|
||||||
Exclude:
|
Exclude:
|
||||||
- 'app/views/changeset/list.atom.builder'
|
- 'app/views/changeset/list.atom.builder'
|
||||||
|
|
||||||
# Offense count: 626
|
# Offense count: 630
|
||||||
Metrics/AbcSize:
|
Metrics/AbcSize:
|
||||||
Max: 277
|
Max: 271
|
||||||
|
|
||||||
|
# Offense count: 35
|
||||||
|
# Configuration parameters: CountComments.
|
||||||
|
Metrics/BlockLength:
|
||||||
|
Max: 295
|
||||||
|
|
||||||
# Offense count: 12
|
# Offense count: 12
|
||||||
Metrics/BlockNesting:
|
Metrics/BlockNesting:
|
||||||
|
@ -61,17 +66,17 @@ Metrics/BlockNesting:
|
||||||
Metrics/ClassLength:
|
Metrics/ClassLength:
|
||||||
Max: 1652
|
Max: 1652
|
||||||
|
|
||||||
# Offense count: 68
|
# Offense count: 69
|
||||||
Metrics/CyclomaticComplexity:
|
Metrics/CyclomaticComplexity:
|
||||||
Max: 20
|
Max: 20
|
||||||
|
|
||||||
# Offense count: 2561
|
# Offense count: 2826
|
||||||
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
|
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives.
|
||||||
# URISchemes: http, https
|
# URISchemes: http, https
|
||||||
Metrics/LineLength:
|
Metrics/LineLength:
|
||||||
Max: 962
|
Max: 962
|
||||||
|
|
||||||
# Offense count: 604
|
# Offense count: 612
|
||||||
# Configuration parameters: CountComments.
|
# Configuration parameters: CountComments.
|
||||||
Metrics/MethodLength:
|
Metrics/MethodLength:
|
||||||
Max: 179
|
Max: 179
|
||||||
|
@ -79,14 +84,14 @@ Metrics/MethodLength:
|
||||||
# Offense count: 1
|
# Offense count: 1
|
||||||
# Configuration parameters: CountComments.
|
# Configuration parameters: CountComments.
|
||||||
Metrics/ModuleLength:
|
Metrics/ModuleLength:
|
||||||
Max: 139
|
Max: 147
|
||||||
|
|
||||||
# Offense count: 4
|
# Offense count: 4
|
||||||
# Configuration parameters: CountKeywordArgs.
|
# Configuration parameters: CountKeywordArgs.
|
||||||
Metrics/ParameterLists:
|
Metrics/ParameterLists:
|
||||||
Max: 9
|
Max: 9
|
||||||
|
|
||||||
# Offense count: 70
|
# Offense count: 71
|
||||||
Metrics/PerceivedComplexity:
|
Metrics/PerceivedComplexity:
|
||||||
Max: 23
|
Max: 23
|
||||||
|
|
||||||
|
@ -106,6 +111,17 @@ Rails/HasAndBelongsToMany:
|
||||||
- 'app/models/changeset.rb'
|
- 'app/models/changeset.rb'
|
||||||
- 'app/models/user.rb'
|
- 'app/models/user.rb'
|
||||||
|
|
||||||
|
# Offense count: 5
|
||||||
|
# Configuration parameters: Include.
|
||||||
|
# Include: db/migrate/*.rb
|
||||||
|
Rails/NotNullColumn:
|
||||||
|
Exclude:
|
||||||
|
- 'db/migrate/002_cleanup_osm_db.rb'
|
||||||
|
- 'db/migrate/020_populate_node_tags_and_remove.rb'
|
||||||
|
- 'db/migrate/021_move_to_innodb.rb'
|
||||||
|
- 'db/migrate/025_add_end_time_to_changesets.rb'
|
||||||
|
- 'db/migrate/20120404205604_add_user_and_description_to_redaction.rb'
|
||||||
|
|
||||||
# Offense count: 17
|
# Offense count: 17
|
||||||
Rails/OutputSafety:
|
Rails/OutputSafety:
|
||||||
Exclude:
|
Exclude:
|
||||||
|
@ -120,7 +136,7 @@ Rails/OutputSafety:
|
||||||
- 'lib/rich_text.rb'
|
- 'lib/rich_text.rb'
|
||||||
- 'test/helpers/application_helper_test.rb'
|
- 'test/helpers/application_helper_test.rb'
|
||||||
|
|
||||||
# Offense count: 65
|
# Offense count: 74
|
||||||
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
||||||
# SupportedStyles: strict, flexible
|
# SupportedStyles: strict, flexible
|
||||||
Rails/TimeZone:
|
Rails/TimeZone:
|
||||||
|
@ -140,10 +156,17 @@ Style/AsciiComments:
|
||||||
Exclude:
|
Exclude:
|
||||||
- 'test/models/message_test.rb'
|
- 'test/models/message_test.rb'
|
||||||
|
|
||||||
# Offense count: 218
|
# Offense count: 220
|
||||||
Style/Documentation:
|
Style/Documentation:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
|
# Offense count: 1
|
||||||
|
# Cop supports --auto-correct.
|
||||||
|
# Configuration parameters: MaxLineLength.
|
||||||
|
Style/IfUnlessModifier:
|
||||||
|
Exclude:
|
||||||
|
- 'app/controllers/way_controller.rb'
|
||||||
|
|
||||||
# Offense count: 60
|
# Offense count: 60
|
||||||
# Cop supports --auto-correct.
|
# Cop supports --auto-correct.
|
||||||
Style/LineEndConcatenation:
|
Style/LineEndConcatenation:
|
||||||
|
@ -159,7 +182,7 @@ Style/LineEndConcatenation:
|
||||||
- 'test/controllers/relation_controller_test.rb'
|
- 'test/controllers/relation_controller_test.rb'
|
||||||
- 'test/controllers/way_controller_test.rb'
|
- 'test/controllers/way_controller_test.rb'
|
||||||
|
|
||||||
# Offense count: 69
|
# Offense count: 71
|
||||||
# Cop supports --auto-correct.
|
# Cop supports --auto-correct.
|
||||||
Style/NumericLiterals:
|
Style/NumericLiterals:
|
||||||
MinDigits: 11
|
MinDigits: 11
|
||||||
|
|
|
@ -62,7 +62,7 @@ class ApplicationController < ActionController::Base
|
||||||
unless current_token.nil?
|
unless current_token.nil?
|
||||||
unless current_token.read_attribute(cap)
|
unless current_token.read_attribute(cap)
|
||||||
report_error "OAuth token doesn't have that capability.", :forbidden
|
report_error "OAuth token doesn't have that capability.", :forbidden
|
||||||
return false
|
false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -74,7 +74,7 @@ class ApplicationController < ActionController::Base
|
||||||
if params[:cookie_test].nil?
|
if params[:cookie_test].nil?
|
||||||
session[:cookie_test] = true
|
session[:cookie_test] = true
|
||||||
redirect_to Hash[params].merge(:cookie_test => "true")
|
redirect_to Hash[params].merge(:cookie_test => "true")
|
||||||
return false
|
false
|
||||||
else
|
else
|
||||||
flash.now[:warning] = t "application.require_cookies.cookies_needed"
|
flash.now[:warning] = t "application.require_cookies.cookies_needed"
|
||||||
end
|
end
|
||||||
|
@ -192,7 +192,7 @@ class ApplicationController < ActionController::Base
|
||||||
# check user is a moderator
|
# check user is a moderator
|
||||||
unless @user.moderator?
|
unless @user.moderator?
|
||||||
render :text => errormessage, :status => :forbidden
|
render :text => errormessage, :status => :forbidden
|
||||||
return false
|
false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -220,14 +220,14 @@ class ApplicationController < ActionController::Base
|
||||||
def check_api_readable
|
def check_api_readable
|
||||||
if api_status == :offline
|
if api_status == :offline
|
||||||
report_error "Database offline for maintenance", :service_unavailable
|
report_error "Database offline for maintenance", :service_unavailable
|
||||||
return false
|
false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_api_writable
|
def check_api_writable
|
||||||
unless api_status == :online
|
unless api_status == :online
|
||||||
report_error "Database offline for maintenance", :service_unavailable
|
report_error "Database offline for maintenance", :service_unavailable
|
||||||
return false
|
false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -262,7 +262,7 @@ class ApplicationController < ActionController::Base
|
||||||
def require_public_data
|
def require_public_data
|
||||||
unless @user.data_public?
|
unless @user.data_public?
|
||||||
report_error "You must make your edits public to upload new data", :forbidden
|
report_error "You must make your edits public to upload new data", :forbidden
|
||||||
return false
|
false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -375,7 +375,7 @@ class ApplicationController < ActionController::Base
|
||||||
##
|
##
|
||||||
# ensure that there is a "this_user" instance variable
|
# ensure that there is a "this_user" instance variable
|
||||||
def lookup_this_user
|
def lookup_this_user
|
||||||
unless @this_user = User.active.find_by_display_name(params[:display_name])
|
unless @this_user = User.active.find_by(:display_name => params[:display_name])
|
||||||
render_unknown_user params[:display_name]
|
render_unknown_user params[:display_name]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -256,7 +256,7 @@ class ChangesetController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
if params[:display_name]
|
if params[:display_name]
|
||||||
user = User.find_by_display_name(params[:display_name])
|
user = User.find_by(:display_name => params[:display_name])
|
||||||
if !user || !user.active?
|
if !user || !user.active?
|
||||||
render_unknown_user params[:display_name]
|
render_unknown_user params[:display_name]
|
||||||
return
|
return
|
||||||
|
@ -481,7 +481,7 @@ class ChangesetController < ApplicationController
|
||||||
raise OSM::APIBadUserInput.new("invalid user ID") if user.to_i < 1
|
raise OSM::APIBadUserInput.new("invalid user ID") if user.to_i < 1
|
||||||
u = User.find(user.to_i)
|
u = User.find(user.to_i)
|
||||||
else
|
else
|
||||||
u = User.find_by_display_name(name)
|
u = User.find_by(:display_name => name)
|
||||||
end
|
end
|
||||||
|
|
||||||
# make sure we found a user
|
# make sure we found a user
|
||||||
|
@ -535,10 +535,10 @@ class ChangesetController < ApplicationController
|
||||||
# if parameter 'open' is nill then open and closed changesets are returned
|
# if parameter 'open' is nill then open and closed changesets are returned
|
||||||
def conditions_open(changesets, open)
|
def conditions_open(changesets, open)
|
||||||
if open.nil?
|
if open.nil?
|
||||||
return changesets
|
changesets
|
||||||
else
|
else
|
||||||
return changesets.where("closed_at >= ? and num_changes <= ?",
|
changesets.where("closed_at >= ? and num_changes <= ?",
|
||||||
Time.now.getutc, Changeset::MAX_ELEMENTS)
|
Time.now.getutc, Changeset::MAX_ELEMENTS)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -547,10 +547,10 @@ class ChangesetController < ApplicationController
|
||||||
# ('closed at' time has passed or changes limit is hit)
|
# ('closed at' time has passed or changes limit is hit)
|
||||||
def conditions_closed(changesets, closed)
|
def conditions_closed(changesets, closed)
|
||||||
if closed.nil?
|
if closed.nil?
|
||||||
return changesets
|
changesets
|
||||||
else
|
else
|
||||||
return changesets.where("closed_at < ? or num_changes > ?",
|
changesets.where("closed_at < ? or num_changes > ?",
|
||||||
Time.now.getutc, Changeset::MAX_ELEMENTS)
|
Time.now.getutc, Changeset::MAX_ELEMENTS)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -559,12 +559,12 @@ class ChangesetController < ApplicationController
|
||||||
# (either specified as array or comma-separated string)
|
# (either specified as array or comma-separated string)
|
||||||
def conditions_ids(changesets, ids)
|
def conditions_ids(changesets, ids)
|
||||||
if ids.nil?
|
if ids.nil?
|
||||||
return changesets
|
changesets
|
||||||
elsif ids.empty?
|
elsif ids.empty?
|
||||||
raise OSM::APIBadUserInput.new("No changesets were given to search for")
|
raise OSM::APIBadUserInput.new("No changesets were given to search for")
|
||||||
else
|
else
|
||||||
ids = ids.split(",").collect(&:to_i)
|
ids = ids.split(",").collect(&:to_i)
|
||||||
return changesets.where(:id => ids)
|
changesets.where(:id => ids)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,7 @@ class DiaryEntryController < ApplicationController
|
||||||
|
|
||||||
def list
|
def list
|
||||||
if params[:display_name]
|
if params[:display_name]
|
||||||
@this_user = User.active.find_by_display_name(params[:display_name])
|
@this_user = User.active.find_by(:display_name => params[:display_name])
|
||||||
|
|
||||||
if @this_user
|
if @this_user
|
||||||
@title = t "diary_entry.list.user_title", :user => @this_user.display_name
|
@title = t "diary_entry.list.user_title", :user => @this_user.display_name
|
||||||
|
@ -150,7 +150,7 @@ class DiaryEntryController < ApplicationController
|
||||||
|
|
||||||
def rss
|
def rss
|
||||||
if params[:display_name]
|
if params[:display_name]
|
||||||
user = User.active.find_by_display_name(params[:display_name])
|
user = User.active.find_by(:display_name => params[:display_name])
|
||||||
|
|
||||||
if user
|
if user
|
||||||
@entries = user.diary_entries
|
@entries = user.diary_entries
|
||||||
|
|
|
@ -127,7 +127,7 @@ class NotesController < ApplicationController
|
||||||
comment = params[:text]
|
comment = params[:text]
|
||||||
|
|
||||||
# Find the note and check it is valid
|
# Find the note and check it is valid
|
||||||
@note = Note.find_by_id(id)
|
@note = Note.find_by(:id => id)
|
||||||
raise OSM::APINotFoundError unless @note
|
raise OSM::APINotFoundError unless @note
|
||||||
raise OSM::APIAlreadyDeletedError.new("note", @note.id) unless @note.visible?
|
raise OSM::APIAlreadyDeletedError.new("note", @note.id) unless @note.visible?
|
||||||
raise OSM::APINoteAlreadyClosedError.new(@note) if @note.closed?
|
raise OSM::APINoteAlreadyClosedError.new(@note) if @note.closed?
|
||||||
|
@ -157,7 +157,7 @@ class NotesController < ApplicationController
|
||||||
comment = params[:text]
|
comment = params[:text]
|
||||||
|
|
||||||
# Find the note and check it is valid
|
# Find the note and check it is valid
|
||||||
@note = Note.find_by_id(id)
|
@note = Note.find_by(:id => id)
|
||||||
raise OSM::APINotFoundError unless @note
|
raise OSM::APINotFoundError unless @note
|
||||||
raise OSM::APIAlreadyDeletedError.new("note", @note.id) unless @note.visible? || @user.moderator?
|
raise OSM::APIAlreadyDeletedError.new("note", @note.id) unless @note.visible? || @user.moderator?
|
||||||
raise OSM::APINoteAlreadyOpenError.new(@note) unless @note.closed? || !@note.visible?
|
raise OSM::APINoteAlreadyOpenError.new(@note) unless @note.closed? || !@note.visible?
|
||||||
|
@ -277,7 +277,7 @@ class NotesController < ApplicationController
|
||||||
# Display a list of notes by a specified user
|
# Display a list of notes by a specified user
|
||||||
def mine
|
def mine
|
||||||
if params[:display_name]
|
if params[:display_name]
|
||||||
if @this_user = User.active.find_by_display_name(params[:display_name])
|
if @this_user = User.active.find_by(:display_name => params[:display_name])
|
||||||
@title = t "note.mine.title", :user => @this_user.display_name
|
@title = t "note.mine.title", :user => @this_user.display_name
|
||||||
@heading = t "note.mine.heading", :user => @this_user.display_name
|
@heading = t "note.mine.heading", :user => @this_user.display_name
|
||||||
@description = t "note.mine.subheading", :user => render_to_string(:partial => "user", :object => @this_user)
|
@description = t "note.mine.subheading", :user => render_to_string(:partial => "user", :object => @this_user)
|
||||||
|
|
|
@ -27,7 +27,7 @@ class OauthController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def revoke
|
def revoke
|
||||||
@token = current_user.oauth_tokens.find_by_token params[:token]
|
@token = current_user.oauth_tokens.find_by :token => params[:token]
|
||||||
if @token
|
if @token
|
||||||
@token.invalidate!
|
@token.invalidate!
|
||||||
flash[:notice] = t("oauth.revoke.flash", :application => @token.client_application.name)
|
flash[:notice] = t("oauth.revoke.flash", :application => @token.client_application.name)
|
||||||
|
|
|
@ -161,10 +161,10 @@ class SwfController < ApplicationController
|
||||||
def swf_record(id, r)
|
def swf_record(id, r)
|
||||||
if r.length > 62
|
if r.length > 62
|
||||||
# Long header: tag id, 0x3F, length
|
# Long header: tag id, 0x3F, length
|
||||||
return pack_u16((id << 6) + 0x3F) + pack_u32(r.length) + r
|
pack_u16((id << 6) + 0x3F) + pack_u32(r.length) + r
|
||||||
else
|
else
|
||||||
# Short header: tag id, length
|
# Short header: tag id, length
|
||||||
return pack_u16((id << 6) + r.length) + r
|
pack_u16((id << 6) + r.length) + r
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -149,7 +149,7 @@ class UserController < ApplicationController
|
||||||
@title = t "user.lost_password.title"
|
@title = t "user.lost_password.title"
|
||||||
|
|
||||||
if params[:user] && params[:user][:email]
|
if params[:user] && params[:user][:email]
|
||||||
user = User.visible.find_by_email(params[:user][:email])
|
user = User.visible.find_by(:email => params[:user][:email])
|
||||||
|
|
||||||
if user.nil?
|
if user.nil?
|
||||||
users = User.visible.where("LOWER(email) = LOWER(?)", params[:user][:email])
|
users = User.visible.where("LOWER(email) = LOWER(?)", params[:user][:email])
|
||||||
|
@ -172,7 +172,7 @@ class UserController < ApplicationController
|
||||||
@title = t "user.reset_password.title"
|
@title = t "user.reset_password.title"
|
||||||
|
|
||||||
if params[:token]
|
if params[:token]
|
||||||
token = UserToken.find_by_token(params[:token])
|
token = UserToken.find_by(:token => params[:token])
|
||||||
|
|
||||||
if token
|
if token
|
||||||
@user = token.user
|
@user = token.user
|
||||||
|
@ -270,7 +270,7 @@ class UserController < ApplicationController
|
||||||
|
|
||||||
if params[:session] == request.session_options[:id]
|
if params[:session] == request.session_options[:id]
|
||||||
if session[:token]
|
if session[:token]
|
||||||
token = UserToken.find_by_token(session[:token])
|
token = UserToken.find_by(:token => session[:token])
|
||||||
token.destroy if token
|
token.destroy if token
|
||||||
session.delete(:token)
|
session.delete(:token)
|
||||||
end
|
end
|
||||||
|
@ -286,7 +286,7 @@ class UserController < ApplicationController
|
||||||
|
|
||||||
def confirm
|
def confirm
|
||||||
if request.post?
|
if request.post?
|
||||||
token = UserToken.find_by_token(params[:confirm_string])
|
token = UserToken.find_by(:token => params[:confirm_string])
|
||||||
if token && token.user.active?
|
if token && token.user.active?
|
||||||
flash[:error] = t("user.confirm.already active")
|
flash[:error] = t("user.confirm.already active")
|
||||||
redirect_to :action => "login"
|
redirect_to :action => "login"
|
||||||
|
@ -303,7 +303,7 @@ class UserController < ApplicationController
|
||||||
token.destroy
|
token.destroy
|
||||||
|
|
||||||
if session[:token]
|
if session[:token]
|
||||||
token = UserToken.find_by_token(session[:token])
|
token = UserToken.find_by(:token => session[:token])
|
||||||
session.delete(:token)
|
session.delete(:token)
|
||||||
else
|
else
|
||||||
token = nil
|
token = nil
|
||||||
|
@ -321,15 +321,15 @@ class UserController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
user = User.find_by_display_name(params[:display_name])
|
user = User.find_by(:display_name => params[:display_name])
|
||||||
|
|
||||||
redirect_to root_path if user.nil? || user.active?
|
redirect_to root_path if user.nil? || user.active?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def confirm_resend
|
def confirm_resend
|
||||||
user = User.find_by_display_name(params[:display_name])
|
user = User.find_by(:display_name => params[:display_name])
|
||||||
token = UserToken.find_by_token(session[:token])
|
token = UserToken.find_by(:token => session[:token])
|
||||||
|
|
||||||
if user.nil? || token.nil? || token.user != user
|
if user.nil? || token.nil? || token.user != user
|
||||||
flash[:error] = t "user.confirm_resend.failure", :name => params[:display_name]
|
flash[:error] = t "user.confirm_resend.failure", :name => params[:display_name]
|
||||||
|
@ -343,7 +343,7 @@ class UserController < ApplicationController
|
||||||
|
|
||||||
def confirm_email
|
def confirm_email
|
||||||
if request.post?
|
if request.post?
|
||||||
token = UserToken.find_by_token(params[:confirm_string])
|
token = UserToken.find_by(:token => params[:confirm_string])
|
||||||
if token && token.user.new_email?
|
if token && token.user.new_email?
|
||||||
@user = token.user
|
@user = token.user
|
||||||
@user.email = @user.new_email
|
@user.email = @user.new_email
|
||||||
|
@ -393,7 +393,7 @@ class UserController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def view
|
def view
|
||||||
@this_user = User.find_by_display_name(params[:display_name])
|
@this_user = User.find_by(:display_name => params[:display_name])
|
||||||
|
|
||||||
if @this_user &&
|
if @this_user &&
|
||||||
(@this_user.visible? || (@user && @user.administrator?))
|
(@this_user.visible? || (@user && @user.administrator?))
|
||||||
|
@ -404,7 +404,7 @@ class UserController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def make_friend
|
def make_friend
|
||||||
@new_friend = User.find_by_display_name(params[:display_name])
|
@new_friend = User.find_by(:display_name => params[:display_name])
|
||||||
|
|
||||||
if @new_friend
|
if @new_friend
|
||||||
if request.post?
|
if request.post?
|
||||||
|
@ -432,7 +432,7 @@ class UserController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def remove_friend
|
def remove_friend
|
||||||
@friend = User.find_by_display_name(params[:display_name])
|
@friend = User.find_by(:display_name => params[:display_name])
|
||||||
|
|
||||||
if @friend
|
if @friend
|
||||||
if request.post?
|
if request.post?
|
||||||
|
@ -530,11 +530,11 @@ class UserController < ApplicationController
|
||||||
|
|
||||||
redirect_to :action => "terms"
|
redirect_to :action => "terms"
|
||||||
else
|
else
|
||||||
user = User.find_by_auth_provider_and_auth_uid(provider, uid)
|
user = User.find_by(:auth_provider => provider, :auth_uid => uid)
|
||||||
|
|
||||||
if user.nil? && provider == "google"
|
if user.nil? && provider == "google"
|
||||||
openid_url = auth_info[:extra][:id_info]["openid_id"]
|
openid_url = auth_info[:extra][:id_info]["openid_id"]
|
||||||
user = User.find_by_auth_provider_and_auth_uid("openid", openid_url) if openid_url
|
user = User.find_by(:auth_provider => "openid", :auth_uid => openid_url) if openid_url
|
||||||
user.update(:auth_provider => provider, :auth_uid => uid) if user
|
user.update(:auth_provider => provider, :auth_uid => uid) if user
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -601,15 +601,15 @@ class UserController < ApplicationController
|
||||||
# try and come up with the correct URL based on what the user entered
|
# try and come up with the correct URL based on what the user entered
|
||||||
def openid_expand_url(openid_url)
|
def openid_expand_url(openid_url)
|
||||||
if openid_url.nil?
|
if openid_url.nil?
|
||||||
return nil
|
nil
|
||||||
elsif openid_url.match(%r{(.*)gmail.com(/?)$}) || openid_url.match(%r{(.*)googlemail.com(/?)$})
|
elsif openid_url.match(%r{(.*)gmail.com(/?)$}) || openid_url.match(%r{(.*)googlemail.com(/?)$})
|
||||||
# Special case gmail.com as it is potentially a popular OpenID
|
# Special case gmail.com as it is potentially a popular OpenID
|
||||||
# provider and, unlike yahoo.com, where it works automatically, Google
|
# provider and, unlike yahoo.com, where it works automatically, Google
|
||||||
# have hidden their OpenID endpoint somewhere obscure this making it
|
# have hidden their OpenID endpoint somewhere obscure this making it
|
||||||
# somewhat less user friendly.
|
# somewhat less user friendly.
|
||||||
return "https://www.google.com/accounts/o8/id"
|
"https://www.google.com/accounts/o8/id"
|
||||||
else
|
else
|
||||||
return openid_url
|
openid_url
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -766,7 +766,7 @@ class UserController < ApplicationController
|
||||||
##
|
##
|
||||||
# ensure that there is a "this_user" instance variable
|
# ensure that there is a "this_user" instance variable
|
||||||
def lookup_user_by_name
|
def lookup_user_by_name
|
||||||
@this_user = User.find_by_display_name(params[:display_name])
|
@this_user = User.find_by(:display_name => params[:display_name])
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
redirect_to :action => "view", :display_name => params[:display_name] unless @this_user
|
redirect_to :action => "view", :display_name => params[:display_name] unless @this_user
|
||||||
end
|
end
|
||||||
|
@ -823,9 +823,9 @@ class UserController < ApplicationController
|
||||||
# display a message about th current status of the gravatar setting
|
# display a message about th current status of the gravatar setting
|
||||||
def gravatar_status_message(user)
|
def gravatar_status_message(user)
|
||||||
if user.image_use_gravatar
|
if user.image_use_gravatar
|
||||||
return t "user.account.gravatar.enabled"
|
t "user.account.gravatar.enabled"
|
||||||
else
|
else
|
||||||
return t "user.account.gravatar.disabled"
|
t "user.account.gravatar.disabled"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
module TraceHelper
|
module TraceHelper
|
||||||
def link_to_tag(tag)
|
def link_to_tag(tag)
|
||||||
if @action == "mine"
|
if @action == "mine"
|
||||||
return link_to(tag, :tag => tag, :page => nil)
|
link_to(tag, :tag => tag, :page => nil)
|
||||||
else
|
else
|
||||||
return link_to(tag, :tag => tag, :display_name => @display_name, :page => nil)
|
link_to(tag, :tag => tag, :display_name => @display_name, :page => nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -18,7 +18,7 @@ class ClientApplication < ActiveRecord::Base
|
||||||
attr_accessor :token_callback_url
|
attr_accessor :token_callback_url
|
||||||
|
|
||||||
def self.find_token(token_key)
|
def self.find_token(token_key)
|
||||||
token = OauthToken.find_by_token(token_key, :include => :client_application)
|
token = OauthToken.includes(:client_application).find_by(:token => token_key)
|
||||||
token if token && token.authorized?
|
token if token && token.authorized?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ class User < ActiveRecord::Base
|
||||||
user = nil
|
user = nil
|
||||||
end
|
end
|
||||||
elsif options[:token]
|
elsif options[:token]
|
||||||
token = UserToken.find_by_token(options[:token])
|
token = UserToken.find_by(:token => options[:token])
|
||||||
user = token.user if token
|
user = token.user if token
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -240,7 +240,7 @@ class User < ActiveRecord::Base
|
||||||
##
|
##
|
||||||
# return an oauth access token for a specified application
|
# return an oauth access token for a specified application
|
||||||
def access_token(application_key)
|
def access_token(application_key)
|
||||||
ClientApplication.find_by_key(application_key).access_token_for_user(self)
|
ClientApplication.find_by(:key => application_key).access_token_for_user(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -47,16 +47,15 @@ module Potlatch
|
||||||
# Parse and get value
|
# Parse and get value
|
||||||
def self.getvalue(s)
|
def self.getvalue(s)
|
||||||
case s.getbyte
|
case s.getbyte
|
||||||
when 0 then return getdouble(s) # number
|
when 0 then getdouble(s) # number
|
||||||
when 1 then return s.getbyte # boolean
|
when 1 then s.getbyte # boolean
|
||||||
when 2 then return getstring(s) # string
|
when 2 then getstring(s) # string
|
||||||
when 3 then return getobject(s) # object/hash
|
when 3 then getobject(s) # object/hash
|
||||||
when 5 then return nil # null
|
when 5 then nil # null
|
||||||
when 6 then return nil # undefined
|
when 6 then nil # undefined
|
||||||
when 8 then s.read(4) # mixedArray
|
when 8 then s.read(4) # mixedArray
|
||||||
return getobject(s) # |
|
getobject(s) # |
|
||||||
when 10 then return getarray(s) # array
|
when 10 then getarray(s) # array
|
||||||
else return nil # error
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,7 @@ class OauthClientsControllerTest < ActionController::TestCase
|
||||||
}, { :user => user }
|
}, { :user => user }
|
||||||
end
|
end
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_redirected_to oauth_client_path(:id => ClientApplication.find_by_name("Test Application").id)
|
assert_redirected_to oauth_client_path(:id => ClientApplication.find_by(:name => "Test Application").id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show
|
def test_show
|
||||||
|
|
|
@ -73,7 +73,7 @@ class RedactionsControllerTest < ActionController::TestCase
|
||||||
|
|
||||||
post :create, :redaction => { :title => "Foo", :description => "Description here." }
|
post :create, :redaction => { :title => "Foo", :description => "Description here." }
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_redirected_to(redaction_path(Redaction.find_by_title("Foo")))
|
assert_redirected_to(redaction_path(Redaction.find_by(:title => "Foo")))
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_create_moderator_invalid
|
def test_create_moderator_invalid
|
||||||
|
|
|
@ -94,7 +94,7 @@ class OAuthTest < ActionDispatch::IntegrationTest
|
||||||
|
|
||||||
post "/oauth/revoke", :token => token.token
|
post "/oauth/revoke", :token => token.token
|
||||||
assert_redirected_to oauth_clients_url(token.user.display_name)
|
assert_redirected_to oauth_clients_url(token.user.display_name)
|
||||||
token = OauthToken.find_by_token(token.token)
|
token = OauthToken.find_by(:token => token.token)
|
||||||
assert_not_nil token.invalidated_at
|
assert_not_nil token.invalidated_at
|
||||||
|
|
||||||
signed_get "/api/0.6/user/preferences", :consumer => client, :token => token
|
signed_get "/api/0.6/user/preferences", :consumer => client, :token => token
|
||||||
|
@ -172,7 +172,7 @@ class OAuthTest < ActionDispatch::IntegrationTest
|
||||||
|
|
||||||
post "/oauth/revoke", :token => token.token
|
post "/oauth/revoke", :token => token.token
|
||||||
assert_redirected_to oauth_clients_url(token.user.display_name)
|
assert_redirected_to oauth_clients_url(token.user.display_name)
|
||||||
token = OauthToken.find_by_token(token.token)
|
token = OauthToken.find_by(:token => token.token)
|
||||||
assert_not_nil token.invalidated_at
|
assert_not_nil token.invalidated_at
|
||||||
|
|
||||||
signed_get "/api/0.6/gpx/2", :consumer => client, :token => token
|
signed_get "/api/0.6/gpx/2", :consumer => client, :token => token
|
||||||
|
@ -231,7 +231,7 @@ class OAuthTest < ActionDispatch::IntegrationTest
|
||||||
|
|
||||||
post "/oauth/revoke", :token => token.token
|
post "/oauth/revoke", :token => token.token
|
||||||
assert_redirected_to oauth_clients_url(token.user.display_name)
|
assert_redirected_to oauth_clients_url(token.user.display_name)
|
||||||
token = OauthToken.find_by_token(token.token)
|
token = OauthToken.find_by(:token => token.token)
|
||||||
assert_not_nil token.invalidated_at
|
assert_not_nil token.invalidated_at
|
||||||
|
|
||||||
signed_get "/api/0.6/user/preferences", :consumer => client, :token => token
|
signed_get "/api/0.6/user/preferences", :consumer => client, :token => token
|
||||||
|
@ -282,7 +282,7 @@ class OAuthTest < ActionDispatch::IntegrationTest
|
||||||
|
|
||||||
post "/oauth/revoke", :token => token.token
|
post "/oauth/revoke", :token => token.token
|
||||||
assert_redirected_to oauth_clients_url(token.user.display_name)
|
assert_redirected_to oauth_clients_url(token.user.display_name)
|
||||||
token = OauthToken.find_by_token(token.token)
|
token = OauthToken.find_by(:token => token.token)
|
||||||
assert_not_nil token.invalidated_at
|
assert_not_nil token.invalidated_at
|
||||||
|
|
||||||
signed_get "/api/0.6/gpx/2", :consumer => client, :token => token
|
signed_get "/api/0.6/gpx/2", :consumer => client, :token => token
|
||||||
|
@ -356,7 +356,7 @@ class OAuthTest < ActionDispatch::IntegrationTest
|
||||||
def parse_token(response)
|
def parse_token(response)
|
||||||
params = CGI.parse(response.body)
|
params = CGI.parse(response.body)
|
||||||
|
|
||||||
token = OauthToken.find_by_token(params["oauth_token"].first)
|
token = OauthToken.find_by(:token => params["oauth_token"].first)
|
||||||
assert_equal token.secret, params["oauth_token_secret"].first
|
assert_equal token.secret, params["oauth_token_secret"].first
|
||||||
|
|
||||||
token
|
token
|
||||||
|
|
|
@ -555,7 +555,7 @@ class UserLoginTest < ActionDispatch::IntegrationTest
|
||||||
assert_template "changeset/history"
|
assert_template "changeset/history"
|
||||||
assert_select "span.username", "openIDuser"
|
assert_select "span.username", "openIDuser"
|
||||||
|
|
||||||
user = User.find_by_display_name("openIDuser")
|
user = User.find_by(:display_name => "openIDuser")
|
||||||
assert_equal "google", user.auth_provider
|
assert_equal "google", user.auth_provider
|
||||||
assert_equal "987654321", user.auth_uid
|
assert_equal "987654321", user.auth_uid
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue