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
0fd499af
Commit
0fd499af
authored
Feb 06, 2012
by
Holger Just
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into unstable
parents
aa3ab990
43afcde3
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
93 additions
and
5 deletions
+93
-5
Gemfile
Gemfile
+1
-1
attachment.rb
app/models/attachment.rb
+2
-1
message.rb
app/models/message.rb
+2
-1
20120131142400_remove_noisy_attachment_journals.rb
...igrate/20120131142400_remove_noisy_attachment_journals.rb
+30
-0
20120131142401_remove_noisy_message_journals.rb
db/migrate/20120131142401_remove_noisy_message_journals.rb
+32
-0
attachment_test.rb
test/unit/attachment_test.rb
+21
-1
message_test.rb
test/unit/message_test.rb
+5
-1
No files found.
Gemfile
View file @
0fd499af
...
...
@@ -35,7 +35,7 @@ group :rmagick do
# the line above this comment block and uncomment the one underneath it to
# get an rmagick version known to work on older distributions.
#
# The following distribut
í
ons are known to *not* ship with a usable
# The following distribut
i
ons are known to *not* ship with a usable
# ImageMagick version. There might be additional ones.
# * Ubuntu 9.10 and older
# * Debian Lenny 5.0 and older
...
...
app/models/attachment.rb
View file @
0fd499af
...
...
@@ -34,7 +34,8 @@ class Attachment < ActiveRecord::Base
end
),
:activity_type
=>
'files'
,
:activity_permission
=>
:view_files
,
:activity_find_options
=>
{
:include
=>
{
:version
=>
:project
}
}
:activity_find_options
=>
{
:include
=>
{
:version
=>
:project
}
},
:except
=>
[
:downloads
]
acts_as_activity
:type
=>
'documents'
,
:permission
=>
:view_documents
,
:find_options
=>
{
:include
=>
{
:document
=>
:project
}
}
...
...
app/models/message.rb
View file @
0fd499af
...
...
@@ -30,7 +30,8 @@ class Message < ActiveRecord::Base
{
:id
=>
msg
.
parent_id
,
:r
=>
msg
.
id
,
:anchor
=>
"message-
#{
msg
.
id
}
"
}
end
.
reverse_merge
:controller
=>
'messages'
,
:action
=>
'show'
,
:board_id
=>
msg
.
board_id
end
),
:activity_find_options
=>
{
:include
=>
{
:board
=>
:project
}
}
:activity_find_options
=>
{
:include
=>
{
:board
=>
:project
}
},
:except
=>
[
:last_reply_id
,
:replies_count
]
acts_as_searchable
:columns
=>
[
'subject'
,
'content'
],
:include
=>
{
:board
=>
:project
},
...
...
db/migrate/20120131142400_remove_noisy_attachment_journals.rb
0 → 100644
View file @
0fd499af
#-- encoding: UTF-8
#-- copyright
# ChiliProject is a project management system.
#
# Copyright (C) 2010-2012 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# 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.
#
# See doc/COPYRIGHT.rdoc for more details.
#++
class
RemoveNoisyAttachmentJournals
<
ActiveRecord
::
Migration
def
self
.
up
AttachmentJournal
.
find_each
(
:batch_size
=>
100
)
do
|
j
|
if
j
.
changes
.
keys
==
[
"downloads"
]
j
.
destroy
elsif
j
.
changes
.
keys
.
include?
"downloads"
j
.
changes
.
delete
(
"downloads"
)
j
.
save!
end
end
end
def
self
.
down
# no-op as the downloads counter shouldn't be journaled in the first time
end
end
db/migrate/20120131142401_remove_noisy_message_journals.rb
0 → 100644
View file @
0fd499af
#-- encoding: UTF-8
#-- copyright
# ChiliProject is a project management system.
#
# Copyright (C) 2010-2012 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# 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.
#
# See doc/COPYRIGHT.rdoc for more details.
#++
class
RemoveNoisyMessageJournals
<
ActiveRecord
::
Migration
def
self
.
up
noisy_keys
=
%w[last_reply_id replies_count]
MessageJournal
.
find_each
(
:batch_size
=>
100
)
do
|
j
|
if
(
j
.
changes
.
keys
|
noisy_keys
).
sort
==
noisy_keys
j
.
destroy
elsif
(
j
.
changes
.
keys
&
noisy_keys
).
count
>
0
noisy_keys
.
each
{
|
k
|
j
.
changes
.
delete
(
k
)
}
j
.
save!
end
end
end
def
self
.
down
# no-op as the pointers shouldn't be journaled in the first time
end
end
test/unit/attachment_test.rb
View file @
0fd499af
...
...
@@ -14,7 +14,7 @@
require
File
.
expand_path
(
'../../test_helper'
,
__FILE__
)
class
AttachmentTest
<
ActiveSupport
::
TestCase
fixtures
:issues
,
:
us
ers
fixtures
:issues
,
:
projects
,
:users
,
:issue_statuses
,
:trackers
,
:projects_track
ers
def
setup
end
...
...
@@ -76,4 +76,24 @@ class AttachmentTest < ActiveSupport::TestCase
end
end
end
context
"Attachment#increment_download"
do
should
"not create a journal entry"
do
issue
=
Issue
.
generate!
(
:status_id
=>
1
,
:tracker_id
=>
1
,
:project_id
=>
1
)
attachment
=
Attachment
.
create!
(
:container
=>
issue
,
:file
=>
mock_file
,
:author
=>
User
.
find
(
1
))
assert_equal
0
,
attachment
.
downloads
# just the initial journal
assert_equal
1
,
attachment
.
journals
.
count
attachment
.
reload
attachment
.
increment_download
assert_equal
1
,
attachment
.
downloads
# no added journal
assert_equal
1
,
attachment
.
journals
.
count
end
end
end
test/unit/message_test.rb
View file @
0fd499af
...
...
@@ -43,22 +43,27 @@ class MessageTest < ActiveSupport::TestCase
messages_count
=
@board
.
messages_count
@message
=
Message
.
find
(
1
)
replies_count
=
@message
.
replies_count
journals_count
=
@message
.
journals
.
count
reply_author
=
User
.
find
(
2
)
reply
=
Message
.
new
(
:board
=>
@board
,
:subject
=>
'Test reply'
,
:content
=>
'Test reply content'
,
:parent
=>
@message
,
:author
=>
reply_author
)
assert
reply
.
save
@board
.
reload
# same topics count
assert_equal
topics_count
,
@board
[
:topics_count
]
# messages count incremented
assert_equal
messages_count
+
1
,
@board
[
:messages_count
]
assert_equal
reply
,
@board
.
last_message
@message
.
reload
# replies count incremented
assert_equal
replies_count
+
1
,
@message
[
:replies_count
]
assert_equal
reply
,
@message
.
last_reply
# author should be watching the message
assert
@message
.
watched_by?
(
reply_author
)
# journal count should be unchanged
assert_equal
journals_count
,
@message
.
journals
.
count
end
def
test_moving_message_should_update_counters
...
...
@@ -146,6 +151,5 @@ class MessageTest < ActiveSupport::TestCase
message
=
Message
.
new
(
:board
=>
@board
,
:subject
=>
'Test message'
,
:content
=>
'Test message content'
,
:author
=>
@user
)
assert
message
.
save
end
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