From dea10c54f9f9fed80d60e0358d9f2675937daad9 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Wed, 31 Dec 2008 11:31:02 +0000 Subject: [PATCH] Merged r2164 to r2167, r2188 and r2189 from trunk. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/0.8-stable@2216 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/issues_controller.rb | 5 +++- app/controllers/repositories_controller.rb | 3 +++ app/models/mailer.rb | 1 + app/views/issues/_form.rhtml | 8 +++++++ .../repositories/_link_to_functions.rhtml | 10 ++++++++ app/views/repositories/annotate.rhtml | 2 ++ app/views/repositories/changes.rhtml | 11 +-------- app/views/repositories/entry.rhtml | 2 ++ doc/CHANGELOG | 7 ++++++ lang/fr.yml | 2 +- lib/redmine/scm/adapters/darcs_adapter.rb | 13 +++++++--- test/functional/issues_controller_test.rb | 24 +++++++++++++++++++ test/unit/repository_darcs_test.rb | 6 +++++ .../lib/acts_as_watchable.rb | 2 ++ 14 files changed, 81 insertions(+), 15 deletions(-) create mode 100644 app/views/repositories/_link_to_functions.rhtml diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index f1f88bfdb..7df4177e6 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -123,7 +123,10 @@ class IssuesController < ApplicationController render :nothing => true, :layout => true return end - @issue.attributes = params[:issue] + if params[:issue].is_a?(Hash) + @issue.attributes = params[:issue] + @issue.watcher_user_ids = params[:issue]['watcher_user_ids'] if User.current.allowed_to?(:add_issue_watchers, @project) + end @issue.author = User.current default_status = IssueStatus.default diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index dc2acee3a..3cec2e8e5 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -127,6 +127,9 @@ class RepositoriesController < ApplicationController end def annotate + @entry = @repository.entry(@path, @rev) + show_error_not_found and return unless @entry + @annotate = @repository.scm.annotate(@path, @rev) render_error l(:error_scm_annotate) and return if @annotate.nil? || @annotate.empty? end diff --git a/app/models/mailer.rb b/app/models/mailer.rb index 9614ab094..93f07f6e9 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -28,6 +28,7 @@ class Mailer < ActionMailer::Base 'Issue-Author' => issue.author.login redmine_headers 'Issue-Assignee' => issue.assigned_to.login if issue.assigned_to recipients issue.recipients + cc(issue.watcher_recipients - @recipients) subject "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] (#{issue.status.name}) #{issue.subject}" body :issue => issue, :issue_url => url_for(:controller => 'issues', :action => 'show', :id => issue) diff --git a/app/views/issues/_form.rhtml b/app/views/issues/_form.rhtml index 419536fee..7ae990d5f 100644 --- a/app/views/issues/_form.rhtml +++ b/app/views/issues/_form.rhtml @@ -48,6 +48,14 @@

<%= render :partial => 'attachments/form' %>

<% end %> +<% if @issue.new_record? && User.current.allowed_to?(:add_issue_watchers, @project) -%> +

+<% @issue.project.users.sort.each do |user| -%> + +<% end -%> +

+<% end %> + <%= call_hook(:view_issues_form_details_bottom, { :issue => @issue, :form => f }) %> <%= wikitoolbar_for 'issue_description' %> diff --git a/app/views/repositories/_link_to_functions.rhtml b/app/views/repositories/_link_to_functions.rhtml new file mode 100644 index 000000000..7737bf484 --- /dev/null +++ b/app/views/repositories/_link_to_functions.rhtml @@ -0,0 +1,10 @@ +

+<% if @repository.supports_cat? %> + <%= link_to_if action_name != 'entry', l(:button_view), {:action => 'entry', :id => @project, :path => to_path_param(@path), :rev => @rev } %> | +<% end %> +<% if @repository.supports_annotate? %> + <%= link_to_if action_name != 'annotate', l(:button_annotate), {:action => 'annotate', :id => @project, :path => to_path_param(@path), :rev => @rev } %> | +<% end %> +<%= link_to(l(:button_download), {:action => 'entry', :id => @project, :path => to_path_param(@path), :rev => @rev, :format => 'raw' }) if @repository.supports_cat? %> +<%= "(#{number_to_human_size(@entry.size)})" if @entry.size %> +

diff --git a/app/views/repositories/annotate.rhtml b/app/views/repositories/annotate.rhtml index b5669ef76..44b5a81a6 100644 --- a/app/views/repositories/annotate.rhtml +++ b/app/views/repositories/annotate.rhtml @@ -1,5 +1,7 @@

<%= render :partial => 'navigation', :locals => { :path => @path, :kind => 'file', :revision => @rev } %>

+

<%= render :partial => 'link_to_functions' %>

+ <% colors = Hash.new {|k,v| k[v] = (k.size % 12) } %>
diff --git a/app/views/repositories/changes.rhtml b/app/views/repositories/changes.rhtml index ca5c58328..aa359ef4d 100644 --- a/app/views/repositories/changes.rhtml +++ b/app/views/repositories/changes.rhtml @@ -1,15 +1,6 @@

<%= render :partial => 'navigation', :locals => { :path => @path, :kind => (@entry ? @entry.kind : nil), :revision => @rev } %>

-

-<% if @repository.supports_cat? %> - <%= link_to l(:button_view), {:action => 'entry', :id => @project, :path => to_path_param(@path), :rev => @rev } %> | -<% end %> -<% if @repository.supports_annotate? %> - <%= link_to l(:button_annotate), {:action => 'annotate', :id => @project, :path => to_path_param(@path), :rev => @rev } %> | -<% end %> -<%= link_to(l(:button_download), {:action => 'entry', :id => @project, :path => to_path_param(@path), :rev => @rev, :format => 'raw' }) if @repository.supports_cat? %> -<%= "(#{number_to_human_size(@entry.size)})" if @entry.size %> -

+

<%= render :partial => 'link_to_functions' %>

<%= render_properties(@properties) %> diff --git a/app/views/repositories/entry.rhtml b/app/views/repositories/entry.rhtml index 8e1e1992c..12ba9f428 100644 --- a/app/views/repositories/entry.rhtml +++ b/app/views/repositories/entry.rhtml @@ -1,5 +1,7 @@

<%= render :partial => 'navigation', :locals => { :path => @path, :kind => 'file', :revision => @rev } %>

+

<%= render :partial => 'link_to_functions' %>

+ <%= render :partial => 'common/file', :locals => {:filename => @path, :content => @content} %> <% content_for :header_tags do %> diff --git a/doc/CHANGELOG b/doc/CHANGELOG index bfc15e0a4..31208cd86 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -5,6 +5,13 @@ Copyright (C) 2006-2008 Jean-Philippe Lang http://www.redmine.org/ +== v0.8.1 + +* Select watchers on new issue form +* Show view/annotate/download links on entry and annotate views +* Fixed: Deleted files are shown when using Darcs + + == 2008-12-30 v0.8.0 * Setting added in order to limit the number of diff lines that should be displayed diff --git a/lang/fr.yml b/lang/fr.yml index daa6f2f60..9d0230093 100644 --- a/lang/fr.yml +++ b/lang/fr.yml @@ -580,7 +580,7 @@ label_reverse_chronological_order: Dans l'ordre chronologique inverse label_planning: Planning label_incoming_emails: Emails entrants label_generate_key: Générer une clé -label_issue_watchers: Utilisateurs surveillant cette demande +label_issue_watchers: Observateurs label_example: Exemple button_login: Connexion diff --git a/lib/redmine/scm/adapters/darcs_adapter.rb b/lib/redmine/scm/adapters/darcs_adapter.rb index 4a5183f79..658f06055 100644 --- a/lib/redmine/scm/adapters/darcs_adapter.rb +++ b/lib/redmine/scm/adapters/darcs_adapter.rb @@ -84,7 +84,7 @@ module Redmine end end return nil if $? && $?.exitstatus != 0 - entries.sort_by_name + entries.compact.sort_by_name end def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={}) @@ -148,15 +148,22 @@ module Redmine end private - + + # Returns an Entry from the given XML element + # or nil if the entry was deleted def entry_from_xml(element, path_prefix) + modified_element = element.elements['modified'] + if modified_element.elements['modified_how'].text.match(/removed/) + return nil + end + Entry.new({:name => element.attributes['name'], :path => path_prefix + element.attributes['name'], :kind => element.name == 'file' ? 'file' : 'dir', :size => nil, :lastrev => Revision.new({ :identifier => nil, - :scmid => element.elements['modified'].elements['patch'].attributes['hash'] + :scmid => modified_element.elements['patch'].attributes['hash'] }) }) end diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb index f0f1ec6ec..961e04c99 100644 --- a/test/functional/issues_controller_test.rb +++ b/test/functional/issues_controller_test.rb @@ -332,6 +332,30 @@ class IssuesControllerTest < Test::Unit::TestCase assert_equal 'activerecord_error_invalid', issue.errors.on(:custom_values) end + def test_post_new_with_watchers + @request.session[:user_id] = 2 + ActionMailer::Base.deliveries.clear + + assert_difference 'Watcher.count', 2 do + post :new, :project_id => 1, + :issue => {:tracker_id => 1, + :subject => 'This is a new issue with watchers', + :description => 'This is the description', + :priority_id => 5, + :watcher_user_ids => ['2', '3']} + end + assert_redirected_to 'issues/show' + + issue = Issue.find_by_subject('This is a new issue with watchers') + # Watchers added + assert_equal [2, 3], issue.watcher_user_ids.sort + assert issue.watched_by?(User.find(3)) + # Watchers notified + mail = ActionMailer::Base.deliveries.last + assert_kind_of TMail::Mail, mail + assert [mail.bcc, mail.cc].flatten.include?(User.find(3).mail) + end + def test_post_should_preserve_fields_values_on_validation_failure @request.session[:user_id] = 2 post :new, :project_id => 1, diff --git a/test/unit/repository_darcs_test.rb b/test/unit/repository_darcs_test.rb index ca8c267f2..0c8c9a143 100644 --- a/test/unit/repository_darcs_test.rb +++ b/test/unit/repository_darcs_test.rb @@ -49,6 +49,12 @@ class RepositoryDarcsTest < Test::Unit::TestCase assert_equal 6, @repository.changesets.count end + def test_deleted_files_should_not_be_listed + entries = @repository.entries('sources') + assert entries.detect {|e| e.name == 'watchers_controller.rb'} + assert_nil entries.detect {|e| e.name == 'welcome_controller.rb'} + end + def test_cat @repository.fetch_changesets cat = @repository.cat("sources/welcome_controller.rb", 2) diff --git a/vendor/plugins/acts_as_watchable/lib/acts_as_watchable.rb b/vendor/plugins/acts_as_watchable/lib/acts_as_watchable.rb index 2cb122795..3d0de0dca 100644 --- a/vendor/plugins/acts_as_watchable/lib/acts_as_watchable.rb +++ b/vendor/plugins/acts_as_watchable/lib/acts_as_watchable.rb @@ -14,6 +14,8 @@ module Redmine class_eval do has_many :watchers, :as => :watchable, :dependent => :delete_all has_many :watcher_users, :through => :watchers, :source => :user + + attr_protected :watcher_ids, :watcher_user_ids end end end -- 2.39.5