Revision 1297:0a574315af3e .svn/pristine/34

View differences:

.svn/pristine/34/342285b027af8a7f1e30f8ee50c822bf5f5c7ecb.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
begin
21
  require 'mocha'
22

  
23
  class SubversionAdapterTest < ActiveSupport::TestCase
24

  
25
    if repository_configured?('subversion')
26
      def setup
27
        @adapter = Redmine::Scm::Adapters::SubversionAdapter.new(self.class.subversion_repository_url)
28
      end
29

  
30
      def test_client_version
31
        v = Redmine::Scm::Adapters::SubversionAdapter.client_version
32
        assert v.is_a?(Array)
33
      end
34

  
35
      def test_scm_version
36
        to_test = { "svn, version 1.6.13 (r1002816)\n"  => [1,6,13],
37
                    "svn, versione 1.6.13 (r1002816)\n" => [1,6,13],
38
                    "1.6.1\n1.7\n1.8"                   => [1,6,1],
39
                    "1.6.2\r\n1.8.1\r\n1.9.1"           => [1,6,2]}
40
        to_test.each do |s, v|
41
          test_scm_version_for(s, v)
42
        end
43
      end
44

  
45
      def test_info_not_nil
46
        assert_not_nil @adapter.info
47
      end
48

  
49
      def test_info_nil
50
        adpt = Redmine::Scm::Adapters::SubversionAdapter.new(
51
                  "file:///invalid/invalid/"
52
                  )
53
        assert_nil adpt.info
54
      end
55

  
56
      private
57

  
58
      def test_scm_version_for(scm_version, version)
59
        @adapter.class.expects(:scm_version_from_command_line).returns(scm_version)
60
        assert_equal version, @adapter.class.svn_binary_version
61
      end
62
    else
63
      puts "Subversion test repository NOT FOUND. Skipping unit tests !!!"
64
      def test_fake; assert true end
65
    end
66
  end
67
rescue LoadError
68
  class SubversionMochaFake < ActiveSupport::TestCase
69
    def test_fake; assert(false, "Requires mocha to run those tests")  end
70
  end
71
end
.svn/pristine/34/34322da11fdda11e13ebe7d947206d86863f3c74.svn-base
1
<%= labelled_form_for @project do |f| %>
2
<%= render :partial => 'form', :locals => { :f => f } %>
3
<%= submit_tag l(:button_save) %>
4
<% end %>
.svn/pristine/34/345f7acae2c1ee68bbdbe5e119f5efcf6fb9fb67.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 IssueTransactionTest < ActiveSupport::TestCase
21
  fixtures :projects, :users, :members, :member_roles, :roles,
22
           :trackers, :projects_trackers,
23
           :versions,
24
           :issue_statuses, :issue_categories, :issue_relations, :workflows,
25
           :enumerations,
26
           :issues,
27
           :custom_fields, :custom_fields_projects, :custom_fields_trackers, :custom_values,
28
           :time_entries
29

  
30
  self.use_transactional_fixtures = false
31

  
32
  def test_invalid_move_to_another_project
33
    parent1 = Issue.generate!
34
    child =   Issue.generate!(:parent_issue_id => parent1.id)
35
    grandchild = Issue.generate!(:parent_issue_id => child.id, :tracker_id => 2)
36
    Project.find(2).tracker_ids = [1]
37

  
38
    parent1.reload
39
    assert_equal [1, parent1.id, 1, 6], [parent1.project_id, parent1.root_id, parent1.lft, parent1.rgt]
40

  
41
    # child can not be moved to Project 2 because its child is on a disabled tracker
42
    child = Issue.find(child.id)
43
    child.project = Project.find(2)
44
    assert !child.save
45
    child.reload
46
    grandchild.reload
47
    parent1.reload
48

  
49
    # no change
50
    assert_equal [1, parent1.id, 1, 6], [parent1.project_id, parent1.root_id, parent1.lft, parent1.rgt]
51
    assert_equal [1, parent1.id, 2, 5], [child.project_id, child.root_id, child.lft, child.rgt]
52
    assert_equal [1, parent1.id, 3, 4], [grandchild.project_id, grandchild.root_id, grandchild.lft, grandchild.rgt]
53
  end
54
end
.svn/pristine/34/345fb72e40574b54a9481a84a098650cf151872f.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 QueriesController < ApplicationController
19
  menu_item :issues
20
  before_filter :find_query, :except => [:new, :create, :index]
21
  before_filter :find_optional_project, :only => [:new, :create]
22

  
23
  accept_api_auth :index
24

  
25
  include QueriesHelper
26

  
27
  def index
28
    case params[:format]
29
    when 'xml', 'json'
30
      @offset, @limit = api_offset_and_limit
31
    else
32
      @limit = per_page_option
33
    end
34

  
35
    @query_count = Query.visible.count
36
    @query_pages = Paginator.new self, @query_count, @limit, params['page']
37
    @queries = Query.visible.all(:limit => @limit, :offset => @offset, :order => "#{Query.table_name}.name")
38

  
39
    respond_to do |format|
40
      format.html { render :nothing => true }
41
      format.api
42
    end
43
  end
44

  
45
  def new
46
    @query = Query.new
47
    @query.user = User.current
48
    @query.project = @project
49
    @query.is_public = false unless User.current.allowed_to?(:manage_public_queries, @project) || User.current.admin?
50
    build_query_from_params
51
  end
52

  
53
  def create
54
    @query = Query.new(params[:query])
55
    @query.user = User.current
56
    @query.project = params[:query_is_for_all] ? nil : @project
57
    @query.is_public = false unless User.current.allowed_to?(:manage_public_queries, @project) || User.current.admin?
58
    build_query_from_params
59
    @query.column_names = nil if params[:default_columns]
60

  
61
    if @query.save
62
      flash[:notice] = l(:notice_successful_create)
63
      redirect_to :controller => 'issues', :action => 'index', :project_id => @project, :query_id => @query
64
    else
65
      render :action => 'new', :layout => !request.xhr?
66
    end
67
  end
68

  
69
  def edit
70
  end
71

  
72
  def update
73
    @query.attributes = params[:query]
74
    @query.project = nil if params[:query_is_for_all]
75
    @query.is_public = false unless User.current.allowed_to?(:manage_public_queries, @project) || User.current.admin?
76
    build_query_from_params
77
    @query.column_names = nil if params[:default_columns]
78

  
79
    if @query.save
80
      flash[:notice] = l(:notice_successful_update)
81
      redirect_to :controller => 'issues', :action => 'index', :project_id => @project, :query_id => @query
82
    else
83
      render :action => 'edit'
84
    end
85
  end
86

  
87
  def destroy
88
    @query.destroy
89
    redirect_to :controller => 'issues', :action => 'index', :project_id => @project, :set_filter => 1
90
  end
91

  
92
private
93
  def find_query
94
    @query = Query.find(params[:id])
95
    @project = @query.project
96
    render_403 unless @query.editable_by?(User.current)
97
  rescue ActiveRecord::RecordNotFound
98
    render_404
99
  end
100

  
101
  def find_optional_project
102
    @project = Project.find(params[:project_id]) if params[:project_id]
103
    render_403 unless User.current.allowed_to?(:save_queries, @project, :global => true)
104
  rescue ActiveRecord::RecordNotFound
105
    render_404
106
  end
107
end
.svn/pristine/34/34944e69635f53bef7eb7777ca3abc691bf31c39.svn-base
1
var revisionGraph = null;
2

  
3
function drawRevisionGraph(holder, commits_hash, graph_space) {
4
    var XSTEP = 20,
5
        CIRCLE_INROW_OFFSET = 10;
6
    var commits_by_scmid = commits_hash,
7
        commits = $.map(commits_by_scmid, function(val,i){return val;});
8
    var max_rdmid = commits.length - 1;
9
    var commit_table_rows = $('table.changesets tr.changeset');
10

  
11
    // create graph
12
    if(revisionGraph != null)
13
        revisionGraph.clear();
14
    else
15
        revisionGraph = Raphael(holder);
16

  
17
    var top = revisionGraph.set();
18
    // init dimensions
19
    var graph_x_offset = commit_table_rows.first().find('td').first().position().left - $(holder).position().left,
20
        graph_y_offset = $(holder).position().top,
21
        graph_right_side = graph_x_offset + (graph_space + 1) * XSTEP,
22
        graph_bottom = commit_table_rows.last().position().top + commit_table_rows.last().height() - graph_y_offset;
23

  
24
    revisionGraph.setSize(graph_right_side, graph_bottom);
25

  
26
    // init colors
27
    var colors = [];
28
    Raphael.getColor.reset();
29
    for (var k = 0; k <= graph_space; k++) {
30
        colors.push(Raphael.getColor());
31
    }
32

  
33
    var parent_commit;
34
    var x, y, parent_x, parent_y;
35
    var path, title;
36
    var revision_dot_overlay;
37
    $.each(commits, function(index, commit) {
38
        if (!commit.hasOwnProperty("space"))
39
            commit.space = 0;
40

  
41
        y = commit_table_rows.eq(max_rdmid - commit.rdmid).position().top - graph_y_offset + CIRCLE_INROW_OFFSET;
42
        x = graph_x_offset + XSTEP / 2 + XSTEP * commit.space;
43
        revisionGraph.circle(x, y, 3)
44
            .attr({
45
                fill: colors[commit.space],
46
                stroke: 'none',
47
            }).toFront();
48
        // paths to parents
49
        $.each(commit.parent_scmids, function(index, parent_scmid) {
50
            parent_commit = commits_by_scmid[parent_scmid];
51
            if (parent_commit) {
52
                if (!parent_commit.hasOwnProperty("space"))
53
                    parent_commit.space = 0;
54

  
55
                parent_y = commit_table_rows.eq(max_rdmid - parent_commit.rdmid).position().top - graph_y_offset + CIRCLE_INROW_OFFSET;
56
                parent_x = graph_x_offset + XSTEP / 2 + XSTEP * parent_commit.space;
57
                if (parent_commit.space == commit.space) {
58
                    // vertical path
59
                    path = revisionGraph.path([
60
                        'M', x, y,
61
                        'V', parent_y]);
62
                } else {
63
                    // path to a commit in a different branch (Bezier curve)
64
                    path = revisionGraph.path([
65
                        'M', x, y,
66
                        'C', x, y, x, y + (parent_y - y) / 2, x + (parent_x - x) / 2, y + (parent_y - y) / 2,
67
                        'C', x + (parent_x - x) / 2, y + (parent_y - y) / 2, parent_x, parent_y-(parent_y-y)/2, parent_x, parent_y]);
68
                }
69
            } else {
70
                // vertical path ending at the bottom of the revisionGraph
71
                path = revisionGraph.path([
72
                    'M', x, y,
73
                    'V', graph_bottom]);
74
            }
75
            path.attr({stroke: colors[commit.space], "stroke-width": 1.5}).toBack();
76
        });
77
        revision_dot_overlay = revisionGraph.circle(x, y, 10);
78
        revision_dot_overlay
79
            .attr({
80
                fill: '#000',
81
                opacity: 0,
82
                cursor: 'pointer', 
83
                href: commit.href
84
            });
85

  
86
        if(commit.refs != null && commit.refs.length > 0) {
87
            title = document.createElementNS(revisionGraph.canvas.namespaceURI, 'title');
88
            title.appendChild(document.createTextNode(commit.refs));
89
            revision_dot_overlay.node.appendChild(title);
90
        }
91
        top.push(revision_dot_overlay);
92
    });
93
    top.toFront();
94
};
.svn/pristine/34/349bb4552fd5e3ee5085280e36098a4598dd3ace.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 AuthSourceLdapTest < ActiveSupport::TestCase
21
  include Redmine::I18n
22
  fixtures :auth_sources
23

  
24
  def setup
25
  end
26

  
27
  def test_create
28
    a = AuthSourceLdap.new(:name => 'My LDAP', :host => 'ldap.example.net', :port => 389, :base_dn => 'dc=example,dc=net', :attr_login => 'sAMAccountName')
29
    assert a.save
30
  end
31

  
32
  def test_should_strip_ldap_attributes
33
    a = AuthSourceLdap.new(:name => 'My LDAP', :host => 'ldap.example.net', :port => 389, :base_dn => 'dc=example,dc=net', :attr_login => 'sAMAccountName',
34
                           :attr_firstname => 'givenName ')
35
    assert a.save
36
    assert_equal 'givenName', a.reload.attr_firstname
37
  end
38

  
39
  def test_replace_port_zero_to_389
40
    a = AuthSourceLdap.new(
41
           :name => 'My LDAP', :host => 'ldap.example.net', :port => 0,
42
           :base_dn => 'dc=example,dc=net', :attr_login => 'sAMAccountName',
43
           :attr_firstname => 'givenName ')
44
    assert a.save
45
    assert_equal 389, a.port
46
  end
47

  
48
  def test_filter_should_be_validated
49
    set_language_if_valid 'en'
50

  
51
    a = AuthSourceLdap.new(:name => 'My LDAP', :host => 'ldap.example.net', :port => 389, :attr_login => 'sn')
52
    a.filter = "(mail=*@redmine.org"
53
    assert !a.valid?
54
    assert_include "LDAP filter is invalid", a.errors.full_messages
55

  
56
    a.filter = "(mail=*@redmine.org)"
57
    assert a.valid?
58
  end
59

  
60
  if ldap_configured?
61
    context '#authenticate' do
62
      setup do
63
        @auth = AuthSourceLdap.find(1)
64
        @auth.update_attribute :onthefly_register, true
65
      end
66

  
67
      context 'with a valid LDAP user' do
68
        should 'return the user attributes' do
69
          attributes =  @auth.authenticate('example1','123456')
70
          assert attributes.is_a?(Hash), "An hash was not returned"
71
          assert_equal 'Example', attributes[:firstname]
72
          assert_equal 'One', attributes[:lastname]
73
          assert_equal 'example1@redmine.org', attributes[:mail]
74
          assert_equal @auth.id, attributes[:auth_source_id]
75
          attributes.keys.each do |attribute|
76
            assert User.new.respond_to?("#{attribute}="), "Unexpected :#{attribute} attribute returned"
77
          end
78
        end
79
      end
80

  
81
      context 'with an invalid LDAP user' do
82
        should 'return nil' do
83
          assert_equal nil, @auth.authenticate('nouser','123456')
84
        end
85
      end
86

  
87
      context 'without a login' do
88
        should 'return nil' do
89
          assert_equal nil, @auth.authenticate('','123456')
90
        end
91
      end
92

  
93
      context 'without a password' do
94
        should 'return nil' do
95
          assert_equal nil, @auth.authenticate('edavis','')
96
        end
97
      end
98

  
99
      context 'without filter' do
100
        should 'return any user' do
101
          assert @auth.authenticate('example1','123456')
102
          assert @auth.authenticate('edavis', '123456')
103
        end
104
      end
105

  
106
      context 'with filter' do
107
        setup do
108
          @auth.filter = "(mail=*@redmine.org)"
109
        end
110

  
111
        should 'return user who matches the filter only' do
112
          assert @auth.authenticate('example1','123456')
113
          assert_nil @auth.authenticate('edavis', '123456')
114
        end
115
      end
116
    end
117

  
118
    def test_authenticate_should_timeout
119
      auth_source = AuthSourceLdap.find(1)
120
      auth_source.timeout = 1
121
      def auth_source.initialize_ldap_con(*args); sleep(5); end
122

  
123
      assert_raise AuthSourceTimeoutException do
124
        auth_source.authenticate 'example1', '123456'
125
      end
126
    end
127
  else
128
    puts '(Test LDAP server not configured)'
129
  end
130
end
.svn/pristine/34/34b50e0d1c5a0c7f91a728223c1c4ed77c186cd6.svn-base
1
--- 
2
wikis_001: 
3
  status: 1
4
  start_page: CookBook documentation
5
  project_id: 1
6
  id: 1
7
wikis_002: 
8
  status: 1
9
  start_page: Start page
10
  project_id: 2
11
  id: 2

Also available in: Unified diff