diff options
author | Azul <azul@leap.se> | 2012-11-27 17:45:07 +0100 |
---|---|---|
committer | Azul <azul@leap.se> | 2012-11-27 17:45:07 +0100 |
commit | 5e3b32495fdb359a43f2519646905393ec10a598 (patch) | |
tree | d564fba6491d49163ada428487c93bbb85d2fe38 /help/app/models | |
parent | a4fd38b7cce5fbc5ccdab670f31ab5f74c2bdf03 (diff) |
fixed some small issues and the tests except one
The one remaining is failing because we still build an Array for the admin tickets.
Needs to be implemented so I am leaving that test as is.
Diffstat (limited to 'help/app/models')
-rw-r--r-- | help/app/models/ticket.rb | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/help/app/models/ticket.rb b/help/app/models/ticket.rb index 81cd08e..1ed2ed4 100644 --- a/help/app/models/ticket.rb +++ b/help/app/models/ticket.rb @@ -93,7 +93,7 @@ class Ticket < CouchRest::Model::Base # self.created_by = User.current if User.current #end - def self.for_user(user, options) + def self.for_user(user, options = {}) if options[:open_status] == 'open' Ticket.by_is_open_and_created_by.key([true, user.id]) elsif options[:open_status] == 'closed' @@ -106,9 +106,9 @@ class Ticket < CouchRest::Model::Base # @tickets = @tickets.sort{|x,y| x.updated_at <=> y.updated_at} end - def self.for_admin(user, options) + def self.for_admin(user, options = {}) if options[:admin_status] == 'mine' - self.tickets_by_admin(user.id) #returns Array so pagination does not work + self.tickets_by_admin(user.id, options) #returns Array so pagination does not work elsif options[:open_status] == 'open' Ticket.by_updated_at_and_is_open # Ticket.by_is_open.key(true) #returns CouchRest::Model::Designs::View @@ -122,12 +122,12 @@ class Ticket < CouchRest::Model::Base end #returns Array which doesn't work for pagination, as it is now. - def self.tickets_by_admin(id) + def self.tickets_by_admin(id, options = {}) admin_tickets = [] tickets = Ticket.all tickets.each do |ticket| ticket.comments.each do |comment| - if comment.posted_by == id and (params[:open_status] != 'open' or ticket.is_open) and (params[:open_status] != 'closed' or !ticket.is_open) #limit based on whether the ticket is open if open_status is set to open or closed + if comment.posted_by == id and (options[:open_status] != 'open' or ticket.is_open) and (options[:open_status] != 'closed' or !ticket.is_open) #limit based on whether the ticket is open if open_status is set to open or closed admin_tickets << ticket break end |