Revision 1298:4f746d8966dd .svn/pristine/46

View differences:

.svn/pristine/46/460154f7f38123fe1c4a30970945d9f47767461e.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
module Redmine
19
  module WikiFormatting
20
    module Textile
21
      module Helper
22
        def wikitoolbar_for(field_id)
23
          heads_for_wiki_formatter
24
          # Is there a simple way to link to a public resource?
25
          url = "#{Redmine::Utils.relative_url_root}/help/wiki_syntax.html"
26
          help_link = link_to(l(:setting_text_formatting), url,
27
            :onclick => "window.open(\"#{ url }\", \"\", \"resizable=yes, location=no, width=300, height=640, menubar=no, status=no, scrollbars=yes\"); return false;")
28

  
29
          javascript_tag("var wikiToolbar = new jsToolBar($('#{field_id}')); wikiToolbar.setHelpLink('#{escape_javascript help_link}'); wikiToolbar.draw();")
30
        end
31

  
32
        def initial_page_content(page)
33
          "h1. #{@page.pretty_title}"
34
        end
35

  
36
        def heads_for_wiki_formatter
37
          unless @heads_for_wiki_formatter_included
38
            content_for :header_tags do
39
              javascript_include_tag('jstoolbar/jstoolbar') +
40
              javascript_include_tag('jstoolbar/textile') +
41
              javascript_include_tag("jstoolbar/lang/jstoolbar-#{current_language.to_s.downcase}") +
42
              stylesheet_link_tag('jstoolbar')
43
            end
44
            @heads_for_wiki_formatter_included = true
45
          end
46
        end
47
      end
48
    end
49
  end
50
end
.svn/pristine/46/4604849a86c8bbf40b2a1eb833e2c3ff6fe87f8f.svn-base
1
<div class="contextual">
2
<%= watcher_tag(@wiki, User.current) %>
3
</div>
4

  
5
<h2><%= l(:label_index_by_date) %></h2>
6

  
7
<% if @pages.empty? %>
8
<p class="nodata"><%= l(:label_no_data) %></p>
9
<% end %>
10

  
11
<% @pages_by_date.keys.sort.reverse.each do |date| %>
12
<h3><%= format_date(date) %></h3>
13
<ul>
14
<% @pages_by_date[date].each do |page| %>
15
    <li><%= link_to h(page.pretty_title), :action => 'show', :id => page.title, :project_id => page.project %></li>
16
<% end %>
17
</ul>
18
<% end %>
19

  
20
<% content_for :sidebar do %>
21
  <%= render :partial => 'sidebar' %>
22
<% end %>
23

  
24
<% unless @pages.empty? %>
25
<% other_formats_links do |f| %>
26
  <%= f.link_to 'Atom', :url => {:controller => 'activities', :action => 'index', :id => @project, :show_wiki_edits => 1, :key => User.current.rss_key} %>
27
  <%= f.link_to('HTML', :url => {:action => 'export'}) if User.current.allowed_to?(:export_wiki_pages, @project) %>
28
<% end %>
29
<% end %>
30

  
31
<% content_for :header_tags do %>
32
<%= auto_discovery_link_tag(:atom, :controller => 'activities', :action => 'index', :id => @project, :show_wiki_edits => 1, :format => 'atom', :key => User.current.rss_key) %>
33
<% end %>
.svn/pristine/46/460823ad942a6dbaf3986f763002fe9ab659fb36.svn-base
1
# Redmine - project management software
2
# Copyright (C) 2006-2013  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 WorkflowPermission < WorkflowRule
19
  validates_inclusion_of :rule, :in => %w(readonly required)
20
  validate :validate_field_name
21

  
22
  # Replaces the workflow permissions for the given tracker and role
23
  #
24
  # Example:
25
  #   WorkflowPermission.replace_permissions role, tracker, {'due_date' => {'1' => 'readonly', '2' => 'required'}}
26
  def self.replace_permissions(tracker, role, permissions)
27
    destroy_all(:tracker_id => tracker.id, :role_id => role.id)
28

  
29
    permissions.each { |field, rule_by_status_id|
30
      rule_by_status_id.each { |status_id, rule|
31
        if rule.present?
32
          WorkflowPermission.create(:role_id => role.id, :tracker_id => tracker.id, :old_status_id => status_id, :field_name => field, :rule => rule)
33
        end
34
      }
35
    }
36
  end
37

  
38
  protected
39

  
40
  def validate_field_name
41
    unless Tracker::CORE_FIELDS_ALL.include?(field_name) || field_name.to_s.match(/^\d+$/)
42
      errors.add :field_name, :invalid
43
    end
44
  end
45
end
.svn/pristine/46/46d08e5d685f85ea6b371254e247586c06beb87e.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
require 'sys_controller'
20
require 'mocha'
21

  
22
# Re-raise errors caught by the controller.
23
class SysController; def rescue_action(e) raise e end; end
24

  
25
class SysControllerTest < ActionController::TestCase
26
  fixtures :projects, :repositories, :enabled_modules
27

  
28
  def setup
29
    @controller = SysController.new
30
    @request    = ActionController::TestRequest.new
31
    @response   = ActionController::TestResponse.new
32
    Setting.sys_api_enabled = '1'
33
    Setting.enabled_scm = %w(Subversion Git)
34
  end
35

  
36
  def test_projects_with_repository_enabled
37
    get :projects
38
    assert_response :success
39
    assert_equal 'application/xml', @response.content_type
40
    with_options :tag => 'projects' do |test|
41
      test.assert_tag :children => { :count  => Project.active.has_module(:repository).count }
42
      test.assert_tag 'project', :child => {:tag => 'identifier', :sibling => {:tag => 'is-public'}}
43
    end
44
    assert_no_tag 'extra-info'
45
    assert_no_tag 'extra_info'
46
  end
47

  
48
  def test_create_project_repository
49
    assert_nil Project.find(4).repository
50

  
51
    post :create_project_repository, :id => 4,
52
                                     :vendor => 'Subversion',
53
                                     :repository => { :url => 'file:///create/project/repository/subproject2'}
54
    assert_response :created
55
    assert_equal 'application/xml', @response.content_type
56

  
57
    r = Project.find(4).repository
58
    assert r.is_a?(Repository::Subversion)
59
    assert_equal 'file:///create/project/repository/subproject2', r.url
60
    
61
    assert_tag 'repository-subversion',
62
      :child => {
63
        :tag => 'id', :content => r.id.to_s,
64
        :sibling => {:tag => 'url', :content => r.url}
65
      }
66
    assert_no_tag 'extra-info'
67
    assert_no_tag 'extra_info'
68
  end
69

  
70
  def test_fetch_changesets
71
    Repository::Subversion.any_instance.expects(:fetch_changesets).returns(true)
72
    get :fetch_changesets
73
    assert_response :success
74
  end
75

  
76
  def test_fetch_changesets_one_project
77
    Repository::Subversion.any_instance.expects(:fetch_changesets).returns(true)
78
    get :fetch_changesets, :id => 'ecookbook'
79
    assert_response :success
80
  end
81

  
82
  def test_fetch_changesets_unknown_project
83
    get :fetch_changesets, :id => 'unknown'
84
    assert_response 404
85
  end
86

  
87
  def test_disabled_ws_should_respond_with_403_error
88
    with_settings :sys_api_enabled => '0' do
89
      get :projects
90
      assert_response 403
91
    end
92
  end
93

  
94
  def test_api_key
95
    with_settings :sys_api_key => 'my_secret_key' do
96
      get :projects, :key => 'my_secret_key'
97
      assert_response :success
98
    end
99
  end
100

  
101
  def test_wrong_key_should_respond_with_403_error
102
    with_settings :sys_api_enabled => 'my_secret_key' do
103
      get :projects, :key => 'wrong_key'
104
      assert_response 403
105
    end
106
  end
107
end

Also available in: Unified diff