menu_item :new_issue, :only => [:new, :create]
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_project, :only => [:new, :create, :update_form, :preview, :auto_complete]
before_filter :authorize, :except => [:index, :changes, :preview, :context_menu]
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
def bulk_edit
@issues.sort!
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
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
if request.post?
rescue ActiveRecord::RecordNotFound
render_404
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
links = []
if !journal.notes.blank?
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]
links << link_to_in_place_notes_editor(image_tag('edit.png'), "journal-#{journal.id}-notes",
{ :controller => 'journals', :action => 'edit', :id => journal },
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/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.:format', :action => 'create', :format => /xml/
end
:queries => :index,
:reports => [:issue_report, :issue_report_details]}
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_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_own_issue_notes, {:journals => :edit}, :require => :loggedin
map.permission :move_issues, {:issue_moves => [:new, :create]}, :require => :loggedin
assert_equal 'This is the test_new issue', issue.subject
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
@request.session[:user_id] = 2
subject = 'Updated by an invalid http verb'
User.current = nil
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
@request.session[:user_id] = 1
xhr :get, :edit, :id => 2
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/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 :post, "/issues/calendar", :controller => 'calendars', :action => 'show'