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:
Ian Christian Myers 2013-06-05 00:04:03 -07:00
parent 130d837952
commit 3b245031a4
3 changed files with 3 additions and 2 deletions

View file

@ -29,7 +29,7 @@ class InvitesController < ApplicationController
end
def destroy
requires_parameter(:email)
params.require(:email)
invite = Invite.where(invited_by_id: current_user.id, email: params[:email]).first
raise Discourse::InvalidParameters.new(:email) if invite.blank?

View file

@ -1,6 +1,7 @@
require_dependency 'trashable'
class Invite < ActiveRecord::Base
include ActiveModel::ForbiddenAttributesProtection
include Trashable
belongs_to :user

View file

@ -17,7 +17,7 @@ describe InvitesController 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
it "raises an error when the email cannot be found" do