summaryrefslogtreecommitdiff
path: root/engines/support
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2014-07-05 12:49:44 +0200
committerAzul <azul@leap.se>2014-07-09 13:26:36 +0200
commitc8fc45c21d72837d5a6bd41ffca18b3ac52a305f (patch)
treea2cd0bb6bf2d17a072e1bc4b2a4b626493b7c95e /engines/support
parent915573311a92df28ba370326542589982aa6febc (diff)
stay on all tickets view when sorting (#5879)
When an admin sorted the tickets view in a different order it would take them to their own tickets list before
Diffstat (limited to 'engines/support')
-rw-r--r--engines/support/app/controllers/tickets_controller.rb24
-rw-r--r--engines/support/test/integration/navigation_test.rb19
2 files changed, 23 insertions, 20 deletions
diff --git a/engines/support/app/controllers/tickets_controller.rb b/engines/support/app/controllers/tickets_controller.rb
index 1ccbd16..602bbd9 100644
--- a/engines/support/app/controllers/tickets_controller.rb
+++ b/engines/support/app/controllers/tickets_controller.rb
@@ -4,10 +4,10 @@ class TicketsController < ApplicationController
respond_to :html, :json
#has_scope :open, :type => boolean
- before_filter :fetch_user
before_filter :require_login, :only => [:index]
before_filter :fetch_ticket, except: [:new, :create, :index]
- before_filter :require_ticket_access, except: [:new, :create]
+ before_filter :require_ticket_access, except: [:new, :create, :index]
+ before_filter :fetch_user
before_filter :set_title
def new
@@ -129,22 +129,14 @@ class TicketsController < ApplicationController
end
def ticket_access?
- admin? or (
- @ticket &&
- @ticket.created_by.blank?
- ) or (
- @ticket &&
- @ticket.created_by == current_user.id
- ) or (
- @ticket.nil? &&
- @user &&
- @user.id == current_user.id
- )
+ admin? or
+ @ticket.created_by.blank? or
+ current_user.id == @ticket.created_by
end
def fetch_user
- if params[:user_id]
- @user = User.find(params[:user_id])
+ if admin?
+ @user = User.find(params[:user_id]) if params[:user_id]
else
@user = current_user
end
@@ -156,7 +148,7 @@ class TicketsController < ApplicationController
def search_options(params)
params.merge(
:admin_status => params[:user_id] ? 'mine' : 'all',
- :user_id => @user.id,
+ :user_id => @user ? @user.id : current_user.id,
:is_admin => admin?
)
end
diff --git a/engines/support/test/integration/navigation_test.rb b/engines/support/test/integration/navigation_test.rb
index eec8c0e..1cf5825 100644
--- a/engines/support/test/integration/navigation_test.rb
+++ b/engines/support/test/integration/navigation_test.rb
@@ -1,9 +1,20 @@
require 'test_helper'
-class NavigationTest < ActionDispatch::IntegrationTest
+class NavigationTest < BrowserIntegrationTest
- # test "the truth" do
- # assert true
- # end
+ #
+ # this is a regression test for #5879
+ #
+ test "admin can navigate all tickets" do
+ login
+ with_config admins: [@user.login] do
+ visit '/'
+ click_on 'Tickets'
+ click_on 'Created at'
+ uri = URI.parse(current_url)
+ assert_equal '/tickets', uri.path
+ assert_equal 'open_status=open&sort_order=created_at_desc', uri.query
+ end
+ end
end