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