@@ -0,0 +1,46 | |||
|
1 | # redMine - project management software | |
|
2 | # Copyright (C) 2006-2007 Jean-Philippe Lang | |
|
3 | # | |
|
4 | # This program is free software; you can redistribute it and/or | |
|
5 | # modify it under the terms of the GNU General Public License | |
|
6 | # as published by the Free Software Foundation; either version 2 | |
|
7 | # of the License, or (at your option) any later version. | |
|
8 | # | |
|
9 | # This program is distributed in the hope that it will be useful, | |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
12 | # GNU General Public License for more details. | |
|
13 | # | |
|
14 | # You should have received a copy of the GNU General Public License | |
|
15 | # along with this program; if not, write to the Free Software | |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
|
17 | ||
|
18 | require File.dirname(__FILE__) + '/../test_helper' | |
|
19 | require 'repositories_controller' | |
|
20 | ||
|
21 | # Re-raise errors caught by the controller. | |
|
22 | class RepositoriesController; def rescue_action(e) raise e end; end | |
|
23 | ||
|
24 | class RepositoriesControllerTest < Test::Unit::TestCase | |
|
25 | fixtures :projects, :users, :roles, :members, :repositories, :issues, :issue_statuses, :changesets, :changes, :issue_categories, :enumerations, :custom_fields, :custom_values, :trackers | |
|
26 | ||
|
27 | def setup | |
|
28 | @controller = RepositoriesController.new | |
|
29 | @request = ActionController::TestRequest.new | |
|
30 | @response = ActionController::TestResponse.new | |
|
31 | User.current = nil | |
|
32 | end | |
|
33 | ||
|
34 | def test_revision_with_before_nil_and_afer_normal | |
|
35 | get :revision, {:id => 1, :rev => 1} | |
|
36 | assert_response :success | |
|
37 | assert_template 'revision' | |
|
38 | assert_no_tag :tag => "div", :attributes => { :class => "contextual" }, | |
|
39 | :child => { :tag => "a", :attributes => { :href => '/repositories/revision/1?rev=0'} | |
|
40 | } | |
|
41 | assert_tag :tag => "div", :attributes => { :class => "contextual" }, | |
|
42 | :child => { :tag => "a", :attributes => { :href => '/repositories/revision/1?rev=2'} | |
|
43 | } | |
|
44 | end | |
|
45 | ||
|
46 | end |
@@ -1,264 +1,272 | |||
|
1 | 1 | # redMine - project management software |
|
2 | 2 | # Copyright (C) 2006-2007 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 'SVG/Graph/Bar' |
|
19 | 19 | require 'SVG/Graph/BarHorizontal' |
|
20 | 20 | require 'digest/sha1' |
|
21 | 21 | |
|
22 | class ChangesetNotFound < Exception | |
|
23 | end | |
|
24 | ||
|
22 | 25 | class RepositoriesController < ApplicationController |
|
23 | 26 | layout 'base' |
|
24 | 27 | before_filter :find_repository, :except => :edit |
|
25 | 28 | before_filter :find_project, :only => :edit |
|
26 | 29 | before_filter :authorize |
|
27 | 30 | accept_key_auth :revisions |
|
28 | 31 | |
|
29 | 32 | def edit |
|
30 | 33 | @repository = @project.repository |
|
31 | 34 | if !@repository |
|
32 | 35 | @repository = Repository.factory(params[:repository_scm]) |
|
33 | 36 | @repository.project = @project |
|
34 | 37 | end |
|
35 | 38 | if request.post? |
|
36 | 39 | @repository.attributes = params[:repository] |
|
37 | 40 | @repository.save |
|
38 | 41 | end |
|
39 | 42 | render(:update) {|page| page.replace_html "tab-content-repository", :partial => 'projects/settings/repository'} |
|
40 | 43 | end |
|
41 | 44 | |
|
42 | 45 | def destroy |
|
43 | 46 | @repository.destroy |
|
44 | 47 | redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'repository' |
|
45 | 48 | end |
|
46 | 49 | |
|
47 | 50 | def show |
|
48 | 51 | # check if new revisions have been committed in the repository |
|
49 | 52 | @repository.fetch_changesets if Setting.autofetch_changesets? |
|
50 | 53 | # get entries for the browse frame |
|
51 | 54 | @entries = @repository.entries('') |
|
52 | 55 | # latest changesets |
|
53 | 56 | @changesets = @repository.changesets.find(:all, :limit => 10, :order => "committed_on DESC") |
|
54 | 57 | show_error and return unless @entries || @changesets.any? |
|
55 | 58 | end |
|
56 | 59 | |
|
57 | 60 | def browse |
|
58 | 61 | @entries = @repository.entries(@path, @rev) |
|
59 | 62 | if request.xhr? |
|
60 | 63 | @entries ? render(:partial => 'dir_list_content') : render(:nothing => true) |
|
61 | 64 | else |
|
62 | 65 | show_error unless @entries |
|
63 | 66 | end |
|
64 | 67 | end |
|
65 | 68 | |
|
66 | 69 | def changes |
|
67 | 70 | @entry = @repository.scm.entry(@path, @rev) |
|
68 | 71 | show_error and return unless @entry |
|
69 | 72 | @changesets = @repository.changesets_for_path(@path) |
|
70 | 73 | end |
|
71 | 74 | |
|
72 | 75 | def revisions |
|
73 | 76 | @changeset_count = @repository.changesets.count |
|
74 | 77 | @changeset_pages = Paginator.new self, @changeset_count, |
|
75 | 78 | 25, |
|
76 | 79 | params['page'] |
|
77 | 80 | @changesets = @repository.changesets.find(:all, |
|
78 | 81 | :limit => @changeset_pages.items_per_page, |
|
79 | 82 | :offset => @changeset_pages.current.offset) |
|
80 | 83 | |
|
81 | 84 | respond_to do |format| |
|
82 | 85 | format.html { render :layout => false if request.xhr? } |
|
83 | 86 | format.atom { render_feed(@changesets, :title => "#{@project.name}: #{l(:label_revision_plural)}") } |
|
84 | 87 | end |
|
85 | 88 | end |
|
86 | 89 | |
|
87 | 90 | def entry |
|
88 | 91 | @content = @repository.scm.cat(@path, @rev) |
|
89 | 92 | show_error and return unless @content |
|
90 | 93 | if 'raw' == params[:format] |
|
91 | 94 | send_data @content, :filename => @path.split('/').last |
|
92 | 95 | end |
|
93 | 96 | end |
|
94 | 97 | |
|
95 | 98 | def revision |
|
96 | 99 | @changeset = @repository.changesets.find_by_revision(@rev) |
|
97 |
s |
|
|
100 | raise ChangesetNotFound unless @changeset | |
|
98 | 101 | @changes_count = @changeset.changes.size |
|
99 | 102 | @changes_pages = Paginator.new self, @changes_count, 150, params['page'] |
|
100 | 103 | @changes = @changeset.changes.find(:all, |
|
101 | 104 | :limit => @changes_pages.items_per_page, |
|
102 | 105 | :offset => @changes_pages.current.offset) |
|
103 | 106 | |
|
104 | render :action => "revision", :layout => false if request.xhr? | |
|
107 | respond_to do |format| | |
|
108 | format.html | |
|
109 | format.js {render :layout => false} | |
|
110 | end | |
|
111 | rescue ChangesetNotFound | |
|
112 | show_error | |
|
105 | 113 | end |
|
106 | 114 | |
|
107 | 115 | def diff |
|
108 | 116 | @rev_to = params[:rev_to] ? params[:rev_to].to_i : (@rev - 1) |
|
109 | 117 | @diff_type = params[:type] || User.current.pref[:diff_type] || 'inline' |
|
110 | 118 | @diff_type = 'inline' unless %w(inline sbs).include?(@diff_type) |
|
111 | 119 | |
|
112 | 120 | # Save diff type as user preference |
|
113 | 121 | if User.current.logged? && @diff_type != User.current.pref[:diff_type] |
|
114 | 122 | User.current.pref[:diff_type] = @diff_type |
|
115 | 123 | User.current.preference.save |
|
116 | 124 | end |
|
117 | 125 | |
|
118 | 126 | @cache_key = "repositories/diff/#{@repository.id}/" + Digest::MD5.hexdigest("#{@path}-#{@rev}-#{@rev_to}-#{@diff_type}") |
|
119 | 127 | unless read_fragment(@cache_key) |
|
120 | 128 | @diff = @repository.diff(@path, @rev, @rev_to, @diff_type) |
|
121 | 129 | show_error and return unless @diff |
|
122 | 130 | end |
|
123 | 131 | end |
|
124 | 132 | |
|
125 | 133 | def stats |
|
126 | 134 | end |
|
127 | 135 | |
|
128 | 136 | def graph |
|
129 | 137 | data = nil |
|
130 | 138 | case params[:graph] |
|
131 | 139 | when "commits_per_month" |
|
132 | 140 | data = graph_commits_per_month(@repository) |
|
133 | 141 | when "commits_per_author" |
|
134 | 142 | data = graph_commits_per_author(@repository) |
|
135 | 143 | end |
|
136 | 144 | if data |
|
137 | 145 | headers["Content-Type"] = "image/svg+xml" |
|
138 | 146 | send_data(data, :type => "image/svg+xml", :disposition => "inline") |
|
139 | 147 | else |
|
140 | 148 | render_404 |
|
141 | 149 | end |
|
142 | 150 | end |
|
143 | 151 | |
|
144 | 152 | private |
|
145 | 153 | def find_project |
|
146 | 154 | @project = Project.find(params[:id]) |
|
147 | 155 | rescue ActiveRecord::RecordNotFound |
|
148 | 156 | render_404 |
|
149 | 157 | end |
|
150 | 158 | |
|
151 | 159 | def find_repository |
|
152 | 160 | @project = Project.find(params[:id]) |
|
153 | 161 | @repository = @project.repository |
|
154 | 162 | render_404 and return false unless @repository |
|
155 | 163 | @path = params[:path].join('/') unless params[:path].nil? |
|
156 | 164 | @path ||= '' |
|
157 | 165 | @rev = params[:rev].to_i if params[:rev] |
|
158 | 166 | rescue ActiveRecord::RecordNotFound |
|
159 | 167 | render_404 |
|
160 | 168 | end |
|
161 | 169 | |
|
162 | 170 | def show_error |
|
163 | 171 | flash.now[:error] = l(:notice_scm_error) |
|
164 | 172 | render :nothing => true, :layout => true |
|
165 | 173 | end |
|
166 | 174 | |
|
167 | 175 | def graph_commits_per_month(repository) |
|
168 | 176 | @date_to = Date.today |
|
169 | 177 | @date_from = @date_to << 11 |
|
170 | 178 | @date_from = Date.civil(@date_from.year, @date_from.month, 1) |
|
171 | 179 | commits_by_day = repository.changesets.count(:all, :group => :commit_date, :conditions => ["commit_date BETWEEN ? AND ?", @date_from, @date_to]) |
|
172 | 180 | commits_by_month = [0] * 12 |
|
173 | 181 | commits_by_day.each {|c| commits_by_month[c.first.to_date.months_ago] += c.last } |
|
174 | 182 | |
|
175 | 183 | changes_by_day = repository.changes.count(:all, :group => :commit_date, :conditions => ["commit_date BETWEEN ? AND ?", @date_from, @date_to]) |
|
176 | 184 | changes_by_month = [0] * 12 |
|
177 | 185 | changes_by_day.each {|c| changes_by_month[c.first.to_date.months_ago] += c.last } |
|
178 | 186 | |
|
179 | 187 | fields = [] |
|
180 | 188 | month_names = l(:actionview_datehelper_select_month_names_abbr).split(',') |
|
181 | 189 | 12.times {|m| fields << month_names[((Date.today.month - 1 - m) % 12)]} |
|
182 | 190 | |
|
183 | 191 | graph = SVG::Graph::Bar.new( |
|
184 | 192 | :height => 300, |
|
185 | 193 | :width => 500, |
|
186 | 194 | :fields => fields.reverse, |
|
187 | 195 | :stack => :side, |
|
188 | 196 | :scale_integers => true, |
|
189 | 197 | :step_x_labels => 2, |
|
190 | 198 | :show_data_values => false, |
|
191 | 199 | :graph_title => l(:label_commits_per_month), |
|
192 | 200 | :show_graph_title => true |
|
193 | 201 | ) |
|
194 | 202 | |
|
195 | 203 | graph.add_data( |
|
196 | 204 | :data => commits_by_month[0..11].reverse, |
|
197 | 205 | :title => l(:label_revision_plural) |
|
198 | 206 | ) |
|
199 | 207 | |
|
200 | 208 | graph.add_data( |
|
201 | 209 | :data => changes_by_month[0..11].reverse, |
|
202 | 210 | :title => l(:label_change_plural) |
|
203 | 211 | ) |
|
204 | 212 | |
|
205 | 213 | graph.burn |
|
206 | 214 | end |
|
207 | 215 | |
|
208 | 216 | def graph_commits_per_author(repository) |
|
209 | 217 | commits_by_author = repository.changesets.count(:all, :group => :committer) |
|
210 | 218 | commits_by_author.sort! {|x, y| x.last <=> y.last} |
|
211 | 219 | |
|
212 | 220 | changes_by_author = repository.changes.count(:all, :group => :committer) |
|
213 | 221 | h = changes_by_author.inject({}) {|o, i| o[i.first] = i.last; o} |
|
214 | 222 | |
|
215 | 223 | fields = commits_by_author.collect {|r| r.first} |
|
216 | 224 | commits_data = commits_by_author.collect {|r| r.last} |
|
217 | 225 | changes_data = commits_by_author.collect {|r| h[r.first] || 0} |
|
218 | 226 | |
|
219 | 227 | fields = fields + [""]*(10 - fields.length) if fields.length<10 |
|
220 | 228 | commits_data = commits_data + [0]*(10 - commits_data.length) if commits_data.length<10 |
|
221 | 229 | changes_data = changes_data + [0]*(10 - changes_data.length) if changes_data.length<10 |
|
222 | 230 | |
|
223 | 231 | graph = SVG::Graph::BarHorizontal.new( |
|
224 | 232 | :height => 300, |
|
225 | 233 | :width => 500, |
|
226 | 234 | :fields => fields, |
|
227 | 235 | :stack => :side, |
|
228 | 236 | :scale_integers => true, |
|
229 | 237 | :show_data_values => false, |
|
230 | 238 | :rotate_y_labels => false, |
|
231 | 239 | :graph_title => l(:label_commits_per_author), |
|
232 | 240 | :show_graph_title => true |
|
233 | 241 | ) |
|
234 | 242 | |
|
235 | 243 | graph.add_data( |
|
236 | 244 | :data => commits_data, |
|
237 | 245 | :title => l(:label_revision_plural) |
|
238 | 246 | ) |
|
239 | 247 | |
|
240 | 248 | graph.add_data( |
|
241 | 249 | :data => changes_data, |
|
242 | 250 | :title => l(:label_change_plural) |
|
243 | 251 | ) |
|
244 | 252 | |
|
245 | 253 | graph.burn |
|
246 | 254 | end |
|
247 | 255 | |
|
248 | 256 | end |
|
249 | 257 | |
|
250 | 258 | class Date |
|
251 | 259 | def months_ago(date = Date.today) |
|
252 | 260 | (date.year - self.year)*12 + (date.month - self.month) |
|
253 | 261 | end |
|
254 | 262 | |
|
255 | 263 | def weeks_ago(date = Date.today) |
|
256 | 264 | (date.year - self.year)*52 + (date.cweek - self.cweek) |
|
257 | 265 | end |
|
258 | 266 | end |
|
259 | 267 | |
|
260 | 268 | class String |
|
261 | 269 | def with_leading_slash |
|
262 | 270 | starts_with?('/') ? self : "/#{self}" |
|
263 | 271 | end |
|
264 | 272 | end |
@@ -1,172 +1,172 | |||
|
1 | 1 | # redMine - project management software |
|
2 | 2 | # Copyright (C) 2006-2007 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 | class TimelogController < ApplicationController |
|
19 | 19 | layout 'base' |
|
20 | 20 | before_filter :find_project, :authorize |
|
21 | 21 | |
|
22 | 22 | helper :sort |
|
23 | 23 | include SortHelper |
|
24 | 24 | helper :issues |
|
25 | 25 | |
|
26 | 26 | def report |
|
27 | 27 | @available_criterias = { 'version' => {:sql => "#{Issue.table_name}.fixed_version_id", |
|
28 | 28 | :values => @project.versions, |
|
29 | 29 | :label => :label_version}, |
|
30 | 30 | 'category' => {:sql => "#{Issue.table_name}.category_id", |
|
31 | 31 | :values => @project.issue_categories, |
|
32 | 32 | :label => :field_category}, |
|
33 | 33 | 'member' => {:sql => "#{TimeEntry.table_name}.user_id", |
|
34 | 34 | :values => @project.users, |
|
35 | 35 | :label => :label_member}, |
|
36 | 36 | 'tracker' => {:sql => "#{Issue.table_name}.tracker_id", |
|
37 | 37 | :values => Tracker.find(:all), |
|
38 | 38 | :label => :label_tracker}, |
|
39 | 39 | 'activity' => {:sql => "#{TimeEntry.table_name}.activity_id", |
|
40 | 40 | :values => Enumeration::get_values('ACTI'), |
|
41 | 41 | :label => :label_activity} |
|
42 | 42 | } |
|
43 | 43 | |
|
44 | 44 | @criterias = params[:criterias] || [] |
|
45 | 45 | @criterias = @criterias.select{|criteria| @available_criterias.has_key? criteria} |
|
46 | 46 | @criterias.uniq! |
|
47 | 47 | |
|
48 | 48 | @columns = (params[:period] && %w(year month week).include?(params[:period])) ? params[:period] : 'month' |
|
49 | 49 | |
|
50 | 50 | if params[:date_from] |
|
51 | 51 | begin; @date_from = params[:date_from].to_date; rescue; end |
|
52 | 52 | end |
|
53 | 53 | if params[:date_to] |
|
54 | 54 | begin; @date_to = params[:date_to].to_date; rescue; end |
|
55 | 55 | end |
|
56 | 56 | @date_from ||= Date.civil(Date.today.year, 1, 1) |
|
57 |
@date_to ||= Date.civil(Date.today.year, Date.today.month |
|
|
57 | @date_to ||= (Date.civil(Date.today.year, Date.today.month, 1) >> 1) - 1 | |
|
58 | 58 | |
|
59 | 59 | unless @criterias.empty? |
|
60 | 60 | sql_select = @criterias.collect{|criteria| @available_criterias[criteria][:sql] + " AS " + criteria}.join(', ') |
|
61 | 61 | sql_group_by = @criterias.collect{|criteria| @available_criterias[criteria][:sql]}.join(', ') |
|
62 | 62 | |
|
63 | 63 | sql = "SELECT #{sql_select}, tyear, tmonth, tweek, SUM(hours) AS hours" |
|
64 | 64 | sql << " FROM #{TimeEntry.table_name} LEFT JOIN #{Issue.table_name} ON #{TimeEntry.table_name}.issue_id = #{Issue.table_name}.id" |
|
65 | 65 | sql << " WHERE #{TimeEntry.table_name}.project_id = %s" % @project.id |
|
66 | 66 | sql << " AND spent_on BETWEEN '%s' AND '%s'" % [ActiveRecord::Base.connection.quoted_date(@date_from.to_time), ActiveRecord::Base.connection.quoted_date(@date_to.to_time)] |
|
67 | 67 | sql << " GROUP BY #{sql_group_by}, tyear, tmonth, tweek" |
|
68 | 68 | |
|
69 | 69 | @hours = ActiveRecord::Base.connection.select_all(sql) |
|
70 | 70 | |
|
71 | 71 | @hours.each do |row| |
|
72 | 72 | case @columns |
|
73 | 73 | when 'year' |
|
74 | 74 | row['year'] = row['tyear'] |
|
75 | 75 | when 'month' |
|
76 | 76 | row['month'] = "#{row['tyear']}-#{row['tmonth']}" |
|
77 | 77 | when 'week' |
|
78 | 78 | row['week'] = "#{row['tyear']}-#{row['tweek']}" |
|
79 | 79 | end |
|
80 | 80 | end |
|
81 | 81 | end |
|
82 | 82 | |
|
83 | 83 | @periods = [] |
|
84 | 84 | date_from = @date_from |
|
85 | 85 | # 100 columns max |
|
86 | 86 | while date_from < @date_to && @periods.length < 100 |
|
87 | 87 | case @columns |
|
88 | 88 | when 'year' |
|
89 | 89 | @periods << "#{date_from.year}" |
|
90 | 90 | date_from = date_from >> 12 |
|
91 | 91 | when 'month' |
|
92 | 92 | @periods << "#{date_from.year}-#{date_from.month}" |
|
93 | 93 | date_from = date_from >> 1 |
|
94 | 94 | when 'week' |
|
95 | 95 | @periods << "#{date_from.year}-#{date_from.cweek}" |
|
96 | 96 | date_from = date_from + 7 |
|
97 | 97 | end |
|
98 | 98 | end |
|
99 | 99 | |
|
100 | 100 | render :layout => false if request.xhr? |
|
101 | 101 | end |
|
102 | 102 | |
|
103 | 103 | def details |
|
104 | 104 | sort_init 'spent_on', 'desc' |
|
105 | 105 | sort_update |
|
106 | 106 | |
|
107 | 107 | @entries = (@issue ? @issue : @project).time_entries.find(:all, :include => [:activity, :user, {:issue => [:tracker, :assigned_to, :priority]}], :order => sort_clause) |
|
108 | 108 | |
|
109 | 109 | @total_hours = @entries.inject(0) { |sum,entry| sum + entry.hours } |
|
110 | 110 | @owner_id = User.current.id |
|
111 | 111 | |
|
112 | 112 | send_csv and return if 'csv' == params[:export] |
|
113 | 113 | render :action => 'details', :layout => false if request.xhr? |
|
114 | 114 | end |
|
115 | 115 | |
|
116 | 116 | def edit |
|
117 | 117 | render_404 and return if @time_entry && @time_entry.user != User.current |
|
118 | 118 | @time_entry ||= TimeEntry.new(:project => @project, :issue => @issue, :user => User.current, :spent_on => Date.today) |
|
119 | 119 | @time_entry.attributes = params[:time_entry] |
|
120 | 120 | if request.post? and @time_entry.save |
|
121 | 121 | flash[:notice] = l(:notice_successful_update) |
|
122 | 122 | redirect_to :action => 'details', :project_id => @time_entry.project, :issue_id => @time_entry.issue |
|
123 | 123 | return |
|
124 | 124 | end |
|
125 | 125 | @activities = Enumeration::get_values('ACTI') |
|
126 | 126 | end |
|
127 | 127 | |
|
128 | 128 | private |
|
129 | 129 | def find_project |
|
130 | 130 | if params[:id] |
|
131 | 131 | @time_entry = TimeEntry.find(params[:id]) |
|
132 | 132 | @project = @time_entry.project |
|
133 | 133 | elsif params[:issue_id] |
|
134 | 134 | @issue = Issue.find(params[:issue_id]) |
|
135 | 135 | @project = @issue.project |
|
136 | 136 | elsif params[:project_id] |
|
137 | 137 | @project = Project.find(params[:project_id]) |
|
138 | 138 | else |
|
139 | 139 | render_404 |
|
140 | 140 | return false |
|
141 | 141 | end |
|
142 | 142 | end |
|
143 | 143 | |
|
144 | 144 | def send_csv |
|
145 | 145 | ic = Iconv.new(l(:general_csv_encoding), 'UTF-8') |
|
146 | 146 | export = StringIO.new |
|
147 | 147 | CSV::Writer.generate(export, l(:general_csv_separator)) do |csv| |
|
148 | 148 | # csv header fields |
|
149 | 149 | headers = [l(:field_spent_on), |
|
150 | 150 | l(:field_user), |
|
151 | 151 | l(:field_activity), |
|
152 | 152 | l(:field_issue), |
|
153 | 153 | l(:field_hours), |
|
154 | 154 | l(:field_comments) |
|
155 | 155 | ] |
|
156 | 156 | csv << headers.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end } |
|
157 | 157 | # csv lines |
|
158 | 158 | @entries.each do |entry| |
|
159 | 159 | fields = [l_date(entry.spent_on), |
|
160 | 160 | entry.user.name, |
|
161 | 161 | entry.activity.name, |
|
162 | 162 | (entry.issue ? entry.issue.id : nil), |
|
163 | 163 | entry.hours, |
|
164 | 164 | entry.comments |
|
165 | 165 | ] |
|
166 | 166 | csv << fields.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end } |
|
167 | 167 | end |
|
168 | 168 | end |
|
169 | 169 | export.rewind |
|
170 | 170 | send_data(export.read, :type => 'text/csv; header=present', :filename => 'export.csv') |
|
171 | 171 | end |
|
172 | 172 | end |
@@ -1,94 +1,104 | |||
|
1 | 1 | # redMine - project management software |
|
2 | 2 | # Copyright (C) 2006-2007 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 | class Changeset < ActiveRecord::Base |
|
19 | 19 | belongs_to :repository |
|
20 | 20 | has_many :changes, :dependent => :delete_all |
|
21 | 21 | has_and_belongs_to_many :issues |
|
22 | 22 | |
|
23 | 23 | acts_as_event :title => Proc.new {|o| "#{l(:label_revision)} #{o.revision}" + (o.comments.blank? ? '' : (': ' + o.comments))}, |
|
24 | 24 | :description => :comments, |
|
25 | 25 | :datetime => :committed_on, |
|
26 | 26 | :author => :committer, |
|
27 | 27 | :url => Proc.new {|o| {:controller => 'repositories', :action => 'revision', :id => o.repository.project_id, :rev => o.revision}} |
|
28 | 28 | |
|
29 | 29 | acts_as_searchable :columns => 'comments', |
|
30 | 30 | :include => :repository, |
|
31 | 31 | :project_key => "#{Repository.table_name}.project_id", |
|
32 | 32 | :date_column => 'committed_on' |
|
33 | 33 | |
|
34 | 34 | validates_presence_of :repository_id, :revision, :committed_on, :commit_date |
|
35 | 35 | validates_numericality_of :revision, :only_integer => true |
|
36 | 36 | validates_uniqueness_of :revision, :scope => :repository_id |
|
37 | 37 | validates_uniqueness_of :scmid, :scope => :repository_id, :allow_nil => true |
|
38 | 38 | |
|
39 | 39 | def comments=(comment) |
|
40 | 40 | write_attribute(:comments, comment.strip) |
|
41 | 41 | end |
|
42 | 42 | |
|
43 | 43 | def committed_on=(date) |
|
44 | 44 | self.commit_date = date |
|
45 | 45 | super |
|
46 | 46 | end |
|
47 | 47 | |
|
48 | 48 | def after_create |
|
49 | 49 | scan_comment_for_issue_ids |
|
50 | 50 | end |
|
51 | 51 | |
|
52 | 52 | def scan_comment_for_issue_ids |
|
53 | 53 | return if comments.blank? |
|
54 | 54 | # keywords used to reference issues |
|
55 | 55 | ref_keywords = Setting.commit_ref_keywords.downcase.split(",").collect(&:strip) |
|
56 | 56 | # keywords used to fix issues |
|
57 | 57 | fix_keywords = Setting.commit_fix_keywords.downcase.split(",").collect(&:strip) |
|
58 | 58 | # status and optional done ratio applied |
|
59 | 59 | fix_status = IssueStatus.find_by_id(Setting.commit_fix_status_id) |
|
60 | 60 | done_ratio = Setting.commit_fix_done_ratio.blank? ? nil : Setting.commit_fix_done_ratio.to_i |
|
61 | 61 | |
|
62 | 62 | kw_regexp = (ref_keywords + fix_keywords).collect{|kw| Regexp.escape(kw)}.join("|") |
|
63 | 63 | return if kw_regexp.blank? |
|
64 | 64 | |
|
65 | 65 | referenced_issues = [] |
|
66 | 66 | |
|
67 | 67 | if ref_keywords.delete('*') |
|
68 | 68 | # find any issue ID in the comments |
|
69 | 69 | target_issue_ids = [] |
|
70 | 70 | comments.scan(%r{([\s\(,-^])#(\d+)(?=[[:punct:]]|\s|<|$)}).each { |m| target_issue_ids << m[1] } |
|
71 | 71 | referenced_issues += repository.project.issues.find_all_by_id(target_issue_ids) |
|
72 | 72 | end |
|
73 | 73 | |
|
74 | 74 | comments.scan(Regexp.new("(#{kw_regexp})[\s:]+(([\s,;&]*#?\\d+)+)", Regexp::IGNORECASE)).each do |match| |
|
75 | 75 | action = match[0] |
|
76 | 76 | target_issue_ids = match[1].scan(/\d+/) |
|
77 | 77 | target_issues = repository.project.issues.find_all_by_id(target_issue_ids) |
|
78 | 78 | if fix_status && fix_keywords.include?(action.downcase) |
|
79 | 79 | # update status of issues |
|
80 | 80 | logger.debug "Issues fixed by changeset #{self.revision}: #{issue_ids.join(', ')}." if logger && logger.debug? |
|
81 | 81 | target_issues.each do |issue| |
|
82 | 82 | # don't change the status is the issue is already closed |
|
83 | 83 | next if issue.status.is_closed? |
|
84 | 84 | issue.status = fix_status |
|
85 | 85 | issue.done_ratio = done_ratio if done_ratio |
|
86 | 86 | issue.save |
|
87 | 87 | end |
|
88 | 88 | end |
|
89 | 89 | referenced_issues += target_issues |
|
90 | 90 | end |
|
91 | 91 | |
|
92 | 92 | self.issues = referenced_issues.uniq |
|
93 | 93 | end |
|
94 | ||
|
95 | # Returns the previous changeset | |
|
96 | def previous | |
|
97 | @previous ||= Changeset.find(:first, :conditions => ['revision < ? AND repository_id = ?', self.revision, self.repository_id], :order => 'revision DESC') | |
|
98 | end | |
|
99 | ||
|
100 | # Returns the next changeset | |
|
101 | def next | |
|
102 | @next ||= Changeset.find(:first, :conditions => ['revision > ? AND repository_id = ?', self.revision, self.repository_id], :order => 'revision ASC') | |
|
103 | end | |
|
94 | 104 | end |
@@ -1,50 +1,64 | |||
|
1 | 1 | <div class="contextual"> |
|
2 | « | |
|
3 | <% unless @changeset.previous.nil? -%> | |
|
4 | <%= link_to l(:label_previous), :controller => 'repositories', :action => 'revision', :id => @project, :rev => @changeset.previous.revision %> | |
|
5 | <% else -%> | |
|
6 | <%= l(:label_previous) %> | |
|
7 | <% end -%> | |
|
8 | | | |
|
9 | <% unless @changeset.next.nil? -%> | |
|
10 | <%= link_to l(:label_next), :controller => 'repositories', :action => 'revision', :id => @project, :rev => @changeset.next.revision %> | |
|
11 | <% else -%> | |
|
12 | <%= l(:label_next) %> | |
|
13 | <% end -%> | |
|
14 | » | |
|
15 | ||
|
2 | 16 | <% form_tag do %> |
|
3 |
|
|
|
17 | <%= text_field_tag 'rev', @rev, :size => 5 %> | |
|
4 | 18 | <%= submit_tag 'OK' %> |
|
5 | 19 | <% end %> |
|
6 | 20 | </div> |
|
7 | 21 | |
|
8 | 22 | <h2><%= l(:label_revision) %> <%= @changeset.revision %></h2> |
|
9 | 23 | |
|
10 | 24 | <p><% if @changeset.scmid %>ID: <%= @changeset.scmid %><br /><% end %> |
|
11 | 25 | <em><%= @changeset.committer %>, <%= format_time(@changeset.committed_on) %></em></p> |
|
12 | 26 | |
|
13 | 27 | <%= textilizable @changeset.comments %> |
|
14 | 28 | |
|
15 | 29 | <% if @changeset.issues.any? %> |
|
16 | 30 | <h3><%= l(:label_related_issues) %></h3> |
|
17 | 31 | <ul> |
|
18 | 32 | <% @changeset.issues.each do |issue| %> |
|
19 | 33 | <li><%= link_to_issue issue %>: <%=h issue.subject %></li> |
|
20 | 34 | <% end %> |
|
21 | 35 | </ul> |
|
22 | 36 | <% end %> |
|
23 | 37 | |
|
24 | 38 | <h3><%= l(:label_attachment_plural) %></h3> |
|
25 | 39 | <div style="float:right;"> |
|
26 | 40 | <div class="square action_A"></div> <div style="float:left;"><%= l(:label_added) %> </div> |
|
27 | 41 | <div class="square action_M"></div> <div style="float:left;"><%= l(:label_modified) %> </div> |
|
28 | 42 | <div class="square action_D"></div> <div style="float:left;"><%= l(:label_deleted) %> </div> |
|
29 | 43 | </div> |
|
30 | 44 | <p><%= link_to(l(:label_view_diff), :action => 'diff', :id => @project, :path => "", :rev => @changeset.revision) if @changeset.changes.any? %></p> |
|
31 | 45 | <table class="list"> |
|
32 | 46 | <tbody> |
|
33 | 47 | <% @changes.each do |change| %> |
|
34 | 48 | <tr class="<%= cycle 'odd', 'even' %>"> |
|
35 | 49 | <td><div class="square action_<%= change.action %>"></div> <%= change.path %> <%= "(#{change.revision})" unless change.revision.blank? %></td> |
|
36 | 50 | <td align="right"> |
|
37 | 51 | <% if change.action == "M" %> |
|
38 | 52 | <%= link_to l(:label_view_diff), :action => 'diff', :id => @project, :path => change.path, :rev => @changeset.revision %> |
|
39 | 53 | <% end %> |
|
40 | 54 | </td> |
|
41 | 55 | </tr> |
|
42 | 56 | <% end %> |
|
43 | 57 | </tbody> |
|
44 | 58 | </table> |
|
45 | 59 | <p><%= pagination_links_full @changes_pages, :rev => @changeset.revision %> |
|
46 | 60 | [ <%= @changes_pages.current.first_item %> - <%= @changes_pages.current.last_item %> / <%= @changes_count %> ]</p> |
|
47 | 61 | |
|
48 | 62 | <% content_for :header_tags do %> |
|
49 | 63 | <%= stylesheet_link_tag "scm" %> |
|
50 | 64 | <% end %> |
@@ -1,487 +1,489 | |||
|
1 | 1 | body { font-family: Verdana, sans-serif; font-size: 12px; color:#484848; margin: 0; padding: 0; min-width: 900px; } |
|
2 | 2 | |
|
3 | 3 | h1, h2, h3, h4 { font-family: "Trebuchet MS", Verdana, sans-serif;} |
|
4 | 4 | h1 {margin:0; padding:0; font-size: 24px;} |
|
5 | 5 | h2, .wiki h1 {font-size: 20px;padding: 2px 10px 1px 0px;margin: 0 0 10px 0; border-bottom: 1px solid #bbbbbb; color: #444;} |
|
6 | 6 | h3, .wiki h2 {font-size: 16px;padding: 2px 10px 1px 0px;margin: 0 0 10px 0; border-bottom: 1px solid #bbbbbb; color: #444;} |
|
7 | 7 | h4, .wiki h3 {font-size: 12px;padding: 2px 10px 1px 0px;margin-bottom: 5px; border-bottom: 1px dotted #bbbbbb; color: #444;} |
|
8 | 8 | |
|
9 | 9 | /***** Layout *****/ |
|
10 | 10 | #top-menu {background: #2C4056;color: #fff;height:1.5em; padding: 2px 6px 0px 6px;} |
|
11 | 11 | #top-menu a {color: #fff; padding-right: 4px;} |
|
12 | 12 | #account {float:right;} |
|
13 | 13 | |
|
14 | 14 | #header {height:5.3em;margin:0;background-color:#507AAA;color:#f8f8f8; padding: 4px 8px 0px 6px; position:relative;} |
|
15 | 15 | #header a {color:#f8f8f8;} |
|
16 | 16 | #quick-search {float:right;} |
|
17 | 17 | |
|
18 | 18 | #main-menu {position: absolute; bottom: 0px; left:6px;} |
|
19 | 19 | #main-menu ul {margin: 0; padding: 0;} |
|
20 | 20 | #main-menu li { |
|
21 | 21 | float:left; |
|
22 | 22 | list-style-type:none; |
|
23 | 23 | margin: 0px 10px 0px 0px; |
|
24 | 24 | padding: 0px 0px 0px 0px; |
|
25 | 25 | white-space:nowrap; |
|
26 | 26 | } |
|
27 | 27 | #main-menu li a { |
|
28 | 28 | display: block; |
|
29 | 29 | color: #fff; |
|
30 | 30 | text-decoration: none; |
|
31 | 31 | margin: 0; |
|
32 | 32 | padding: 4px 4px 4px 4px; |
|
33 | 33 | background: #2C4056; |
|
34 | 34 | } |
|
35 | 35 | #main-menu li a:hover {background:#759FCF;} |
|
36 | 36 | |
|
37 | 37 | #main {background: url(../images/mainbg.png) repeat-x; background-color:#EEEEEE;} |
|
38 | 38 | |
|
39 | 39 | #sidebar{ float: right; width: 17%; position: relative; z-index: 9; min-height: 600px; padding: 0; margin: 0;} |
|
40 | 40 | * html #sidebar{ width: 17%; } |
|
41 | 41 | #sidebar h3{ font-size: 14px; margin-top:14px; color: #666; } |
|
42 | 42 | #sidebar hr{ width: 100%; margin: 0 auto; height: 1px; background: #ccc; border: 0; } |
|
43 | 43 | * html #sidebar hr{ width: 95%; position: relative; left: -6px; color: #ccc; } |
|
44 | 44 | |
|
45 | 45 | #content { width: 80%; background: url(../images/contentbg.png) repeat-x; background-color: #fff; margin: 0px; border-right: 1px solid #ddd; padding: 6px 10px 10px 10px; z-index: 10; height:600px; min-height: 600px;} |
|
46 | 46 | * html #content{ width: 80%; padding-left: 0; margin-top: 0px; padding: 6px 10px 10px 10px;} |
|
47 | 47 | html>body #content { |
|
48 | 48 | height: auto; |
|
49 | 49 | min-height: 600px; |
|
50 | 50 | } |
|
51 | 51 | |
|
52 | 52 | #main.nosidebar #sidebar{ display: none; } |
|
53 | 53 | #main.nosidebar #content{ width: auto; border-right: 0; } |
|
54 | 54 | |
|
55 | 55 | #footer {clear: both; border-top: 1px solid #bbb; font-size: 0.9em; color: #aaa; padding: 5px; text-align:center; background:#fff;} |
|
56 | 56 | |
|
57 | 57 | #login-form table {margin-top:5em; padding:1em; margin-left: auto; margin-right: auto; border: 2px solid #FDBF3B; background-color:#FFEBC1; } |
|
58 | 58 | #login-form table td {padding: 6px;} |
|
59 | 59 | #login-form label {font-weight: bold;} |
|
60 | 60 | |
|
61 | 61 | .clear:after{ content: "."; display: block; height: 0; clear: both; visibility: hidden; } |
|
62 | 62 | |
|
63 | 63 | /***** Links *****/ |
|
64 | 64 | a, a:link, a:visited{ color: #2A5685; text-decoration: none; } |
|
65 | 65 | a:hover, a:active{ color: #c61a1a; text-decoration: underline;} |
|
66 | 66 | a img{ border: 0; } |
|
67 | 67 | |
|
68 | 68 | /***** Tables *****/ |
|
69 | 69 | table.list { border: 1px solid #e4e4e4; border-collapse: collapse; width: 100%; margin-bottom: 4px; } |
|
70 | 70 | table.list th { background-color:#EEEEEE; padding: 4px; white-space:nowrap; } |
|
71 | 71 | table.list td { overflow: hidden; text-overflow: ellipsis; vertical-align: top;} |
|
72 | 72 | table.list td.id { width: 2%; text-align: center;} |
|
73 | 73 | table.list td.checkbox { width: 15px; padding: 0px;} |
|
74 | 74 | |
|
75 | 75 | tr.issue { text-align: center; white-space: nowrap; } |
|
76 | 76 | tr.issue td.subject, tr.issue td.category { white-space: normal; } |
|
77 | 77 | tr.issue td.subject { text-align: left; } |
|
78 | 78 | tr.issue td.done_ratio table.progress { margin-left:auto; margin-right: auto;} |
|
79 | 79 | |
|
80 | 80 | tr.message { height: 2.6em; } |
|
81 | 81 | tr.message td.last_message { font-size: 80%; } |
|
82 | 82 | tr.message.locked td.subject a { background-image: url(../images/locked.png); } |
|
83 | 83 | tr.message.sticky td.subject a { background-image: url(../images/sticky.png); font-weight: bold; } |
|
84 | 84 | |
|
85 | 85 | table.list tbody tr:hover { background-color:#ffffdd; } |
|
86 | 86 | table td {padding:2px;} |
|
87 | 87 | table p {margin:0;} |
|
88 | 88 | .odd {background-color:#f6f7f8;} |
|
89 | 89 | .even {background-color: #fff;} |
|
90 | 90 | |
|
91 | 91 | .highlight { background-color: #FCFD8D;} |
|
92 | 92 | .highlight.token-1 { background-color: #faa;} |
|
93 | 93 | .highlight.token-2 { background-color: #afa;} |
|
94 | 94 | .highlight.token-3 { background-color: #aaf;} |
|
95 | 95 | |
|
96 | 96 | .box{ |
|
97 | 97 | padding:6px; |
|
98 | 98 | margin-bottom: 10px; |
|
99 | 99 | background-color:#f6f6f6; |
|
100 | 100 | color:#505050; |
|
101 | 101 | line-height:1.5em; |
|
102 | 102 | border: 1px solid #e4e4e4; |
|
103 | 103 | } |
|
104 | 104 | |
|
105 | 105 | div.square { |
|
106 | 106 | border: 1px solid #999; |
|
107 | 107 | float: left; |
|
108 | 108 | margin: .3em .4em 0 .4em; |
|
109 | 109 | overflow: hidden; |
|
110 | 110 | width: .6em; height: .6em; |
|
111 | 111 | } |
|
112 | 112 | |
|
113 | 113 | .contextual {float:right; white-space: nowrap; line-height:1.4em;margin-top:5px;font-size:0.9em;} |
|
114 | .contextual input {font-size:0.9em;} | |
|
115 | ||
|
114 | 116 | .splitcontentleft{float:left; width:49%;} |
|
115 | 117 | .splitcontentright{float:right; width:49%;} |
|
116 | 118 | form {display: inline;} |
|
117 | 119 | input, select {vertical-align: middle; margin-top: 1px; margin-bottom: 1px;} |
|
118 | 120 | fieldset {border: 1px solid #e4e4e4; margin:0;} |
|
119 | 121 | legend {color: #484848;} |
|
120 | 122 | hr { width: 100%; height: 1px; background: #ccc; border: 0;} |
|
121 | 123 | textarea.wiki-edit { width: 99%; } |
|
122 | 124 | li p {margin-top: 0;} |
|
123 | 125 | div.issue {background:#ffffdd; padding:6px; margin-bottom:6px;border: 1px solid #d7d7d7;} |
|
124 | 126 | .autoscroll {overflow-x: auto; padding:1px; width:100%;} |
|
125 | 127 | #user_firstname, #user_lastname, #user_mail, #notification_option { width: 90%; } |
|
126 | 128 | |
|
127 | 129 | /***** Tabular forms ******/ |
|
128 | 130 | .tabular p{ |
|
129 | 131 | margin: 0; |
|
130 | 132 | padding: 5px 0 8px 0; |
|
131 | 133 | padding-left: 180px; /*width of left column containing the label elements*/ |
|
132 | 134 | height: 1%; |
|
133 | 135 | clear:left; |
|
134 | 136 | } |
|
135 | 137 | |
|
136 | 138 | .tabular label{ |
|
137 | 139 | font-weight: bold; |
|
138 | 140 | float: left; |
|
139 | 141 | text-align: right; |
|
140 | 142 | margin-left: -180px; /*width of left column*/ |
|
141 | 143 | width: 175px; /*width of labels. Should be smaller than left column to create some right |
|
142 | 144 | margin*/ |
|
143 | 145 | } |
|
144 | 146 | |
|
145 | 147 | .tabular label.floating{ |
|
146 | 148 | font-weight: normal; |
|
147 | 149 | margin-left: 0px; |
|
148 | 150 | text-align: left; |
|
149 | 151 | width: 200px; |
|
150 | 152 | } |
|
151 | 153 | |
|
152 | 154 | #preview fieldset {margin-top: 1em; background: url(../images/draft.png)} |
|
153 | 155 | |
|
154 | 156 | #settings .tabular p{ padding-left: 300px; } |
|
155 | 157 | #settings .tabular label{ margin-left: -300px; width: 295px; } |
|
156 | 158 | |
|
157 | 159 | .required {color: #bb0000;} |
|
158 | 160 | .summary {font-style: italic;} |
|
159 | 161 | |
|
160 | 162 | div.attachments p { margin:4px 0 2px 0; } |
|
161 | 163 | |
|
162 | 164 | /***** Flash & error messages ****/ |
|
163 | 165 | #errorExplanation, div.flash, .nodata { |
|
164 | 166 | padding: 4px 4px 4px 30px; |
|
165 | 167 | margin-bottom: 12px; |
|
166 | 168 | font-size: 1.1em; |
|
167 | 169 | border: 2px solid; |
|
168 | 170 | } |
|
169 | 171 | |
|
170 | 172 | div.flash {margin-top: 8px;} |
|
171 | 173 | |
|
172 | 174 | div.flash.error, #errorExplanation { |
|
173 | 175 | background: url(../images/false.png) 8px 5px no-repeat; |
|
174 | 176 | background-color: #ffe3e3; |
|
175 | 177 | border-color: #dd0000; |
|
176 | 178 | color: #550000; |
|
177 | 179 | } |
|
178 | 180 | |
|
179 | 181 | div.flash.notice { |
|
180 | 182 | background: url(../images/true.png) 8px 5px no-repeat; |
|
181 | 183 | background-color: #dfffdf; |
|
182 | 184 | border-color: #9fcf9f; |
|
183 | 185 | color: #005f00; |
|
184 | 186 | } |
|
185 | 187 | |
|
186 | 188 | .nodata { |
|
187 | 189 | text-align: center; |
|
188 | 190 | background-color: #FFEBC1; |
|
189 | 191 | border-color: #FDBF3B; |
|
190 | 192 | color: #A6750C; |
|
191 | 193 | } |
|
192 | 194 | |
|
193 | 195 | #errorExplanation ul { font-size: 0.9em;} |
|
194 | 196 | |
|
195 | 197 | /***** Ajax indicator ******/ |
|
196 | 198 | #ajax-indicator { |
|
197 | 199 | position: absolute; /* fixed not supported by IE */ |
|
198 | 200 | background-color:#eee; |
|
199 | 201 | border: 1px solid #bbb; |
|
200 | 202 | top:35%; |
|
201 | 203 | left:40%; |
|
202 | 204 | width:20%; |
|
203 | 205 | font-weight:bold; |
|
204 | 206 | text-align:center; |
|
205 | 207 | padding:0.6em; |
|
206 | 208 | z-index:100; |
|
207 | 209 | filter:alpha(opacity=50); |
|
208 | 210 | -moz-opacity:0.5; |
|
209 | 211 | opacity: 0.5; |
|
210 | 212 | -khtml-opacity: 0.5; |
|
211 | 213 | } |
|
212 | 214 | |
|
213 | 215 | html>body #ajax-indicator { position: fixed; } |
|
214 | 216 | |
|
215 | 217 | #ajax-indicator span { |
|
216 | 218 | background-position: 0% 40%; |
|
217 | 219 | background-repeat: no-repeat; |
|
218 | 220 | background-image: url(../images/loading.gif); |
|
219 | 221 | padding-left: 26px; |
|
220 | 222 | vertical-align: bottom; |
|
221 | 223 | } |
|
222 | 224 | |
|
223 | 225 | /***** Calendar *****/ |
|
224 | 226 | table.cal {border-collapse: collapse; width: 100%; margin: 8px 0 6px 0;border: 1px solid #d7d7d7;} |
|
225 | 227 | table.cal thead th {width: 14%;} |
|
226 | 228 | table.cal tbody tr {height: 100px;} |
|
227 | 229 | table.cal th { background-color:#EEEEEE; padding: 4px; } |
|
228 | 230 | table.cal td {border: 1px solid #d7d7d7; vertical-align: top; font-size: 0.9em;} |
|
229 | 231 | table.cal td p.day-num {font-size: 1.1em; text-align:right;} |
|
230 | 232 | table.cal td.odd p.day-num {color: #bbb;} |
|
231 | 233 | table.cal td.today {background:#ffffdd;} |
|
232 | 234 | table.cal td.today p.day-num {font-weight: bold;} |
|
233 | 235 | |
|
234 | 236 | /***** Tooltips ******/ |
|
235 | 237 | .tooltip{position:relative;z-index:24;} |
|
236 | 238 | .tooltip:hover{z-index:25;color:#000;} |
|
237 | 239 | .tooltip span.tip{display: none; text-align:left;} |
|
238 | 240 | |
|
239 | 241 | div.tooltip:hover span.tip{ |
|
240 | 242 | display:block; |
|
241 | 243 | position:absolute; |
|
242 | 244 | top:12px; left:24px; width:270px; |
|
243 | 245 | border:1px solid #555; |
|
244 | 246 | background-color:#fff; |
|
245 | 247 | padding: 4px; |
|
246 | 248 | font-size: 0.8em; |
|
247 | 249 | color:#505050; |
|
248 | 250 | } |
|
249 | 251 | |
|
250 | 252 | /***** Progress bar *****/ |
|
251 | 253 | table.progress { |
|
252 | 254 | border: 1px solid #D7D7D7; |
|
253 | 255 | border-collapse: collapse; |
|
254 | 256 | border-spacing: 0pt; |
|
255 | 257 | empty-cells: show; |
|
256 | 258 | text-align: center; |
|
257 | 259 | float:left; |
|
258 | 260 | margin: 1px 6px 1px 0px; |
|
259 | 261 | } |
|
260 | 262 | |
|
261 | 263 | table.progress td { height: 0.9em; } |
|
262 | 264 | table.progress td.closed { background: #BAE0BA none repeat scroll 0%; } |
|
263 | 265 | table.progress td.open { background: #FFF none repeat scroll 0%; } |
|
264 | 266 | p.pourcent {font-size: 80%;} |
|
265 | 267 | p.progress-info {clear: left; font-style: italic; font-size: 80%;} |
|
266 | 268 | |
|
267 | 269 | /***** Tabs *****/ |
|
268 | 270 | #content .tabs{height: 2.6em;} |
|
269 | 271 | #content .tabs ul{margin:0;} |
|
270 | 272 | #content .tabs ul li{ |
|
271 | 273 | float:left; |
|
272 | 274 | list-style-type:none; |
|
273 | 275 | white-space:nowrap; |
|
274 | 276 | margin-right:8px; |
|
275 | 277 | background:#fff; |
|
276 | 278 | } |
|
277 | 279 | #content .tabs ul li a{ |
|
278 | 280 | display:block; |
|
279 | 281 | font-size: 0.9em; |
|
280 | 282 | text-decoration:none; |
|
281 | 283 | line-height:1em; |
|
282 | 284 | padding:4px; |
|
283 | 285 | border: 1px solid #c0c0c0; |
|
284 | 286 | } |
|
285 | 287 | |
|
286 | 288 | #content .tabs ul li a.selected, #content .tabs ul li a:hover{ |
|
287 | 289 | background-color: #507AAA; |
|
288 | 290 | border: 1px solid #507AAA; |
|
289 | 291 | color: #fff; |
|
290 | 292 | text-decoration:none; |
|
291 | 293 | } |
|
292 | 294 | |
|
293 | 295 | /***** Diff *****/ |
|
294 | 296 | .diff_out { background: #fcc; } |
|
295 | 297 | .diff_in { background: #cfc; } |
|
296 | 298 | |
|
297 | 299 | /***** Wiki *****/ |
|
298 | 300 | div.wiki table { |
|
299 | 301 | border: 1px solid #505050; |
|
300 | 302 | border-collapse: collapse; |
|
301 | 303 | } |
|
302 | 304 | |
|
303 | 305 | div.wiki table, div.wiki td, div.wiki th { |
|
304 | 306 | border: 1px solid #bbb; |
|
305 | 307 | padding: 4px; |
|
306 | 308 | } |
|
307 | 309 | |
|
308 | 310 | div.wiki .external { |
|
309 | 311 | background-position: 0% 60%; |
|
310 | 312 | background-repeat: no-repeat; |
|
311 | 313 | padding-left: 12px; |
|
312 | 314 | background-image: url(../images/external.png); |
|
313 | 315 | } |
|
314 | 316 | |
|
315 | 317 | div.wiki a.new { |
|
316 | 318 | color: #b73535; |
|
317 | 319 | } |
|
318 | 320 | |
|
319 | 321 | div.wiki pre { |
|
320 | 322 | margin: 1em 1em 1em 1.6em; |
|
321 | 323 | padding: 2px; |
|
322 | 324 | background-color: #fafafa; |
|
323 | 325 | border: 1px solid #dadada; |
|
324 | 326 | width:95%; |
|
325 | 327 | overflow-x: auto; |
|
326 | 328 | } |
|
327 | 329 | |
|
328 | 330 | div.wiki div.toc { |
|
329 | 331 | background-color: #ffffdd; |
|
330 | 332 | border: 1px solid #e4e4e4; |
|
331 | 333 | padding: 4px; |
|
332 | 334 | line-height: 1.2em; |
|
333 | 335 | margin-bottom: 12px; |
|
334 | 336 | margin-right: 12px; |
|
335 | 337 | display: table |
|
336 | 338 | } |
|
337 | 339 | * html div.wiki div.toc { width: 50%; } /* IE6 doesn't autosize div */ |
|
338 | 340 | |
|
339 | 341 | div.wiki div.toc.right { float: right; margin-left: 12px; margin-right: 0; width: auto; } |
|
340 | 342 | div.wiki div.toc.left { float: left; margin-right: 12px; margin-left: 0; width: auto; } |
|
341 | 343 | |
|
342 | 344 | div.wiki div.toc a { |
|
343 | 345 | display: block; |
|
344 | 346 | font-size: 0.9em; |
|
345 | 347 | font-weight: normal; |
|
346 | 348 | text-decoration: none; |
|
347 | 349 | color: #606060; |
|
348 | 350 | } |
|
349 | 351 | div.wiki div.toc a:hover { color: #c61a1a; text-decoration: underline;} |
|
350 | 352 | |
|
351 | 353 | div.wiki div.toc a.heading2 { margin-left: 6px; } |
|
352 | 354 | div.wiki div.toc a.heading3 { margin-left: 12px; font-size: 0.8em; } |
|
353 | 355 | |
|
354 | 356 | /***** My page layout *****/ |
|
355 | 357 | .block-receiver { |
|
356 | 358 | border:1px dashed #c0c0c0; |
|
357 | 359 | margin-bottom: 20px; |
|
358 | 360 | padding: 15px 0 15px 0; |
|
359 | 361 | } |
|
360 | 362 | |
|
361 | 363 | .mypage-box { |
|
362 | 364 | margin:0 0 20px 0; |
|
363 | 365 | color:#505050; |
|
364 | 366 | line-height:1.5em; |
|
365 | 367 | } |
|
366 | 368 | |
|
367 | 369 | .handle { |
|
368 | 370 | cursor: move; |
|
369 | 371 | } |
|
370 | 372 | |
|
371 | 373 | a.close-icon { |
|
372 | 374 | display:block; |
|
373 | 375 | margin-top:3px; |
|
374 | 376 | overflow:hidden; |
|
375 | 377 | width:12px; |
|
376 | 378 | height:12px; |
|
377 | 379 | background-repeat: no-repeat; |
|
378 | 380 | cursor:pointer; |
|
379 | 381 | background-image:url('../images/close.png'); |
|
380 | 382 | } |
|
381 | 383 | |
|
382 | 384 | a.close-icon:hover { |
|
383 | 385 | background-image:url('../images/close_hl.png'); |
|
384 | 386 | } |
|
385 | 387 | |
|
386 | 388 | /***** Gantt chart *****/ |
|
387 | 389 | .gantt_hdr { |
|
388 | 390 | position:absolute; |
|
389 | 391 | top:0; |
|
390 | 392 | height:16px; |
|
391 | 393 | border-top: 1px solid #c0c0c0; |
|
392 | 394 | border-bottom: 1px solid #c0c0c0; |
|
393 | 395 | border-right: 1px solid #c0c0c0; |
|
394 | 396 | text-align: center; |
|
395 | 397 | overflow: hidden; |
|
396 | 398 | } |
|
397 | 399 | |
|
398 | 400 | .task { |
|
399 | 401 | position: absolute; |
|
400 | 402 | height:8px; |
|
401 | 403 | font-size:0.8em; |
|
402 | 404 | color:#888; |
|
403 | 405 | padding:0; |
|
404 | 406 | margin:0; |
|
405 | 407 | line-height:0.8em; |
|
406 | 408 | } |
|
407 | 409 | |
|
408 | 410 | .task_late { background:#f66 url(../images/task_late.png); border: 1px solid #f66; } |
|
409 | 411 | .task_done { background:#66f url(../images/task_done.png); border: 1px solid #66f; } |
|
410 | 412 | .task_todo { background:#aaa url(../images/task_todo.png); border: 1px solid #aaa; } |
|
411 | 413 | .milestone { background-image:url(../images/milestone.png); background-repeat: no-repeat; border: 0; } |
|
412 | 414 | |
|
413 | 415 | /***** Icons *****/ |
|
414 | 416 | .icon { |
|
415 | 417 | background-position: 0% 40%; |
|
416 | 418 | background-repeat: no-repeat; |
|
417 | 419 | padding-left: 20px; |
|
418 | 420 | padding-top: 2px; |
|
419 | 421 | padding-bottom: 3px; |
|
420 | 422 | } |
|
421 | 423 | |
|
422 | 424 | .icon22 { |
|
423 | 425 | background-position: 0% 40%; |
|
424 | 426 | background-repeat: no-repeat; |
|
425 | 427 | padding-left: 26px; |
|
426 | 428 | line-height: 22px; |
|
427 | 429 | vertical-align: middle; |
|
428 | 430 | } |
|
429 | 431 | |
|
430 | 432 | .icon-add { background-image: url(../images/add.png); } |
|
431 | 433 | .icon-edit { background-image: url(../images/edit.png); } |
|
432 | 434 | .icon-copy { background-image: url(../images/copy.png); } |
|
433 | 435 | .icon-del { background-image: url(../images/delete.png); } |
|
434 | 436 | .icon-move { background-image: url(../images/move.png); } |
|
435 | 437 | .icon-save { background-image: url(../images/save.png); } |
|
436 | 438 | .icon-cancel { background-image: url(../images/cancel.png); } |
|
437 | 439 | .icon-pdf { background-image: url(../images/pdf.png); } |
|
438 | 440 | .icon-csv { background-image: url(../images/csv.png); } |
|
439 | 441 | .icon-html { background-image: url(../images/html.png); } |
|
440 | 442 | .icon-image { background-image: url(../images/image.png); } |
|
441 | 443 | .icon-txt { background-image: url(../images/txt.png); } |
|
442 | 444 | .icon-file { background-image: url(../images/file.png); } |
|
443 | 445 | .icon-folder { background-image: url(../images/folder.png); } |
|
444 | 446 | .open .icon-folder { background-image: url(../images/folder_open.png); } |
|
445 | 447 | .icon-package { background-image: url(../images/package.png); } |
|
446 | 448 | .icon-home { background-image: url(../images/home.png); } |
|
447 | 449 | .icon-user { background-image: url(../images/user.png); } |
|
448 | 450 | .icon-mypage { background-image: url(../images/user_page.png); } |
|
449 | 451 | .icon-admin { background-image: url(../images/admin.png); } |
|
450 | 452 | .icon-projects { background-image: url(../images/projects.png); } |
|
451 | 453 | .icon-logout { background-image: url(../images/logout.png); } |
|
452 | 454 | .icon-help { background-image: url(../images/help.png); } |
|
453 | 455 | .icon-attachment { background-image: url(../images/attachment.png); } |
|
454 | 456 | .icon-index { background-image: url(../images/index.png); } |
|
455 | 457 | .icon-history { background-image: url(../images/history.png); } |
|
456 | 458 | .icon-feed { background-image: url(../images/feed.png); } |
|
457 | 459 | .icon-time { background-image: url(../images/time.png); } |
|
458 | 460 | .icon-stats { background-image: url(../images/stats.png); } |
|
459 | 461 | .icon-warning { background-image: url(../images/warning.png); } |
|
460 | 462 | .icon-fav { background-image: url(../images/fav.png); } |
|
461 | 463 | .icon-fav-off { background-image: url(../images/fav_off.png); } |
|
462 | 464 | .icon-reload { background-image: url(../images/reload.png); } |
|
463 | 465 | .icon-lock { background-image: url(../images/locked.png); } |
|
464 | 466 | .icon-unlock { background-image: url(../images/unlock.png); } |
|
465 | 467 | .icon-note { background-image: url(../images/note.png); } |
|
466 | 468 | .icon-checked { background-image: url(../images/true.png); } |
|
467 | 469 | |
|
468 | 470 | .icon22-projects { background-image: url(../images/22x22/projects.png); } |
|
469 | 471 | .icon22-users { background-image: url(../images/22x22/users.png); } |
|
470 | 472 | .icon22-tracker { background-image: url(../images/22x22/tracker.png); } |
|
471 | 473 | .icon22-role { background-image: url(../images/22x22/role.png); } |
|
472 | 474 | .icon22-workflow { background-image: url(../images/22x22/workflow.png); } |
|
473 | 475 | .icon22-options { background-image: url(../images/22x22/options.png); } |
|
474 | 476 | .icon22-notifications { background-image: url(../images/22x22/notifications.png); } |
|
475 | 477 | .icon22-authent { background-image: url(../images/22x22/authent.png); } |
|
476 | 478 | .icon22-info { background-image: url(../images/22x22/info.png); } |
|
477 | 479 | .icon22-comment { background-image: url(../images/22x22/comment.png); } |
|
478 | 480 | .icon22-package { background-image: url(../images/22x22/package.png); } |
|
479 | 481 | .icon22-settings { background-image: url(../images/22x22/settings.png); } |
|
480 | 482 | .icon22-plugin { background-image: url(../images/22x22/plugin.png); } |
|
481 | 483 | |
|
482 | 484 | /***** Media print specific styles *****/ |
|
483 | 485 | @media print { |
|
484 | 486 | #top-menu, #header, #main-menu, #sidebar, #footer, .contextual { display:none; } |
|
485 | 487 | #main { background: #fff; } |
|
486 | 488 | #content { width: 99%; margin: 0; padding: 0; border: 0; background: #fff; } |
|
487 | 489 | } |
@@ -1,8 +1,15 | |||
|
1 | 1 | --- |
|
2 | 2 | repositories_001: |
|
3 | 3 | project_id: 1 |
|
4 | 4 | url: svn://localhost/test |
|
5 | 5 | id: 10 |
|
6 | 6 | root_url: svn://localhost |
|
7 | 7 | password: "" |
|
8 | 8 | login: "" |
|
9 | repositories_002: | |
|
10 | project_id: 2 | |
|
11 | url: svn://localhost/test | |
|
12 | id: 11 | |
|
13 | root_url: svn://localhost | |
|
14 | password: "" | |
|
15 | login: "" |
@@ -1,149 +1,149 | |||
|
1 | 1 | # redMine - project management software |
|
2 | 2 | # Copyright (C) 2006-2007 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.dirname(__FILE__) + '/../test_helper' |
|
19 | 19 | require 'projects_controller' |
|
20 | 20 | |
|
21 | 21 | # Re-raise errors caught by the controller. |
|
22 | 22 | class ProjectsController; def rescue_action(e) raise e end; end |
|
23 | 23 | |
|
24 | 24 | class ProjectsControllerTest < Test::Unit::TestCase |
|
25 | 25 | fixtures :projects, :users, :roles, :members, :issues, :journals, :journal_details, :trackers, :projects_trackers, :issue_statuses, :enabled_modules, :enumerations |
|
26 | 26 | |
|
27 | 27 | def setup |
|
28 | 28 | @controller = ProjectsController.new |
|
29 | 29 | @request = ActionController::TestRequest.new |
|
30 | 30 | @response = ActionController::TestResponse.new |
|
31 | 31 | end |
|
32 | 32 | |
|
33 | 33 | def test_index |
|
34 | 34 | get :index |
|
35 | 35 | assert_response :success |
|
36 | 36 | assert_template 'list' |
|
37 | 37 | end |
|
38 | 38 | |
|
39 | 39 | def test_list |
|
40 | 40 | get :list |
|
41 | 41 | assert_response :success |
|
42 | 42 | assert_template 'list' |
|
43 | 43 | assert_not_nil assigns(:project_tree) |
|
44 | 44 | end |
|
45 | 45 | |
|
46 | 46 | def test_show |
|
47 | 47 | get :show, :id => 1 |
|
48 | 48 | assert_response :success |
|
49 | 49 | assert_template 'show' |
|
50 | 50 | assert_not_nil assigns(:project) |
|
51 | 51 | end |
|
52 | 52 | |
|
53 | 53 | def test_list_documents |
|
54 | 54 | get :list_documents, :id => 1 |
|
55 | 55 | assert_response :success |
|
56 | 56 | assert_template 'list_documents' |
|
57 | 57 | assert_not_nil assigns(:grouped) |
|
58 | 58 | end |
|
59 | 59 | |
|
60 | 60 | def test_bulk_edit_issues |
|
61 | 61 | @request.session[:user_id] = 2 |
|
62 | 62 | # update issues priority |
|
63 | 63 | post :bulk_edit_issues, :id => 1, :issue_ids => [1, 2], :priority_id => 7, :notes => 'Bulk editing', :assigned_to_id => '' |
|
64 | 64 | assert_response 302 |
|
65 | 65 | # check that the issues were updated |
|
66 | 66 | assert_equal [7, 7], Issue.find_all_by_id([1, 2]).collect {|i| i.priority.id} |
|
67 | 67 | assert_equal 'Bulk editing', Issue.find(1).journals.find(:first, :order => 'created_on DESC').notes |
|
68 | 68 | end |
|
69 | 69 | |
|
70 | 70 | def test_list_files |
|
71 | 71 | get :list_files, :id => 1 |
|
72 | 72 | assert_response :success |
|
73 | 73 | assert_template 'list_files' |
|
74 | 74 | assert_not_nil assigns(:versions) |
|
75 | 75 | end |
|
76 | 76 | |
|
77 | 77 | def test_changelog |
|
78 | 78 | get :changelog, :id => 1 |
|
79 | 79 | assert_response :success |
|
80 | 80 | assert_template 'changelog' |
|
81 | 81 | assert_not_nil assigns(:versions) |
|
82 | 82 | end |
|
83 | 83 | |
|
84 | 84 | def test_roadmap |
|
85 | 85 | get :roadmap, :id => 1 |
|
86 | 86 | assert_response :success |
|
87 | 87 | assert_template 'roadmap' |
|
88 | 88 | assert_not_nil assigns(:versions) |
|
89 | 89 | end |
|
90 | 90 | |
|
91 | 91 | def test_activity |
|
92 | get :activity, :id => 1 | |
|
92 | get :activity, :id => 1, :year => 2.days.ago.to_date.year, :month => 2.days.ago.to_date.month | |
|
93 | 93 | assert_response :success |
|
94 | 94 | assert_template 'activity' |
|
95 | 95 | assert_not_nil assigns(:events_by_day) |
|
96 | 96 | |
|
97 | 97 | assert_tag :tag => "h3", |
|
98 | 98 | :content => /#{2.days.ago.to_date.day}/, |
|
99 | 99 | :sibling => { :tag => "ul", |
|
100 | 100 | :child => { :tag => "li", |
|
101 | 101 | :child => { :tag => "p", |
|
102 | 102 | :content => /(#{IssueStatus.find(2).name})/, |
|
103 | 103 | } |
|
104 | 104 | } |
|
105 | 105 | } |
|
106 | 106 | assert_tag :tag => "h3", |
|
107 | 107 | :content => /#{3.day.ago.to_date.day}/, |
|
108 | 108 | :sibling => { :tag => "ul", :child => { :tag => "li", |
|
109 | 109 | :child => { :tag => "p", |
|
110 | 110 | :content => /#{Issue.find(1).subject}/, |
|
111 | 111 | } |
|
112 | 112 | } |
|
113 | 113 | } |
|
114 | 114 | end |
|
115 | 115 | |
|
116 | 116 | def test_archive |
|
117 | 117 | @request.session[:user_id] = 1 # admin |
|
118 | 118 | post :archive, :id => 1 |
|
119 | 119 | assert_redirected_to 'admin/projects' |
|
120 | 120 | assert !Project.find(1).active? |
|
121 | 121 | end |
|
122 | 122 | |
|
123 | 123 | def test_unarchive |
|
124 | 124 | @request.session[:user_id] = 1 # admin |
|
125 | 125 | Project.find(1).archive |
|
126 | 126 | post :unarchive, :id => 1 |
|
127 | 127 | assert_redirected_to 'admin/projects' |
|
128 | 128 | assert Project.find(1).active? |
|
129 | 129 | end |
|
130 | 130 | |
|
131 | 131 | def test_add_issue |
|
132 | 132 | @request.session[:user_id] = 2 |
|
133 | 133 | get :add_issue, :id => 1, :tracker_id => 1 |
|
134 | 134 | assert_response :success |
|
135 | 135 | assert_template 'add_issue' |
|
136 | 136 | post :add_issue, :id => 1, :issue => {:tracker_id => 1, :subject => 'This is the test_add_issue issue', :description => 'This is the description', :priority_id => 5} |
|
137 | 137 | assert_redirected_to 'projects/1/issues' |
|
138 | 138 | assert Issue.find_by_subject('This is the test_add_issue issue') |
|
139 | 139 | end |
|
140 | 140 | |
|
141 | 141 | def test_copy_issue |
|
142 | 142 | @request.session[:user_id] = 2 |
|
143 | 143 | get :add_issue, :id => 1, :copy_from => 1 |
|
144 | 144 | assert_template 'add_issue' |
|
145 | 145 | assert_not_nil assigns(:issue) |
|
146 | 146 | orig = Issue.find(1) |
|
147 | 147 | assert_equal orig.subject, assigns(:issue).subject |
|
148 | 148 | end |
|
149 | 149 | end |
@@ -1,42 +1,62 | |||
|
1 | 1 | # redMine - project management software |
|
2 | 2 | # Copyright (C) 2006-2007 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.dirname(__FILE__) + '/../test_helper' |
|
19 | 19 | |
|
20 | 20 | class ChangesetTest < Test::Unit::TestCase |
|
21 | 21 | fixtures :projects, :repositories, :issues, :issue_statuses, :changesets, :changes, :issue_categories, :enumerations, :custom_fields, :custom_values, :users, :members, :trackers |
|
22 | 22 | |
|
23 | 23 | def setup |
|
24 | 24 | end |
|
25 | 25 | |
|
26 | 26 | def test_ref_keywords_any |
|
27 | 27 | Setting.commit_fix_status_id = IssueStatus.find(:first, :conditions => ["is_closed = ?", true]).id |
|
28 | 28 | Setting.commit_fix_done_ratio = '90' |
|
29 | 29 | Setting.commit_ref_keywords = '*' |
|
30 | 30 | Setting.commit_fix_keywords = 'fixes , closes' |
|
31 | 31 | |
|
32 | 32 | c = Changeset.new(:repository => Project.find(1).repository, |
|
33 | 33 | :committed_on => Time.now, |
|
34 | 34 | :comments => 'New commit (#2). Fixes #1') |
|
35 | 35 | c.scan_comment_for_issue_ids |
|
36 | 36 | |
|
37 | 37 | assert_equal [1, 2], c.issue_ids.sort |
|
38 | 38 | fixed = Issue.find(1) |
|
39 | 39 | assert fixed.closed? |
|
40 | 40 | assert_equal 90, fixed.done_ratio |
|
41 | 41 | end |
|
42 | ||
|
43 | def test_previous | |
|
44 | changeset = Changeset.find_by_revision(3) | |
|
45 | assert_equal Changeset.find_by_revision(2), changeset.previous | |
|
46 | end | |
|
47 | ||
|
48 | def test_previous_nil | |
|
49 | changeset = Changeset.find_by_revision(1) | |
|
50 | assert_nil changeset.previous | |
|
51 | end | |
|
52 | ||
|
53 | def test_next | |
|
54 | changeset = Changeset.find_by_revision(2) | |
|
55 | assert_equal Changeset.find_by_revision(3), changeset.next | |
|
56 | end | |
|
57 | ||
|
58 | def test_next_nil | |
|
59 | changeset = Changeset.find_by_revision(4) | |
|
60 | assert_nil changeset.next | |
|
61 | end | |
|
42 | 62 | end |
@@ -1,76 +1,76 | |||
|
1 | 1 | # redMine - project management software |
|
2 | 2 | # Copyright (C) 2006-2007 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.dirname(__FILE__) + '/../test_helper' |
|
19 | 19 | |
|
20 | 20 | class RepositoryTest < Test::Unit::TestCase |
|
21 | 21 | fixtures :projects, :repositories, :issues, :issue_statuses, :changesets, :changes |
|
22 | 22 | |
|
23 | 23 | def setup |
|
24 | 24 | @repository = Project.find(1).repository |
|
25 | 25 | end |
|
26 | 26 | |
|
27 | 27 | def test_create |
|
28 |
repository = Repository::Subversion.new(:project => Project.find( |
|
|
28 | repository = Repository::Subversion.new(:project => Project.find(3)) | |
|
29 | 29 | assert !repository.save |
|
30 | 30 | |
|
31 | 31 | repository.url = "svn://localhost" |
|
32 | 32 | assert repository.save |
|
33 | 33 | repository.reload |
|
34 | 34 | |
|
35 |
project = Project.find( |
|
|
35 | project = Project.find(3) | |
|
36 | 36 | assert_equal repository, project.repository |
|
37 | 37 | end |
|
38 | 38 | |
|
39 | 39 | def test_scan_changesets_for_issue_ids |
|
40 | 40 | # choosing a status to apply to fix issues |
|
41 | 41 | Setting.commit_fix_status_id = IssueStatus.find(:first, :conditions => ["is_closed = ?", true]).id |
|
42 | 42 | Setting.commit_fix_done_ratio = "90" |
|
43 | 43 | Setting.commit_ref_keywords = 'refs , references, IssueID' |
|
44 | 44 | Setting.commit_fix_keywords = 'fixes , closes' |
|
45 | 45 | |
|
46 | 46 | # make sure issue 1 is not already closed |
|
47 | 47 | assert !Issue.find(1).status.is_closed? |
|
48 | 48 | |
|
49 | 49 | Repository.scan_changesets_for_issue_ids |
|
50 | 50 | assert_equal [101, 102], Issue.find(3).changeset_ids |
|
51 | 51 | |
|
52 | 52 | # fixed issues |
|
53 | 53 | fixed_issue = Issue.find(1) |
|
54 | 54 | assert fixed_issue.status.is_closed? |
|
55 | 55 | assert_equal 90, fixed_issue.done_ratio |
|
56 | 56 | assert_equal [101], fixed_issue.changeset_ids |
|
57 | 57 | |
|
58 | 58 | # ignoring commits referencing an issue of another project |
|
59 | 59 | assert_equal [], Issue.find(4).changesets |
|
60 | 60 | end |
|
61 | 61 | |
|
62 | 62 | def test_for_changeset_comments_strip |
|
63 | 63 | repository = Repository::Mercurial.create( :project => Project.find( 4 ), :url => '/foo/bar/baz' ) |
|
64 | 64 | comment = <<-COMMENT |
|
65 | 65 | This is a loooooooooooooooooooooooooooong comment |
|
66 | 66 | |
|
67 | 67 | |
|
68 | 68 | COMMENT |
|
69 | 69 | changeset = Changeset.new( |
|
70 | 70 | :comments => comment, :commit_date => Time.now, :revision => 0, :scmid => 'f39b7922fb3c', |
|
71 | 71 | :committer => 'foo <foo@example.com>', :committed_on => Time.now, :repository => repository ) |
|
72 | 72 | assert( changeset.save ) |
|
73 | 73 | assert_not_equal( comment, changeset.comments ) |
|
74 | 74 | assert_equal( 'This is a loooooooooooooooooooooooooooong comment', changeset.comments ) |
|
75 | 75 | end |
|
76 | 76 | end |
General Comments 0
You need to be logged in to leave comments.
Login now