Fix rubocop warnings

This commit is contained in:
Tom Hughes 2019-12-04 19:25:06 +00:00
parent 743a764f3b
commit 57f5b7840e
24 changed files with 51 additions and 49 deletions

View file

@ -226,14 +226,14 @@ module Api
loaded_lang = "en"
# Load English defaults
en = YAML.safe_load(File.open(Rails.root.join("config", "potlatch", "locales", "en.yml")))["en"]
en = YAML.safe_load(File.open(Rails.root.join("config/potlatch/locales/en.yml")))["en"]
if lang == "en"
return [loaded_lang, en]
[loaded_lang, en]
else
# Use English as a fallback
begin
other = YAML.safe_load(File.open(Rails.root.join("config", "potlatch", "locales", "#{lang}.yml")))[lang]
other = YAML.safe_load(File.open(Rails.root.join("config/potlatch/locales/#{lang}.yml")))[lang]
loaded_lang = lang
rescue StandardError
other = en
@ -241,7 +241,7 @@ module Api
# We have to return a flat list and some of the keys won't be
# translated (probably)
return [loaded_lang, en.merge(other)]
[loaded_lang, en.merge(other)]
end
end
@ -876,7 +876,7 @@ module Api
end
def getlocales
@getlocales ||= Locale.list(Dir.glob(Rails.root.join("config", "potlatch", "locales", "*")).collect { |f| File.basename(f, ".yml") })
@getlocales ||= Locale.list(Dir.glob(Rails.root.join("config/potlatch/locales/*")).collect { |f| File.basename(f, ".yml") })
end
##

View file

@ -12,7 +12,7 @@ class ApiController < ApplicationController
# no auth, the user does not exist or the password was wrong
response.headers["WWW-Authenticate"] = "Basic realm=\"#{realm}\""
render :plain => errormessage, :status => :unauthorized
return false
false
end
end

View file

@ -376,7 +376,7 @@ class UsersController < ApplicationController
@user = User.find_by(:display_name => params[:display_name])
if @user &&
(@user.visible? || (current_user&.administrator?))
(@user.visible? || current_user&.administrator?)
@title = @user.display_name
else
render_unknown_user params[:display_name]

View file

@ -0,0 +1,2 @@
class ApplicationMailer < ActionMailer::Base
end

View file

@ -1,4 +1,4 @@
class Notifier < ActionMailer::Base
class Notifier < ApplicationMailer
include ActionView::Helpers::AssetUrlHelper
self.delivery_job = ActionMailer::MailDeliveryJob
@ -177,7 +177,7 @@ class Notifier < ActionMailer::Base
end
def attach_project_logo
attachments.inline["logo.png"] = File.read(Rails.root.join("app", "assets", "images", "osm_logo_30.png"))
attachments.inline["logo.png"] = File.read(Rails.root.join("app/assets/images/osm_logo_30.png"))
end
def attach_user_avatar(user)
@ -187,9 +187,9 @@ class Notifier < ActionMailer::Base
def user_avatar_file(user)
avatar = user&.avatar
if avatar&.attached?
return avatar.variant(:resize => "50x50>").blob.download
avatar.variant(:resize => "50x50>").blob.download
else
return File.read(Rails.root.join("app", "assets", "images", "avatar_small.png"))
File.read(Rails.root.join("app/assets/images/avatar_small.png"))
end
end