diff options
author | Shuhei Kitagawa <shuheiktgw@users.noreply.github.com> | 2018-05-11 20:14:33 +0900 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2018-05-11 13:14:33 +0200 |
commit | 50491e0d92acea90e7a83d2ab0e9a1b271daa8a8 (patch) | |
tree | b1f3e9ef27fea9bfbcfb0cba5d7867975f514964 /app/controllers | |
parent | 1337ca837b8de992945413a7f4f4b0aecd89dc9c (diff) |
Add tests for invites controller (#7441)
* Add tests for invites controller * Small refactoring and fix for invites controller
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/invites_controller.rb | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/app/controllers/invites_controller.rb b/app/controllers/invites_controller.rb index 38d6c8d73..8e87c63cf 100644 --- a/app/controllers/invites_controller.rb +++ b/app/controllers/invites_controller.rb @@ -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 |