@@ -19,7 +19,7 class IssuesController < ApplicationController | |||
|
19 | 19 | menu_item :new_issue, :only => [:new, :create] |
|
20 | 20 | default_search_scope :issues |
|
21 | 21 | |
|
22 |
before_filter :find_issue, :only => [:show, :edit, :update |
|
|
22 | before_filter :find_issue, :only => [:show, :edit, :update] | |
|
23 | 23 | before_filter :find_issues, :only => [:bulk_edit, :move, :perform_move, :destroy] |
|
24 | 24 | before_filter :find_project, :only => [:new, :create, :update_form, :preview, :auto_complete] |
|
25 | 25 | before_filter :authorize, :except => [:index, :changes, :preview, :context_menu] |
@@ -200,29 +200,6 class IssuesController < ApplicationController | |||
|
200 | 200 | end |
|
201 | 201 | end |
|
202 | 202 | |
|
203 | def reply | |
|
204 | journal = Journal.find(params[:journal_id]) if params[:journal_id] | |
|
205 | if journal | |
|
206 | user = journal.user | |
|
207 | text = journal.notes | |
|
208 | else | |
|
209 | user = @issue.author | |
|
210 | text = @issue.description | |
|
211 | end | |
|
212 | # Replaces pre blocks with [...] | |
|
213 | text = text.to_s.strip.gsub(%r{<pre>((.|\s)*?)</pre>}m, '[...]') | |
|
214 | content = "#{ll(Setting.default_language, :text_user_wrote, user)}\n> " | |
|
215 | content << text.gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n" | |
|
216 | ||
|
217 | render(:update) { |page| | |
|
218 | page.<< "$('notes').value = \"#{escape_javascript content}\";" | |
|
219 | page.show 'update' | |
|
220 | page << "Form.Element.focus('notes');" | |
|
221 | page << "Element.scrollTo('update');" | |
|
222 | page << "$('notes').scrollTop = $('notes').scrollHeight - $('notes').clientHeight;" | |
|
223 | } | |
|
224 | end | |
|
225 | ||
|
226 | 203 | # Bulk edit a set of issues |
|
227 | 204 | def bulk_edit |
|
228 | 205 | @issues.sort! |
@@ -16,7 +16,31 | |||
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | class JournalsController < ApplicationController |
|
19 | before_filter :find_journal | |
|
19 | before_filter :find_journal, :only => [:edit] | |
|
20 | before_filter :find_issue, :only => [:new] | |
|
21 | ||
|
22 | def new | |
|
23 | journal = Journal.find(params[:journal_id]) if params[:journal_id] | |
|
24 | if journal | |
|
25 | user = journal.user | |
|
26 | text = journal.notes | |
|
27 | else | |
|
28 | user = @issue.author | |
|
29 | text = @issue.description | |
|
30 | end | |
|
31 | # Replaces pre blocks with [...] | |
|
32 | text = text.to_s.strip.gsub(%r{<pre>((.|\s)*?)</pre>}m, '[...]') | |
|
33 | content = "#{ll(Setting.default_language, :text_user_wrote, user)}\n> " | |
|
34 | content << text.gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n" | |
|
35 | ||
|
36 | render(:update) { |page| | |
|
37 | page.<< "$('notes').value = \"#{escape_javascript content}\";" | |
|
38 | page.show 'update' | |
|
39 | page << "Form.Element.focus('notes');" | |
|
40 | page << "Element.scrollTo('update');" | |
|
41 | page << "$('notes').scrollTop = $('notes').scrollHeight - $('notes').clientHeight;" | |
|
42 | } | |
|
43 | end | |
|
20 | 44 | |
|
21 | 45 | def edit |
|
22 | 46 | if request.post? |
@@ -38,4 +62,12 private | |||
|
38 | 62 | rescue ActiveRecord::RecordNotFound |
|
39 | 63 | render_404 |
|
40 | 64 | end |
|
65 | ||
|
66 | # TODO: duplicated in IssuesController | |
|
67 | def find_issue | |
|
68 | @issue = Issue.find(params[:id], :include => [:project, :tracker, :status, :author, :priority, :category]) | |
|
69 | @project = @issue.project | |
|
70 | rescue ActiveRecord::RecordNotFound | |
|
71 | render_404 | |
|
72 | end | |
|
41 | 73 | end |
@@ -22,7 +22,7 module JournalsHelper | |||
|
22 | 22 | links = [] |
|
23 | 23 | if !journal.notes.blank? |
|
24 | 24 | links << link_to_remote(image_tag('comment.png'), |
|
25 |
{ :url => {:controller => ' |
|
|
25 | { :url => {:controller => 'journals', :action => 'new', :id => issue, :journal_id => journal} }, | |
|
26 | 26 | :title => l(:button_quote)) if options[:reply_links] |
|
27 | 27 | links << link_to_in_place_notes_editor(image_tag('edit.png'), "journal-#{journal.id}-notes", |
|
28 | 28 | { :controller => 'journals', :action => 'edit', :id => journal }, |
@@ -124,7 +124,7 ActionController::Routing::Routes.draw do |map| | |||
|
124 | 124 | issues_actions.connect 'projects/:project_id/issues', :action => 'create' |
|
125 | 125 | issues_actions.connect 'projects/:project_id/issues/gantt', :controller => 'gantts', :action => 'show' |
|
126 | 126 | issues_actions.connect 'projects/:project_id/issues/calendar', :controller => 'calendars', :action => 'show' |
|
127 |
issues_actions.connect 'issues/:id/quoted', :action => ' |
|
|
127 | issues_actions.connect 'issues/:id/quoted', :controller => 'journals', :action => 'new', :id => /\d+/ | |
|
128 | 128 | issues_actions.connect 'issues/:id/:action', :action => /edit|destroy/, :id => /\d+/ |
|
129 | 129 | issues_actions.connect 'issues.:format', :action => 'create', :format => /xml/ |
|
130 | 130 | end |
@@ -63,10 +63,10 Redmine::AccessControl.map do |map| | |||
|
63 | 63 | :queries => :index, |
|
64 | 64 | :reports => [:issue_report, :issue_report_details]} |
|
65 | 65 | map.permission :add_issues, {:issues => [:new, :create, :update_form]} |
|
66 |
map.permission :edit_issues, {:issues => [:edit, :update, |
|
|
66 | map.permission :edit_issues, {:issues => [:edit, :update, :bulk_edit, :update_form], :journals => [:new]} | |
|
67 | 67 | map.permission :manage_issue_relations, {:issue_relations => [:new, :destroy]} |
|
68 | 68 | map.permission :manage_subtasks, {} |
|
69 |
map.permission :add_issue_notes, {:issues => [:edit, :update, : |
|
|
69 | map.permission :add_issue_notes, {:issues => [:edit, :update], :journals => [:new]} | |
|
70 | 70 | map.permission :edit_issue_notes, {:journals => :edit}, :require => :loggedin |
|
71 | 71 | map.permission :edit_own_issue_notes, {:journals => :edit}, :require => :loggedin |
|
72 | 72 | map.permission :move_issues, {:issue_moves => [:new, :create]}, :require => :loggedin |
@@ -634,20 +634,6 class IssuesControllerTest < ActionController::TestCase | |||
|
634 | 634 | assert_equal 'This is the test_new issue', issue.subject |
|
635 | 635 | end |
|
636 | 636 | |
|
637 | def test_reply_to_issue | |
|
638 | @request.session[:user_id] = 2 | |
|
639 | get :reply, :id => 1 | |
|
640 | assert_response :success | |
|
641 | assert_select_rjs :show, "update" | |
|
642 | end | |
|
643 | ||
|
644 | def test_reply_to_note | |
|
645 | @request.session[:user_id] = 2 | |
|
646 | get :reply, :id => 1, :journal_id => 2 | |
|
647 | assert_response :success | |
|
648 | assert_select_rjs :show, "update" | |
|
649 | end | |
|
650 | ||
|
651 | 637 | def test_update_using_invalid_http_verbs |
|
652 | 638 | @request.session[:user_id] = 2 |
|
653 | 639 | subject = 'Updated by an invalid http verb' |
@@ -31,6 +31,20 class JournalsControllerTest < ActionController::TestCase | |||
|
31 | 31 | User.current = nil |
|
32 | 32 | end |
|
33 | 33 | |
|
34 | def test_reply_to_issue | |
|
35 | @request.session[:user_id] = 2 | |
|
36 | get :new, :id => 1 | |
|
37 | assert_response :success | |
|
38 | assert_select_rjs :show, "update" | |
|
39 | end | |
|
40 | ||
|
41 | def test_reply_to_note | |
|
42 | @request.session[:user_id] = 2 | |
|
43 | get :new, :id => 1, :journal_id => 2 | |
|
44 | assert_response :success | |
|
45 | assert_select_rjs :show, "update" | |
|
46 | end | |
|
47 | ||
|
34 | 48 | def test_get_edit |
|
35 | 49 | @request.session[:user_id] = 1 |
|
36 | 50 | xhr :get, :edit, :id => 2 |
@@ -88,7 +88,7 class RoutingTest < ActionController::IntegrationTest | |||
|
88 | 88 | should_route :get, "/issues/move/new", :controller => 'issue_moves', :action => 'new' |
|
89 | 89 | should_route :post, "/issues/move", :controller => 'issue_moves', :action => 'create' |
|
90 | 90 | |
|
91 |
should_route :post, "/issues/1/quoted", :controller => ' |
|
|
91 | should_route :post, "/issues/1/quoted", :controller => 'journals', :action => 'new', :id => '1' | |
|
92 | 92 | |
|
93 | 93 | should_route :get, "/issues/calendar", :controller => 'calendars', :action => 'show' |
|
94 | 94 | should_route :post, "/issues/calendar", :controller => 'calendars', :action => 'show' |
General Comments 0
You need to be logged in to leave comments.
Login now