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 %>
diff --git a/app/views/code_review/_change_entry_norevision_view.html.erb b/app/views/code_review/_change_entry_norevision_view.html.erb index 096a1a4..d7ccda4 100644 --- a/app/views/code_review/_change_entry_norevision_view.html.erb +++ b/app/views/code_review/_change_entry_norevision_view.html.erb @@ -20,7 +20,7 @@ parameters = request.parameters path = parameters['path'] rev = parameters['rev'] -repository_id = @repository.identifier_param if @repository.respond_to?("identifier_param") +repository_id = @repository.identifier_param unless path.blank? or path.empty? changesets = @repository.latest_changesets(path, rev, Setting.repository_log_display_limit.to_i) change = changesets[0] @@ -36,4 +36,4 @@ unless path.blank? or path.empty? <% end %> -<% end %> \ No newline at end of file +<% end %> diff --git a/app/views/code_review/_change_repository_view.html.erb b/app/views/code_review/_change_repository_view.html.erb index 6c7932b..269a9f3 100644 --- a/app/views/code_review/_change_repository_view.html.erb +++ b/app/views/code_review/_change_repository_view.html.erb @@ -25,7 +25,7 @@ if @changesets changeset_ids << ',' } - repository_id = @repository.identifier_param if @repository.respond_to?("identifier_param") + repository_id = @repository.identifier_param url = url_for :controller => 'code_review', :action => 'update_revisions_view', :id => project, :repository_id => repository_id %> diff --git a/app/views/code_review/_change_revision_view.html.erb b/app/views/code_review/_change_revision_view.html.erb index 67eb805..07b3c22 100644 --- a/app/views/code_review/_change_revision_view.html.erb +++ b/app/views/code_review/_change_revision_view.html.erb @@ -17,7 +17,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -%> <% -repository_id = @repository.identifier_param if @repository.respond_to?("identifier_param") +repository_id = @repository.identifier_param if @changeset urlprefix = url_for(:controller => 'repositories', :action => 'revisions', :id => project, :repository_id => repository_id) + '/' + @changeset.identifier + '/entry' diff --git a/lib/code_review_attachment_patch.rb b/lib/code_review_attachment_patch.rb index 1b1ccb1..313e5ae 100644 --- a/lib/code_review_attachment_patch.rb +++ b/lib/code_review_attachment_patch.rb @@ -15,14 +15,11 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -require_dependency 'attachment' - module CodeReviewAttachmentPatch def self.included(base) # :nodoc: base.send(:include, AttachmentInstanceMethodsCodeReview) base.class_eval do - unloadable # Send unloadable so it will not be unloaded in development has_many :code_reviews has_many :code_review_assignments diff --git a/lib/code_review_change_patch.rb b/lib/code_review_change_patch.rb index 95f9f9e..12d7228 100644 --- a/lib/code_review_change_patch.rb +++ b/lib/code_review_change_patch.rb @@ -15,14 +15,11 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -require_dependency 'change' - module CodeReviewChangePatch def self.included(base) # :nodoc: base.send(:include, ChangeInstanceMethodsCodeReview) base.class_eval do - unloadable # Send unloadable so it will not be unloaded in development has_many :code_reviews, :dependent => :destroy has_many :code_review_assignments, :dependent => :destroy after_save :review_auto_assign diff --git a/lib/code_review_issue_patch.rb b/lib/code_review_issue_patch.rb index e05ae8b..9c0dbe1 100644 --- a/lib/code_review_issue_patch.rb +++ b/lib/code_review_issue_patch.rb @@ -15,14 +15,11 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -require_dependency 'issue' - module CodeReviewIssuePatch def self.included(base) # :nodoc: base.send(:include, IssueInstanceMethodsCodeReview) base.class_eval do - unloadable # Send unloadable so it will not be unloaded in development has_one :code_review, :dependent => :destroy has_one :code_review_assignment, :dependent => :destroy diff --git a/test/functional/repositories_controller_test.rb b/test/functional/repositories_controller_test.rb index 45385d8..43b24df 100644 --- a/test/functional/repositories_controller_test.rb +++ b/test/functional/repositories_controller_test.rb @@ -20,7 +20,7 @@ class RepositoriesControllerTest < ActionController::TestCase - fixtures :projects, :users, :roles, :members, :repositories, :issues, :issue_statuses, :changesets, :changes, :issue_categories, :enumerations, :custom_fields, :custom_values, :trackers + fixtures :projects, :users, :roles, :members, :repositories, :issues, :issue_statuses, :changesets, :changes, :issue_categories, :enumerations, :custom_fields, :custom_values, :trackers, :projects_trackers def setup @controller = RepositoriesController.new @@ -59,8 +59,6 @@ def test_revision change = FactoryGirl.create(:change) changeset = change.changeset project = Project.find(1) - project.repository.destroy - project.repository = changeset.repository issue = Issue.generate!({:project => project, :description => 'test'}) review = FactoryGirl.create(:code_review, change: change, project: project, issue: issue) get :revision, :id => project.id, :rev => changeset.revision, :path => change.path.split('/')