Merge branch 'master' into unstable
This commit is contained in:
commit
0fd499afca
2
Gemfile
2
Gemfile
@ -35,7 +35,7 @@ group :rmagick do
|
|||||||
# the line above this comment block and uncomment the one underneath it to
|
# the line above this comment block and uncomment the one underneath it to
|
||||||
# get an rmagick version known to work on older distributions.
|
# get an rmagick version known to work on older distributions.
|
||||||
#
|
#
|
||||||
# The following distributíons are known to *not* ship with a usable
|
# The following distributions are known to *not* ship with a usable
|
||||||
# ImageMagick version. There might be additional ones.
|
# ImageMagick version. There might be additional ones.
|
||||||
# * Ubuntu 9.10 and older
|
# * Ubuntu 9.10 and older
|
||||||
# * Debian Lenny 5.0 and older
|
# * Debian Lenny 5.0 and older
|
||||||
|
@ -34,7 +34,8 @@ class Attachment < ActiveRecord::Base
|
|||||||
end),
|
end),
|
||||||
:activity_type => 'files',
|
:activity_type => 'files',
|
||||||
:activity_permission => :view_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,
|
acts_as_activity :type => 'documents', :permission => :view_documents,
|
||||||
:find_options => { :include => { :document => :project } }
|
:find_options => { :include => { :document => :project } }
|
||||||
|
@ -30,7 +30,8 @@ class Message < ActiveRecord::Base
|
|||||||
{:id => msg.parent_id, :r => msg.id, :anchor => "message-#{msg.id}"}
|
{:id => msg.parent_id, :r => msg.id, :anchor => "message-#{msg.id}"}
|
||||||
end.reverse_merge :controller => 'messages', :action => 'show', :board_id => msg.board_id
|
end.reverse_merge :controller => 'messages', :action => 'show', :board_id => msg.board_id
|
||||||
end),
|
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'],
|
acts_as_searchable :columns => ['subject', 'content'],
|
||||||
:include => {:board => :project},
|
:include => {:board => :project},
|
||||||
|
@ -0,0 +1,30 @@
|
|||||||
|
#-- 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
|
32
db/migrate/20120131142401_remove_noisy_message_journals.rb
Normal file
32
db/migrate/20120131142401_remove_noisy_message_journals.rb
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#-- 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
|
@ -14,7 +14,7 @@
|
|||||||
require File.expand_path('../../test_helper', __FILE__)
|
require File.expand_path('../../test_helper', __FILE__)
|
||||||
|
|
||||||
class AttachmentTest < ActiveSupport::TestCase
|
class AttachmentTest < ActiveSupport::TestCase
|
||||||
fixtures :issues, :users
|
fixtures :issues, :projects, :users, :issue_statuses, :trackers, :projects_trackers
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
end
|
end
|
||||||
@ -76,4 +76,24 @@ class AttachmentTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
end
|
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
|
end
|
||||||
|
@ -43,22 +43,27 @@ class MessageTest < ActiveSupport::TestCase
|
|||||||
messages_count = @board.messages_count
|
messages_count = @board.messages_count
|
||||||
@message = Message.find(1)
|
@message = Message.find(1)
|
||||||
replies_count = @message.replies_count
|
replies_count = @message.replies_count
|
||||||
|
journals_count = @message.journals.count
|
||||||
|
|
||||||
reply_author = User.find(2)
|
reply_author = User.find(2)
|
||||||
reply = Message.new(:board => @board, :subject => 'Test reply', :content => 'Test reply content', :parent => @message, :author => reply_author)
|
reply = Message.new(:board => @board, :subject => 'Test reply', :content => 'Test reply content', :parent => @message, :author => reply_author)
|
||||||
assert reply.save
|
assert reply.save
|
||||||
|
|
||||||
@board.reload
|
@board.reload
|
||||||
# same topics count
|
# same topics count
|
||||||
assert_equal topics_count, @board[:topics_count]
|
assert_equal topics_count, @board[:topics_count]
|
||||||
# messages count incremented
|
# messages count incremented
|
||||||
assert_equal messages_count+1, @board[:messages_count]
|
assert_equal messages_count+1, @board[:messages_count]
|
||||||
assert_equal reply, @board.last_message
|
assert_equal reply, @board.last_message
|
||||||
|
|
||||||
@message.reload
|
@message.reload
|
||||||
# replies count incremented
|
# replies count incremented
|
||||||
assert_equal replies_count+1, @message[:replies_count]
|
assert_equal replies_count+1, @message[:replies_count]
|
||||||
assert_equal reply, @message.last_reply
|
assert_equal reply, @message.last_reply
|
||||||
# author should be watching the message
|
# author should be watching the message
|
||||||
assert @message.watched_by?(reply_author)
|
assert @message.watched_by?(reply_author)
|
||||||
|
# journal count should be unchanged
|
||||||
|
assert_equal journals_count, @message.journals.count
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_moving_message_should_update_counters
|
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)
|
message = Message.new(:board => @board, :subject => 'Test message', :content => 'Test message content', :author => @user)
|
||||||
assert message.save
|
assert message.save
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user