mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
Implemented strong_parameters for Invite/InvitesController.
The email parameter is now required using strong parameters and will throw ActionController::ParameterMissing if it is missing. If the email address is incorrect or invalid, Discourse::InvalidParameters will still be thrown.
This commit is contained in:
parent
130d837952
commit
3b245031a4
3 changed files with 3 additions and 2 deletions
|
@ -29,7 +29,7 @@ class InvitesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
requires_parameter(:email)
|
params.require(:email)
|
||||||
|
|
||||||
invite = Invite.where(invited_by_id: current_user.id, email: params[:email]).first
|
invite = Invite.where(invited_by_id: current_user.id, email: params[:email]).first
|
||||||
raise Discourse::InvalidParameters.new(:email) if invite.blank?
|
raise Discourse::InvalidParameters.new(:email) if invite.blank?
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
require_dependency 'trashable'
|
require_dependency 'trashable'
|
||||||
|
|
||||||
class Invite < ActiveRecord::Base
|
class Invite < ActiveRecord::Base
|
||||||
|
include ActiveModel::ForbiddenAttributesProtection
|
||||||
include Trashable
|
include Trashable
|
||||||
|
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
|
|
|
@ -17,7 +17,7 @@ describe InvitesController do
|
||||||
|
|
||||||
|
|
||||||
it 'raises an error when the email is missing' do
|
it 'raises an error when the email is missing' do
|
||||||
lambda { delete :destroy }.should raise_error(Discourse::InvalidParameters)
|
lambda { delete :destroy }.should raise_error(ActionController::ParameterMissing)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "raises an error when the email cannot be found" do
|
it "raises an error when the email cannot be found" do
|
||||||
|
|
Loading…
Reference in a new issue