diff --git a/app/controllers/code_review_controller.rb b/app/controllers/code_review_controller.rb index 47de18b..21eaf39 100644 --- a/app/controllers/code_review_controller.rb +++ b/app/controllers/code_review_controller.rb @@ -16,7 +16,6 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class CodeReviewController < ApplicationController - unloadable before_filter :find_project, :authorize, :find_user, :find_setting, :find_repository helper :sort @@ -348,29 +347,26 @@ def forward_to_revision def preview @text = params[:review][:comment] - @text = params[:reply][:comment] unless @text - render :partial => 'common/preview' + @text ||= params[:reply][:comment] + render partial: 'common/preview' end def update_revisions_view - changeset_ids = [] - #changeset_ids = CGI.unescape(params[:changeset_ids]).split(',') unless params[:changeset_ids].blank? - changeset_ids = params[:changeset_ids].split(',') unless params[:changeset_ids].blank? - @changesets = [] - changeset_ids.each {|id| - @changesets << @repository.find_changeset_by_name(id) unless id.blank? - } - render :partial => 'update_revisions' + changeset_ids = params[:changeset_ids].to_s.split(',') + @changesets = changeset_ids.map do |id| + @repository.find_changeset_by_name(id) unless id.blank? + end + render partial: 'update_revisions' end private def find_repository - if params[:repository_id].present? and @project.repositories + if params[:repository_id].present? @repository = @project.repositories.find_by_identifier_param(params[:repository_id]) else @repository = @project.repository end - @repository_id = @repository.identifier_param if @repository.respond_to?("identifier_param") + @repository_id = @repository.identifier_param end def find_project diff --git a/app/controllers/code_review_settings_controller.rb b/app/controllers/code_review_settings_controller.rb index 2b367da..7234865 100644 --- a/app/controllers/code_review_settings_controller.rb +++ b/app/controllers/code_review_settings_controller.rb @@ -16,7 +16,6 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class CodeReviewSettingsController < ApplicationController - unloadable layout 'base' menu_item :code_review include CodeReviewAutoAssignSettings diff --git a/app/helpers/code_review_helper.rb b/app/helpers/code_review_helper.rb index 2086c33..ed17012 100644 --- a/app/helpers/code_review_helper.rb +++ b/app/helpers/code_review_helper.rb @@ -15,7 +15,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. module CodeReviewHelper - unloadable def show_assignments(assignments, project, options = {}) html = "#{l(:review_assignments)}:" assignments.each do |assignment| diff --git a/app/models/code_review.rb b/app/models/code_review.rb index e2cb549..f8b705f 100644 --- a/app/models/code_review.rb +++ b/app/models/code_review.rb @@ -16,7 +16,6 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class CodeReview < ActiveRecord::Base include Redmine::SafeAttributes - unloadable belongs_to :project belongs_to :change belongs_to :issue @@ -158,18 +157,13 @@ def status_id end def open_assignment_issues(user_id) - issues = [] assignments = [] - assignments = change.code_review_assignments if change - assignments = assignments + changeset.code_review_assignments if changeset - assignments = assignments + attachment.code_review_assignments if attachment + assignments += change.code_review_assignments if change + assignments += changeset.code_review_assignments if changeset + assignments += attachment.code_review_assignments if attachment - assignments.each {|assignment| - unless assignment.is_closed? - issues << assignment.issue if user_id == assignment.issue.assigned_to_id - end + assignments.reject(&:is_closed?).map(&:issue).select{ |issue| + user_id == issue.assigned_to_id } - - issues end end diff --git a/app/models/code_review_assignment.rb b/app/models/code_review_assignment.rb index 75c45e1..f9cbdfc 100644 --- a/app/models/code_review_assignment.rb +++ b/app/models/code_review_assignment.rb @@ -16,7 +16,6 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class CodeReviewAssignment < ActiveRecord::Base - unloadable belongs_to :issue belongs_to :change belongs_to :changeset @@ -44,7 +43,7 @@ def repository def repository_identifier return nil unless repository - @repository_identifier ||= repository.identifier_param if repository.respond_to?("identifier_param") + @repository_identifier ||= repository.identifier_param end def self.create_with_changeset(changeset) diff --git a/app/models/code_review_project_setting.rb b/app/models/code_review_project_setting.rb index f1a8d28..16435e4 100644 --- a/app/models/code_review_project_setting.rb +++ b/app/models/code_review_project_setting.rb @@ -15,7 +15,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class CodeReviewProjectSetting < ActiveRecord::Base - unloadable include Redmine::SafeAttributes include CodeReviewAutoAssignSettings diff --git a/app/models/code_review_user_setting.rb b/app/models/code_review_user_setting.rb index 95245f5..d5dad29 100644 --- a/app/models/code_review_user_setting.rb +++ b/app/models/code_review_user_setting.rb @@ -15,7 +15,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class CodeReviewUserSetting < ActiveRecord::Base - unloadable belongs_to :user validates_presence_of :user_id diff --git a/app/views/code_review/_body_bottom.html.erb b/app/views/code_review/_body_bottom.html.erb index ba798ee..1cc9191 100644 --- a/app/views/code_review/_body_bottom.html.erb +++ b/app/views/code_review/_body_bottom.html.erb @@ -54,7 +54,7 @@ if project and controller and project.module_enabled?(:code_review) path = parameters['path'].blank? ? '.' : parameters['path'] - repository_id = @repository.identifier_param if @repository.respond_to?("identifier_param") + repository_id = @repository.identifier_param url = url_for :controller => 'code_review', :action => 'update_diff_view', :id => project, :repository_id => repository_id %>