From 6b778c27ee38091990533c1df6655cc39948b3ee Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sat, 12 Mar 2016 17:23:51 +0100 Subject: [PATCH] Fixed not recognised overview sort by prio. Ignore auto generated link on create if already present. --- app/models/overview.rb | 24 +++++++++++++++---- app/models/ticket/overviews.rb | 6 ++--- .../agent_ticket_overview_level0_test.rb | 16 ++++++------- 3 files changed, 30 insertions(+), 16 deletions(-) diff --git a/app/models/overview.rb b/app/models/overview.rb index 13b0bf27d..35bbe97db 100644 --- a/app/models/overview.rb +++ b/app/models/overview.rb @@ -7,22 +7,36 @@ class Overview < ApplicationModel validates :name, presence: true validates :prio, presence: true - before_create :fill_link - before_update :fill_link + before_create :fill_link_on_create, :fill_prio + before_update :fill_link_on_update notify_clients_support latest_change_support private - # fill link - def fill_link + def fill_prio + return true if prio + prio = 9999 + end + + def fill_link_on_create + return true if !link.empty? + self.link = link_name(name) + end + + def fill_link_on_update return true if link.empty? return true if !changes['name'] - self.link = name.downcase + self.link = link_name(name) + end + + def link_name(name) + link = name.downcase link.gsub!(/\s/, '_') link.gsub!(/[^0-9a-z]/i, '_') link.gsub!(/_+/, '_') + link end end diff --git a/app/models/ticket/overviews.rb b/app/models/ticket/overviews.rb index aa82c2918..e45d187d7 100644 --- a/app/models/ticket/overviews.rb +++ b/app/models/ticket/overviews.rb @@ -21,9 +21,9 @@ returns if data[:current_user].role?('Customer') role = Role.find_by(name: 'Customer') overviews = if data[:current_user].organization_id && data[:current_user].organization.shared - Overview.where(role_id: role.id, active: true) + Overview.where(role_id: role.id, active: true).order(:prio) else - Overview.where(role_id: role.id, organization_shared: false, active: true) + Overview.where(role_id: role.id, organization_shared: false, active: true).order(:prio) end return overviews end @@ -31,7 +31,7 @@ returns # get agent overviews return if !data[:current_user].role?('Agent') role = Role.find_by(name: 'Agent') - Overview.where(role_id: role.id, active: true) + Overview.where(role_id: role.id, active: true).order(:prio) end =begin diff --git a/test/browser/agent_ticket_overview_level0_test.rb b/test/browser/agent_ticket_overview_level0_test.rb index a412e5538..1576544fe 100644 --- a/test/browser/agent_ticket_overview_level0_test.rb +++ b/test/browser/agent_ticket_overview_level0_test.rb @@ -30,14 +30,14 @@ class AgentTicketOverviewLevel0Test < TestCase body: 'overview count test #2', } ) - click( text: 'Overviews' ) + click(text: 'Overviews') # enable full overviews execute( js: '$(".content.active .sidebar").css("display", "block")', ) - click( text: 'Unassigned & Open' ) + click(text: 'Unassigned & Open') sleep 8 # till overview is rendered # select both via bulk action @@ -87,7 +87,7 @@ class AgentTicketOverviewLevel0Test < TestCase overview_counter_before = overview_counter() # click options and enable number and article count - click( css: '.active [data-type="settings"]' ) + click(css: '.active [data-type="settings"]') watch_for( css: '.modal h1', @@ -111,7 +111,7 @@ class AgentTicketOverviewLevel0Test < TestCase check( css: '.modal input[value="article_count"]', ) - click( css: '.modal .js-submit' ) + click(css: '.modal .js-submit') sleep 4 # check if number and article count is shown @@ -147,7 +147,7 @@ class AgentTicketOverviewLevel0Test < TestCase ) # disable number and article count - click( css: '.active [data-type="settings"]' ) + click(css: '.active [data-type="settings"]') watch_for( css: '.modal h1', @@ -159,7 +159,7 @@ class AgentTicketOverviewLevel0Test < TestCase uncheck( css: '.modal input[value="article_count"]', ) - click( css: '.modal .js-submit' ) + click(css: '.modal .js-submit') sleep 2 # check if number and article count is gone @@ -188,7 +188,7 @@ class AgentTicketOverviewLevel0Test < TestCase # get new overview count overview_counter_new = overview_counter() - assert_equal( overview_counter_before['#ticket/view/all_unassigned'] + 1, overview_counter_new['#ticket/view/all_unassigned'] ) + assert_equal(overview_counter_before['#ticket/view/all_unassigned'] + 1, overview_counter_new['#ticket/view/all_unassigned']) # open ticket by search ticket_open_by_search( @@ -206,7 +206,7 @@ class AgentTicketOverviewLevel0Test < TestCase # get current overview count overview_counter_after = overview_counter() - assert_equal( overview_counter_before['#ticket/view/all_unassigned'], overview_counter_after['#ticket/view/all_unassigned'] ) + assert_equal(overview_counter_before['#ticket/view/all_unassigned'], overview_counter_after['#ticket/view/all_unassigned']) # cleanup tasks_close_all()