Add tests for invites controller (#7441)
* Add tests for invites controller * Small refactoring and fix for invites controller
This commit is contained in:
committed by
Eugen Rochko
parent
1337ca837b
commit
50491e0d92
@ -8,9 +8,9 @@ class InvitesController < ApplicationController
|
||||
before_action :authenticate_user!
|
||||
|
||||
def index
|
||||
authorize :invite, :create?
|
||||
authorize :invite, :index?
|
||||
|
||||
@invites = Invite.where(user: current_user)
|
||||
@invites = invites
|
||||
@invite = Invite.new(expires_in: 1.day.to_i)
|
||||
end
|
||||
|
||||
@ -23,13 +23,13 @@ class InvitesController < ApplicationController
|
||||
if @invite.save
|
||||
redirect_to invites_path
|
||||
else
|
||||
@invites = Invite.where(user: current_user)
|
||||
@invites = invites
|
||||
render :index
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@invite = Invite.where(user: current_user).find(params[:id])
|
||||
@invite = invites.find(params[:id])
|
||||
authorize @invite, :destroy?
|
||||
@invite.expire!
|
||||
redirect_to invites_path
|
||||
@ -37,6 +37,10 @@ class InvitesController < ApplicationController
|
||||
|
||||
private
|
||||
|
||||
def invites
|
||||
Invite.where(user: current_user)
|
||||
end
|
||||
|
||||
def resource_params
|
||||
params.require(:invite).permit(:max_uses, :expires_in)
|
||||
end
|
||||
|
Reference in New Issue
Block a user