Commit 0fd499af authored by Holger Just's avatar Holger Just

Merge branch 'master' into unstable

parents aa3ab990 43afcde3
......@@ -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 distributions 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
......
......@@ -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 } }
......
......@@ -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},
......
#-- 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
#-- 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__)
class AttachmentTest < ActiveSupport::TestCase
fixtures :issues, :users
fixtures :issues, :projects, :users, :issue_statuses, :trackers, :projects_trackers
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
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment