Adds customer_ticket_create requirement to enable form

This commit is contained in:
Rolando 2017-09-23 18:38:16 +02:00 committed by Jose Torres
parent 1f83f3b358
commit ba2d22e8a4
2 changed files with 26 additions and 1 deletions

View file

@ -241,7 +241,7 @@ class FormController < ApplicationController
def enabled? def enabled?
return true if params[:test] && current_user && current_user.permissions?('admin.channel_formular') return true if params[:test] && current_user && current_user.permissions?('admin.channel_formular')
return true if Setting.get('form_ticket_create') return true if Setting.get('form_ticket_create') && Setting.get('customer_ticket_create')
response_access_deny response_access_deny
false false
end end

View file

@ -244,4 +244,29 @@ class FormControllerTest < ActionDispatch::IntegrationTest
assert(result['error']) assert(result['error'])
end end
test '06 - customer_ticket_create false disables form' do
Setting.set('form_ticket_create', true)
Setting.set('customer_ticket_create', false)
fingerprint = SecureRandom.hex(40)
post '/api/v1/form_config', params: { fingerprint: fingerprint }.to_json, headers: @headers
result = JSON.parse(@response.body)
token = result['token']
params = {
fingerprint: fingerprint,
token: token,
name: 'Bob Smith',
email: 'discard@znuny.com',
title: 'test',
body: 'hello'
}
post '/api/v1/form_submit', params: params.to_json, headers: @headers
assert_response(401)
end
end end