Project

General

Profile

Feature #33129 » 33129-recent-projects-box.patch

Go MAEDA, 2026-03-16 05:37

View differences:

app/controllers/welcome_controller.rb
24 24

  
25 25
  def index
26 26
    @news = News.latest User.current
27
    @projects = Redmine::ProjectJumpBox.new(User.current).recently_used_projects
27 28
  end
28 29

  
29 30
  def robots
app/views/welcome/index.html.erb
9 9
</div>
10 10

  
11 11
<div class="splitcontentright">
12
  <% if @projects.any? %>
13
  <div class="projects box">
14
    <h3 class="icon icon-projects"><%= sprite_icon('projects', l(:label_project_recently_used)) %></h3>
15
    <ul>
16
      <% @projects.each do |project| %>
17
      <li><%= link_to_project project %></li>
18
      <% end %>
19
    </ul>
20
    <%= link_to l(:label_project_view_all), :controller => 'projects' %>
21
  </div>
22
  <% end %>
12 23
  <% if @news.any? %>
13 24
  <div class="news box">
14 25
  <h3 class="icon icon-news"><%= sprite_icon('news', l(:label_news_latest))%></h3>
config/locales/en.yml
640 640
    other: "%{count} projects"
641 641
  label_project_all: All Projects
642 642
  label_project_latest: Latest projects
643
  label_project_recently_used: Recently used projects
644
  label_project_view_all: View all projects
643 645
  label_issue: Issue
644 646
  label_issue_new: New issue
645 647
  label_issue_plural: Issues
config/locales/ja.yml
1279 1279
  label_import_notifications: インポート中のメール通知
1280 1280
  text_gs_available: ImageMagickのPDFサポートが利用可能 (オプション)
1281 1281
  field_recently_used_projects: 最近使用したプロジェクトの表示件数
1282
  label_project_recently_used: 最近使用したプロジェクト
1283
  label_project_view_all: すべてのプロジェクトを表示
1282 1284
  label_optgroup_bookmarks: ブックマーク
1283 1285
  label_optgroup_recents: 最近使用したもの
1284 1286
  button_project_bookmark: ブックマークに追加
test/functional/welcome_controller_test.rb
31 31
    assert_select 'h3', :text => 'Latest news'
32 32
  end
33 33

  
34
  def test_index_should_display_recently_used_projects
35
    user = User.find(2)
36
    jump_box = Redmine::ProjectJumpBox.new(user)
37
    jump_box.project_used(Project.find('ecookbook'))
38
    jump_box.project_used(Project.find('onlinestore'))
39
    @request.session[:user_id] = user.id
40

  
41
    get :index
42

  
43
    assert_select 'div.projects.box' do
44
      assert_select 'h3', :text => 'Recently used projects'
45
      assert_select 'li', :count => 2
46
      assert_select 'li:nth-child(1) a', :text => 'OnlineStore'
47
      assert_select 'li:nth-child(2) a', :text => 'eCookbook'
48
      assert_select 'a[href="/projects"]', :text => 'View all projects'
49
    end
50
  end
51

  
52
  def test_index_should_not_display_recently_used_projects_for_anonymous
53
    jump_box = Redmine::ProjectJumpBox.new(User.find(2))
54
    jump_box.project_used(Project.find('ecookbook'))
55

  
56
    get :index
57

  
58
    assert_select 'div.projects.box', :count => 0
59
  end
60

  
34 61
  def test_browser_language
35 62
    @request.env['HTTP_ACCEPT_LANGUAGE'] = 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3'
36 63
    get :index
(3-3/3)