diff --git a/.travis.yml b/.travis.yml
index 9a2cf0d..29c721d 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,17 +1,15 @@
language: ruby
rvm:
-- 2.2
- 2.3
- 2.4
+- 2.5
env:
-- REDMINE_VER=3.4-stable
+- REDMINE_VER=master
+- REDMINE_VER=4.0-stable
+install:
+- bash -x ./travis/travis_install.sh
script:
-- export TESTSPACE=`pwd`/testspace
-- export NAME_OF_PLUGIN=redmine_code_review
-- export PATH_TO_PLUGIN=`pwd`
-- export PATH_TO_REDMINE=$TESTSPACE/redmine
-- mkdir $TESTSPACE
-- bash -x ./travis.sh
+- bash -x ./travis/travis.sh
notifications:
slack:
secure: XhtN5XeJKyYhGYRFGfxGpGaVcUnUsZoxX3ZL3RgHikcBhD0hY6Ogn09BSiygP381lbIlV7+2nlRvNoSUKYmx2uX5w8AUYCE4yo9yJGlY+70rD2kjWsuG9OK4L/QPCXIUf8NFX24PdY9CRITK5CfR1/hEZCx9ygT6GLAqpjqNDtfMpSRx7S3olVjX58ucB9azDcvaT75vPY1nEnnn/IuOwGF27KBk9lLZtMaG1ohI6+9jW9xCxz8cLfUUPIu+PH4/AvJ8GMNJtlc3Yvgbg57lCtulvHyrXqXHMvMDL2aTdIj2XsjVSvXV4jRrNuhJga6gDAtl/3Lzm+UZZAeHpR4qHDZN06za25HypX/GbX5pZtpr30t+HHs3cd+ecHb4uP/Tnxko0KzNywg6Ayn/8TC548eu0JRITzPS5C9/NKzA+XnAjVgKMzqy0zU1VVk83hBXshgpfqplfZzdIrn75kcV/3qsiaD4qEFM2MqNYD15Epq8a7W/9IKdhd95LsQjp1Fb0g7XiQcM3ahIgMLIjP5tZfQ8b7tVlmDx1GCP4uRFOBeDeoz9i++UaT/FdPHOFGirWfDZMJoVq3MXixaTudEPFomO2HktErAMIEjQQyVe4FylglGnE52RCqEJ0qiD/kh1HV1VnVqyTJ9o3DXgLTIMdFiw+jHtTuorYPG0Qn1Dqbg=
diff --git a/Gemfile_for_test b/Gemfile_for_test
index d854670..2d8d66d 100644
--- a/Gemfile_for_test
+++ b/Gemfile_for_test
@@ -1,8 +1,9 @@
-source 'http://rubygems.org'
+
group :test do
gem "simplecov-rcov"
- gem 'factory_girl_rails'
+ gem 'factory_bot_rails'
gem 'shoulda'
+ gem 'rails-controller-testing'
gem 'coveralls', :require => false
end
\ No newline at end of file
diff --git a/app/controllers/code_review_controller.rb b/app/controllers/code_review_controller.rb
index 47de18b..d64143b 100644
--- a/app/controllers/code_review_controller.rb
+++ b/app/controllers/code_review_controller.rb
@@ -17,7 +17,7 @@
class CodeReviewController < ApplicationController
unloadable
- before_filter :find_project, :authorize, :find_user, :find_setting, :find_repository
+ before_action :find_project, :authorize, :find_user, :find_setting, :find_repository
helper :sort
include SortHelper
@@ -33,7 +33,7 @@ class CodeReviewController < ApplicationController
def index
sort_init "#{Issue.table_name}.id", 'desc'
- sort_update ["#{Issue.table_name}.id", "#{Issue.table_name}.status_id", "#{Issue.table_name}.subject", "path", "updated_at", "user_id", "#{Changeset.table_name}.committer", "#{Changeset.table_name}.revision"]
+ sort_update ["#{Issue.table_name}.id", "#{Issue.table_name}.status_id", "#{Issue.table_name}.subject", "path", "updated_at", "user_id", "#{Changeset.table_name}.committer", "#{Changeset.table_name}.revision"]
limit = per_page_option
@review_count = CodeReview.where(["project_id = ? and issue_id is NOT NULL", @project.id]).count
@@ -41,18 +41,18 @@ def index
@review_pages = Paginator.new @review_count, limit, params['page']
@show_closed = (params['show_closed'] == 'true')
show_closed_option = " and #{IssueStatus.table_name}.is_closed = ? "
- if (@show_closed)
- show_closed_option = ''
- end
+
+ show_closed_option = '' if (@show_closed)
+
conditions = ["#{CodeReview.table_name}.project_id = ? and issue_id is NOT NULL" + show_closed_option, @project.id]
- unless (@show_closed)
- conditions << false
- end
+
+ conditions << false unless (@show_closed)
@reviews = CodeReview.order(sort_clause).limit(limit).where(conditions).joins(
"left join #{Change.table_name} on change_id = #{Change.table_name}.id left join #{Changeset.table_name} on #{Change.table_name}.changeset_id = #{Changeset.table_name}.id " +
"left join #{Issue.table_name} on issue_id = #{Issue.table_name}.id " +
- "left join #{IssueStatus.table_name} on #{Issue.table_name}.status_id = #{IssueStatus.table_name}.id").offset(@review_pages.offset)
+ "left join #{IssueStatus.table_name} on #{Issue.table_name}.status_id = #{IssueStatus.table_name}.id"
+ ).offset(@review_pages.offset)
@i_am_member = @user.member_of?(@project)
render :template => 'code_review/index', :layout => !request.xhr?
end
@@ -68,7 +68,7 @@ def new
else
@review.issue.tracker_id = @setting.tracker_id
end
- @review.assign_attributes(params[:review])
+ @review.attributes = params.require(:review).permit(:change_id, :subject, :line, :parent_id, :comment, :status_id, :issue) if params[:review]
@review.project_id = @project.id
@review.issue.project_id = @project.id
@@ -85,12 +85,12 @@ def new
@review.issue.safe_attributes = params[:issue] unless params[:issue].blank?
@review.diff_all = (params[:diff_all] == 'true')
- @parent_candidate = get_parent_candidate(@review.rev) if @review.rev
+ @parent_candidate = get_parent_candidate(@review.rev) if @review.rev
if request.post?
@review.issue.save!
if @review.changeset
- @review.changeset.issues.each {|issue|
+ @review.changeset.issues.each { |issue|
create_relation @review, issue, @setting.issue_relation_type
} if @setting.auto_relation?
elsif @review.attachment and @review.attachment.container_type == 'Issue'
@@ -98,7 +98,7 @@ def new
create_relation @review, issue, @setting.issue_relation_type if @setting.auto_relation?
end
watched_users = []
- @review.open_assignment_issues(@user.id).each {|issue|
+ @review.open_assignment_issues(@user.id).each { |issue|
unless @review.issue.parent_id == issue.id
create_relation @review, issue, IssueRelation::TYPE_RELATES
end
@@ -113,38 +113,36 @@ def new
}
@review.save!
- render :partial => 'add_success', :status => 200
+ render partial: 'add_success', status: 200
return
else
change_id = params[:change_id].to_i unless params[:change_id].blank?
@review.change = Change.find(change_id) if change_id
@review.line = params[:line].to_i unless params[:line].blank?
- if (@review.changeset and @review.changeset.user_id)
+ if @review.changeset and @review.changeset.user_id
@review.issue.assigned_to_id = @review.changeset.user_id
end
@default_version_id = @review.issue.fixed_version.id if @review.issue.fixed_version
if @review.changeset and @default_version_id.blank?
- @review.changeset.issues.each {|issue|
+ @review.changeset.issues.each { |issue|
if issue.fixed_version
@default_version_id = issue.fixed_version.id
- break;
+ break
end
}
end
- @review.open_assignment_issues(@user.id).each {|issue|
+ @review.open_assignment_issues(@user.id).each { |issue|
if issue.fixed_version
@default_version_id = issue.fixed_version.id
- break;
+ break
end
} unless @default_version_id
-
-
end
- render :partial => 'new_form', :status => 200
+ render partial: 'new_form', status: 200
}
rescue ActiveRecord::RecordInvalid => e
logger.error e
- render :partial => 'new_form', :status => 200
+ render partial: 'new_form', status: 200
end
end
@@ -160,7 +158,7 @@ def assign
code[:repository_id] = @repository_id if @repository_id
changeset = Changeset.find(code[:changeset_id]) if code[:changeset_id]
- if (changeset == nil and code[:change_id] != nil)
+ if changeset == nil and code[:change_id] != nil
change = Change.find(code[:change_id])
changeset = change.changeset if change
end
@@ -174,8 +172,8 @@ def assign
end
issue[:tracker_id] = @setting.assignment_tracker_id if @setting.assignment_tracker_id
- redirect_to :controller => 'issues', :action => "new" , :project_id => @project,
- :issue => issue, :code => code
+ redirect_to controller: 'issues', action: "new", project_id: @project,
+ issue: issue, code: code
end
def update_diff_view
@@ -190,14 +188,12 @@ def update_diff_view
@action_type = params[:action_type]
changeset = @repository.find_changeset_by_name(@rev)
- if @paths.empty?
- changeset.filechanges.each{|chg|
- }
- end
+
+ changeset.filechanges.each { |chg| } if @paths.empty?
url = @repository.url
root_url = @repository.root_url
- if (url == nil || root_url == nil)
+ if url.nil? || root_url.nil?
fullpath = @path
else
rootpath = url[root_url.length, url.length - root_url.length]
@@ -208,9 +204,9 @@ def update_diff_view
end
end
@change = nil
- changeset.filechanges.each{|chg|
- @change = chg if ((chg.path == fullpath) or ("/#{chg.path}" == fullpath)) or (chg.path == "/#{@path}")
- } unless @path.blank?
+ changeset.filechanges.each { |chg|
+ @change = chg if ((chg.path == fullpath) || ("/#{chg.path}" == fullpath)) || (chg.path == "/#{@path}")
+ } unless @path.blank?
@changeset = changeset
if @path
@@ -220,12 +216,7 @@ def update_diff_view
end
@review.change_id = @change.id if @change
- #render :partial => 'show_error'
- #return
-
-
-
- render :partial => 'update_diff_view'
+ render partial: 'update_diff_view'
end
def update_attachment_view
@@ -238,7 +229,7 @@ def update_attachment_view
@reviews = CodeReview.where(['attachment_id = (?) and issue_id is NOT NULL', @attachment_id]).all
- render :partial => 'update_diff_view'
+ render partial: 'update_diff_view'
end
def show
@@ -251,29 +242,27 @@ def show
target = @review if @review
target = @assignment if @assignment
@repository_id = target.repository_identifier
- if request.xhr? or !params[:update].blank?
- render :partial => 'show'
+ if request.xhr? || !params[:update].blank?
+ render partial: 'show'
elsif target.path
- #@review = @review.root
- path = URI.decode(target.path)
- #path = '/' + path unless path.match(/^\//)
+ path = URI.decode_www_form(target.path)
action_name = target.action_type
rev_to = ''
rev_to = '&rev_to=' + target.rev_to if target.rev_to
if action_name == 'attachment'
attachment = target.attachment
- url = url_for(:controller => 'attachments', :action => 'show', :id => attachment.id) + '/' + URI.escape(attachment.filename)
+ url = url_for(controller: 'attachments', action: 'show',
+ id: attachment.id) + '/' + URI.encode(attachment.filename)
url << '?review_id=' + @review.id.to_s if @review
- redirect_to(url)
else
path = nil if target.diff_all
- url = url_for(:controller => 'repositories', :action => action_name, :id => @project,
- :repository_id => @repository_id, :rev => target.revision, :path => path)
- #url = url_for(:controller => 'repositories', :action => action_name, :id => @project, :repository_id => @repository_id) + path + '?rev=' + target.revision
+ url = url_for(controller: 'repositories', action: action_name,
+ id: @project, repository_id: @repository_id,
+ rev: target.revision, path: path)
url << '?review_id=' + @review.id.to_s + rev_to if @review
url << '?r=' + rev_to unless @review
- redirect_to url
end
+ redirect_to url
end
end
@@ -284,7 +273,7 @@ def reply
@issue.lock_version = params[:issue][:lock_version]
comment = params[:reply][:comment]
journal = @issue.init_journal(User.current, comment)
- @review.assign_attributes(params[:review])
+ @review.attributes = params.require(:review).permit(:change_id, :subject, :line, :parent_id, :comment, :status_id, :issue) if params[:review]
@allowed_statuses = @issue.new_statuses_allowed_to(User.current)
@issue.save!
@@ -293,11 +282,11 @@ def reply
flash[:notice] = l(:notice_successful_update)
end
- render :partial => 'show'
+ render partial: 'show'
rescue ActiveRecord::StaleObjectError
# Optimistic locking exception
@error = l(:notice_locking_conflict)
- render :partial => 'show'
+ render partial: 'show'
end
end
@@ -309,7 +298,7 @@ def update
@allowed_statuses = @review.issue.new_statuses_allowed_to(User.current)
@issue = @review.issue
@issue.lock_version = params[:issue][:lock_version]
- @review.assign_attributes(params[:review])
+ @review.attributes = params.require(:review).permit(:change_id, :subject, :lock_version, :parent_id, :comment, :status_id, :issue)
@review.updated_by_id = @user.id
@review.save!
@review.issue.save!
@@ -317,22 +306,22 @@ def update
lang = current_language
Mailer.deliver_issue_edit(journal) if Setting.notified_events.include?('issue_updated')
set_language lang if respond_to? 'set_language'
- render :partial => 'show'
+ render partial: 'show'
}
rescue ActiveRecord::StaleObjectError
# Optimistic locking exception
@error = l(:notice_locking_conflict)
- render :partial => 'show'
- rescue
- render :partial => 'show'
+ render partial: 'show'
+ #rescue => e
+ #throw e
+ #render :partial => 'show'
end
end
-
def destroy
@review = CodeReview.find(params[:review_id].to_i)
@review.issue.destroy if @review
- render :text => 'delete success.'
+ render plain: 'delete success.'
end
def forward_to_revision
@@ -342,28 +331,28 @@ def forward_to_revision
change = changesets[0]
identifier = change.identifier
- redirect_to url_for(:controller => 'repositories', :action => 'entry', :id => @project, :repository_id => @repository_id) + '/' + path + '?rev=' + identifier.to_s
-
+ redirect_to url_for(controller: 'repositories', action: 'entry',
+ id: @project, repository_id: @repository_id) + '/' + path + '?rev=' + identifier.to_s
end
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|
+ changeset_ids.each { |id|
@changesets << @repository.find_changeset_by_name(id) unless id.blank?
}
- render :partial => 'update_revisions'
+ render partial: 'update_revisions'
end
private
+
def find_repository
if params[:repository_id].present? and @project.repositories
@repository = @project.repositories.find_by_identifier_param(params[:repository_id])
@@ -382,14 +371,13 @@ def find_user
@user = User.current
end
-
def find_setting
@setting = CodeReviewProjectSetting.find_or_create(@project)
end
def get_parent_candidate(revision)
changeset = @repository.find_changeset_by_name(revision)
- changeset.issues.each {|issue|
+ changeset.issues.each { |issue|
return Issue.find(issue.parent_issue_id) if issue.parent_issue_id
}
nil
diff --git a/app/controllers/code_review_settings_controller.rb b/app/controllers/code_review_settings_controller.rb
index 2b367da..93aae06 100644
--- a/app/controllers/code_review_settings_controller.rb
+++ b/app/controllers/code_review_settings_controller.rb
@@ -21,26 +21,25 @@ class CodeReviewSettingsController < ApplicationController
menu_item :code_review
include CodeReviewAutoAssignSettings
- before_filter :find_project, :authorize, :find_user
+ before_action :find_project, :authorize, :find_user
def update
begin
@setting = CodeReviewProjectSetting.find_or_create(@project)
- @setting.assign_attributes params[:setting]
+ @setting.attributes = params.require(:setting).permit(:tracker_id, :assignment_tracker_id, :hide_code_review_tab, :auto_relation, :tracker_in_review_dialog, :auto_assign)
@setting.updated_by = @user.id
- params[:auto_assign][:filters] = params[:auto_assign][:filters].values unless params[:auto_assign][:filters].blank?
+ params[:auto_assign][:filters] = params[:auto_assign][:filters].values if !params[:auto_assign].blank? && !params[:auto_assign][:filters].blank?
@setting.auto_assign_settings = params[:auto_assign].to_yaml
@setting.save!
-
+
flash[:notice] = l(:notice_successful_update)
rescue ActiveRecord::StaleObjectError
# Optimistic locking exception
flash[:error] = l(:notice_locking_conflict)
end
redirect_to :controller => 'projects', :action => "settings", :id => @project, :tab => 'code_review'
-
end
def add_filter
@@ -50,7 +49,7 @@ def add_filter
filters = [] unless filters
filters << params[:auto_assign_add_filter]
- @auto_assign.filters = filters.collect{|f|
+ @auto_assign.filters = filters.collect { |f|
filter = AssignmentFilter.new
filter.attributes = f
filter
@@ -66,7 +65,7 @@ def edit_filter
filters = params[:auto_assign][:filters].values unless params[:auto_assign][:filters].blank?
filters = [] unless filters
i = 0
- @auto_assign.filters = filters.collect{|f|
+ @auto_assign.filters = filters.collect { |f|
filter = AssignmentFilter.new
if i == num
filter.attributes = params[:auto_assign_edit_filter][num.to_s]
@@ -97,16 +96,17 @@ def sort
filters[num][:order] = 999999999
end
- @auto_assign.filters = filters.collect{|f|
+ @auto_assign.filters = filters.collect { |f|
filter = AssignmentFilter.new
filter.attributes = f
filter
}
-
render :partial => "code_review_settings/filters"
end
+
private
+
def find_project
# @project variable must be set before calling the authorize filter
@project = Project.find(params[:id])
@@ -115,5 +115,4 @@ def find_project
def find_user
@user = User.current
end
-
end
diff --git a/app/helpers/code_review_helper.rb b/app/helpers/code_review_helper.rb
index 2086c33..5b64c14 100644
--- a/app/helpers/code_review_helper.rb
+++ b/app/helpers/code_review_helper.rb
@@ -16,19 +16,20 @@
# 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|
issue = assignment.issue
html << link_to("##{issue.id} ", {:controller => 'issues', :action => 'show', :id => issue.id},
- :class => issue.css_classes, :title => "#{issue}(#{issue.status})")
+ :class => issue.css_classes, :title => "#{issue}(#{issue.status})")
end if assignments
link = link_to(l(:button_add), {:controller => 'code_review',
- :action => 'assign', :id=>project, :action_type => options[:action_type],
- :rev => options[:rev], :rev_to => options[:rev_to], :path => options[:path],
- :change_id => options[:change_id], :attachment_id => options[:attachment_id],
- :changeset_id => options[:changeset_id]}, :class => 'icon icon-add')
+ :action => 'assign', :id => project, :action_type => options[:action_type],
+ :rev => options[:rev], :rev_to => options[:rev_to], :path => options[:path],
+ :change_id => options[:change_id], :attachment_id => options[:attachment_id],
+ :changeset_id => options[:changeset_id]}, :class => 'icon icon-add')
html << link if link
diff --git a/app/models/code_review.rb b/app/models/code_review.rb
index e2cb549..bf81b44 100644
--- a/app/models/code_review.rb
+++ b/app/models/code_review.rb
@@ -1,5 +1,5 @@
# Code Review plugin for Redmine
-# Copyright (C) 2009-2015 Haruyuki Iida
+# Copyright (C) 2009-2017 Haruyuki Iida
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -23,14 +23,12 @@ class CodeReview < ActiveRecord::Base
belongs_to :updated_by, :class_name => 'User', :foreign_key => 'updated_by_id'
belongs_to :attachment
- validates_presence_of :project_id, :user_id, :updated_by_id, :issue,
+ validates_presence_of :project_id, :user_id, :updated_by_id, :issue,
:subject, :action_type, :line
STATUS_OPEN = 0
STATUS_CLOSED = 1
- attr_accessible :change_id, :subject, :line, :parent_id, :comment, :status_id, :issue
-
def before_create
issue = Issue.new unless issue
end
@@ -49,7 +47,7 @@ def reopen
issue.status = IssueStatus.find(1)
#self.root.status = STATUS_OPEN
end
-
+
def committer
return changeset.author if changeset
end
@@ -74,7 +72,7 @@ def path
@path = change.path
else
@path = change.path[rootpath.length, change.path.length - rootpath.length]
- end
+ end
rescue => ex
return ex.to_s
end
@@ -92,13 +90,13 @@ def changeset
def repository
@repository ||= changeset.repository if changeset
end
-
+
def repository_identifier
return nil unless repository
@repository_identifier ||= repository.identifier_param
end
- def comment=(str)
+ def comment=(str)
issue.description = str if issue
end
@@ -113,7 +111,6 @@ def before_save
def validate
unless issue.validate
false
-
end
end
@@ -141,7 +138,7 @@ def subject
issue.subject
end
- def parent_id= (p)
+ def parent_id=(p)
issue.parent_issue_id = p
end
@@ -164,7 +161,7 @@ def open_assignment_issues(user_id)
assignments = assignments + changeset.code_review_assignments if changeset
assignments = assignments + attachment.code_review_assignments if attachment
- assignments.each {|assignment|
+ assignments.each { |assignment|
unless assignment.is_closed?
issues << assignment.issue if user_id == assignment.issue.assigned_to_id
end
diff --git a/app/models/code_review_assignment.rb b/app/models/code_review_assignment.rb
index 75c45e1..768030b 100644
--- a/app/models/code_review_assignment.rb
+++ b/app/models/code_review_assignment.rb
@@ -35,13 +35,13 @@ def revision
return rev if rev
changeset.revision if changeset
end
-
+
def repository
@repository ||= change.changeset.repository if change
@repository ||= changeset.repository if changeset
@repository
end
-
+
def repository_identifier
return nil unless repository
@repository_identifier ||= repository.identifier_param if repository.respond_to?("identifier_param")
@@ -55,25 +55,24 @@ def self.create_with_changeset(changeset)
issue = Issue.new
issue.subject = auto_assign.subject
issue.subject = l(:code_review_requrest) if issue.subject.blank?
- issue.subject = issue.subject.sub("$REV" , changeset.revision)
- issue.subject = issue.subject.sub("$COMMENTS" , changeset.comments.split(//u)[0..60].join) unless changeset.comments.blank?
+ issue.subject = issue.subject.sub("$REV", changeset.revision)
+ issue.subject = issue.subject.sub("$COMMENTS", changeset.comments.split(//u)[0..60].join) unless changeset.comments.blank?
issue.tracker_id = setting.assignment_tracker_id
issue.project = project
issue.author = User.find(auto_assign.author_id)
issue.assigned_to_id = auto_assign.select_assign_to(project, changeset.user)
issue.description = auto_assign.description
- issue.description = issue.description.sub("$REV" , changeset.revision) unless issue.description.blank?
- issue.description = issue.description.sub("$COMMENTS" , changeset.comments) unless changeset.comments.blank?
+ issue.description = issue.description.sub("$REV", changeset.revision) unless issue.description.blank?
+ issue.description = issue.description.sub("$COMMENTS", changeset.comments) unless changeset.comments.blank?
issue.save!
-
+
assignment.issue_id = issue.id
assignment.changeset_id = changeset.id
assignment.save!
assignment
end
-
def diff_all
path.blank?
end
diff --git a/app/models/code_review_project_setting.rb b/app/models/code_review_project_setting.rb
index f1a8d28..c418965 100644
--- a/app/models/code_review_project_setting.rb
+++ b/app/models/code_review_project_setting.rb
@@ -29,7 +29,7 @@ class CodeReviewProjectSetting < ActiveRecord::Base
before_save :set_assignment_settings
- attr_accessible :tracker_id, :assignment_tracker_id, :hide_code_review_tab, :auto_relation, :tracker_in_review_dialog, :auto_assign
+ #attr_accessible :tracker_id, :assignment_tracker_id, :hide_code_review_tab, :auto_relation, :tracker_in_review_dialog, :auto_assign
AUTORELATION_TYPE_NONE = 0
AUTORELATION_TYPE_RELATES = 1
@@ -55,18 +55,19 @@ def auto_assign_settings
def auto_assign_settings=(settings)
@auto_assign_settings = settings
end
-
+
def issue_relation_type
return IssueRelation::TYPE_RELATES if auto_relation == CodeReviewProjectSetting::AUTORELATION_TYPE_RELATES
return IssueRelation::TYPE_BLOCKS if auto_relation == CodeReviewProjectSetting::AUTORELATION_TYPE_BLOCKS
return nil
end
-
+
def auto_relation?
issue_relation_type != nil
end
private
+
def set_assignment_settings
if auto_assign_settings
self.auto_assign = auto_assign_settings.to_s
diff --git a/app/models/review_mailer.rb b/app/models/review_mailer.rb
index 3975f9b..6c0851a 100644
--- a/app/models/review_mailer.rb
+++ b/app/models/review_mailer.rb
@@ -16,12 +16,11 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class ReviewMailer < Mailer
-
def review_add(project, review)
redmine_headers 'Project' => review.project.identifier,
'Review-Id' => review.id,
'Review-Author' => review.user.login
-
+
recipients get_mail_addresses(review)
subject "[#{review.project.name} - #{l(:label_review_new)} - #{l(:label_review)}##{review.id}] "
@@ -31,18 +30,18 @@ def review_add(project, review)
return if (l(:this_is_checking_for_before_rails_2_2_2) == 'this_is_checking_for_before_rails_2_2_2')
# 何故かrails 2.2 以後は以下の処理が必要
-
+
content_type "multipart/alternative"
part "text/plain" do |p|
- p.body = render_message("review_add.text.plain.erb", :body => body, :review=>review, :review_url => review_url)
+ p.body = render_message("review_add.text.plain.erb", :body => body, :review => review, :review_url => review_url)
end
part "text/html" do |p|
- p.body = render_message("review_add.text.html.erb", :body => body, :review=>review, :review_url => review_url)
+ p.body = render_message("review_add.text.html.erb", :body => body, :review => review, :review_url => review_url)
end
end
-
+
def review_reply(project, review)
redmine_headers 'Project' => review.project.identifier,
'Review-Id' => review.id,
@@ -56,17 +55,16 @@ def review_reply(project, review)
return if (l(:this_is_checking_for_before_rails_2_2_2) == 'this_is_checking_for_before_rails_2_2_2')
# 何故かrails 2.2 以後は以下の処理が必要
-
+
content_type "multipart/alternative"
part "text/plain" do |p|
- p.body = render_message("review_reply.text.plain.erb", :body => body, :review=>review, :review_url => review_url)
+ p.body = render_message("review_reply.text.plain.erb", :body => body, :review => review, :review_url => review_url)
end
part "text/html" do |p|
- p.body = render_message("review_reply.text.html.erb", :body => body, :review=>review, :review_url => review_url)
+ p.body = render_message("review_reply.text.html.erb", :body => body, :review => review, :review_url => review_url)
end
-
end
def review_status_changed(project, review)
@@ -86,21 +84,21 @@ def review_status_changed(project, review)
return if (l(:this_is_checking_for_before_rails_2_2_2) == 'this_is_checking_for_before_rails_2_2_2')
# 何故かrails 2.2 以後は以下の処理が必要
-
+
content_type "multipart/alternative"
part "text/plain" do |p|
- p.body = render_message("review_status_changed.text.plain.erb", :body => body, :review=>review, :review_url => review_url)
+ p.body = render_message("review_status_changed.text.plain.erb", :body => body, :review => review, :review_url => review_url)
end
part "text/html" do |p|
- p.body = render_message("review_status_changed.text.html.erb", :body => body, :review=>review, :review_url => review_url)
+ p.body = render_message("review_status_changed.text.html.erb", :body => body, :review => review, :review_url => review_url)
end
end
def get_mail_addresses(review)
mail_addresses = []
- review.root.users_for_notification.each{|u|
+ review.root.users_for_notification.each { |u|
mail_addresses << u.mail
}
committer = review.change.changeset.user
@@ -109,14 +107,12 @@ def get_mail_addresses(review)
mail_addresses << committer.mail if setting and !setting.mail_notification_none?
end
- review.project.members.each{|member|
+ review.project.members.each { |member|
user = member.user
setting = CodeReviewUserSetting.find_or_create(user.id)
next unless setting
mail_addresses << user.mail if setting.mail_notification_all?
}
mail_addresses.compact.uniq
-
end
-
end
diff --git a/app/views/code_review/_issues_show_details_bottom.html.erb b/app/views/code_review/_issues_show_details_bottom.html.erb
index 620f2a2..62463e9 100644
--- a/app/views/code_review/_issues_show_details_bottom.html.erb
+++ b/app/views/code_review/_issues_show_details_bottom.html.erb
@@ -5,7 +5,7 @@
<%
unless User.current.allowed_to?({:controller => 'code_review', :action => 'show'}, project)
- return
+ return
end
%>
@@ -18,7 +18,11 @@ review = issue.code_review
<%= l(:code_review) %>: |
<%
- label = URI.decode("#{review.repository_identifier + ':' if review.repository_identifier}#{review.path}#{'@' + review.revision if review.revision}:line #{review.line}")
+ if review.attachment
+ label = URI.decode("#{review.attachment.filename}#{'@' + review.revision if review.revision}:line #{review.line}")
+ else
+ label = URI.decode("#{review.repository_identifier + ':' if review.repository_identifier}#{review.path}#{'@' + review.revision if review.revision}:line #{review.line}")
+ end
-%>
<%= link_to(label,
:controller => 'code_review', :action => 'show', :id => project, :review_id => review.id, :repository_id => review.repository_identifier) %>
@@ -26,7 +30,7 @@ review = issue.code_review
<% end %>
<% if issue.code_review_assignment %>
- <%
+ <%
assignment = issue.code_review_assignment
repository_id = assignment.repository_identifier
%>
diff --git a/app/views/code_review/_new_form.html.erb b/app/views/code_review/_new_form.html.erb
index a560d17..df6748b 100644
--- a/app/views/code_review/_new_form.html.erb
+++ b/app/views/code_review/_new_form.html.erb
@@ -71,11 +71,14 @@
<%= custom_field_tag_with_label :issue, value %>
<% end %>
+
<%= f.text_area :comment,
:cols => 30,
:rows => 12,
:accesskey => accesskey(:edit),
:class => 'wiki-edit' %>
+ <%= wikitoolbar_for 'review_comment' %>
+
@@ -110,10 +113,9 @@
<%= button_tag l(:button_apply), type: 'button', onclick: "$('#review-form').load('#{submit_url}', $('#review_form').serialize2json())" %>
- <%= preview_link({ :controller => 'code_review', :action => 'preview', :id => @project}, 'review_form') %>
+
-
- <%= wikitoolbar_for 'review_comment' %>
+
<% end %>
diff --git a/app/views/code_review/_show.html.erb b/app/views/code_review/_show.html.erb
index 24a1edd..e381cf5 100644
--- a/app/views/code_review/_show.html.erb
+++ b/app/views/code_review/_show.html.erb
@@ -117,9 +117,7 @@
-%>
<%= button_tag l(:button_apply), type: 'button', onclick: "$('#show_review_#{@review.id}').load('#{submit_url}', $('##{review_form_id}').serialize())" %>
- <%= link_to_function l(:label_preview), "$('#preview_#{@review.id}').load('#{url_for(:controller => 'code_review', :action => 'preview', :id => @project)}', $('##{review_form_id}').serialize())" %>
-
<%= wikitoolbar_for 'review_comment_' + @review.id.to_s %>
<% end %>
@@ -179,9 +177,7 @@
<%
reply_preview_id = "reply_preview_#{@review.id}"
-%>
- <%= link_to_function l(:label_preview), "$('##{reply_preview_id}').load('#{url_for(:controller => 'code_review', :action => 'preview', :id => @project)}', $('##{message_form_id}').serialize())" %>
-
<%= wikitoolbar_for 'reply_comment_' + @review.id.to_s %>
<% end %>
diff --git a/assets/javascripts/code_review.js b/assets/javascripts/code_review.js
index f2eef97..a2ea33d 100644
--- a/assets/javascripts/code_review.js
+++ b/assets/javascripts/code_review.js
@@ -29,19 +29,19 @@ var review_dialog_title = null;
var repository_id = null;
var filenames = [];
-var ReviewCount = function(total, open, progress){
- this.total = total;
- this.open = open;
- this.closed = total - open;
- this.progress = progress
+var ReviewCount = function (total, open, progress) {
+ this.total = total;
+ this.open = open;
+ this.closed = total - open;
+ this.progress = progress
};
-var CodeReview = function(id) {
- this.id = id;
- this.path = '';
- this.line = 0;
- this.url = '';
- this.is_closed = false;
+var CodeReview = function (id) {
+ this.id = id;
+ this.path = '';
+ this.line = 0;
+ this.url = '';
+ this.is_closed = false;
};
var review_counts = new Array();
@@ -49,135 +49,134 @@ var code_reviews_map = new Array();
var code_reviews_dialog_map = new Array();
function UpdateRepositoryView(title) {
- var header = $("table.changesets thead tr:first");
- var th = $(' | | ');
- th.html(title);
- header.append(th);
- $('tr.changeset td.id a:first-child').each(function(i){
- var revision = this.getAttribute("href");
- revision = revision.substr(revision.lastIndexOf("/") + 1);
- var review = review_counts['revision_' + revision];
- var td = $(' | ',{
- 'class':'progress'
- });
- td.html(review.progress);
- $(this.parentNode.parentNode).append(td);
+ var header = $("table.changesets thead tr:first");
+ var th = $(' | ');
+ th.html(title);
+ header.append(th);
+ $('tr.changeset td.id a:first-child').each(function (i) {
+ var revision = this.getAttribute("href");
+ revision = revision.substr(revision.lastIndexOf("/") + 1);
+ var review = review_counts['revision_' + revision];
+ var td = $(' | ', {
+ 'class': 'progress'
});
- }
+ td.html(review.progress);
+ $(this.parentNode.parentNode).append(td);
+ });
+}
//add function $.down
-if(! $.fn.down)
-(function($) {
- $.fn.down = function() {
- var el = this[0] && this[0].firstChild;
- while (el && el.nodeType != 1)
- el = el.nextSibling;
- return $(el);
+if (!$.fn.down)
+ (function ($) {
+ $.fn.down = function () {
+ var el = this[0] && this[0].firstChild;
+ while (el && el.nodeType != 1)
+ el = el.nextSibling;
+ return $(el);
};
-})(jQuery);
+ })(jQuery);
function UpdateRevisionView() {
- $('li.change').each(function(){
- var li = $(this);
- if (li.hasClass('folder')) return;
-
- var a = li.down('a');
- if (a.size() == 0) return;
- var path = a.attr('href').replace(urlprefix, '').replace(/\?.*$/, '');
-
- var reviewlist = code_reviews_map[path];
- if (reviewlist == null) return;
-
- var ul = $('');
- for (var j = 0; j < reviewlist.length; j++) {
- var review = reviewlist[j];
- var icon = review.is_closed? 'icon-closed-review': 'icon-review';
- var item = $('', {
- 'class': 'icon ' + icon + ' code_review_summary'
- });
- item.html(review.url);
- ul.append(item);
- }
- li.append(ul);
- });
+ $('li.change').each(function () {
+ var li = $(this);
+ if (li.hasClass('folder')) return;
+
+ var a = li.down('a');
+ if (a.size() == 0) return;
+ var path = a.attr('href').replace(urlprefix, '').replace(/\?.*$/, '');
+
+ var reviewlist = code_reviews_map[path];
+ if (reviewlist == null) return;
+
+ var ul = $('');
+ for (var j = 0; j < reviewlist.length; j++) {
+ var review = reviewlist[j];
+ var icon = review.is_closed ? 'icon-closed-review' : 'icon-review';
+ var item = $('', {
+ 'class': 'icon ' + icon + ' code_review_summary'
+ });
+ item.html(review.url);
+ ul.append(item);
+ }
+ li.append(ul);
+ });
}
-function setAddReviewButton(url, change_id, image_tag, is_readonly, is_diff, attachment_id){
- var filetables = [];
- var j = 0;
- $('table').each(function(){
- if($(this).hasClass('filecontent')){
- filetables[j++] = this;
- }
- });
- j = 0;
- $('table.filecontent th.filename').each(function(){
- filenames[j] = $.trim($(this).text());
- j++;
- });
- addReviewUrl = url + '?change_id=' + change_id + '&action_type=' + action_type +
- '&rev=' + rev + '&rev_to=' + rev_to +
- '&attachment_id=' + attachment_id + '&repository_id=' + encodeURIComponent(repository_id);
- if (path != null && path.length > 0) {
- addReviewUrl = addReviewUrl + '&path=' + encodeURIComponent(path);
- }
- var num = 0;
- if (is_diff) {
- num = 1;
+function setAddReviewButton(url, change_id, image_tag, is_readonly, is_diff, attachment_id) {
+ var filetables = [];
+ var j = 0;
+ $('table').each(function () {
+ if ($(this).hasClass('filecontent')) {
+ filetables[j++] = this;
}
- var i, l, tl;
- for (i = 0, tl = filetables.length; i < tl; i++) {
- var table = filetables[i];
- var trs = table.getElementsByTagName('tr');
-
- for (j = 0,l = trs.length; j < l; j++) {
- var tr = trs[j];
- var ths = tr.getElementsByTagName('th');
-
- var th = ths[num];
- if (th == null) {
- continue;
- }
-
- var th_html = th.innerHTML;
-
- var line = th_html.match(/[0-9]+/);
- if (line == null) {
- continue;
- }
-
- var span_html = '';
-
- if (!is_readonly) {
- span_html += image_tag;
- }
- span_html += '';
- th.innerHTML = th_html + span_html;
-
- var img = th.getElementsByTagName('img')[0];
- if (img != null ) {
- img.id = 'add_revew_img_' + line + '_' + i;
- $(img).click(clickPencil);
- }
- }
+ });
+ j = 0;
+ $('table.filecontent th.filename').each(function () {
+ filenames[j] = $.trim($(this).text());
+ j++;
+ });
+ addReviewUrl = url + '?change_id=' + change_id + '&action_type=' + action_type +
+ '&rev=' + rev + '&rev_to=' + rev_to +
+ '&attachment_id=' + attachment_id + '&repository_id=' + encodeURIComponent(repository_id);
+ if (path != null && path.length > 0) {
+ addReviewUrl = addReviewUrl + '&path=' + encodeURIComponent(path);
+ }
+ var num = 0;
+ if (is_diff) {
+ num = 1;
+ }
+ var i, l, tl;
+ for (i = 0, tl = filetables.length; i < tl; i++) {
+ var table = filetables[i];
+ var trs = table.getElementsByTagName('tr');
+
+ for (j = 0, l = trs.length; j < l; j++) {
+ var tr = trs[j];
+ var ths = tr.getElementsByTagName('th');
+
+ var th = ths[num];
+ if (th == null) {
+ continue;
+ }
+
+ var th_html = th.innerHTML;
+
+ var line = th_html.match(/[0-9]+/);
+ if (line == null) {
+ continue;
+ }
+
+ var span_html = '';
+
+ if (!is_readonly) {
+ span_html += image_tag;
+ }
+ span_html += '';
+ th.innerHTML = th_html + span_html;
+
+ var img = th.getElementsByTagName('img')[0];
+ if (img != null) {
+ img.id = 'add_revew_img_' + line + '_' + i;
+ $(img).click(clickPencil);
+ }
}
+ }
}
-function clickPencil(e)
-{
-// alert('$(e.target).attr("id") = ' + $(e.target).attr("id"));
- var result = $(e.target).attr("id").match(/([0-9]+)_([0-9]+)/);
- var line = result[1];
- var file_count = eval(result[2]);
- var url = addReviewUrl + '&line=' + line + '&file_count=' + file_count;
-
- if (path == null || path.length == 0) {
- url = url + '&path=' + encodeURIComponent(filenames[file_count]) + '&diff_all=true';
- }
- addReview(url);
- formPopup(e.pageX, e.pageY);
- e.preventDefault();
+function clickPencil(e) {
+ // alert('$(e.target).attr("id") = ' + $(e.target).attr("id"));
+ var result = $(e.target).attr("id").match(/([0-9]+)_([0-9]+)/);
+ var line = result[1];
+ var file_count = eval(result[2]);
+ var url = addReviewUrl + '&line=' + line + '&file_count=' + file_count;
+
+ if (path == null || path.length == 0) {
+ url = url + '&path=' + encodeURIComponent(filenames[file_count]) + '&diff_all=true';
+ }
+ addReview(url);
+ formPopup(e.pageX, e.pageY);
+ e.preventDefault();
}
var addReviewUrl = null;
var showReviewUrl = null;
@@ -185,170 +184,186 @@ var showReviewImageTag = null;
var showClosedReviewImageTag = null;
function setShowReviewButton(line, review_id, is_closed, file_count) {
- //alert('file_count = ' + file_count);
- var span = $('#review_span_' + line + '_' + file_count);
- if (span.size() == 0) {
- return;
- }
- var innerSpan = $('',{id: 'review_' + review_id});
- span.append(innerSpan);
- innerSpan.html(is_closed? showClosedReviewImageTag : showReviewImageTag);
- var div = $('', {
- 'class':'draggable',
- id: 'show_review_' + review_id
- });
- $('#code_review').append(div);
- innerSpan.down('img').click(function(e) {
- var review_id = $(e.target).parent().attr('id').match(/[0-9]+/)[0];
- var span = $('#review_' + review_id); // span element of view review button
+ //alert('file_count = ' + file_count);
+ var span = $('#review_span_' + line + '_' + file_count);
+ if (span.size() == 0) {
+ return;
+ }
+ var innerSpan = $('', {
+ id: 'review_' + review_id
+ });
+ span.append(innerSpan);
+ innerSpan.html(is_closed ? showClosedReviewImageTag : showReviewImageTag);
+ var div = $('', {
+ 'class': 'draggable',
+ id: 'show_review_' + review_id
+ });
+ $('#code_review').append(div);
+ innerSpan.down('img').click(function (e) {
+ var review_id = $(e.target).parent().attr('id').match(/[0-9]+/)[0];
+ var span = $('#review_' + review_id); // span element of view review button
var pos = span.offset();
- showReview(showReviewUrl, review_id, pos.left + 10 + 5, pos.top + 25);
- });
+ showReview(showReviewUrl, review_id, pos.left + 10 + 5, pos.top + 25);
+ });
}
function popupReview(review_id) {
- var span = $('#review_' + review_id); // span element of view review button
- var pos = span.offset();
- $('html,body').animate({ scrollTop: pos.top },
- {duration: 'fast',
- complete: function(){showReview(showReviewUrl, review_id, pos.left + 10 + 5, pos.top)}});
- // position and show popup dialog
- // create popup dialog
- //var win = showReview(showReviewUrl, review_id, pos.left + 10 + 5, pos.top);
-// win.toFront();
+ var span = $('#review_' + review_id); // span element of view review button
+ var pos = span.offset();
+ $('html,body').animate({
+ scrollTop: pos.top
+ }, {
+ duration: 'fast',
+ complete: function () {
+ showReview(showReviewUrl, review_id, pos.left + 10 + 5, pos.top)
+ }
+ });
+ // position and show popup dialog
+ // create popup dialog
+ //var win = showReview(showReviewUrl, review_id, pos.left + 10 + 5, pos.top);
+ // win.toFront();
}
function showReview(url, review_id, x, y) {
- if (code_reviews_dialog_map[review_id] != null) {
- var cur_win = code_reviews_dialog_map[review_id];
- cur_win.hide();
- code_reviews_dialog_map[review_id] = null;
- }
- $('#show_review_' + review_id).load(url, {review_id: review_id});
- var review = getReviewObjById(review_id);
-
- var win = $('#show_review_' + review_id).dialog({
- show: {effect:'scale'},// ? 'top-left'
- //position: [x, y + 5],
- width:640,
- zIndex: topZindex,
- title: review_dialog_title
- });
-// win.getContent().style.color = "#484848";
-// win.getContent().style.background = "#ffffff";
- topZindex++;
- code_reviews_dialog_map[review_id] = win;
- return win
+ if (code_reviews_dialog_map[review_id] != null) {
+ var cur_win = code_reviews_dialog_map[review_id];
+ cur_win.hide();
+ code_reviews_dialog_map[review_id] = null;
+ }
+ $('#show_review_' + review_id).load(url, {
+ review_id: review_id
+ });
+ var review = getReviewObjById(review_id);
+
+ var win = $('#show_review_' + review_id).dialog({
+ show: {
+ effect: 'scale'
+ }, // ? 'top-left'
+ //position: [x, y + 5],
+ width: 640,
+ zIndex: topZindex,
+ title: review_dialog_title
+ });
+ // win.getContent().style.color = "#484848";
+ // win.getContent().style.background = "#ffffff";
+ topZindex++;
+ code_reviews_dialog_map[review_id] = win;
+ $('.ui-dialog').appendTo('#content');
+ $('.ui-effects-wrapper').zIndex(0);
+ return win
}
function getReviewObjById(review_id) {
- for (var reviewlist in code_reviews_map) {
- for (var i = 0; i < reviewlist.length; i++) {
- var review = reviewlist[i];
- if (review.id == review_id) {
- return review;
- }
- }
+ for (var reviewlist in code_reviews_map) {
+ for (var i = 0; i < reviewlist.length; i++) {
+ var review = reviewlist[i];
+ if (review.id == review_id) {
+ return review;
+ }
}
- return null;
+ }
+ return null;
}
-function formPopup(x, y){
- //@see http://docs.jquery.com/UI/Effects/Scale
- var win = $('#review-form-frame').dialog({
- show: {effect:'scale', direction: 'both'},// ? 'top-left'
-// position: [x, y + 5],
- width:640,
- zIndex: topZindex,
- title: add_form_title
- });
-// win.getContent().style.background = "#ffffff";
- if (review_form_dialog != null) {
- review_form_dialog.destroy();
- review_form_dialog = null;
- }
- review_form_dialog = win;
- topZindex += 10;
- return false;
+function formPopup(x, y) {
+ //@see http://docs.jquery.com/UI/Effects/Scale
+ var win = $('#review-form-frame').dialog({
+ show: {
+ effect: 'scale',
+ direction: 'both'
+ }, // ? 'top-left'
+ // position: [x, y + 5],
+ width: 640,
+ zIndex: topZindex,
+ title: add_form_title
+ });
+ // win.getContent().style.background = "#ffffff";
+ if (review_form_dialog != null) {
+ review_form_dialog.destroy();
+ review_form_dialog = null;
+ }
+ review_form_dialog = win;
+ topZindex += 10;
+ $('.ui-dialog').appendTo('#content');
+ $('.ui-effects-wrapper').zIndex(0);
+ return false;
}
function hideForm() {
- if (review_form_dialog == null) {
- return;
- }
- review_form_dialog.dialog('close');
- review_form_dialog = null;
- $('#review-form').html('');
+ if (review_form_dialog == null) {
+ return;
+ }
+ review_form_dialog.dialog('close');
+ review_form_dialog = null;
+ $('#review-form').html('');
}
+
function addReview(url) {
- $('#review-form').load(url);
+ $('#review-form').load(url);
}
function deleteReview(review_id) {
- $('show_review_' + review_id).remove();
- $('review_' + review_id).remove();
-
+ $('show_review_' + review_id).remove();
+ $('review_' + review_id).remove();
+
}
function changeImage(review_id, is_closed) {
- var span = $('review_' + review_id);
- var new_image = null;
- var dummy = new Element('span');
- if (is_closed) {
- dummy.insert(showClosedReviewImageTag);
- }
- else {
- dummy.insert(showReviewImageTag);
- }
- new_image = dummy.down().getAttribute('src');
- //alert(new_image);
- span.down('img').setAttribute('src', new_image);
+ var span = $('review_' + review_id);
+ var new_image = null;
+ var dummy = new Element('span');
+ if (is_closed) {
+ dummy.insert(showClosedReviewImageTag);
+ } else {
+ dummy.insert(showReviewImageTag);
+ }
+ new_image = dummy.down().getAttribute('src');
+ //alert(new_image);
+ span.down('img').setAttribute('src', new_image);
}
function make_addreview_link(project, link) {
- var alist = $('div.tabs ul li a#tab-entry');
- if (alist == null) {
- return;
- }
- var a = alist[0];
- var p = a.parentNode.parentNode;
- p.innerHTML = p.innerHTML + link;
+ var alist = $('div.tabs ul li a#tab-entry');
+ if (alist == null) {
+ return;
+ }
+ var a = alist[0];
+ var p = a.parentNode.parentNode;
+ p.innerHTML = p.innerHTML + link;
}
function call_update_revisions(url) {
- var changeset_ids = '';
- var links = $$('table.changesets tbody tr.changeset td.id a');
- for (var i = 0; i < links.length; i++) {
- var link = links[i];
- var href = link.getAttribute('href');
- var id = href.replace(/^.*\/revisions\//, '');
- if (i > 0) {
- changeset_ids += ',';
- }
- changeset_ids += id;
+ var changeset_ids = '';
+ var links = $$('table.changesets tbody tr.changeset td.id a');
+ for (var i = 0; i < links.length; i++) {
+ var link = links[i];
+ var href = link.getAttribute('href');
+ var id = href.replace(/^.*\/revisions\//, '');
+ if (i > 0) {
+ changeset_ids += ',';
}
- new Ajax.Updater('code_review_revisions', url,
- {
- evalScripts:true,
- method:'get',
- parameters: 'changeset_ids=' + encodeURI(changeset_ids)
- });
+ changeset_ids += id;
+ }
+ new Ajax.Updater('code_review_revisions', url, {
+ evalScripts: true,
+ method: 'get',
+ parameters: 'changeset_ids=' + encodeURI(changeset_ids)
+ });
}
-$.fn.serialize2json = function()
-{
- var o = {};
- var a = this.serializeArray();
- $.each(a, function() {
- if (o[this.name]) {
- if (!o[this.name].push) {
- o[this.name] = [o[this.name]];
- }
- o[this.name].push(this.value || '');
- } else {
- o[this.name] = this.value || '';
- }
- });
- return o;
+$.fn.serialize2json = function () {
+ var o = {};
+ var a = this.serializeArray();
+ $.each(a, function () {
+ if (o[this.name]) {
+ if (!o[this.name].push) {
+ o[this.name] = [o[this.name]];
+ }
+ o[this.name].push(this.value || '');
+ } else {
+ o[this.name] = this.value || '';
+ }
+ });
+ return o;
};
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index af39e4e..f4bb5be 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -19,4 +19,4 @@
#map.connect 'projects/:id/code_review/:action', :controller => 'code_review'
match 'projects/:id/code_review/:action', :controller => 'code_review', :via => [:get, :post]
match 'projects/:id/code_review_settings/:action', :controller => 'code_review_settings', :via => [:get, :post, :put, :patch]
-end
\ No newline at end of file
+end
diff --git a/db/migrate/0001_create_code_reviews.rb b/db/migrate/0001_create_code_reviews.rb
index 9410360..a01f11c 100644
--- a/db/migrate/0001_create_code_reviews.rb
+++ b/db/migrate/0001_create_code_reviews.rb
@@ -1,5 +1,5 @@
# Code Review plugin for Redmine
-# Copyright (C) 2009 Haruyuki Iida
+# Copyright (C) 2009-2017 Haruyuki Iida
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -15,10 +15,9 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-class CreateCodeReviews < ActiveRecord::Migration
+class CreateCodeReviews < ActiveRecord::Migration[4.2]
def self.up
create_table :code_reviews do |t|
-
t.column :project_id, :integer
t.column :parent_id, :integer
@@ -36,7 +35,6 @@ def self.up
t.column :status, :integer
t.column :line, :integer
-
end
end
diff --git a/db/migrate/0002_add_updated_by.rb b/db/migrate/0002_add_updated_by.rb
index 21d8959..fec07e5 100644
--- a/db/migrate/0002_add_updated_by.rb
+++ b/db/migrate/0002_add_updated_by.rb
@@ -1,5 +1,5 @@
# Code Review plugin for Redmine
-# Copyright (C) 2009 Haruyuki Iida
+# Copyright (C) 2009-2017 Haruyuki Iida
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -15,8 +15,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-class AddUpdatedBy < ActiveRecord::Migration
-
+class AddUpdatedBy < ActiveRecord::Migration[4.2]
def self.up
add_column(:code_reviews, "updated_by_id", :integer)
end
diff --git a/db/migrate/0003_add_lock_version.rb b/db/migrate/0003_add_lock_version.rb
index 0ddb0ec..51a777d 100644
--- a/db/migrate/0003_add_lock_version.rb
+++ b/db/migrate/0003_add_lock_version.rb
@@ -1,5 +1,5 @@
# Code Review plugin for Redmine
-# Copyright (C) 2009 Haruyuki Iida
+# Copyright (C) 2009-2017 Haruyuki Iida
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -15,10 +15,9 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-class AddLockVersion < ActiveRecord::Migration
-
+class AddLockVersion < ActiveRecord::Migration[4.2]
def self.up
- add_column(:code_reviews, "lock_version", :integer, :default=>0, :null => false)
+ add_column(:code_reviews, "lock_version", :integer, :default => 0, :null => false)
end
def self.down
diff --git a/db/migrate/0004_add_status_changed.rb b/db/migrate/0004_add_status_changed.rb
index ab110e1..de0d9df 100644
--- a/db/migrate/0004_add_status_changed.rb
+++ b/db/migrate/0004_add_status_changed.rb
@@ -1,5 +1,5 @@
# Code Review plugin for Redmine
-# Copyright (C) 2009 Haruyuki Iida
+# Copyright (C) 2009-2017 Haruyuki Iida
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -15,8 +15,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-class AddStatusChanged < ActiveRecord::Migration
-
+class AddStatusChanged < ActiveRecord::Migration[4.2]
def self.up
add_column(:code_reviews, "status_changed_from", :integer)
add_column(:code_reviews, "status_changed_to", :integer)
diff --git a/db/migrate/0005_create_code_review_user_settings.rb b/db/migrate/0005_create_code_review_user_settings.rb
index e61a2a3..43fd11f 100644
--- a/db/migrate/0005_create_code_review_user_settings.rb
+++ b/db/migrate/0005_create_code_review_user_settings.rb
@@ -1,5 +1,5 @@
# Code Review plugin for Redmine
-# Copyright (C) 2009 Haruyuki Iida
+# Copyright (C) 2009-2017 Haruyuki Iida
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -14,18 +14,16 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-class CreateCodeReviewUserSettings < ActiveRecord::Migration
+class CreateCodeReviewUserSettings < ActiveRecord::Migration[4.2]
def self.up
create_table :code_review_user_settings do |t|
+ t.column :user_id, :integer, :default => 0, :null => false
- t.column :user_id, :integer, :default=>0, :null => false
-
- t.column :mail_notification, :integer, :default=>0, :null => false
+ t.column :mail_notification, :integer, :default => 0, :null => false
t.column :created_at, :timestamp
t.column :updated_at, :timestamp
-
end
end
diff --git a/db/migrate/0006_link_to_issue.rb b/db/migrate/0006_link_to_issue.rb
index 9d3ecb7..4193136 100644
--- a/db/migrate/0006_link_to_issue.rb
+++ b/db/migrate/0006_link_to_issue.rb
@@ -1,5 +1,5 @@
# Code Review plugin for Redmine
-# Copyright (C) 2009 Haruyuki Iida
+# Copyright (C) 2009-2017 Haruyuki Iida
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -15,8 +15,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-class LinkToIssue < ActiveRecord::Migration
-
+class LinkToIssue < ActiveRecord::Migration[4.2]
def self.up
add_column(:code_reviews, "issue_id", :integer)
rename_column(:code_reviews, "status", "old_status")
diff --git a/db/migrate/0007_rename_user.rb b/db/migrate/0007_rename_user.rb
index 6a66866..19439b9 100644
--- a/db/migrate/0007_rename_user.rb
+++ b/db/migrate/0007_rename_user.rb
@@ -1,5 +1,5 @@
# Code Review plugin for Redmine
-# Copyright (C) 2009 Haruyuki Iida
+# Copyright (C) 2009-2017 Haruyuki Iida
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -15,13 +15,12 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-class RenameUser < ActiveRecord::Migration
-
+class RenameUser < ActiveRecord::Migration[4.2]
def self.up
rename_column(:code_reviews, "user_id", "old_user_id")
end
def self.down
- rename_column(:code_reviews, "old_user_id", "user_id")
+ rename_column(:code_reviews, "old_user_id", "user_id")
end
end
diff --git a/db/migrate/0008_create_code_review_project_settings.rb b/db/migrate/0008_create_code_review_project_settings.rb
index 5bfdc8a..e0bcc9d 100644
--- a/db/migrate/0008_create_code_review_project_settings.rb
+++ b/db/migrate/0008_create_code_review_project_settings.rb
@@ -1,5 +1,5 @@
# Code Review plugin for Redmine
-# Copyright (C) 2009 Haruyuki Iida
+# Copyright (C) 2009-2017 Haruyuki Iida
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -14,10 +14,9 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-class CreateCodeReviewProjectSettings < ActiveRecord::Migration
+class CreateCodeReviewProjectSettings < ActiveRecord::Migration[4.2]
def self.up
create_table :code_review_project_settings do |t|
-
t.column :project_id, :integer
t.column :tracker_id, :integer
@@ -27,7 +26,6 @@ def self.up
t.column :updated_at, :timestamp
t.column :updated_by, :integer
-
end
end
diff --git a/db/migrate/0009_add_hide_tab.rb b/db/migrate/0009_add_hide_tab.rb
index ca09e29..319862e 100644
--- a/db/migrate/0009_add_hide_tab.rb
+++ b/db/migrate/0009_add_hide_tab.rb
@@ -1,5 +1,5 @@
# Code Review plugin for Redmine
-# Copyright (C) 2009 Haruyuki Iida
+# Copyright (C) 2009-2017 Haruyuki Iida
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -15,8 +15,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-class AddHideTab < ActiveRecord::Migration
-
+class AddHideTab < ActiveRecord::Migration[4.2]
def self.up
add_column(:code_review_project_settings, "hide_code_review_tab", :boolean, :default => false)
end
diff --git a/db/migrate/0010_add_action_type.rb b/db/migrate/0010_add_action_type.rb
index a64e306..49eaa51 100644
--- a/db/migrate/0010_add_action_type.rb
+++ b/db/migrate/0010_add_action_type.rb
@@ -1,5 +1,5 @@
# Code Review plugin for Redmine
-# Copyright (C) 2009 Haruyuki Iida
+# Copyright (C) 2009-2017 Haruyuki Iida
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -15,8 +15,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-class AddActionType < ActiveRecord::Migration
-
+class AddActionType < ActiveRecord::Migration[4.2]
def self.up
add_column(:code_reviews, "action_type", :string)
add_column(:code_reviews, "file_path", :string)
diff --git a/db/migrate/0011_add_auto_relation.rb b/db/migrate/0011_add_auto_relation.rb
index ee8fe73..8a4e2cd 100644
--- a/db/migrate/0011_add_auto_relation.rb
+++ b/db/migrate/0011_add_auto_relation.rb
@@ -1,5 +1,5 @@
# Code Review plugin for Redmine
-# Copyright (C) 2009 Haruyuki Iida
+# Copyright (C) 2009-2017 Haruyuki Iida
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -15,13 +15,12 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-class AddAutoRelation < ActiveRecord::Migration
-
+class AddAutoRelation < ActiveRecord::Migration[4.2]
def self.up
add_column(:code_review_project_settings, "auto_relation", :integer, :default => 1)
end
def self.down
- remove_column(:code_review_project_settings, "auto_relation")
+ remove_column(:code_review_project_settings, "auto_relation")
end
end
diff --git a/db/migrate/0012_add_attachment_id.rb b/db/migrate/0012_add_attachment_id.rb
index ec2e7a0..7acfbdf 100644
--- a/db/migrate/0012_add_attachment_id.rb
+++ b/db/migrate/0012_add_attachment_id.rb
@@ -1,5 +1,5 @@
# Code Review plugin for Redmine
-# Copyright (C) 2009 Haruyuki Iida
+# Copyright (C) 2009-2017 Haruyuki Iida
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -15,8 +15,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-class AddAttachmentId < ActiveRecord::Migration
-
+class AddAttachmentId < ActiveRecord::Migration[4.2]
def self.up
add_column(:code_reviews, "attachment_id", :integer)
end
diff --git a/db/migrate/0013_add_file_count.rb b/db/migrate/0013_add_file_count.rb
index 464d046..2cfee35 100644
--- a/db/migrate/0013_add_file_count.rb
+++ b/db/migrate/0013_add_file_count.rb
@@ -1,5 +1,5 @@
# Code Review plugin for Redmine
-# Copyright (C) 2009 Haruyuki Iida
+# Copyright (C) 2009-2017 Haruyuki Iida
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -15,8 +15,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-class AddFileCount < ActiveRecord::Migration
-
+class AddFileCount < ActiveRecord::Migration[4.2]
def self.up
add_column(:code_reviews, "file_count", :integer, :default => 0, :null => false)
end
diff --git a/db/migrate/0014_create_code_review_assignments.rb b/db/migrate/0014_create_code_review_assignments.rb
index a582d31..b2f483f 100644
--- a/db/migrate/0014_create_code_review_assignments.rb
+++ b/db/migrate/0014_create_code_review_assignments.rb
@@ -1,5 +1,5 @@
# Code Review plugin for Redmine
-# Copyright (C) 2010 Haruyuki Iida
+# Copyright (C) 2010-2017 Haruyuki Iida
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -15,10 +15,9 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-class CreateCodeReviewAssignments < ActiveRecord::Migration
+class CreateCodeReviewAssignments < ActiveRecord::Migration[4.2]
def self.up
create_table :code_review_assignments do |t|
-
t.column :issue_id, :int
t.column :change_id, :int
@@ -32,7 +31,6 @@ def self.up
t.column :rev_to, :string
t.column :action_type, :string
-
end
end
diff --git a/db/migrate/0015_add_assignment_tracker.rb b/db/migrate/0015_add_assignment_tracker.rb
index 08567e2..7c8d34b 100644
--- a/db/migrate/0015_add_assignment_tracker.rb
+++ b/db/migrate/0015_add_assignment_tracker.rb
@@ -1,5 +1,5 @@
# Code Review plugin for Redmine
-# Copyright (C) 2009 Haruyuki Iida
+# Copyright (C) 2009-2017 Haruyuki Iida
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -15,8 +15,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-class AddAssignmentTracker < ActiveRecord::Migration
-
+class AddAssignmentTracker < ActiveRecord::Migration[4.2]
def self.up
add_column(:code_review_project_settings, "assignment_tracker_id", :integer)
end
diff --git a/db/migrate/0016_add_changeset_id.rb b/db/migrate/0016_add_changeset_id.rb
index 96536e8..d916905 100644
--- a/db/migrate/0016_add_changeset_id.rb
+++ b/db/migrate/0016_add_changeset_id.rb
@@ -1,5 +1,5 @@
# Code Review plugin for Redmine
-# Copyright (C) 2009 Haruyuki Iida
+# Copyright (C) 2009-2017 Haruyuki Iida
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -15,8 +15,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-class AddChangesetId < ActiveRecord::Migration
-
+class AddChangesetId < ActiveRecord::Migration[4.2]
def self.up
add_column(:code_review_assignments, "changeset_id", :integer)
end
diff --git a/db/migrate/0017_add_auto_assign.rb b/db/migrate/0017_add_auto_assign.rb
index 6e9c6fe..0135a3b 100644
--- a/db/migrate/0017_add_auto_assign.rb
+++ b/db/migrate/0017_add_auto_assign.rb
@@ -1,5 +1,5 @@
# Code Review plugin for Redmine
-# Copyright (C) 2009-2010 Haruyuki Iida
+# Copyright (C) 2009-2017 Haruyuki Iida
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -15,8 +15,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-class AddAutoAssign < ActiveRecord::Migration
-
+class AddAutoAssign < ActiveRecord::Migration[4.2]
def self.up
add_column(:code_review_project_settings, "auto_assign", :text)
end
diff --git a/db/migrate/0018_add_lock_version_to_project_settings.rb b/db/migrate/0018_add_lock_version_to_project_settings.rb
index c6ba8cf..47d88b8 100644
--- a/db/migrate/0018_add_lock_version_to_project_settings.rb
+++ b/db/migrate/0018_add_lock_version_to_project_settings.rb
@@ -1,5 +1,5 @@
# Code Review plugin for Redmine
-# Copyright (C) 2009-2010 Haruyuki Iida
+# Copyright (C) 2009-2017 Haruyuki Iida
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -15,8 +15,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-class AddLockVersionToProjectSettings < ActiveRecord::Migration
-
+class AddLockVersionToProjectSettings < ActiveRecord::Migration[4.2]
def self.up
add_column(:code_review_project_settings, "lock_version", :integer, :null => false, :default => 0)
end
diff --git a/db/migrate/0019_delete_old_fields.rb b/db/migrate/0019_delete_old_fields.rb
index ab9744b..c5cca80 100644
--- a/db/migrate/0019_delete_old_fields.rb
+++ b/db/migrate/0019_delete_old_fields.rb
@@ -1,5 +1,5 @@
# Code Review plugin for Redmine
-# Copyright (C) 2012 Haruyuki Iida
+# Copyright (C) 2012-2017 Haruyuki Iida
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -15,8 +15,8 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-class DeleteOldFields < ActiveRecord::Migration
- OLD_FIELDS=["old_parent_id", "old_user_id", "old_comment", "old_status"]
+class DeleteOldFields < ActiveRecord::Migration[4.2]
+ OLD_FIELDS = ["old_parent_id", "old_user_id", "old_comment", "old_status"]
def self.up
remove_column(:code_reviews, "old_parent_id")
remove_column(:code_reviews, "old_user_id")
diff --git a/db/migrate/0020_add_tracker_to_review_dialog.rb b/db/migrate/0020_add_tracker_to_review_dialog.rb
index 8b9daa4..05d358c 100644
--- a/db/migrate/0020_add_tracker_to_review_dialog.rb
+++ b/db/migrate/0020_add_tracker_to_review_dialog.rb
@@ -1,5 +1,5 @@
# Code Review plugin for Redmine
-# Copyright (C) 2009-2012 Haruyuki Iida
+# Copyright (C) 2009-2017 Haruyuki Iida
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -15,9 +15,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
-class AddTrackerToReviewDialog < ActiveRecord::Migration
-
+class AddTrackerToReviewDialog < ActiveRecord::Migration[4.2]
def self.up
add_column(:code_review_project_settings, "tracker_in_review_dialog", :boolean, :default => false)
end
@@ -25,4 +23,4 @@ def self.up
def self.down
remove_column(:code_review_project_settings, "tracker_in_review_dialog")
end
-end
\ No newline at end of file
+end
diff --git a/db/migrate/0021_add_diff_all.rb b/db/migrate/0021_add_diff_all.rb
index 44ee539..fd8ddda 100644
--- a/db/migrate/0021_add_diff_all.rb
+++ b/db/migrate/0021_add_diff_all.rb
@@ -1,5 +1,5 @@
# Code Review plugin for Redmine
-# Copyright (C) 2013 Haruyuki Iida
+# Copyright (C) 2013-2017 Haruyuki Iida
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -15,7 +15,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-class AddDiffAll < ActiveRecord::Migration
+class AddDiffAll < ActiveRecord::Migration[4.2]
def self.up
add_column(:code_reviews, "diff_all", :boolean)
end
@@ -23,4 +23,4 @@ def self.up
def self.down
remove_column(:code_reviews, "diff_all")
end
-end
\ No newline at end of file
+end
diff --git a/init.rb b/init.rb
index 1d35765..d0f8bf4 100644
--- a/init.rb
+++ b/init.rb
@@ -1,5 +1,5 @@
# Code Review plugin for Redmine
-# Copyright (C) 2009-2017 Haruyuki Iida
+# Copyright (C) 2009-2018 Haruyuki Iida
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -41,24 +41,19 @@
Issue.send(:include, CodeReviewIssuePatch)
end
- unless ProjectsHelper.included_modules.include? CodeReviewProjectsHelperPatch
- ProjectsHelper.send(:include, CodeReviewProjectsHelperPatch)
- end
-
unless Attachment.included_modules.include? CodeReviewAttachmentPatch
Attachment.send(:include, CodeReviewAttachmentPatch)
end
-
end
Redmine::Plugin.register :redmine_code_review do
name 'Redmine Code Review plugin'
author 'Haruyuki Iida'
author_url 'http://twitter.com/haru_iida'
- url "http://www.r-labs.org/projects/show/codereview" if respond_to?(:url)
+ url "http://www.redmine.org/plugins/redmine_code_review" if respond_to?(:url)
description 'This is a Code Review plugin for Redmine'
- version '0.9.0'
- requires_redmine :version_or_higher => '3.4.0'
+ version '1.0.0'
+ requires_redmine :version_or_higher => '4.0.0'
project_module :code_review do
permission :view_code_review, {:code_review => [:update_diff_view, :update_attachment_view, :update_revisions_view, :index, :show]}, {:read => true}
@@ -67,15 +62,13 @@
permission :delete_code_review, {:code_review => [:destroy]}, :require => :member
permission :assign_code_review, {:code_review => [:assign]}, :require => :member
permission :code_review_setting, {:code_review_settings => [:show, :update, :add_filter, :edit_filter, :sort]}, :require => :member
-
end
- menu :project_menu, :code_review, { :controller => 'code_review', :action => 'index' }, :caption => :code_reviews,
- :if => Proc.new{|project|
- setting = CodeReviewProjectSetting.find_or_create(project)
- project.repository != nil and setting and !setting.hide_code_review_tab
- }, :after => :repository
-
+ menu :project_menu, :code_review, {:controller => 'code_review', :action => 'index'}, :caption => :code_reviews,
+ :if => Proc.new { |project|
+ setting = CodeReviewProjectSetting.find_or_create(project)
+ project.repository != nil and setting and !setting.hide_code_review_tab
+ }, :after => :repository
Redmine::WikiFormatting::Macros.register do
desc "This is my macro link to code review"
@@ -86,8 +79,6 @@
review = CodeReview.find(review_id)
return nil unless review
link_to(l(:label_review) + '#' + review.id.to_s, :controller => 'code_review', :action => 'show', :id => review.project, :review_id => review.id)
-
end
end
-
end
diff --git a/lib/code_review_application_hooks.rb b/lib/code_review_application_hooks.rb
index 5e7b0a4..af9c87f 100644
--- a/lib/code_review_application_hooks.rb
+++ b/lib/code_review_application_hooks.rb
@@ -16,6 +16,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require 'redmine/utils'
+
class CodeReviewApplicationHooks < Redmine::Hook::ViewListener
render_on :view_layouts_base_html_head, :partial => 'code_review/html_header'
render_on :view_layouts_base_body_bottom, :partial => 'code_review/body_bottom'
diff --git a/lib/code_review_attachment_patch.rb b/lib/code_review_attachment_patch.rb
index 1b1ccb1..41c2047 100644
--- a/lib/code_review_attachment_patch.rb
+++ b/lib/code_review_attachment_patch.rb
@@ -25,14 +25,9 @@ def self.included(base) # :nodoc:
unloadable # Send unloadable so it will not be unloaded in development
has_many :code_reviews
has_many :code_review_assignments
-
end
-
end
end
module AttachmentInstanceMethodsCodeReview
-
end
-
-
diff --git a/lib/code_review_auto_assign_settings.rb b/lib/code_review_auto_assign_settings.rb
index 5dd5b97..2c58c2a 100644
--- a/lib/code_review_auto_assign_settings.rb
+++ b/lib/code_review_auto_assign_settings.rb
@@ -21,7 +21,7 @@ def initialize(yml_string = nil)
yml_string = {:enabled => false}.to_yaml if yml_string.blank?
load_yml(yml_string)
end
-
+
def self.load(yml_string)
AutoAssignSettings.new(yml_string)
end
@@ -49,7 +49,7 @@ def assignable_list=(list)
def assignable_list
return nil unless yml[:assignable_list]
- yml[:assignable_list].collect { |id| id.to_i }
+ yml[:assignable_list].collect { |id| id.to_i }
end
def assignable?(user)
@@ -86,7 +86,6 @@ def filter_enabled?
yml[:filter_enabled] == true or yml[:filter_enabled] == 'true'
end
-
def to_s
return YAML.dump(yml)
nil
@@ -94,7 +93,7 @@ def to_s
def filters=(list)
unless list
- return yml[:filters] = nil
+ return yml[:filters] = nil
end
yml[:filters] = list.collect do |filter|
filter.attributes
@@ -105,10 +104,10 @@ def filters
return [] unless yml[:filters]
list = yml[:filters].collect do |hash|
filter = AssignmentFilter.new
- filter.attributes=(hash)
+ filter.attributes = (hash)
filter
end
- list.sort {|a, b| a.order <=> b.order}
+ list.sort { |a, b| a.order <=> b.order }
end
def add_filter(filter)
@@ -126,8 +125,8 @@ def accept_for_default
def match_with_changeset?(changeset)
return true unless filter_enabled?
- changeset.filechanges.each{|change|
- return if match_with_change?(change)
+ changeset.filechanges.each { |change|
+ return if match_with_change?(change)
}
return false
end
@@ -143,7 +142,7 @@ def match_with_change?(change)
def attributes
yml
end
-
+
private
def yml
@@ -161,7 +160,7 @@ def load_yml(yml_string)
def select_assign_to_with_list(project, list, commiter_id = nil)
return nil unless list
return nil if list.empty?
- list.collect!{|item| item.to_i}
+ list.collect! { |item| item.to_i }
list.delete(commiter_id)
return nil if list.empty?
assign_to = list.at(rand(list.size))
diff --git a/lib/code_review_change_patch.rb b/lib/code_review_change_patch.rb
index 95f9f9e..0e2ad96 100644
--- a/lib/code_review_change_patch.rb
+++ b/lib/code_review_change_patch.rb
@@ -26,9 +26,7 @@ def self.included(base) # :nodoc:
has_many :code_reviews, :dependent => :destroy
has_many :code_review_assignments, :dependent => :destroy
after_save :review_auto_assign
-
end
-
end
end
@@ -37,7 +35,7 @@ module ChangeInstanceMethodsCodeReview
# for review_issues
#
def review_count
- code_reviews.select{|o|
+ code_reviews.select { |o|
o.issue_id != nil
}.length
end
@@ -55,7 +53,7 @@ def open_review_count
def closed_review_count
closed_reviews.length
end
-
+
def closed_reviews
@closed_reviews ||= code_reviews.select do |o|
o.issue_id != nil and o.is_closed?
@@ -94,4 +92,3 @@ def review_auto_assign
CodeReviewAssignment.create_with_changeset(changeset)
end
end
-
diff --git a/lib/code_review_changeset_patch.rb b/lib/code_review_changeset_patch.rb
index c68d7a4..7300ece 100644
--- a/lib/code_review_changeset_patch.rb
+++ b/lib/code_review_changeset_patch.rb
@@ -19,14 +19,10 @@
module CodeReviewChangesetPatch
def self.included(base) # :nodoc:
- base.send(:include, ChangesetInstanceMethodsCodeReview)
-
base.class_eval do
unloadable # Send unloadable so it will not be unloaded in development
has_many :code_review_assignments, :dependent => :destroy
- alias_method_chain :scan_comment_for_issue_ids, :code_review
end
-
end
end
@@ -37,7 +33,7 @@ module ChangesetInstanceMethodsCodeReview
def review_count
return @review_count if @review_count
@review_count = 0
- filechanges.each{|change|
+ filechanges.each { |change|
@review_count += change.review_count
}
return @review_count
@@ -46,7 +42,7 @@ def review_count
def open_review_count
return @open_review_count if @open_review_count
@open_review_count = 0
- filechanges.each{|change|
+ filechanges.each { |change|
@open_review_count += change.open_review_count
}
return @open_review_count
@@ -63,11 +59,11 @@ def open_reviews
def review_issues
return @review_issues if @review_issues
- filechanges.each{|change|
+ filechanges.each { |change|
unless @review_issues
- @review_issues = change.code_reviews.collect{|issue| issue}
+ @review_issues = change.code_reviews.collect { |issue| issue }
else
- @review_issues = @review_issues + change.code_reviews.collect{|issue| issue}
+ @review_issues = @review_issues + change.code_reviews.collect { |issue| issue }
end
@review_issues
}
@@ -91,9 +87,9 @@ def completed_review_pourcent
elsif open_review_count == 0
100
else
- @completed_review_pourcent ||= (closed_review_count * 100 + open_reviews.collect{|o|
+ @completed_review_pourcent ||= (closed_review_count * 100 + open_reviews.collect { |o|
o.issue.done_ratio
- }.inject(:+))/review_count
+ }.inject(:+)) / review_count
end
end
@@ -104,7 +100,7 @@ def completed_review_pourcent
def assignment_count
#return @assignment_count if @assignment_count
@assignment_count = code_review_assignments.length
- filechanges.each{|change|
+ filechanges.each { |change|
@assignment_count += change.assignment_count
}
return @assignment_count
@@ -112,10 +108,10 @@ def assignment_count
def open_assignment_count
return @open_assignment_count if @open_assignment_count
- @open_assignment_count = code_review_assignments.select {|assignment|
+ @open_assignment_count = code_review_assignments.select { |assignment|
!assignment.is_closed?
}.length
- filechanges.each{|change|
+ filechanges.each { |change|
@open_assignment_count += change.open_assignment_count
}
return @open_assignment_count
@@ -124,20 +120,19 @@ def open_assignment_count
def assignment_issues
return @assignment_issues if @assignment_issues
@assignment_issues = code_review_assignments
- filechanges.each{|change|
- @assignment_issues = @assignment_issues + change.code_review_assignments.collect{|issue| issue}
+ filechanges.each { |change|
+ @assignment_issues = @assignment_issues + change.code_review_assignments.collect { |issue| issue }
}
@assignment_issues
-
end
def open_assignments
return @open_assignments if @open_assignments
- @open_assignments = code_review_assignments.select {|assignment|
+ @open_assignments = code_review_assignments.select { |assignment|
!assignment.is_closed?
}
- filechanges.each{|change|
- @open_assignments = @open_assignments + change.code_review_assignments.select {|assignment|
+ filechanges.each { |change|
+ @open_assignments = @open_assignments + change.code_review_assignments.select { |assignment|
!assignment.is_closed?
}
}
@@ -162,18 +157,17 @@ def completed_assignment_pourcent
100
else
opens = open_assignments
- @completed_assignment_pourcent ||= (closed_assignment_count * 100 + open_assignments.collect{|o|
+ @completed_assignment_pourcent ||= (closed_assignment_count * 100 + open_assignments.collect { |o|
o.issue.done_ratio
- }.sum)/assignment_count
-
+ }.sum) / assignment_count
end
end
#
# changeset作成時にレビューの自動アサインを行う
#
- def scan_comment_for_issue_ids_with_code_review
- ret = scan_comment_for_issue_ids_without_code_review
+ def scan_comment_for_issue_ids
+ ret = super
project = repository.project if repository
return ret unless project
return ret unless project.module_enabled?('code_review')
@@ -186,4 +180,4 @@ def scan_comment_for_issue_ids_with_code_review
end
end
-
+Changeset.prepend(ChangesetInstanceMethodsCodeReview)
diff --git a/lib/code_review_issue_hooks.rb b/lib/code_review_issue_hooks.rb
index f1326dd..aefd423 100644
--- a/lib/code_review_issue_hooks.rb
+++ b/lib/code_review_issue_hooks.rb
@@ -18,7 +18,8 @@
class CodeReviewIssueHooks < Redmine::Hook::ViewListener
include RepositoriesHelper
render_on :view_issues_show_details_bottom, :partial => 'code_review/issues_show_details_bottom'
- def view_issues_show_details_bottom_org(context = { })
+
+ def view_issues_show_details_bottom_org(context = {})
project = context[:project]
return '' unless project
unless User.current.allowed_to?({:controller => 'code_review', :action => 'show'}, project)
@@ -36,7 +37,7 @@ def view_issues_show_details_bottom_org(context = { })
return o
end
- def view_issues_form_details_bottom(context = { })
+ def view_issues_form_details_bottom(context = {})
project = context[:project]
request = context[:request]
parameters = request.parameters
@@ -58,11 +59,10 @@ def view_issues_form_details_bottom(context = { })
o << "\n"
o << hidden_field_tag("code[attachment_id]", code[:attachment_id].to_i) unless code[:attachment_id].blank?
-
return o
end
-
- def controller_issues_new_after_save(context = { })
+
+ def controller_issues_new_after_save(context = {})
if context[:request] && context[:project] && context[:issue]
project = context[:project]
request = context[:request]
@@ -86,12 +86,13 @@ def controller_issues_new_after_save(context = { })
end
private
+
def create_review_info(project, review)
o = ''
o << "#{l(:code_review)}: | "
o << ''
o << link_to("#{review.repository_identifier + ':' if review.repository_identifier}#{review.path}#{'@' + review.revision if review.revision}:line #{review.line}",
- :controller => 'code_review', :action => 'show', :id => project, :review_id => review.id, :repository_id => review.repository_identifier)
+ :controller => 'code_review', :action => 'show', :id => project, :review_id => review.id, :repository_id => review.repository_identifier)
o << ' | '
o << '
'
return o
@@ -104,7 +105,7 @@ def create_assignment_info(project, assignment)
o << ''
if assignment.path
o << link_to("#{repository_id + ':' if repository_id}#{assignment.path}#{'@' + assignment.revision if assignment.revision}",
- :controller => 'code_review', :action => 'show', :id => project, :assignment_id => assignment.id, :repository_id => repository_id)
+ :controller => 'code_review', :action => 'show', :id => project, :assignment_id => assignment.id, :repository_id => repository_id)
elsif assignment.revision
repo = project unless repository_id
repo ||= assignment.repository
diff --git a/lib/code_review_issue_patch.rb b/lib/code_review_issue_patch.rb
index e05ae8b..3a88259 100644
--- a/lib/code_review_issue_patch.rb
+++ b/lib/code_review_issue_patch.rb
@@ -25,14 +25,9 @@ def self.included(base) # :nodoc:
unloadable # Send unloadable so it will not be unloaded in development
has_one :code_review, :dependent => :destroy
has_one :code_review_assignment, :dependent => :destroy
-
end
-
end
end
module IssueInstanceMethodsCodeReview
-
end
-
-
diff --git a/lib/code_review_projects_helper_patch.rb b/lib/code_review_projects_helper_patch.rb
index f167693..06fa67c 100644
--- a/lib/code_review_projects_helper_patch.rb
+++ b/lib/code_review_projects_helper_patch.rb
@@ -17,22 +17,9 @@
require_dependency 'projects_helper'
-module CodeReviewProjectsHelperPatch
- def self.included(base) # :nodoc:
- base.send(:include, ProjectsHelperMethodsCodeReview)
-
- base.class_eval do
- #unloadable
-
- alias_method_chain :project_settings_tabs, :code_review
- end
-
- end
-end
-
module ProjectsHelperMethodsCodeReview
- def project_settings_tabs_with_code_review
- tabs = project_settings_tabs_without_code_review
+ def project_settings_tabs
+ tabs = super
action = {:name => 'code_review', :controller => 'code_review_settings', :action => :show, :partial => 'code_review_settings/show', :label => :code_review}
tabs << action if User.current.allowed_to?(action, @project)
@@ -41,4 +28,4 @@ def project_settings_tabs_with_code_review
end
end
-
+ProjectsHelper.prepend(ProjectsHelperMethodsCodeReview)
diff --git a/test/code_review_object_daddy_helpers.rb b/test/code_review_object_daddy_helpers.rb
index 13c7ed0..9d17551 100644
--- a/test/code_review_object_daddy_helpers.rb
+++ b/test/code_review_object_daddy_helpers.rb
@@ -16,11 +16,11 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
module CodeReviewObjectDaddyHelpers
- def CodeReview.generate_for_project!(project, attributes={})
- attributes[:comment] = 'test comment' unless attributes[:comment]
- attributes[:issue] = Issue.generate_for_project!({:project => project, :description => attributes[:comment], :subject => 'test'}) unless attributes[:issue]
- attributes[:project] = project
- review = CodeReview.generate!(attributes)
- review
- end
+ def CodeReview.generate_for_project!(project, attributes = {})
+ attributes[:comment] = 'test comment' unless attributes[:comment]
+ attributes[:issue] = Issue.generate_for_project!({:project => project, :description => attributes[:comment], :subject => 'test'}) unless attributes[:issue]
+ attributes[:project] = project
+ review = CodeReview.generate!(attributes)
+ review
+ end
end
diff --git a/test/exemplars/code_review_exemplar.rb b/test/exemplars/code_review_exemplar.rb
index 565422f..0543491 100644
--- a/test/exemplars/code_review_exemplar.rb
+++ b/test/exemplars/code_review_exemplar.rb
@@ -23,11 +23,9 @@ class CodeReview < ActiveRecord::Base
generator_for :action_type => 'diff'
generator_for :line => 30
-
def self.next_subject
@last_subject ||= 'Code Review 0'
@last_subject.succ!
@last_subject
end
-
end
diff --git a/test/fixtures/code_review_assignments.yml b/test/fixtures/code_review_assignments.yml
index c23a486..d4f09a0 100644
--- a/test/fixtures/code_review_assignments.yml
+++ b/test/fixtures/code_review_assignments.yml
@@ -2,13 +2,13 @@
one:
id: 1
- issue_id:
+ issue_id: 1
- change_id:
+ change_id: 1
- attachment_id:
+ attachment_id:
- file_path: MyString
+ file_path: /aaa/bbb
rev: 1
@@ -19,17 +19,17 @@ one:
two:
id: 2
- issue_id:
+ issue_id: 1
- change_id:
+ change_id: 2
- attachment_id:
+ attachment_id: 1
- file_path: MyString
+ file_path: /aaa/bbb
- rev: MyString
+ rev: 2
- rev_to: MyString
+ rev_to: 3
- action_type: MyString
+ action_type: diff
diff --git a/test/functional/attachments_controller_test.rb b/test/functional/attachments_controller_test.rb
index d1279f1..83714a4 100644
--- a/test/functional/attachments_controller_test.rb
+++ b/test/functional/attachments_controller_test.rb
@@ -21,49 +21,45 @@
# Re-raise errors caught by the controller.
class AttachmentsController; def rescue_action(e) raise e end; end
-
class AttachmentsControllerTest < ActionController::TestCase
fixtures :users, :projects, :roles, :members, :member_roles, :enabled_modules, :issues, :trackers, :attachments,
:versions, :wiki_pages, :wikis, :documents
-
+
def setup
@controller = AttachmentsController.new
- @request = ActionController::TestRequest.new
- @response = ActionController::TestResponse.new
+ @request = ActionController::TestRequest.create(self.class.controller_class)
+ #@response = ActionController::TestResponse.new
Attachment.storage_path = "#{Rails.root}/test/fixtures/files"
-
+
[1, 2].each { |num|
project = Project.find(num)
project.enable_module!('code_review')
project.save!
}
-
roles = Role.all
- roles.each {|role|
+ roles.each { |role|
role.permissions << :view_code_review
role.save
}
User.current = nil
end
-
-
+
def test_show_diff
@request.session[:user_id] = 1
- attachment = FactoryGirl.create(:attachment, filename: "test.diff")
- get :show, :id => attachment.id, :type => 'inline'
+ attachment = FactoryBot.create(:attachment, filename: "test.diff")
+ get :show, :params => {:id => attachment.id, :type => 'inline'}
assert_response :success
assert_template 'diff'
- assert_equal 'text/html', @response.content_type
+ #assert_equal 'text/html', @response.content_type
end
-
+
def test_show_text_file
@request.session[:user_id] = 1
- attachment = FactoryGirl.create(:attachment, filename: "test.rb")
- get :show, :id => attachment.id, :type => 'inline'
+ attachment = FactoryBot.create(:attachment, filename: "test.rb")
+ get :show, :params => {:id => attachment.id, :type => 'inline'}
assert_response :success
assert_template 'file'
- assert_equal 'text/html', @response.content_type
+ #assert_equal 'text/html', @response.content_type
end
-
end
diff --git a/test/functional/code_review_controller_test.rb b/test/functional/code_review_controller_test.rb
index fdebc67..8b4bd94 100644
--- a/test/functional/code_review_controller_test.rb
+++ b/test/functional/code_review_controller_test.rb
@@ -18,14 +18,14 @@
class CodeReviewControllerTest < ActionController::TestCase
fixtures :code_reviews, :projects, :users, :repositories,
- :changesets, :changes, :members, :member_roles, :roles, :issues, :issue_statuses,
- :enumerations, :issue_categories, :trackers, :projects, :projects_trackers,
- :code_review_project_settings, :attachments, :code_review_assignments,
- :code_review_user_settings
+ :changesets, :changes, :members, :member_roles, :roles, :issues, :issue_statuses,
+ :enumerations, :issue_categories, :trackers, :projects, :projects_trackers,
+ :code_review_project_settings, :attachments, :code_review_assignments,
+ :code_review_user_settings
+
def setup
@controller = CodeReviewController.new
- @request = ActionController::TestRequest.new
- @response = ActionController::TestResponse.new
+ @request = ActionController::TestRequest.create(self.class.controller_class)
@request.env["HTTP_REFERER"] = '/'
enabled_module = EnabledModule.new
enabled_module.project_id = 1
@@ -38,7 +38,7 @@ def setup
User.current = nil
roles = Role.all
- roles.each {|role|
+ roles.each { |role|
role.permissions << :view_code_review
role.save
}
@@ -47,28 +47,27 @@ def setup
context "index" do
should "show review list" do
@request.session[:user_id] = 1
- get :index, :id => 1
+ get :index, :params => {:id => 1}
assert_response :success
end
should "not show review list if module was not enabled." do
@request.session[:user_id] = 1
- get :index, :id => 3
+ get :index, :params => {:id => 3}
assert_response 403
end
should "show all review list if show_closed is true" do
@request.session[:user_id] = 1
- get :index, :id => 1, :show_closed => true
+ get :index, :params => {:id => 1, :show_closed => true}
assert_response :success
end
-
end
context "new" do
should "create form when get mthod" do
@request.session[:user_id] = 1
- get :new, :id => 1, :action_type => 'diff', :rev => 5
+ get :new, :params => {:id => 1, :action_type => 'diff', :rev => 5}
assert_response :success
assert_template '_new_form'
end
@@ -76,13 +75,13 @@ def setup
should "create new review" do
@request.session[:user_id] = 1
count = CodeReview.all.length
- post :new, :id => 1, :review => {:line => 1, :change_id => 1,
- :comment => 'aaa', :subject => 'bbb'}, :action_type => 'diff'
+ post :new, :params => {:id => 1, :review => {:line => 1, :change_id => 1,
+ :comment => 'aaa', :subject => 'bbb'}, :action_type => 'diff'}
assert_response :success
assert_template '_add_success'
assert_equal(count + 1, CodeReview.all.length)
- get :new, :id => 1, :action_type => 'diff', :rev => 5
+ get :new, :params => {:id => 1, :action_type => 'diff', :rev => 5}
assert_response :success
assert_template '_new_form'
end
@@ -96,23 +95,23 @@ def setup
changeset.issues << issue
changeset.save
count = CodeReview.all.length
- post :new, :id => 1, :review => {:line => 1, :change_id => 3,
- :comment => 'aaa', :subject => 'bbb'}, :action_type => 'diff'
+ post :new, :params => {:id => 1, :review => {:line => 1, :change_id => 3,
+ :comment => 'aaa', :subject => 'bbb'}, :action_type => 'diff'}
assert_response :success
assert_template '_add_success'
assert_equal(count + 1, CodeReview.all.length)
settings = CodeReviewProjectSetting.all
- settings.each{|setting|
+ settings.each { |setting|
setting.destroy
}
- post :new, :id => 1, :review => {:line => 1, :change_id => 1,
- :comment => 'aaa', :subject => 'bbb'}, :action_type => 'diff'
+ post :new, :params => {:id => 1, :review => {:line => 1, :change_id => 1,
+ :comment => 'aaa', :subject => 'bbb'}, :action_type => 'diff'}
assert_response 200
end
should "save safe_attributes" do
- @request.session[:user_id] = 1
+ @request.session[:user_id] = 1
project = Project.find(1)
change = Change.find(3)
changeset = change.changeset
@@ -120,8 +119,8 @@ def setup
changeset.issues << issue
changeset.save
count = CodeReview.all.length
- post :new, :id => 1, :review => {:line => 10, :change_id => 3,
- :comment => 'aaa', :subject => 'bbb', :parent_id => 1, :status_id => 1}, :action_type => 'diff'
+ post :new, :params => {:id => 1, :review => {:line => 10, :change_id => 3,
+ :comment => 'aaa', :subject => 'bbb', :parent_id => 1, :status_id => 1}, :action_type => 'diff'}
assert_response :success
assert_template '_add_success'
@@ -138,10 +137,10 @@ def setup
@request.session[:user_id] = 1
project = Project.find(1)
issue = Issue.generate!(:project => project)
- attachment = FactoryGirl.create(:attachment, container: issue)
+ attachment = FactoryBot.create(:attachment, container: issue)
count = CodeReview.all.length
- post :new, :id => 1, :review => {:line => 1, :comment => 'aaa',
- :subject => 'bbb', :attachment_id => attachment.id}, :action_type => 'diff'
+ post :new, :params => {:id => 1, :review => {:line => 1, :comment => 'aaa',
+ :subject => 'bbb', :attachment_id => attachment.id}, :action_type => 'diff'}
assert_response :success
assert_template '_add_success'
assert_equal(count + 1, CodeReview.all.length)
@@ -150,7 +149,7 @@ def setup
def test_show
@request.session[:user_id] = 1
- get :show, :id => 1, :review_id => 9
+ get :show, :params => {:id => 1, :review_id => 9}
assert_response 302
#assert_template '_show'
end
@@ -158,13 +157,13 @@ def test_show
context "show" do
should "be success with review_id" do
@request.session[:user_id] = 1
- get :show, :id => 1, :review_id => 9
+ get :show, :params => {:id => 1, :review_id => 9}
assert_response 302
#assert_template '_show'
end
should "be success with assignment_id" do
@request.session[:user_id] = 1
- get :show, :id => 1, :assignment_id => 1
+ get :show, :params => {:id => 1, :assignment_id => 1}
assert_response 302
#assert_template '_show'
end
@@ -173,13 +172,12 @@ def test_show
def test_destroy
project = Project.find(1)
issue = Issue.generate!(:project => project)
- review = FactoryGirl.create(:code_review, project: project)
+ review = FactoryBot.create(:code_review, project: project)
count = CodeReview.all.length
@request.session[:user_id] = 1
- get :destroy, :id => 1, :review_id => review.id
+ get :destroy, :params => {:id => 1, :review_id => review.id}
assert_response :success
assert_equal(count - 1, CodeReview.all.length)
-
end
context "reply" do
@@ -187,19 +185,19 @@ def test_destroy
@request.session[:user_id] = 1
review = CodeReview.find(9)
- get :reply, :id => 1, :review_id => 9,
- :reply => {:comment => 'aaa'}, :issue=> {:lock_version => review.issue.lock_version}
+ get :reply, :params => {:id => 1, :review_id => 9,
+ :reply => {:comment => 'aaa'}, :issue => {:lock_version => review.issue.lock_version}}
assert_response :success
assert_template '_show'
- assert_equal(nil, assigns(:error))
+ assert_nil assigns(:error)
end
should "not create reply if anyone replied sametime" do
@request.session[:user_id] = 1
review = CodeReview.find(9)
- get :reply, :id => 1, :review_id => 9,
- :reply => {:comment => 'aaa'}, :issue=> {:lock_version => review.issue.lock_version + 1}
+ get :reply, :params => {:id => 1, :review_id => 9,
+ :reply => {:comment => 'aaa'}, :issue => {:lock_version => review.issue.lock_version + 1}}
assert_response :success
assert_template '_show'
assert_not_nil assigns(:error)
@@ -208,48 +206,48 @@ def test_destroy
def test_reply_lock_error
@request.session[:user_id] = 1
- get :reply, :id => 1, :review_id => 9,
- :reply => {:comment => 'aaa'}, :issue=> {:lock_version => 1}
+ get :reply, :params => {:id => 1, :review_id => 9,
+ :reply => {:comment => 'aaa'}, :issue => {:lock_version => 1}}
assert_response :success
assert_template '_show'
assert assigns(:error)
end
-# def test_close
-# @request.session[:user_id] = 1
-# review_id = 9
-# review = CodeReview.find(review_id)
-# review.reopen
-# review.save
-# assert !review.is_closed?
-# get :close, :id => 1, :review_id => review_id
-# assert_response :success
-# assert_template '_show'
-# review = CodeReview.find(review_id)
-# assert review.is_closed?
-# end
-#
-# def test_reopen
-# @request.session[:user_id] = 1
-# review = CodeReview.find(1)
-# review.close
-# review.save
-# assert review.is_closed?
-# get :reopen, :id => 1, :review_id => 1
-# assert_response :success
-# assert_template '_show'
-# review = CodeReview.find(1)
-# assert !review.is_closed?
-# end
+ # def test_close
+ # @request.session[:user_id] = 1
+ # review_id = 9
+ # review = CodeReview.find(review_id)
+ # review.reopen
+ # review.save
+ # assert !review.is_closed?
+ # get :close, :id => 1, :review_id => review_id
+ # assert_response :success
+ # assert_template '_show'
+ # review = CodeReview.find(review_id)
+ # assert review.is_closed?
+ # end
+ #
+ # def test_reopen
+ # @request.session[:user_id] = 1
+ # review = CodeReview.find(1)
+ # review.close
+ # review.save
+ # assert review.is_closed?
+ # get :reopen, :id => 1, :review_id => 1
+ # assert_response :success
+ # assert_template '_show'
+ # review = CodeReview.find(1)
+ # assert !review.is_closed?
+ # end
def test_update
@request.session[:user_id] = 1
review_id = 9
review = CodeReview.find(review_id)
assert_equal('Unable to print recipes', review.comment)
- post :update, :id => 1, :review_id => review_id,
- :review => {:comment => 'bbb', :lock_version => review.lock_version},
- :issue => {:lock_version => review.issue.lock_version}
+ post :update, :params => {:id => 1, :review_id => review_id,
+ :review => {:comment => 'bbb', :lock_version => review.lock_version},
+ :issue => {:lock_version => review.issue.lock_version}}
assert_response :success
review = CodeReview.find(review_id)
assert_equal('bbb', review.comment)
@@ -259,14 +257,15 @@ def test_update_lock_error
@request.session[:user_id] = 1
review_id = 9
review = CodeReview.find(review_id)
+ review.save!
assert_equal('Unable to print recipes', review.comment)
- post :update, :id => 1, :review_id => review_id,
- :review => {:comment => 'bbb', :lock_version => review.lock_version},
- :issue => {:lock_version => 1}
+ post :update, :params => {:id => 1, :review_id => review_id,
+ :review => {:comment => 'bbb', :lock_version => review.lock_version},
+ :issue => {:lock_version => 1}}
+ assert_not_nil assigns(:error)
assert_response :success
review = CodeReview.find(review_id)
assert_equal('Unable to print recipes', review.comment)
- assert assigns(:error)
end
def test_update_diff_view
@@ -274,14 +273,14 @@ def test_update_diff_view
review_id = 9
review = CodeReview.find(review_id)
assert_equal('Unable to print recipes', review.comment)
- post :update_diff_view, :id => 1, :review_id => review_id, :rev => 1, :path => '/test/some/path/in/the/repo'
+ post :update_diff_view, :params => {:id => 1, :review_id => review_id, :rev => 1, :path => '/test/some/path/in/the/repo'}
assert_response :success
review = CodeReview.find(review_id)
end
def test_forward_to_revision
@request.session[:user_id] = 1
- #post :forward_to_revision, :id => 1, :path => '/test/some/path/in/the/repo'
+ post :forward_to_revision, :params => {:id => 1, :path => '/subversion_test/folder/helloworld.rb'}
end
def test_update_attachment_view
@@ -289,7 +288,7 @@ def test_update_attachment_view
review_id = 9
review = CodeReview.find(review_id)
assert_equal('Unable to print recipes', review.comment)
- post :update_attachment_view, :id => 1, :attachment_id => 1
+ post :update_attachment_view, :params => {:id => 1, :attachment_id => 1}
assert_response :success
review = CodeReview.find(review_id)
end
@@ -298,13 +297,13 @@ def test_preview
@request.session[:user_id] = 1
review = {}
review[:comment] = 'aaa'
- post :preview, :id => 1, :review => review
+ post :preview, :params => {:id => 1, :review => review}
assert_response :success
end
def test_assign
@request.session[:user_id] = 1
- post :assign, :id => 1
+ post :assign, :params => {:id => 1}
assert_response :redirect
end
@@ -314,13 +313,13 @@ def test_assign
end
should "succeed if changeset_ids is nil" do
- get :update_revisions_view, :id => 1
+ get :update_revisions_view, :params => {:id => 1}
assert_response :success
assert_equal(0, assigns(:changesets).length)
end
should "succeed if changeset_ids is not nil" do
- get :update_revisions_view, :id => 1, :changeset_ids => '1,2,3'
+ get :update_revisions_view, :params => {:id => 1, :changeset_ids => '1,2,3'}
assert_response :success
assert_equal(3, assigns(:changesets).length)
end
diff --git a/test/functional/code_review_settings_controller_test.rb b/test/functional/code_review_settings_controller_test.rb
index a1f8fe5..678a77b 100644
--- a/test/functional/code_review_settings_controller_test.rb
+++ b/test/functional/code_review_settings_controller_test.rb
@@ -21,10 +21,10 @@ class CodeReviewSettingsControllerTest < ActionController::TestCase
:code_review_project_settings, :issues, :issue_statuses, :enumerations
include CodeReviewAutoAssignSettings
+
def setup
@controller = CodeReviewSettingsController.new
- @request = ActionController::TestRequest.new
- @response = ActionController::TestResponse.new
+ @request = ActionController::TestRequest.create(self.class.controller_class)
@request.env["HTTP_REFERER"] = '/'
enabled_module = EnabledModule.new
enabled_module.project_id = 1
@@ -38,13 +38,12 @@ def setup
User.current = nil
roles = Role.all
- roles.each {|role|
+ roles.each { |role|
role.permissions << :view_code_review
role.save
}
end
-
context "update" do
setup do
@request.session[:user_id] = 1
@@ -52,18 +51,17 @@ def setup
should "return 302 if user is anonymous" do
@request.session[:user_id] = User.anonymous.id
- get :update, :id => 1
+ get :update, :params => {:id => 1}
assert_response 302
end
should "save settings" do
-
@request.session[:user_id] = 1
setting = CodeReviewProjectSetting.find(1)
- post :update, :id => 1, :setting => {:tracker_id => 2, :assignment_tracker_id => 3,
- :hide_code_review_tab => true, :auto_relation => CodeReviewProjectSetting::AUTORELATION_TYPE_BLOCKS},
- :auto_assign => {:filters => {:a => 1}}
+ post :update, :params => {:id => 1, :setting => {:tracker_id => 2, :assignment_tracker_id => 3,
+ :hide_code_review_tab => true, :auto_relation => CodeReviewProjectSetting::AUTORELATION_TYPE_BLOCKS},
+ :auto_assign => {:filters => {:a => 1}}}
assert_response :redirect
project = Project.find(1)
assert_redirected_to :controller => 'projects', :action => 'settings', :id => project, :tab => 'code_review'
@@ -76,13 +74,13 @@ def setup
assert_equal(true, setting.hide_code_review_tab)
assert_equal(CodeReviewProjectSetting::AUTORELATION_TYPE_BLOCKS, setting.auto_relation)
- get :update, :id => 1, :setting => {:tracker_id => 1, :id => setting.id}, :convert => 'true',
- :auto_assign => {}
+ get :update, :params => {:id => 1, :setting => {:tracker_id => 1, :id => setting.id}, :convert => 'true',
+ :auto_assign => {}}
assert_response :redirect
project = Project.find(1)
assert_redirected_to :controller => 'projects', :action => 'settings', :id => project, :tab => 'code_review'
- post :update, :id => 2, :setting => {:tracker_id => 1, :assignment_tracker_id => 1}, :auto_assign => {}
+ post :update, :params => {:id => 2, :setting => {:tracker_id => 1, :assignment_tracker_id => 1}, :auto_assign => {}}
assert_response :redirect
project = Project.find(2)
assert_redirected_to :controller => 'projects', :action => 'settings', :id => project, :tab => 'code_review'
@@ -103,7 +101,7 @@ def setup
filter.expression = 'aaa'
filter.order = 10
filter.accept = true
- post :add_filter, :id => @project.id, :auto_assign => @setting.auto_assign_settings.attributes.merge({:add_filter => filter.attributes})
+ post :add_filter, :params => {:id => @project.id, :auto_assign => @setting.auto_assign_settings.attributes.merge({:add_filter => filter.attributes})}
@auto_assign = assigns(:auto_assign)
assert_not_nil @auto_assign
assert_equal(count + 1, @auto_assign.filters.length)
@@ -120,19 +118,18 @@ def setup
end
should "update filter" do
-
filter = AssignmentFilter.new
filter.expression = 'aaa'
filter.order = 10
filter.accept = true
-
+
filter2 = AssignmentFilter.new
filter2.expression = 'bbb'
filter2.order = 10
filter2.accept = false
- post :edit_filter, :id => @project.id, :auto_assign => @setting.auto_assign_settings.attributes.merge(:filters => {'0' => filter.attributes}), :num => 0,
- :auto_assign_edit_filter => {'0' => filter2.attributes}
+ post :edit_filter, :params => {:id => @project.id, :auto_assign => @setting.auto_assign_settings.attributes.merge(:filters => {'0' => filter.attributes}), :num => 0,
+ :auto_assign_edit_filter => {'0' => filter2.attributes}}
@auto_assign = assigns(:auto_assign)
assert_not_nil @auto_assign
assert_equal(1, @auto_assign.filters.length)
@@ -166,30 +163,29 @@ def setup
@filters['1'] = filter.attributes
@filters['2'] = filter2.attributes
@filters['3'] = filter2.attributes
-
end
- should "sort filters" do
- post :sort, :id => @project.id, :auto_assign => @setting.auto_assign_settings.attributes.merge(:filters => @filters), :num => 0,
- :auto_assign_filter => {:num => 2, :move_to => 'highest'}
+ should "sort filters" do
+ post :sort, :params => {:id => @project.id, :auto_assign => @setting.auto_assign_settings.attributes.merge(:filters => @filters), :num => 0,
+ :auto_assign_filter => {:num => 2, :move_to => 'highest'}}
@auto_assign = assigns(:auto_assign)
assert_not_nil @auto_assign
assert_response :success
- post :sort, :id => @project.id, :auto_assign => @setting.auto_assign_settings.attributes.merge(:filters => @filters), :num => 0,
- :auto_assign_filter => {:num => 2, :move_to => 'higher'}
+ post :sort, :params => {:id => @project.id, :auto_assign => @setting.auto_assign_settings.attributes.merge(:filters => @filters), :num => 0,
+ :auto_assign_filter => {:num => 2, :move_to => 'higher'}}
@auto_assign = assigns(:auto_assign)
assert_not_nil @auto_assign
assert_response :success
- post :sort, :id => @project.id, :auto_assign => @setting.auto_assign_settings.attributes.merge(:filters => @filters), :num => 0,
- :auto_assign_filter => {:num => 2, :move_to => 'lowest'}
+ post :sort, :params => {:id => @project.id, :auto_assign => @setting.auto_assign_settings.attributes.merge(:filters => @filters), :num => 0,
+ :auto_assign_filter => {:num => 2, :move_to => 'lowest'}}
@auto_assign = assigns(:auto_assign)
assert_not_nil @auto_assign
assert_response :success
- post :sort, :id => @project.id, :auto_assign => @setting.auto_assign_settings.attributes.merge(:filters => @filters), :num => 0,
- :auto_assign_filter => {:num => 2, :move_to => 'lower'}
+ post :sort, :params => {:id => @project.id, :auto_assign => @setting.auto_assign_settings.attributes.merge(:filters => @filters), :num => 0,
+ :auto_assign_filter => {:num => 2, :move_to => 'lower'}}
@auto_assign = assigns(:auto_assign)
assert_not_nil @auto_assign
assert_response :success
diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb
index eca63ea..1c24d6f 100644
--- a/test/functional/issues_controller_test.rb
+++ b/test/functional/issues_controller_test.rb
@@ -1,5 +1,5 @@
# Code Review plugin for Redmine
-# Copyright (C) 2009-2014 Haruyuki Iida
+# Copyright (C) 2009-2018 Haruyuki Iida
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -26,6 +26,7 @@ class IssuesControllerTest < ActionController::TestCase
:users,
:roles,
:members,
+ :member_roles,
:issues,
:issue_statuses,
:versions,
@@ -42,12 +43,16 @@ class IssuesControllerTest < ActionController::TestCase
:time_entries,
:journals,
:journal_details,
- :code_reviews
-
+ :code_reviews,
+ :code_review_assignments,
+ :code_review_user_settings,
+ :changes,
+ :changesets,
+ :repositories
+
def setup
@controller = IssuesController.new
- @request = ActionController::TestRequest.new
- @response = ActionController::TestResponse.new
+ @request = ActionController::TestRequest.create(self.class.controller_class)
User.current = nil
enabled_module = EnabledModule.new
enabled_module.project_id = 1
@@ -58,7 +63,7 @@ def setup
enabled_module.name = 'code_review'
enabled_module.save
roles = Role.all
- roles.each {|role|
+ roles.each { |role|
role.permissions << :view_code_review
role.save
}
@@ -68,40 +73,38 @@ def test_show
@request.session[:user_id] = 1
project = Project.find(1)
issue = Issue.generate!(:project => project)
- get :show, :id => issue.id
+ get :show, params: {id: issue.id}
- issue = Issue.generate!(:project => project)
- assignment = FactoryGirl.create(:code_review_assignment, issue: issue, rev: 'aaa', file_path: nil)
- get :show, :id => assignment.issue.id
+ assignment = FactoryBot.create(:code_review_assignment, issue: issue, rev: 'aaa', file_path: nil, change_id: 1)
+ get :show, :params => {:id => assignment.issue.id}
issue = Issue.generate!(:project => Project.find(1))
- assignment = FactoryGirl.create(:code_review_assignment, issue: issue, rev: 'aaa', file_path: '/aaa/bbb')
- get :show, :id => assignment.issue.id
-
- review = FactoryGirl.create(:code_review, project: project)
- get :show, :id => review.issue.id
+ assignment = FactoryBot.create(:code_review_assignment, issue: issue, rev: 'aaa', file_path: '/aaa/bbb')
+ get :show, :params => {:id => assignment.issue.id}
+ review = FactoryBot.create(:code_review, project: project)
+ get :show, :params => {:id => review.issue.id}
end
def test_new
@request.session[:user_id] = 1
- get :new, :project_id => 1
+ get :new, params: {project_id: 1}
assert_response :success
- get :new, :project_id => 1, :code =>{:rev => 1, :rev_to => 2, :path => '/aaa/bbb', :action_type => 'diff'}
+ get :new, :params => {:project_id => 1, :code => {:rev => 1, :rev_to => 2, :path => '/aaa/bbb', :action_type => 'diff'}}
assert_response :success
- post :new, :project_id => 1,
- :issue => {:tracker_id => 1, :status_id => 1, :subject => 'hoge'},
- :code =>{:rev => 1, :rev_to => 2, :path => '/aaa/bbb', :action_type => 'diff'}
+ post :new, :params => {:project_id => 1,
+ :issue => {:tracker_id => 1, :status_id => 1, :subject => 'hoge'},
+ :code => {:rev => 1, :rev_to => 2, :path => '/aaa/bbb', :action_type => 'diff'}}
# TODO: 0.9.xのサポート終了時に以下を有効にする。
#assert_response :SUCESS
end
-
+
context "create" do
should "create code_review_assignment." do
@request.session[:user_id] = 1
project = Project.find(1)
- post :create, :project_id => 1, :issue => {:subject => 'test'}, :code => {:change_id => 1, :changeset_id => 1}
+ post :create, :params => {:project_id => 1, :issue => {:subject => 'test'}, :code => {:change_id => 1, :changeset_id => 1}}
assert_response :redirect
end
end
diff --git a/test/functional/projects_controller_test.rb b/test/functional/projects_controller_test.rb
index 99b1701..8133437 100644
--- a/test/functional/projects_controller_test.rb
+++ b/test/functional/projects_controller_test.rb
@@ -24,8 +24,7 @@ class ProjectsControllerTest < ActionController::TestCase
def setup
@controller = ProjectsController.new
- @request = ActionController::TestRequest.new
- @response = ActionController::TestResponse.new
+ @request = ActionController::TestRequest.create(self.class.controller_class)
end
context "#settings" do
@@ -35,12 +34,12 @@ def setup
end
should "302 get" do
- get :settings, :id => 1
+ get :settings, :params => {:id => 1}
assert_response 302
end
should "302 post" do
- get :settings, :id => 1
+ get :settings, :params => {:id => 1}
assert_response 302
end
@@ -50,48 +49,36 @@ def setup
end
should "not exist tag id get" do
- get :settings, :id => 1
+ get :settings, :params => {:id => 1}
assert_response :success
assert_template 'settings'
- assert_no_tag :div, :attributes => {:class => 'tabs'},
- :descendant => {:tag => 'ul',
- :descendant => {:tag => 'li',
- :descendant => {:tag => 'a', :attributes => {:id => 'tab-code_review'}}}}
+ assert_select 'div.tabs ul li a#tab-code_review', false
end
should "not exist tag id post" do
- post :settings, :id => 1
+ post :settings, :params => {:id => 1}
assert_response :success
assert_template 'settings'
- assert_no_tag :div, :attributes => {:class => 'tabs'},
- :descendant => {:tag => 'ul',
- :descendant => {:tag => 'li',
- :descendant => {:tag => 'a', :attributes => {:id => 'tab-code_review'}}}}
+ assert_select 'div.tabs ul li a#tab-code_review', false
end
context "and module" do
setup do
- FactoryGirl.create(:enabled_module, project_id: 1, name: 'code_review')
+ FactoryBot.create(:enabled_module, project_id: 1, name: 'code_review')
end
should "not exist tag id get" do
- get :settings, :id => 1
+ get :settings, :params => {:id => 1}
assert_response :success
assert_template 'settings'
- assert_no_tag :div, :attributes => {:class => 'tabs'},
- :descendant => {:tag => 'ul',
- :descendant => {:tag => 'li',
- :descendant => {:tag => 'a', :attributes => {:id => 'tab-code_review'}}}}
+ assert_select 'div.tabs ul li a#tab-code_review', false
end
should "not exist tag id post" do
- post :settings, :id => 1
+ post :settings, :params => {:id => 1}
assert_response :success
assert_template 'settings'
- assert_no_tag :div, :attributes => {:class => 'tabs'},
- :descendant => {:tag => 'ul',
- :descendant => {:tag => 'li',
- :descendant => {:tag => 'a', :attributes => {:id => 'tab-code_review'}}}}
+ assert_select 'div.tabs ul li a#tab-code_review', false
end
end
end
@@ -103,12 +90,12 @@ def setup
end
should "403 get" do
- get :settings, :id => 1
+ get :settings, :params => {:id => 1}
assert_response 403
end
should "403 post" do
- get :settings, :id => 1
+ get :settings, :params => {:id => 1}
assert_response 403
end
@@ -118,48 +105,36 @@ def setup
end
should "not exist tag id get" do
- get :settings, :id => 1
+ get :settings, :params => {:id => 1}
assert_response :success
assert_template 'settings'
- assert_no_tag :div, :attributes => {:class => 'tabs'},
- :descendant => {:tag => 'ul',
- :descendant => {:tag => 'li',
- :descendant => {:tag => 'a', :attributes => {:id => 'tab-code_review'}}}}
+ assert_select 'div.tabs ul li a#tab-code_review', false
end
should "not exist tag id post" do
- post :settings, :id => 1
+ post :settings, :params => {:id => 1}
assert_response :success
assert_template 'settings'
- assert_no_tag :div, :attributes => {:class => 'tabs'},
- :descendant => {:tag => 'ul',
- :descendant => {:tag => 'li',
- :descendant => {:tag => 'a', :attributes => {:id => 'tab-code_review'}}}}
+ assert_select 'div.tabs ul li a#tab-code_review', false
end
context "and module" do
setup do
- FactoryGirl.create(:enabled_module, project_id: 1, name: 'code_review')
+ FactoryBot.create(:enabled_module, project_id: 1, name: 'code_review')
end
should "not exist tag id get" do
- get :settings, :id => 1
+ get :settings, :params => {:id => 1}
assert_response :success
assert_template 'settings'
- assert_no_tag :div, :attributes => {:class => 'tabs'},
- :descendant => {:tag => 'ul',
- :descendant => {:tag => 'li',
- :descendant => {:tag => 'a', :attributes => {:id => 'tab-code_review'}}}}
+ assert_select 'div.tabs ul li a#tab-code_review', false
end
should "not exist tag id post" do
- post :settings, :id => 1
+ post :settings, :params => {:id => 1}
assert_response :success
assert_template 'settings'
- assert_no_tag :div, :attributes => {:class => 'tabs'},
- :descendant => {:tag => 'ul',
- :descendant => {:tag => 'li',
- :descendant => {:tag => 'a', :attributes => {:id => 'tab-code_review'}}}}
+ assert_select 'div.tabs ul li a#tab-code_review', false
end
end
end
@@ -172,23 +147,17 @@ def setup
end
should "not exist tag id get" do
- get :settings, :id => 1
+ get :settings, :params => {:id => 1}
assert_response :success
assert_template 'settings'
- assert_no_tag :div, :attributes => {:class => 'tabs'},
- :descendant => {:tag => 'ul',
- :descendant => {:tag => 'li',
- :descendant => {:tag => 'a', :attributes => {:id => 'tab-code_review'}}}}
+ assert_select 'div.tabs ul li a#tab-code_review', false
end
should "not exist tag id post" do
- get :settings, :id => 1
+ get :settings, :params => {:id => 1}
assert_response :success
assert_template 'settings'
- assert_no_tag :div, :attributes => {:class => 'tabs'},
- :descendant => {:tag => 'ul',
- :descendant => {:tag => 'li',
- :descendant => {:tag => 'a', :attributes => {:id => 'tab-code_review'}}}}
+ assert_select 'div.tabs ul li a#tab-code_review', false
end
context "with permission" do
@@ -197,48 +166,36 @@ def setup
end
should "not exist tag id get" do
- get :settings, :id => 1
+ get :settings, :params => {:id => 1}
assert_response :success
assert_template 'settings'
- assert_no_tag :div, :attributes => {:class => 'tabs'},
- :descendant => {:tag => 'ul',
- :descendant => {:tag => 'li',
- :descendant => {:tag => 'a', :attributes => {:id => 'tab-code_review'}}}}
+ assert_select 'div.tabs ul li a#tab-code_review', false
end
should "not exist tag id post" do
- post :settings, :id => 1
+ post :settings, :params => {:id => 1}
assert_response :success
assert_template 'settings'
- assert_no_tag :div, :attributes => {:class => 'tabs'},
- :descendant => {:tag => 'ul',
- :descendant => {:tag => 'li',
- :descendant => {:tag => 'a', :attributes => {:id => 'tab-code_review'}}}}
+ assert_select 'div.tabs ul li a#tab-code_review', false
end
context "and module" do
setup do
- FactoryGirl.create(:enabled_module, project_id: 1, name: 'code_review')
+ FactoryBot.create(:enabled_module, project_id: 1, name: 'code_review')
end
should "not exist tag id get" do
- get :settings, :id => 1
+ get :settings, :params => {:id => 1}
assert_response :success
assert_template 'settings'
- assert_no_tag :div, :attributes => {:class => 'tabs'},
- :descendant => {:tag => 'ul',
- :descendant => {:tag => 'li',
- :descendant => {:tag => 'a', :attributes => {:id => 'tab-code_review'}}}}
+ assert_select 'div.tabs ul li a#tab-code_review', false
end
should "not exist tag id post" do
- post :settings, :id => 1
+ post :settings, :params => {:id => 1}
assert_response :success
assert_template 'settings'
- assert_no_tag :div, :attributes => {:class => 'tabs'},
- :descendant => {:tag => 'ul',
- :descendant => {:tag => 'li',
- :descendant => {:tag => 'a', :attributes => {:id => 'tab-code_review'}}}}
+ assert_select 'div.tabs ul li a#tab-code_review', false
end
end
end
@@ -251,23 +208,17 @@ def setup
end
should "not exist tag id get" do
- get :settings, :id => 1
+ get :settings, :params => {:id => 1}
assert_response :success
assert_template 'settings'
- assert_no_tag :div, :attributes => {:class => 'tabs'},
- :descendant => {:tag => 'ul',
- :descendant => {:tag => 'li',
- :descendant => {:tag => 'a', :attributes => {:id => 'tab-code_review'}}}}
+ assert_select 'div.tabs ul li a#tab-code_review', false
end
should "not exist tag id post" do
- get :settings, :id => 1
+ get :settings, :params => {:id => 1}
assert_response :success
assert_template 'settings'
- assert_no_tag :div, :attributes => {:class => 'tabs'},
- :descendant => {:tag => 'ul',
- :descendant => {:tag => 'li',
- :descendant => {:tag => 'a', :attributes => {:id => 'tab-code_review'}}}}
+ assert_select 'div.tabs ul li a#tab-code_review', false
end
context "with permission" do
@@ -276,48 +227,36 @@ def setup
end
should "not exist tag id get" do
- get :settings, :id => 1
+ get :settings, :params => {:id => 1}
assert_response :success
assert_template 'settings'
- assert_no_tag :div, :attributes => {:class => 'tabs'},
- :descendant => {:tag => 'ul',
- :descendant => {:tag => 'li',
- :descendant => {:tag => 'a', :attributes => {:id => 'tab-code_review'}}}}
+ assert_select 'div.tabs ul li a#tab-code_review', false
end
should "not exist tag id post" do
- post :settings, :id => 1
+ post :settings, :params => {:id => 1}
assert_response :success
assert_template 'settings'
- assert_no_tag :div, :attributes => {:class => 'tabs'},
- :descendant => {:tag => 'ul',
- :descendant => {:tag => 'li',
- :descendant => {:tag => 'a', :attributes => {:id => 'tab-code_review'}}}}
+ assert_select 'div.tabs ul li a#tab-code_review', false
end
context "and module" do
setup do
- FactoryGirl.create(:enabled_module, project_id: 1, name: 'code_review')
+ FactoryBot.create(:enabled_module, project_id: 1, name: 'code_review')
end
should "exist tag id get" do
- get :settings, :id => 1
+ get :settings, :params => {:id => 1}
assert_response :success
assert_template 'settings'
- assert_tag :div, :attributes => {:class => 'tabs'},
- :descendant => {:tag => 'ul',
- :descendant => {:tag => 'li',
- :descendant => {:tag => 'a', :attributes => {:id => 'tab-code_review'}}}}
+ assert_select 'div.tabs ul li a#tab-code_review'
end
should "exist tag id post" do
- post :settings, :id => 1
+ post :settings, :params => {:id => 1}
assert_response :success
assert_template 'settings'
- assert_tag :div, :attributes => {:class => 'tabs'},
- :descendant => {:tag => 'ul',
- :descendant => {:tag => 'li',
- :descendant => {:tag => 'a', :attributes => {:id => 'tab-code_review'}}}}
+ assert_select 'div.tabs ul li a#tab-code_review'
end
end
end
diff --git a/test/functional/repositories_controller_test.rb b/test/functional/repositories_controller_test.rb
index 45385d8..0edb2bd 100644
--- a/test/functional/repositories_controller_test.rb
+++ b/test/functional/repositories_controller_test.rb
@@ -18,14 +18,13 @@
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
require 'repositories_controller'
-
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, :member_roles, :repositories, :issues, :issue_statuses, :changesets,
+ :changes, :issue_categories, :enumerations, :custom_fields, :custom_values, :trackers, :projects_trackers
+
def setup
@controller = RepositoriesController.new
- @request = ActionController::TestRequest.new
- @response = ActionController::TestResponse.new
+ @request = ActionController::TestRequest.create(self.class.controller_class)
User.current = nil
enabled_module = EnabledModule.new
enabled_module.project_id = 1
@@ -46,7 +45,7 @@ def setup
User.current = nil
roles = Role.all
- roles.each {|role|
+ roles.each { |role|
role.permissions << :view_code_review
role.permissions << :add_code_review
role.permissions << :browse_repository
@@ -56,38 +55,38 @@ def setup
def test_revision
@request.session[:user_id] = 1
- change = FactoryGirl.create(:change)
+ change = FactoryBot.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('/')
+ issue = Issue.generate!({:project_id => project.id, :description => 'test', :tracker => Tracker.find(1), :status_id => 1})
+ review = FactoryBot.create(:code_review, change: change, project: project, issue: issue)
+ get :revision, :params => {:id => project.id, :rev => changeset.revision, :path => change.path.split('/'), repository_id: 1}
#assert_response :success
end
def test_revisions
@request.session[:user_id] = 1
- get :revisions, :id => 1
+ get :revisions, :params => {:id => 1, repository_id: 10}
assert_response :success
end
def test_show
@request.session[:user_id] = 1
- get :show, :id => 1
+ get :show, :params => {:id => 1}
assert_response :success
end
-
+
def test_diff
- @request.session[:user_id] = 1
- get :diff, :id => 1, :path => '/subversion_test/helloworld.c'.split('/'), :rev => 8
+ @request.session[:user_id] = 10
+ get :diff, :params => {:id => 1, :path => '/subversion_test/helloworld.c'.split('/'), :rev => 8, repository_id: 10}
#assert_response :success
end
def test_entry
- @request.session[:user_id] = 1
- get :entry, :id => 1, :path => '/subversion_test/helloworld.c'.split('/'), :rev => 8
+ @request.session[:user_id] = 10
+ get :entry, :params => {:id => 1, :path => '/subversion_test/helloworld.c'.split('/'), :rev => 8, repository_id: 10}
assert_response :success
end
end
diff --git a/test/test_helper.rb b/test/test_helper.rb
index e0fbbe3..bde5bcd 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -1,5 +1,5 @@
# Code Review plugin for Redmine
-# Copyright (C) 2010-2017 Haruyuki Iida
+# Copyright (C) 2010-2018 Haruyuki Iida
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -15,10 +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 'simplecov'
require 'simplecov-rcov'
require 'coveralls'
+require 'factory_bot'
+require 'shoulda'
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
SimpleCov::Formatter::RcovFormatter,
@@ -31,6 +32,13 @@
end
require File.expand_path(File.dirname(__FILE__) + '/../../../test/test_helper')
+include ActionDispatch::TestProcess
+
+fixtures = []
+Dir.chdir(File.dirname(__FILE__) + '/fixtures/') do
+ fixtures = Dir.glob('*.yml').map { |s| s.gsub(/.yml$/, '') }
+end
+ActiveRecord::FixtureSet.create_fixtures(File.dirname(__FILE__) + '/fixtures/', fixtures)
# Ensure that we are using the temporary fixture path
#ngines::Testing.set_fixture_path
@@ -45,15 +53,17 @@ def mock_file
file
end
-FactoryGirl.define do
+def uploaded_test_file(name, mime)
+ fixture_file_upload(Rails.root.to_s + "/test/fixtures/files/#{name}", mime, true)
+end
+FactoryBot.define do
factory :attachment do
-
- container{
- Project.find(1)
+ container {
+ Issue.find(1)
}
file {
- mock_file
+ uploaded_test_file("hg-export.diff", "text/plain")
}
author {
User.find(1)
@@ -78,7 +88,7 @@ def mock_file
factory :changeset do
sequence(:revision, 1000)
- committed_on{
+ committed_on {
Date.today
}
#association :repository
@@ -95,11 +105,11 @@ def mock_file
action {
"A"
}
- sequence(:path){ |n|
+ sequence(:path) { |n|
"test/dir/aaa#{n}"
}
changeset {
- FactoryGirl.create(:changeset)
+ FactoryBot.create(:changeset)
}
end
@@ -109,7 +119,7 @@ def mock_file
factory :issue do
subject 'hoge'
- author{
+ author {
User.find(1)
}
end
@@ -128,7 +138,5 @@ def mock_file
end
factory :enabled_module do
-
end
-
-end
\ No newline at end of file
+end
diff --git a/test/test_runner.rb b/test/test_runner.rb
index eaec046..f74ef8b 100644
--- a/test/test_runner.rb
+++ b/test/test_runner.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.
-
require 'simplecov'
require 'simplecov-rcov'
SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
@@ -28,10 +27,10 @@
require "#{testdir}/test_helper"
-Dir::glob("#{testdir}/fixtures/*.yml").each {|f|
+Dir::glob("#{testdir}/fixtures/*.yml").each { |f|
FileUtils.copy(f, "#{testdir}/../../../test/fixtures/")
}
-Dir::glob("#{testdir}/**/*test.rb").each {|f|
+Dir::glob("#{testdir}/**/*test.rb").each { |f|
require f
-}
\ No newline at end of file
+}
diff --git a/test/unit/code_review_assignment_test.rb b/test/unit/code_review_assignment_test.rb
index 976196a..03774da 100644
--- a/test/unit/code_review_assignment_test.rb
+++ b/test/unit/code_review_assignment_test.rb
@@ -25,7 +25,7 @@ class CodeReviewAssignmentTest < ActiveSupport::TestCase
def setup
@assignment = CodeReviewAssignment.new
end
-
+
context "is_closed?" do
should "return false if assignment issue is not closed." do
@assignment.issue = Issue.new
@@ -100,5 +100,4 @@ def setup
assert_equal('123 5001 foo 456', assignment.issue.subject)
end
end
-
end
diff --git a/test/unit/code_review_attachment_patch_test.rb b/test/unit/code_review_attachment_patch_test.rb
index 2eba3a7..9484ff2 100644
--- a/test/unit/code_review_attachment_patch_test.rb
+++ b/test/unit/code_review_attachment_patch_test.rb
@@ -24,9 +24,9 @@ class CodeReviewAttachmentPatchTest < ActiveSupport::TestCase
def setup
@project = Project.find(1)
@issue = Issue.where(:project_id => 1).first
- @attachment = FactoryGirl.create(:attachment, container: @issue)
+ @attachment = FactoryBot.create(:attachment, container: @issue)
end
-
+
context "code_review_assginments" do
should "returns empty array if attachment has no assignments" do
assert_not_nil(@attachment.code_review_assignments)
diff --git a/test/unit/code_review_auto_assign_settings_test.rb b/test/unit/code_review_auto_assign_settings_test.rb
index b2b4cff..6af7546 100644
--- a/test/unit/code_review_auto_assign_settings_test.rb
+++ b/test/unit/code_review_auto_assign_settings_test.rb
@@ -19,18 +19,25 @@
class CodeReviewAtuoAssignSettingsTest < ActiveSupport::TestCase
fixtures :code_reviews, :projects, :users, :repositories,
- :changesets, :changes, :members, :member_roles, :roles, :issues, :issue_statuses,
- :enumerations, :issue_categories, :trackers, :projects, :projects_trackers,
- :code_review_project_settings, :attachments, :code_review_assignments,
- :code_review_user_settings
+ :changesets, :changes, :members, :member_roles, :roles, :issues, :issue_statuses,
+ :enumerations, :issue_categories, :trackers, :projects, :projects_trackers,
+ :code_review_project_settings, :attachments, :code_review_assignments,
+ :code_review_user_settings
include CodeReviewAutoAssignSettings
+ def startup
+ #DatabaseRewinder.clean_all
+ end
+
+ def teardown
+ #DatabaseRewinder.clean
+ end
+
context "AutoAssignSettings" do
context "to_s" do
should "return string if @yml is not nil." do
-
- str =< @project, :user_id => i)
+ }
+ @project.members << members
end
should "return nil if assignable_list is nil" do
@@ -154,12 +166,12 @@ class CodeReviewAtuoAssignSettingsTest < ActiveSupport::TestCase
end
should "return user_id" do
- @settings.assignable_list = [1,2,3,4,5]
+ @settings.assignable_list = [1, 2, 3, 4, 5]
assert_not_nil @settings.select_assign_to(@project)
end
should "not return id that equals user.id" do
- @settings.assignable_list = [1,2]
+ @settings.assignable_list = [1, 2]
user = User.find(1)
assert_equal(2, @settings.select_assign_to(@project, user))
@settings.assignable_list = [1]
@@ -247,37 +259,37 @@ class CodeReviewAtuoAssignSettingsTest < ActiveSupport::TestCase
#project.repository.destroy if project.repository
#repository = Repository.new
#repository.project = project
- @changeset = FactoryGirl.create(:changeset, repository: project.repository)
+ @changeset = FactoryBot.create(:changeset, repository: project.repository)
#@changeset.repository = repository
end
should "return true if filters.length is 0 and accept_for_default is true." do
@settings.filters = []
- change = FactoryGirl.create(:change, changeset: @changeset)
+ change = FactoryBot.create(:change, changeset: @changeset)
assert @settings.match_with_change?(change)
end
should "return true if filter matches and accept? is true" do
@settings.accept_for_default = false
- change = FactoryGirl.create(:change, path: '/aaa/bbb/ccc.rb', changeset: @changeset)
+ change = FactoryBot.create(:change, path: '/aaa/bbb/ccc.rb', changeset: @changeset)
assert @settings.match_with_change?(change)
- change = FactoryGirl.create(:change, path: '/trunk/plugins/redmine_code_review/lib/ccc.rb', changeset: @changeset)
+ change = FactoryBot.create(:change, path: '/trunk/plugins/redmine_code_review/lib/ccc.rb', changeset: @changeset)
assert @settings.match_with_change?(change)
end
should "return false if filter matches and accept? is false" do
- change = FactoryGirl.create(:change, path: '/aaa/bbb/ccctest.rb', changeset: @changeset)
+ change = FactoryBot.create(:change, path: '/aaa/bbb/ccctest.rb', changeset: @changeset)
assert !@settings.match_with_change?(change)
end
should "return false if filter doesn't matches and accept_for_default is false" do
- change = FactoryGirl.create(:change, path: '/aaa/bbb/ccctest.html', changeset: @changeset)
+ change = FactoryBot.create(:change, path: '/aaa/bbb/ccctest.html', changeset: @changeset)
@settings.accept_for_default = false
assert !@settings.match_with_change?(change)
end
should "return true if filter doesn't matches and accept_for_default is true" do
- change = FactoryGirl.create(:change, path: '/aaa/bbb/ccctest.html', changeset: @changeset)
+ change = FactoryBot.create(:change, path: '/aaa/bbb/ccctest.html', changeset: @changeset)
@settings.accept_for_default = true
assert @settings.match_with_change?(change)
end
@@ -285,7 +297,7 @@ class CodeReviewAtuoAssignSettingsTest < ActiveSupport::TestCase
should "return false if filters.length is 0 and accept_for_default is false." do
@settings.filters = []
@settings.accept_for_default = false
- change = FactoryGirl.create(:change, changeset: @changeset)
+ change = FactoryBot.create(:change, changeset: @changeset)
assert !@settings.match_with_change?(change)
end
end
@@ -381,5 +393,4 @@ class CodeReviewAtuoAssignSettingsTest < ActiveSupport::TestCase
assert @settings.filter_enabled?
end
end
-
end
diff --git a/test/unit/code_review_change_patch_test.rb b/test/unit/code_review_change_patch_test.rb
index 63c5b8b..10df2e3 100644
--- a/test/unit/code_review_change_patch_test.rb
+++ b/test/unit/code_review_change_patch_test.rb
@@ -19,7 +19,6 @@
class CodeReviewChangePatchTest < ActiveSupport::TestCase
fixtures :code_reviews, :projects, :users, :repositories, :changesets, :changes, :issues, :issue_statuses, :enumerations, :issue_categories, :trackers
-
def test_review_count
change = Change.find(2)
assert_equal(2, change.review_count)
@@ -33,7 +32,6 @@ def test_open_review_count
issue.save
change = Change.find(2)
assert_equal(1, change.open_review_count)
-
end
def test_closed_review_count
@@ -46,21 +44,21 @@ def test_closed_review_count
assert_equal(1, change.closed_review_count)
end
- def test_assignment_count
- change = FactoryGirl.create(:change)
+ def test_assignment_count
+ change = FactoryBot.create(:change)
assert_equal(0, change.assignment_count)
- change.code_review_assignments << FactoryGirl.create(:code_review_assignment)
+ change.code_review_assignments << FactoryBot.create(:code_review_assignment)
assert_equal(1, change.assignment_count)
- change.code_review_assignments << FactoryGirl.create(:code_review_assignment)
+ change.code_review_assignments << FactoryBot.create(:code_review_assignment)
assert_equal(2, change.assignment_count)
end
def test_open_assignment_count
- change = FactoryGirl.create(:change)
- change.code_review_assignments << FactoryGirl.create(:code_review_assignment)
- change.code_review_assignments << FactoryGirl.create(:code_review_assignment)
- change.code_review_assignments << FactoryGirl.create(:code_review_assignment)
- change.code_review_assignments << FactoryGirl.create(:code_review_assignment)
+ change = FactoryBot.create(:change)
+ change.code_review_assignments << FactoryBot.create(:code_review_assignment)
+ change.code_review_assignments << FactoryBot.create(:code_review_assignment)
+ change.code_review_assignments << FactoryBot.create(:code_review_assignment)
+ change.code_review_assignments << FactoryBot.create(:code_review_assignment)
assert_equal(4, change.open_assignment_count)
close_status = IssueStatus.find(5)
change.code_review_assignments[0].issue.status = close_status
@@ -70,11 +68,11 @@ def test_open_assignment_count
end
def test_closed_assignment_count
- change = FactoryGirl.create(:change)
- change.code_review_assignments << FactoryGirl.create(:code_review_assignment)
- change.code_review_assignments << FactoryGirl.create(:code_review_assignment)
- change.code_review_assignments << FactoryGirl.create(:code_review_assignment)
- change.code_review_assignments << FactoryGirl.create(:code_review_assignment)
+ change = FactoryBot.create(:change)
+ change.code_review_assignments << FactoryBot.create(:code_review_assignment)
+ change.code_review_assignments << FactoryBot.create(:code_review_assignment)
+ change.code_review_assignments << FactoryBot.create(:code_review_assignment)
+ change.code_review_assignments << FactoryBot.create(:code_review_assignment)
assert_equal(0, change.closed_assignment_count)
close_status = IssueStatus.find(5)
change.code_review_assignments[0].issue.status = close_status
@@ -85,26 +83,26 @@ def test_closed_assignment_count
context "open_assignments" do
should "return empty array if change has no assignments." do
- change = FactoryGirl.create(:change)
+ change = FactoryBot.create(:change)
assert_equal(0, change.open_assignments.length)
end
should "return empty array if change has no open assignments" do
- change = FactoryGirl.create(:change)
- change.code_review_assignments << FactoryGirl.create(:code_review_assignment)
- change.code_review_assignments << FactoryGirl.create(:code_review_assignment)
+ change = FactoryBot.create(:change)
+ change.code_review_assignments << FactoryBot.create(:code_review_assignment)
+ change.code_review_assignments << FactoryBot.create(:code_review_assignment)
close_status = IssueStatus.find(5)
- change.code_review_assignments.each{|assignments|
+ change.code_review_assignments.each { |assignments|
assignments.issue.status = close_status
}
assert_equal(0, change.open_assignments.length)
end
should "return 2 assignments if change has 2 open assignments" do
- change = FactoryGirl.create(:change)
- change.code_review_assignments << FactoryGirl.create(:code_review_assignment)
- change.code_review_assignments << FactoryGirl.create(:code_review_assignment)
- change.code_review_assignments << FactoryGirl.create(:code_review_assignment)
+ change = FactoryBot.create(:change)
+ change.code_review_assignments << FactoryBot.create(:code_review_assignment)
+ change.code_review_assignments << FactoryBot.create(:code_review_assignment)
+ change.code_review_assignments << FactoryBot.create(:code_review_assignment)
close_status = IssueStatus.find(5)
change.code_review_assignments[0].issue.status = close_status
@@ -112,11 +110,11 @@ def test_closed_assignment_count
end
should "return 2 assignments if change has 2 open assignments which are assigned to user_id 1" do
- change = FactoryGirl.create(:change)
- change.code_review_assignments << FactoryGirl.create(:code_review_assignment)
- change.code_review_assignments << FactoryGirl.create(:code_review_assignment)
- change.code_review_assignments << FactoryGirl.create(:code_review_assignment)
- change.code_review_assignments << FactoryGirl.create(:code_review_assignment)
+ change = FactoryBot.create(:change)
+ change.code_review_assignments << FactoryBot.create(:code_review_assignment)
+ change.code_review_assignments << FactoryBot.create(:code_review_assignment)
+ change.code_review_assignments << FactoryBot.create(:code_review_assignment)
+ change.code_review_assignments << FactoryBot.create(:code_review_assignment)
close_status = IssueStatus.find(5)
change.code_review_assignments[0].issue.status = close_status
change.code_review_assignments[0].issue.assigned_to_id = 1
diff --git a/test/unit/code_review_changeset_patch_test.rb b/test/unit/code_review_changeset_patch_test.rb
index 9502321..8b5e1af 100644
--- a/test/unit/code_review_changeset_patch_test.rb
+++ b/test/unit/code_review_changeset_patch_test.rb
@@ -1,5 +1,5 @@
# Code Review plugin for Redmine
-# Copyright (C) 2009-2014 Haruyuki Iida
+# Copyright (C) 2009-2018 Haruyuki Iida
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -18,10 +18,10 @@
class CodeReviewChangesetPatchTest < ActiveSupport::TestCase
fixtures :code_reviews, :projects, :users, :repositories,
- :changesets, :changes, :members, :member_roles, :roles, :issues, :issue_statuses,
- :enumerations, :issue_categories, :trackers, :projects, :projects_trackers,
- :code_review_project_settings, :attachments, :code_review_assignments,
- :code_review_user_settings
+ :changesets, :changes, :members, :member_roles, :roles, :issues, :issue_statuses,
+ :enumerations, :issue_categories, :trackers, :projects, :projects_trackers,
+ :code_review_project_settings, :attachments, :code_review_assignments,
+ :code_review_user_settings
include CodeReviewAutoAssignSettings
@@ -47,31 +47,32 @@ def test_review_issues
end
def test_assignment_count
+ CodeReviewAssignment.destroy_all
changeset = Changeset.find(100)
assert_equal(0, changeset.assignment_count)
change = changeset.filechanges[0]
- change.code_review_assignments << FactoryGirl.create(:code_review_assignment, issue_id: 1)
- change.code_review_assignments << FactoryGirl.create(:code_review_assignment, issue_id: 2)
+ change.code_review_assignments << FactoryBot.create(:code_review_assignment, issue_id: 1)
+ change.code_review_assignments << FactoryBot.create(:code_review_assignment, issue_id: 2)
change = changeset.filechanges[1]
- change.code_review_assignments << FactoryGirl.create(:code_review_assignment, issue_id: 3)
+ change.code_review_assignments << FactoryBot.create(:code_review_assignment, issue_id: 3)
assert_equal(3, changeset.assignment_count)
end
def test_completed_assignment_pourcent
- changeset = FactoryGirl.create(:changeset)
- FactoryGirl.create(:change, changeset: changeset)
- FactoryGirl.create(:change, changeset: changeset)
+ changeset = FactoryBot.create(:changeset)
+ FactoryBot.create(:change, changeset: changeset)
+ FactoryBot.create(:change, changeset: changeset)
changeset = Changeset.find(changeset.id)
change = changeset.filechanges[0]
- change.code_review_assignments << FactoryGirl.create(:code_review_assignment, issue_id: 1)
- change.code_review_assignments << FactoryGirl.create(:code_review_assignment, issue_id: 2)
+ change.code_review_assignments << FactoryBot.create(:code_review_assignment, issue_id: 1)
+ change.code_review_assignments << FactoryBot.create(:code_review_assignment, issue_id: 2)
change = changeset.filechanges[1]
- change.code_review_assignments << FactoryGirl.create(:code_review_assignment, issue_id: 3)
- change.code_review_assignments << FactoryGirl.create(:code_review_assignment, issue_id: 4)
+ change.code_review_assignments << FactoryBot.create(:code_review_assignment, issue_id: 3)
+ change.code_review_assignments << FactoryBot.create(:code_review_assignment, issue_id: 4)
issues = []
- 1.upto(4) {|i|
+ 1.upto(4) { |i|
issues[i - 1] = Issue.find(i)
issues[i - 1].status_id = 1
issues[i - 1].due_date = nil
@@ -79,6 +80,7 @@ def test_completed_assignment_pourcent
issues[i - 1].save!
}
changeset.save!
+ changeset = Changeset.find(changeset.id)
assert_equal(0, changeset.completed_assignment_pourcent)
issues[0].status_id = 5
issues[0].save!
@@ -88,90 +90,115 @@ def test_completed_assignment_pourcent
issues[1].done_ratio = 50
issues[1].save!
changeset = Changeset.find(changeset.id)
+ assert_equal(4, changeset.assignment_count)
+ assert_equal(3, changeset.open_assignment_count)
assert_equal(37.5.to_i, changeset.completed_assignment_pourcent)
end
context "closed_assignment_pourcent" do
-
should "returns 0 if changeset has no assignments." do
- change = FactoryGirl.create(:change)
+ change = FactoryBot.create(:change)
changeset = change.changeset
assert_equal(0, changeset.closed_assignment_pourcent)
end
should "returns 0 if changeset has no closed assignments." do
- change = FactoryGirl.create(:change)
+ change = FactoryBot.create(:change)
changeset = change.changeset
@project = Project.generate!
issue1 = Issue.generate!({:project => @project, :status_id => 1})
issue2 = Issue.generate!({:project => @project, :status_id => 1})
- change.code_review_assignments << FactoryGirl.create(:code_review_assignment, issue: issue1)
- change.code_review_assignments << FactoryGirl.create(:code_review_assignment, issue: issue2)
+ change.code_review_assignments << FactoryBot.create(:code_review_assignment, issue: issue1)
+ change.code_review_assignments << FactoryBot.create(:code_review_assignment, issue: issue2)
change.save!
assert_equal(0, changeset.closed_assignment_pourcent)
end
should "returns 100 if changeset has no closed assignments." do
- change = FactoryGirl.create(:change)
+ CodeReviewAssignment.destroy_all
+ Issue.destroy_all
+ change = FactoryBot.create(:change)
changeset = change.changeset
@project = Project.find(1)
issue1 = Issue.generate!({:project => @project, :status => IssueStatus.find(5)})
+ issue1.status = IssueStatus.find(5)
+ issue1.save!
+ issue1 = Issue.find(issue1.id)
issue2 = Issue.generate!({:project => @project, :status => IssueStatus.find(5)})
- change.code_review_assignments << FactoryGirl.create(:code_review_assignment, issue: issue1)
- change.code_review_assignments << FactoryGirl.create(:code_review_assignment, issue: issue2)
+ issue2.status = IssueStatus.find(5)
+ issue2.save!
+ issue2 = Issue.find(issue2.id)
+ change.code_review_assignments << FactoryBot.create(:code_review_assignment, issue: issue1)
+ change.code_review_assignments << FactoryBot.create(:code_review_assignment, issue: issue2)
change.save!
- changeset =Changeset.find(changeset.id)
+ changeset = Changeset.find(changeset.id)
+ assert issue1.closed?
+ assert issue2.closed?
assert_equal(2, changeset.assignment_count)
- #assert_equal(100, changeset.closed_assignment_pourcent)
+ assert_equal(1, changeset.filechanges.length)
+ assert_equal(0, changeset.open_assignment_count)
+ assert_equal(2, changeset.closed_assignment_count)
+ assert_equal(100, changeset.closed_assignment_pourcent)
end
should "returns 50 if half of assignments were closed." do
- change = FactoryGirl.create(:change)
+ CodeReviewAssignment.destroy_all
+ Issue.destroy_all
+ Change.destroy_all
+ Changeset.destroy_all
+ change = FactoryBot.create(:change)
changeset = change.changeset
@project = Project.generate!
issue1 = Issue.generate!({:project => @project, :status => IssueStatus.find(5)})
+ issue1.status = IssueStatus.find(5)
+ issue1.save!
issue2 = Issue.generate!({:project => @project, :status => IssueStatus.find(1)})
+ issue2.status = IssueStatus.find(1)
+ issue2.save!
issue3 = Issue.generate!({:project => @project, :status => IssueStatus.find(5)})
+ issue3.status = IssueStatus.find(5)
+ issue3.save!
issue4 = Issue.generate!({:project => @project, :status => IssueStatus.find(1)})
- status1 = IssueStatus.find(1)
- status5 = IssueStatus.find(5)
- assert(!status1.is_closed)
- assert(status5.is_closed)
- change.code_review_assignments << FactoryGirl.create(:code_review_assignment, issue: issue1)
- change.code_review_assignments << FactoryGirl.create(:code_review_assignment, issue: issue2)
+ issue4.status = IssueStatus.find(1)
+ issue4.save!
+ change.code_review_assignments << FactoryBot.create(:code_review_assignment, issue: Issue.find(issue1.id))
+ change.code_review_assignments << FactoryBot.create(:code_review_assignment, issue: Issue.find(issue2.id))
change.save!
- change = FactoryGirl.create(:change, changeset: changeset)
- change.code_review_assignments << FactoryGirl.create(:code_review_assignment, issue: issue3)
- change.code_review_assignments << FactoryGirl.create(:code_review_assignment, issue: issue4)
+ assert_equal(1, change.open_assignment_count)
+ change = FactoryBot.create(:change, changeset: changeset)
+ change.code_review_assignments << FactoryBot.create(:code_review_assignment, issue: Issue.find(issue3.id))
+ change.code_review_assignments << FactoryBot.create(:code_review_assignment, issue: Issue.find(issue4.id))
change.save!
+ changeset.save!
changeset = Changeset.find(changeset.id)
- #assert_equal(50, changeset.closed_assignment_pourcent)
+ assert_equal(2, changeset.open_assignment_count)
+ assert_equal(50, changeset.closed_assignment_pourcent)
end
end
context "assignment_issues" do
should "returns empty array if changeset has no assignments." do
- change = FactoryGirl.create(:change)
+ change = FactoryBot.create(:change)
changeset = change.changeset
assert_not_nil(changeset.assignment_issues)
end
should "returns assignments if changeset has assignments." do
- change = FactoryGirl.create(:change)
+ change = FactoryBot.create(:change)
changeset = change.changeset
assert_not_nil change
- change.code_review_assignments << FactoryGirl.create(:code_review_assignment, issue_id: 1)
- change.code_review_assignments << FactoryGirl.create(:code_review_assignment, issue_id: 2)
+ change.code_review_assignments << FactoryBot.create(:code_review_assignment, issue_id: 1)
+ change.code_review_assignments << FactoryBot.create(:code_review_assignment, issue_id: 2)
change.save!
changeset = Changeset.find(changeset.id)
assert_not_nil(changeset.assignment_issues)
assert_equal(2, changeset.assignment_issues.length)
- change = FactoryGirl.create(:change, changeset: changeset)
+ change = FactoryBot.create(:change, changeset: changeset)
- change.code_review_assignments << FactoryGirl.create(:code_review_assignment, issue_id: 3)
+ change.code_review_assignments << FactoryBot.create(:code_review_assignment, issue_id: 3)
change.save!
changeset = Changeset.find(changeset.id)
@@ -179,7 +206,6 @@ def test_completed_assignment_pourcent
assert_not_nil(changeset.assignment_issues)
assert_equal(3, changeset.assignment_issues.length)
end
-
end
context "after_save" do
@@ -189,7 +215,7 @@ def test_completed_assignment_pourcent
repository = project.repository
- @changeset = FactoryGirl.create(:changeset, repository: repository)
+ @changeset = FactoryBot.create(:changeset, repository: repository)
auto_assign = AutoAssignSettings.new
auto_assign.enabled = true
@@ -217,9 +243,9 @@ def test_completed_assignment_pourcent
should "create assignments" do
count = CodeReviewAssignment.all.length
- change1 = FactoryGirl.create(:change, path: '/aaa/bbb/ccc.rb', changeset: @changeset)
+ change1 = FactoryBot.create(:change, path: '/aaa/bbb/ccc.rb', changeset: @changeset)
assert_equal(count + 1, CodeReviewAssignment.all.length)
- change2 = FactoryGirl.create(:change, path: '/aaa/bbb/ccc2.rb', changeset: @changeset)
+ change2 = FactoryBot.create(:change, path: '/aaa/bbb/ccc2.rb', changeset: @changeset)
assert_equal(count + 1, CodeReviewAssignment.all.length)
end
end
diff --git a/test/unit/code_review_project_settings_test.rb b/test/unit/code_review_project_settings_test.rb
index 971fde8..6046b04 100644
--- a/test/unit/code_review_project_settings_test.rb
+++ b/test/unit/code_review_project_settings_test.rb
@@ -25,7 +25,7 @@ class CodeReviewProjectSettingsTest < ActiveSupport::TestCase
@setting = CodeReviewProjectSetting.new
end
- should "return false if project_id is nil." do
+ should "return false if project_id is nil." do
assert !@setting.save
end
@@ -44,7 +44,7 @@ class CodeReviewProjectSettingsTest < ActiveSupport::TestCase
should "be saved if auto_assign is setted." do
project = Project.find(1)
- setting = FactoryGirl.create(:code_review_project_setting, project: project)
+ setting = FactoryBot.create(:code_review_project_setting, project: project)
id = setting.id
assert !setting.auto_assign_settings.enabled?
setting.auto_assign_settings.enabled = true
@@ -53,55 +53,55 @@ class CodeReviewProjectSettingsTest < ActiveSupport::TestCase
assert setting.auto_assign_settings.enabled?
end
end
-
+
context "issue_relation_type" do
setup do
@setting = CodeReviewProjectSetting.new
end
-
+
should "return IssueRelation::TYPE_RELATES if auto_relation is CodeReviewProjectSetting::AUTORELATION_TYPE_RELATES" do
@setting.auto_relation = CodeReviewProjectSetting::AUTORELATION_TYPE_RELATES
assert_equal(IssueRelation::TYPE_RELATES, @setting.issue_relation_type)
end
-
+
should "return IssueRelation::TYPE_BLOCKS if auto_relation is CodeReviewProjectSetting::AUTORELATION_TYPE_BLOCKS" do
@setting.auto_relation = CodeReviewProjectSetting::AUTORELATION_TYPE_BLOCKS
assert_equal(IssueRelation::TYPE_BLOCKS, @setting.issue_relation_type)
end
-
+
should "return nil if auto_relation is CodeReviewProjectSetting::AUTORELATION_TYPE_NONE" do
@setting.auto_relation = CodeReviewProjectSetting::AUTORELATION_TYPE_NONE
assert_nil(@setting.issue_relation_type)
end
-
+
should "return nil if auto_relation is nil" do
- @setting.auto_relation =nil
+ @setting.auto_relation = nil
assert_nil(@setting.issue_relation_type)
end
end
-
+
context "auto_relation?" do
setup do
@setting = CodeReviewProjectSetting.new
end
-
+
should "return true if auto_relation is CodeReviewProjectSetting::AUTORELATION_TYPE_RELATES" do
@setting.auto_relation = CodeReviewProjectSetting::AUTORELATION_TYPE_RELATES
assert(@setting.issue_relation_type)
end
-
+
should "return true if auto_relation is CodeReviewProjectSetting::AUTORELATION_TYPE_BLOCKS" do
@setting.auto_relation = CodeReviewProjectSetting::AUTORELATION_TYPE_BLOCKS
assert(@setting.issue_relation_type)
end
-
+
should "return false if auto_relation is CodeReviewProjectSetting::AUTORELATION_TYPE_NONE" do
@setting.auto_relation = CodeReviewProjectSetting::AUTORELATION_TYPE_NONE
assert !(@setting.issue_relation_type)
end
-
+
should "return false if auto_relation is nil" do
- @setting.auto_relation =nil
+ @setting.auto_relation = nil
assert !(@setting.issue_relation_type)
end
end
diff --git a/test/unit/code_review_test.rb b/test/unit/code_review_test.rb
index c667836..7a0a492 100644
--- a/test/unit/code_review_test.rb
+++ b/test/unit/code_review_test.rb
@@ -18,7 +18,7 @@
class CodeReviewTest < ActiveSupport::TestCase
fixtures :code_reviews, :projects, :users, :repositories, :changesets,
- :changes, :issues, :issue_statuses , :enumerations, :issue_categories,
+ :changes, :issues, :issue_statuses, :enumerations, :issue_categories,
:trackers, :projects_trackers, :attachments
# Create new object.
@@ -29,15 +29,15 @@ def test_create
code_review.project_id = 1
code_review.issue.project_id = 1
code_review.comment = "aaa"
- code_review.user_id = 1;
- code_review.change_id = 1;
- code_review.updated_by_id = 1;
+ code_review.user_id = 1
+ code_review.change_id = 1
+ code_review.updated_by_id = 1
code_review.subject = "aaa"
code_review.action_type = 'diff'
code_review.line = 20
assert code_review.save
-
+
code_review.destroy
end
@@ -81,8 +81,6 @@ def test_repository
assert_equal(10, code_review.repository.id)
end
-
-
def test_is_closed?
review = CodeReview.find(9)
assert !review.is_closed?
@@ -105,7 +103,6 @@ def test_status_id
assert_equal(review.status_id, review.issue.status_id)
review.status_id = 5
assert_equal(5, review.issue.status_id)
-
end
def test_user
@@ -115,15 +112,17 @@ def test_user
issue = review.issue
assert_equal(issue.author_id, 2)
end
+
private
+
def newreview
code_review = CodeReview.new
code_review.issue = Issue.new
- code_review.project_id = 1;
+ code_review.project_id = 1
code_review.comment = "aaa"
- code_review.user_id = 1;
- code_review.change_id = 1;
- code_review.updated_by_id = 1;
+ code_review.user_id = 1
+ code_review.change_id = 1
+ code_review.updated_by_id = 1
return code_review
end
end
diff --git a/travis/env.sh b/travis/env.sh
new file mode 100644
index 0000000..3ba4f48
--- /dev/null
+++ b/travis/env.sh
@@ -0,0 +1,5 @@
+export TRAVISDIR=`pwd`
+export PATH_TO_PLUGIN=`dirname ${TRAVISDIR}`
+export TESTSPACE=$PATH_TO_PLUGIN/testspace
+export PATH_TO_REDMINE=$TESTSPACE/redmine
+export RAILS_ENV=test
\ No newline at end of file
diff --git a/travis/travis.sh b/travis/travis.sh
new file mode 100644
index 0000000..6d901d9
--- /dev/null
+++ b/travis/travis.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+set -e
+
+cd `dirname $0`
+. env.sh
+cd ..
+
+if [ "$NAME_OF_PLUGIN" == "" ]
+then
+ export NAME_OF_PLUGIN=`basename $PATH_TO_PLUGIN`
+fi
+
+cd $PATH_TO_REDMINE
+
+bundle exec rake db:structure:dump
+
+# create scms for test
+bundle exec rake test:scm:setup:all
+
+# run tests
+# bundle exec rake TEST=test/unit/role_test.rb
+bundle exec rake redmine:plugins:test NAME=$NAME_OF_PLUGIN
+
diff --git a/travis.sh b/travis/travis_install.sh
similarity index 63%
rename from travis.sh
rename to travis/travis_install.sh
index 16d5341..8bd0755 100644
--- a/travis.sh
+++ b/travis/travis_install.sh
@@ -1,29 +1,37 @@
#!/bin/bash
-#/bin/bash
-
set -e
+cd `dirname $0`
+. env.sh
+cd ..
+
if [[ ! "$TESTSPACE" = /* ]] ||
[[ ! "$PATH_TO_REDMINE" = /* ]] ||
- [[ ! "$REDMINE_VER" = * ]] ||
- [[ ! "$NAME_OF_PLUGIN" = * ]] ||
[[ ! "$PATH_TO_PLUGIN" = /* ]];
then
echo "You should set"\
- " TESTSPACE, PATH_TO_REDMINE, REDMINE_VER"\
- " NAME_OF_PLUGIN, PATH_TO_PLUGIN"\
+ " TESTSPACE, PATH_TO_REDMINE,"\
+ " PATH_TO_PLUGIN"\
" environment variables"
echo "You set:"\
"$TESTSPACE"\
"$PATH_TO_REDMINE"\
- "$REDMINE_VER"\
- "$NAME_OF_PLUGIN"\
"$PATH_TO_PLUGIN"
exit 1;
fi
-export RAILS_ENV=test
+if [ "$REDMINE_VER" = "" ]
+then
+ export REDMINE_VER=master
+fi
+
+if [ "$NAME_OF_PLUGIN" == "" ]
+then
+ export NAME_OF_PLUGIN=`basename $PATH_TO_PLUGIN`
+fi
+
+mkdir -p $TESTSPACE
export REDMINE_GIT_REPO=git://github.com/redmine/redmine.git
export REDMINE_GIT_TAG=$REDMINE_VER
@@ -36,7 +44,7 @@ fi
# checkout redmine
git clone $REDMINE_GIT_REPO $PATH_TO_REDMINE
-cp test/fixtures/* ${PATH_TO_REDMINE}/test/fixtures/
+
cd $PATH_TO_REDMINE
if [ ! "$REDMINE_GIT_TAG" = "master" ];
then
@@ -63,16 +71,4 @@ bundle exec rake db:migrate
# run plugin database migrations
bundle exec rake redmine:plugins:migrate
-# install redmine database
-#bundle exec rake redmine:load_default_data REDMINE_LANG=en
-
-bundle exec rake db:structure:dump
-
-# create scms for test
-
-bundle exec rake test:scm:setup:all
-
-# run tests
-# bundle exec rake TEST=test/unit/role_test.rb
-bundle exec rake redmine:plugins:test NAME=$NAME_OF_PLUGIN
|