Added possibility to set create groups via setting/channels/web. Added browser tests.

This commit is contained in:
Martin Edenhofer 2013-02-21 22:09:36 +01:00
parent 4ad897ce9b
commit a52a74a915
5 changed files with 105 additions and 8 deletions

View file

@ -279,9 +279,9 @@ class Index extends App.Controller
reply: (e) =>
e.preventDefault()
article_id = $(e.target).parents('[data-id]').data('id')
article = App.TicketArticle.find( article_id )
article_type = App.TicketArticleType.find( article.ticket_article_type_id )
customer = App.User.find( article.created_by_id )
article = App.Collection.find( 'TicketArticle', article_id )
article_type = App.Collection.find( 'TicketArticleType', article.ticket_article_type_id )
customer = App.Collection.find( 'User', article.created_by_id )
# update form
@form_update_execute(article_type)
@ -347,7 +347,7 @@ class Index extends App.Controller
e.preventDefault()
params = @formParam(e.target)
@log 'TicketZoom', 'notice', 'update', params, @ticket
article_type = App.TicketArticleType.find( params['ticket_article_type_id'] )
article_type = App.Collection.find( 'TicketArticleType', params['ticket_article_type_id'] )
# update ticket
ticket_update = {}

View file

@ -85,12 +85,25 @@ class Index extends App.Controller
if !( 'ticket_priority_id' of defaults )
defaults['ticket_priority_id'] = App.Collection.findByAttribute( 'TicketPriority', 'name', '2 normal' )
groupFilter = (collection) =>
groupFilter = (collection, type) =>
# only filter on collections
return collection if type isnt 'collection'
# get configured ids
group_ids = App.Config.get('customer_ticket_create_group_ids')
# return all groups if no one is selected
if !_.isArray( group_ids )
group_ids = [group_ids]
# filter selected groups
if _.isEmpty( group_ids )
return collection
_.filter(
collection
(item) ->
return item if item.name is 'Support'
return item if item.name is 'Sales'
return item if item && _.contains( group_ids, item.id.toString() )
)
# generate form

View file

@ -779,6 +779,30 @@ Setting.create_if_not_exists(
:frontend => true
)
Setting.create_if_not_exists(
:title => 'Group selection for Ticket creation',
:name => 'customer_ticket_create_group_ids',
:area => 'CustomerWeb::Base',
:description => 'Defines groups where customer can create tickets via web interface. "-" means all groups are available.',
:options => {
:form => [
{
:display => '',
:null => true,
:name => 'group_ids',
:tag => 'select',
:multiple => true,
:null => false,
:nulloption => true,
:relation => 'Group',
},
],
},
:state => '',
:frontend => true
)
Setting.create_if_not_exists(
:title => 'Enable Ticket View/Update',
:name => 'customer_ticket_view',

View file

@ -22,6 +22,16 @@ class TicketCreate < ActiveSupport::TestCase
:id => 'form_create',
:result => true,
},
{
:execute => 'wait',
:value => 2,
},
{
:execute => 'select',
:element => :select_list,
:name => 'group_id',
:value => 'Users',
},
{
:execute => 'set',
:element => :text_field,
@ -41,7 +51,7 @@ class TicketCreate < ActiveSupport::TestCase
},
{
:execute => 'wait',
:value => 3,
:value => 5,
},
{
:execute => 'check',
@ -54,6 +64,44 @@ class TicketCreate < ActiveSupport::TestCase
:element => :url,
:result => '#ticket/zoom/',
},
# check ticket
{
:execute => 'match',
:element => :div,
:class => 'article',
:value => 'some body 123äöü',
:match_result => true,
},
# update ticket
{
:execute => 'check',
:element => :text_field,
:name => 'body',
:result => true,
},
{
:execute => 'set',
:element => :text_field,
:name => 'body',
:value => 'some body 1234 äöüß',
},
{
:execute => 'click',
:element => :button,
:type => 'submit',
},
{
:execute => 'wait',
:value => 5,
},
{
:execute => 'match',
:element => :body,
:value => 'some body 1234 äöüß',
:match_result => true,
},
],
},
]

View file

@ -138,6 +138,14 @@ class ActiveSupport::TestCase
element = instance.send( action[:element], { :type => action[:type] } )
assert( element.exists?, "(#{test[:name]}) Element #{action[:element]} with type #{action[:type]} doesn't exist" )
end
elsif action[:class]
if action[:result] == false
element = instance.send( action[:element], { :class => action[:class] } )
assert( !element.exists?, "(#{test[:name]}) Element #{action[:element]} with class #{action[:class]} exists" )
else
element = instance.send( action[:element], { :class => action[:class] } )
assert( element.exists?, "(#{test[:name]}) Element #{action[:element]} with class #{action[:class]} doesn't exist" )
end
elsif action[:name]
if action[:result] == false
element = instance.send( action[:element], { :name => action[:name] } )
@ -160,11 +168,15 @@ class ActiveSupport::TestCase
else
assert( false, "(#{test[:name]}) url #{instance.url} is not matching #{action[:result]}" )
end
elsif action[:element] == :body
element = instance.send( action[:element] )
else
assert( false, "(#{test[:name]}) unknow selector for '#{action[:element]}'" )
end
if action[:execute] == 'set'
element.set( action[:value] )
elsif action[:execute] == 'select'
element.select( action[:value] )
elsif action[:execute] == 'click'
element.click
elsif action[:execute] == 'send_key'