Revision 912:5e80956cc792 .svn/pristine

View differences:

.svn/pristine/00/005b22dce38bfa0d4254f9b889284c20d8267418.svn-base
1
class <%= class_name %> < ActiveRecord::Migration
2
  def self.up
3
    create_table :open_id_authentication_associations, :force => true do |t|
4
      t.integer :issued, :lifetime
5
      t.string :handle, :assoc_type
6
      t.binary :server_url, :secret
7
    end
8

  
9
    create_table :open_id_authentication_nonces, :force => true do |t|
10
      t.integer :timestamp, :null => false
11
      t.string :server_url, :null => true
12
      t.string :salt, :null => false
13
    end
14
  end
15

  
16
  def self.down
17
    drop_table :open_id_authentication_associations
18
    drop_table :open_id_authentication_nonces
19
  end
20
end
.svn/pristine/00/0065f42c8aab54558480736376f69f7b72cabc58.svn-base
1
require 'test/unit'
2
require 'rubygems'
3

  
4
gem 'activesupport'
5
require 'active_support'
6

  
7
gem 'actionpack'
8
require 'action_controller'
9

  
10
gem 'mocha'
11
require 'mocha'
12

  
13
gem 'ruby-openid'
14
require 'openid'
15

  
16
RAILS_ROOT = File.dirname(__FILE__) unless defined? RAILS_ROOT
17
require File.dirname(__FILE__) + "/../lib/open_id_authentication"
.svn/pristine/00/007e22f777adc578342260747f72f3fcfceb129d.svn-base
1
# Redmine - project management software
2
# Copyright (C) 2006-2011  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 ProjectCustomField < CustomField
19
  def type_name
20
    :label_project_plural
21
  end
22
end
.svn/pristine/00/00c4bd6691f32db8720a826db98aecc930f926d9.svn-base
1
# $Id: entry.rb 123 2006-05-18 03:52:38Z blackhedd $
2
#
3
# LDAP Entry (search-result) support classes
4
#
5
#
6
#----------------------------------------------------------------------------
7
#
8
# Copyright (C) 2006 by Francis Cianfrocca. All Rights Reserved.
9
#
10
# Gmail: garbagecat10
11
#
12
# This program is free software; you can redistribute it and/or modify
13
# it under the terms of the GNU General Public License as published by
14
# the Free Software Foundation; either version 2 of the License, or
15
# (at your option) any later version.
16
#
17
# This program is distributed in the hope that it will be useful,
18
# but WITHOUT ANY WARRANTY; without even the implied warranty of
19
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
# GNU General Public License for more details.
21
#
22
# You should have received a copy of the GNU General Public License
23
# along with this program; if not, write to the Free Software
24
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
25
#
26
#---------------------------------------------------------------------------
27
#
28

  
29

  
30

  
31

  
32
module Net
33
class LDAP
34

  
35

  
36
  # Objects of this class represent individual entries in an LDAP
37
  # directory. User code generally does not instantiate this class.
38
  # Net::LDAP#search provides objects of this class to user code,
39
  # either as block parameters or as return values.
40
  #
41
  # In LDAP-land, an "entry" is a collection of attributes that are
42
  # uniquely and globally identified by a DN ("Distinguished Name").
43
  # Attributes are identified by short, descriptive words or phrases.
44
  # Although a directory is
45
  # free to implement any attribute name, most of them follow rigorous
46
  # standards so that the range of commonly-encountered attribute
47
  # names is not large.
48
  #
49
  # An attribute name is case-insensitive. Most directories also
50
  # restrict the range of characters allowed in attribute names.
51
  # To simplify handling attribute names, Net::LDAP::Entry
52
  # internally converts them to a standard format. Therefore, the
53
  # methods which take attribute names can take Strings or Symbols,
54
  # and work correctly regardless of case or capitalization.
55
  #
56
  # An attribute consists of zero or more data items called
57
  # <i>values.</i> An entry is the combination of a unique DN, a set of attribute
58
  # names, and a (possibly-empty) array of values for each attribute.
59
  #
60
  # Class Net::LDAP::Entry provides convenience methods for dealing
61
  # with LDAP entries.
62
  # In addition to the methods documented below, you may access individual
63
  # attributes of an entry simply by giving the attribute name as
64
  # the name of a method call. For example:
65
  #  ldap.search( ... ) do |entry|
66
  #    puts "Common name: #{entry.cn}"
67
  #    puts "Email addresses:"
68
  #      entry.mail.each {|ma| puts ma}
69
  #  end
70
  # If you use this technique to access an attribute that is not present
71
  # in a particular Entry object, a NoMethodError exception will be raised.
72
  #
73
  #--
74
  # Ugly problem to fix someday: We key off the internal hash with
75
  # a canonical form of the attribute name: convert to a string,
76
  # downcase, then take the symbol. Unfortunately we do this in
77
  # at least three places. Should do it in ONE place.
78
  class Entry
79

  
80
    # This constructor is not generally called by user code.
81
    def initialize dn = nil # :nodoc:
82
      @myhash = Hash.new {|k,v| k[v] = [] }
83
      @myhash[:dn] = [dn]
84
    end
85

  
86

  
87
    def []= name, value # :nodoc:
88
      sym = name.to_s.downcase.intern
89
      @myhash[sym] = value
90
    end
91

  
92

  
93
    #--
94
    # We have to deal with this one as we do with []=
95
    # because this one and not the other one gets called
96
    # in formulations like entry["CN"] << cn.
97
    #
98
    def [] name # :nodoc:
99
      name = name.to_s.downcase.intern unless name.is_a?(Symbol)
100
      @myhash[name]
101
    end
102

  
103
    # Returns the dn of the Entry as a String.
104
    def dn
105
      self[:dn][0]
106
    end
107

  
108
    # Returns an array of the attribute names present in the Entry.
109
    def attribute_names
110
      @myhash.keys
111
    end
112

  
113
    # Accesses each of the attributes present in the Entry.
114
    # Calls a user-supplied block with each attribute in turn,
115
    # passing two arguments to the block: a Symbol giving
116
    # the name of the attribute, and a (possibly empty)
117
    # Array of data values.
118
    #
119
    def each
120
      if block_given?
121
        attribute_names.each {|a|
122
          attr_name,values = a,self[a]
123
          yield attr_name, values
124
        }
125
      end
126
    end
127

  
128
    alias_method :each_attribute, :each
129

  
130

  
131
    #--
132
    # Convenience method to convert unknown method names
133
    # to attribute references. Of course the method name
134
    # comes to us as a symbol, so let's save a little time
135
    # and not bother with the to_s.downcase two-step.
136
    # Of course that means that a method name like mAIL
137
    # won't work, but we shouldn't be encouraging that
138
    # kind of bad behavior in the first place.
139
    # Maybe we should thow something if the caller sends
140
    # arguments or a block...
141
    #
142
    def method_missing *args, &block # :nodoc:
143
      s = args[0].to_s.downcase.intern
144
      if attribute_names.include?(s)
145
        self[s]
146
      elsif s.to_s[-1] == 61 and s.to_s.length > 1
147
        value = args[1] or raise RuntimeError.new( "unable to set value" )
148
        value = [value] unless value.is_a?(Array)
149
        name = s.to_s[0..-2].intern
150
        self[name] = value
151
      else
152
        raise NoMethodError.new( "undefined method '#{s}'" )
153
      end
154
    end
155

  
156
    def write
157
    end
158

  
159
  end # class Entry
160

  
161

  
162
end # class LDAP
163
end # module Net
164

  
165

  
.svn/pristine/00/00c75f473c43fdd31d40a91d365b29f9d7f944cd.svn-base
1
See http://dejavu.sourceforge.net/wiki/index.rb/Bugs
2

  
3
$Id: BUGS 80 2004-11-13 13:12:02Z src $
.svn/pristine/01/01049e9d9cec55a96b7b1a93672943d74c1a87d6.svn-base
1
class AddCustomFieldsSearchable < ActiveRecord::Migration
2
  def self.up
3
    add_column :custom_fields, :searchable, :boolean, :default => false
4
  end
5

  
6
  def self.down
7
    remove_column :custom_fields, :searchable
8
  end
9
end
.svn/pristine/01/011d952bc7773843d5a8219df22dce0959479d6d.svn-base
1
# Redmine - project management software
2
# Copyright (C) 2006-2011  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 DocumentCategoryTest < ActiveSupport::TestCase
21
  fixtures :enumerations, :documents, :issues
22

  
23
  def test_should_be_an_enumeration
24
    assert DocumentCategory.ancestors.include?(Enumeration)
25
  end
26

  
27
  def test_objects_count
28
    assert_equal 2, DocumentCategory.find_by_name("Uncategorized").objects_count
29
    assert_equal 0, DocumentCategory.find_by_name("User documentation").objects_count
30
  end
31

  
32
  def test_option_name
33
    assert_equal :enumeration_doc_categories, DocumentCategory.new.option_name
34
  end
35
end
.svn/pristine/01/01272907f6842a5e924d61c923ee0994110ab686.svn-base
1
# Redmine - project management software
2
# Copyright (C) 2006-2011  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 Redmine::MenuManager::MenuHelperTest < HelperTestCase
21
  include Redmine::MenuManager::MenuHelper
22
  include ActionController::Assertions::SelectorAssertions
23
  fixtures :users, :members, :projects, :enabled_modules
24

  
25
  # Used by assert_select
26
  def html_document
27
    HTML::Document.new(@response.body)
28
  end
29

  
30
  def setup
31
    super
32
    @response = ActionController::TestResponse.new
33
    # Stub the current menu item in the controller
34
    def current_menu_item
35
      :index
36
    end
37
  end
38

  
39

  
40
  context "MenuManager#current_menu_item" do
41
    should "be tested"
42
  end
43

  
44
  context "MenuManager#render_main_menu" do
45
    should "be tested"
46
  end
47

  
48
  context "MenuManager#render_menu" do
49
    should "be tested"
50
  end
51

  
52
  context "MenuManager#menu_item_and_children" do
53
    should "be tested"
54
  end
55

  
56
  context "MenuManager#extract_node_details" do
57
    should "be tested"
58
  end
59

  
60
  def test_render_single_menu_node
61
    node = Redmine::MenuManager::MenuItem.new(:testing, '/test', { })
62
    @response.body = render_single_menu_node(node, 'This is a test', node.url, false)
63

  
64
    assert_select("a.testing", "This is a test")
65
  end
66

  
67
  def test_render_menu_node
68
    single_node = Redmine::MenuManager::MenuItem.new(:single_node, '/test', { })
69
    @response.body = render_menu_node(single_node, nil)
70

  
71
    assert_select("li") do
72
      assert_select("a.single-node", "Single node")
73
    end
74
  end
75

  
76
  def test_render_menu_node_with_nested_items
77
    parent_node = Redmine::MenuManager::MenuItem.new(:parent_node, '/test', { })
78
    parent_node << Redmine::MenuManager::MenuItem.new(:child_one_node, '/test', { })
79
    parent_node << Redmine::MenuManager::MenuItem.new(:child_two_node, '/test', { })
80
    parent_node <<
81
      Redmine::MenuManager::MenuItem.new(:child_three_node, '/test', { }) <<
82
      Redmine::MenuManager::MenuItem.new(:child_three_inner_node, '/test', { })
83

  
84
    @response.body = render_menu_node(parent_node, nil)
85

  
86
    assert_select("li") do
87
      assert_select("a.parent-node", "Parent node")
88
      assert_select("ul") do
89
        assert_select("li a.child-one-node", "Child one node")
90
        assert_select("li a.child-two-node", "Child two node")
91
        assert_select("li") do
92
          assert_select("a.child-three-node", "Child three node")
93
          assert_select("ul") do
94
            assert_select("li a.child-three-inner-node", "Child three inner node")
95
          end
96
        end
97
      end
98
    end
99

  
100
  end
101

  
102
  def test_render_menu_node_with_children
103
    User.current = User.find(2)
104

  
105
    parent_node = Redmine::MenuManager::MenuItem.new(:parent_node,
106
                                                     '/test',
107
                                                     {
108
                                                       :children => Proc.new {|p|
109
                                                         children = []
110
                                                         3.times do |time|
111
                                                           children << Redmine::MenuManager::MenuItem.new("test_child_#{time}",
112
                                                                                                             {:controller => 'issues', :action => 'index'},
113
                                                                                                             {})
114
                                                         end
115
                                                         children
116
                                                       }
117
                                                     })
118
    @response.body = render_menu_node(parent_node, Project.find(1))
119

  
120
    assert_select("li") do
121
      assert_select("a.parent-node", "Parent node")
122
      assert_select("ul") do
123
        assert_select("li a.test-child-0", "Test child 0")
124
        assert_select("li a.test-child-1", "Test child 1")
125
        assert_select("li a.test-child-2", "Test child 2")
126
      end
127
    end
128
  end
129

  
130
  def test_render_menu_node_with_nested_items_and_children
131
    User.current = User.find(2)
132

  
133
    parent_node = Redmine::MenuManager::MenuItem.new(:parent_node,
134
                                                     '/test',
135
                                                     {
136
                                                       :children => Proc.new {|p|
137
                                                         children = []
138
                                                         3.times do |time|
139
                                                           children << Redmine::MenuManager::MenuItem.new("test_child_#{time}", {:controller => 'issues', :action => 'index'}, {})
140
                                                         end
141
                                                         children
142
                                                       }
143
                                                     })
144

  
145
    parent_node << Redmine::MenuManager::MenuItem.new(:child_node,
146
                                                     '/test',
147
                                                     {
148
                                                       :children => Proc.new {|p|
149
                                                         children = []
150
                                                         6.times do |time|
151
                                                            children << Redmine::MenuManager::MenuItem.new("test_dynamic_child_#{time}", {:controller => 'issues', :action => 'index'}, {})
152
                                                         end
153
                                                         children
154
                                                       }
155
                                                     })
156

  
157
    @response.body = render_menu_node(parent_node, Project.find(1))
158

  
159
    assert_select("li") do
160
      assert_select("a.parent-node", "Parent node")
161
      assert_select("ul") do
162
        assert_select("li a.child-node", "Child node")
163
        assert_select("ul") do
164
          assert_select("li a.test-dynamic-child-0", "Test dynamic child 0")
165
          assert_select("li a.test-dynamic-child-1", "Test dynamic child 1")
166
          assert_select("li a.test-dynamic-child-2", "Test dynamic child 2")
167
          assert_select("li a.test-dynamic-child-3", "Test dynamic child 3")
168
          assert_select("li a.test-dynamic-child-4", "Test dynamic child 4")
169
          assert_select("li a.test-dynamic-child-5", "Test dynamic child 5")
170
        end
171
        assert_select("li a.test-child-0", "Test child 0")
172
        assert_select("li a.test-child-1", "Test child 1")
173
        assert_select("li a.test-child-2", "Test child 2")
174
      end
175
    end
176
  end
177

  
178
  def test_render_menu_node_with_children_without_an_array
179
    parent_node = Redmine::MenuManager::MenuItem.new(:parent_node,
180
                                                     '/test',
181
                                                     {
182
                                                       :children => Proc.new {|p| Redmine::MenuManager::MenuItem.new("test_child", "/testing", {})}
183
                                                     })
184

  
185
    assert_raises Redmine::MenuManager::MenuError, ":children must be an array of MenuItems" do
186
      @response.body = render_menu_node(parent_node, Project.find(1))
187
    end
188
  end
189

  
190
  def test_render_menu_node_with_incorrect_children
191
    parent_node = Redmine::MenuManager::MenuItem.new(:parent_node,
192
                                                     '/test',
193
                                                     {
194
                                                       :children => Proc.new {|p| ["a string"] }
195
                                                     })
196

  
197
    assert_raises Redmine::MenuManager::MenuError, ":children must be an array of MenuItems" do
198
      @response.body = render_menu_node(parent_node, Project.find(1))
199
    end
200

  
201
  end
202

  
203
  def test_menu_items_for_should_yield_all_items_if_passed_a_block
204
    menu_name = :test_menu_items_for_should_yield_all_items_if_passed_a_block
205
    Redmine::MenuManager.map menu_name do |menu|
206
      menu.push(:a_menu, '/', { })
207
      menu.push(:a_menu_2, '/', { })
208
      menu.push(:a_menu_3, '/', { })
209
    end
210

  
211
    items_yielded = []
212
    menu_items_for(menu_name) do |item|
213
      items_yielded << item
214
    end
215

  
216
    assert_equal 3, items_yielded.size
217
  end
218

  
219
  def test_menu_items_for_should_return_all_items
220
    menu_name = :test_menu_items_for_should_return_all_items
221
    Redmine::MenuManager.map menu_name do |menu|
222
      menu.push(:a_menu, '/', { })
223
      menu.push(:a_menu_2, '/', { })
224
      menu.push(:a_menu_3, '/', { })
225
    end
226

  
227
    items = menu_items_for(menu_name)
228
    assert_equal 3, items.size
229
  end
230

  
231
  def test_menu_items_for_should_skip_unallowed_items_on_a_project
232
    menu_name = :test_menu_items_for_should_skip_unallowed_items_on_a_project
233
    Redmine::MenuManager.map menu_name do |menu|
234
      menu.push(:a_menu, {:controller => 'issues', :action => 'index' }, { })
235
      menu.push(:a_menu_2, {:controller => 'issues', :action => 'index' }, { })
236
      menu.push(:unallowed, {:controller => 'issues', :action => 'unallowed' }, { })
237
    end
238

  
239
    User.current = User.find(2)
240

  
241
    items = menu_items_for(menu_name, Project.find(1))
242
    assert_equal 2, items.size
243
  end
244

  
245
  def test_menu_items_for_should_skip_items_that_fail_the_conditions
246
    menu_name = :test_menu_items_for_should_skip_items_that_fail_the_conditions
247
    Redmine::MenuManager.map menu_name do |menu|
248
      menu.push(:a_menu, {:controller => 'issues', :action => 'index' }, { })
249
      menu.push(:unallowed,
250
                {:controller => 'issues', :action => 'index' },
251
                { :if => Proc.new { false }})
252
    end
253

  
254
    User.current = User.find(2)
255

  
256
    items = menu_items_for(menu_name, Project.find(1))
257
    assert_equal 1, items.size
258
  end
259

  
260
end
.svn/pristine/01/013035c9e2d7a0734359dad136ab782f7272366b.svn-base
1
class CreateJournals < ActiveRecord::Migration
2

  
3
  # model removed, but needed for data migration
4
  class IssueHistory < ActiveRecord::Base; belongs_to :issue; end
5
  # model removed
6
  class Permission < ActiveRecord::Base; end
7

  
8
  def self.up
9
    create_table :journals, :force => true do |t|
10
      t.column "journalized_id", :integer, :default => 0, :null => false
11
      t.column "journalized_type", :string, :limit => 30, :default => "", :null => false
12
      t.column "user_id", :integer, :default => 0, :null => false
13
      t.column "notes", :text
14
      t.column "created_on", :datetime, :null => false
15
    end
16
    create_table :journal_details, :force => true do |t|
17
      t.column "journal_id", :integer, :default => 0, :null => false
18
      t.column "property", :string, :limit => 30, :default => "", :null => false
19
      t.column "prop_key", :string, :limit => 30, :default => "", :null => false
20
      t.column "old_value", :string
21
      t.column "value", :string
22
    end
23

  
24
    # indexes
25
    add_index "journals", ["journalized_id", "journalized_type"], :name => "journals_journalized_id"
26
    add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id"
27

  
28
    Permission.create :controller => "issues", :action => "history", :description => "label_history", :sort => 1006, :is_public => true, :mail_option => 0, :mail_enabled => 0
29

  
30
    # data migration
31
    IssueHistory.find(:all, :include => :issue).each {|h|
32
      j = Journal.new(:journalized => h.issue, :user_id => h.author_id, :notes => h.notes, :created_on => h.created_on)
33
      j.details << JournalDetail.new(:property => 'attr', :prop_key => 'status_id', :value => h.status_id)
34
      j.save
35
    }
36

  
37
    drop_table :issue_histories
38
  end
39

  
40
  def self.down
41
    drop_table :journal_details
42
    drop_table :journals
43

  
44
    create_table "issue_histories", :force => true do |t|
45
      t.column "issue_id", :integer, :default => 0, :null => false
46
      t.column "status_id", :integer, :default => 0, :null => false
47
      t.column "author_id", :integer, :default => 0, :null => false
48
      t.column "notes", :text, :default => ""
49
      t.column "created_on", :timestamp
50
    end
51

  
52
    add_index "issue_histories", ["issue_id"], :name => "issue_histories_issue_id"
53

  
54
    Permission.find(:first, :conditions => ["controller=? and action=?", 'issues', 'history']).destroy
55
  end
56
end
.svn/pristine/01/01346eb099170b569ce9589ce5f15a834ff1b1a7.svn-base
1
# Various mathematical calculations extracted from the PDF::Writer for Ruby gem.
2
# - http://rubyforge.org/projects/ruby-pdf
3
# - Copyright 2003 - 2005 Austin Ziegler.
4
# - Licensed under a MIT-style licence.
5
#
6

  
7
module RFPDF::Math
8
  PI2   = ::Math::PI * 2.0
9

  
10
  # One degree of arc measured in terms of radians.
11
  DR  = PI2 / 360.0
12
  # One radian of arc, measured in terms of degrees.
13
  RD  = 360 / PI2
14
  # One degree of arc, measured in terms of gradians.
15
  DG  = 400 / 360.0
16
  # One gradian of arc, measured in terms of degrees.
17
  GD  = 360 / 400.0
18
  # One radian of arc, measured in terms of gradians.
19
  RG  = 400 / PI2
20
  # One gradian of arc, measured in terms of radians.
21
  GR  = PI2 / 400.0
22

  
23
  # Truncate the remainder.
24
  def remt(num, den)
25
    num - den * (num / den.to_f).to_i
26
  end
27

  
28
  # Wrap radian values within the range of radians (0..PI2).
29
  def rad2rad(rad)
30
    remt(rad, PI2)
31
  end
32

  
33
  # Wrap degree values within the range of degrees (0..360).
34
  def deg2deg(deg)
35
    remt(deg, 360)
36
  end
37

  
38
  # Wrap gradian values within the range of gradians (0..400).
39
  def grad2grad(grad)
40
    remt(grad, 400)
41
  end
42

  
43
  # Convert degrees to radians. The value will be constrained to the
44
  # range of radians (0..PI2) unless +wrap+ is false.
45
  def deg2rad(deg, wrap = true)
46
    rad = DR * deg
47
    rad = rad2rad(rad) if wrap
48
    rad
49
  end
50

  
51
  # Convert degrees to gradians. The value will be constrained to the
52
  # range of gradians (0..400) unless +wrap+ is false.
53
  def deg2grad(deg, wrap = true)
54
    grad = DG * deg
55
    grad = grad2grad(grad) if wrap
56
    grad
57
  end
58

  
59
  # Convert radians to degrees. The value will be constrained to the
60
  # range of degrees (0..360) unless +wrap+ is false.
61
  def rad2deg(rad, wrap = true)
62
    deg = RD * rad
63
    deg = deg2deg(deg) if wrap
64
    deg
65
  end
66

  
67
  # Convert radians to gradians. The value will be constrained to the
68
  # range of gradians (0..400) unless +wrap+ is false.
69
  def rad2grad(rad, wrap = true)
70
    grad = RG * rad
71
    grad = grad2grad(grad) if wrap
72
    grad
73
  end
74

  
75
  # Convert gradians to degrees. The value will be constrained to the
76
  # range of degrees (0..360) unless +wrap+ is false.
77
  def grad2deg(grad, wrap = true)
78
    deg = GD * grad
79
    deg = deg2deg(deg) if wrap
80
    deg
81
  end
82

  
83
  # Convert gradians to radians. The value will be constrained to the
84
  # range of radians (0..PI2) unless +wrap+ is false.
85
  def grad2rad(grad, wrap = true)
86
    rad = GR * grad
87
    rad = rad2rad(rad) if wrap
88
    rad
89
  end
90
end
.svn/pristine/01/016b47aef50027cc7a73f1b3fdde3506ed5b4072.svn-base
1
class IssueCategory < ActiveRecord::Base
2
  generator_for :name, :start => 'Category 0001'
3

  
4
end
.svn/pristine/01/0171e251406a6b1885f3fa9813dc6f97a4ee7ea8.svn-base
1
require File.dirname(__FILE__) + '/test_helper'
2

  
3
class NormalizeTest < Test::Unit::TestCase
4
  include OpenIdAuthentication
5

  
6
  NORMALIZATIONS = {
7
    "openid.aol.com/nextangler"             => "http://openid.aol.com/nextangler",
8
    "http://openid.aol.com/nextangler"      => "http://openid.aol.com/nextangler",
9
    "https://openid.aol.com/nextangler"     => "https://openid.aol.com/nextangler",
10
    "HTTP://OPENID.AOL.COM/NEXTANGLER"      => "http://openid.aol.com/NEXTANGLER",
11
    "HTTPS://OPENID.AOL.COM/NEXTANGLER"     => "https://openid.aol.com/NEXTANGLER",
12
    "loudthinking.com"                      => "http://loudthinking.com/",
13
    "http://loudthinking.com"               => "http://loudthinking.com/",
14
    "http://loudthinking.com:80"            => "http://loudthinking.com/",
15
    "https://loudthinking.com:443"          => "https://loudthinking.com/",
16
    "http://loudthinking.com:8080"          => "http://loudthinking.com:8080/",
17
    "techno-weenie.net"                     => "http://techno-weenie.net/",
18
    "http://techno-weenie.net"              => "http://techno-weenie.net/",
19
    "http://techno-weenie.net  "            => "http://techno-weenie.net/",
20
    "=name"                                 => "=name"
21
  }
22

  
23
  def test_normalizations
24
    NORMALIZATIONS.each do |from, to|
25
      assert_equal to, normalize_identifier(from)
26
    end
27
  end
28

  
29
  def test_broken_open_id
30
    assert_raises(InvalidOpenId) { normalize_identifier(nil) }
31
  end
32
end
.svn/pristine/01/01c72fb7f3d1eed2891447f585aaa09ce5f33082.svn-base
1
jsToolBar.strings = {};
2
jsToolBar.strings['Strong'] = 'پررنگ';
3
jsToolBar.strings['Italic'] = 'کج';
4
jsToolBar.strings['Underline'] = 'زیرخط';
5
jsToolBar.strings['Deleted'] = 'برداشته شده';
6
jsToolBar.strings['Code'] = 'کد درون خطی';
7
jsToolBar.strings['Heading 1'] = 'سربرگ ۱';
8
jsToolBar.strings['Heading 2'] = 'سربرگ ۲';
9
jsToolBar.strings['Heading 3'] = 'سربرگ ۳';
10
jsToolBar.strings['Unordered list'] = 'فهرست بدون شماره';
11
jsToolBar.strings['Ordered list'] = 'فهرست با شماره';
12
jsToolBar.strings['Quote'] = 'تو بردن';
13
jsToolBar.strings['Unquote'] = 'بیرون آوردن';
14
jsToolBar.strings['Preformatted text'] = 'نوشته قالب بندی شده';
15
jsToolBar.strings['Wiki link'] = 'پیوند به برگ ویکی';
16
jsToolBar.strings['Image'] = 'عکس';
.svn/pristine/01/01d08f5b37dfa46aae097b270dbf10baa02d7e48.svn-base
1
class ExportPdf < ActiveRecord::Migration
2
  # model removed
3
  class Permission < ActiveRecord::Base; end
4

  
5
  def self.up
6
    Permission.create :controller => "projects", :action => "export_issues_pdf", :description => "label_export_pdf", :sort => 1002, :is_public => true, :mail_option => 0, :mail_enabled => 0
7
    Permission.create :controller => "issues", :action => "export_pdf", :description => "label_export_pdf", :sort => 1015, :is_public => true, :mail_option => 0, :mail_enabled => 0
8
  end
9

  
10
  def self.down
11
    Permission.find(:first, :conditions => ["controller=? and action=?", 'projects', 'export_issues_pdf']).destroy
12
    Permission.find(:first, :conditions => ["controller=? and action=?", 'issues', 'export_pdf']).destroy
13
  end
14
end
.svn/pristine/01/01fd40d061a2be270b23a0152d0699de1966efc7.svn-base
1
--- 
2
roles_001: 
3
  name: Manager
4
  id: 1
5
  builtin: 0
6
  issues_visibility: all
7
  permissions: |
8
    --- 
9
    - :add_project
10
    - :edit_project
11
    - :select_project_modules
12
    - :manage_members
13
    - :manage_versions
14
    - :manage_categories
15
    - :view_issues
16
    - :add_issues
17
    - :edit_issues
18
    - :manage_issue_relations
19
    - :manage_subtasks
20
    - :add_issue_notes
21
    - :move_issues
22
    - :delete_issues
23
    - :view_issue_watchers
24
    - :add_issue_watchers
25
    - :set_issues_private
26
    - :delete_issue_watchers
27
    - :manage_public_queries
28
    - :save_queries
29
    - :view_gantt
30
    - :view_calendar
31
    - :log_time
32
    - :view_time_entries
33
    - :edit_time_entries
34
    - :delete_time_entries
35
    - :manage_news
36
    - :comment_news
37
    - :view_documents
38
    - :manage_documents
39
    - :view_wiki_pages
40
    - :export_wiki_pages
41
    - :view_wiki_edits
42
    - :edit_wiki_pages
43
    - :delete_wiki_pages_attachments
44
    - :protect_wiki_pages
45
    - :delete_wiki_pages
46
    - :rename_wiki_pages
47
    - :add_messages
48
    - :edit_messages
49
    - :delete_messages
50
    - :manage_boards
51
    - :view_files
52
    - :manage_files
53
    - :browse_repository
54
    - :manage_repository
55
    - :view_changesets
56
    - :manage_project_activities
57

  
58
  position: 1
59
roles_002: 
60
  name: Developer
61
  id: 2
62
  builtin: 0
63
  issues_visibility: default
64
  permissions: |
65
    --- 
66
    - :edit_project
67
    - :manage_members
68
    - :manage_versions
69
    - :manage_categories
70
    - :view_issues
71
    - :add_issues
72
    - :edit_issues
73
    - :manage_issue_relations
74
    - :manage_subtasks
75
    - :add_issue_notes
76
    - :move_issues
77
    - :delete_issues
78
    - :view_issue_watchers
79
    - :save_queries
80
    - :view_gantt
81
    - :view_calendar
82
    - :log_time
83
    - :view_time_entries
84
    - :edit_own_time_entries
85
    - :manage_news
86
    - :comment_news
87
    - :view_documents
88
    - :manage_documents
89
    - :view_wiki_pages
90
    - :view_wiki_edits
91
    - :edit_wiki_pages
92
    - :protect_wiki_pages
93
    - :delete_wiki_pages
94
    - :add_messages
95
    - :edit_own_messages
96
    - :delete_own_messages
97
    - :manage_boards
98
    - :view_files
99
    - :manage_files
100
    - :browse_repository
101
    - :view_changesets
102

  
103
  position: 2
104
roles_003: 
105
  name: Reporter
106
  id: 3
107
  builtin: 0
108
  issues_visibility: default
109
  permissions: |
110
    --- 
111
    - :edit_project
112
    - :manage_members
113
    - :manage_versions
114
    - :manage_categories
115
    - :view_issues
116
    - :add_issues
117
    - :edit_issues
118
    - :manage_issue_relations
119
    - :add_issue_notes
120
    - :move_issues
121
    - :view_issue_watchers
122
    - :save_queries
123
    - :view_gantt
124
    - :view_calendar
125
    - :log_time
126
    - :view_time_entries
127
    - :manage_news
128
    - :comment_news
129
    - :view_documents
130
    - :manage_documents
131
    - :view_wiki_pages
132
    - :view_wiki_edits
133
    - :edit_wiki_pages
134
    - :delete_wiki_pages
135
    - :add_messages
136
    - :manage_boards
137
    - :view_files
138
    - :manage_files
139
    - :browse_repository
140
    - :view_changesets
141

  
142
  position: 3
143
roles_004: 
144
  name: Non member
145
  id: 4
146
  builtin: 1
147
  issues_visibility: default
148
  permissions: |
149
    --- 
150
    - :view_issues
151
    - :add_issues
152
    - :edit_issues
153
    - :manage_issue_relations
154
    - :add_issue_notes
155
    - :move_issues
156
    - :save_queries
157
    - :view_gantt
158
    - :view_calendar
159
    - :log_time
160
    - :view_time_entries
161
    - :comment_news
162
    - :view_documents
163
    - :manage_documents
164
    - :view_wiki_pages
165
    - :view_wiki_edits
166
    - :edit_wiki_pages
167
    - :add_messages
168
    - :view_files
169
    - :manage_files
170
    - :browse_repository
171
    - :view_changesets
172

  
173
  position: 4
174
roles_005: 
175
  name: Anonymous
176
  id: 5
177
  builtin: 2
178
  issues_visibility: default
179
  permissions: |
180
    --- 
181
    - :view_issues
182
    - :add_issue_notes
183
    - :view_gantt
184
    - :view_calendar
185
    - :view_time_entries
186
    - :view_documents
187
    - :view_wiki_pages
188
    - :view_wiki_edits
189
    - :view_files
190
    - :browse_repository
191
    - :view_changesets
192

  
193
  position: 5
194

  
.svn/pristine/02/025612e4a47b7cb1c36f52b9661b0cc1f94b2a45.svn-base
1
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
one:
3
  id: 1
4
<% for attribute in attributes -%>
5
  <%= attribute.name %>: <%= attribute.default %>
6
<% end -%>
7
two:
8
  id: 2
9
<% for attribute in attributes -%>
10
  <%= attribute.name %>: <%= attribute.default %>
11
<% end -%>
.svn/pristine/02/028f99ce7a03d78da3e425bf63496e052307234f.svn-base
1
Message-ID: <4974C93E.3070005@somenet.foo>
2
Date: Mon, 19 Jan 2009 19:41:02 +0100
3
From: "John Smith" <jsmith@somenet.foo>
4
User-Agent: Thunderbird 2.0.0.19 (Windows/20081209)
5
MIME-Version: 1.0
6
To: redmine@somenet.foo
7
Subject: Reply via email
8
References: <redmine.message-2.20070512171800@somenet.foo>
9
In-Reply-To: <redmine.message-2.20070512171800@somenet.foo>
10
Content-Type: text/plain; charset=UTF-8; format=flowed
11
Content-Transfer-Encoding: 7bit
12

  
13
This is a reply to a forum message.
14

  
15

  
.svn/pristine/02/02c8aed5827fd37b4953522a150e77160bca0811.svn-base
1
--- 
2
issue_categories_001: 
3
  name: Printing
4
  project_id: 1
5
  assigned_to_id: 2
6
  id: 1
7
issue_categories_002: 
8
  name: Recipes
9
  project_id: 1
10
  assigned_to_id: 
11
  id: 2
12
issue_categories_003: 
13
  name: Stock management
14
  project_id: 2
15
  assigned_to_id: 
16
  id: 3
17
issue_categories_004: 
18
  name: Printing
19
  project_id: 2
20
  assigned_to_id: 
21
  id: 4
22
  
.svn/pristine/02/02dadac204e591b101d6e3bacd9c59cdeb84b1b6.svn-base
1
<ul>
2
  <% if !@time_entry.nil? -%>
3
    <li><%= context_menu_link l(:button_edit), {:controller => 'timelog', :action => 'edit', :id => @time_entry},
4
            :class => 'icon-edit', :disabled => !@can[:edit] %></li>
5
  <% else %>
6
    <li><%= context_menu_link l(:button_edit), {:controller => 'timelog', :action => 'bulk_edit', :ids => @time_entries.collect(&:id)},
7
            :class => 'icon-edit', :disabled => !@can[:edit] %></li>
8
  <% end %>
9

  
10
  <%= call_hook(:view_time_entries_context_menu_start, {:time_entries => @time_entries, :can => @can, :back => @back }) %>
11

  
12
  <% if @activities.present? -%>
13
  <li class="folder">
14
    <a href="#" class="submenu"><%= l(:field_activity) %></a>
15
    <ul>
16
    <% @activities.each do |u| -%>
17
        <li><%= context_menu_link h(u.name), {:controller => 'timelog', :action => 'bulk_edit', :ids => @time_entries.collect(&:id), :time_entry => {'activity_id' => u}, :back_url => @back}, :method => :post,
18
                                  :selected => (@time_entry && u == @time_entry.activity), :disabled => !@can[:edit] %></li>
19
    <% end -%>
20
        <li><%= context_menu_link l(:label_none), {:controller => 'timelog', :action => 'bulk_edit', :ids => @time_entries.collect(&:id), :time_entry => {'activity_id' => 'none'}, :back_url => @back}, :method => :post,
21
                                  :selected => (@time_entry && @time_entry.activity.nil?), :disabled => !@can[:edit] %></li>
22
    </ul>
23
  </li>
24
  <% end %>
25

  
26
  <%= call_hook(:view_time_entries_context_menu_end, {:time_entries => @time_entries, :can => @can, :back => @back }) %>
27

  
28
  <li>
29
    <%= context_menu_link l(:button_delete),
30
      {:controller => 'timelog', :action => 'destroy', :ids => @time_entries.collect(&:id), :back_url => @back},
31
      :method => :delete, :confirm => l(:text_time_entries_destroy_confirmation), :class => 'icon-del', :disabled => !@can[:delete] %>
32
  </li>
33
</ul>
.svn/pristine/02/02f1dca1c1029f6ec67eec5619e4edd46e4ee43d.svn-base
1
class AddChangesetsScmid < ActiveRecord::Migration
2
  def self.up
3
    add_column :changesets, :scmid, :string
4
  end
5

  
6
  def self.down
7
    remove_column :changesets, :scmid
8
  end
9
end
.svn/pristine/03/03110323c21c0fa4339bdcd80aed971c5c6bd9d4.svn-base
1
api.issue_category do
2
  api.id @category.id
3
  api.project(:id => @category.project_id, :name => @category.project.name) unless @category.project.nil?
4
  api.name @category.name
5
  api.assigned_to(:id => @category.assigned_to_id, :name => @category.assigned_to.name) unless @category.assigned_to.nil?
6
end
.svn/pristine/03/032e9aa73399010aaf3eb408ecd8fb8f296696b1.svn-base
1
<div class="contextual">
2
  <% if User.current.allowed_to?(:add_subprojects, @project) %>
3
    <%= link_to l(:label_subproject_new), {:controller => 'projects', :action => 'new', :parent_id => @project}, :class => 'icon icon-add' %>
4
  <% end %>
5
</div>
6

  
7
<h2><%=l(:label_overview)%></h2>
8

  
9
<div class="splitcontentleft">
10
  <div class="wiki">
11
    <%= textilizable @project.description %>
12
  </div>
13
  <ul>
14
  <% unless @project.homepage.blank? %><li><%=l(:field_homepage)%>: <%= auto_link(h(@project.homepage)) %></li><% end %>
15
  <% if @subprojects.any? %>
16
   <li><%=l(:label_subproject_plural)%>:
17
      <%= @subprojects.collect{|p| link_to(h(p), :action => 'show', :id => p)}.join(", ").html_safe %></li>
18
  <% end %>
19
  <% @project.visible_custom_field_values.each do |custom_value| %>
20
  <% if !custom_value.value.blank? %>
21
     <li><%=h custom_value.custom_field.name %>: <%=h show_value(custom_value) %></li>
22
  <% end %>
23
  <% end %>
24
  </ul>
25

  
26
  <% if User.current.allowed_to?(:view_issues, @project) %>
27
  <div class="issues box">
28
    <h3><%=l(:label_issue_tracking)%></h3>
29
    <ul>
30
    <% for tracker in @trackers %>
31
      <li><%= link_to h(tracker.name), :controller => 'issues', :action => 'index', :project_id => @project,
32
                                                :set_filter => 1,
33
                                                "tracker_id" => tracker.id %>:
34
          <%= l(:label_x_open_issues_abbr_on_total, :count => @open_issues_by_tracker[tracker].to_i,
35
                                                    :total => @total_issues_by_tracker[tracker].to_i) %>
36
      </li>
37
    <% end %>
38
    </ul>
39
    <p>
40
      <%= link_to l(:label_issue_view_all), :controller => 'issues', :action => 'index', :project_id => @project, :set_filter => 1 %>
41
      <% if User.current.allowed_to?(:view_calendar, @project, :global => true) %>
42
        | <%= link_to(l(:label_calendar), :controller => 'calendars', :action => 'show', :project_id => @project) %>
43
      <% end %>
44
      <% if User.current.allowed_to?(:view_gantt, @project, :global => true) %>
45
        | <%= link_to(l(:label_gantt), :controller => 'gantts', :action => 'show', :project_id => @project) %>
46
      <% end %>
47
    </p>
48
  </div>
49
  <% end %>
50
  <%= call_hook(:view_projects_show_left, :project => @project) %>
51
</div>
52

  
53
<div class="splitcontentright">
54
  <%= render :partial => 'members_box' %>
55

  
56
  <% if @news.any? && authorize_for('news', 'index') %>
57
  <div class="news box">
58
    <h3><%=l(:label_news_latest)%></h3>
59
    <%= render :partial => 'news/news', :collection => @news %>
60
    <p><%= link_to l(:label_news_view_all), :controller => 'news', :action => 'index', :project_id => @project %></p>
61
  </div>
62
  <% end %>
63
  <%= call_hook(:view_projects_show_right, :project => @project) %>
64
</div>
65

  
66
<% content_for :sidebar do %>
67
    <% if @total_hours.present? %>
68
    <h3><%= l(:label_spent_time) %></h3>
69
    <p><span class="icon icon-time"><%= l_hours(@total_hours) %></span></p>
70
    <p><%= link_to(l(:label_details), {:controller => 'timelog', :action => 'index', :project_id => @project}) %> |
71
    <%= link_to(l(:label_report), {:controller => 'time_entry_reports', :action => 'report', :project_id => @project}) %></p>
72
    <% end %>
73
    <%= call_hook(:view_projects_show_sidebar_bottom, :project => @project) %>
74
<% end %>
75

  
76
<% content_for :header_tags do %>
77
<%= auto_discovery_link_tag(:atom, {:controller => 'activities', :action => 'index', :id => @project, :format => 'atom', :key => User.current.rss_key}) %>
78
<% end %>
79

  
80
<% html_title(l(:label_overview)) -%>
.svn/pristine/03/033178c724d843125ead35eb43e31dacdb4a5511.svn-base
1
# Patch the data from a boolean change.
2
class UpdateMailNotificationValues < ActiveRecord::Migration
3
  def self.up
4
    # No-op
5
    # See 20100129193402_change_users_mail_notification_to_string.rb
6
  end
7

  
8
  def self.down
9
    # No-op
10
  end
11
end
.svn/pristine/03/03389ce7c25a023f73b895dc03af8c3f1ee755e9.svn-base
1
<h2><%=l(:label_document)%></h2>
2

  
3
<% form_tag({:action => 'edit', :id => @document}, :class => "tabular") do %>
4
  <%= render :partial => 'form' %>
5
  <%= submit_tag l(:button_save) %>
6
<% end %>
7

  
8

  
.svn/pristine/03/033d037b8655e755ff07ebfb8102a3786ab52ea0.svn-base
1
<p><%= l(:mail_body_account_activation_request, h(@user.login)) %></p>
2
<p><%= link_to h(@url), @url %></p>
.svn/pristine/03/033e041df5add14807dd8e40c1a8ef8894cdf897.svn-base
1
Return-Path: <john.doe@somenet.foo>
2
Received: from osiris ([127.0.0.1])
3
	by OSIRIS
4
	with hMailServer ; Sun, 22 Jun 2008 12:28:07 +0200
5
Message-ID: <000501c8d452$a95cd7e0$0a00a8c0@osiris>
6
From: "John Doe" <john.doe@somenet.foo>
7
To: <redmine@somenet.foo>
8
Subject: Ticket by unknown user
9
Date: Sun, 22 Jun 2008 12:28:07 +0200
10
MIME-Version: 1.0
11
Content-Type: text/plain;
12
	format=flowed;
13
	charset="iso-8859-1";
14
	reply-type=original
15
Content-Transfer-Encoding: 7bit
16

  
17
This is a ticket submitted by an unknown user.
18

  
.svn/pristine/03/0341468b2bb841c8c330355c1e3aa94ad3cce987.svn-base
1
*SVN* (version numbers are overrated)
2

  
3
* (5 Oct 2006) Allow customization of #versions association options [Dan Peterson]
4

  
5
*0.5.1*
6

  
7
* (8 Aug 2006) Versioned models now belong to the unversioned model.  @article_version.article.class => Article [Aslak Hellesoy]
8

  
9
*0.5* # do versions even matter for plugins?
10

  
11
* (21 Apr 2006) Added without_locking and without_revision methods.
12

  
13
  Foo.without_revision do
14
    @foo.update_attributes ...
15
  end
16

  
17
*0.4*
18

  
19
* (28 March 2006) Rename non_versioned_fields to non_versioned_columns (old one is kept for compatibility).
20
* (28 March 2006) Made explicit documentation note that string column names are required for non_versioned_columns.
21

  
22
*0.3.1*
23

  
24
* (7 Jan 2006) explicitly set :foreign_key option for the versioned model's belongs_to assocation for STI [Caged]
25
* (7 Jan 2006) added tests to prove has_many :through joins work
26

  
27
*0.3*
28

  
29
* (2 Jan 2006) added ability to share a mixin with versioned class
30
* (2 Jan 2006) changed the dynamic version model to MyModel::Version
31

  
32
*0.2.4*
33

  
34
* (27 Nov 2005) added note about possible destructive behavior of if_changed? [Michael Schuerig]
35

  
36
*0.2.3*
37

  
38
* (12 Nov 2005) fixed bug with old behavior of #blank? [Michael Schuerig]
39
* (12 Nov 2005) updated tests to use ActiveRecord Schema
40

  
41
*0.2.2*
42

  
43
* (3 Nov 2005) added documentation note to #acts_as_versioned [Martin Jul]
44

  
45
*0.2.1*
46

  
47
* (6 Oct 2005) renamed dirty? to changed? to keep it uniform.  it was aliased to keep it backwards compatible.
48

  
49
*0.2* 
50

  
51
* (6 Oct 2005)  added find_versions and find_version class methods.
52

  
53
* (6 Oct 2005)  removed transaction from create_versioned_table().  
54
  this way you can specify your own transaction around a group of operations.
55

  
56
* (30 Sep 2005) fixed bug where find_versions() would order by 'version' twice. (found by Joe Clark)
57

  
58
* (26 Sep 2005) added :sequence_name option to acts_as_versioned to set the sequence name on the versioned model
59

  
60
*0.1.3* (18 Sep 2005)
61

  
62
* First RubyForge release
63

  
64
*0.1.2*
65

  
66
* check if module is already included when acts_as_versioned is called
67

  
68
*0.1.1*
69

  
70
* Adding tests and rdocs
71

  
72
*0.1* 
73

  
74
* Initial transfer from Rails ticket: http://dev.rubyonrails.com/ticket/1974
.svn/pristine/03/0367c769a1dec5c6ffea095893b82d493a02e68a.svn-base
1
# Redmine - project management software
2
# Copyright (C) 2006-2011  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 'redmine/scm/adapters/subversion_adapter'
19

  
20
class Repository::Subversion < Repository
21
  attr_protected :root_url
22
  validates_presence_of :url
23
  validates_format_of :url, :with => /^(http|https|svn(\+[^\s:\/\\]+)?|file):\/\/.+/i
24

  
25
  def self.scm_adapter_class
26
    Redmine::Scm::Adapters::SubversionAdapter
27
  end
28

  
29
  def self.scm_name
30
    'Subversion'
31
  end
32

  
33
  def supports_directory_revisions?
34
    true
35
  end
36

  
37
  def repo_log_encoding
38
    'UTF-8'
39
  end
40

  
41
  def latest_changesets(path, rev, limit=10)
42
    revisions = scm.revisions(path, rev, nil, :limit => limit)
43
    revisions ? changesets.find_all_by_revision(revisions.collect(&:identifier), :order => "committed_on DESC", :include => :user) : []
44
  end
45

  
46
  # Returns a path relative to the url of the repository
47
  def relative_path(path)
48
    path.gsub(Regexp.new("^\/?#{Regexp.escape(relative_url)}"), '')
49
  end
50

  
51
  def fetch_changesets
52
    scm_info = scm.info
53
    if scm_info
54
      # latest revision found in database
55
      db_revision = latest_changeset ? latest_changeset.revision.to_i : 0
56
      # latest revision in the repository
57
      scm_revision = scm_info.lastrev.identifier.to_i
58
      if db_revision < scm_revision
59
        logger.debug "Fetching changesets for repository #{url}" if logger && logger.debug?
60
        identifier_from = db_revision + 1
61
        while (identifier_from <= scm_revision)
62
          # loads changesets by batches of 200
63
          identifier_to = [identifier_from + 199, scm_revision].min
64
          revisions = scm.revisions('', identifier_to, identifier_from, :with_paths => true)
65
          revisions.reverse_each do |revision|
66
            transaction do
67
              changeset = Changeset.create(:repository   => self,
68
                                           :revision     => revision.identifier,
69
                                           :committer    => revision.author,
70
                                           :committed_on => revision.time,
71
                                           :comments     => revision.message)
72

  
73
              revision.paths.each do |change|
74
                changeset.create_change(change)
75
              end unless changeset.new_record?
76
            end
77
          end unless revisions.nil?
78
          identifier_from = identifier_to + 1
79
        end
80
      end
81
    end
82
  end
83

  
84
  private
85

  
86
  # Returns the relative url of the repository
87
  # Eg: root_url = file:///var/svn/foo
88
  #     url      = file:///var/svn/foo/bar
89
  #     => returns /bar
90
  def relative_url
91
    @relative_url ||= url.gsub(Regexp.new("^#{Regexp.escape(root_url || scm.root_url)}", Regexp::IGNORECASE), '')
92
  end
93
end
.svn/pristine/03/03803ec02697cfe8f89b59eb47e58dc9312a0502.svn-base
1
# Redmine - project management software
2
# Copyright (C) 2006-2011  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 Redmine::UnifiedDiffTest < ActiveSupport::TestCase
21

  
22
  def setup
23
  end
24

  
25
  def test_subversion_diff
26
    diff = Redmine::UnifiedDiff.new(read_diff_fixture('subversion.diff'))
27
    # number of files
28
    assert_equal 4, diff.size
29
    assert diff.detect {|file| file.file_name =~ %r{^config/settings.yml}}
30
  end
31

  
32
  def test_truncate_diff
33
    diff = Redmine::UnifiedDiff.new(read_diff_fixture('subversion.diff'), :max_lines => 20)
34
    assert_equal 2, diff.size
35
  end
36

  
37
  def test_inline_partials
38
    diff = Redmine::UnifiedDiff.new(read_diff_fixture('partials.diff'))
39
    assert_equal 1, diff.size
40
    diff = diff.first
41
    assert_equal 43, diff.size
42

  
43
    assert_equal [51, -1], diff[0].offsets
44
    assert_equal [51, -1], diff[1].offsets
45
    assert_equal 'Lorem ipsum dolor sit amet, consectetur adipiscing <span>elit</span>', diff[0].html_line
46
    assert_equal 'Lorem ipsum dolor sit amet, consectetur adipiscing <span>xx</span>', diff[1].html_line
47

  
48
    assert_nil diff[2].offsets
49
    assert_equal 'Praesent et sagittis dui. Vivamus ac diam diam', diff[2].html_line
50

  
51
    assert_equal [0, -14], diff[3].offsets
52
    assert_equal [0, -14], diff[4].offsets
53
    assert_equal '<span>Ut sed</span> auctor justo', diff[3].html_line
54
    assert_equal '<span>xxx</span> auctor justo', diff[4].html_line
55

  
56
    assert_equal [13, -19], diff[6].offsets
57
    assert_equal [13, -19], diff[7].offsets
58

  
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff