render :partial => 'attributes'
end
- def preview
- @issue = @project.issues.find_by_id(params[:id]) unless params[:id].blank?
- if @issue
- @attachements = @issue.attachments
- @description = params[:issue] && params[:issue][:description]
- if @description && @description.gsub(/(\r?\n|\n\r?)/, "\n") == @issue.description.to_s.gsub(/(\r?\n|\n\r?)/, "\n")
- @description = nil
- end
- @notes = params[:notes]
- else
- @description = (params[:issue] ? params[:issue][:description] : nil)
- end
- render :layout => false
- end
-
private
def find_issue
@issue = Issue.find(params[:id], :include => [:project, :tracker, :status, :author, :priority, :category])
--- /dev/null
+class PreviewsController < ApplicationController
+ before_filter :find_project
+
+ def issue
+ @issue = @project.issues.find_by_id(params[:id]) unless params[:id].blank?
+ if @issue
+ @attachements = @issue.attachments
+ @description = params[:issue] && params[:issue][:description]
+ if @description && @description.gsub(/(\r?\n|\n\r?)/, "\n") == @issue.description.to_s.gsub(/(\r?\n|\n\r?)/, "\n")
+ @description = nil
+ end
+ @notes = params[:notes]
+ else
+ @description = (params[:issue] ? params[:issue][:description] : nil)
+ end
+ render :layout => false
+ end
+
+ private
+
+ def find_project
+ project_id = (params[:issue] && params[:issue][:project_id]) || params[:project_id]
+ @project = Project.find(project_id)
+ rescue ActiveRecord::RecordNotFound
+ render_404
+ end
+
+end
<%= f.hidden_field :lock_version %>
<%= submit_tag l(:button_submit) %>
<%= link_to_remote l(:label_preview),
- { :url => { :controller => 'issues', :action => 'preview', :project_id => @project, :id => @issue },
+ { :url => preview_issue_path(:project_id => @project, :id => @issue),
:method => 'post',
:update => 'preview',
:with => 'Form.serialize("issue-form")',
<%= submit_tag l(:button_create) %>
<%= submit_tag l(:button_create_and_continue), :name => 'continue' %>
<%= link_to_remote l(:label_preview),
- { :url => { :controller => 'issues', :action => 'preview', :project_id => @project },
+ { :url => preview_issue_path(:project_id => @project),
:method => 'post',
:update => 'preview',
:with => "Form.serialize('issue-form')",
+++ /dev/null
-<% if @notes %>
- <fieldset class="preview"><legend><%= l(:field_notes) %></legend>
- <%= textilizable @notes, :attachments => @attachements, :object => @issue %>
- </fieldset>
-<% end %>
-
-<% if @description %>
- <fieldset class="preview"><legend><%= l(:field_description) %></legend>
- <%= textilizable @description, :attachments => @attachements, :object => @issue %>
- </fieldset>
-<% end %>
--- /dev/null
+<% if @notes %>
+ <fieldset class="preview"><legend><%= l(:field_notes) %></legend>
+ <%= textilizable @notes, :attachments => @attachements, :object => @issue %>
+ </fieldset>
+<% end %>
+
+<% if @description %>
+ <fieldset class="preview"><legend><%= l(:field_description) %></legend>
+ <%= textilizable @description, :attachments => @attachements, :object => @issue %>
+ </fieldset>
+<% end %>
map.resources :issue_moves, :only => [:new, :create], :path_prefix => '/issues', :as => 'move'
map.auto_complete_issues '/issues/auto_complete', :controller => 'auto_completes', :action => 'issues'
+ # TODO: would look nicer as /issues/:id/preview
+ map.preview_issue '/issues/preview/:id', :controller => 'previews', :action => 'issue'
map.with_options :controller => 'issues' do |issues_routes|
issues_routes.with_options :conditions => {:method => :get} do |issues_views|
:class => 'icon-del disabled' }
end
- def test_preview_new_issue
- @request.session[:user_id] = 2
- post :preview, :project_id => '1', :issue => {:description => 'Foo'}
- assert_response :success
- assert_template 'preview'
- assert_not_nil assigns(:description)
- end
-
- def test_preview_notes
- @request.session[:user_id] = 2
- post :preview, :project_id => '1', :id => 1, :issue => {:description => Issue.find(1).description}, :notes => 'Foo'
- assert_response :success
- assert_template 'preview'
- assert_not_nil assigns(:notes)
- end
-
def test_destroy_issue_with_no_time_entries
assert_nil TimeEntry.find_by_issue_id(2)
@request.session[:user_id] = 2
--- /dev/null
+require File.dirname(__FILE__) + '/../test_helper'
+
+class PreviewsControllerTest < ActionController::TestCase
+ fixtures :all
+
+ def test_preview_new_issue
+ @request.session[:user_id] = 2
+ post :issue, :project_id => '1', :issue => {:description => 'Foo'}
+ assert_response :success
+ assert_template 'preview'
+ assert_not_nil assigns(:description)
+ end
+
+ def test_preview_issue_notes
+ @request.session[:user_id] = 2
+ post :issue, :project_id => '1', :id => 1, :issue => {:description => Issue.find(1).description}, :notes => 'Foo'
+ assert_response :success
+ assert_template 'preview'
+ assert_not_nil assigns(:notes)
+ end
+
+end
should_route :post, "/projects/project-name/issues/gantt", :controller => 'gantts', :action => 'show', :project_id => 'project-name'
should_route :get, "/issues/auto_complete", :controller => 'auto_completes', :action => 'issues'
+
+ should_route :get, "/issues/preview/123", :controller => 'previews', :action => 'issue', :id => '123'
+ should_route :post, "/issues/preview/123", :controller => 'previews', :action => 'issue', :id => '123'
end
context "issue categories" do