##// END OF EJS Templates
Fixed links to versions anchors on the roadmap....
Jean-Philippe Lang -
r8580:1fa341df1cfb
parent child
Show More
@@ -1,68 +1,68
1 1 <div class="contextual">
2 2 <%= link_to l(:label_version_new), new_project_version_path(@project), :class => 'icon icon-add' if User.current.allowed_to?(:manage_versions, @project) %>
3 3 </div>
4 4
5 5 <h2><%=l(:label_roadmap)%></h2>
6 6
7 7 <% if @versions.empty? %>
8 8 <p class="nodata"><%= l(:label_no_data) %></p>
9 9 <% else %>
10 10 <div id="roadmap">
11 11 <% @versions.each do |version| %>
12 12 <h3 class="version"><%= tag 'a', :name => anchor(version.name) %><%= link_to_version version %></h3>
13 13 <%= render :partial => 'versions/overview', :locals => {:version => version} %>
14 14 <%= render(:partial => "wiki/content", :locals => {:content => version.wiki_page.content}) if version.wiki_page %>
15 15
16 16 <% if (issues = @issues_by_version[version]) && issues.size > 0 %>
17 17 <% form_tag({}) do -%>
18 18 <table class="list related-issues">
19 19 <caption><%= l(:label_related_issues) %></caption>
20 20 <% issues.each do |issue| -%>
21 21 <tr class="hascontextmenu">
22 22 <td class="checkbox"><%= check_box_tag 'ids[]', issue.id, false, :id => nil %></td>
23 23 <td><%= link_to_issue(issue, :project => (@project != issue.project)) %></td>
24 24 </tr>
25 25 <% end -%>
26 26 </table>
27 27 <% end %>
28 28 <% end %>
29 29 <%= call_hook :view_projects_roadmap_version_bottom, :version => version %>
30 30 <% end %>
31 31 </div>
32 32 <% end %>
33 33
34 34 <% content_for :sidebar do %>
35 35 <% form_tag({}, :method => :get) do %>
36 36 <h3><%= l(:label_roadmap) %></h3>
37 37 <% @trackers.each do |tracker| %>
38 38 <label><%= check_box_tag "tracker_ids[]", tracker.id, (@selected_tracker_ids.include? tracker.id.to_s), :id => nil %>
39 39 <%=h tracker.name %></label><br />
40 40 <% end %>
41 41 <br />
42 42 <label for="completed"><%= check_box_tag "completed", 1, params[:completed] %> <%= l(:label_show_completed_versions) %></label>
43 43 <% if @project.descendants.active.any? %>
44 44 <%= hidden_field_tag 'with_subprojects', 0 %>
45 45 <br /><label><%= check_box_tag 'with_subprojects', 1, @with_subprojects %> <%=l(:label_subproject_plural)%></label>
46 46 <% end %>
47 47 <p><%= submit_tag l(:button_apply), :class => 'button-small', :name => nil %></p>
48 48 <% end %>
49 49
50 50 <h3><%= l(:label_version_plural) %></h3>
51 51 <% @versions.each do |version| %>
52 <%= link_to format_version_name(version), :anchor => anchor(version.name) %><br />
52 <%= link_to format_version_name(version), "##{anchor(version.name)}" %><br />
53 53 <% end %>
54 54 <% if @completed_versions.present? %>
55 55 <p>
56 56 <%= link_to_function l(:label_completed_versions),
57 57 'Element.toggleClassName("toggle-completed-versions", "collapsed"); Element.toggle("completed-versions")',
58 58 :id => 'toggle-completed-versions', :class => 'collapsible collapsed' %><br />
59 59 <span id="completed-versions" style="display:none;">
60 60 <%= @completed_versions.map {|version| link_to format_version_name(version), version_path(version)}.join("<br />\n".html_safe) %>
61 61 </span>
62 62 </p>
63 63 <% end %>
64 64 <% end %>
65 65
66 66 <% html_title(l(:label_roadmap)) %>
67 67
68 68 <%= context_menu issues_context_menu_path %>
@@ -1,184 +1,187
1 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2011 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 require File.expand_path('../../test_helper', __FILE__)
19 19 require 'versions_controller'
20 20
21 21 # Re-raise errors caught by the controller.
22 22 class VersionsController; def rescue_action(e) raise e end; end
23 23
24 24 class VersionsControllerTest < ActionController::TestCase
25 25 fixtures :projects, :versions, :issues, :users, :roles, :members, :member_roles, :enabled_modules, :issue_statuses
26 26
27 27 def setup
28 28 @controller = VersionsController.new
29 29 @request = ActionController::TestRequest.new
30 30 @response = ActionController::TestResponse.new
31 31 User.current = nil
32 32 end
33 33
34 34 def test_index
35 35 get :index, :project_id => 1
36 36 assert_response :success
37 37 assert_template 'index'
38 38 assert_not_nil assigns(:versions)
39 39 # Version with no date set appears
40 40 assert assigns(:versions).include?(Version.find(3))
41 41 # Completed version doesn't appear
42 42 assert !assigns(:versions).include?(Version.find(1))
43 43 # Context menu on issues
44 44 assert_select "script", :text => Regexp.new(Regexp.escape("new ContextMenu('/issues/context_menu')"))
45 # Links to versions anchors
46 assert_tag 'a', :attributes => {:href => '#2.0'},
47 :ancestor => {:tag => 'div', :attributes => {:id => 'sidebar'}}
45 48 # Links to completed versions in the sidebar
46 49 assert_tag 'a', :attributes => {:href => '/versions/1'},
47 50 :ancestor => {:tag => 'div', :attributes => {:id => 'sidebar'}}
48 51 end
49 52
50 53 def test_index_with_completed_versions
51 54 get :index, :project_id => 1, :completed => 1
52 55 assert_response :success
53 56 assert_template 'index'
54 57 assert_not_nil assigns(:versions)
55 58 # Version with no date set appears
56 59 assert assigns(:versions).include?(Version.find(3))
57 60 # Completed version appears
58 61 assert assigns(:versions).include?(Version.find(1))
59 62 end
60 63
61 64 def test_index_with_tracker_ids
62 65 get :index, :project_id => 1, :tracker_ids => [1, 3]
63 66 assert_response :success
64 67 assert_template 'index'
65 68 assert_not_nil assigns(:issues_by_version)
66 69 assert_nil assigns(:issues_by_version).values.flatten.detect {|issue| issue.tracker_id == 2}
67 70 end
68 71
69 72 def test_index_showing_subprojects_versions
70 73 @subproject_version = Version.generate!(:project => Project.find(3))
71 74 get :index, :project_id => 1, :with_subprojects => 1
72 75 assert_response :success
73 76 assert_template 'index'
74 77 assert_not_nil assigns(:versions)
75 78
76 79 assert assigns(:versions).include?(Version.find(4)), "Shared version not found"
77 80 assert assigns(:versions).include?(@subproject_version), "Subproject version not found"
78 81 end
79 82
80 83 def test_show
81 84 get :show, :id => 2
82 85 assert_response :success
83 86 assert_template 'show'
84 87 assert_not_nil assigns(:version)
85 88
86 89 assert_tag :tag => 'h2', :content => /1.0/
87 90 end
88 91
89 92 def test_new
90 93 @request.session[:user_id] = 2
91 94 get :new, :project_id => '1'
92 95 assert_response :success
93 96 assert_template 'new'
94 97 end
95 98
96 99 def test_create
97 100 @request.session[:user_id] = 2 # manager
98 101 assert_difference 'Version.count' do
99 102 post :create, :project_id => '1', :version => {:name => 'test_add_version'}
100 103 end
101 104 assert_redirected_to '/projects/ecookbook/settings/versions'
102 105 version = Version.find_by_name('test_add_version')
103 106 assert_not_nil version
104 107 assert_equal 1, version.project_id
105 108 end
106 109
107 110 def test_create_from_issue_form
108 111 @request.session[:user_id] = 2 # manager
109 112 assert_difference 'Version.count' do
110 113 xhr :post, :create, :project_id => '1', :version => {:name => 'test_add_version_from_issue_form'}
111 114 end
112 115 assert_response :success
113 116 assert_select_rjs :replace, 'issue_fixed_version_id'
114 117 version = Version.find_by_name('test_add_version_from_issue_form')
115 118 assert_not_nil version
116 119 assert_equal 1, version.project_id
117 120 end
118 121
119 122 def test_get_edit
120 123 @request.session[:user_id] = 2
121 124 get :edit, :id => 2
122 125 assert_response :success
123 126 assert_template 'edit'
124 127 end
125 128
126 129 def test_close_completed
127 130 Version.update_all("status = 'open'")
128 131 @request.session[:user_id] = 2
129 132 put :close_completed, :project_id => 'ecookbook'
130 133 assert_redirected_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => 'ecookbook'
131 134 assert_not_nil Version.find_by_status('closed')
132 135 end
133 136
134 137 def test_post_update
135 138 @request.session[:user_id] = 2
136 139 put :update, :id => 2,
137 140 :version => { :name => 'New version name',
138 141 :effective_date => Date.today.strftime("%Y-%m-%d")}
139 142 assert_redirected_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => 'ecookbook'
140 143 version = Version.find(2)
141 144 assert_equal 'New version name', version.name
142 145 assert_equal Date.today, version.effective_date
143 146 end
144 147
145 148 def test_post_update_with_validation_failure
146 149 @request.session[:user_id] = 2
147 150 put :update, :id => 2,
148 151 :version => { :name => '',
149 152 :effective_date => Date.today.strftime("%Y-%m-%d")}
150 153 assert_response :success
151 154 assert_template 'edit'
152 155 end
153 156
154 157 def test_destroy
155 158 @request.session[:user_id] = 2
156 159 assert_difference 'Version.count', -1 do
157 160 delete :destroy, :id => 3
158 161 end
159 162 assert_redirected_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => 'ecookbook'
160 163 assert_nil Version.find_by_id(3)
161 164 end
162 165
163 166 def test_destroy_version_in_use_should_fail
164 167 @request.session[:user_id] = 2
165 168 assert_no_difference 'Version.count' do
166 169 delete :destroy, :id => 2
167 170 end
168 171 assert_redirected_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => 'ecookbook'
169 172 assert flash[:error].match(/Unable to delete version/)
170 173 assert Version.find_by_id(2)
171 174 end
172 175
173 176 def test_issue_status_by
174 177 xhr :get, :status_by, :id => 2
175 178 assert_response :success
176 179 assert_template '_issue_counts'
177 180 end
178 181
179 182 def test_issue_status_by_status
180 183 xhr :get, :status_by, :id => 2, :status_by => 'status'
181 184 assert_response :success
182 185 assert_template '_issue_counts'
183 186 end
184 187 end
General Comments 0
You need to be logged in to leave comments. Login now