Add tests, show papertrail whodunnit properly on repp api

This commit is contained in:
Karl Erik Õunapuu 2020-11-18 12:35:11 +02:00
parent 7d08e22f6f
commit 38f86225ca
No known key found for this signature in database
GPG key ID: C9DD647298A34764
3 changed files with 28 additions and 3 deletions

View file

@ -4,9 +4,10 @@ module Repp
rescue_from ActiveRecord::RecordNotFound, with: :not_found_error
before_action :authenticate_user
before_action :check_ip_restriction
before_action :set_paper_trail_whodunnit
attr_reader :current_user
before_action :set_paper_trail_whodunnit
rescue_from ActionController::ParameterMissing do |exception|
render json: { code: 2003, message: exception }, status: :bad_request
end
@ -23,6 +24,10 @@ module Repp
private
def set_paper_trail_whodunnit
::PaperTrail.request.whodunnit = current_user
end
def render_success(code: nil, message: nil, data: nil)
@response = { code: code || 1000, message: message || 'Command completed successfully',
data: data || {} }