From 10e059214019d86fc890d98a5ae3051bc836b643 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sun, 22 May 2016 11:37:44 +0200 Subject: [PATCH] Added oder of article, sometimes on postgresql it's different. --- app/controllers/tickets_controller.rb | 31 +++++++++---------- .../agent_ticket_actions_level6_test.rb | 24 +++++--------- 2 files changed, 22 insertions(+), 33 deletions(-) diff --git a/app/controllers/tickets_controller.rb b/app/controllers/tickets_controller.rb index 2a36a292d..8a5e3a9cd 100644 --- a/app/controllers/tickets_controller.rb +++ b/app/controllers/tickets_controller.rb @@ -44,7 +44,7 @@ class TicketsController < ApplicationController # create article if given if params[:article] - article_create( ticket, params[:article] ) + article_create(ticket, params[:article]) end render json: ticket, status: :created @@ -57,10 +57,10 @@ class TicketsController < ApplicationController # permission check return if !ticket_permission(ticket) - if ticket.update_attributes( Ticket.param_validation( params[:ticket] ) ) + if ticket.update_attributes(Ticket.param_validation(params[:ticket])) if params[:article] - article_create( ticket, params[:article] ) + article_create(ticket, params[:article]) end render json: ticket, status: :ok @@ -71,7 +71,7 @@ class TicketsController < ApplicationController # DELETE /api/v1/tickets/1 def destroy - ticket = Ticket.find( params[:id] ) + ticket = Ticket.find(params[:id]) # permission check return if !ticket_permission(ticket) @@ -97,10 +97,10 @@ class TicketsController < ApplicationController def ticket_history # get ticket data - ticket = Ticket.find( params[:id] ) + ticket = Ticket.find(params[:id]) # permission check - return if !ticket_permission( ticket ) + return if !ticket_permission(ticket) # get history of ticket history = ticket.history_get(true) @@ -112,15 +112,14 @@ class TicketsController < ApplicationController # GET /api/v1/ticket_related/1 def ticket_related - ticket = Ticket.find( params[:ticket_id] ) + ticket = Ticket.find(params[:ticket_id]) assets = ticket.assets({}) # open tickets by customer - group_ids = Group.select( 'groups.id' ) + group_ids = Group.select('groups.id') .joins(:users) - .where( 'groups_users.user_id = ?', current_user.id ) - .where( 'groups.active = ?', true ) - .map( &:id ) + .where('groups_users.user_id = ?', current_user.id) + .map(&:id) access_condition = [ 'group_id IN (?)', group_ids ] @@ -142,11 +141,11 @@ class TicketsController < ApplicationController } ticket_ids_recent_viewed = [] - recent_views = RecentView.list( current_user, 8, 'Ticket' ) + recent_views = RecentView.list(current_user, 8, 'Ticket') recent_views.each {|recent_view| next if recent_view['object'] != 'Ticket' ticket_ids_recent_viewed.push recent_view['o_id'] - recent_view_ticket = Ticket.find( recent_view['o_id'] ) + recent_view_ticket = Ticket.find(recent_view['o_id']) assets = recent_view_ticket.assets(assets) } @@ -185,7 +184,7 @@ class TicketsController < ApplicationController end # permission check - return if !ticket_permission( ticket_slave ) + return if !ticket_permission(ticket_slave) # check diffetent ticket ids if ticket_slave.id == ticket_master.id @@ -214,7 +213,7 @@ class TicketsController < ApplicationController def ticket_full # permission check - ticket = Ticket.find( params[:id] ) + ticket = Ticket.find(params[:id]) return if !ticket_permission(ticket) # get attributes to update @@ -225,7 +224,7 @@ class TicketsController < ApplicationController assets = ticket.assets(assets) # get related articles - articles = Ticket::Article.where(ticket_id: params[:id]) + articles = Ticket::Article.where(ticket_id: params[:id]).order('created_at ASC, id ASC') # get related users article_ids = [] diff --git a/test/browser/agent_ticket_actions_level6_test.rb b/test/browser/agent_ticket_actions_level6_test.rb index 311c3763d..462928de7 100644 --- a/test/browser/agent_ticket_actions_level6_test.rb +++ b/test/browser/agent_ticket_actions_level6_test.rb @@ -53,8 +53,8 @@ class AgentTicketActionLevel6Test < TestCase # check if ticket is shown and attachment exists location_check(url: '#ticket/zoom/') - sleep 4 - ticket_number = @browser.find_elements({ css: '.active .ticketZoom-header .ticket-number' } )[0].text + sleep 2 + ticket_number = @browser.find_elements({ css: '.active .ticketZoom-header .ticket-number' })[0].text match( css: '.active .ticket-article-item:nth-child(1) .attachments', value: 'upload2.jpg', @@ -77,9 +77,7 @@ class AgentTicketActionLevel6Test < TestCase ) # submit form - click( - css: '.active .js-submit', - ) + click(css: '.active .js-submit') sleep 2 # check warning @@ -93,9 +91,7 @@ class AgentTicketActionLevel6Test < TestCase ) # submit form - click( - css: '.active .js-submit', - ) + click(css: '.active .js-submit') sleep 2 # no warning @@ -136,9 +132,7 @@ class AgentTicketActionLevel6Test < TestCase ) # submit form - click( - css: '.active .js-submit', - ) + click(css: '.active .js-submit') sleep 2 # check warning @@ -146,9 +140,7 @@ class AgentTicketActionLevel6Test < TestCase css: '.active .modal', value: 'missing', ) - click( - css: '.active .modal .js-cancel', - ) + click(css: '.active .modal .js-cancel') sleep 2 ticket_update( @@ -159,9 +151,7 @@ class AgentTicketActionLevel6Test < TestCase ) # submit form - click( - css: '.active .js-submit', - ) + click(css: '.active .js-submit') sleep 2 # discard changes should gone away