Revision 1297:0a574315af3e .svn/pristine/25

View differences:

.svn/pristine/25/252eb4f2f106201746352d88a816534e53e8ac4b.svn-base
1
# Redmine - project management software
2
# Copyright (C) 2006-2012  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
module Redmine #:nodoc:
19
  module CoreExtensions #:nodoc:
20
    module String #:nodoc:
21
      # Custom string conversions
22
      module Conversions
23
        # Parses hours format and returns a float
24
        def to_hours
25
          s = self.dup
26
          s.strip!
27
          if s =~ %r{^(\d+([.,]\d+)?)h?$}
28
            s = $1
29
          else
30
            # 2:30 => 2.5
31
            s.gsub!(%r{^(\d+):(\d+)$}) { $1.to_i + $2.to_i / 60.0 }
32
            # 2h30, 2h, 30m => 2.5, 2, 0.5
33
            s.gsub!(%r{^((\d+)\s*(h|hours?))?\s*((\d+)\s*(m|min)?)?$}i) { |m| ($1 || $4) ? ($2.to_i + $5.to_i / 60.0) : m[0] }
34
          end
35
          # 2,5 => 2.5
36
          s.gsub!(',', '.')
37
          begin; Kernel.Float(s); rescue; nil; end
38
        end
39

  
40
        # Object#to_a removed in ruby1.9
41
        if RUBY_VERSION > '1.9'
42
          def to_a
43
            [self.dup]
44
          end
45
        end
46
      end
47
    end
48
  end
49
end
.svn/pristine/25/25447f18997fb5819d5b27f060defe1630ee82df.svn-base
1
<%= board_breadcrumb(@message) %>
2

  
3
<h2><%= avatar(@topic.author, :size => "24") %><%=h @topic.subject %></h2>
4

  
5
<%= form_for @message, {
6
               :as => :message,
7
               :url => {:action => 'edit'},
8
               :html => {:multipart => true,
9
                         :id => 'message-form',
10
                         :method => :post}
11
          } do |f| %>
12
  <%= render :partial => 'form',
13
             :locals => {:f => f, :replying => !@message.parent.nil?} %>
14
  <%= submit_tag l(:button_save) %>
15
  <%= preview_link({:controller => 'messages', :action => 'preview', :board_id => @board, :id => @message}, 'message-form') %>
16
<% end %>
17
<div id="preview" class="wiki"></div>
.svn/pristine/25/259870e377324ce9639c6de14a859fead9c01fbd.svn-base
1
<%= form_tag({:controller => 'journals', :action => 'edit', :id => @journal},
2
             :remote => true,
3
             :id => "journal-#{@journal.id}-form") do %>
4
    <%= label_tag "notes", l(:description_notes), :class => "hidden-for-sighted" %>
5
    <%= text_area_tag :notes, @journal.notes,
6
          :id => "journal_#{@journal.id}_notes",
7
          :class => 'wiki-edit',
8
          :rows => (@journal.notes.blank? ? 10 : [[10, @journal.notes.length / 50].max, 100].min) %>
9
    <%= call_hook(:view_journals_notes_form_after_notes, { :journal => @journal}) %>
10
    <p><%= submit_tag l(:button_save) %>
11
    <%= preview_link preview_edit_issue_path(:project_id => @project, :id => @journal.issue), 
12
                     "journal-#{@journal.id}-form",
13
                     "journal_#{@journal.id}_preview" %> |
14
    <%= link_to l(:button_cancel), '#', :onclick => "$('#journal-#{@journal.id}-form').remove(); $('#journal-#{@journal.id}-notes').show(); return false;" %></p>
15

  
16
    <div id="journal_<%= @journal.id %>_preview" class="wiki"></div>
17
<% end %>
18
<%= wikitoolbar_for "journal_#{@journal.id}_notes" %>
.svn/pristine/25/25a7a4fdea85fbb1b14478fb690111974ca9c5c6.svn-base
1
# Redmine - project management software
2
# Copyright (C) 2006-2012  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
class DocumentCategory < Enumeration
19
  has_many :documents, :foreign_key => 'category_id'
20

  
21
  OptionName = :enumeration_doc_categories
22

  
23
  def option_name
24
    OptionName
25
  end
26

  
27
  def objects_count
28
    documents.count
29
  end
30

  
31
  def transfer_relations(to)
32
    documents.update_all("category_id = #{to.id}")
33
  end
34

  
35
  def self.default
36
    d = super
37
    d = first if d.nil?
38
    d
39
  end
40
end
.svn/pristine/25/25cdcad944ee39e6a9c2a56e5a525014ecebc7bc.svn-base
1
# Redmine - project management software
2
# Copyright (C) 2006-2012  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.expand_path('../../test_helper', __FILE__)
19

  
20
class RepositoriesMercurialControllerTest < ActionController::TestCase
21
  tests RepositoriesController
22

  
23
  fixtures :projects, :users, :roles, :members, :member_roles,
24
           :repositories, :enabled_modules
25

  
26
  REPOSITORY_PATH = Rails.root.join('tmp/test/mercurial_repository').to_s
27
  CHAR_1_HEX = "\xc3\x9c"
28
  PRJ_ID     = 3
29
  NUM_REV    = 32
30

  
31
  ruby19_non_utf8_pass =
32
     (RUBY_VERSION >= '1.9' && Encoding.default_external.to_s != 'UTF-8')
33

  
34
  def setup
35
    User.current = nil
36
    @project    = Project.find(PRJ_ID)
37
    @repository = Repository::Mercurial.create(
38
                      :project => @project,
39
                      :url     => REPOSITORY_PATH,
40
                      :path_encoding => 'ISO-8859-1'
41
                      )
42
    assert @repository
43
    @diff_c_support = true
44
    @char_1        = CHAR_1_HEX.dup
45
    @tag_char_1    = "tag-#{CHAR_1_HEX}-00"
46
    @branch_char_0 = "branch-#{CHAR_1_HEX}-00"
47
    @branch_char_1 = "branch-#{CHAR_1_HEX}-01"
48
    if @char_1.respond_to?(:force_encoding)
49
      @char_1.force_encoding('UTF-8')
50
      @tag_char_1.force_encoding('UTF-8')
51
      @branch_char_0.force_encoding('UTF-8')
52
      @branch_char_1.force_encoding('UTF-8')
53
    end
54
  end
55

  
56
  if ruby19_non_utf8_pass
57
    puts "TODO: Mercurial functional test fails in Ruby 1.9 " +
58
         "and Encoding.default_external is not UTF-8. " +
59
         "Current value is '#{Encoding.default_external.to_s}'"
60
    def test_fake; assert true end
61
  elsif File.directory?(REPOSITORY_PATH)
62

  
63
    def test_get_new
64
      @request.session[:user_id] = 1
65
      @project.repository.destroy
66
      get :new, :project_id => 'subproject1', :repository_scm => 'Mercurial'
67
      assert_response :success
68
      assert_template 'new'
69
      assert_kind_of Repository::Mercurial, assigns(:repository)
70
      assert assigns(:repository).new_record?
71
    end
72

  
73
    def test_show_root
74
      assert_equal 0, @repository.changesets.count
75
      @repository.fetch_changesets
76
      @project.reload
77
      assert_equal NUM_REV, @repository.changesets.count
78
      get :show, :id => PRJ_ID
79
      assert_response :success
80
      assert_template 'show'
81
      assert_not_nil assigns(:entries)
82
      assert_equal 4, assigns(:entries).size
83
      assert assigns(:entries).detect {|e| e.name == 'images'  && e.kind == 'dir'}
84
      assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'}
85
      assert assigns(:entries).detect {|e| e.name == 'README'  && e.kind == 'file'}
86
      assert_not_nil assigns(:changesets)
87
      assert assigns(:changesets).size > 0
88
    end
89

  
90
    def test_show_directory
91
      assert_equal 0, @repository.changesets.count
92
      @repository.fetch_changesets
93
      @project.reload
94
      assert_equal NUM_REV, @repository.changesets.count
95
      get :show, :id => PRJ_ID, :path => repository_path_hash(['images'])[:param]
96
      assert_response :success
97
      assert_template 'show'
98
      assert_not_nil assigns(:entries)
99
      assert_equal ['delete.png', 'edit.png'], assigns(:entries).collect(&:name)
100
      entry = assigns(:entries).detect {|e| e.name == 'edit.png'}
101
      assert_not_nil entry
102
      assert_equal 'file', entry.kind
103
      assert_equal 'images/edit.png', entry.path
104
      assert_not_nil assigns(:changesets)
105
      assert assigns(:changesets).size > 0
106
    end
107

  
108
    def test_show_at_given_revision
109
      assert_equal 0, @repository.changesets.count
110
      @repository.fetch_changesets
111
      @project.reload
112
      assert_equal NUM_REV, @repository.changesets.count
113
      [0, '0', '0885933ad4f6'].each do |r1|
114
        get :show, :id => PRJ_ID, :path => repository_path_hash(['images'])[:param],
115
            :rev => r1
116
        assert_response :success
117
        assert_template 'show'
118
        assert_not_nil assigns(:entries)
119
        assert_equal ['delete.png'], assigns(:entries).collect(&:name)
120
        assert_not_nil assigns(:changesets)
121
        assert assigns(:changesets).size > 0
122
      end
123
    end
124

  
125
    def test_show_directory_sql_escape_percent
126
      assert_equal 0, @repository.changesets.count
127
      @repository.fetch_changesets
128
      @project.reload
129
      assert_equal NUM_REV, @repository.changesets.count
130
      [13, '13', '3a330eb32958'].each do |r1|
131
        get :show, :id => PRJ_ID,
132
            :path => repository_path_hash(['sql_escape', 'percent%dir'])[:param],
133
            :rev => r1
134
        assert_response :success
135
        assert_template 'show'
136

  
137
        assert_not_nil assigns(:entries)
138
        assert_equal ['percent%file1.txt', 'percentfile1.txt'],
139
                     assigns(:entries).collect(&:name)
140
        changesets = assigns(:changesets)
141
        assert_not_nil changesets
142
        assert assigns(:changesets).size > 0
143
        assert_equal %w(13 11 10 9), changesets.collect(&:revision)
144
      end
145
    end
146

  
147
    def test_show_directory_latin_1_path
148
      assert_equal 0, @repository.changesets.count
149
      @repository.fetch_changesets
150
      @project.reload
151
      assert_equal NUM_REV, @repository.changesets.count
152
      [21, '21', 'adf805632193'].each do |r1|
153
        get :show, :id => PRJ_ID,
154
            :path => repository_path_hash(['latin-1-dir'])[:param],
155
            :rev => r1
156
        assert_response :success
157
        assert_template 'show'
158

  
159
        assert_not_nil assigns(:entries)
160
        assert_equal ["make-latin-1-file.rb",
161
                      "test-#{@char_1}-1.txt",
162
                      "test-#{@char_1}-2.txt",
163
                      "test-#{@char_1}.txt"], assigns(:entries).collect(&:name)
164
        changesets = assigns(:changesets)
165
        assert_not_nil changesets
166
        assert_equal %w(21 20 19 18 17), changesets.collect(&:revision)
167
      end
168
    end
169

  
170
    def show_should_show_branch_selection_form
171
      @repository.fetch_changesets
172
      @project.reload
173
      get :show, :id => PRJ_ID
174
      assert_tag 'form', :attributes => {:id => 'revision_selector', :action => '/projects/subproject1/repository/show'}
175
      assert_tag 'select', :attributes => {:name => 'branch'},
176
        :child => {:tag => 'option', :attributes => {:value => 'test-branch-01'}},
177
        :parent => {:tag => 'form', :attributes => {:id => 'revision_selector'}}
178
    end
179

  
180
    def test_show_branch
181
      assert_equal 0, @repository.changesets.count
182
      @repository.fetch_changesets
183
      @project.reload
184
      assert_equal NUM_REV, @repository.changesets.count
185
       [
186
          'default',
187
          @branch_char_1,
188
          'branch (1)[2]&,%.-3_4',
189
          @branch_char_0,
190
          'test_branch.latin-1',
191
          'test-branch-00',
192
      ].each do |bra|
193
        get :show, :id => PRJ_ID, :rev => bra
194
        assert_response :success
195
        assert_template 'show'
196
        assert_not_nil assigns(:entries)
197
        assert assigns(:entries).size > 0
198
        assert_not_nil assigns(:changesets)
199
        assert assigns(:changesets).size > 0
200
      end
201
    end
202

  
203
    def test_show_tag
204
      assert_equal 0, @repository.changesets.count
205
      @repository.fetch_changesets
206
      @project.reload
207
      assert_equal NUM_REV, @repository.changesets.count
208
       [
209
        @tag_char_1,
210
        'tag_test.00',
211
        'tag-init-revision'
212
      ].each do |tag|
213
        get :show, :id => PRJ_ID, :rev => tag
214
        assert_response :success
215
        assert_template 'show'
216
        assert_not_nil assigns(:entries)
217
        assert assigns(:entries).size > 0
218
        assert_not_nil assigns(:changesets)
219
        assert assigns(:changesets).size > 0
220
      end
221
    end
222

  
223
    def test_changes
224
      get :changes, :id => PRJ_ID,
225
          :path => repository_path_hash(['images', 'edit.png'])[:param]
226
      assert_response :success
227
      assert_template 'changes'
228
      assert_tag :tag => 'h2', :content => 'edit.png'
229
    end
230

  
231
    def test_entry_show
232
      get :entry, :id => PRJ_ID,
233
          :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param]
234
      assert_response :success
235
      assert_template 'entry'
236
      # Line 10
237
      assert_tag :tag => 'th',
238
                 :content => '10',
239
                 :attributes => { :class => 'line-num' },
240
                 :sibling => { :tag => 'td', :content => /WITHOUT ANY WARRANTY/ }
241
    end
242

  
243
    def test_entry_show_latin_1_path
244
      [21, '21', 'adf805632193'].each do |r1|
245
        get :entry, :id => PRJ_ID,
246
            :path => repository_path_hash(['latin-1-dir', "test-#{@char_1}-2.txt"])[:param],
247
            :rev => r1
248
        assert_response :success
249
        assert_template 'entry'
250
        assert_tag :tag => 'th',
251
                 :content => '1',
252
                 :attributes => { :class => 'line-num' },
253
                 :sibling => { :tag => 'td',
254
                               :content => /Mercurial is a distributed version control system/ }
255
      end
256
    end
257

  
258
    def test_entry_show_latin_1_contents
259
      with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do
260
        [27, '27', '7bbf4c738e71'].each do |r1|
261
          get :entry, :id => PRJ_ID,
262
              :path => repository_path_hash(['latin-1-dir', "test-#{@char_1}.txt"])[:param],
263
              :rev => r1
264
          assert_response :success
265
          assert_template 'entry'
266
          assert_tag :tag => 'th',
267
                 :content => '1',
268
                 :attributes => { :class => 'line-num' },
269
                 :sibling => { :tag => 'td',
270
                               :content => /test-#{@char_1}.txt/ }
271
        end
272
      end
273
    end
274

  
275
    def test_entry_download
276
      get :entry, :id => PRJ_ID,
277
          :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param],
278
          :format => 'raw'
279
      assert_response :success
280
      # File content
281
      assert @response.body.include?('WITHOUT ANY WARRANTY')
282
    end
283

  
284
    def test_entry_binary_force_download
285
      get :entry, :id => PRJ_ID, :rev => 1,
286
          :path => repository_path_hash(['images', 'edit.png'])[:param]
287
      assert_response :success
288
      assert_equal 'image/png', @response.content_type
289
    end
290

  
291
    def test_directory_entry
292
      get :entry, :id => PRJ_ID,
293
          :path => repository_path_hash(['sources'])[:param]
294
      assert_response :success
295
      assert_template 'show'
296
      assert_not_nil assigns(:entry)
297
      assert_equal 'sources', assigns(:entry).name
298
    end
299

  
300
    def test_diff
301
      assert_equal 0, @repository.changesets.count
302
      @repository.fetch_changesets
303
      @project.reload
304
      assert_equal NUM_REV, @repository.changesets.count
305
      [4, '4', 'def6d2f1254a'].each do |r1|
306
        # Full diff of changeset 4
307
        ['inline', 'sbs'].each do |dt|
308
          get :diff, :id => PRJ_ID, :rev => r1, :type => dt
309
          assert_response :success
310
          assert_template 'diff'
311
          if @diff_c_support
312
            # Line 22 removed
313
            assert_tag :tag => 'th',
314
                       :content => '22',
315
                       :sibling => { :tag => 'td',
316
                                     :attributes => { :class => /diff_out/ },
317
                                     :content => /def remove/ }
318
            assert_tag :tag => 'h2', :content => /4:def6d2f1254a/
319
          end
320
        end
321
      end
322
    end
323

  
324
    def test_diff_two_revs
325
      assert_equal 0, @repository.changesets.count
326
      @repository.fetch_changesets
327
      @project.reload
328
      assert_equal NUM_REV, @repository.changesets.count
329
      [2, '400bb8672109', '400', 400].each do |r1|
330
        [4, 'def6d2f1254a'].each do |r2|
331
          ['inline', 'sbs'].each do |dt|
332
            get :diff,
333
                :id     => PRJ_ID,
334
                :rev    => r1,
335
                :rev_to => r2,
336
                :type => dt
337
            assert_response :success
338
            assert_template 'diff'
339
            diff = assigns(:diff)
340
            assert_not_nil diff
341
            assert_tag :tag => 'h2',
342
                       :content => /4:def6d2f1254a 2:400bb8672109/
343
          end
344
        end
345
      end
346
    end
347

  
348
    def test_diff_latin_1_path
349
      with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do
350
        [21, 'adf805632193'].each do |r1|
351
          ['inline', 'sbs'].each do |dt|
352
            get :diff, :id => PRJ_ID, :rev => r1, :type => dt
353
            assert_response :success
354
            assert_template 'diff'
355
            assert_tag :tag => 'thead',
356
                       :descendant => {
357
                         :tag => 'th',
358
                         :attributes => { :class => 'filename' } ,
359
                         :content => /latin-1-dir\/test-#{@char_1}-2.txt/ ,
360
                        },
361
                       :sibling => {
362
                         :tag => 'tbody',
363
                         :descendant => {
364
                            :tag => 'td',
365
                            :attributes => { :class => /diff_in/ },
366
                            :content => /It is written in Python/
367
                         }
368
                       }
369
          end
370
        end
371
      end
372
    end
373

  
374
    def test_diff_should_show_modified_filenames
375
      get :diff, :id => PRJ_ID, :rev => '400bb8672109', :type => 'inline'
376
      assert_response :success
377
      assert_template 'diff'
378
      assert_select 'th.filename', :text => 'sources/watchers_controller.rb'
379
    end
380

  
381
    def test_diff_should_show_deleted_filenames
382
      get :diff, :id => PRJ_ID, :rev => 'b3a615152df8', :type => 'inline'
383
      assert_response :success
384
      assert_template 'diff'
385
      assert_select 'th.filename', :text => 'sources/welcome_controller.rb'
386
    end
387

  
388
    def test_annotate
389
      get :annotate, :id => PRJ_ID,
390
          :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param]
391
      assert_response :success
392
      assert_template 'annotate'
393

  
394
      # Line 22, revision 4:def6d2f1254a
395
      assert_select 'tr' do
396
        assert_select 'th.line-num', :text => '22'
397
        assert_select 'td.revision', :text => '4:def6d2f1254a'
398
        assert_select 'td.author', :text => 'jsmith'
399
        assert_select 'td', :text => /remove_watcher/
400
      end
401
    end
402

  
403
    def test_annotate_not_in_tip
404
      assert_equal 0, @repository.changesets.count
405
      @repository.fetch_changesets
406
      @project.reload
407
      assert_equal NUM_REV, @repository.changesets.count
408
      get :annotate, :id => PRJ_ID,
409
          :path => repository_path_hash(['sources', 'welcome_controller.rb'])[:param]
410
      assert_response 404
411
      assert_error_tag :content => /was not found/
412
    end
413

  
414
    def test_annotate_at_given_revision
415
      assert_equal 0, @repository.changesets.count
416
      @repository.fetch_changesets
417
      @project.reload
418
      assert_equal NUM_REV, @repository.changesets.count
419
      [2, '400bb8672109', '400', 400].each do |r1|
420
        get :annotate, :id => PRJ_ID, :rev => r1,
421
            :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param]
422
        assert_response :success
423
        assert_template 'annotate'
424
        assert_tag :tag => 'h2', :content => /@ 2:400bb8672109/
425
      end
426
    end
427

  
428
    def test_annotate_latin_1_path
429
      [21, '21', 'adf805632193'].each do |r1|
430
        get :annotate, :id => PRJ_ID,
431
            :path => repository_path_hash(['latin-1-dir', "test-#{@char_1}-2.txt"])[:param],
432
            :rev => r1
433
        assert_response :success
434
        assert_template 'annotate'
435
        assert_tag :tag => 'th',
436
                 :content => '1',
437
                 :attributes => { :class => 'line-num' },
438
                 :sibling =>
439
                       {
440
                         :tag => 'td',
441
                         :attributes => { :class => 'revision' },
442
                         :child => { :tag => 'a', :content => '20:709858aafd1b' }
443
                       }
444
        assert_tag :tag => 'th',
445
                 :content => '1',
446
                 :attributes => { :class => 'line-num' },
447
                 :sibling =>
448
                       {
449
                          :tag     => 'td'    ,
450
                          :content => 'jsmith' ,
451
                          :attributes => { :class   => 'author' },
452
                        }
453
        assert_tag :tag => 'th',
454
                 :content => '1',
455
                 :attributes => { :class => 'line-num' },
456
                 :sibling => { :tag => 'td',
457
                               :content => /Mercurial is a distributed version control system/ }
458

  
459
      end
460
    end
461

  
462
    def test_annotate_latin_1_contents
463
      with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do
464
        [27, '7bbf4c738e71'].each do |r1|
465
          get :annotate, :id => PRJ_ID,
466
              :path => repository_path_hash(['latin-1-dir', "test-#{@char_1}.txt"])[:param],
467
              :rev => r1
468
          assert_tag :tag => 'th',
469
                     :content => '1',
470
                     :attributes => { :class => 'line-num' },
471
                     :sibling => { :tag => 'td',
472
                                   :content => /test-#{@char_1}.txt/ }
473
        end
474
      end
475
    end
476

  
477
    def test_empty_revision
478
      assert_equal 0, @repository.changesets.count
479
      @repository.fetch_changesets
480
      @project.reload
481
      assert_equal NUM_REV, @repository.changesets.count
482
      ['', ' ', nil].each do |r|
483
        get :revision, :id => PRJ_ID, :rev => r
484
        assert_response 404
485
        assert_error_tag :content => /was not found/
486
      end
487
    end
488

  
489
    def test_destroy_valid_repository
490
      @request.session[:user_id] = 1 # admin
491
      assert_equal 0, @repository.changesets.count
492
      @repository.fetch_changesets
493
      assert_equal NUM_REV, @repository.changesets.count
494

  
495
      assert_difference 'Repository.count', -1 do
496
        delete :destroy, :id => @repository.id
497
      end
498
      assert_response 302
499
      @project.reload
500
      assert_nil @project.repository
501
    end
502

  
503
    def test_destroy_invalid_repository
504
      @request.session[:user_id] = 1 # admin
505
      @project.repository.destroy
506
      @repository = Repository::Mercurial.create!(
507
                      :project => Project.find(PRJ_ID),
508
                      :url     => "/invalid",
509
                      :path_encoding => 'ISO-8859-1'
510
                      )
511
      @repository.fetch_changesets
512
      assert_equal 0, @repository.changesets.count
513

  
514
      assert_difference 'Repository.count', -1 do
515
        delete :destroy, :id => @repository.id
516
      end
517
      assert_response 302
518
      @project.reload
519
      assert_nil @project.repository
520
    end
521
  else
522
    puts "Mercurial test repository NOT FOUND. Skipping functional tests !!!"
523
    def test_fake; assert true end
524
  end
525
end
.svn/pristine/25/25dce4703e6f8e8002b5671dfd69151214860a9a.svn-base
1
<table class="cal">
2
<thead>
3
<tr><th scope="col" title="<%= l(:label_week) %>" class="week-number"></th><% 7.times do |i| %><th scope="col"><%= day_name( (calendar.first_wday+i)%7 ) %></th><% end %></tr>
4
</thead>
5
<tbody>
6
<tr>
7
<% day = calendar.startdt
8
while day <= calendar.enddt %>
9
<%= ("<td class='week-number' title='#{ l(:label_week) }'>#{(day+(11-day.cwday)%7).cweek}</td>".html_safe) if day.cwday == calendar.first_wday %>
10
<td class="<%= day.month==calendar.month ? 'even' : 'odd' %><%= ' today' if Date.today == day %>">
11
<p class="day-num"><%= day.day %></p>
12
<% calendar.events_on(day).each do |i| %>
13
  <% if i.is_a? Issue %>
14
  <div class="<%= i.css_classes %> <%= 'starting' if day == i.start_date %> <%= 'ending' if day == i.due_date %> tooltip">
15
  <%= h("#{i.project} -") unless @project && @project == i.project %>
16
  <%= link_to_issue i, :truncate => 30 %>
17
  <span class="tip"><%= render_issue_tooltip i %></span>
18
  </div>
19
  <% else %>
20
  <span class="icon icon-package">
21
    <%= h("#{i.project} -") unless @project && @project == i.project %>
22
    <%= link_to_version i%>
23
  </span>
24
  <% end %>
25
<% end %>
26
</td>
27
<%= '</tr><tr>'.html_safe if day.cwday==calendar.last_wday and day!=calendar.enddt %>
28
<% day = day + 1
29
end %>
30
</tr>
31
</tbody>
32
</table>

Also available in: Unified diff