update tests to work with the new data model, where neccessary
This commit is contained in:
parent
81e97d23a8
commit
1f9eda4e0d
@ -19,8 +19,14 @@ require "digest/md5"
|
|||||||
|
|
||||||
class Attachment < ActiveRecord::Base
|
class Attachment < ActiveRecord::Base
|
||||||
belongs_to :container, :polymorphic => true
|
belongs_to :container, :polymorphic => true
|
||||||
|
|
||||||
|
# FIXME: Remove these once the Versions, Documents and Projects themselves can provide file events
|
||||||
|
belongs_to :version, :foreign_key => "container_id"
|
||||||
|
belongs_to :document, :foreign_key => "container_id"
|
||||||
|
belongs_to :project, :foreign_key => "container_id"
|
||||||
|
|
||||||
belongs_to :author, :class_name => "User", :foreign_key => "author_id"
|
belongs_to :author, :class_name => "User", :foreign_key => "author_id"
|
||||||
|
|
||||||
validates_presence_of :container, :filename, :author
|
validates_presence_of :container, :filename, :author
|
||||||
validates_length_of :filename, :maximum => 255
|
validates_length_of :filename, :maximum => 255
|
||||||
validates_length_of :disk_filename, :maximum => 255
|
validates_length_of :disk_filename, :maximum => 255
|
||||||
@ -31,16 +37,24 @@ class Attachment < ActiveRecord::Base
|
|||||||
:id => o.versioned_id, :filename => o.filename }
|
:id => o.versioned_id, :filename => o.filename }
|
||||||
end),
|
end),
|
||||||
:activity_type => 'files',
|
:activity_type => 'files',
|
||||||
:activity_permission => :view_files
|
:activity_permission => :view_files,
|
||||||
|
:activity_find_options => { :include => { :version => :project } }
|
||||||
|
|
||||||
acts_as_activity :type => 'documents', :permission => :view_documents
|
acts_as_activity :type => 'documents', :permission => :view_documents,
|
||||||
|
:find_options => { :include => { :document => :project } }
|
||||||
|
|
||||||
|
# This method is called on save by the AttachmentJournal in order to
|
||||||
|
# decide which kind of activity we are dealing with. When that activity
|
||||||
|
# is retrieved later, we don't need to check the container_type in
|
||||||
|
# SQL anymore as that will be just the one we have specified here.
|
||||||
def activity_type
|
def activity_type
|
||||||
case container_type
|
case container_type
|
||||||
when "Document"
|
when "Document"
|
||||||
"documents"
|
"documents"
|
||||||
when "Version"
|
when "Version"
|
||||||
"files"
|
"files"
|
||||||
|
when "Project"
|
||||||
|
"files"
|
||||||
else
|
else
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
@ -774,6 +774,14 @@ class Issue < ActiveRecord::Base
|
|||||||
and i.project_id=#{project.id}
|
and i.project_id=#{project.id}
|
||||||
group by s.id, s.is_closed, j.id")
|
group by s.id, s.is_closed, j.id")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
IssueJournal.class_eval do
|
||||||
|
# Shortcut
|
||||||
|
def new_status
|
||||||
|
if details.keys.include? 'status_id'
|
||||||
|
(newval = details['status_id'].last) ? IssueStatus.find_by_id(newval.to_i) : nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -5,12 +5,12 @@
|
|||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
@ -20,25 +20,25 @@ class MailHandler < ActionMailer::Base
|
|||||||
|
|
||||||
class UnauthorizedAction < StandardError; end
|
class UnauthorizedAction < StandardError; end
|
||||||
class MissingInformation < StandardError; end
|
class MissingInformation < StandardError; end
|
||||||
|
|
||||||
attr_reader :email, :user
|
attr_reader :email, :user
|
||||||
|
|
||||||
def self.receive(email, options={})
|
def self.receive(email, options={})
|
||||||
@@handler_options = options.dup
|
@@handler_options = options.dup
|
||||||
|
|
||||||
@@handler_options[:issue] ||= {}
|
@@handler_options[:issue] ||= {}
|
||||||
|
|
||||||
@@handler_options[:allow_override] = @@handler_options[:allow_override].split(',').collect(&:strip) if @@handler_options[:allow_override].is_a?(String)
|
@@handler_options[:allow_override] = @@handler_options[:allow_override].split(',').collect(&:strip) if @@handler_options[:allow_override].is_a?(String)
|
||||||
@@handler_options[:allow_override] ||= []
|
@@handler_options[:allow_override] ||= []
|
||||||
# Project needs to be overridable if not specified
|
# Project needs to be overridable if not specified
|
||||||
@@handler_options[:allow_override] << 'project' unless @@handler_options[:issue].has_key?(:project)
|
@@handler_options[:allow_override] << 'project' unless @@handler_options[:issue].has_key?(:project)
|
||||||
# Status overridable by default
|
# Status overridable by default
|
||||||
@@handler_options[:allow_override] << 'status' unless @@handler_options[:issue].has_key?(:status)
|
@@handler_options[:allow_override] << 'status' unless @@handler_options[:issue].has_key?(:status)
|
||||||
|
|
||||||
@@handler_options[:no_permission_check] = (@@handler_options[:no_permission_check].to_s == '1' ? true : false)
|
@@handler_options[:no_permission_check] = (@@handler_options[:no_permission_check].to_s == '1' ? true : false)
|
||||||
super email
|
super email
|
||||||
end
|
end
|
||||||
|
|
||||||
# Processes incoming emails
|
# Processes incoming emails
|
||||||
# Returns the created object (eg. an issue, a message) or false
|
# Returns the created object (eg. an issue, a message) or false
|
||||||
def receive(email)
|
def receive(email)
|
||||||
@ -77,13 +77,13 @@ class MailHandler < ActionMailer::Base
|
|||||||
User.current = @user
|
User.current = @user
|
||||||
dispatch
|
dispatch
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
MESSAGE_ID_RE = %r{^<redmine\.([a-z0-9_]+)\-(\d+)\.\d+@}
|
MESSAGE_ID_RE = %r{^<redmine\.([a-z0-9_]+)\-(\d+)\.\d+@}
|
||||||
ISSUE_REPLY_SUBJECT_RE = %r{\[[^\]]*#(\d+)\]}
|
ISSUE_REPLY_SUBJECT_RE = %r{\[[^\]]*#(\d+)\]}
|
||||||
MESSAGE_REPLY_SUBJECT_RE = %r{\[[^\]]*msg(\d+)\]}
|
MESSAGE_REPLY_SUBJECT_RE = %r{\[[^\]]*msg(\d+)\]}
|
||||||
|
|
||||||
def dispatch
|
def dispatch
|
||||||
headers = [email.in_reply_to, email.references].flatten.compact
|
headers = [email.in_reply_to, email.references].flatten.compact
|
||||||
if headers.detect {|h| h.to_s =~ MESSAGE_ID_RE}
|
if headers.detect {|h| h.to_s =~ MESSAGE_ID_RE}
|
||||||
@ -112,7 +112,7 @@ class MailHandler < ActionMailer::Base
|
|||||||
logger.error "MailHandler: unauthorized attempt from #{user}" if logger
|
logger.error "MailHandler: unauthorized attempt from #{user}" if logger
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
# Creates a new issue
|
# Creates a new issue
|
||||||
def receive_issue
|
def receive_issue
|
||||||
project = target_project
|
project = target_project
|
||||||
@ -153,7 +153,7 @@ class MailHandler < ActionMailer::Base
|
|||||||
logger.info "MailHandler: issue ##{issue.id} created by #{user}" if logger && logger.info
|
logger.info "MailHandler: issue ##{issue.id} created by #{user}" if logger && logger.info
|
||||||
issue
|
issue
|
||||||
end
|
end
|
||||||
|
|
||||||
def target_project
|
def target_project
|
||||||
# TODO: other ways to specify project:
|
# TODO: other ways to specify project:
|
||||||
# * parse the email To field
|
# * parse the email To field
|
||||||
@ -162,14 +162,14 @@ class MailHandler < ActionMailer::Base
|
|||||||
raise MissingInformation.new('Unable to determine target project') if target.nil?
|
raise MissingInformation.new('Unable to determine target project') if target.nil?
|
||||||
target
|
target
|
||||||
end
|
end
|
||||||
|
|
||||||
# Adds a note to an existing issue
|
# Adds a note to an existing issue
|
||||||
def receive_issue_reply(issue_id)
|
def receive_issue_reply(issue_id)
|
||||||
status = (get_keyword(:status) && IssueStatus.find_by_name(get_keyword(:status)))
|
status = (get_keyword(:status) && IssueStatus.find_by_name(get_keyword(:status)))
|
||||||
due_date = get_keyword(:due_date, :override => true)
|
due_date = get_keyword(:due_date, :override => true)
|
||||||
start_date = get_keyword(:start_date, :override => true)
|
start_date = get_keyword(:start_date, :override => true)
|
||||||
assigned_to = (get_keyword(:assigned_to, :override => true) && find_user_from_keyword(get_keyword(:assigned_to, :override => true)))
|
assigned_to = (get_keyword(:assigned_to, :override => true) && find_user_from_keyword(get_keyword(:assigned_to, :override => true)))
|
||||||
|
|
||||||
issue = Issue.find_by_id(issue_id)
|
issue = Issue.find_by_id(issue_id)
|
||||||
return unless issue
|
return unless issue
|
||||||
# check permission
|
# check permission
|
||||||
@ -188,16 +188,16 @@ class MailHandler < ActionMailer::Base
|
|||||||
issue.start_date = start_date if start_date
|
issue.start_date = start_date if start_date
|
||||||
issue.due_date = due_date if due_date
|
issue.due_date = due_date if due_date
|
||||||
issue.assigned_to = assigned_to if assigned_to
|
issue.assigned_to = assigned_to if assigned_to
|
||||||
|
|
||||||
issue.save!
|
issue.save!
|
||||||
logger.info "MailHandler: issue ##{issue.id} updated by #{user}" if logger && logger.info
|
logger.info "MailHandler: issue ##{issue.id} updated by #{user}" if logger && logger.info
|
||||||
journal
|
journal
|
||||||
end
|
end
|
||||||
|
|
||||||
# Reply will be added to the issue
|
# Reply will be added to the issue
|
||||||
def receive_journal_reply(journal_id)
|
def receive_journal_reply(journal_id)
|
||||||
journal = Journal.find_by_id(journal_id)
|
journal = Journal.find_by_id(journal_id)
|
||||||
if journal && journal.versioned.is_a? Issue
|
if journal and journal.versioned.is_a? Issue
|
||||||
receive_issue_reply(journal.versioned_id)
|
receive_issue_reply(journal.versioned_id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -207,11 +207,11 @@ class MailHandler < ActionMailer::Base
|
|||||||
message = Message.find_by_id(message_id)
|
message = Message.find_by_id(message_id)
|
||||||
if message
|
if message
|
||||||
message = message.root
|
message = message.root
|
||||||
|
|
||||||
unless @@handler_options[:no_permission_check]
|
unless @@handler_options[:no_permission_check]
|
||||||
raise UnauthorizedAction unless user.allowed_to?(:add_messages, message.project)
|
raise UnauthorizedAction unless user.allowed_to?(:add_messages, message.project)
|
||||||
end
|
end
|
||||||
|
|
||||||
if !message.locked?
|
if !message.locked?
|
||||||
reply = Message.new(:subject => email.subject.gsub(%r{^.*msg\d+\]}, '').strip,
|
reply = Message.new(:subject => email.subject.gsub(%r{^.*msg\d+\]}, '').strip,
|
||||||
:content => cleaned_up_text_body)
|
:content => cleaned_up_text_body)
|
||||||
@ -225,7 +225,7 @@ class MailHandler < ActionMailer::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_attachments(obj)
|
def add_attachments(obj)
|
||||||
if email.has_attachments?
|
if email.has_attachments?
|
||||||
email.attachments.each do |attachment|
|
email.attachments.each do |attachment|
|
||||||
@ -236,7 +236,7 @@ class MailHandler < ActionMailer::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Adds To and Cc as watchers of the given object if the sender has the
|
# Adds To and Cc as watchers of the given object if the sender has the
|
||||||
# appropriate permission
|
# appropriate permission
|
||||||
def add_watchers(obj)
|
def add_watchers(obj)
|
||||||
@ -248,7 +248,7 @@ class MailHandler < ActionMailer::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_keyword(attr, options={})
|
def get_keyword(attr, options={})
|
||||||
@keywords ||= {}
|
@keywords ||= {}
|
||||||
if @keywords.has_key?(attr)
|
if @keywords.has_key?(attr)
|
||||||
@ -263,7 +263,7 @@ class MailHandler < ActionMailer::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the text/plain part of the email
|
# Returns the text/plain part of the email
|
||||||
# If not found (eg. HTML-only email), returns the body with tags removed
|
# If not found (eg. HTML-only email), returns the body with tags removed
|
||||||
def plain_text_body
|
def plain_text_body
|
||||||
@ -284,7 +284,7 @@ class MailHandler < ActionMailer::Base
|
|||||||
@plain_text_body.strip!
|
@plain_text_body.strip!
|
||||||
@plain_text_body
|
@plain_text_body
|
||||||
end
|
end
|
||||||
|
|
||||||
def cleaned_up_text_body
|
def cleaned_up_text_body
|
||||||
cleanup_body(plain_text_body)
|
cleanup_body(plain_text_body)
|
||||||
end
|
end
|
||||||
@ -292,19 +292,19 @@ class MailHandler < ActionMailer::Base
|
|||||||
def self.full_sanitizer
|
def self.full_sanitizer
|
||||||
@full_sanitizer ||= HTML::FullSanitizer.new
|
@full_sanitizer ||= HTML::FullSanitizer.new
|
||||||
end
|
end
|
||||||
|
|
||||||
# Creates a user account for the +email+ sender
|
# Creates a user account for the +email+ sender
|
||||||
def self.create_user_from_email(email)
|
def self.create_user_from_email(email)
|
||||||
addr = email.from_addrs.to_a.first
|
addr = email.from_addrs.to_a.first
|
||||||
if addr && !addr.spec.blank?
|
if addr && !addr.spec.blank?
|
||||||
user = User.new
|
user = User.new
|
||||||
user.mail = addr.spec
|
user.mail = addr.spec
|
||||||
|
|
||||||
names = addr.name.blank? ? addr.spec.gsub(/@.*$/, '').split('.') : addr.name.split
|
names = addr.name.blank? ? addr.spec.gsub(/@.*$/, '').split('.') : addr.name.split
|
||||||
user.firstname = names.shift
|
user.firstname = names.shift
|
||||||
user.lastname = names.join(' ')
|
user.lastname = names.join(' ')
|
||||||
user.lastname = '-' if user.lastname.blank?
|
user.lastname = '-' if user.lastname.blank?
|
||||||
|
|
||||||
user.login = user.mail
|
user.login = user.mail
|
||||||
user.password = ActiveSupport::SecureRandom.hex(5)
|
user.password = ActiveSupport::SecureRandom.hex(5)
|
||||||
user.language = Setting.default_language
|
user.language = Setting.default_language
|
||||||
@ -313,7 +313,7 @@ class MailHandler < ActionMailer::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# Removes the email body of text after the truncation configurations.
|
# Removes the email body of text after the truncation configurations.
|
||||||
def cleanup_body(body)
|
def cleanup_body(body)
|
||||||
delimiters = Setting.mail_handler_body_delimiters.to_s.split(/[\r\n]+/).reject(&:blank?).map {|s| Regexp.escape(s)}
|
delimiters = Setting.mail_handler_body_delimiters.to_s.split(/[\r\n]+/).reject(&:blank?).map {|s| Regexp.escape(s)}
|
||||||
|
@ -19,6 +19,7 @@ class Mailer < ActionMailer::Base
|
|||||||
layout 'mailer'
|
layout 'mailer'
|
||||||
helper :application
|
helper :application
|
||||||
helper :issues
|
helper :issues
|
||||||
|
helper :journals
|
||||||
helper :custom_fields
|
helper :custom_fields
|
||||||
|
|
||||||
include ActionController::UrlWriter
|
include ActionController::UrlWriter
|
||||||
|
@ -31,7 +31,8 @@ class Message < ActiveRecord::Base
|
|||||||
else
|
else
|
||||||
{:id => o.parent_id, :r => o.id, :anchor => "message-#{o.id}"}
|
{:id => o.parent_id, :r => o.id, :anchor => "message-#{o.id}"}
|
||||||
end.reverse_merge :controller => 'messages', :action => 'show', :board_id => o.board_id
|
end.reverse_merge :controller => 'messages', :action => 'show', :board_id => o.board_id
|
||||||
end)
|
end),
|
||||||
|
:activity_find_options => { :include => { :board => :project } }
|
||||||
|
|
||||||
acts_as_searchable :columns => ['subject', 'content'],
|
acts_as_searchable :columns => ['subject', 'content'],
|
||||||
:include => {:board => :project},
|
:include => {:board => :project},
|
||||||
|
@ -27,7 +27,8 @@ class WikiContent < ActiveRecord::Base
|
|||||||
:event_title => Proc.new {|o| "#{l(:label_wiki_edit)}: #{o.page.title} (##{o.version})"},
|
:event_title => Proc.new {|o| "#{l(:label_wiki_edit)}: #{o.page.title} (##{o.version})"},
|
||||||
:event_url => Proc.new {|o| {:controller => 'wiki', :id => o.page.wiki.project_id, :page => o.page.title, :version => o.version}},
|
:event_url => Proc.new {|o| {:controller => 'wiki', :id => o.page.wiki.project_id, :page => o.page.title, :version => o.version}},
|
||||||
:activity_type => 'wiki_edits',
|
:activity_type => 'wiki_edits',
|
||||||
:activity_permission => :view_wiki_edits
|
:activity_permission => :view_wiki_edits,
|
||||||
|
:activity_find_options => { :include => { :page => { :wiki => :project } } }
|
||||||
|
|
||||||
def activity_type
|
def activity_type
|
||||||
'wiki_edits'
|
'wiki_edits'
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<% for detail in @journal.details %>
|
<% for detail in @journal.details %>
|
||||||
<li><%= show_detail(detail, true) %></li>
|
<li><%= @journal.render_detail(detail, true) %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<%= l(:text_issue_updated, :id => "##{@issue.id}", :author => @journal.user) %>
|
<%= l(:text_issue_updated, :id => "##{@issue.id}", :author => @journal.user) %>
|
||||||
|
|
||||||
<% for detail in @journal.details -%>
|
<% for detail in @journal.details -%>
|
||||||
<%= show_detail(detail, true) %>
|
<%= @journal.render_detail(detail, true) %>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
||||||
<%= @journal.notes if @journal.notes? %>
|
<%= @journal.notes if @journal.notes? %>
|
||||||
|
@ -2,7 +2,7 @@ class RenameCommentToComments < ActiveRecord::Migration
|
|||||||
def self.up
|
def self.up
|
||||||
rename_column(:comments, :comment, :comments) if ActiveRecord::Base.connection.columns(Comment.table_name).detect{|c| c.name == "comment"}
|
rename_column(:comments, :comment, :comments) if ActiveRecord::Base.connection.columns(Comment.table_name).detect{|c| c.name == "comment"}
|
||||||
rename_column(:wiki_contents, :comment, :comments) if ActiveRecord::Base.connection.columns(WikiContent.table_name).detect{|c| c.name == "comment"}
|
rename_column(:wiki_contents, :comment, :comments) if ActiveRecord::Base.connection.columns(WikiContent.table_name).detect{|c| c.name == "comment"}
|
||||||
rename_column(:wiki_content_versions, :comment, :comments) if ActiveRecord::Base.connection.columns(WikiContent.versioned_table_name).detect{|c| c.name == "comment"}
|
rename_column(:wiki_content_versions, :comment, :comments) if ActiveRecord::Base.connection.columns("wiki_content_versions").detect{|c| c.name == "comment"}
|
||||||
rename_column(:time_entries, :comment, :comments) if ActiveRecord::Base.connection.columns(TimeEntry.table_name).detect{|c| c.name == "comment"}
|
rename_column(:time_entries, :comment, :comments) if ActiveRecord::Base.connection.columns(TimeEntry.table_name).detect{|c| c.name == "comment"}
|
||||||
rename_column(:changesets, :comment, :comments) if ActiveRecord::Base.connection.columns(Changeset.table_name).detect{|c| c.name == "comment"}
|
rename_column(:changesets, :comment, :comments) if ActiveRecord::Base.connection.columns(Changeset.table_name).detect{|c| c.name == "comment"}
|
||||||
end
|
end
|
||||||
|
@ -36,13 +36,13 @@ module Redmine
|
|||||||
# Returns an array of available event types
|
# Returns an array of available event types
|
||||||
def event_types
|
def event_types
|
||||||
return @event_types unless @event_types.nil?
|
return @event_types unless @event_types.nil?
|
||||||
|
|
||||||
@event_types = Redmine::Activity.available_event_types
|
@event_types = Redmine::Activity.available_event_types
|
||||||
@event_types = @event_types.select do |o|
|
if @project
|
||||||
permissions = constantized_providers(o).collect do |p|
|
@event_types = @event_types.select do |o|
|
||||||
p.activity_provider_options[o].try(:[], :permission)
|
permissions = constantized_providers(o).collect do |p|
|
||||||
end.compact
|
p.activity_provider_options[o].try(:[], :permission)
|
||||||
if @project
|
end.compact
|
||||||
return @user.allowed_to?("view_#{o}".to_sym, @project) if permissions.blank?
|
return @user.allowed_to?("view_#{o}".to_sym, @project) if permissions.blank?
|
||||||
permissions.all? {|p| @user.allowed_to?(p, @project) } if @project
|
permissions.all? {|p| @user.allowed_to?(p, @project) } if @project
|
||||||
end
|
end
|
||||||
|
22
test/fixtures/journal_details.yml
vendored
22
test/fixtures/journal_details.yml
vendored
@ -1,22 +0,0 @@
|
|||||||
---
|
|
||||||
journal_details_001:
|
|
||||||
old_value: "1"
|
|
||||||
property: attr
|
|
||||||
id: 1
|
|
||||||
value: "2"
|
|
||||||
prop_key: status_id
|
|
||||||
journal_id: 1
|
|
||||||
journal_details_002:
|
|
||||||
old_value: "40"
|
|
||||||
property: attr
|
|
||||||
id: 2
|
|
||||||
value: "30"
|
|
||||||
prop_key: done_ratio
|
|
||||||
journal_id: 1
|
|
||||||
journal_details_003:
|
|
||||||
old_value: nil
|
|
||||||
property: attr
|
|
||||||
id: 3
|
|
||||||
value: "6"
|
|
||||||
prop_key: fixed_version_id
|
|
||||||
journal_id: 4
|
|
193
test/fixtures/journals.yml
vendored
193
test/fixtures/journals.yml
vendored
@ -1,29 +1,180 @@
|
|||||||
---
|
---
|
||||||
journals_001:
|
journals_001:
|
||||||
created_on: <%= 2.days.ago.to_date.to_s(:db) %>
|
|
||||||
notes: "Journal notes"
|
|
||||||
id: 1
|
id: 1
|
||||||
journalized_type: Issue
|
type: "IssueJournal"
|
||||||
|
activity_type: "issues"
|
||||||
|
created_at: <%= 2.days.ago.to_date.to_s(:db) %>
|
||||||
|
version: 1
|
||||||
user_id: 1
|
user_id: 1
|
||||||
journalized_id: 1
|
notes: "Journal notes"
|
||||||
journals_002:
|
versioned_id: 1
|
||||||
created_on: <%= 1.days.ago.to_date.to_s(:db) %>
|
changes: |
|
||||||
notes: "Some notes with Redmine links: #2, r2."
|
---
|
||||||
|
status_id:
|
||||||
|
- 1
|
||||||
|
- 2
|
||||||
|
done_ratio:
|
||||||
|
- 40
|
||||||
|
- 30
|
||||||
|
journals_002:
|
||||||
id: 2
|
id: 2
|
||||||
journalized_type: Issue
|
type: "IssueJournal"
|
||||||
|
activity_type: "issues"
|
||||||
|
created_at: <%= 1.days.ago.to_date.to_s(:db) %>
|
||||||
|
version: 2
|
||||||
user_id: 2
|
user_id: 2
|
||||||
journalized_id: 1
|
notes: "Some notes with Redmine links: #2, r2."
|
||||||
journals_003:
|
versioned_id: 1
|
||||||
created_on: <%= 1.days.ago.to_date.to_s(:db) %>
|
changes: "--- {}"
|
||||||
notes: "A comment with inline image: !picture.jpg!"
|
journals_003:
|
||||||
id: 3
|
id: 3
|
||||||
journalized_type: Issue
|
type: "IssueJournal"
|
||||||
|
activity_type: "issues"
|
||||||
|
created_at: <%= 1.days.ago.to_date.to_s(:db) %>
|
||||||
|
version: 1
|
||||||
user_id: 2
|
user_id: 2
|
||||||
journalized_id: 2
|
notes: "A comment with inline image: !picture.jpg!"
|
||||||
journals_004:
|
versioned_id: 2
|
||||||
created_on: <%= 1.days.ago.to_date.to_s(:db) %>
|
changes: "--- {}"
|
||||||
notes: "A comment with a private version."
|
journals_004:
|
||||||
id: 4
|
id: 4
|
||||||
journalized_type: Issue
|
type: "IssueJournal"
|
||||||
|
activity_type: "issues"
|
||||||
|
created_at: <%= 1.days.ago.to_date.to_s(:db) %>
|
||||||
|
version: 1
|
||||||
|
user_id: 2
|
||||||
|
notes: "A comment with a private version."
|
||||||
|
versioned_id: 6
|
||||||
|
changes: |
|
||||||
|
---
|
||||||
|
fixed_version_id:
|
||||||
|
-
|
||||||
|
- 6
|
||||||
|
journals_005:
|
||||||
|
id: 5
|
||||||
|
type: "IssueJournal"
|
||||||
|
activity_type: "issues"
|
||||||
|
created_at: <%= 1.days.ago.to_date.to_s(:db) %>
|
||||||
|
version: 0
|
||||||
user_id: 1
|
user_id: 1
|
||||||
journalized_id: 6
|
notes:
|
||||||
|
versioned_id: 5
|
||||||
|
changes: "--- {}"
|
||||||
|
journals_006:
|
||||||
|
id: 6
|
||||||
|
type: "WikiContentJournal"
|
||||||
|
activity_type: "wiki_edits"
|
||||||
|
created_at: 2007-03-07 00:08:07 +01:00
|
||||||
|
version: 1
|
||||||
|
user_id: 2
|
||||||
|
notes: Page creation
|
||||||
|
versioned_id: 1
|
||||||
|
changes: |
|
||||||
|
---
|
||||||
|
compression: ""
|
||||||
|
data: |-
|
||||||
|
h1. CookBook documentation
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Some [[documentation]] here...
|
||||||
|
journals_007:
|
||||||
|
id: 7
|
||||||
|
type: "WikiContentJournal"
|
||||||
|
activity_type: "wiki_edits"
|
||||||
|
created_at: 2007-03-07 00:08:34 +01:00
|
||||||
|
version: 2
|
||||||
|
user_id: 1
|
||||||
|
notes: Small update
|
||||||
|
versioned_id: 1
|
||||||
|
changes: |
|
||||||
|
---
|
||||||
|
compression: ""
|
||||||
|
data: |-
|
||||||
|
h1. CookBook documentation
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Some updated [[documentation]] here...
|
||||||
|
journals_008:
|
||||||
|
id: 8
|
||||||
|
type: "WikiContentJournal"
|
||||||
|
activity_type: "wiki_edits"
|
||||||
|
created_at: 2007-03-07 00:10:51 +01:00
|
||||||
|
version: 3
|
||||||
|
user_id: 1
|
||||||
|
notes: ""
|
||||||
|
versioned_id: 1
|
||||||
|
changes: |
|
||||||
|
---
|
||||||
|
compression: ""
|
||||||
|
data: |-
|
||||||
|
h1. CookBook documentation
|
||||||
|
Some updated [[documentation]] here...
|
||||||
|
journals_009:
|
||||||
|
id: 9
|
||||||
|
type: "WikiContentJournal"
|
||||||
|
activity_type: "wiki_edits"
|
||||||
|
created_at: 2007-03-08 00:18:07 +01:00
|
||||||
|
version: 1
|
||||||
|
user_id: 1
|
||||||
|
notes:
|
||||||
|
versioned_id: 2
|
||||||
|
changes: |
|
||||||
|
---
|
||||||
|
data: |-
|
||||||
|
h1. Another page
|
||||||
|
|
||||||
|
This is a link to a ticket: #2
|
||||||
|
|
||||||
|
|
||||||
|
journals_010:
|
||||||
|
id: 10
|
||||||
|
type: "MessageJournal"
|
||||||
|
activity_type: "messages"
|
||||||
|
created_at: <%= 2.days.ago.to_date.to_s(:db) %>
|
||||||
|
version: 1
|
||||||
|
user_id: 1
|
||||||
|
notes:
|
||||||
|
versioned_id: 5
|
||||||
|
changes: --- {}
|
||||||
|
journals_011:
|
||||||
|
id: 11
|
||||||
|
type: "AttachmentJournal"
|
||||||
|
activity_type: "files"
|
||||||
|
created_at: <%= 2.days.ago.to_date.to_s(:db) %>
|
||||||
|
version: 1
|
||||||
|
user_id: 2
|
||||||
|
notes: "An attachment on a version"
|
||||||
|
versioned_id: 9
|
||||||
|
changes: --- {}
|
||||||
|
journals_012:
|
||||||
|
id: 12
|
||||||
|
type: "AttachmentJournal"
|
||||||
|
activity_type: "files"
|
||||||
|
created_at: <%= 2.days.ago.to_date.to_s(:db) %>
|
||||||
|
version: 1
|
||||||
|
user_id: 2
|
||||||
|
notes: "An attachment on a project"
|
||||||
|
versioned_id: 8
|
||||||
|
changes: --- {}
|
||||||
|
journals_013:
|
||||||
|
id: 13
|
||||||
|
type: "AttachmentJournal"
|
||||||
|
activity_type: "files"
|
||||||
|
created_at: <%= 2.days.ago.to_date.to_s(:db) %>
|
||||||
|
version: 1
|
||||||
|
user_id: 2
|
||||||
|
notes: "An attachment on an issue"
|
||||||
|
versioned_id: 7
|
||||||
|
changes: --- {}
|
||||||
|
journals_014:
|
||||||
|
id: 14
|
||||||
|
type: "AttachmentJournal"
|
||||||
|
activity_type: "documents"
|
||||||
|
created_at: <%= 2.days.ago.to_date.to_s(:db) %>
|
||||||
|
version: 1
|
||||||
|
user_id: 2
|
||||||
|
notes: "An attachment on a document"
|
||||||
|
versioned_id: 2
|
||||||
|
changes: --- {}
|
56
test/fixtures/wiki_content_versions.yml
vendored
56
test/fixtures/wiki_content_versions.yml
vendored
@ -1,56 +0,0 @@
|
|||||||
---
|
|
||||||
wiki_content_versions_001:
|
|
||||||
updated_on: 2007-03-07 00:08:07 +01:00
|
|
||||||
page_id: 1
|
|
||||||
id: 1
|
|
||||||
version: 1
|
|
||||||
author_id: 2
|
|
||||||
comments: Page creation
|
|
||||||
wiki_content_id: 1
|
|
||||||
compression: ""
|
|
||||||
data: |-
|
|
||||||
h1. CookBook documentation
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Some [[documentation]] here...
|
|
||||||
wiki_content_versions_002:
|
|
||||||
updated_on: 2007-03-07 00:08:34 +01:00
|
|
||||||
page_id: 1
|
|
||||||
id: 2
|
|
||||||
version: 2
|
|
||||||
author_id: 1
|
|
||||||
comments: Small update
|
|
||||||
wiki_content_id: 1
|
|
||||||
compression: ""
|
|
||||||
data: |-
|
|
||||||
h1. CookBook documentation
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Some updated [[documentation]] here...
|
|
||||||
wiki_content_versions_003:
|
|
||||||
updated_on: 2007-03-07 00:10:51 +01:00
|
|
||||||
page_id: 1
|
|
||||||
id: 3
|
|
||||||
version: 3
|
|
||||||
author_id: 1
|
|
||||||
comments: ""
|
|
||||||
wiki_content_id: 1
|
|
||||||
compression: ""
|
|
||||||
data: |-
|
|
||||||
h1. CookBook documentation
|
|
||||||
Some updated [[documentation]] here...
|
|
||||||
wiki_content_versions_004:
|
|
||||||
data: |-
|
|
||||||
h1. Another page
|
|
||||||
|
|
||||||
This is a link to a ticket: #2
|
|
||||||
updated_on: 2007-03-08 00:18:07 +01:00
|
|
||||||
page_id: 2
|
|
||||||
wiki_content_id: 2
|
|
||||||
id: 4
|
|
||||||
version: 1
|
|
||||||
author_id: 1
|
|
||||||
comments:
|
|
||||||
|
|
51
test/fixtures/wiki_contents.yml
vendored
51
test/fixtures/wiki_contents.yml
vendored
@ -9,10 +9,10 @@ wiki_contents_001:
|
|||||||
updated_on: 2007-03-07 00:10:51 +01:00
|
updated_on: 2007-03-07 00:10:51 +01:00
|
||||||
page_id: 1
|
page_id: 1
|
||||||
id: 1
|
id: 1
|
||||||
version: 3
|
lock_version: 3
|
||||||
author_id: 1
|
author_id: 1
|
||||||
comments: Gzip compression activated
|
comments: Gzip compression activated
|
||||||
wiki_contents_002:
|
wiki_contents_002:
|
||||||
text: |-
|
text: |-
|
||||||
h1. Another page
|
h1. Another page
|
||||||
|
|
||||||
@ -22,10 +22,10 @@ wiki_contents_002:
|
|||||||
updated_on: 2007-03-08 00:18:07 +01:00
|
updated_on: 2007-03-08 00:18:07 +01:00
|
||||||
page_id: 2
|
page_id: 2
|
||||||
id: 2
|
id: 2
|
||||||
version: 1
|
lock_version: 1
|
||||||
author_id: 1
|
author_id: 1
|
||||||
comments:
|
comments:
|
||||||
wiki_contents_003:
|
wiki_contents_003:
|
||||||
text: |-
|
text: |-
|
||||||
h1. Start page
|
h1. Start page
|
||||||
|
|
||||||
@ -33,10 +33,10 @@ wiki_contents_003:
|
|||||||
updated_on: 2007-03-08 00:18:07 +01:00
|
updated_on: 2007-03-08 00:18:07 +01:00
|
||||||
page_id: 3
|
page_id: 3
|
||||||
id: 3
|
id: 3
|
||||||
version: 1
|
lock_version: 1
|
||||||
author_id: 1
|
author_id: 1
|
||||||
comments:
|
comments:
|
||||||
wiki_contents_004:
|
wiki_contents_004:
|
||||||
text: |-
|
text: |-
|
||||||
h1. Page with an inline image
|
h1. Page with an inline image
|
||||||
|
|
||||||
@ -46,10 +46,10 @@ wiki_contents_004:
|
|||||||
updated_on: 2007-03-08 00:18:07 +01:00
|
updated_on: 2007-03-08 00:18:07 +01:00
|
||||||
page_id: 4
|
page_id: 4
|
||||||
id: 4
|
id: 4
|
||||||
version: 1
|
lock_version: 1
|
||||||
author_id: 1
|
author_id: 1
|
||||||
comments:
|
comments:
|
||||||
wiki_contents_005:
|
wiki_contents_005:
|
||||||
text: |-
|
text: |-
|
||||||
h1. Child page 1
|
h1. Child page 1
|
||||||
|
|
||||||
@ -57,10 +57,10 @@ wiki_contents_005:
|
|||||||
updated_on: 2007-03-08 00:18:07 +01:00
|
updated_on: 2007-03-08 00:18:07 +01:00
|
||||||
page_id: 5
|
page_id: 5
|
||||||
id: 5
|
id: 5
|
||||||
version: 1
|
lock_version: 1
|
||||||
author_id: 1
|
author_id: 1
|
||||||
comments:
|
comments:
|
||||||
wiki_contents_006:
|
wiki_contents_006:
|
||||||
text: |-
|
text: |-
|
||||||
h1. Child page 2
|
h1. Child page 2
|
||||||
|
|
||||||
@ -68,31 +68,30 @@ wiki_contents_006:
|
|||||||
updated_on: 2007-03-08 00:18:07 +01:00
|
updated_on: 2007-03-08 00:18:07 +01:00
|
||||||
page_id: 6
|
page_id: 6
|
||||||
id: 6
|
id: 6
|
||||||
version: 1
|
lock_version: 1
|
||||||
author_id: 1
|
author_id: 1
|
||||||
comments:
|
comments:
|
||||||
wiki_contents_007:
|
wiki_contents_007:
|
||||||
text: This is a child page
|
text: This is a child page
|
||||||
updated_on: 2007-03-08 00:18:07 +01:00
|
updated_on: 2007-03-08 00:18:07 +01:00
|
||||||
page_id: 7
|
page_id: 7
|
||||||
id: 7
|
id: 7
|
||||||
version: 1
|
lock_version: 1
|
||||||
author_id: 1
|
author_id: 1
|
||||||
comments:
|
comments:
|
||||||
wiki_contents_008:
|
wiki_contents_008:
|
||||||
text: This is a parent page
|
text: This is a parent page
|
||||||
updated_on: 2007-03-08 00:18:07 +01:00
|
updated_on: 2007-03-08 00:18:07 +01:00
|
||||||
page_id: 8
|
page_id: 8
|
||||||
id: 8
|
id: 8
|
||||||
version: 1
|
lock_version: 1
|
||||||
author_id: 1
|
author_id: 1
|
||||||
comments:
|
comments:
|
||||||
wiki_contents_009:
|
wiki_contents_009:
|
||||||
text: This is a child page
|
text: This is a child page
|
||||||
updated_on: 2007-03-08 00:18:07 +01:00
|
updated_on: 2007-03-08 00:18:07 +01:00
|
||||||
page_id: 9
|
page_id: 9
|
||||||
id: 9
|
id: 9
|
||||||
version: 1
|
lock_version: 1
|
||||||
author_id: 1
|
author_id: 1
|
||||||
comments:
|
comments:
|
||||||
|
|
||||||
|
@ -5,12 +5,12 @@
|
|||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
@ -43,19 +43,18 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
:custom_fields_trackers,
|
:custom_fields_trackers,
|
||||||
:time_entries,
|
:time_entries,
|
||||||
:journals,
|
:journals,
|
||||||
:journal_details,
|
|
||||||
:queries
|
:queries
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@controller = IssuesController.new
|
@controller = IssuesController.new
|
||||||
@request = ActionController::TestRequest.new
|
@request = ActionController::TestRequest.new
|
||||||
@response = ActionController::TestResponse.new
|
@response = ActionController::TestResponse.new
|
||||||
User.current = nil
|
User.current = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_index
|
def test_index
|
||||||
Setting.default_language = 'en'
|
Setting.default_language = 'en'
|
||||||
|
|
||||||
get :index
|
get :index
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_template 'index.rhtml'
|
assert_template 'index.rhtml'
|
||||||
@ -69,7 +68,7 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
# project column
|
# project column
|
||||||
assert_tag :tag => 'th', :content => /Project/
|
assert_tag :tag => 'th', :content => /Project/
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_index_should_not_list_issues_when_module_disabled
|
def test_index_should_not_list_issues_when_module_disabled
|
||||||
EnabledModule.delete_all("name = 'issue_tracking' AND project_id = 1")
|
EnabledModule.delete_all("name = 'issue_tracking' AND project_id = 1")
|
||||||
get :index
|
get :index
|
||||||
@ -91,7 +90,7 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
assert_no_tag :tag => 'a', :content => /Can't print recipes/
|
assert_no_tag :tag => 'a', :content => /Can't print recipes/
|
||||||
assert_tag :tag => 'a', :content => /Subproject issue/
|
assert_tag :tag => 'a', :content => /Subproject issue/
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_index_with_project
|
def test_index_with_project
|
||||||
Setting.display_subprojects_issues = 0
|
Setting.display_subprojects_issues = 0
|
||||||
get :index, :project_id => 1
|
get :index, :project_id => 1
|
||||||
@ -101,7 +100,7 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
assert_tag :tag => 'a', :content => /Can't print recipes/
|
assert_tag :tag => 'a', :content => /Can't print recipes/
|
||||||
assert_no_tag :tag => 'a', :content => /Subproject issue/
|
assert_no_tag :tag => 'a', :content => /Subproject issue/
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_index_with_project_and_subprojects
|
def test_index_with_project_and_subprojects
|
||||||
Setting.display_subprojects_issues = 1
|
Setting.display_subprojects_issues = 1
|
||||||
get :index, :project_id => 1
|
get :index, :project_id => 1
|
||||||
@ -112,7 +111,7 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
assert_tag :tag => 'a', :content => /Subproject issue/
|
assert_tag :tag => 'a', :content => /Subproject issue/
|
||||||
assert_no_tag :tag => 'a', :content => /Issue of a private subproject/
|
assert_no_tag :tag => 'a', :content => /Issue of a private subproject/
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_index_with_project_and_subprojects_should_show_private_subprojects
|
def test_index_with_project_and_subprojects_should_show_private_subprojects
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
Setting.display_subprojects_issues = 1
|
Setting.display_subprojects_issues = 1
|
||||||
@ -124,14 +123,14 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
assert_tag :tag => 'a', :content => /Subproject issue/
|
assert_tag :tag => 'a', :content => /Subproject issue/
|
||||||
assert_tag :tag => 'a', :content => /Issue of a private subproject/
|
assert_tag :tag => 'a', :content => /Issue of a private subproject/
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_index_with_project_and_filter
|
def test_index_with_project_and_filter
|
||||||
get :index, :project_id => 1, :set_filter => 1
|
get :index, :project_id => 1, :set_filter => 1
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_template 'index.rhtml'
|
assert_template 'index.rhtml'
|
||||||
assert_not_nil assigns(:issues)
|
assert_not_nil assigns(:issues)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_index_with_query
|
def test_index_with_query
|
||||||
get :index, :project_id => 1, :query_id => 5
|
get :index, :project_id => 1, :query_id => 5
|
||||||
assert_response :success
|
assert_response :success
|
||||||
@ -139,7 +138,7 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
assert_not_nil assigns(:issues)
|
assert_not_nil assigns(:issues)
|
||||||
assert_nil assigns(:issue_count_by_group)
|
assert_nil assigns(:issue_count_by_group)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_index_with_query_grouped_by_tracker
|
def test_index_with_query_grouped_by_tracker
|
||||||
get :index, :project_id => 1, :query_id => 6
|
get :index, :project_id => 1, :query_id => 6
|
||||||
assert_response :success
|
assert_response :success
|
||||||
@ -147,7 +146,7 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
assert_not_nil assigns(:issues)
|
assert_not_nil assigns(:issues)
|
||||||
assert_not_nil assigns(:issue_count_by_group)
|
assert_not_nil assigns(:issue_count_by_group)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_index_with_query_grouped_by_list_custom_field
|
def test_index_with_query_grouped_by_list_custom_field
|
||||||
get :index, :project_id => 1, :query_id => 9
|
get :index, :project_id => 1, :query_id => 9
|
||||||
assert_response :success
|
assert_response :success
|
||||||
@ -155,15 +154,15 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
assert_not_nil assigns(:issues)
|
assert_not_nil assigns(:issues)
|
||||||
assert_not_nil assigns(:issue_count_by_group)
|
assert_not_nil assigns(:issue_count_by_group)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_index_sort_by_field_not_included_in_columns
|
def test_index_sort_by_field_not_included_in_columns
|
||||||
Setting.issue_list_default_columns = %w(subject author)
|
Setting.issue_list_default_columns = %w(subject author)
|
||||||
get :index, :sort => 'tracker'
|
get :index, :sort => 'tracker'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_index_csv_with_project
|
def test_index_csv_with_project
|
||||||
Setting.default_language = 'en'
|
Setting.default_language = 'en'
|
||||||
|
|
||||||
get :index, :format => 'csv'
|
get :index, :format => 'csv'
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_not_nil assigns(:issues)
|
assert_not_nil assigns(:issues)
|
||||||
@ -175,24 +174,24 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
assert_not_nil assigns(:issues)
|
assert_not_nil assigns(:issues)
|
||||||
assert_equal 'text/csv', @response.content_type
|
assert_equal 'text/csv', @response.content_type
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_index_pdf
|
def test_index_pdf
|
||||||
get :index, :format => 'pdf'
|
get :index, :format => 'pdf'
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_not_nil assigns(:issues)
|
assert_not_nil assigns(:issues)
|
||||||
assert_equal 'application/pdf', @response.content_type
|
assert_equal 'application/pdf', @response.content_type
|
||||||
|
|
||||||
get :index, :project_id => 1, :format => 'pdf'
|
get :index, :project_id => 1, :format => 'pdf'
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_not_nil assigns(:issues)
|
assert_not_nil assigns(:issues)
|
||||||
assert_equal 'application/pdf', @response.content_type
|
assert_equal 'application/pdf', @response.content_type
|
||||||
|
|
||||||
get :index, :project_id => 1, :query_id => 6, :format => 'pdf'
|
get :index, :project_id => 1, :query_id => 6, :format => 'pdf'
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_not_nil assigns(:issues)
|
assert_not_nil assigns(:issues)
|
||||||
assert_equal 'application/pdf', @response.content_type
|
assert_equal 'application/pdf', @response.content_type
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_index_pdf_with_query_grouped_by_list_custom_field
|
def test_index_pdf_with_query_grouped_by_list_custom_field
|
||||||
get :index, :project_id => 1, :query_id => 9, :format => 'pdf'
|
get :index, :project_id => 1, :query_id => 9, :format => 'pdf'
|
||||||
assert_response :success
|
assert_response :success
|
||||||
@ -200,31 +199,31 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
assert_not_nil assigns(:issue_count_by_group)
|
assert_not_nil assigns(:issue_count_by_group)
|
||||||
assert_equal 'application/pdf', @response.content_type
|
assert_equal 'application/pdf', @response.content_type
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_index_sort
|
def test_index_sort
|
||||||
get :index, :sort => 'tracker,id:desc'
|
get :index, :sort => 'tracker,id:desc'
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
sort_params = @request.session['issues_index_sort']
|
sort_params = @request.session['issues_index_sort']
|
||||||
assert sort_params.is_a?(String)
|
assert sort_params.is_a?(String)
|
||||||
assert_equal 'tracker,id:desc', sort_params
|
assert_equal 'tracker,id:desc', sort_params
|
||||||
|
|
||||||
issues = assigns(:issues)
|
issues = assigns(:issues)
|
||||||
assert_not_nil issues
|
assert_not_nil issues
|
||||||
assert !issues.empty?
|
assert !issues.empty?
|
||||||
assert_equal issues.sort {|a,b| a.tracker == b.tracker ? b.id <=> a.id : a.tracker <=> b.tracker }.collect(&:id), issues.collect(&:id)
|
assert_equal issues.sort {|a,b| a.tracker == b.tracker ? b.id <=> a.id : a.tracker <=> b.tracker }.collect(&:id), issues.collect(&:id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_index_with_columns
|
def test_index_with_columns
|
||||||
columns = ['tracker', 'subject', 'assigned_to']
|
columns = ['tracker', 'subject', 'assigned_to']
|
||||||
get :index, :set_filter => 1, :query => { 'column_names' => columns}
|
get :index, :set_filter => 1, :query => { 'column_names' => columns}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
# query should use specified columns
|
# query should use specified columns
|
||||||
query = assigns(:query)
|
query = assigns(:query)
|
||||||
assert_kind_of Query, query
|
assert_kind_of Query, query
|
||||||
assert_equal columns, query.column_names.map(&:to_s)
|
assert_equal columns, query.column_names.map(&:to_s)
|
||||||
|
|
||||||
# columns should be stored in session
|
# columns should be stored in session
|
||||||
assert_kind_of Hash, session[:query]
|
assert_kind_of Hash, session[:query]
|
||||||
assert_kind_of Array, session[:query][:column_names]
|
assert_kind_of Array, session[:query][:column_names]
|
||||||
@ -237,73 +236,73 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
assert_not_nil assigns(:journals)
|
assert_not_nil assigns(:journals)
|
||||||
assert_equal 'application/atom+xml', @response.content_type
|
assert_equal 'application/atom+xml', @response.content_type
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show_by_anonymous
|
def test_show_by_anonymous
|
||||||
get :show, :id => 1
|
get :show, :id => 1
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_template 'show.rhtml'
|
assert_template 'show.rhtml'
|
||||||
assert_not_nil assigns(:issue)
|
assert_not_nil assigns(:issue)
|
||||||
assert_equal Issue.find(1), assigns(:issue)
|
assert_equal Issue.find(1), assigns(:issue)
|
||||||
|
|
||||||
# anonymous role is allowed to add a note
|
# anonymous role is allowed to add a note
|
||||||
assert_tag :tag => 'form',
|
assert_tag :tag => 'form',
|
||||||
:descendant => { :tag => 'fieldset',
|
:descendant => { :tag => 'fieldset',
|
||||||
:child => { :tag => 'legend',
|
:child => { :tag => 'legend',
|
||||||
:content => /Notes/ } }
|
:content => /Notes/ } }
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show_by_manager
|
def test_show_by_manager
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :show, :id => 1
|
get :show, :id => 1
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_tag :tag => 'form',
|
assert_tag :tag => 'form',
|
||||||
:descendant => { :tag => 'fieldset',
|
:descendant => { :tag => 'fieldset',
|
||||||
:child => { :tag => 'legend',
|
:child => { :tag => 'legend',
|
||||||
:content => /Change properties/ } },
|
:content => /Change properties/ } },
|
||||||
:descendant => { :tag => 'fieldset',
|
:descendant => { :tag => 'fieldset',
|
||||||
:child => { :tag => 'legend',
|
:child => { :tag => 'legend',
|
||||||
:content => /Log time/ } },
|
:content => /Log time/ } },
|
||||||
:descendant => { :tag => 'fieldset',
|
:descendant => { :tag => 'fieldset',
|
||||||
:child => { :tag => 'legend',
|
:child => { :tag => 'legend',
|
||||||
:content => /Notes/ } }
|
:content => /Notes/ } }
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show_should_deny_anonymous_access_without_permission
|
def test_show_should_deny_anonymous_access_without_permission
|
||||||
Role.anonymous.remove_permission!(:view_issues)
|
Role.anonymous.remove_permission!(:view_issues)
|
||||||
get :show, :id => 1
|
get :show, :id => 1
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show_should_deny_non_member_access_without_permission
|
def test_show_should_deny_non_member_access_without_permission
|
||||||
Role.non_member.remove_permission!(:view_issues)
|
Role.non_member.remove_permission!(:view_issues)
|
||||||
@request.session[:user_id] = 9
|
@request.session[:user_id] = 9
|
||||||
get :show, :id => 1
|
get :show, :id => 1
|
||||||
assert_response 403
|
assert_response 403
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show_should_deny_member_access_without_permission
|
def test_show_should_deny_member_access_without_permission
|
||||||
Role.find(1).remove_permission!(:view_issues)
|
Role.find(1).remove_permission!(:view_issues)
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :show, :id => 1
|
get :show, :id => 1
|
||||||
assert_response 403
|
assert_response 403
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show_should_not_disclose_relations_to_invisible_issues
|
def test_show_should_not_disclose_relations_to_invisible_issues
|
||||||
Setting.cross_project_issue_relations = '1'
|
Setting.cross_project_issue_relations = '1'
|
||||||
IssueRelation.create!(:issue_from => Issue.find(1), :issue_to => Issue.find(2), :relation_type => 'relates')
|
IssueRelation.create!(:issue_from => Issue.find(1), :issue_to => Issue.find(2), :relation_type => 'relates')
|
||||||
# Relation to a private project issue
|
# Relation to a private project issue
|
||||||
IssueRelation.create!(:issue_from => Issue.find(1), :issue_to => Issue.find(4), :relation_type => 'relates')
|
IssueRelation.create!(:issue_from => Issue.find(1), :issue_to => Issue.find(4), :relation_type => 'relates')
|
||||||
|
|
||||||
get :show, :id => 1
|
get :show, :id => 1
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_tag :div, :attributes => { :id => 'relations' },
|
assert_tag :div, :attributes => { :id => 'relations' },
|
||||||
:descendant => { :tag => 'a', :content => /#2$/ }
|
:descendant => { :tag => 'a', :content => /#2$/ }
|
||||||
assert_no_tag :div, :attributes => { :id => 'relations' },
|
assert_no_tag :div, :attributes => { :id => 'relations' },
|
||||||
:descendant => { :tag => 'a', :content => /#4$/ }
|
:descendant => { :tag => 'a', :content => /#4$/ }
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show_atom
|
def test_show_atom
|
||||||
get :show, :id => 2, :format => 'atom'
|
get :show, :id => 2, :format => 'atom'
|
||||||
assert_response :success
|
assert_response :success
|
||||||
@ -311,7 +310,7 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
# Inline image
|
# Inline image
|
||||||
assert_select 'content', :text => Regexp.new(Regexp.quote('http://test.host/attachments/download/10'))
|
assert_select 'content', :text => Regexp.new(Regexp.quote('http://test.host/attachments/download/10'))
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show_export_to_pdf
|
def test_show_export_to_pdf
|
||||||
get :show, :id => 3, :format => 'pdf'
|
get :show, :id => 3, :format => 'pdf'
|
||||||
assert_response :success
|
assert_response :success
|
||||||
@ -325,7 +324,7 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
get :new, :project_id => 1, :tracker_id => 1
|
get :new, :project_id => 1, :tracker_id => 1
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_template 'new'
|
assert_template 'new'
|
||||||
|
|
||||||
assert_tag :tag => 'input', :attributes => { :name => 'issue[custom_field_values][2]',
|
assert_tag :tag => 'input', :attributes => { :name => 'issue[custom_field_values][2]',
|
||||||
:value => 'Default string' }
|
:value => 'Default string' }
|
||||||
end
|
end
|
||||||
@ -335,55 +334,55 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
get :new, :project_id => 1
|
get :new, :project_id => 1
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_template 'new'
|
assert_template 'new'
|
||||||
|
|
||||||
issue = assigns(:issue)
|
issue = assigns(:issue)
|
||||||
assert_not_nil issue
|
assert_not_nil issue
|
||||||
assert_equal Project.find(1).trackers.first, issue.tracker
|
assert_equal Project.find(1).trackers.first, issue.tracker
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_get_new_with_no_default_status_should_display_an_error
|
def test_get_new_with_no_default_status_should_display_an_error
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
IssueStatus.delete_all
|
IssueStatus.delete_all
|
||||||
|
|
||||||
get :new, :project_id => 1
|
get :new, :project_id => 1
|
||||||
assert_response 500
|
assert_response 500
|
||||||
assert_not_nil flash[:error]
|
assert_not_nil flash[:error]
|
||||||
assert_tag :tag => 'div', :attributes => { :class => /error/ },
|
assert_tag :tag => 'div', :attributes => { :class => /error/ },
|
||||||
:content => /No default issue/
|
:content => /No default issue/
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_get_new_with_no_tracker_should_display_an_error
|
def test_get_new_with_no_tracker_should_display_an_error
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
Tracker.delete_all
|
Tracker.delete_all
|
||||||
|
|
||||||
get :new, :project_id => 1
|
get :new, :project_id => 1
|
||||||
assert_response 500
|
assert_response 500
|
||||||
assert_not_nil flash[:error]
|
assert_not_nil flash[:error]
|
||||||
assert_tag :tag => 'div', :attributes => { :class => /error/ },
|
assert_tag :tag => 'div', :attributes => { :class => /error/ },
|
||||||
:content => /No tracker/
|
:content => /No tracker/
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_update_new_form
|
def test_update_new_form
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
xhr :post, :update_form, :project_id => 1,
|
xhr :post, :update_form, :project_id => 1,
|
||||||
:issue => {:tracker_id => 2,
|
:issue => {:tracker_id => 2,
|
||||||
:subject => 'This is the test_new issue',
|
:subject => 'This is the test_new issue',
|
||||||
:description => 'This is the description',
|
:description => 'This is the description',
|
||||||
:priority_id => 5}
|
:priority_id => 5}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_template 'attributes'
|
assert_template 'attributes'
|
||||||
|
|
||||||
issue = assigns(:issue)
|
issue = assigns(:issue)
|
||||||
assert_kind_of Issue, issue
|
assert_kind_of Issue, issue
|
||||||
assert_equal 1, issue.project_id
|
assert_equal 1, issue.project_id
|
||||||
assert_equal 2, issue.tracker_id
|
assert_equal 2, issue.tracker_id
|
||||||
assert_equal 'This is the test_new issue', issue.subject
|
assert_equal 'This is the test_new issue', issue.subject
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_post_create
|
def test_post_create
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
assert_difference 'Issue.count' do
|
assert_difference 'Issue.count' do
|
||||||
post :create, :project_id => 1,
|
post :create, :project_id => 1,
|
||||||
:issue => {:tracker_id => 3,
|
:issue => {:tracker_id => 3,
|
||||||
:status_id => 2,
|
:status_id => 2,
|
||||||
:subject => 'This is the test_new issue',
|
:subject => 'This is the test_new issue',
|
||||||
@ -393,7 +392,7 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
:custom_field_values => {'2' => 'Value for field 2'}}
|
:custom_field_values => {'2' => 'Value for field 2'}}
|
||||||
end
|
end
|
||||||
assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
|
assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
|
||||||
|
|
||||||
issue = Issue.find_by_subject('This is the test_new issue')
|
issue = Issue.find_by_subject('This is the test_new issue')
|
||||||
assert_not_nil issue
|
assert_not_nil issue
|
||||||
assert_equal 2, issue.author_id
|
assert_equal 2, issue.author_id
|
||||||
@ -404,21 +403,21 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
assert_not_nil v
|
assert_not_nil v
|
||||||
assert_equal 'Value for field 2', v.value
|
assert_equal 'Value for field 2', v.value
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_post_create_and_continue
|
def test_post_create_and_continue
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
post :create, :project_id => 1,
|
post :create, :project_id => 1,
|
||||||
:issue => {:tracker_id => 3,
|
:issue => {:tracker_id => 3,
|
||||||
:subject => 'This is first issue',
|
:subject => 'This is first issue',
|
||||||
:priority_id => 5},
|
:priority_id => 5},
|
||||||
:continue => ''
|
:continue => ''
|
||||||
assert_redirected_to :controller => 'issues', :action => 'new', :issue => {:tracker_id => 3}
|
assert_redirected_to :controller => 'issues', :action => 'new', :issue => {:tracker_id => 3}
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_post_create_without_custom_fields_param
|
def test_post_create_without_custom_fields_param
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
assert_difference 'Issue.count' do
|
assert_difference 'Issue.count' do
|
||||||
post :create, :project_id => 1,
|
post :create, :project_id => 1,
|
||||||
:issue => {:tracker_id => 1,
|
:issue => {:tracker_id => 1,
|
||||||
:subject => 'This is the test_new issue',
|
:subject => 'This is the test_new issue',
|
||||||
:description => 'This is the description',
|
:description => 'This is the description',
|
||||||
@ -432,7 +431,7 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
field.update_attribute(:is_required, true)
|
field.update_attribute(:is_required, true)
|
||||||
|
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
post :create, :project_id => 1,
|
post :create, :project_id => 1,
|
||||||
:issue => {:tracker_id => 1,
|
:issue => {:tracker_id => 1,
|
||||||
:subject => 'This is the test_new issue',
|
:subject => 'This is the test_new issue',
|
||||||
:description => 'This is the description',
|
:description => 'This is the description',
|
||||||
@ -443,13 +442,13 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
assert_not_nil issue
|
assert_not_nil issue
|
||||||
assert_equal I18n.translate('activerecord.errors.messages.invalid'), issue.errors.on(:custom_values)
|
assert_equal I18n.translate('activerecord.errors.messages.invalid'), issue.errors.on(:custom_values)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_post_create_with_watchers
|
def test_post_create_with_watchers
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
ActionMailer::Base.deliveries.clear
|
ActionMailer::Base.deliveries.clear
|
||||||
|
|
||||||
assert_difference 'Watcher.count', 2 do
|
assert_difference 'Watcher.count', 2 do
|
||||||
post :create, :project_id => 1,
|
post :create, :project_id => 1,
|
||||||
:issue => {:tracker_id => 1,
|
:issue => {:tracker_id => 1,
|
||||||
:subject => 'This is a new issue with watchers',
|
:subject => 'This is a new issue with watchers',
|
||||||
:description => 'This is the description',
|
:description => 'This is the description',
|
||||||
@ -459,7 +458,7 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
issue = Issue.find_by_subject('This is a new issue with watchers')
|
issue = Issue.find_by_subject('This is a new issue with watchers')
|
||||||
assert_not_nil issue
|
assert_not_nil issue
|
||||||
assert_redirected_to :controller => 'issues', :action => 'show', :id => issue
|
assert_redirected_to :controller => 'issues', :action => 'show', :id => issue
|
||||||
|
|
||||||
# Watchers added
|
# Watchers added
|
||||||
assert_equal [2, 3], issue.watcher_user_ids.sort
|
assert_equal [2, 3], issue.watcher_user_ids.sort
|
||||||
assert issue.watched_by?(User.find(3))
|
assert issue.watched_by?(User.find(3))
|
||||||
@ -468,12 +467,12 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
assert_kind_of TMail::Mail, mail
|
assert_kind_of TMail::Mail, mail
|
||||||
assert [mail.bcc, mail.cc].flatten.include?(User.find(3).mail)
|
assert [mail.bcc, mail.cc].flatten.include?(User.find(3).mail)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_post_create_subissue
|
def test_post_create_subissue
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
|
|
||||||
assert_difference 'Issue.count' do
|
assert_difference 'Issue.count' do
|
||||||
post :create, :project_id => 1,
|
post :create, :project_id => 1,
|
||||||
:issue => {:tracker_id => 1,
|
:issue => {:tracker_id => 1,
|
||||||
:subject => 'This is a child issue',
|
:subject => 'This is a child issue',
|
||||||
:parent_issue_id => 2}
|
:parent_issue_id => 2}
|
||||||
@ -482,12 +481,12 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
assert_not_nil issue
|
assert_not_nil issue
|
||||||
assert_equal Issue.find(2), issue.parent
|
assert_equal Issue.find(2), issue.parent
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_post_create_should_send_a_notification
|
def test_post_create_should_send_a_notification
|
||||||
ActionMailer::Base.deliveries.clear
|
ActionMailer::Base.deliveries.clear
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
assert_difference 'Issue.count' do
|
assert_difference 'Issue.count' do
|
||||||
post :create, :project_id => 1,
|
post :create, :project_id => 1,
|
||||||
:issue => {:tracker_id => 3,
|
:issue => {:tracker_id => 3,
|
||||||
:subject => 'This is the test_new issue',
|
:subject => 'This is the test_new issue',
|
||||||
:description => 'This is the description',
|
:description => 'This is the description',
|
||||||
@ -496,13 +495,13 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
:custom_field_values => {'2' => 'Value for field 2'}}
|
:custom_field_values => {'2' => 'Value for field 2'}}
|
||||||
end
|
end
|
||||||
assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
|
assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
|
||||||
|
|
||||||
assert_equal 1, ActionMailer::Base.deliveries.size
|
assert_equal 1, ActionMailer::Base.deliveries.size
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_post_create_should_preserve_fields_values_on_validation_failure
|
def test_post_create_should_preserve_fields_values_on_validation_failure
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
post :create, :project_id => 1,
|
post :create, :project_id => 1,
|
||||||
:issue => {:tracker_id => 1,
|
:issue => {:tracker_id => 1,
|
||||||
# empty subject
|
# empty subject
|
||||||
:subject => '',
|
:subject => '',
|
||||||
@ -511,35 +510,35 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
:custom_field_values => {'1' => 'Oracle', '2' => 'Value for field 2'}}
|
:custom_field_values => {'1' => 'Oracle', '2' => 'Value for field 2'}}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_template 'new'
|
assert_template 'new'
|
||||||
|
|
||||||
assert_tag :textarea, :attributes => { :name => 'issue[description]' },
|
assert_tag :textarea, :attributes => { :name => 'issue[description]' },
|
||||||
:content => 'This is a description'
|
:content => 'This is a description'
|
||||||
assert_tag :select, :attributes => { :name => 'issue[priority_id]' },
|
assert_tag :select, :attributes => { :name => 'issue[priority_id]' },
|
||||||
:child => { :tag => 'option', :attributes => { :selected => 'selected',
|
:child => { :tag => 'option', :attributes => { :selected => 'selected',
|
||||||
:value => '6' },
|
:value => '6' },
|
||||||
:content => 'High' }
|
:content => 'High' }
|
||||||
# Custom fields
|
# Custom fields
|
||||||
assert_tag :select, :attributes => { :name => 'issue[custom_field_values][1]' },
|
assert_tag :select, :attributes => { :name => 'issue[custom_field_values][1]' },
|
||||||
:child => { :tag => 'option', :attributes => { :selected => 'selected',
|
:child => { :tag => 'option', :attributes => { :selected => 'selected',
|
||||||
:value => 'Oracle' },
|
:value => 'Oracle' },
|
||||||
:content => 'Oracle' }
|
:content => 'Oracle' }
|
||||||
assert_tag :input, :attributes => { :name => 'issue[custom_field_values][2]',
|
assert_tag :input, :attributes => { :name => 'issue[custom_field_values][2]',
|
||||||
:value => 'Value for field 2'}
|
:value => 'Value for field 2'}
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_post_create_should_ignore_non_safe_attributes
|
def test_post_create_should_ignore_non_safe_attributes
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
assert_nothing_raised do
|
assert_nothing_raised do
|
||||||
post :create, :project_id => 1, :issue => { :tracker => "A param can not be a Tracker" }
|
post :create, :project_id => 1, :issue => { :tracker => "A param can not be a Tracker" }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "without workflow privilege" do
|
context "without workflow privilege" do
|
||||||
setup do
|
setup do
|
||||||
Workflow.delete_all(["role_id = ?", Role.anonymous.id])
|
Workflow.delete_all(["role_id = ?", Role.anonymous.id])
|
||||||
Role.anonymous.add_permission! :add_issues
|
Role.anonymous.add_permission! :add_issues
|
||||||
end
|
end
|
||||||
|
|
||||||
context "#new" do
|
context "#new" do
|
||||||
should "propose default status only" do
|
should "propose default status only" do
|
||||||
get :new, :project_id => 1
|
get :new, :project_id => 1
|
||||||
@ -550,10 +549,10 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
:children => {:count => 1},
|
:children => {:count => 1},
|
||||||
:child => {:tag => 'option', :attributes => {:value => IssueStatus.default.id.to_s}}
|
:child => {:tag => 'option', :attributes => {:value => IssueStatus.default.id.to_s}}
|
||||||
end
|
end
|
||||||
|
|
||||||
should "accept default status" do
|
should "accept default status" do
|
||||||
assert_difference 'Issue.count' do
|
assert_difference 'Issue.count' do
|
||||||
post :create, :project_id => 1,
|
post :create, :project_id => 1,
|
||||||
:issue => {:tracker_id => 1,
|
:issue => {:tracker_id => 1,
|
||||||
:subject => 'This is an issue',
|
:subject => 'This is an issue',
|
||||||
:status_id => 1}
|
:status_id => 1}
|
||||||
@ -561,10 +560,10 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
issue = Issue.last(:order => 'id')
|
issue = Issue.last(:order => 'id')
|
||||||
assert_equal IssueStatus.default, issue.status
|
assert_equal IssueStatus.default, issue.status
|
||||||
end
|
end
|
||||||
|
|
||||||
should "ignore unauthorized status" do
|
should "ignore unauthorized status" do
|
||||||
assert_difference 'Issue.count' do
|
assert_difference 'Issue.count' do
|
||||||
post :create, :project_id => 1,
|
post :create, :project_id => 1,
|
||||||
:issue => {:tracker_id => 1,
|
:issue => {:tracker_id => 1,
|
||||||
:subject => 'This is an issue',
|
:subject => 'This is an issue',
|
||||||
:status_id => 3}
|
:status_id => 3}
|
||||||
@ -574,7 +573,7 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_copy_issue
|
def test_copy_issue
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :new, :project_id => 1, :copy_from => 1
|
get :new, :project_id => 1, :copy_from => 1
|
||||||
@ -583,7 +582,7 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
orig = Issue.find(1)
|
orig = Issue.find(1)
|
||||||
assert_equal orig.subject, assigns(:issue).subject
|
assert_equal orig.subject, assigns(:issue).subject
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_get_edit
|
def test_get_edit
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :edit, :id => 1
|
get :edit, :id => 1
|
||||||
@ -592,25 +591,25 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
assert_not_nil assigns(:issue)
|
assert_not_nil assigns(:issue)
|
||||||
assert_equal Issue.find(1), assigns(:issue)
|
assert_equal Issue.find(1), assigns(:issue)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_get_edit_with_params
|
def test_get_edit_with_params
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :edit, :id => 1, :issue => { :status_id => 5, :priority_id => 7 }
|
get :edit, :id => 1, :issue => { :status_id => 5, :priority_id => 7 }
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_template 'edit'
|
assert_template 'edit'
|
||||||
|
|
||||||
issue = assigns(:issue)
|
issue = assigns(:issue)
|
||||||
assert_not_nil issue
|
assert_not_nil issue
|
||||||
|
|
||||||
assert_equal 5, issue.status_id
|
assert_equal 5, issue.status_id
|
||||||
assert_tag :select, :attributes => { :name => 'issue[status_id]' },
|
assert_tag :select, :attributes => { :name => 'issue[status_id]' },
|
||||||
:child => { :tag => 'option',
|
:child => { :tag => 'option',
|
||||||
:content => 'Closed',
|
:content => 'Closed',
|
||||||
:attributes => { :selected => 'selected' } }
|
:attributes => { :selected => 'selected' } }
|
||||||
|
|
||||||
assert_equal 7, issue.priority_id
|
assert_equal 7, issue.priority_id
|
||||||
assert_tag :select, :attributes => { :name => 'issue[priority_id]' },
|
assert_tag :select, :attributes => { :name => 'issue[priority_id]' },
|
||||||
:child => { :tag => 'option',
|
:child => { :tag => 'option',
|
||||||
:content => 'Urgent',
|
:content => 'Urgent',
|
||||||
:attributes => { :selected => 'selected' } }
|
:attributes => { :selected => 'selected' } }
|
||||||
end
|
end
|
||||||
@ -619,13 +618,13 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
xhr :post, :update_form, :project_id => 1,
|
xhr :post, :update_form, :project_id => 1,
|
||||||
:id => 1,
|
:id => 1,
|
||||||
:issue => {:tracker_id => 2,
|
:issue => {:tracker_id => 2,
|
||||||
:subject => 'This is the test_new issue',
|
:subject => 'This is the test_new issue',
|
||||||
:description => 'This is the description',
|
:description => 'This is the description',
|
||||||
:priority_id => 5}
|
:priority_id => 5}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_template 'attributes'
|
assert_template 'attributes'
|
||||||
|
|
||||||
issue = assigns(:issue)
|
issue = assigns(:issue)
|
||||||
assert_kind_of Issue, issue
|
assert_kind_of Issue, issue
|
||||||
assert_equal 1, issue.id
|
assert_equal 1, issue.id
|
||||||
@ -633,7 +632,7 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
assert_equal 2, issue.tracker_id
|
assert_equal 2, issue.tracker_id
|
||||||
assert_equal 'This is the test_new issue', issue.subject
|
assert_equal 'This is the test_new issue', issue.subject
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_reply_to_issue
|
def test_reply_to_issue
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :reply, :id => 1
|
get :reply, :id => 1
|
||||||
@ -665,55 +664,60 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
def test_put_update_without_custom_fields_param
|
def test_put_update_without_custom_fields_param
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
ActionMailer::Base.deliveries.clear
|
ActionMailer::Base.deliveries.clear
|
||||||
|
|
||||||
issue = Issue.find(1)
|
issue = Issue.find(1)
|
||||||
assert_equal '125', issue.custom_value_for(2).value
|
assert_equal '125', issue.custom_value_for(2).value
|
||||||
old_subject = issue.subject
|
old_subject = issue.subject
|
||||||
new_subject = 'Subject modified by IssuesControllerTest#test_post_edit'
|
new_subject = 'Subject modified by IssuesControllerTest#test_post_edit'
|
||||||
|
|
||||||
assert_difference('Journal.count') do
|
assert_difference('IssueJournal.count') do
|
||||||
assert_difference('JournalDetail.count', 2) do
|
put :update, :id => 1, :issue => {:subject => new_subject,
|
||||||
put :update, :id => 1, :issue => {:subject => new_subject,
|
:priority_id => '6',
|
||||||
:priority_id => '6',
|
:category_id => '1' # no change
|
||||||
:category_id => '1' # no change
|
}
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
assert Issue.current_journal.changes.has_key? "subject"
|
||||||
|
assert Issue.current_journal.changes.has_key? "priority_id"
|
||||||
|
assert !Issue.current_journal.changes.has_key? "category_id"
|
||||||
|
|
||||||
assert_redirected_to :action => 'show', :id => '1'
|
assert_redirected_to :action => 'show', :id => '1'
|
||||||
issue.reload
|
issue.reload
|
||||||
assert_equal new_subject, issue.subject
|
assert_equal new_subject, issue.subject
|
||||||
# Make sure custom fields were not cleared
|
# Make sure custom fields were not cleared
|
||||||
assert_equal '125', issue.custom_value_for(2).value
|
assert_equal '125', issue.custom_value_for(2).value
|
||||||
|
|
||||||
mail = ActionMailer::Base.deliveries.last
|
mail = ActionMailer::Base.deliveries.last
|
||||||
assert_kind_of TMail::Mail, mail
|
assert_kind_of TMail::Mail, mail
|
||||||
assert mail.subject.starts_with?("[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}]")
|
assert mail.subject.starts_with?("[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}]")
|
||||||
assert mail.body.include?("Subject changed from #{old_subject} to #{new_subject}")
|
assert mail.body.include?("Subject changed from #{old_subject} to #{new_subject}")
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_put_update_with_custom_field_change
|
def test_put_update_with_custom_field_change
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
issue = Issue.find(1)
|
issue = Issue.find(1)
|
||||||
assert_equal '125', issue.custom_value_for(2).value
|
assert_equal '125', issue.custom_value_for(2).value
|
||||||
|
|
||||||
assert_difference('Journal.count') do
|
assert_difference('Journal.count') do
|
||||||
assert_difference('JournalDetail.count', 3) do
|
put :update, :id => 1, :issue => {:subject => 'Custom field change',
|
||||||
put :update, :id => 1, :issue => {:subject => 'Custom field change',
|
:priority_id => '6',
|
||||||
:priority_id => '6',
|
:category_id => '1', # no change
|
||||||
:category_id => '1', # no change
|
:custom_field_values => { '2' => 'New custom value' }
|
||||||
:custom_field_values => { '2' => 'New custom value' }
|
}
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
assert Issue.current_journal.changes.has_key? "subject"
|
||||||
|
assert Issue.current_journal.changes.has_key? "priority_id"
|
||||||
|
assert !Issue.current_journal.changes.has_key? "category_id"
|
||||||
|
assert Issue.current_journal.changes.has_key? "2"
|
||||||
|
|
||||||
assert_redirected_to :action => 'show', :id => '1'
|
assert_redirected_to :action => 'show', :id => '1'
|
||||||
issue.reload
|
issue.reload
|
||||||
assert_equal 'New custom value', issue.custom_value_for(2).value
|
assert_equal 'New custom value', issue.custom_value_for(2).value
|
||||||
|
|
||||||
mail = ActionMailer::Base.deliveries.last
|
mail = ActionMailer::Base.deliveries.last
|
||||||
assert_kind_of TMail::Mail, mail
|
assert_kind_of TMail::Mail, mail
|
||||||
assert mail.body.include?("Searchable field changed from 125 to New custom value")
|
assert mail.body.include?("Searchable field changed from 125 to New custom value")
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_put_update_with_status_and_assignee_change
|
def test_put_update_with_status_and_assignee_change
|
||||||
issue = Issue.find(1)
|
issue = Issue.find(1)
|
||||||
assert_equal 1, issue.status_id
|
assert_equal 1, issue.status_id
|
||||||
@ -731,13 +735,13 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
j = Journal.find(:first, :order => 'id DESC')
|
j = Journal.find(:first, :order => 'id DESC')
|
||||||
assert_equal 'Assigned to dlopper', j.notes
|
assert_equal 'Assigned to dlopper', j.notes
|
||||||
assert_equal 2, j.details.size
|
assert_equal 2, j.details.size
|
||||||
|
|
||||||
mail = ActionMailer::Base.deliveries.last
|
mail = ActionMailer::Base.deliveries.last
|
||||||
assert mail.body.include?("Status changed from New to Assigned")
|
assert mail.body.include?("Status changed from New to Assigned")
|
||||||
# subject should contain the new status
|
# subject should contain the new status
|
||||||
assert mail.subject.include?("(#{ IssueStatus.find(2).name })")
|
assert mail.subject.include?("(#{ IssueStatus.find(2).name })")
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_put_update_with_note_only
|
def test_put_update_with_note_only
|
||||||
notes = 'Note added by IssuesControllerTest#test_update_with_note_only'
|
notes = 'Note added by IssuesControllerTest#test_update_with_note_only'
|
||||||
# anonymous user
|
# anonymous user
|
||||||
@ -749,11 +753,11 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
assert_equal notes, j.notes
|
assert_equal notes, j.notes
|
||||||
assert_equal 0, j.details.size
|
assert_equal 0, j.details.size
|
||||||
assert_equal User.anonymous, j.user
|
assert_equal User.anonymous, j.user
|
||||||
|
|
||||||
mail = ActionMailer::Base.deliveries.last
|
mail = ActionMailer::Base.deliveries.last
|
||||||
assert mail.body.include?(notes)
|
assert mail.body.include?(notes)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_put_update_with_note_and_spent_time
|
def test_put_update_with_note_and_spent_time
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
spent_hours_before = Issue.find(1).spent_hours
|
spent_hours_before = Issue.find(1).spent_hours
|
||||||
@ -764,22 +768,22 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
:time_entry => { :hours => '2.5', :comments => 'test_put_update_with_note_and_spent_time', :activity_id => TimeEntryActivity.first.id }
|
:time_entry => { :hours => '2.5', :comments => 'test_put_update_with_note_and_spent_time', :activity_id => TimeEntryActivity.first.id }
|
||||||
end
|
end
|
||||||
assert_redirected_to :action => 'show', :id => '1'
|
assert_redirected_to :action => 'show', :id => '1'
|
||||||
|
|
||||||
issue = Issue.find(1)
|
issue = Issue.find(1)
|
||||||
|
|
||||||
j = Journal.find(:first, :order => 'id DESC')
|
j = Journal.find(:first, :order => 'id DESC')
|
||||||
assert_equal '2.5 hours added', j.notes
|
assert_equal '2.5 hours added', j.notes
|
||||||
assert_equal 0, j.details.size
|
assert_equal 0, j.details.size
|
||||||
|
|
||||||
t = issue.time_entries.find_by_comments('test_put_update_with_note_and_spent_time')
|
t = issue.time_entries.find_by_comments('test_put_update_with_note_and_spent_time')
|
||||||
assert_not_nil t
|
assert_not_nil t
|
||||||
assert_equal 2.5, t.hours
|
assert_equal 2.5, t.hours
|
||||||
assert_equal spent_hours_before + 2.5, issue.spent_hours
|
assert_equal spent_hours_before + 2.5, issue.spent_hours
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_put_update_with_attachment_only
|
def test_put_update_with_attachment_only
|
||||||
set_tmp_attachments_directory
|
set_tmp_attachments_directory
|
||||||
|
|
||||||
# Delete all fixtured journals, a race condition can occur causing the wrong
|
# Delete all fixtured journals, a race condition can occur causing the wrong
|
||||||
# journal to get fetched in the next find.
|
# journal to get fetched in the next find.
|
||||||
Journal.delete_all
|
Journal.delete_all
|
||||||
@ -795,21 +799,21 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
assert_equal 1, j.details.size
|
assert_equal 1, j.details.size
|
||||||
assert_equal 'testfile.txt', j.details.first.value
|
assert_equal 'testfile.txt', j.details.first.value
|
||||||
assert_equal User.anonymous, j.user
|
assert_equal User.anonymous, j.user
|
||||||
|
|
||||||
mail = ActionMailer::Base.deliveries.last
|
mail = ActionMailer::Base.deliveries.last
|
||||||
assert mail.body.include?('testfile.txt')
|
assert mail.body.include?('testfile.txt')
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_put_update_with_attachment_that_fails_to_save
|
def test_put_update_with_attachment_that_fails_to_save
|
||||||
set_tmp_attachments_directory
|
set_tmp_attachments_directory
|
||||||
|
|
||||||
# Delete all fixtured journals, a race condition can occur causing the wrong
|
# Delete all fixtured journals, a race condition can occur causing the wrong
|
||||||
# journal to get fetched in the next find.
|
# journal to get fetched in the next find.
|
||||||
Journal.delete_all
|
Journal.delete_all
|
||||||
|
|
||||||
# Mock out the unsaved attachment
|
# Mock out the unsaved attachment
|
||||||
Attachment.any_instance.stubs(:create).returns(Attachment.new)
|
Attachment.any_instance.stubs(:create).returns(Attachment.new)
|
||||||
|
|
||||||
# anonymous user
|
# anonymous user
|
||||||
put :update,
|
put :update,
|
||||||
:id => 1,
|
:id => 1,
|
||||||
@ -824,12 +828,12 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
issue = Issue.find(1)
|
issue = Issue.find(1)
|
||||||
issue.journals.clear
|
issue.journals.clear
|
||||||
ActionMailer::Base.deliveries.clear
|
ActionMailer::Base.deliveries.clear
|
||||||
|
|
||||||
put :update,
|
put :update,
|
||||||
:id => 1,
|
:id => 1,
|
||||||
:notes => ''
|
:notes => ''
|
||||||
assert_redirected_to :action => 'show', :id => '1'
|
assert_redirected_to :action => 'show', :id => '1'
|
||||||
|
|
||||||
issue.reload
|
issue.reload
|
||||||
assert issue.journals.empty?
|
assert issue.journals.empty?
|
||||||
# No email should be sent
|
# No email should be sent
|
||||||
@ -842,18 +846,18 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
issue = Issue.find(1)
|
issue = Issue.find(1)
|
||||||
old_subject = issue.subject
|
old_subject = issue.subject
|
||||||
new_subject = 'Subject modified by IssuesControllerTest#test_post_edit'
|
new_subject = 'Subject modified by IssuesControllerTest#test_post_edit'
|
||||||
|
|
||||||
put :update, :id => 1, :issue => {:subject => new_subject,
|
put :update, :id => 1, :issue => {:subject => new_subject,
|
||||||
:priority_id => '6',
|
:priority_id => '6',
|
||||||
:category_id => '1' # no change
|
:category_id => '1' # no change
|
||||||
}
|
}
|
||||||
assert_equal 1, ActionMailer::Base.deliveries.size
|
assert_equal 1, ActionMailer::Base.deliveries.size
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_put_update_with_invalid_spent_time
|
def test_put_update_with_invalid_spent_time
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
notes = 'Note added by IssuesControllerTest#test_post_edit_with_invalid_spent_time'
|
notes = 'Note added by IssuesControllerTest#test_post_edit_with_invalid_spent_time'
|
||||||
|
|
||||||
assert_no_difference('Journal.count') do
|
assert_no_difference('Journal.count') do
|
||||||
put :update,
|
put :update,
|
||||||
:id => 1,
|
:id => 1,
|
||||||
@ -862,12 +866,12 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
end
|
end
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_template 'edit'
|
assert_template 'edit'
|
||||||
|
|
||||||
assert_tag :textarea, :attributes => { :name => 'notes' },
|
assert_tag :textarea, :attributes => { :name => 'notes' },
|
||||||
:content => notes
|
:content => notes
|
||||||
assert_tag :input, :attributes => { :name => 'time_entry[hours]', :value => "2z" }
|
assert_tag :input, :attributes => { :name => 'time_entry[hours]', :value => "2z" }
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_put_update_should_allow_fixed_version_to_be_set_to_a_subproject
|
def test_put_update_should_allow_fixed_version_to_be_set_to_a_subproject
|
||||||
issue = Issue.find(2)
|
issue = Issue.find(2)
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
@ -898,7 +902,7 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_redirected_to '/issues'
|
assert_redirected_to '/issues'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_put_update_should_not_redirect_back_using_the_back_url_parameter_off_the_host
|
def test_put_update_should_not_redirect_back_using_the_back_url_parameter_off_the_host
|
||||||
issue = Issue.find(2)
|
issue = Issue.find(2)
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
@ -913,19 +917,19 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_redirected_to :controller => 'issues', :action => 'show', :id => issue.id
|
assert_redirected_to :controller => 'issues', :action => 'show', :id => issue.id
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_get_bulk_edit
|
def test_get_bulk_edit
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :bulk_edit, :ids => [1, 2]
|
get :bulk_edit, :ids => [1, 2]
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_template 'bulk_edit'
|
assert_template 'bulk_edit'
|
||||||
|
|
||||||
# Project specific custom field, date type
|
# Project specific custom field, date type
|
||||||
field = CustomField.find(9)
|
field = CustomField.find(9)
|
||||||
assert !field.is_for_all?
|
assert !field.is_for_all?
|
||||||
assert_equal 'date', field.field_format
|
assert_equal 'date', field.field_format
|
||||||
assert_tag :input, :attributes => {:name => 'issue[custom_field_values][9]'}
|
assert_tag :input, :attributes => {:name => 'issue[custom_field_values][9]'}
|
||||||
|
|
||||||
# System wide custom field
|
# System wide custom field
|
||||||
assert CustomField.find(1).is_for_all?
|
assert CustomField.find(1).is_for_all?
|
||||||
assert_tag :select, :attributes => {:name => 'issue[custom_field_values][1]'}
|
assert_tag :select, :attributes => {:name => 'issue[custom_field_values][1]'}
|
||||||
@ -938,11 +942,11 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
:issue => {:priority_id => 7,
|
:issue => {:priority_id => 7,
|
||||||
:assigned_to_id => '',
|
:assigned_to_id => '',
|
||||||
:custom_field_values => {'2' => ''}}
|
:custom_field_values => {'2' => ''}}
|
||||||
|
|
||||||
assert_response 302
|
assert_response 302
|
||||||
# check that the issues were updated
|
# check that the issues were updated
|
||||||
assert_equal [7, 7], Issue.find_all_by_id([1, 2]).collect {|i| i.priority.id}
|
assert_equal [7, 7], Issue.find_all_by_id([1, 2]).collect {|i| i.priority.id}
|
||||||
|
|
||||||
issue = Issue.find(1)
|
issue = Issue.find(1)
|
||||||
journal = issue.journals.find(:first, :order => 'created_on DESC')
|
journal = issue.journals.find(:first, :order => 'created_on DESC')
|
||||||
assert_equal '125', issue.custom_value_for(2).value
|
assert_equal '125', issue.custom_value_for(2).value
|
||||||
@ -975,7 +979,7 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
:issue => {:priority_id => '',
|
:issue => {:priority_id => '',
|
||||||
:assigned_to_id => '',
|
:assigned_to_id => '',
|
||||||
:status_id => '5'}
|
:status_id => '5'}
|
||||||
|
|
||||||
assert_response 302
|
assert_response 302
|
||||||
issue = Issue.find(1)
|
issue = Issue.find(1)
|
||||||
assert issue.closed?
|
assert issue.closed?
|
||||||
@ -988,9 +992,9 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
:issue => {:priority_id => '',
|
:issue => {:priority_id => '',
|
||||||
:assigned_to_id => '',
|
:assigned_to_id => '',
|
||||||
:custom_field_values => {'2' => '777'}}
|
:custom_field_values => {'2' => '777'}}
|
||||||
|
|
||||||
assert_response 302
|
assert_response 302
|
||||||
|
|
||||||
issue = Issue.find(1)
|
issue = Issue.find(1)
|
||||||
journal = issue.journals.find(:first, :order => 'created_on DESC')
|
journal = issue.journals.find(:first, :order => 'created_on DESC')
|
||||||
assert_equal '777', issue.custom_value_for(2).value
|
assert_equal '777', issue.custom_value_for(2).value
|
||||||
@ -1008,7 +1012,7 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
# check that the issues were updated
|
# check that the issues were updated
|
||||||
assert_nil Issue.find(2).assigned_to
|
assert_nil Issue.find(2).assigned_to
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_post_bulk_edit_should_allow_fixed_version_to_be_set_to_a_subproject
|
def test_post_bulk_edit_should_allow_fixed_version_to_be_set_to_a_subproject
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
|
|
||||||
@ -1062,7 +1066,7 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
assert_equal 1, Issue.find(1).tracker_id
|
assert_equal 1, Issue.find(1).tracker_id
|
||||||
assert_equal 2, Issue.find(2).tracker_id
|
assert_equal 2, Issue.find(2).tracker_id
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_bulk_move_to_another_tracker
|
def test_bulk_move_to_another_tracker
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
post :move, :ids => [1, 2], :new_tracker_id => 2
|
post :move, :ids => [1, 2], :new_tracker_id => 2
|
||||||
@ -1095,12 +1099,12 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
assert_equal issue_before_move.status_id, issue_after_move.status_id
|
assert_equal issue_before_move.status_id, issue_after_move.status_id
|
||||||
assert_equal issue_before_move.assigned_to_id, issue_after_move.assigned_to_id
|
assert_equal issue_before_move.assigned_to_id, issue_after_move.assigned_to_id
|
||||||
end
|
end
|
||||||
|
|
||||||
should "allow changing the issue's attributes" do
|
should "allow changing the issue's attributes" do
|
||||||
# Fixes random test failure with Mysql
|
# Fixes random test failure with Mysql
|
||||||
# where Issue.all(:limit => 2, :order => 'id desc', :conditions => {:project_id => 2}) doesn't return the expected results
|
# where Issue.all(:limit => 2, :order => 'id desc', :conditions => {:project_id => 2}) doesn't return the expected results
|
||||||
Issue.delete_all("project_id=2")
|
Issue.delete_all("project_id=2")
|
||||||
|
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
assert_difference 'Issue.count', 2 do
|
assert_difference 'Issue.count', 2 do
|
||||||
assert_no_difference 'Project.find(1).issues.count' do
|
assert_no_difference 'Project.find(1).issues.count' do
|
||||||
@ -1119,14 +1123,14 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_copy_to_another_project_should_follow_when_needed
|
def test_copy_to_another_project_should_follow_when_needed
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
post :move, :ids => [1], :new_project_id => 2, :copy_options => {:copy => '1'}, :follow => '1'
|
post :move, :ids => [1], :new_project_id => 2, :copy_options => {:copy => '1'}, :follow => '1'
|
||||||
issue = Issue.first(:order => 'id DESC')
|
issue = Issue.first(:order => 'id DESC')
|
||||||
assert_redirected_to :controller => 'issues', :action => 'show', :id => issue
|
assert_redirected_to :controller => 'issues', :action => 'show', :id => issue
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_context_menu_one_issue
|
def test_context_menu_one_issue
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :context_menu, :ids => [1]
|
get :context_menu, :ids => [1]
|
||||||
@ -1174,7 +1178,7 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
:attributes => { :href => '#',
|
:attributes => { :href => '#',
|
||||||
:class => 'icon-del disabled' }
|
:class => 'icon-del disabled' }
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_context_menu_multiple_issues_of_same_project
|
def test_context_menu_multiple_issues_of_same_project
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :context_menu, :ids => [1, 2]
|
get :context_menu, :ids => [1, 2]
|
||||||
@ -1209,7 +1213,7 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
:attributes => { :href => '#',
|
:attributes => { :href => '#',
|
||||||
:class => 'icon-del disabled' }
|
:class => 'icon-del disabled' }
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_preview_new_issue
|
def test_preview_new_issue
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
post :preview, :project_id => '1', :issue => {:description => 'Foo'}
|
post :preview, :project_id => '1', :issue => {:description => 'Foo'}
|
||||||
@ -1217,7 +1221,7 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
assert_template 'preview'
|
assert_template 'preview'
|
||||||
assert_not_nil assigns(:description)
|
assert_not_nil assigns(:description)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_preview_notes
|
def test_preview_notes
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
post :preview, :project_id => '1', :id => 1, :issue => {:description => Issue.find(1).description}, :notes => 'Foo'
|
post :preview, :project_id => '1', :id => 1, :issue => {:description => Issue.find(1).description}, :notes => 'Foo'
|
||||||
@ -1232,14 +1236,14 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
assert_not_nil assigns(:issues)
|
assert_not_nil assigns(:issues)
|
||||||
assert assigns(:issues).detect {|issue| issue.subject.match /recipe/}
|
assert assigns(:issues).detect {|issue| issue.subject.match /recipe/}
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_auto_complete_should_return_issue_with_given_id
|
def test_auto_complete_should_return_issue_with_given_id
|
||||||
get :auto_complete, :project_id => 'subproject1', :q => '13'
|
get :auto_complete, :project_id => 'subproject1', :q => '13'
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_not_nil assigns(:issues)
|
assert_not_nil assigns(:issues)
|
||||||
assert assigns(:issues).include?(Issue.find(13))
|
assert assigns(:issues).include?(Issue.find(13))
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_destroy_issue_with_no_time_entries
|
def test_destroy_issue_with_no_time_entries
|
||||||
assert_nil TimeEntry.find_by_issue_id(2)
|
assert_nil TimeEntry.find_by_issue_id(2)
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
@ -1273,7 +1277,7 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
assert_nil TimeEntry.find(1).issue_id
|
assert_nil TimeEntry.find(1).issue_id
|
||||||
assert_nil TimeEntry.find(2).issue_id
|
assert_nil TimeEntry.find(2).issue_id
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_destroy_issues_and_reassign_time_entries_to_another_issue
|
def test_destroy_issues_and_reassign_time_entries_to_another_issue
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
post :destroy, :ids => [1, 3], :todo => 'reassign', :reassign_to_id => 2
|
post :destroy, :ids => [1, 3], :todo => 'reassign', :reassign_to_id => 2
|
||||||
@ -1282,7 +1286,7 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
assert_equal 2, TimeEntry.find(1).issue_id
|
assert_equal 2, TimeEntry.find(1).issue_id
|
||||||
assert_equal 2, TimeEntry.find(2).issue_id
|
assert_equal 2, TimeEntry.find(2).issue_id
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_default_search_scope
|
def test_default_search_scope
|
||||||
get :index
|
get :index
|
||||||
assert_tag :div, :attributes => {:id => 'quick-search'},
|
assert_tag :div, :attributes => {:id => 'quick-search'},
|
||||||
|
@ -43,11 +43,10 @@ class IssuesControllerTransactionTest < ActionController::TestCase
|
|||||||
:custom_fields_trackers,
|
:custom_fields_trackers,
|
||||||
:time_entries,
|
:time_entries,
|
||||||
:journals,
|
:journals,
|
||||||
:journal_details,
|
|
||||||
:queries
|
:queries
|
||||||
|
|
||||||
self.use_transactional_fixtures = false
|
self.use_transactional_fixtures = false
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@controller = IssuesController.new
|
@controller = IssuesController.new
|
||||||
@request = ActionController::TestRequest.new
|
@request = ActionController::TestRequest.new
|
||||||
|
@ -22,8 +22,8 @@ require 'journals_controller'
|
|||||||
class JournalsController; def rescue_action(e) raise e end; end
|
class JournalsController; def rescue_action(e) raise e end; end
|
||||||
|
|
||||||
class JournalsControllerTest < ActionController::TestCase
|
class JournalsControllerTest < ActionController::TestCase
|
||||||
fixtures :projects, :users, :members, :member_roles, :roles, :issues, :journals, :journal_details, :enabled_modules
|
fixtures :projects, :users, :members, :member_roles, :roles, :issues, :journals, :enabled_modules
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@controller = JournalsController.new
|
@controller = JournalsController.new
|
||||||
@request = ActionController::TestRequest.new
|
@request = ActionController::TestRequest.new
|
||||||
|
@ -22,7 +22,7 @@ require 'projects_controller'
|
|||||||
class ProjectsController; def rescue_action(e) raise e end; end
|
class ProjectsController; def rescue_action(e) raise e end; end
|
||||||
|
|
||||||
class ProjectsControllerTest < ActionController::TestCase
|
class ProjectsControllerTest < ActionController::TestCase
|
||||||
fixtures :projects, :versions, :users, :roles, :members, :member_roles, :issues, :journals, :journal_details,
|
fixtures :projects, :versions, :users, :roles, :members, :member_roles, :issues, :journals,
|
||||||
:trackers, :projects_trackers, :issue_statuses, :enabled_modules, :enumerations, :boards, :messages,
|
:trackers, :projects_trackers, :issue_statuses, :enabled_modules, :enumerations, :boards, :messages,
|
||||||
:attachments, :custom_fields, :custom_values, :time_entries
|
:attachments, :custom_fields, :custom_values, :time_entries
|
||||||
|
|
||||||
|
@ -5,12 +5,12 @@
|
|||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
@ -22,15 +22,15 @@ require 'wiki_controller'
|
|||||||
class WikiController; def rescue_action(e) raise e end; end
|
class WikiController; def rescue_action(e) raise e end; end
|
||||||
|
|
||||||
class WikiControllerTest < ActionController::TestCase
|
class WikiControllerTest < ActionController::TestCase
|
||||||
fixtures :projects, :users, :roles, :members, :member_roles, :enabled_modules, :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions, :attachments
|
fixtures :projects, :users, :roles, :members, :member_roles, :enabled_modules, :wikis, :wiki_pages, :wiki_contents, :journals, :attachments
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@controller = WikiController.new
|
@controller = WikiController.new
|
||||||
@request = ActionController::TestRequest.new
|
@request = ActionController::TestRequest.new
|
||||||
@response = ActionController::TestResponse.new
|
@response = ActionController::TestResponse.new
|
||||||
User.current = nil
|
User.current = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show_start_page
|
def test_show_start_page
|
||||||
get :index, :id => 'ecookbook'
|
get :index, :id => 'ecookbook'
|
||||||
assert_response :success
|
assert_response :success
|
||||||
@ -43,7 +43,7 @@ class WikiControllerTest < ActionController::TestCase
|
|||||||
:child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/Page_with_an_inline_image' },
|
:child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/Page_with_an_inline_image' },
|
||||||
:content => 'Page with an inline image' } }
|
:content => 'Page with an inline image' } }
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show_page_with_name
|
def test_show_page_with_name
|
||||||
get :index, :id => 1, :page => 'Another_page'
|
get :index, :id => 1, :page => 'Another_page'
|
||||||
assert_response :success
|
assert_response :success
|
||||||
@ -54,30 +54,30 @@ class WikiControllerTest < ActionController::TestCase
|
|||||||
assert_tag :tag => 'img', :attributes => { :src => '/attachments/download/3',
|
assert_tag :tag => 'img', :attributes => { :src => '/attachments/download/3',
|
||||||
:alt => 'This is a logo' }
|
:alt => 'This is a logo' }
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show_with_sidebar
|
def test_show_with_sidebar
|
||||||
page = Project.find(1).wiki.pages.new(:title => 'Sidebar')
|
page = Project.find(1).wiki.pages.new(:title => 'Sidebar')
|
||||||
page.content = WikiContent.new(:text => 'Side bar content for test_show_with_sidebar')
|
page.content = WikiContent.new(:text => 'Side bar content for test_show_with_sidebar')
|
||||||
page.save!
|
page.save!
|
||||||
|
|
||||||
get :index, :id => 1, :page => 'Another_page'
|
get :index, :id => 1, :page => 'Another_page'
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_tag :tag => 'div', :attributes => {:id => 'sidebar'},
|
assert_tag :tag => 'div', :attributes => {:id => 'sidebar'},
|
||||||
:content => /Side bar content for test_show_with_sidebar/
|
:content => /Side bar content for test_show_with_sidebar/
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show_unexistent_page_without_edit_right
|
def test_show_unexistent_page_without_edit_right
|
||||||
get :index, :id => 1, :page => 'Unexistent page'
|
get :index, :id => 1, :page => 'Unexistent page'
|
||||||
assert_response 404
|
assert_response 404
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show_unexistent_page_with_edit_right
|
def test_show_unexistent_page_with_edit_right
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :index, :id => 1, :page => 'Unexistent page'
|
get :index, :id => 1, :page => 'Unexistent page'
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_template 'edit'
|
assert_template 'edit'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_create_page
|
def test_create_page
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
post :edit, :id => 1,
|
post :edit, :id => 1,
|
||||||
@ -91,7 +91,7 @@ class WikiControllerTest < ActionController::TestCase
|
|||||||
assert_not_nil page.content
|
assert_not_nil page.content
|
||||||
assert_equal 'Created the page', page.content.comments
|
assert_equal 'Created the page', page.content.comments
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_create_page_with_attachments
|
def test_create_page_with_attachments
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
assert_difference 'WikiPage.count' do
|
assert_difference 'WikiPage.count' do
|
||||||
@ -108,7 +108,7 @@ class WikiControllerTest < ActionController::TestCase
|
|||||||
assert_equal 1, page.attachments.count
|
assert_equal 1, page.attachments.count
|
||||||
assert_equal 'testfile.txt', page.attachments.first.filename
|
assert_equal 'testfile.txt', page.attachments.first.filename
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_preview
|
def test_preview
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
xhr :post, :preview, :id => 1, :page => 'CookBook_documentation',
|
xhr :post, :preview, :id => 1, :page => 'CookBook_documentation',
|
||||||
@ -119,7 +119,7 @@ class WikiControllerTest < ActionController::TestCase
|
|||||||
assert_template 'common/_preview'
|
assert_template 'common/_preview'
|
||||||
assert_tag :tag => 'strong', :content => /previewed text/
|
assert_tag :tag => 'strong', :content => /previewed text/
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_preview_new_page
|
def test_preview_new_page
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
xhr :post, :preview, :id => 1, :page => 'New page',
|
xhr :post, :preview, :id => 1, :page => 'New page',
|
||||||
@ -130,7 +130,7 @@ class WikiControllerTest < ActionController::TestCase
|
|||||||
assert_template 'common/_preview'
|
assert_template 'common/_preview'
|
||||||
assert_tag :tag => 'h1', :content => /New page/
|
assert_tag :tag => 'h1', :content => /New page/
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_history
|
def test_history
|
||||||
get :history, :id => 1, :page => 'CookBook_documentation'
|
get :history, :id => 1, :page => 'CookBook_documentation'
|
||||||
assert_response :success
|
assert_response :success
|
||||||
@ -148,7 +148,7 @@ class WikiControllerTest < ActionController::TestCase
|
|||||||
assert_equal 1, assigns(:versions).size
|
assert_equal 1, assigns(:versions).size
|
||||||
assert_select "input[type=submit][name=commit]", false
|
assert_select "input[type=submit][name=commit]", false
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_diff
|
def test_diff
|
||||||
get :diff, :id => 1, :page => 'CookBook_documentation', :version => 2, :version_from => 1
|
get :diff, :id => 1, :page => 'CookBook_documentation', :version => 2, :version_from => 1
|
||||||
assert_response :success
|
assert_response :success
|
||||||
@ -156,7 +156,7 @@ class WikiControllerTest < ActionController::TestCase
|
|||||||
assert_tag :tag => 'span', :attributes => { :class => 'diff_in'},
|
assert_tag :tag => 'span', :attributes => { :class => 'diff_in'},
|
||||||
:content => /updated/
|
:content => /updated/
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_annotate
|
def test_annotate
|
||||||
get :annotate, :id => 1, :page => 'CookBook_documentation', :version => 2
|
get :annotate, :id => 1, :page => 'CookBook_documentation', :version => 2
|
||||||
assert_response :success
|
assert_response :success
|
||||||
@ -170,7 +170,7 @@ class WikiControllerTest < ActionController::TestCase
|
|||||||
:child => { :tag => 'td', :attributes => {:class => 'author'}, :content => /redMine Admin/ },
|
:child => { :tag => 'td', :attributes => {:class => 'author'}, :content => /redMine Admin/ },
|
||||||
:child => { :tag => 'td', :content => /Some updated \[\[documentation\]\] here/ }
|
:child => { :tag => 'td', :content => /Some updated \[\[documentation\]\] here/ }
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_rename_with_redirect
|
def test_rename_with_redirect
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
post :rename, :id => 1, :page => 'Another_page',
|
post :rename, :id => 1, :page => 'Another_page',
|
||||||
@ -193,13 +193,13 @@ class WikiControllerTest < ActionController::TestCase
|
|||||||
# Check that there's no redirects
|
# Check that there's no redirects
|
||||||
assert_nil wiki.find_page('Another page')
|
assert_nil wiki.find_page('Another page')
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_destroy_child
|
def test_destroy_child
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
post :destroy, :id => 1, :page => 'Child_1'
|
post :destroy, :id => 1, :page => 'Child_1'
|
||||||
assert_redirected_to :action => 'special', :id => 'ecookbook', :page => 'Page_index'
|
assert_redirected_to :action => 'special', :id => 'ecookbook', :page => 'Page_index'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_destroy_parent
|
def test_destroy_parent
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
assert_no_difference('WikiPage.count') do
|
assert_no_difference('WikiPage.count') do
|
||||||
@ -208,7 +208,7 @@ class WikiControllerTest < ActionController::TestCase
|
|||||||
assert_response :success
|
assert_response :success
|
||||||
assert_template 'destroy'
|
assert_template 'destroy'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_destroy_parent_with_nullify
|
def test_destroy_parent_with_nullify
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
assert_difference('WikiPage.count', -1) do
|
assert_difference('WikiPage.count', -1) do
|
||||||
@ -217,7 +217,7 @@ class WikiControllerTest < ActionController::TestCase
|
|||||||
assert_redirected_to :action => 'special', :id => 'ecookbook', :page => 'Page_index'
|
assert_redirected_to :action => 'special', :id => 'ecookbook', :page => 'Page_index'
|
||||||
assert_nil WikiPage.find_by_id(2)
|
assert_nil WikiPage.find_by_id(2)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_destroy_parent_with_cascade
|
def test_destroy_parent_with_cascade
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
assert_difference('WikiPage.count', -3) do
|
assert_difference('WikiPage.count', -3) do
|
||||||
@ -227,7 +227,7 @@ class WikiControllerTest < ActionController::TestCase
|
|||||||
assert_nil WikiPage.find_by_id(2)
|
assert_nil WikiPage.find_by_id(2)
|
||||||
assert_nil WikiPage.find_by_id(5)
|
assert_nil WikiPage.find_by_id(5)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_destroy_parent_with_reassign
|
def test_destroy_parent_with_reassign
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
assert_difference('WikiPage.count', -1) do
|
assert_difference('WikiPage.count', -1) do
|
||||||
@ -237,7 +237,7 @@ class WikiControllerTest < ActionController::TestCase
|
|||||||
assert_nil WikiPage.find_by_id(2)
|
assert_nil WikiPage.find_by_id(2)
|
||||||
assert_equal WikiPage.find(1), WikiPage.find_by_id(5).parent
|
assert_equal WikiPage.find(1), WikiPage.find_by_id(5).parent
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_page_index
|
def test_page_index
|
||||||
get :special, :id => 'ecookbook', :page => 'Page_index'
|
get :special, :id => 'ecookbook', :page => 'Page_index'
|
||||||
assert_response :success
|
assert_response :success
|
||||||
@ -245,7 +245,7 @@ class WikiControllerTest < ActionController::TestCase
|
|||||||
pages = assigns(:pages)
|
pages = assigns(:pages)
|
||||||
assert_not_nil pages
|
assert_not_nil pages
|
||||||
assert_equal Project.find(1).wiki.pages.size, pages.size
|
assert_equal Project.find(1).wiki.pages.size, pages.size
|
||||||
|
|
||||||
assert_tag :ul, :attributes => { :class => 'pages-hierarchy' },
|
assert_tag :ul, :attributes => { :class => 'pages-hierarchy' },
|
||||||
:child => { :tag => 'li', :child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/CookBook_documentation' },
|
:child => { :tag => 'li', :child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/CookBook_documentation' },
|
||||||
:content => 'CookBook documentation' },
|
:content => 'CookBook documentation' },
|
||||||
@ -256,12 +256,12 @@ class WikiControllerTest < ActionController::TestCase
|
|||||||
:child => { :tag => 'li', :child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/Another_page' },
|
:child => { :tag => 'li', :child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/Another_page' },
|
||||||
:content => 'Another page' } }
|
:content => 'Another page' } }
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_not_found
|
def test_not_found
|
||||||
get :index, :id => 999
|
get :index, :id => 999
|
||||||
assert_response 404
|
assert_response 404
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_protect_page
|
def test_protect_page
|
||||||
page = WikiPage.find_by_wiki_id_and_title(1, 'Another_page')
|
page = WikiPage.find_by_wiki_id_and_title(1, 'Another_page')
|
||||||
assert !page.protected?
|
assert !page.protected?
|
||||||
@ -270,7 +270,7 @@ class WikiControllerTest < ActionController::TestCase
|
|||||||
assert_redirected_to :action => 'index', :id => 'ecookbook', :page => 'Another_page'
|
assert_redirected_to :action => 'index', :id => 'ecookbook', :page => 'Another_page'
|
||||||
assert page.reload.protected?
|
assert page.reload.protected?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_unprotect_page
|
def test_unprotect_page
|
||||||
page = WikiPage.find_by_wiki_id_and_title(1, 'CookBook_documentation')
|
page = WikiPage.find_by_wiki_id_and_title(1, 'CookBook_documentation')
|
||||||
assert page.protected?
|
assert page.protected?
|
||||||
@ -279,7 +279,7 @@ class WikiControllerTest < ActionController::TestCase
|
|||||||
assert_redirected_to :action => 'index', :id => 'ecookbook', :page => 'CookBook_documentation'
|
assert_redirected_to :action => 'index', :id => 'ecookbook', :page => 'CookBook_documentation'
|
||||||
assert !page.reload.protected?
|
assert !page.reload.protected?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show_page_with_edit_link
|
def test_show_page_with_edit_link
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :index, :id => 1
|
get :index, :id => 1
|
||||||
@ -287,15 +287,15 @@ class WikiControllerTest < ActionController::TestCase
|
|||||||
assert_template 'show'
|
assert_template 'show'
|
||||||
assert_tag :tag => 'a', :attributes => { :href => '/projects/1/wiki/CookBook_documentation/edit' }
|
assert_tag :tag => 'a', :attributes => { :href => '/projects/1/wiki/CookBook_documentation/edit' }
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show_page_without_edit_link
|
def test_show_page_without_edit_link
|
||||||
@request.session[:user_id] = 4
|
@request.session[:user_id] = 4
|
||||||
get :index, :id => 1
|
get :index, :id => 1
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_template 'show'
|
assert_template 'show'
|
||||||
assert_no_tag :tag => 'a', :attributes => { :href => '/projects/1/wiki/CookBook_documentation/edit' }
|
assert_no_tag :tag => 'a', :attributes => { :href => '/projects/1/wiki/CookBook_documentation/edit' }
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_edit_unprotected_page
|
def test_edit_unprotected_page
|
||||||
# Non members can edit unprotected wiki pages
|
# Non members can edit unprotected wiki pages
|
||||||
@request.session[:user_id] = 4
|
@request.session[:user_id] = 4
|
||||||
@ -303,21 +303,21 @@ class WikiControllerTest < ActionController::TestCase
|
|||||||
assert_response :success
|
assert_response :success
|
||||||
assert_template 'edit'
|
assert_template 'edit'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_edit_protected_page_by_nonmember
|
def test_edit_protected_page_by_nonmember
|
||||||
# Non members can't edit protected wiki pages
|
# Non members can't edit protected wiki pages
|
||||||
@request.session[:user_id] = 4
|
@request.session[:user_id] = 4
|
||||||
get :edit, :id => 1, :page => 'CookBook_documentation'
|
get :edit, :id => 1, :page => 'CookBook_documentation'
|
||||||
assert_response 403
|
assert_response 403
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_edit_protected_page_by_member
|
def test_edit_protected_page_by_member
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :edit, :id => 1, :page => 'CookBook_documentation'
|
get :edit, :id => 1, :page => 'CookBook_documentation'
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_template 'edit'
|
assert_template 'edit'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_history_of_non_existing_page_should_return_404
|
def test_history_of_non_existing_page_should_return_404
|
||||||
get :history, :id => 1, :page => 'Unknown_page'
|
get :history, :id => 1, :page => 'Unknown_page'
|
||||||
assert_response 404
|
assert_response 404
|
||||||
|
@ -39,7 +39,6 @@ class IssuesApiTest < ActionController::IntegrationTest
|
|||||||
:custom_fields_trackers,
|
:custom_fields_trackers,
|
||||||
:time_entries,
|
:time_entries,
|
||||||
:journals,
|
:journals,
|
||||||
:journal_details,
|
|
||||||
:queries
|
:queries
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
require "#{File.dirname(__FILE__)}/../test_helper"
|
require "#{File.dirname(__FILE__)}/../test_helper"
|
||||||
|
|
||||||
class ProjectsApiTest < ActionController::IntegrationTest
|
class ProjectsApiTest < ActionController::IntegrationTest
|
||||||
fixtures :projects, :versions, :users, :roles, :members, :member_roles, :issues, :journals, :journal_details,
|
fixtures :projects, :versions, :users, :roles, :members, :member_roles, :issues, :journals,
|
||||||
:trackers, :projects_trackers, :issue_statuses, :enabled_modules, :enumerations, :boards, :messages,
|
:trackers, :projects_trackers, :issue_statuses, :enabled_modules, :enumerations, :boards, :messages,
|
||||||
:attachments, :custom_fields, :custom_values, :time_entries
|
:attachments, :custom_fields, :custom_values, :time_entries
|
||||||
|
|
||||||
|
@ -5,12 +5,12 @@
|
|||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
@ -47,7 +47,7 @@ class ActiveSupport::TestCase
|
|||||||
self.use_instantiated_fixtures = false
|
self.use_instantiated_fixtures = false
|
||||||
|
|
||||||
# Add more helper methods to be used by all tests here...
|
# Add more helper methods to be used by all tests here...
|
||||||
|
|
||||||
def log_user(login, password)
|
def log_user(login, password)
|
||||||
User.anonymous
|
User.anonymous
|
||||||
get "/login"
|
get "/login"
|
||||||
@ -57,7 +57,7 @@ class ActiveSupport::TestCase
|
|||||||
post "/login", :username => login, :password => password
|
post "/login", :username => login, :password => password
|
||||||
assert_equal login, User.find(session[:user_id]).login
|
assert_equal login, User.find(session[:user_id]).login
|
||||||
end
|
end
|
||||||
|
|
||||||
def uploaded_test_file(name, mime)
|
def uploaded_test_file(name, mime)
|
||||||
ActionController::TestUploadedFile.new(ActiveSupport::TestCase.fixture_path + "/files/#{name}", mime)
|
ActionController::TestUploadedFile.new(ActiveSupport::TestCase.fixture_path + "/files/#{name}", mime)
|
||||||
end
|
end
|
||||||
@ -71,14 +71,14 @@ class ActiveSupport::TestCase
|
|||||||
file.stubs(:read).returns(false)
|
file.stubs(:read).returns(false)
|
||||||
file
|
file
|
||||||
end
|
end
|
||||||
|
|
||||||
# Use a temporary directory for attachment related tests
|
# Use a temporary directory for attachment related tests
|
||||||
def set_tmp_attachments_directory
|
def set_tmp_attachments_directory
|
||||||
Dir.mkdir "#{RAILS_ROOT}/tmp/test" unless File.directory?("#{RAILS_ROOT}/tmp/test")
|
Dir.mkdir "#{RAILS_ROOT}/tmp/test" unless File.directory?("#{RAILS_ROOT}/tmp/test")
|
||||||
Dir.mkdir "#{RAILS_ROOT}/tmp/test/attachments" unless File.directory?("#{RAILS_ROOT}/tmp/test/attachments")
|
Dir.mkdir "#{RAILS_ROOT}/tmp/test/attachments" unless File.directory?("#{RAILS_ROOT}/tmp/test/attachments")
|
||||||
Attachment.storage_path = "#{RAILS_ROOT}/tmp/test/attachments"
|
Attachment.storage_path = "#{RAILS_ROOT}/tmp/test/attachments"
|
||||||
end
|
end
|
||||||
|
|
||||||
def with_settings(options, &block)
|
def with_settings(options, &block)
|
||||||
saved_settings = options.keys.inject({}) {|h, k| h[k] = Setting[k].dup; h}
|
saved_settings = options.keys.inject({}) {|h, k| h[k] = Setting[k].dup; h}
|
||||||
options.each {|k, v| Setting[k] = v}
|
options.each {|k, v| Setting[k] = v}
|
||||||
@ -93,12 +93,12 @@ class ActiveSupport::TestCase
|
|||||||
# LDAP is not listening
|
# LDAP is not listening
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the path to the test +vendor+ repository
|
# Returns the path to the test +vendor+ repository
|
||||||
def self.repository_path(vendor)
|
def self.repository_path(vendor)
|
||||||
File.join(RAILS_ROOT.gsub(%r{config\/\.\.}, ''), "/tmp/test/#{vendor.downcase}_repository")
|
File.join(RAILS_ROOT.gsub(%r{config\/\.\.}, ''), "/tmp/test/#{vendor.downcase}_repository")
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns true if the +vendor+ test repository is configured
|
# Returns true if the +vendor+ test repository is configured
|
||||||
def self.repository_configured?(vendor)
|
def self.repository_configured?(vendor)
|
||||||
File.directory?(repository_path(vendor))
|
File.directory?(repository_path(vendor))
|
||||||
@ -144,21 +144,17 @@ class ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "use the new value's name" do
|
should "use the new value's name" do
|
||||||
@detail = JournalDetail.generate!(:property => 'attr',
|
@detail = IssueJournal.generate(:version => 1)
|
||||||
:old_value => @old_value.id,
|
@detail.update_attribute(:changes, {prop_key => [@old_value.id, @new_value.id]}.to_yaml)
|
||||||
:value => @new_value.id,
|
|
||||||
:prop_key => prop_key)
|
assert_match @new_value.name, @detail.render_detail(prop_key, true)
|
||||||
|
|
||||||
assert_match @new_value.name, show_detail(@detail, true)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
should "use the old value's name" do
|
should "use the old value's name" do
|
||||||
@detail = JournalDetail.generate!(:property => 'attr',
|
@detail = IssueJournal.generate(:version => 1)
|
||||||
:old_value => @old_value.id,
|
@detail.update_attribute(:changes, {prop_key => [@old_value.id, @new_value.id]}.to_yaml)
|
||||||
:value => @new_value.id,
|
|
||||||
:prop_key => prop_key)
|
assert_match @old_value.name, @detail.render_detail(prop_key, true)
|
||||||
|
|
||||||
assert_match @old_value.name, show_detail(@detail, true)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
require File.dirname(__FILE__) + '/../test_helper'
|
require File.dirname(__FILE__) + '/../test_helper'
|
||||||
|
|
||||||
class ActivityTest < ActiveSupport::TestCase
|
class ActivityTest < ActiveSupport::TestCase
|
||||||
fixtures :projects, :versions, :attachments, :users, :roles, :members, :member_roles, :issues, :journals, :journal_details,
|
fixtures :projects, :versions, :attachments, :users, :roles, :members, :member_roles, :issues, :journals,
|
||||||
:trackers, :projects_trackers, :issue_statuses, :enabled_modules, :enumerations, :boards, :messages
|
:trackers, :projects_trackers, :issue_statuses, :enabled_modules, :enumerations, :boards, :messages
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@ -28,7 +28,6 @@ class ActivityTest < ActiveSupport::TestCase
|
|||||||
def test_activity_without_subprojects
|
def test_activity_without_subprojects
|
||||||
events = find_events(User.anonymous, :project => @project)
|
events = find_events(User.anonymous, :project => @project)
|
||||||
assert_not_nil events
|
assert_not_nil events
|
||||||
|
|
||||||
assert events.include?(Issue.find(1))
|
assert events.include?(Issue.find(1))
|
||||||
assert !events.include?(Issue.find(4))
|
assert !events.include?(Issue.find(4))
|
||||||
# subproject issue
|
# subproject issue
|
||||||
@ -43,40 +42,40 @@ class ActivityTest < ActiveSupport::TestCase
|
|||||||
# subproject issue
|
# subproject issue
|
||||||
assert events.include?(Issue.find(5))
|
assert events.include?(Issue.find(5))
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_global_activity_anonymous
|
def test_global_activity_anonymous
|
||||||
events = find_events(User.anonymous)
|
events = find_events(User.anonymous)
|
||||||
assert_not_nil events
|
assert_not_nil events
|
||||||
|
|
||||||
assert events.include?(Issue.find(1))
|
assert events.include?(Issue.find(1))
|
||||||
assert events.include?(Message.find(5))
|
assert events.include?(Message.find(5))
|
||||||
# Issue of a private project
|
# Issue of a private project
|
||||||
assert !events.include?(Issue.find(4))
|
assert !events.include?(Issue.find(6))
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_global_activity_logged_user
|
def test_global_activity_logged_user
|
||||||
events = find_events(User.find(2)) # manager
|
events = find_events(User.find(2)) # manager
|
||||||
assert_not_nil events
|
assert_not_nil events
|
||||||
|
|
||||||
assert events.include?(Issue.find(1))
|
assert events.include?(Issue.find(1))
|
||||||
# Issue of a private project the user belongs to
|
# Issue of a private project the user belongs to
|
||||||
assert events.include?(Issue.find(4))
|
assert events.include?(Issue.find(6))
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_user_activity
|
def test_user_activity
|
||||||
user = User.find(2)
|
user = User.find(2)
|
||||||
events = Redmine::Activity::Fetcher.new(User.anonymous, :author => user).events(nil, nil, :limit => 10)
|
events = Redmine::Activity::Fetcher.new(User.anonymous, :author => user).events(nil, nil, :limit => 10)
|
||||||
|
|
||||||
assert(events.size > 0)
|
assert(events.size > 0)
|
||||||
assert(events.size <= 10)
|
assert(events.size <= 10)
|
||||||
assert_nil(events.detect {|e| e.event_author != user})
|
assert_nil(events.detect {|e| e.event_author != user})
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_files_activity
|
def test_files_activity
|
||||||
f = Redmine::Activity::Fetcher.new(User.anonymous, :project => Project.find(1))
|
f = Redmine::Activity::Fetcher.new(User.anonymous, :project => Project.find(1))
|
||||||
f.scope = ['files']
|
f.scope = ['files']
|
||||||
events = f.events
|
events = f.events
|
||||||
|
|
||||||
assert_kind_of Array, events
|
assert_kind_of Array, events
|
||||||
assert events.include?(Attachment.find_by_container_type_and_container_id('Project', 1))
|
assert events.include?(Attachment.find_by_container_type_and_container_id('Project', 1))
|
||||||
assert events.include?(Attachment.find_by_container_type_and_container_id('Version', 1))
|
assert events.include?(Attachment.find_by_container_type_and_container_id('Version', 1))
|
||||||
@ -85,8 +84,11 @@ class ActivityTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def find_events(user, options={})
|
def find_events(user, options={})
|
||||||
Redmine::Activity::Fetcher.new(user, options).events(Date.today - 30, Date.today + 1)
|
events = Redmine::Activity::Fetcher.new(user, options).events(Date.today - 30, Date.today + 1)
|
||||||
|
# Because events are provided by the journals, but we want to test for
|
||||||
|
# their targets here, transform that
|
||||||
|
events.group_by(&:versioned).keys
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -5,12 +5,12 @@
|
|||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
@ -22,7 +22,7 @@ class IssueTest < ActiveSupport::TestCase
|
|||||||
:trackers, :projects_trackers,
|
:trackers, :projects_trackers,
|
||||||
:enabled_modules,
|
:enabled_modules,
|
||||||
:versions,
|
:versions,
|
||||||
:issue_statuses, :issue_categories, :issue_relations, :workflows,
|
:issue_statuses, :issue_categories, :issue_relations, :workflows,
|
||||||
:enumerations,
|
:enumerations,
|
||||||
:issues,
|
:issues,
|
||||||
:custom_fields, :custom_fields_projects, :custom_fields_trackers, :custom_values,
|
:custom_fields, :custom_fields_projects, :custom_fields_trackers, :custom_values,
|
||||||
@ -34,17 +34,17 @@ class IssueTest < ActiveSupport::TestCase
|
|||||||
issue.reload
|
issue.reload
|
||||||
assert_equal 1.5, issue.estimated_hours
|
assert_equal 1.5, issue.estimated_hours
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_create_minimal
|
def test_create_minimal
|
||||||
issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3, :status_id => 1, :priority => IssuePriority.all.first, :subject => 'test_create')
|
issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3, :status_id => 1, :priority => IssuePriority.all.first, :subject => 'test_create')
|
||||||
assert issue.save
|
assert issue.save
|
||||||
assert issue.description.nil?
|
assert issue.description.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_create_with_required_custom_field
|
def test_create_with_required_custom_field
|
||||||
field = IssueCustomField.find_by_name('Database')
|
field = IssueCustomField.find_by_name('Database')
|
||||||
field.update_attribute(:is_required, true)
|
field.update_attribute(:is_required, true)
|
||||||
|
|
||||||
issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :subject => 'test_create', :description => 'IssueTest#test_create_with_required_custom_field')
|
issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :subject => 'test_create', :description => 'IssueTest#test_create_with_required_custom_field')
|
||||||
assert issue.available_custom_fields.include?(field)
|
assert issue.available_custom_fields.include?(field)
|
||||||
# No value for the custom field
|
# No value for the custom field
|
||||||
@ -64,7 +64,7 @@ class IssueTest < ActiveSupport::TestCase
|
|||||||
issue.reload
|
issue.reload
|
||||||
assert_equal 'PostgreSQL', issue.custom_value_for(field).value
|
assert_equal 'PostgreSQL', issue.custom_value_for(field).value
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_visible_scope_for_anonymous
|
def test_visible_scope_for_anonymous
|
||||||
# Anonymous user should see issues of public projects only
|
# Anonymous user should see issues of public projects only
|
||||||
issues = Issue.visible(User.anonymous).all
|
issues = Issue.visible(User.anonymous).all
|
||||||
@ -75,7 +75,7 @@ class IssueTest < ActiveSupport::TestCase
|
|||||||
issues = Issue.visible(User.anonymous).all
|
issues = Issue.visible(User.anonymous).all
|
||||||
assert issues.empty?
|
assert issues.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_visible_scope_for_user
|
def test_visible_scope_for_user
|
||||||
user = User.find(9)
|
user = User.find(9)
|
||||||
assert user.projects.empty?
|
assert user.projects.empty?
|
||||||
@ -95,7 +95,7 @@ class IssueTest < ActiveSupport::TestCase
|
|||||||
assert issues.any?
|
assert issues.any?
|
||||||
assert_nil issues.detect {|issue| issue.project_id != 2}
|
assert_nil issues.detect {|issue| issue.project_id != 2}
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_visible_scope_for_admin
|
def test_visible_scope_for_admin
|
||||||
user = User.find(1)
|
user = User.find(1)
|
||||||
user.members.each(&:destroy)
|
user.members.each(&:destroy)
|
||||||
@ -105,24 +105,24 @@ class IssueTest < ActiveSupport::TestCase
|
|||||||
# Admin should see issues on private projects that he does not belong to
|
# Admin should see issues on private projects that he does not belong to
|
||||||
assert issues.detect {|issue| !issue.project.is_public?}
|
assert issues.detect {|issue| !issue.project.is_public?}
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_errors_full_messages_should_include_custom_fields_errors
|
def test_errors_full_messages_should_include_custom_fields_errors
|
||||||
field = IssueCustomField.find_by_name('Database')
|
field = IssueCustomField.find_by_name('Database')
|
||||||
|
|
||||||
issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :subject => 'test_create', :description => 'IssueTest#test_create_with_required_custom_field')
|
issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :subject => 'test_create', :description => 'IssueTest#test_create_with_required_custom_field')
|
||||||
assert issue.available_custom_fields.include?(field)
|
assert issue.available_custom_fields.include?(field)
|
||||||
# Invalid value
|
# Invalid value
|
||||||
issue.custom_field_values = { field.id => 'SQLServer' }
|
issue.custom_field_values = { field.id => 'SQLServer' }
|
||||||
|
|
||||||
assert !issue.valid?
|
assert !issue.valid?
|
||||||
assert_equal 1, issue.errors.full_messages.size
|
assert_equal 1, issue.errors.full_messages.size
|
||||||
assert_equal "Database #{I18n.translate('activerecord.errors.messages.inclusion')}", issue.errors.full_messages.first
|
assert_equal "Database #{I18n.translate('activerecord.errors.messages.inclusion')}", issue.errors.full_messages.first
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_update_issue_with_required_custom_field
|
def test_update_issue_with_required_custom_field
|
||||||
field = IssueCustomField.find_by_name('Database')
|
field = IssueCustomField.find_by_name('Database')
|
||||||
field.update_attribute(:is_required, true)
|
field.update_attribute(:is_required, true)
|
||||||
|
|
||||||
issue = Issue.find(1)
|
issue = Issue.find(1)
|
||||||
assert_nil issue.custom_value_for(field)
|
assert_nil issue.custom_value_for(field)
|
||||||
assert issue.available_custom_fields.include?(field)
|
assert issue.available_custom_fields.include?(field)
|
||||||
@ -137,23 +137,23 @@ class IssueTest < ActiveSupport::TestCase
|
|||||||
issue.reload
|
issue.reload
|
||||||
assert_equal 'PostgreSQL', issue.custom_value_for(field).value
|
assert_equal 'PostgreSQL', issue.custom_value_for(field).value
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_should_not_update_attributes_if_custom_fields_validation_fails
|
def test_should_not_update_attributes_if_custom_fields_validation_fails
|
||||||
issue = Issue.find(1)
|
issue = Issue.find(1)
|
||||||
field = IssueCustomField.find_by_name('Database')
|
field = IssueCustomField.find_by_name('Database')
|
||||||
assert issue.available_custom_fields.include?(field)
|
assert issue.available_custom_fields.include?(field)
|
||||||
|
|
||||||
issue.custom_field_values = { field.id => 'Invalid' }
|
issue.custom_field_values = { field.id => 'Invalid' }
|
||||||
issue.subject = 'Should be not be saved'
|
issue.subject = 'Should be not be saved'
|
||||||
assert !issue.save
|
assert !issue.save
|
||||||
|
|
||||||
issue.reload
|
issue.reload
|
||||||
assert_equal "Can't print recipes", issue.subject
|
assert_equal "Can't print recipes", issue.subject
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_should_not_recreate_custom_values_objects_on_update
|
def test_should_not_recreate_custom_values_objects_on_update
|
||||||
field = IssueCustomField.find_by_name('Database')
|
field = IssueCustomField.find_by_name('Database')
|
||||||
|
|
||||||
issue = Issue.find(1)
|
issue = Issue.find(1)
|
||||||
issue.custom_field_values = { field.id => 'PostgreSQL' }
|
issue.custom_field_values = { field.id => 'PostgreSQL' }
|
||||||
assert issue.save
|
assert issue.save
|
||||||
@ -164,14 +164,14 @@ class IssueTest < ActiveSupport::TestCase
|
|||||||
issue.reload
|
issue.reload
|
||||||
assert_equal custom_value.id, issue.custom_value_for(field).id
|
assert_equal custom_value.id, issue.custom_value_for(field).id
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_assigning_tracker_id_should_reload_custom_fields_values
|
def test_assigning_tracker_id_should_reload_custom_fields_values
|
||||||
issue = Issue.new(:project => Project.find(1))
|
issue = Issue.new(:project => Project.find(1))
|
||||||
assert issue.custom_field_values.empty?
|
assert issue.custom_field_values.empty?
|
||||||
issue.tracker_id = 1
|
issue.tracker_id = 1
|
||||||
assert issue.custom_field_values.any?
|
assert issue.custom_field_values.any?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_assigning_attributes_should_assign_tracker_id_first
|
def test_assigning_attributes_should_assign_tracker_id_first
|
||||||
attributes = ActiveSupport::OrderedHash.new
|
attributes = ActiveSupport::OrderedHash.new
|
||||||
attributes['custom_field_values'] = { '1' => 'MySQL' }
|
attributes['custom_field_values'] = { '1' => 'MySQL' }
|
||||||
@ -181,35 +181,35 @@ class IssueTest < ActiveSupport::TestCase
|
|||||||
assert_not_nil issue.custom_value_for(1)
|
assert_not_nil issue.custom_value_for(1)
|
||||||
assert_equal 'MySQL', issue.custom_value_for(1).value
|
assert_equal 'MySQL', issue.custom_value_for(1).value
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_should_update_issue_with_disabled_tracker
|
def test_should_update_issue_with_disabled_tracker
|
||||||
p = Project.find(1)
|
p = Project.find(1)
|
||||||
issue = Issue.find(1)
|
issue = Issue.find(1)
|
||||||
|
|
||||||
p.trackers.delete(issue.tracker)
|
p.trackers.delete(issue.tracker)
|
||||||
assert !p.trackers.include?(issue.tracker)
|
assert !p.trackers.include?(issue.tracker)
|
||||||
|
|
||||||
issue.reload
|
issue.reload
|
||||||
issue.subject = 'New subject'
|
issue.subject = 'New subject'
|
||||||
assert issue.save
|
assert issue.save
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_should_not_set_a_disabled_tracker
|
def test_should_not_set_a_disabled_tracker
|
||||||
p = Project.find(1)
|
p = Project.find(1)
|
||||||
p.trackers.delete(Tracker.find(2))
|
p.trackers.delete(Tracker.find(2))
|
||||||
|
|
||||||
issue = Issue.find(1)
|
issue = Issue.find(1)
|
||||||
issue.tracker_id = 2
|
issue.tracker_id = 2
|
||||||
issue.subject = 'New subject'
|
issue.subject = 'New subject'
|
||||||
assert !issue.save
|
assert !issue.save
|
||||||
assert_not_nil issue.errors.on(:tracker_id)
|
assert_not_nil issue.errors.on(:tracker_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_category_based_assignment
|
def test_category_based_assignment
|
||||||
issue = Issue.create(:project_id => 1, :tracker_id => 1, :author_id => 3, :status_id => 1, :priority => IssuePriority.all.first, :subject => 'Assignment test', :description => 'Assignment test', :category_id => 1)
|
issue = Issue.create(:project_id => 1, :tracker_id => 1, :author_id => 3, :status_id => 1, :priority => IssuePriority.all.first, :subject => 'Assignment test', :description => 'Assignment test', :category_id => 1)
|
||||||
assert_equal IssueCategory.find(1).assigned_to, issue.assigned_to
|
assert_equal IssueCategory.find(1).assigned_to, issue.assigned_to
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_copy
|
def test_copy
|
||||||
issue = Issue.new.copy_from(1)
|
issue = Issue.new.copy_from(1)
|
||||||
assert issue.save
|
assert issue.save
|
||||||
@ -223,13 +223,13 @@ class IssueTest < ActiveSupport::TestCase
|
|||||||
def test_copy_should_copy_status
|
def test_copy_should_copy_status
|
||||||
orig = Issue.find(8)
|
orig = Issue.find(8)
|
||||||
assert orig.status != IssueStatus.default
|
assert orig.status != IssueStatus.default
|
||||||
|
|
||||||
issue = Issue.new.copy_from(orig)
|
issue = Issue.new.copy_from(orig)
|
||||||
assert issue.save
|
assert issue.save
|
||||||
issue.reload
|
issue.reload
|
||||||
assert_equal orig.status, issue.status
|
assert_equal orig.status, issue.status
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_should_close_duplicates
|
def test_should_close_duplicates
|
||||||
# Create 3 issues
|
# Create 3 issues
|
||||||
issue1 = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :priority => IssuePriority.all.first, :subject => 'Duplicates test', :description => 'Duplicates test')
|
issue1 = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :priority => IssuePriority.all.first, :subject => 'Duplicates test', :description => 'Duplicates test')
|
||||||
@ -238,37 +238,37 @@ class IssueTest < ActiveSupport::TestCase
|
|||||||
assert issue2.save
|
assert issue2.save
|
||||||
issue3 = issue1.clone
|
issue3 = issue1.clone
|
||||||
assert issue3.save
|
assert issue3.save
|
||||||
|
|
||||||
# 2 is a dupe of 1
|
# 2 is a dupe of 1
|
||||||
IssueRelation.create(:issue_from => issue2, :issue_to => issue1, :relation_type => IssueRelation::TYPE_DUPLICATES)
|
IssueRelation.create(:issue_from => issue2, :issue_to => issue1, :relation_type => IssueRelation::TYPE_DUPLICATES)
|
||||||
# And 3 is a dupe of 2
|
# And 3 is a dupe of 2
|
||||||
IssueRelation.create(:issue_from => issue3, :issue_to => issue2, :relation_type => IssueRelation::TYPE_DUPLICATES)
|
IssueRelation.create(:issue_from => issue3, :issue_to => issue2, :relation_type => IssueRelation::TYPE_DUPLICATES)
|
||||||
# And 3 is a dupe of 1 (circular duplicates)
|
# And 3 is a dupe of 1 (circular duplicates)
|
||||||
IssueRelation.create(:issue_from => issue3, :issue_to => issue1, :relation_type => IssueRelation::TYPE_DUPLICATES)
|
IssueRelation.create(:issue_from => issue3, :issue_to => issue1, :relation_type => IssueRelation::TYPE_DUPLICATES)
|
||||||
|
|
||||||
assert issue1.reload.duplicates.include?(issue2)
|
assert issue1.reload.duplicates.include?(issue2)
|
||||||
|
|
||||||
# Closing issue 1
|
# Closing issue 1
|
||||||
issue1.init_journal(User.find(:first), "Closing issue1")
|
issue1.init_journal(User.find(:first), "Closing issue1")
|
||||||
issue1.status = IssueStatus.find :first, :conditions => {:is_closed => true}
|
issue1.status = IssueStatus.find :first, :conditions => {:is_closed => true}
|
||||||
assert issue1.save
|
assert issue1.save
|
||||||
# 2 and 3 should be also closed
|
# 2 and 3 should be also closed
|
||||||
assert issue2.reload.closed?
|
assert issue2.reload.closed?
|
||||||
assert issue3.reload.closed?
|
assert issue3.reload.closed?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_should_not_close_duplicated_issue
|
def test_should_not_close_duplicated_issue
|
||||||
# Create 3 issues
|
# Create 3 issues
|
||||||
issue1 = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :priority => IssuePriority.all.first, :subject => 'Duplicates test', :description => 'Duplicates test')
|
issue1 = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :priority => IssuePriority.all.first, :subject => 'Duplicates test', :description => 'Duplicates test')
|
||||||
assert issue1.save
|
assert issue1.save
|
||||||
issue2 = issue1.clone
|
issue2 = issue1.clone
|
||||||
assert issue2.save
|
assert issue2.save
|
||||||
|
|
||||||
# 2 is a dupe of 1
|
# 2 is a dupe of 1
|
||||||
IssueRelation.create(:issue_from => issue2, :issue_to => issue1, :relation_type => IssueRelation::TYPE_DUPLICATES)
|
IssueRelation.create(:issue_from => issue2, :issue_to => issue1, :relation_type => IssueRelation::TYPE_DUPLICATES)
|
||||||
# 2 is a dup of 1 but 1 is not a duplicate of 2
|
# 2 is a dup of 1 but 1 is not a duplicate of 2
|
||||||
assert !issue2.reload.duplicates.include?(issue1)
|
assert !issue2.reload.duplicates.include?(issue1)
|
||||||
|
|
||||||
# Closing issue 2
|
# Closing issue 2
|
||||||
issue2.init_journal(User.find(:first), "Closing issue2")
|
issue2.init_journal(User.find(:first), "Closing issue2")
|
||||||
issue2.status = IssueStatus.find :first, :conditions => {:is_closed => true}
|
issue2.status = IssueStatus.find :first, :conditions => {:is_closed => true}
|
||||||
@ -276,57 +276,57 @@ class IssueTest < ActiveSupport::TestCase
|
|||||||
# 1 should not be also closed
|
# 1 should not be also closed
|
||||||
assert !issue1.reload.closed?
|
assert !issue1.reload.closed?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_assignable_versions
|
def test_assignable_versions
|
||||||
issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :fixed_version_id => 1, :subject => 'New issue')
|
issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :fixed_version_id => 1, :subject => 'New issue')
|
||||||
assert_equal ['open'], issue.assignable_versions.collect(&:status).uniq
|
assert_equal ['open'], issue.assignable_versions.collect(&:status).uniq
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_should_not_be_able_to_assign_a_new_issue_to_a_closed_version
|
def test_should_not_be_able_to_assign_a_new_issue_to_a_closed_version
|
||||||
issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :fixed_version_id => 1, :subject => 'New issue')
|
issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :fixed_version_id => 1, :subject => 'New issue')
|
||||||
assert !issue.save
|
assert !issue.save
|
||||||
assert_not_nil issue.errors.on(:fixed_version_id)
|
assert_not_nil issue.errors.on(:fixed_version_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_should_not_be_able_to_assign_a_new_issue_to_a_locked_version
|
def test_should_not_be_able_to_assign_a_new_issue_to_a_locked_version
|
||||||
issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :fixed_version_id => 2, :subject => 'New issue')
|
issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :fixed_version_id => 2, :subject => 'New issue')
|
||||||
assert !issue.save
|
assert !issue.save
|
||||||
assert_not_nil issue.errors.on(:fixed_version_id)
|
assert_not_nil issue.errors.on(:fixed_version_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_should_be_able_to_assign_a_new_issue_to_an_open_version
|
def test_should_be_able_to_assign_a_new_issue_to_an_open_version
|
||||||
issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :fixed_version_id => 3, :subject => 'New issue')
|
issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :fixed_version_id => 3, :subject => 'New issue')
|
||||||
assert issue.save
|
assert issue.save
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_should_be_able_to_update_an_issue_assigned_to_a_closed_version
|
def test_should_be_able_to_update_an_issue_assigned_to_a_closed_version
|
||||||
issue = Issue.find(11)
|
issue = Issue.find(11)
|
||||||
assert_equal 'closed', issue.fixed_version.status
|
assert_equal 'closed', issue.fixed_version.status
|
||||||
issue.subject = 'Subject changed'
|
issue.subject = 'Subject changed'
|
||||||
assert issue.save
|
assert issue.save
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_should_not_be_able_to_reopen_an_issue_assigned_to_a_closed_version
|
def test_should_not_be_able_to_reopen_an_issue_assigned_to_a_closed_version
|
||||||
issue = Issue.find(11)
|
issue = Issue.find(11)
|
||||||
issue.status_id = 1
|
issue.status_id = 1
|
||||||
assert !issue.save
|
assert !issue.save
|
||||||
assert_not_nil issue.errors.on_base
|
assert_not_nil issue.errors.on_base
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_should_be_able_to_reopen_and_reassign_an_issue_assigned_to_a_closed_version
|
def test_should_be_able_to_reopen_and_reassign_an_issue_assigned_to_a_closed_version
|
||||||
issue = Issue.find(11)
|
issue = Issue.find(11)
|
||||||
issue.status_id = 1
|
issue.status_id = 1
|
||||||
issue.fixed_version_id = 3
|
issue.fixed_version_id = 3
|
||||||
assert issue.save
|
assert issue.save
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_should_be_able_to_reopen_an_issue_assigned_to_a_locked_version
|
def test_should_be_able_to_reopen_an_issue_assigned_to_a_locked_version
|
||||||
issue = Issue.find(12)
|
issue = Issue.find(12)
|
||||||
assert_equal 'locked', issue.fixed_version.status
|
assert_equal 'locked', issue.fixed_version.status
|
||||||
issue.status_id = 1
|
issue.status_id = 1
|
||||||
assert issue.save
|
assert issue.save
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_move_to_another_project_with_same_category
|
def test_move_to_another_project_with_same_category
|
||||||
issue = Issue.find(1)
|
issue = Issue.find(1)
|
||||||
assert issue.move_to_project(Project.find(2))
|
assert issue.move_to_project(Project.find(2))
|
||||||
@ -337,7 +337,7 @@ class IssueTest < ActiveSupport::TestCase
|
|||||||
# Make sure time entries were move to the target project
|
# Make sure time entries were move to the target project
|
||||||
assert_equal 2, issue.time_entries.first.project_id
|
assert_equal 2, issue.time_entries.first.project_id
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_move_to_another_project_without_same_category
|
def test_move_to_another_project_without_same_category
|
||||||
issue = Issue.find(2)
|
issue = Issue.find(2)
|
||||||
assert issue.move_to_project(Project.find(2))
|
assert issue.move_to_project(Project.find(2))
|
||||||
@ -346,7 +346,7 @@ class IssueTest < ActiveSupport::TestCase
|
|||||||
# Category cleared
|
# Category cleared
|
||||||
assert_nil issue.category_id
|
assert_nil issue.category_id
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_move_to_another_project_should_clear_fixed_version_when_not_shared
|
def test_move_to_another_project_should_clear_fixed_version_when_not_shared
|
||||||
issue = Issue.find(1)
|
issue = Issue.find(1)
|
||||||
issue.update_attribute(:fixed_version_id, 1)
|
issue.update_attribute(:fixed_version_id, 1)
|
||||||
@ -356,7 +356,7 @@ class IssueTest < ActiveSupport::TestCase
|
|||||||
# Cleared fixed_version
|
# Cleared fixed_version
|
||||||
assert_equal nil, issue.fixed_version
|
assert_equal nil, issue.fixed_version
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_move_to_another_project_should_keep_fixed_version_when_shared_with_the_target_project
|
def test_move_to_another_project_should_keep_fixed_version_when_shared_with_the_target_project
|
||||||
issue = Issue.find(1)
|
issue = Issue.find(1)
|
||||||
issue.update_attribute(:fixed_version_id, 4)
|
issue.update_attribute(:fixed_version_id, 4)
|
||||||
@ -366,7 +366,7 @@ class IssueTest < ActiveSupport::TestCase
|
|||||||
# Keep fixed_version
|
# Keep fixed_version
|
||||||
assert_equal 4, issue.fixed_version_id
|
assert_equal 4, issue.fixed_version_id
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_move_to_another_project_should_clear_fixed_version_when_not_shared_with_the_target_project
|
def test_move_to_another_project_should_clear_fixed_version_when_not_shared_with_the_target_project
|
||||||
issue = Issue.find(1)
|
issue = Issue.find(1)
|
||||||
issue.update_attribute(:fixed_version_id, 1)
|
issue.update_attribute(:fixed_version_id, 1)
|
||||||
@ -376,7 +376,7 @@ class IssueTest < ActiveSupport::TestCase
|
|||||||
# Cleared fixed_version
|
# Cleared fixed_version
|
||||||
assert_equal nil, issue.fixed_version
|
assert_equal nil, issue.fixed_version
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_move_to_another_project_should_keep_fixed_version_when_shared_systemwide
|
def test_move_to_another_project_should_keep_fixed_version_when_shared_systemwide
|
||||||
issue = Issue.find(1)
|
issue = Issue.find(1)
|
||||||
issue.update_attribute(:fixed_version_id, 7)
|
issue.update_attribute(:fixed_version_id, 7)
|
||||||
@ -386,7 +386,7 @@ class IssueTest < ActiveSupport::TestCase
|
|||||||
# Keep fixed_version
|
# Keep fixed_version
|
||||||
assert_equal 7, issue.fixed_version_id
|
assert_equal 7, issue.fixed_version_id
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_move_to_another_project_with_disabled_tracker
|
def test_move_to_another_project_with_disabled_tracker
|
||||||
issue = Issue.find(1)
|
issue = Issue.find(1)
|
||||||
target = Project.find(2)
|
target = Project.find(2)
|
||||||
@ -396,7 +396,7 @@ class IssueTest < ActiveSupport::TestCase
|
|||||||
issue.reload
|
issue.reload
|
||||||
assert_equal 1, issue.project_id
|
assert_equal 1, issue.project_id
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_copy_to_the_same_project
|
def test_copy_to_the_same_project
|
||||||
issue = Issue.find(1)
|
issue = Issue.find(1)
|
||||||
copy = nil
|
copy = nil
|
||||||
@ -407,7 +407,7 @@ class IssueTest < ActiveSupport::TestCase
|
|||||||
assert_equal issue.project, copy.project
|
assert_equal issue.project, copy.project
|
||||||
assert_equal "125", copy.custom_value_for(2).value
|
assert_equal "125", copy.custom_value_for(2).value
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_copy_to_another_project_and_tracker
|
def test_copy_to_another_project_and_tracker
|
||||||
issue = Issue.find(1)
|
issue = Issue.find(1)
|
||||||
copy = nil
|
copy = nil
|
||||||
@ -453,7 +453,7 @@ class IssueTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_recipients_should_not_include_users_that_cannot_view_the_issue
|
def test_recipients_should_not_include_users_that_cannot_view_the_issue
|
||||||
issue = Issue.find(12)
|
issue = Issue.find(12)
|
||||||
assert issue.recipients.include?(issue.author.mail)
|
assert issue.recipients.include?(issue.author.mail)
|
||||||
@ -470,39 +470,39 @@ class IssueTest < ActiveSupport::TestCase
|
|||||||
assert issue.watched_by?(user)
|
assert issue.watched_by?(user)
|
||||||
assert !issue.watcher_recipients.include?(user.mail)
|
assert !issue.watcher_recipients.include?(user.mail)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_issue_destroy
|
def test_issue_destroy
|
||||||
Issue.find(1).destroy
|
Issue.find(1).destroy
|
||||||
assert_nil Issue.find_by_id(1)
|
assert_nil Issue.find_by_id(1)
|
||||||
assert_nil TimeEntry.find_by_issue_id(1)
|
assert_nil TimeEntry.find_by_issue_id(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_blocked
|
def test_blocked
|
||||||
blocked_issue = Issue.find(9)
|
blocked_issue = Issue.find(9)
|
||||||
blocking_issue = Issue.find(10)
|
blocking_issue = Issue.find(10)
|
||||||
|
|
||||||
assert blocked_issue.blocked?
|
assert blocked_issue.blocked?
|
||||||
assert !blocking_issue.blocked?
|
assert !blocking_issue.blocked?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_blocked_issues_dont_allow_closed_statuses
|
def test_blocked_issues_dont_allow_closed_statuses
|
||||||
blocked_issue = Issue.find(9)
|
blocked_issue = Issue.find(9)
|
||||||
|
|
||||||
allowed_statuses = blocked_issue.new_statuses_allowed_to(users(:users_002))
|
allowed_statuses = blocked_issue.new_statuses_allowed_to(users(:users_002))
|
||||||
assert !allowed_statuses.empty?
|
assert !allowed_statuses.empty?
|
||||||
closed_statuses = allowed_statuses.select {|st| st.is_closed?}
|
closed_statuses = allowed_statuses.select {|st| st.is_closed?}
|
||||||
assert closed_statuses.empty?
|
assert closed_statuses.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_unblocked_issues_allow_closed_statuses
|
def test_unblocked_issues_allow_closed_statuses
|
||||||
blocking_issue = Issue.find(10)
|
blocking_issue = Issue.find(10)
|
||||||
|
|
||||||
allowed_statuses = blocking_issue.new_statuses_allowed_to(users(:users_002))
|
allowed_statuses = blocking_issue.new_statuses_allowed_to(users(:users_002))
|
||||||
assert !allowed_statuses.empty?
|
assert !allowed_statuses.empty?
|
||||||
closed_statuses = allowed_statuses.select {|st| st.is_closed?}
|
closed_statuses = allowed_statuses.select {|st| st.is_closed?}
|
||||||
assert !closed_statuses.empty?
|
assert !closed_statuses.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_overdue
|
def test_overdue
|
||||||
assert Issue.new(:due_date => 1.day.ago.to_date).overdue?
|
assert Issue.new(:due_date => 1.day.ago.to_date).overdue?
|
||||||
assert !Issue.new(:due_date => Date.today).overdue?
|
assert !Issue.new(:due_date => Date.today).overdue?
|
||||||
@ -510,11 +510,11 @@ class IssueTest < ActiveSupport::TestCase
|
|||||||
assert !Issue.new(:due_date => nil).overdue?
|
assert !Issue.new(:due_date => nil).overdue?
|
||||||
assert !Issue.new(:due_date => 1.day.ago.to_date, :status => IssueStatus.find(:first, :conditions => {:is_closed => true})).overdue?
|
assert !Issue.new(:due_date => 1.day.ago.to_date, :status => IssueStatus.find(:first, :conditions => {:is_closed => true})).overdue?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_assignable_users
|
def test_assignable_users
|
||||||
assert_kind_of User, Issue.find(1).assignable_users.first
|
assert_kind_of User, Issue.find(1).assignable_users.first
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_create_should_send_email_notification
|
def test_create_should_send_email_notification
|
||||||
ActionMailer::Base.deliveries.clear
|
ActionMailer::Base.deliveries.clear
|
||||||
issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3, :status_id => 1, :priority => IssuePriority.all.first, :subject => 'test_create', :estimated_hours => '1:30')
|
issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3, :status_id => 1, :priority => IssuePriority.all.first, :subject => 'test_create', :estimated_hours => '1:30')
|
||||||
@ -522,18 +522,18 @@ class IssueTest < ActiveSupport::TestCase
|
|||||||
assert issue.save
|
assert issue.save
|
||||||
assert_equal 1, ActionMailer::Base.deliveries.size
|
assert_equal 1, ActionMailer::Base.deliveries.size
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_stale_issue_should_not_send_email_notification
|
def test_stale_issue_should_not_send_email_notification
|
||||||
ActionMailer::Base.deliveries.clear
|
ActionMailer::Base.deliveries.clear
|
||||||
issue = Issue.find(1)
|
issue = Issue.find(1)
|
||||||
stale = Issue.find(1)
|
stale = Issue.find(1)
|
||||||
|
|
||||||
issue.init_journal(User.find(1))
|
issue.init_journal(User.find(1))
|
||||||
issue.subject = 'Subjet update'
|
issue.subject = 'Subjet update'
|
||||||
assert issue.save
|
assert issue.save
|
||||||
assert_equal 1, ActionMailer::Base.deliveries.size
|
assert_equal 1, ActionMailer::Base.deliveries.size
|
||||||
ActionMailer::Base.deliveries.clear
|
ActionMailer::Base.deliveries.clear
|
||||||
|
|
||||||
stale.init_journal(User.find(1))
|
stale.init_journal(User.find(1))
|
||||||
stale.subject = 'Another subjet update'
|
stale.subject = 'Another subjet update'
|
||||||
assert_raise ActiveRecord::StaleObjectError do
|
assert_raise ActiveRecord::StaleObjectError do
|
||||||
@ -541,7 +541,7 @@ class IssueTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
assert ActionMailer::Base.deliveries.empty?
|
assert ActionMailer::Base.deliveries.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_saving_twice_should_not_duplicate_journal_details
|
def test_saving_twice_should_not_duplicate_journal_details
|
||||||
i = Issue.find(:first)
|
i = Issue.find(:first)
|
||||||
i.init_journal(User.find(2), 'Some notes')
|
i.init_journal(User.find(2), 'Some notes')
|
||||||
@ -551,18 +551,19 @@ class IssueTest < ActiveSupport::TestCase
|
|||||||
assert_difference 'Journal.count' do
|
assert_difference 'Journal.count' do
|
||||||
assert i.save
|
assert i.save
|
||||||
end
|
end
|
||||||
|
assert i.current_journal.changes.has_key? "subject"
|
||||||
|
assert i.current_journal.changes.has_key? "done_ratio"
|
||||||
|
|
||||||
# 1 more change
|
# 1 more change
|
||||||
i.priority = IssuePriority.find(:first, :conditions => ["id <> ?", i.priority_id])
|
i.priority = IssuePriority.find(:first, :conditions => ["id <> ?", i.priority_id])
|
||||||
assert_no_difference 'Journal.count' do
|
assert_difference 'Journal.count' do
|
||||||
assert_difference 'JournalDetail.count', 1 do
|
i.save
|
||||||
i.save
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
assert i.current_journal.changes.has_key? "priority_id"
|
||||||
|
|
||||||
# no more change
|
# no more change
|
||||||
assert_no_difference 'Journal.count' do
|
assert_no_difference 'Journal.count' do
|
||||||
assert_no_difference 'JournalDetail.count' do
|
i.save
|
||||||
i.save
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -572,12 +573,12 @@ class IssueTest < ActiveSupport::TestCase
|
|||||||
@issue_status = IssueStatus.find(1)
|
@issue_status = IssueStatus.find(1)
|
||||||
@issue_status.update_attribute(:default_done_ratio, 50)
|
@issue_status.update_attribute(:default_done_ratio, 50)
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with Setting.issue_done_ratio using the issue_field" do
|
context "with Setting.issue_done_ratio using the issue_field" do
|
||||||
setup do
|
setup do
|
||||||
Setting.issue_done_ratio = 'issue_field'
|
Setting.issue_done_ratio = 'issue_field'
|
||||||
end
|
end
|
||||||
|
|
||||||
should "read the issue's field" do
|
should "read the issue's field" do
|
||||||
assert_equal 0, @issue.done_ratio
|
assert_equal 0, @issue.done_ratio
|
||||||
end
|
end
|
||||||
@ -587,7 +588,7 @@ class IssueTest < ActiveSupport::TestCase
|
|||||||
setup do
|
setup do
|
||||||
Setting.issue_done_ratio = 'issue_status'
|
Setting.issue_done_ratio = 'issue_status'
|
||||||
end
|
end
|
||||||
|
|
||||||
should "read the Issue Status's default done ratio" do
|
should "read the Issue Status's default done ratio" do
|
||||||
assert_equal 50, @issue.done_ratio
|
assert_equal 50, @issue.done_ratio
|
||||||
end
|
end
|
||||||
@ -600,12 +601,12 @@ class IssueTest < ActiveSupport::TestCase
|
|||||||
@issue_status = IssueStatus.find(1)
|
@issue_status = IssueStatus.find(1)
|
||||||
@issue_status.update_attribute(:default_done_ratio, 50)
|
@issue_status.update_attribute(:default_done_ratio, 50)
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with Setting.issue_done_ratio using the issue_field" do
|
context "with Setting.issue_done_ratio using the issue_field" do
|
||||||
setup do
|
setup do
|
||||||
Setting.issue_done_ratio = 'issue_field'
|
Setting.issue_done_ratio = 'issue_field'
|
||||||
end
|
end
|
||||||
|
|
||||||
should "not change the issue" do
|
should "not change the issue" do
|
||||||
@issue.update_done_ratio_from_issue_status
|
@issue.update_done_ratio_from_issue_status
|
||||||
|
|
||||||
@ -617,7 +618,7 @@ class IssueTest < ActiveSupport::TestCase
|
|||||||
setup do
|
setup do
|
||||||
Setting.issue_done_ratio = 'issue_status'
|
Setting.issue_done_ratio = 'issue_status'
|
||||||
end
|
end
|
||||||
|
|
||||||
should "not change the issue's done ratio" do
|
should "not change the issue's done ratio" do
|
||||||
@issue.update_done_ratio_from_issue_status
|
@issue.update_done_ratio_from_issue_status
|
||||||
|
|
||||||
@ -667,19 +668,19 @@ class IssueTest < ActiveSupport::TestCase
|
|||||||
assert_equal 2, groups.size
|
assert_equal 2, groups.size
|
||||||
assert_equal 5, groups.inject(0) {|sum, group| sum + group['total'].to_i}
|
assert_equal 5, groups.inject(0) {|sum, group| sum + group['total'].to_i}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
context ".allowed_target_projects_on_move" do
|
context ".allowed_target_projects_on_move" do
|
||||||
should "return all active projects for admin users" do
|
should "return all active projects for admin users" do
|
||||||
User.current = User.find(1)
|
User.current = User.find(1)
|
||||||
assert_equal Project.active.count, Issue.allowed_target_projects_on_move.size
|
assert_equal Project.active.count, Issue.allowed_target_projects_on_move.size
|
||||||
end
|
end
|
||||||
|
|
||||||
should "return allowed projects for non admin users" do
|
should "return allowed projects for non admin users" do
|
||||||
User.current = User.find(2)
|
User.current = User.find(2)
|
||||||
Role.non_member.remove_permission! :move_issues
|
Role.non_member.remove_permission! :move_issues
|
||||||
assert_equal 3, Issue.allowed_target_projects_on_move.size
|
assert_equal 3, Issue.allowed_target_projects_on_move.size
|
||||||
|
|
||||||
Role.non_member.add_permission! :move_issues
|
Role.non_member.add_permission! :move_issues
|
||||||
assert_equal Project.active.count, Issue.allowed_target_projects_on_move.size
|
assert_equal Project.active.count, Issue.allowed_target_projects_on_move.size
|
||||||
end
|
end
|
||||||
@ -693,7 +694,7 @@ class IssueTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
def test_on_active_projects_scope
|
def test_on_active_projects_scope
|
||||||
assert Project.find(2).archive
|
assert Project.find(2).archive
|
||||||
|
|
||||||
before = Issue.on_active_project.length
|
before = Issue.on_active_project.length
|
||||||
# test inclusion to results
|
# test inclusion to results
|
||||||
issue = Issue.generate_for_project!(Project.find(1), :tracker => Project.find(2).trackers.first)
|
issue = Issue.generate_for_project!(Project.find(1), :tracker => Project.find(2).trackers.first)
|
||||||
|
@ -18,14 +18,14 @@
|
|||||||
require File.dirname(__FILE__) + '/../test_helper'
|
require File.dirname(__FILE__) + '/../test_helper'
|
||||||
|
|
||||||
class JournalTest < ActiveSupport::TestCase
|
class JournalTest < ActiveSupport::TestCase
|
||||||
fixtures :issues, :issue_statuses, :journals, :journal_details
|
fixtures :issues, :issue_statuses, :journals
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@journal = Journal.find 1
|
@journal = IssueJournal.first
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_journalized_is_an_issue
|
def test_journalized_is_an_issue
|
||||||
issue = @journal.issue
|
issue = @journal.journalized
|
||||||
assert_kind_of Issue, issue
|
assert_kind_of Issue, issue
|
||||||
assert_equal 1, issue.id
|
assert_equal 1, issue.id
|
||||||
end
|
end
|
||||||
@ -34,16 +34,16 @@ class JournalTest < ActiveSupport::TestCase
|
|||||||
status = @journal.new_status
|
status = @journal.new_status
|
||||||
assert_not_nil status
|
assert_not_nil status
|
||||||
assert_kind_of IssueStatus, status
|
assert_kind_of IssueStatus, status
|
||||||
assert_equal 2, status.id
|
assert_equal 2, status.id
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_create_should_send_email_notification
|
def test_create_should_send_email_notification
|
||||||
ActionMailer::Base.deliveries.clear
|
ActionMailer::Base.deliveries.clear
|
||||||
issue = Issue.find(:first)
|
issue = Issue.find(:first)
|
||||||
user = User.find(:first)
|
user = User.find(:first)
|
||||||
journal = issue.init_journal(user, issue)
|
|
||||||
|
|
||||||
assert journal.save
|
assert_equal 0, ActionMailer::Base.deliveries.size
|
||||||
|
issue.update_attribute(:subject, "New subject to trigger automatic journal entry")
|
||||||
assert_equal 1, ActionMailer::Base.deliveries.size
|
assert_equal 1, ActionMailer::Base.deliveries.size
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -259,7 +259,7 @@ class MailHandlerTest < ActiveSupport::TestCase
|
|||||||
# This email contains: 'Status: Resolved'
|
# This email contains: 'Status: Resolved'
|
||||||
journal = submit_email('ticket_reply_with_status.eml')
|
journal = submit_email('ticket_reply_with_status.eml')
|
||||||
assert journal.is_a?(Journal)
|
assert journal.is_a?(Journal)
|
||||||
issue = Issue.find(journal.issue.id)
|
issue = Issue.find(journal.journalized.id)
|
||||||
assert_equal User.find_by_login('jsmith'), journal.user
|
assert_equal User.find_by_login('jsmith'), journal.user
|
||||||
assert_equal Issue.find(2), journal.journalized
|
assert_equal Issue.find(2), journal.journalized
|
||||||
assert_match /This is reply/, journal.notes
|
assert_match /This is reply/, journal.notes
|
||||||
|
@ -20,8 +20,8 @@ require File.dirname(__FILE__) + '/../test_helper'
|
|||||||
class MailerTest < ActiveSupport::TestCase
|
class MailerTest < ActiveSupport::TestCase
|
||||||
include Redmine::I18n
|
include Redmine::I18n
|
||||||
include ActionController::Assertions::SelectorAssertions
|
include ActionController::Assertions::SelectorAssertions
|
||||||
fixtures :projects, :enabled_modules, :issues, :users, :members, :member_roles, :roles, :documents, :attachments, :news, :tokens, :journals, :journal_details, :changesets, :trackers, :issue_statuses, :enumerations, :messages, :boards, :repositories
|
fixtures :projects, :enabled_modules, :issues, :users, :members, :member_roles, :roles, :documents, :attachments, :news, :tokens, :journals, :changesets, :trackers, :issue_statuses, :enumerations, :messages, :boards, :repositories
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
ActionMailer::Base.deliveries.clear
|
ActionMailer::Base.deliveries.clear
|
||||||
Setting.host_name = 'mydomain.foo'
|
Setting.host_name = 'mydomain.foo'
|
||||||
|
@ -27,7 +27,6 @@ class SearchTest < ActiveSupport::TestCase
|
|||||||
:issues,
|
:issues,
|
||||||
:trackers,
|
:trackers,
|
||||||
:journals,
|
:journals,
|
||||||
:journal_details,
|
|
||||||
:repositories,
|
:repositories,
|
||||||
:changesets
|
:changesets
|
||||||
|
|
||||||
|
@ -5,12 +5,12 @@
|
|||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
@ -18,19 +18,19 @@
|
|||||||
require File.dirname(__FILE__) + '/../test_helper'
|
require File.dirname(__FILE__) + '/../test_helper'
|
||||||
|
|
||||||
class WikiContentTest < ActiveSupport::TestCase
|
class WikiContentTest < ActiveSupport::TestCase
|
||||||
fixtures :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions, :users
|
fixtures :wikis, :wiki_pages, :wiki_contents, :journals, :users
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@wiki = Wiki.find(1)
|
@wiki = Wiki.find(1)
|
||||||
@page = @wiki.pages.first
|
@page = @wiki.pages.first
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_create
|
def test_create
|
||||||
page = WikiPage.new(:wiki => @wiki, :title => "Page")
|
page = WikiPage.new(:wiki => @wiki, :title => "Page")
|
||||||
page.content = WikiContent.new(:text => "Content text", :author => User.find(1), :comments => "My comment")
|
page.content = WikiContent.new(:text => "Content text", :author => User.find(1), :comments => "My comment")
|
||||||
assert page.save
|
assert page.save
|
||||||
page.reload
|
page.reload
|
||||||
|
|
||||||
content = page.content
|
content = page.content
|
||||||
assert_kind_of WikiContent, content
|
assert_kind_of WikiContent, content
|
||||||
assert_equal 1, content.version
|
assert_equal 1, content.version
|
||||||
@ -40,14 +40,14 @@ class WikiContentTest < ActiveSupport::TestCase
|
|||||||
assert_equal User.find(1), content.author
|
assert_equal User.find(1), content.author
|
||||||
assert_equal content.text, content.versions.last.text
|
assert_equal content.text, content.versions.last.text
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_create_should_send_email_notification
|
def test_create_should_send_email_notification
|
||||||
Setting.notified_events = ['wiki_content_added']
|
Setting.notified_events = ['wiki_content_added']
|
||||||
ActionMailer::Base.deliveries.clear
|
ActionMailer::Base.deliveries.clear
|
||||||
page = WikiPage.new(:wiki => @wiki, :title => "A new page")
|
page = WikiPage.new(:wiki => @wiki, :title => "A new page")
|
||||||
page.content = WikiContent.new(:text => "Content text", :author => User.find(1), :comments => "My comment")
|
page.content = WikiContent.new(:text => "Content text", :author => User.find(1), :comments => "My comment")
|
||||||
assert page.save
|
assert page.save
|
||||||
|
|
||||||
assert_equal 1, ActionMailer::Base.deliveries.size
|
assert_equal 1, ActionMailer::Base.deliveries.size
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -60,26 +60,26 @@ class WikiContentTest < ActiveSupport::TestCase
|
|||||||
assert_equal version_count+1, content.version
|
assert_equal version_count+1, content.version
|
||||||
assert_equal version_count+1, content.versions.length
|
assert_equal version_count+1, content.versions.length
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_update_should_send_email_notification
|
def test_update_should_send_email_notification
|
||||||
Setting.notified_events = ['wiki_content_updated']
|
Setting.notified_events = ['wiki_content_updated']
|
||||||
ActionMailer::Base.deliveries.clear
|
ActionMailer::Base.deliveries.clear
|
||||||
content = @page.content
|
content = @page.content
|
||||||
content.text = "My new content"
|
content.text = "My new content"
|
||||||
assert content.save
|
assert content.save
|
||||||
|
|
||||||
assert_equal 1, ActionMailer::Base.deliveries.size
|
assert_equal 1, ActionMailer::Base.deliveries.size
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_fetch_history
|
def test_fetch_history
|
||||||
assert !@page.content.versions.empty?
|
assert !@page.content.versions.empty?
|
||||||
@page.content.versions.each do |version|
|
@page.content.versions.each do |version|
|
||||||
assert_kind_of String, version.text
|
assert_kind_of String, version.text
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_large_text_should_not_be_truncated_to_64k
|
def test_large_text_should_not_be_truncated_to_64k
|
||||||
page = WikiPage.new(:wiki => @wiki, :title => "Big page")
|
page = WikiPage.new(:wiki => @wiki, :title => "Big page")
|
||||||
page.content = WikiContent.new(:text => "a" * 500.kilobyte, :author => User.find(1))
|
page.content = WikiContent.new(:text => "a" * 500.kilobyte, :author => User.find(1))
|
||||||
assert page.save
|
assert page.save
|
||||||
page.reload
|
page.reload
|
||||||
|
@ -5,12 +5,12 @@
|
|||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
@ -18,51 +18,51 @@
|
|||||||
require File.dirname(__FILE__) + '/../test_helper'
|
require File.dirname(__FILE__) + '/../test_helper'
|
||||||
|
|
||||||
class WikiPageTest < ActiveSupport::TestCase
|
class WikiPageTest < ActiveSupport::TestCase
|
||||||
fixtures :projects, :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions
|
fixtures :projects, :wikis, :wiki_pages, :wiki_contents, :journals
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@wiki = Wiki.find(1)
|
@wiki = Wiki.find(1)
|
||||||
@page = @wiki.pages.first
|
@page = @wiki.pages.first
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_create
|
def test_create
|
||||||
page = WikiPage.new(:wiki => @wiki)
|
page = WikiPage.new(:wiki => @wiki)
|
||||||
assert !page.save
|
assert !page.save
|
||||||
assert_equal 1, page.errors.count
|
assert_equal 1, page.errors.count
|
||||||
|
|
||||||
page.title = "Page"
|
page.title = "Page"
|
||||||
assert page.save
|
assert page.save
|
||||||
page.reload
|
page.reload
|
||||||
assert !page.protected?
|
assert !page.protected?
|
||||||
|
|
||||||
@wiki.reload
|
@wiki.reload
|
||||||
assert @wiki.pages.include?(page)
|
assert @wiki.pages.include?(page)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_sidebar_should_be_protected_by_default
|
def test_sidebar_should_be_protected_by_default
|
||||||
page = @wiki.find_or_new_page('sidebar')
|
page = @wiki.find_or_new_page('sidebar')
|
||||||
assert page.new_record?
|
assert page.new_record?
|
||||||
assert page.protected?
|
assert page.protected?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_find_or_new_page
|
def test_find_or_new_page
|
||||||
page = @wiki.find_or_new_page("CookBook documentation")
|
page = @wiki.find_or_new_page("CookBook documentation")
|
||||||
assert_kind_of WikiPage, page
|
assert_kind_of WikiPage, page
|
||||||
assert !page.new_record?
|
assert !page.new_record?
|
||||||
|
|
||||||
page = @wiki.find_or_new_page("Non existing page")
|
page = @wiki.find_or_new_page("Non existing page")
|
||||||
assert_kind_of WikiPage, page
|
assert_kind_of WikiPage, page
|
||||||
assert page.new_record?
|
assert page.new_record?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_parent_title
|
def test_parent_title
|
||||||
page = WikiPage.find_by_title('Another_page')
|
page = WikiPage.find_by_title('Another_page')
|
||||||
assert_nil page.parent_title
|
assert_nil page.parent_title
|
||||||
|
|
||||||
page = WikiPage.find_by_title('Page_with_an_inline_image')
|
page = WikiPage.find_by_title('Page_with_an_inline_image')
|
||||||
assert_equal 'CookBook documentation', page.parent_title
|
assert_equal 'CookBook documentation', page.parent_title
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_assign_parent
|
def test_assign_parent
|
||||||
page = WikiPage.find_by_title('Another_page')
|
page = WikiPage.find_by_title('Another_page')
|
||||||
page.parent_title = 'CookBook documentation'
|
page.parent_title = 'CookBook documentation'
|
||||||
@ -70,7 +70,7 @@ class WikiPageTest < ActiveSupport::TestCase
|
|||||||
page.reload
|
page.reload
|
||||||
assert_equal WikiPage.find_by_title('CookBook_documentation'), page.parent
|
assert_equal WikiPage.find_by_title('CookBook_documentation'), page.parent
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_unassign_parent
|
def test_unassign_parent
|
||||||
page = WikiPage.find_by_title('Page_with_an_inline_image')
|
page = WikiPage.find_by_title('Page_with_an_inline_image')
|
||||||
page.parent_title = ''
|
page.parent_title = ''
|
||||||
@ -78,10 +78,10 @@ class WikiPageTest < ActiveSupport::TestCase
|
|||||||
page.reload
|
page.reload
|
||||||
assert_nil page.parent
|
assert_nil page.parent
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_parent_validation
|
def test_parent_validation
|
||||||
page = WikiPage.find_by_title('CookBook_documentation')
|
page = WikiPage.find_by_title('CookBook_documentation')
|
||||||
|
|
||||||
# A page that doesn't exist
|
# A page that doesn't exist
|
||||||
page.parent_title = 'Unknown title'
|
page.parent_title = 'Unknown title'
|
||||||
assert !page.save
|
assert !page.save
|
||||||
@ -98,23 +98,26 @@ class WikiPageTest < ActiveSupport::TestCase
|
|||||||
page.parent_title = 'Another_page'
|
page.parent_title = 'Another_page'
|
||||||
assert page.save
|
assert page.save
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_destroy
|
def test_destroy
|
||||||
page = WikiPage.find(1)
|
page = WikiPage.find(1)
|
||||||
|
content_ids = WikiContent.find_all_by_page_id(1).collect(&:id)
|
||||||
page.destroy
|
page.destroy
|
||||||
assert_nil WikiPage.find_by_id(1)
|
assert_nil WikiPage.find_by_id(1)
|
||||||
# make sure that page content and its history are deleted
|
# make sure that page content and its history are deleted
|
||||||
assert WikiContent.find_all_by_page_id(1).empty?
|
assert WikiContent.find_all_by_page_id(1).empty?
|
||||||
assert WikiContent.versioned_class.find_all_by_page_id(1).empty?
|
content_ids.each do |wiki_content_id|
|
||||||
|
assert WikiContent.journal_class.find_all_by_versioned_id(wiki_content_id).empty?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_destroy_should_not_nullify_children
|
def test_destroy_should_not_nullify_children
|
||||||
page = WikiPage.find(2)
|
page = WikiPage.find(2)
|
||||||
child_ids = page.child_ids
|
child_ids = page.child_ids
|
||||||
assert child_ids.any?
|
assert child_ids.any?
|
||||||
page.destroy
|
page.destroy
|
||||||
assert_nil WikiPage.find_by_id(2)
|
assert_nil WikiPage.find_by_id(2)
|
||||||
|
|
||||||
children = WikiPage.find_all_by_id(child_ids)
|
children = WikiPage.find_all_by_id(child_ids)
|
||||||
assert_equal child_ids.size, children.size
|
assert_equal child_ids.size, children.size
|
||||||
children.each do |child|
|
children.each do |child|
|
||||||
|
@ -7,12 +7,12 @@
|
|||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
@ -20,13 +20,13 @@
|
|||||||
require File.dirname(__FILE__) + '/../test_helper'
|
require File.dirname(__FILE__) + '/../test_helper'
|
||||||
|
|
||||||
class WikiTest < ActiveSupport::TestCase
|
class WikiTest < ActiveSupport::TestCase
|
||||||
fixtures :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions
|
fixtures :wikis, :wiki_pages, :wiki_contents, :journals
|
||||||
|
|
||||||
def test_create
|
def test_create
|
||||||
wiki = Wiki.new(:project => Project.find(2))
|
wiki = Wiki.new(:project => Project.find(2))
|
||||||
assert !wiki.save
|
assert !wiki.save
|
||||||
assert_equal 1, wiki.errors.count
|
assert_equal 1, wiki.errors.count
|
||||||
|
|
||||||
wiki.start_page = "Start page"
|
wiki.start_page = "Start page"
|
||||||
assert wiki.save
|
assert wiki.save
|
||||||
end
|
end
|
||||||
@ -38,26 +38,26 @@ class WikiTest < ActiveSupport::TestCase
|
|||||||
@wiki.reload
|
@wiki.reload
|
||||||
assert_equal "Another start page", @wiki.start_page
|
assert_equal "Another start page", @wiki.start_page
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_titleize
|
def test_titleize
|
||||||
assert_equal 'Page_title_with_CAPITALES', Wiki.titleize('page title with CAPITALES')
|
assert_equal 'Page_title_with_CAPITALES', Wiki.titleize('page title with CAPITALES')
|
||||||
assert_equal 'テスト', Wiki.titleize('テスト')
|
assert_equal 'テスト', Wiki.titleize('テスト')
|
||||||
end
|
end
|
||||||
|
|
||||||
context "#sidebar" do
|
context "#sidebar" do
|
||||||
setup do
|
setup do
|
||||||
@wiki = Wiki.find(1)
|
@wiki = Wiki.find(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "return nil if undefined" do
|
should "return nil if undefined" do
|
||||||
assert_nil @wiki.sidebar
|
assert_nil @wiki.sidebar
|
||||||
end
|
end
|
||||||
|
|
||||||
should "return a WikiPage if defined" do
|
should "return a WikiPage if defined" do
|
||||||
page = @wiki.pages.new(:title => 'Sidebar')
|
page = @wiki.pages.new(:title => 'Sidebar')
|
||||||
page.content = WikiContent.new(:text => 'Side bar content for test_show_with_sidebar')
|
page.content = WikiContent.new(:text => 'Side bar content for test_show_with_sidebar')
|
||||||
page.save!
|
page.save!
|
||||||
|
|
||||||
assert_kind_of WikiPage, @wiki.sidebar
|
assert_kind_of WikiPage, @wiki.sidebar
|
||||||
assert_equal 'Sidebar', @wiki.sidebar.title
|
assert_equal 'Sidebar', @wiki.sidebar.title
|
||||||
end
|
end
|
||||||
|
@ -68,11 +68,11 @@ module Redmine
|
|||||||
scope_options[:conditions] = cond.conditions
|
scope_options[:conditions] = cond.conditions
|
||||||
if options[:limit]
|
if options[:limit]
|
||||||
# id and creation time should be in same order in most cases
|
# id and creation time should be in same order in most cases
|
||||||
scope_options[:order] = "#{table_name}.id DESC"
|
scope_options[:order] = "#{journal_class.table_name}.id DESC"
|
||||||
scope_options[:limit] = options[:limit]
|
scope_options[:limit] = options[:limit]
|
||||||
end
|
end
|
||||||
|
|
||||||
with_scope(:find => scope_options) do
|
journal_class.with_scope(:find => scope_options) do
|
||||||
journal_class.find(:all, provider_options[:find_options].dup)
|
journal_class.find(:all, provider_options[:find_options].dup)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user