Merged r3941 from trunk.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.0-stable@3991 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Eric Davis 2010-08-19 04:33:46 +00:00
parent 8ca6941a33
commit 2012c60bfd
8 changed files with 53 additions and 44 deletions

View File

@ -19,7 +19,7 @@ class IssuesController < ApplicationController
menu_item :new_issue, :only => [:new, :create] menu_item :new_issue, :only => [:new, :create]
default_search_scope :issues default_search_scope :issues
before_filter :find_issue, :only => [:show, :edit, :update, :reply] before_filter :find_issue, :only => [:show, :edit, :update]
before_filter :find_issues, :only => [:bulk_edit, :move, :perform_move, :destroy] before_filter :find_issues, :only => [:bulk_edit, :move, :perform_move, :destroy]
before_filter :find_project, :only => [:new, :create, :update_form, :preview, :auto_complete] before_filter :find_project, :only => [:new, :create, :update_form, :preview, :auto_complete]
before_filter :authorize, :except => [:index, :changes, :preview, :context_menu] before_filter :authorize, :except => [:index, :changes, :preview, :context_menu]
@ -200,29 +200,6 @@ class IssuesController < ApplicationController
end end
end end
def reply
journal = Journal.find(params[:journal_id]) if params[:journal_id]
if journal
user = journal.user
text = journal.notes
else
user = @issue.author
text = @issue.description
end
# Replaces pre blocks with [...]
text = text.to_s.strip.gsub(%r{<pre>((.|\s)*?)</pre>}m, '[...]')
content = "#{ll(Setting.default_language, :text_user_wrote, user)}\n> "
content << text.gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n"
render(:update) { |page|
page.<< "$('notes').value = \"#{escape_javascript content}\";"
page.show 'update'
page << "Form.Element.focus('notes');"
page << "Element.scrollTo('update');"
page << "$('notes').scrollTop = $('notes').scrollHeight - $('notes').clientHeight;"
}
end
# Bulk edit a set of issues # Bulk edit a set of issues
def bulk_edit def bulk_edit
@issues.sort! @issues.sort!

View File

@ -16,7 +16,31 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class JournalsController < ApplicationController class JournalsController < ApplicationController
before_filter :find_journal before_filter :find_journal, :only => [:edit]
before_filter :find_issue, :only => [:new]
def new
journal = Journal.find(params[:journal_id]) if params[:journal_id]
if journal
user = journal.user
text = journal.notes
else
user = @issue.author
text = @issue.description
end
# Replaces pre blocks with [...]
text = text.to_s.strip.gsub(%r{<pre>((.|\s)*?)</pre>}m, '[...]')
content = "#{ll(Setting.default_language, :text_user_wrote, user)}\n> "
content << text.gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n"
render(:update) { |page|
page.<< "$('notes').value = \"#{escape_javascript content}\";"
page.show 'update'
page << "Form.Element.focus('notes');"
page << "Element.scrollTo('update');"
page << "$('notes').scrollTop = $('notes').scrollHeight - $('notes').clientHeight;"
}
end
def edit def edit
if request.post? if request.post?
@ -38,4 +62,12 @@ private
rescue ActiveRecord::RecordNotFound rescue ActiveRecord::RecordNotFound
render_404 render_404
end end
# TODO: duplicated in IssuesController
def find_issue
@issue = Issue.find(params[:id], :include => [:project, :tracker, :status, :author, :priority, :category])
@project = @issue.project
rescue ActiveRecord::RecordNotFound
render_404
end
end end

View File

@ -22,7 +22,7 @@ module JournalsHelper
links = [] links = []
if !journal.notes.blank? if !journal.notes.blank?
links << link_to_remote(image_tag('comment.png'), links << link_to_remote(image_tag('comment.png'),
{ :url => {:controller => 'issues', :action => 'reply', :id => issue, :journal_id => journal} }, { :url => {:controller => 'journals', :action => 'new', :id => issue, :journal_id => journal} },
:title => l(:button_quote)) if options[:reply_links] :title => l(:button_quote)) if options[:reply_links]
links << link_to_in_place_notes_editor(image_tag('edit.png'), "journal-#{journal.id}-notes", links << link_to_in_place_notes_editor(image_tag('edit.png'), "journal-#{journal.id}-notes",
{ :controller => 'journals', :action => 'edit', :id => journal }, { :controller => 'journals', :action => 'edit', :id => journal },

View File

@ -124,7 +124,7 @@ ActionController::Routing::Routes.draw do |map|
issues_actions.connect 'projects/:project_id/issues', :action => 'create' issues_actions.connect 'projects/:project_id/issues', :action => 'create'
issues_actions.connect 'projects/:project_id/issues/gantt', :controller => 'gantts', :action => 'show' issues_actions.connect 'projects/:project_id/issues/gantt', :controller => 'gantts', :action => 'show'
issues_actions.connect 'projects/:project_id/issues/calendar', :controller => 'calendars', :action => 'show' issues_actions.connect 'projects/:project_id/issues/calendar', :controller => 'calendars', :action => 'show'
issues_actions.connect 'issues/:id/quoted', :action => 'reply', :id => /\d+/ issues_actions.connect 'issues/:id/quoted', :controller => 'journals', :action => 'new', :id => /\d+/
issues_actions.connect 'issues/:id/:action', :action => /edit|destroy/, :id => /\d+/ issues_actions.connect 'issues/:id/:action', :action => /edit|destroy/, :id => /\d+/
issues_actions.connect 'issues.:format', :action => 'create', :format => /xml/ issues_actions.connect 'issues.:format', :action => 'create', :format => /xml/
end end

View File

@ -63,10 +63,10 @@ Redmine::AccessControl.map do |map|
:queries => :index, :queries => :index,
:reports => [:issue_report, :issue_report_details]} :reports => [:issue_report, :issue_report_details]}
map.permission :add_issues, {:issues => [:new, :create, :update_form]} map.permission :add_issues, {:issues => [:new, :create, :update_form]}
map.permission :edit_issues, {:issues => [:edit, :update, :reply, :bulk_edit, :update_form]} map.permission :edit_issues, {:issues => [:edit, :update, :bulk_edit, :update_form], :journals => [:new]}
map.permission :manage_issue_relations, {:issue_relations => [:new, :destroy]} map.permission :manage_issue_relations, {:issue_relations => [:new, :destroy]}
map.permission :manage_subtasks, {} map.permission :manage_subtasks, {}
map.permission :add_issue_notes, {:issues => [:edit, :update, :reply]} map.permission :add_issue_notes, {:issues => [:edit, :update], :journals => [:new]}
map.permission :edit_issue_notes, {:journals => :edit}, :require => :loggedin map.permission :edit_issue_notes, {:journals => :edit}, :require => :loggedin
map.permission :edit_own_issue_notes, {:journals => :edit}, :require => :loggedin map.permission :edit_own_issue_notes, {:journals => :edit}, :require => :loggedin
map.permission :move_issues, {:issue_moves => [:new, :create]}, :require => :loggedin map.permission :move_issues, {:issue_moves => [:new, :create]}, :require => :loggedin

View File

@ -634,20 +634,6 @@ class IssuesControllerTest < ActionController::TestCase
assert_equal 'This is the test_new issue', issue.subject assert_equal 'This is the test_new issue', issue.subject
end end
def test_reply_to_issue
@request.session[:user_id] = 2
get :reply, :id => 1
assert_response :success
assert_select_rjs :show, "update"
end
def test_reply_to_note
@request.session[:user_id] = 2
get :reply, :id => 1, :journal_id => 2
assert_response :success
assert_select_rjs :show, "update"
end
def test_update_using_invalid_http_verbs def test_update_using_invalid_http_verbs
@request.session[:user_id] = 2 @request.session[:user_id] = 2
subject = 'Updated by an invalid http verb' subject = 'Updated by an invalid http verb'

View File

@ -31,6 +31,20 @@ class JournalsControllerTest < ActionController::TestCase
User.current = nil User.current = nil
end end
def test_reply_to_issue
@request.session[:user_id] = 2
get :new, :id => 1
assert_response :success
assert_select_rjs :show, "update"
end
def test_reply_to_note
@request.session[:user_id] = 2
get :new, :id => 1, :journal_id => 2
assert_response :success
assert_select_rjs :show, "update"
end
def test_get_edit def test_get_edit
@request.session[:user_id] = 1 @request.session[:user_id] = 1
xhr :get, :edit, :id => 2 xhr :get, :edit, :id => 2

View File

@ -88,7 +88,7 @@ class RoutingTest < ActionController::IntegrationTest
should_route :get, "/issues/move/new", :controller => 'issue_moves', :action => 'new' should_route :get, "/issues/move/new", :controller => 'issue_moves', :action => 'new'
should_route :post, "/issues/move", :controller => 'issue_moves', :action => 'create' should_route :post, "/issues/move", :controller => 'issue_moves', :action => 'create'
should_route :post, "/issues/1/quoted", :controller => 'issues', :action => 'reply', :id => '1' should_route :post, "/issues/1/quoted", :controller => 'journals', :action => 'new', :id => '1'
should_route :get, "/issues/calendar", :controller => 'calendars', :action => 'show' should_route :get, "/issues/calendar", :controller => 'calendars', :action => 'show'
should_route :post, "/issues/calendar", :controller => 'calendars', :action => 'show' should_route :post, "/issues/calendar", :controller => 'calendars', :action => 'show'