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
Expand all
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
This diff is collapsed.
Click to expand it.
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
This diff is collapsed.
Click to expand it.
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