Project

General

Profile

Defect #31141 » fix-31141.patch

Mizuki ISHIKAWA, 2019-05-16 03:46

View differences:

app/controllers/repositories_controller.rb
257 257
                      Digest::MD5.hexdigest("#{@path}-#{@rev}-#{@rev_to}-#{@diff_type}-#{current_language}")
258 258
      unless read_fragment(@cache_key)
259 259
        @diff = @repository.diff(@path, @rev, @rev_to)
260
        show_error_not_found unless @diff
260
        (show_error_not_found; return) unless @diff
261 261
      end
262 262

  
263 263
      @changeset = @repository.find_changeset_by_name(@rev)
264 264
      @changeset_to = @rev_to ? @repository.find_changeset_by_name(@rev_to) : nil
265 265
      @diff_format_revisions = @repository.diff_format_revisions(@changeset, @changeset_to)
266
      render :diff, :formats => :html
266 267
    end
267 268
  end
268 269

  
config/routes.rb
249 249
  post   'projects/:id/repository/:repository_id/revisions/:rev/issues', :to => 'repositories#add_related_issue'
250 250
  delete 'projects/:id/repository/:repository_id/revisions/:rev/issues/:issue_id', :to => 'repositories#remove_related_issue'
251 251
  get 'projects/:id/repository/:repository_id/revisions', :to => 'repositories#revisions'
252
  %w(browse show entry raw annotate diff).each do |action|
252
  %w(browse show entry raw annotate).each do |action|
253 253
    get "projects/:id/repository/:repository_id/revisions/:rev/#{action}(/*path)",
254 254
        :controller => 'repositories',
255 255
        :action => action,
256
        :format => false,
256
        :format => 'html',
257 257
        :constraints => {:rev => /[a-z0-9\.\-_]+/, :path => /.*/}
258 258
  end
259 259

  
260
  %w(browse entry raw changes annotate diff).each do |action|
260
  %w(browse entry raw changes annotate).each do |action|
261 261
    get "projects/:id/repository/:repository_id/#{action}(/*path)",
262 262
        :controller => 'repositories',
263 263
        :action => action,
264
        :format => false,
264
        :format => 'html',
265 265
        :constraints => {:path => /.*/}
266 266
  end
267 267

  
268
  get "projects/:id/repository/:repository_id/revisions/:rev/diff(/*path)",
269
      :to => 'repositories#diff',
270
      :format => false,
271
      :constraints => {:rev => /[a-z0-9\.\-_]+/, :path => /.*/}
272
  get "projects/:id/repository/:repository_id/diff(/*path)",
273
      :to => 'repositories#diff',
274
      :format => false,
275
      :constraints => {:path => /.*/}
276

  
268 277
  get 'projects/:id/repository/:repository_id/show/*path', :to => 'repositories#show', :format => 'html', :constraints => {:path => /.*/}
269 278

  
270 279
  get 'projects/:id/repository/:repository_id', :to => 'repositories#show', :path => nil
test/integration/repositories_git_test.rb
78 78
      assert_match /\Acommit deff712f05a90d96edbd70facc47d944be5897e3/, response.body
79 79
    end
80 80

  
81
    def test_get_diff_with_format_text_should_return_html
82
      @repository.fetch_changesets
83
      assert_equal NUM_REV, @repository.changesets.count
84

  
85
      get "/projects/subproject1/repository/#{@repository.id}/revisions/deff712f05a90d96edbd70facc47d944be5897e3/diff/sources/watchers_controller.rb", :params => { :format => 'txt' }
86
      assert_response :success
87

  
88
      assert a = css_select("a.diff").first
89
      assert_equal 'Unified diff', a.text
90
      get a['href']
91
      assert_response :success
92
      assert_match /\Acommit deff712f05a90d96edbd70facc47d944be5897e3/, response.body
93
    end
94

  
81 95
  else
82 96
    puts "Git test repository NOT FOUND. Skipping integration tests !!!"
83 97
    def test_fake; assert true end
test/integration/routing/repositories_test.rb
53 53
    should_route 'GET /projects/foo/repository/foo/revisions.atom' => 'repositories#revisions', :id => 'foo', :repository_id => 'foo', :format => 'atom'
54 54

  
55 55
    should_route 'GET /projects/foo/repository/foo/revisions/2457' => 'repositories#revision', :id => 'foo', :repository_id => 'foo', :rev => '2457'
56
    should_route 'GET /projects/foo/repository/foo/revisions/2457/show' => 'repositories#show', :id => 'foo', :repository_id => 'foo', :rev => '2457'
56
    should_route 'GET /projects/foo/repository/foo/revisions/2457/show' => 'repositories#show', :id => 'foo', :repository_id => 'foo', :rev => '2457', :format => 'html'
57 57
    should_route 'GET /projects/foo/repository/foo/revisions/2457/diff' => 'repositories#diff', :id => 'foo', :repository_id => 'foo', :rev => '2457'
58 58

  
59
    %w(show diff entry raw annotate).each do |action|
59
    %w(show entry raw annotate).each do |action|
60 60
      @paths.each do |path|
61 61
        should_route "GET /projects/foo/repository/foo/revisions/2457/#{action}/#{path}" => "repositories##{action}",
62
          :id => 'foo', :repository_id => 'foo', :rev => '2457', :path => path
62
          :id => 'foo', :repository_id => 'foo', :rev => '2457', :path => path, :format => 'html'
63 63
      end
64 64
    end
65
    @paths.each do |path|
66
      should_route "GET /projects/foo/repository/foo/revisions/2457/diff/#{path}" => "repositories#diff",
67
        :id => 'foo', :repository_id => 'foo', :rev => '2457', :path => path
68
    end
65 69
  end
66 70

  
67 71
  def test_repositories_non_revisions_path_with_repository_id
68
    should_route 'GET /projects/foo/repository/svn/changes' => 'repositories#changes', :id => 'foo', :repository_id => 'svn'
72
    should_route 'GET /projects/foo/repository/svn/changes' => 'repositories#changes', :id => 'foo', :repository_id => 'svn', :format => 'html'
69 73

  
70
    %w(changes diff browse entry raw annotate).each do |action|
74
    %w(changes browse entry raw annotate).each do |action|
71 75
      @paths.each do |path|
72 76
        should_route "GET /projects/foo/repository/svn/#{action}/#{path}" => "repositories##{action}",
73
          :id => 'foo', :repository_id => 'svn', :path => path
77
          :id => 'foo', :repository_id => 'svn', :path => path, :format => 'html'
74 78
      end
75 79
    end
80
    @paths.each do |path|
81
      should_route "GET /projects/foo/repository/svn/diff/#{path}" => "repositories#diff",
82
        :id => 'foo', :repository_id => 'svn', :path => path
83
    end
76 84
  end
77 85

  
78 86
  def test_repositories_related_issues_with_repository_id
(1-1/2)