Merge branch 'release-v2.7.0' into stable

This commit is contained in:
Holger Just 2012-02-06 23:40:10 +01:00
commit ad996d7839
13 changed files with 124 additions and 28 deletions

14
Gemfile
View File

@ -13,9 +13,7 @@ group :test do
gem 'shoulda', '~> 2.10.3'
gem 'edavis10-object_daddy', :require => 'object_daddy'
gem 'mocha'
platforms :mri_18, :mingw_18 do gem 'ruby-debug' end
platforms :mri_19, :mingw_19 do gem 'ruby-debug19', :require => 'ruby-debug' end
gem 'capybara'
end
group :ldap do
@ -34,7 +32,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
@ -102,7 +100,9 @@ if File.readable?(gemfile_local)
end
# Load plugins' Gemfiles
Dir.glob File.expand_path("../vendor/plugins/*/Gemfile", __FILE__) do |file|
puts "Loading #{file} ..." if $DEBUG # `ruby -d` or `bundle -v`
instance_eval File.read(file)
["plugins", "chiliproject_plugins"].each do |plugin_path|
Dir.glob File.expand_path("../vendor/#{plugin_path}/*/Gemfile", __FILE__) do |file|
puts "Loading #{file} ..." if $DEBUG # `ruby -d` or `bundle -v`
instance_eval File.read(file)
end
end

View File

@ -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 } }

View File

@ -16,8 +16,24 @@ class JournalObserver < ActiveRecord::Observer
attr_accessor :send_notification
def after_create(journal)
if journal.type == "IssueJournal" and !journal.initial? and send_notification
after_create_issue_journal(journal)
case journal.type
when "IssueJournal"
if !journal.initial? && send_notification
after_create_issue_journal(journal)
end
when "WikiContentJournal"
wiki_content = journal.journaled
wiki_page = wiki_content.page
if journal.initial?
if Setting.notified_events.include?('wiki_content_added')
Mailer.deliver_wiki_content_added(wiki_content)
end
else
if Setting.notified_events.include?('wiki_content_updated')
Mailer.deliver_wiki_content_updated(wiki_content)
end
end
end
clear_notification
end

View File

@ -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},

View File

@ -200,6 +200,14 @@ class Repository < ActiveRecord::Base
encoding.blank? ? 'UTF-8' : encoding
end
# Provide a log encoding even if the column was not created yet
# It's used by 20100714111653_build_initial_journals_for_acts_as_journalized
# for initial journal creaetion of the changesets while the colum is only
# created by 20110228000000_add_repositories_log_encoding
def log_encoding
read_attribute(:log_encoding)
end
# Fetches new changesets for all repositories of active projects
# Can be called periodically by an external script
# eg. ruby script/runner "Repository.fetch_changesets"

View File

@ -1,5 +0,0 @@
require File.expand_path("../config/environment", __FILE__)
use Rails::Rack::LogTailer
use Rails::Rack::Static
run ActionController::Dispatcher.new

View File

@ -18,6 +18,9 @@
# you don't control web/app server and can't set it the proper way
# ENV['RAILS_ENV'] ||= 'production'
# use RACK_ENV if we are running as a simple rack app
ENV['RAILS_ENV'] ||= ENV['RACK_ENV'] if ENV['RACK_ENV']
# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.3.14' unless defined? RAILS_GEM_VERSION
@ -55,7 +58,7 @@ Rails::Initializer.run do |config|
# Activate observers that should always be running
# config.active_record.observers = :cacher, :garbage_collector
config.active_record.observers = :journal_observer, :message_observer, :issue_observer, :news_observer, :document_observer, :wiki_content_observer, :comment_observer
config.active_record.observers = :journal_observer, :message_observer, :issue_observer, :news_observer, :document_observer, :comment_observer
# Make Active Record use UTC-base instead of local time
# config.active_record.default_timezone = :utc

View File

@ -12,14 +12,19 @@
# See doc/COPYRIGHT.rdoc for more details.
#++
class WikiContentObserver < ActiveRecord::Observer
def after_create(wiki_content)
Mailer.deliver_wiki_content_added(wiki_content) if Setting.notified_events.include?('wiki_content_added')
end
def after_update(wiki_content)
if wiki_content.text_changed?
Mailer.deliver_wiki_content_updated(wiki_content) if Setting.notified_events.include?('wiki_content_updated')
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

View 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

View File

@ -1,5 +1,16 @@
= ChiliProject changelog
== 2012-02-06 v2.7.0
* Bug #593: Notification Mail for Wiki-Changes has wrong Diff
* Bug #775: Activity view too verbose
* Bug #819: RAILS_ENV is not properly set if running under thin
* Bug #822: Initial journal creation fails because of the missing log_encoding of Repositories
* Bug #823: Plugin in new directory not picking up Gemfile
* Bug #839: ruby-debug19 breaks on Ruby 1.9.3
* Bug #849: Prefix parameter of thin is not working
* Bug #857: Gemfile has an non ASCII character
== 2012-01-03 v2.6.0
* Bug #356: Clicking on login while logged-in logs you out

View File

@ -18,7 +18,7 @@ module ChiliProject
module VERSION #:nodoc:
MAJOR = 2
MINOR = 6
MINOR = 7
PATCH = 0
TINY = PATCH # Redmine compat

View File

@ -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

View File

@ -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