summaryrefslogtreecommitdiffstats
path: root/app/controllers/issues_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/issues_controller.rb')
-rw-r--r--app/controllers/issues_controller.rb21
1 files changed, 13 insertions, 8 deletions
diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb
index de346c576..5623c3bfa 100644
--- a/app/controllers/issues_controller.rb
+++ b/app/controllers/issues_controller.rb
@@ -104,15 +104,16 @@ class IssuesController < ApplicationController
end
def show
- @journals = @issue.journals.includes(:user, :details).reorder("#{Journal.table_name}.id ASC").all
+ @journals = @issue.journals.includes(:user, :details).
+ references(:user, :details).
+ reorder("#{Journal.table_name}.id ASC").to_a
@journals.each_with_index {|j,i| j.indice = i+1}
@journals.reject!(&:private_notes?) unless User.current.allowed_to?(:view_private_notes, @issue.project)
Journal.preload_journals_details_custom_fields(@journals)
- # TODO: use #select! when ruby1.8 support is dropped
- @journals.reject! {|journal| !journal.notes? && journal.visible_details.empty?}
+ @journals.select! {|journal| journal.notes? || journal.visible_details.any?}
@journals.reverse! if User.current.wants_comments_in_reverse_order?
- @changesets = @issue.changesets.visible.all
+ @changesets = @issue.changesets.visible.to_a
@changesets.reverse! if User.current.wants_comments_in_reverse_order?
@relations = @issue.relations.select {|r| r.other_issue(@issue) && r.other_issue(@issue).visible? }
@@ -189,7 +190,7 @@ class IssuesController < ApplicationController
rescue ActiveRecord::StaleObjectError
@conflict = true
if params[:last_journal_id]
- @conflict_journals = @issue.journals_after(params[:last_journal_id]).all
+ @conflict_journals = @issue.journals_after(params[:last_journal_id]).to_a
@conflict_journals.reject!(&:private_notes?) unless User.current.allowed_to?(:view_private_notes, @issue.project)
end
end
@@ -301,7 +302,7 @@ class IssuesController < ApplicationController
else
@saved_issues = @issues
@unsaved_issues = unsaved_issues
- @issues = Issue.visible.where(:id => @unsaved_issues.map(&:id)).all
+ @issues = Issue.visible.where(:id => @unsaved_issues.map(&:id)).to_a
bulk_edit
render :action => 'bulk_edit'
end
@@ -375,7 +376,9 @@ class IssuesController < ApplicationController
def update_issue_from_params
@edit_allowed = User.current.allowed_to?(:edit_issues, @project)
@time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project)
- @time_entry.attributes = params[:time_entry]
+ if params[:time_entry]
+ @time_entry.attributes = params[:time_entry]
+ end
@issue.init_journal(User.current)
@@ -422,7 +425,9 @@ class IssuesController < ApplicationController
@issue.project = @project
@issue.author ||= User.current
# Tracker must be set before custom field values
- @issue.tracker ||= @project.trackers.find((params[:issue] && params[:issue][:tracker_id]) || params[:tracker_id] || :first)
+ tracker_id = (params[:issue] && params[:issue][:tracker_id]) || params[:tracker_id]
+ tracker = tracker_id.present? ? @project.trackers.find(tracker_id) : @project.trackers.first
+ @issue.tracker ||= tracker
if @issue.tracker.nil?
render_error l(:error_no_tracker_in_project)
return false