fixed-33953.patch

Yuichi HARADA, 2020-11-06 08:27

Download (4.09 KB)

View differences:

app/controllers/repositories_controller.rb
321 321
    if params[:repository_id].present?
322 322
      @repository = @project.repositories.find_by_identifier_param(params[:repository_id])
323 323
    else
324
      @repository = @project.repository
324
      @repository = @project.repository || @project.repositories.first
325 325
    end
326 326
    (render_404; return false) unless @repository
327 327
    @path = params[:path].is_a?(Array) ? params[:path].join('/') : params[:path].to_s
lib/redmine.rb
346 346
  menu.push :repository,
347 347
            {:controller => 'repositories', :action => 'show',
348 348
             :repository_id => nil, :path => nil, :rev => nil},
349
            :if => Proc.new {|p| p.repository && !p.repository.new_record?}
349
            :if => Proc.new {|p| p.repositories.any?{|r| !r.new_record?}}
350 350
  menu.push :settings, {:controller => 'projects', :action => 'settings'},
351 351
            :last => true
352 352
end
test/functional/repositories_controller_test.rb
188 188
    end
189 189
  end
190 190

  
191
  def test_show_without_main_repository_should_browse_first_repository
192
    project = Project.find(1)
193
    repos = project.repositories
194
    repos << Repository::Subversion.create(:identifier => 'test', :url => 'svn://valid')
195
    assert_equal true, repos.exists?(:is_default => true)
196

  
197
    repos.update_all(:is_default => false)
198
    repos.reload
199
    assert_equal false, repos.exists?(:is_default => true)
200

  
201
    repository = repos.first
202
    @request.session[:user_id] = 2
203

  
204
    get(:show, :params => {:id => 1})
205
    assert_response :success
206
    assert_select '#sidebar' do
207
      assert_select 'a.repository.selected[href=?]', "/projects/#{project.identifier}/repository/#{repository.identifier_param}"
208
    end
209
  end
210

  
191 211
  if repository_configured?('subversion')
192 212
    def test_show_should_show_diff_button_depending_on_browse_repository_permission
193 213
      @request.session[:user_id] = 2
test/integration/lib/redmine/menu_manager_test.rb
28 28
           :roles,
29 29
           :member_roles,
30 30
           :members,
31
           :enabled_modules
31
           :enabled_modules,
32
           :repositories
32 33

  
33 34
  def test_project_menu_with_specific_locale
34 35
    get '/projects/ecookbook/issues',
......
80 81
    end
81 82
  end
82 83

  
84
  def test_project_menu_should_display_repository_tab_when_exists_repository
85
    project = Project.find('ecookbook')
86
    repos = project.repositories
87
    assert_equal true, repos.exists?
88

  
89
    log_user('jsmith', 'jsmith')
90

  
91
    assert_equal true, repos.exists?(:is_default => true)
92
    get '/projects/ecookbook'
93
    assert_select '#main-menu' do
94
      assert_select 'a.repository', :count => 1
95
    end
96

  
97
    repos.update_all(:is_default => false)
98
    assert_equal false, repos.exists?(:is_default => true)
99
    get '/projects/ecookbook'
100
    assert_select '#main-menu' do
101
      assert_select 'a.repository', :count => 1
102
    end
103

  
104
    repos.delete_all
105
    assert_equal false, repos.exists?
106
    get '/projects/ecookbook'
107
    assert_select '#main-menu' do
108
      assert_select 'a.repository', :count => 0
109
    end
110
  end
111

  
83 112
  def test_main_menu_should_select_projects_tab_on_project_list
84 113
    get '/projects'
85 114
    assert_select '#main-menu' do