@@ -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 |
@@ -19,6 +19,9 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 |
@@ -94,14 +97,19 class RepositoriesController < ApplicationController | |||
|
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 | ||
|
104 | render :action => "revision", :layout => false if request.xhr? | |
|
106 | ||
|
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 |
@@ -54,7 +54,7 class TimelogController < ApplicationController | |||
|
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(', ') |
@@ -91,4 +91,14 class Changeset < ActiveRecord::Base | |||
|
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,8 +1,22 | |||
|
1 | 1 | <div class="contextual"> |
|
2 | <% form_tag do %> | |
|
3 | <%= l(:label_revision) %>: <%= text_field_tag 'rev', @rev, :size => 5 %> | |
|
4 | <%= submit_tag 'OK' %> | |
|
5 |
<% e |
|
|
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 | ||
|
16 | <% form_tag do %> | |
|
17 | <%= text_field_tag 'rev', @rev, :size => 5 %> | |
|
18 | <%= submit_tag 'OK' %> | |
|
19 | <% end %> | |
|
6 | 20 | </div> |
|
7 | 21 | |
|
8 | 22 | <h2><%= l(:label_revision) %> <%= @changeset.revision %></h2> |
@@ -111,6 +111,8 div.square { | |||
|
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;} |
@@ -6,3 +6,10 repositories_001: | |||
|
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: "" |
@@ -89,7 +89,7 class ProjectsControllerTest < Test::Unit::TestCase | |||
|
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) |
@@ -39,4 +39,24 class ChangesetTest < Test::Unit::TestCase | |||
|
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 |
@@ -25,14 +25,14 class RepositoryTest < Test::Unit::TestCase | |||
|
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 |
General Comments 0
You need to be logged in to leave comments.
Login now