file_naming.diff

Mathias Nestler, 2014-04-05 21:00

Download (3.66 KB)

View differences:

app/controllers/issues_controller.rb
65 65
        if params[:columns] == 'all'
66 66
          @query.column_names = @query.available_inline_columns.map(&:name)
67 67
        end
68
        filename = @query.name.blank? || @query.name == '_' ? "issues" : @query.name.parameterize.underscore
69
        filename += ".#{params[:format]}"
68 70
      when 'atom'
69 71
        @limit = Setting.feeds_limit.to_i
70 72
      when 'xml', 'json'
......
89 91
          Issue.load_visible_relations(@issues) if include_in_api_response?('relations')
90 92
        }
91 93
        format.atom { render_feed(@issues, :title => "#{@project || Setting.app_title}: #{l(:label_issue_plural)}") }
92
        format.csv  { send_data(query_to_csv(@issues, @query, params), :type => 'text/csv; header=present', :filename => 'issues.csv') }
93
        format.pdf  { send_data(issues_to_pdf(@issues, @project, @query), :type => 'application/pdf', :filename => 'issues.pdf') }
94
        format.csv  { send_data(query_to_csv(@issues, @query, params), :type => 'text/csv; header=present', :filename => filename) }
95
        format.pdf  { send_data(issues_to_pdf(@issues, @project, @query), :type => 'application/pdf', :filename => filename) }
94 96
      end
95 97
    else
96 98
      respond_to do |format|
test/functional/issues_controller_test.rb
397 397
    assert_equal assigns(:query).columns.size, lines[0].split(',').size
398 398
  end
399 399

  
400
  def test_index_csv_filename_without_query
401
    get :index, :format => 'csv'
402
    assert_response :success
403
    assert_match /issues.csv/, @response.headers['Content-Disposition']
404
  end
405

  
406
  def test_index_csv_filename_with_query
407
    q = IssueQuery.create!(:name => 'My Query Name 1', :visibility => IssueQuery::VISIBILITY_PUBLIC)
408
    get :index, :query_id => q.id, :format => 'csv'
409
    assert_response :success
410
    assert_match /my_query_name_1\.csv/, @response.headers['Content-Disposition']
411
  end
412

  
400 413
  def test_index_csv_with_project
401 414
    get :index, :project_id => 1, :format => 'csv'
402 415
    assert_response :success
......
599 612
    end
600 613
  end
601 614

  
615
  def test_index_pdf_filename_without_query
616
    get :index, :format => 'pdf'
617
    assert_response :success
618
    assert_match /issues.pdf/, @response.headers['Content-Disposition']
619
  end
620

  
621
  def test_index_pdf_filename_with_query
622
    q = IssueQuery.create!(:name => 'My Query Name 1', :visibility => IssueQuery::VISIBILITY_PUBLIC)
623
    get :index, :query_id => q.id, :format => 'pdf'
624
    assert_response :success
625
    assert_match /my_query_name_1\.pdf/, @response.headers['Content-Disposition']
626
  end
627

  
602 628
  def test_index_pdf_with_query_grouped_by_list_custom_field
603 629
    get :index, :project_id => 1, :query_id => 9, :format => 'pdf'
604 630
    assert_response :success
605
-