usage of raise corrected

This commit is contained in:
Sam 2015-05-07 11:00:51 +10:00
parent 77cc087b13
commit 8277a586bb
7 changed files with 10 additions and 10 deletions

View File

@ -6,7 +6,7 @@ class Admin::ApiController < Admin::AdminController
def regenerate_key
api_key = ApiKey.find_by(id: params[:id])
raise Discourse::NotFound.new if api_key.blank?
raise Discourse::NotFound if api_key.blank?
api_key.regenerate!(current_user)
render_serialized(api_key, ApiKeySerializer)
@ -14,7 +14,7 @@ class Admin::ApiController < Admin::AdminController
def revoke_key
api_key = ApiKey.find_by(id: params[:id])
raise Discourse::NotFound.new if api_key.blank?
raise Discourse::NotFound if api_key.blank?
api_key.destroy
render nothing: true

View File

@ -5,7 +5,7 @@ class Admin::ReportsController < Admin::AdminController
def show
report_type = params[:type]
raise Discourse::NotFound.new unless report_type =~ /^[a-z0-9\_]+$/
raise Discourse::NotFound unless report_type =~ /^[a-z0-9\_]+$/
start_date = 1.month.ago
start_date = Time.parse(params[:start_date]) if params[:start_date].present?
@ -14,7 +14,7 @@ class Admin::ReportsController < Admin::AdminController
end_date = Time.parse(params[:end_date]) if params[:end_date].present?
report = Report.find(report_type, {start_date: start_date, end_date: end_date})
raise Discourse::NotFound.new if report.blank?
raise Discourse::NotFound if report.blank?
render_json_dump(report: report)
end

View File

@ -38,7 +38,7 @@ class Admin::UsersController < Admin::AdminController
def show
@user = User.find_by(username_lower: params[:id])
raise Discourse::NotFound.new unless @user
raise Discourse::NotFound unless @user
render_serialized(@user, AdminDetailedUserSerializer, root: false)
end

View File

@ -261,7 +261,7 @@ class ApplicationController < ActionController::Base
elsif params[:external_id]
SingleSignOnRecord.find_by(external_id: params[:external_id]).try(:user)
end
raise Discourse::NotFound.new if user.blank?
raise Discourse::NotFound if user.blank?
guardian.ensure_can_see!(user)
user

View File

@ -225,11 +225,11 @@ class ListController < ApplicationController
parent_category_id = nil
if parent_slug_or_id.present?
parent_category_id = Category.query_parent_category(parent_slug_or_id)
raise Discourse::NotFound.new if parent_category_id.blank?
raise Discourse::NotFound if parent_category_id.blank?
end
@category = Category.query_category(slug_or_id, parent_category_id)
raise Discourse::NotFound.new if !@category
raise Discourse::NotFound if !@category
@description_meta = @category.description
guardian.ensure_can_see!(@category)

View File

@ -85,7 +85,7 @@ class UserBadgesController < ApplicationController
else
badge = Badge.find_by(name: params[:badge_name], enabled: true)
end
raise Discourse::NotFound.new if badge.blank?
raise Discourse::NotFound if badge.blank?
badge
end

View File

@ -157,7 +157,7 @@ class UsersController < ApplicationController
redirect_to path("/users/#{current_user.username}/#{params[:path]}")
return
end
raise Discourse::NotFound.new
raise Discourse::NotFound
end
def invited