Revision 1297:0a574315af3e .svn/pristine/22

View differences:

.svn/pristine/22/2215da5ea32efbcca552e4718d4f9896046cbfa7.svn-base
1
<%= wiki_page_breadcrumb(@page) %>
2

  
3
<h2><%= h @original_title %></h2>
4

  
5
<%= error_messages_for 'page' %>
6

  
7
<%= labelled_form_for :wiki_page, @page,
8
                     :url => { :action => 'rename' },
9
                     :html => { :method => :post } do |f| %>
10
<div class="box tabular">
11
<p><%= f.text_field :title, :required => true, :size => 100  %></p>
12
<p><%= f.check_box :redirect_existing_links %></p>
13
<p><%= f.select :parent_id,
14
                content_tag('option', '', :value => '') + 
15
                  wiki_page_options_for_select(
16
                    @wiki.pages.all(:include => :parent) - @page.self_and_descendants,
17
                    @page.parent),
18
                :label => :field_parent_title %></p>
19
</div>
20
<%= submit_tag l(:button_rename) %>
21
<% end %>
.svn/pristine/22/22425409df08842dce9d0920b3c239700ff36d87.svn-base
1
Date: Mon, 19 Nov 2012 10:17:45 +0900
2
Message-ID: <CANBr5-U6cXMfLek5QiB2ZrBPR3vTThn9_Upvdkf3Dkod664+Xw@mail.gmail.com>
3
Subject: test
4
From: John Smith <JSmith@somenet.foo>
5
To: redmine@somenet.foo
6
Content-Type: multipart/mixed; boundary=bcaec54ee4ea84f77904cecee22e
7

  
8
--bcaec54ee4ea84f77904cecee22e
9
Content-Type: text/plain; charset=ISO-8859-1
10

  
11
test
12

  
13
--bcaec54ee4ea84f77904cecee22e
14
Content-Type: text/plain; charset=US-ASCII; name="=?ISO-2022-JP?B?GyRCJUYlOSVIGyhCLnR4dA==?="
15
Content-Disposition: attachment; filename="=?ISO-2022-JP?B?GyRCJUYlOSVIGyhCLnR4dA==?="
16
Content-Transfer-Encoding: base64
17
X-Attachment-Id: f_h9owndpv0
18

  
19
dGVzdAo=
20
--bcaec54ee4ea84f77904cecee22e--
.svn/pristine/22/226ca6df54d2f722db0a366c7bc4bc8b7ec109c6.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
19
  module SubclassFactory
20
    def self.included(base) 
21
      base.extend ClassMethods
22
    end 
23

  
24
    module ClassMethods
25
      def get_subclass(class_name)
26
        klass = nil
27
        begin
28
          klass = class_name.to_s.classify.constantize
29
        rescue
30
          # invalid class name
31
        end
32
        unless subclasses.include? klass
33
          klass = nil
34
        end
35
        klass
36
      end
37

  
38
      # Returns an instance of the given subclass name
39
      def new_subclass_instance(class_name, *args)
40
        klass = get_subclass(class_name)
41
        if klass
42
          klass.new(*args)
43
        end
44
      end
45
    end
46
  end
47
end
.svn/pristine/22/228763af0fab9d92d601d760e23db085d02a829d.svn-base
1
<div class="contextual">
2
  &#171;
3
  <% unless @changeset.previous.nil? -%>
4
    <%= link_to_revision(@changeset.previous, @repository, :text => l(:label_previous)) %>
5
  <% else -%>
6
    <%= l(:label_previous) %>
7
  <% end -%>
8
|
9
  <% unless @changeset.next.nil? -%>
10
    <%= link_to_revision(@changeset.next, @repository, :text => l(:label_next)) %>
11
  <% else -%>
12
    <%= l(:label_next) %>
13
  <% end -%>
14
  &#187;&nbsp;
15

  
16
  <%= form_tag({:controller => 'repositories',
17
               :action     => 'revision',
18
               :id         => @project,
19
               :repository_id => @repository.identifier_param,
20
               :rev        => nil},
21
               :method     => :get) do %>
22
    <%= text_field_tag 'rev', @rev, :size => 8 %>
23
    <%= submit_tag 'OK', :name => nil %>
24
  <% end %>
25
</div>
26

  
27
<h2><%= avatar(@changeset.user, :size => "24") %><%= l(:label_revision) %> <%= format_revision(@changeset) %></h2>
28

  
29
<% if @changeset.scmid.present? || @changeset.parents.present? || @changeset.children.present? %>
30
<table class="revision-info">
31
  <% if @changeset.scmid.present? %>
32
    <tr>
33
      <td>ID</td><td><%= h(@changeset.scmid) %></td>
34
    </tr>
35
  <% end %>
36
  <% if @changeset.parents.present? %>
37
    <tr>
38
      <td><%= l(:label_parent_revision) %></td>
39
      <td>
40
        <%= @changeset.parents.collect{
41
              |p| link_to_revision(p, @repository, :text => format_revision(p))
42
            }.join(", ").html_safe %>
43
      </td>
44
    </tr>
45
  <% end %>
46
  <% if @changeset.children.present? %>
47
    <tr>
48
      <td><%= l(:label_child_revision) %></td>
49
      <td>
50
       <%= @changeset.children.collect{
51
              |p| link_to_revision(p, @repository, :text => format_revision(p))
52
             }.join(", ").html_safe %>
53
      </td>
54
    </tr>
55
  <% end %>
56
</table>
57
<% end %>
58

  
59
<p>
60
<span class="author">
61
<%= authoring(@changeset.committed_on, @changeset.author) %>
62
</span>
63
</p>
64

  
65
<%= textilizable @changeset.comments %>
66

  
67
<% if @changeset.issues.visible.any? || User.current.allowed_to?(:manage_related_issues, @repository.project) %>
68
  <%= render :partial => 'related_issues' %>
69
<% end %>
70

  
71
<% if User.current.allowed_to?(:browse_repository, @project) %>
72
<h3><%= l(:label_attachment_plural) %></h3>
73
<ul id="changes-legend">
74
<li class="change change-A"><%= l(:label_added)    %></li>
75
<li class="change change-M"><%= l(:label_modified) %></li>
76
<li class="change change-C"><%= l(:label_copied)   %></li>
77
<li class="change change-R"><%= l(:label_renamed)  %></li>
78
<li class="change change-D"><%= l(:label_deleted)  %></li>
79
</ul>
80

  
81
<p><%= link_to(l(:label_view_diff),
82
               :action => 'diff',
83
               :id     => @project,
84
               :repository_id => @repository.identifier_param,
85
               :path   => "",
86
               :rev    => @changeset.identifier) if @changeset.filechanges.any? %></p>
87

  
88
<div class="changeset-changes">
89
<%= render_changeset_changes %>
90
</div>
91
<% end %>
92

  
93
<% content_for :header_tags do %>
94
<%= stylesheet_link_tag "scm" %>
95
<% end %>
96

  
97
<% html_title("#{l(:label_revision)} #{format_revision(@changeset)}") -%>
.svn/pristine/22/228ab5b14477141cc691a1ebb6e20efbefbf1ba7.svn-base
1
<table class="list transitions transitions-<%= name %>">
2
<thead>
3
  <tr>
4
    <th align="left">
5
      <%= link_to_function(image_tag('toggle_check.png'), "toggleCheckboxesBySelector('table.transitions-#{name} input')",
6
                                                          :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}") %>
7
      <%=l(:label_current_status)%>
8
    </th>
9
    <th align="center" colspan="<%= @statuses.length %>"><%=l(:label_new_statuses_allowed)%></th>
10
  </tr>
11
  <tr>
12
    <td></td>
13
    <% for new_status in @statuses %>
14
    <td width="<%= 75 / @statuses.size %>%" align="center">
15
      <%= link_to_function(image_tag('toggle_check.png'), "toggleCheckboxesBySelector('table.transitions-#{name} input.new-status-#{new_status.id}')",
16
                                                      :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}") %>
17
      <%=h new_status.name %>
18
    </td>
19
    <% end %>
20
  </tr>
21
</thead>
22
<tbody>
23
  <% for old_status in @statuses %>
24
  <tr class="<%= cycle("odd", "even") %>">
25
    <td>
26
      <%= link_to_function(image_tag('toggle_check.png'), "toggleCheckboxesBySelector('table.transitions-#{name} input.old-status-#{old_status.id}')",
27
                                                          :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}") %>
28

  
29
      <%=h old_status.name %>
30
    </td>
31
    <% for new_status in @statuses -%>
32
    <% checked = workflows.detect {|w| w.old_status_id == old_status.id && w.new_status_id == new_status.id} %>
33
    <td align="center" class="<%= checked ? 'enabled' : '' %>">
34
      <%= check_box_tag "issue_status[#{ old_status.id }][#{new_status.id}][]", name, checked,
35
            :class => "old-status-#{old_status.id} new-status-#{new_status.id}" %>
36
    </td>
37
    <% end -%>
38
  </tr>
39
  <% end %>
40
</tbody>
41
</table>
.svn/pristine/22/22d0c7f9d45361c16b2b7eccd0c488f009ccf152.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 TimeEntryActivityTest < ActiveSupport::TestCase
21
  fixtures :enumerations, :time_entries, :custom_fields
22

  
23
  include Redmine::I18n
24

  
25
  def test_should_be_an_enumeration
26
    assert TimeEntryActivity.ancestors.include?(Enumeration)
27
  end
28

  
29
  def test_objects_count
30
    assert_equal 3, TimeEntryActivity.find_by_name("Design").objects_count
31
    assert_equal 2, TimeEntryActivity.find_by_name("Development").objects_count
32
  end
33

  
34
  def test_option_name
35
    assert_equal :enumeration_activities, TimeEntryActivity.new.option_name
36
  end
37

  
38
  def test_create_with_custom_field
39
    field = TimeEntryActivityCustomField.find_by_name('Billable')
40
    e = TimeEntryActivity.new(:name => 'Custom Data')
41
    e.custom_field_values = {field.id => "1"}
42
    assert e.save
43

  
44
    e.reload
45
    assert_equal "1", e.custom_value_for(field).value
46
  end
47

  
48
  def test_create_without_required_custom_field_should_fail
49
    set_language_if_valid 'en'
50
    field = TimeEntryActivityCustomField.find_by_name('Billable')
51
    field.update_attribute(:is_required, true)
52

  
53
    e = TimeEntryActivity.new(:name => 'Custom Data')
54
    assert !e.save
55
    assert_equal ["Billable can't be blank"], e.errors.full_messages
56
  end
57

  
58
  def test_create_with_required_custom_field_should_succeed
59
    field = TimeEntryActivityCustomField.find_by_name('Billable')
60
    field.update_attribute(:is_required, true)
61

  
62
    e = TimeEntryActivity.new(:name => 'Custom Data')
63
    e.custom_field_values = {field.id => "1"}
64
    assert e.save
65
  end
66

  
67
  def test_update_with_required_custom_field_change
68
    set_language_if_valid 'en'
69
    field = TimeEntryActivityCustomField.find_by_name('Billable')
70
    field.update_attribute(:is_required, true)
71

  
72
    e = TimeEntryActivity.find(10)
73
    assert e.available_custom_fields.include?(field)
74
    # No change to custom field, record can be saved
75
    assert e.save
76
    # Blanking custom field, save should fail
77
    e.custom_field_values = {field.id => ""}
78
    assert !e.save
79
    assert_equal ["Billable can't be blank"], e.errors.full_messages
80

  
81
    # Update custom field to valid value, save should succeed
82
    e.custom_field_values = {field.id => "0"}
83
    assert e.save
84
    e.reload
85
    assert_equal "0", e.custom_value_for(field).value
86
  end
87
end
88

  
.svn/pristine/22/22ddddc8c878fc3e93d3136a28528f9e4f69f7e0.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 Redmine::SafeAttributesTest < ActiveSupport::TestCase
21
  fixtures :users
22

  
23
  class Base
24
    def attributes=(attrs)
25
      attrs.each do |key, value|
26
        send("#{key}=", value)
27
      end
28
    end
29
  end
30

  
31
  class Person < Base
32
    attr_accessor :firstname, :lastname, :login
33
    include Redmine::SafeAttributes
34
    safe_attributes :firstname, :lastname
35
    safe_attributes :login, :if => lambda {|person, user| user.admin?}
36
  end
37

  
38
  class Book < Base
39
    attr_accessor :title
40
    include Redmine::SafeAttributes
41
    safe_attributes :title
42
  end
43

  
44
  def test_safe_attribute_names
45
    p = Person.new
46
    user = User.anonymous
47
    assert_equal ['firstname', 'lastname'], p.safe_attribute_names(user)
48
    assert p.safe_attribute?('firstname', user)
49
    assert !p.safe_attribute?('login', user)
50

  
51
    p = Person.new
52
    user = User.find(1)
53
    assert_equal ['firstname', 'lastname', 'login'], p.safe_attribute_names(user)
54
    assert p.safe_attribute?('firstname', user)
55
    assert p.safe_attribute?('login', user)
56
  end
57

  
58
  def test_safe_attribute_names_without_user
59
    p = Person.new
60
    User.current = nil
61
    assert_equal ['firstname', 'lastname'], p.safe_attribute_names
62
    assert p.safe_attribute?('firstname')
63
    assert !p.safe_attribute?('login')
64

  
65
    p = Person.new
66
    User.current = User.find(1)
67
    assert_equal ['firstname', 'lastname', 'login'], p.safe_attribute_names
68
    assert p.safe_attribute?('firstname')
69
    assert p.safe_attribute?('login')
70
  end
71

  
72
  def test_set_safe_attributes
73
    p = Person.new
74
    p.send('safe_attributes=', {'firstname' => 'John', 'lastname' => 'Smith', 'login' => 'jsmith'}, User.anonymous)
75
    assert_equal 'John', p.firstname
76
    assert_equal 'Smith', p.lastname
77
    assert_nil p.login
78

  
79
    p = Person.new
80
    User.current = User.find(1)
81
    p.send('safe_attributes=', {'firstname' => 'John', 'lastname' => 'Smith', 'login' => 'jsmith'}, User.find(1))
82
    assert_equal 'John', p.firstname
83
    assert_equal 'Smith', p.lastname
84
    assert_equal 'jsmith', p.login
85
  end
86

  
87
  def test_set_safe_attributes_without_user
88
    p = Person.new
89
    User.current = nil
90
    p.safe_attributes = {'firstname' => 'John', 'lastname' => 'Smith', 'login' => 'jsmith'}
91
    assert_equal 'John', p.firstname
92
    assert_equal 'Smith', p.lastname
93
    assert_nil p.login
94

  
95
    p = Person.new
96
    User.current = User.find(1)
97
    p.safe_attributes = {'firstname' => 'John', 'lastname' => 'Smith', 'login' => 'jsmith'}
98
    assert_equal 'John', p.firstname
99
    assert_equal 'Smith', p.lastname
100
    assert_equal 'jsmith', p.login
101
  end
102
end
.svn/pristine/22/22e0815b30d651aac0c03e283ee06938ada8af0c.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 'net/imap'
19

  
20
module Redmine
21
  module IMAP
22
    class << self
23
      def check(imap_options={}, options={})
24
        host = imap_options[:host] || '127.0.0.1'
25
        port = imap_options[:port] || '143'
26
        ssl = !imap_options[:ssl].nil?
27
        folder = imap_options[:folder] || 'INBOX'
28

  
29
        imap = Net::IMAP.new(host, port, ssl)
30
        imap.login(imap_options[:username], imap_options[:password]) unless imap_options[:username].nil?
31
        imap.select(folder)
32
        imap.search(['NOT', 'SEEN']).each do |message_id|
33
          msg = imap.fetch(message_id,'RFC822')[0].attr['RFC822']
34
          logger.debug "Receiving message #{message_id}" if logger && logger.debug?
35
          if MailHandler.receive(msg, options)
36
            logger.debug "Message #{message_id} successfully received" if logger && logger.debug?
37
            if imap_options[:move_on_success]
38
              imap.copy(message_id, imap_options[:move_on_success])
39
            end
40
            imap.store(message_id, "+FLAGS", [:Seen, :Deleted])
41
          else
42
            logger.debug "Message #{message_id} can not be processed" if logger && logger.debug?
43
            imap.store(message_id, "+FLAGS", [:Seen])
44
            if imap_options[:move_on_failure]
45
              imap.copy(message_id, imap_options[:move_on_failure])
46
              imap.store(message_id, "+FLAGS", [:Deleted])
47
            end
48
          end
49
        end
50
        imap.expunge
51
      end
52

  
53
      private
54

  
55
      def logger
56
        ::Rails.logger
57
      end
58
    end
59
  end
60
end
.svn/pristine/22/22fbfd1ac0d86469e5085705e69350a177979509.svn-base
1
class AddWorkflowsAssigneeAndAuthor < ActiveRecord::Migration
2
  def self.up
3
    add_column :workflows, :assignee, :boolean, :null => false, :default => false
4
    add_column :workflows, :author, :boolean, :null => false, :default => false
5

  
6
    WorkflowRule.update_all(:assignee => false)
7
    WorkflowRule.update_all(:author => false)
8
  end
9

  
10
  def self.down
11
    remove_column :workflows, :assignee
12
    remove_column :workflows, :author
13
  end
14
end

Also available in: Unified diff