Revision 1298:4f746d8966dd .svn/pristine/1a

View differences:

.svn/pristine/1a/1a57484f351c2899093aa4b926665fc8327667ab.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
require File.expand_path('../../test_helper', __FILE__)
19

  
20
class LayoutTest < ActionController::IntegrationTest
21
  fixtures :projects, :trackers, :issue_statuses, :issues,
22
           :enumerations, :users, :issue_categories,
23
           :projects_trackers,
24
           :roles,
25
           :member_roles,
26
           :members,
27
           :enabled_modules
28

  
29
  test "browsing to a missing page should render the base layout" do
30
    get "/users/100000000"
31

  
32
    assert_response :not_found
33

  
34
    # UsersController uses the admin layout by default
35
    assert_select "#admin-menu", :count => 0
36
  end
37

  
38
  test "browsing to an unauthorized page should render the base layout" do
39
    change_user_password('miscuser9', 'test1234')
40

  
41
    log_user('miscuser9','test1234')
42

  
43
    get "/admin"
44
    assert_response :forbidden
45
    assert_select "#admin-menu", :count => 0
46
  end
47

  
48
  def test_top_menu_and_search_not_visible_when_login_required
49
    with_settings :login_required => '1' do
50
      get '/'
51
      assert_select "#top-menu > ul", 0
52
      assert_select "#quick-search", 0
53
    end
54
  end
55

  
56
  def test_top_menu_and_search_visible_when_login_not_required
57
    with_settings :login_required => '0' do
58
      get '/'
59
      assert_select "#top-menu > ul"
60
      assert_select "#quick-search"
61
    end
62
  end
63

  
64
  def test_wiki_formatter_header_tags
65
    Role.anonymous.add_permission! :add_issues
66

  
67
    get '/projects/ecookbook/issues/new'
68
    assert_tag :script,
69
      :attributes => {:src => %r{^/javascripts/jstoolbar/jstoolbar-textile.min.js}},
70
      :parent => {:tag => 'head'}
71
  end
72

  
73
  def test_calendar_header_tags
74
    with_settings :default_language => 'fr' do
75
      get '/issues'
76
      assert_include "/javascripts/i18n/jquery.ui.datepicker-fr.js", response.body
77
    end
78

  
79
    with_settings :default_language => 'en-GB' do
80
      get '/issues'
81
      assert_include "/javascripts/i18n/jquery.ui.datepicker-en-GB.js", response.body
82
    end
83

  
84
    with_settings :default_language => 'en' do
85
      get '/issues'
86
      assert_not_include "/javascripts/i18n/jquery.ui.datepicker", response.body
87
    end
88

  
89
    with_settings :default_language => 'zh' do
90
      get '/issues'
91
      assert_include "/javascripts/i18n/jquery.ui.datepicker-zh-CN.js", response.body
92
    end
93

  
94
    with_settings :default_language => 'zh-TW' do
95
      get '/issues'
96
      assert_include "/javascripts/i18n/jquery.ui.datepicker-zh-TW.js", response.body
97
    end
98

  
99
    with_settings :default_language => 'pt' do
100
      get '/issues'
101
      assert_include "/javascripts/i18n/jquery.ui.datepicker-pt.js", response.body
102
    end
103

  
104
    with_settings :default_language => 'pt-BR' do
105
      get '/issues'
106
      assert_include "/javascripts/i18n/jquery.ui.datepicker-pt-BR.js", response.body
107
    end
108
  end
109

  
110
  def test_search_field_outside_project_should_link_to_global_search
111
    get '/'
112
    assert_select 'div#quick-search form[action=/search]'
113
  end
114

  
115
  def test_search_field_inside_project_should_link_to_project_search
116
    get '/projects/ecookbook'
117
    assert_select 'div#quick-search form[action=/projects/ecookbook/search]'
118
  end
119
end
.svn/pristine/1a/1a5ac9a1d7cbc1a58738649fabccca79dc7633e5.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
require File.expand_path('../../../test_helper', __FILE__)
19

  
20
class RoutingWikisTest < ActionController::IntegrationTest
21
  def test_wikis_plural_admin_setup
22
    ["get", "post"].each do |method|
23
      assert_routing(
24
          { :method => method, :path => "/projects/ladida/wiki/destroy" },
25
          { :controller => 'wikis', :action => 'destroy', :id => 'ladida' }
26
        )
27
    end
28
    assert_routing(
29
        { :method => 'post', :path => "/projects/ladida/wiki" },
30
        { :controller => 'wikis', :action => 'edit', :id => 'ladida' }
31
      )
32
  end
33
end
.svn/pristine/1a/1a762326747d7b8c686840a8d5c0aaf794f1453e.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
require File.expand_path('../../../test_helper', __FILE__)
19

  
20
class RoutingCustomFieldsTest < ActionController::IntegrationTest
21
  def test_custom_fields
22
    assert_routing(
23
        { :method => 'get', :path => "/custom_fields" },
24
        { :controller => 'custom_fields', :action => 'index' }
25
      )
26
    assert_routing(
27
        { :method => 'get', :path => "/custom_fields/new" },
28
        { :controller => 'custom_fields', :action => 'new' }
29
      )
30
    assert_routing(
31
        { :method => 'post', :path => "/custom_fields" },
32
        { :controller => 'custom_fields', :action => 'create' }
33
      )
34
    assert_routing(
35
        { :method => 'get', :path => "/custom_fields/2/edit" },
36
        { :controller => 'custom_fields', :action => 'edit', :id => '2' }
37
      )
38
    assert_routing(
39
        { :method => 'put', :path => "/custom_fields/2" },
40
        { :controller => 'custom_fields', :action => 'update', :id => '2' }
41
      )
42
    assert_routing(
43
        { :method => 'delete', :path => "/custom_fields/2" },
44
        { :controller => 'custom_fields', :action => 'destroy', :id => '2' }
45
      )
46
  end
47
end
.svn/pristine/1a/1a82d923d734db1f664f7d362dd31d181914982f.svn-base
1
<div class="contextual">
2
<%= link_to_remote l(:button_add),
3
                   :url => {:controller => 'watchers',
4
                            :action => 'new',
5
                            :object_type => watched.class.name.underscore,
6
                            :object_id => watched} if User.current.allowed_to?(:add_issue_watchers, @project) %>
7
</div>
8

  
9
<h3><%= l(:label_issue_watchers) %> (<%= watched.watcher_users.size %>)</h3>
10

  
11
<% unless @watcher.nil? %>
12
  <% remote_form_for(:watcher, @watcher,
13
                     :url => {:controller => 'watchers',
14
                              :action => 'new',
15
                              :object_type => watched.class.name.underscore,
16
                              :object_id => watched},
17
                      :method => :post,
18
                     :html => {:id => 'new-watcher-form'}) do |f| %>
19
    <p><%= f.select :user_id, (watched.addable_watcher_users.collect {|m| [m.name, m.id]}), :prompt => "--- #{l(:actionview_instancetag_blank_option)} ---" %>
20

  
21
    <%= submit_tag l(:button_add) %>
22
    <%= toggle_link l(:button_cancel), 'new-watcher-form'%></p>
23
  <% end %>
24
<% end %>
25

  
26
<%= watchers_list(watched) %>
.svn/pristine/1a/1a8a501f625f400265586ffe68a1c06c8affc4fc.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 CalendarTest < ActiveSupport::TestCase
21

  
22
  def test_monthly
23
    c = Redmine::Helpers::Calendar.new(Date.today, :fr, :month)
24
    assert_equal [1, 7], [c.startdt.cwday, c.enddt.cwday]
25

  
26
    c = Redmine::Helpers::Calendar.new('2007-07-14'.to_date, :fr, :month)
27
    assert_equal ['2007-06-25'.to_date, '2007-08-05'.to_date], [c.startdt, c.enddt]
28

  
29
    c = Redmine::Helpers::Calendar.new(Date.today, :en, :month)
30
    assert_equal [7, 6], [c.startdt.cwday, c.enddt.cwday]
31
  end
32

  
33
  def test_weekly
34
    c = Redmine::Helpers::Calendar.new(Date.today, :fr, :week)
35
    assert_equal [1, 7], [c.startdt.cwday, c.enddt.cwday]
36

  
37
    c = Redmine::Helpers::Calendar.new('2007-07-14'.to_date, :fr, :week)
38
    assert_equal ['2007-07-09'.to_date, '2007-07-15'.to_date], [c.startdt, c.enddt]
39

  
40
    c = Redmine::Helpers::Calendar.new(Date.today, :en, :week)
41
    assert_equal [7, 6], [c.startdt.cwday, c.enddt.cwday]
42
  end
43

  
44
  def test_monthly_start_day
45
    [1, 6, 7].each do |day|
46
      with_settings :start_of_week => day do
47
        c = Redmine::Helpers::Calendar.new(Date.today, :en, :month)
48
        assert_equal day , c.startdt.cwday
49
        assert_equal (day + 5) % 7 + 1, c.enddt.cwday
50
      end
51
    end
52
  end
53

  
54
  def test_weekly_start_day
55
    [1, 6, 7].each do |day|
56
      with_settings :start_of_week => day do
57
        c = Redmine::Helpers::Calendar.new(Date.today, :en, :week)
58
        assert_equal day, c.startdt.cwday
59
        assert_equal (day + 5) % 7 + 1, c.enddt.cwday
60
      end
61
    end
62
  end
63
end
.svn/pristine/1a/1ab88c9db51ca0f94d552b61bcc13c4bd5d1f921.svn-base
1
<% if @statuses.empty? or rows.empty? %>
2
    <p><i><%=l(:label_no_data)%></i></p>
3
<% else %>
4
<% col_width = 70 / (@statuses.length+3) %>
5
<table class="list">
6
<thead><tr>
7
<th style="width:25%"></th>
8
<% for status in @statuses %>
9
<th style="width:<%= col_width %>%"><%=h status.name %></th>
10
<% end %>
11
<th align="center" style="width:<%= col_width %>%"><strong><%=l(:label_open_issues_plural)%></strong></th>
12
<th align="center" style="width:<%= col_width %>%"><strong><%=l(:label_closed_issues_plural)%></strong></th>
13
<th align="center" style="width:<%= col_width %>%"><strong><%=l(:label_total)%></strong></th>
14
</tr></thead>
15
<tbody>
16
<% for row in rows %>
17
<tr class="<%= cycle("odd", "even") %>">
18
  <td><%= link_to h(row.name), aggregate_path(@project, field_name, row) %></td>
19
  <% for status in @statuses %>
20
    <td align="center"><%= aggregate_link data, { field_name => row.id, "status_id" => status.id }, aggregate_path(@project, field_name, row, :status_id => status.id) %></td>
21
  <% end %>
22
  <td align="center"><%= aggregate_link data, { field_name => row.id, "closed" => 0 }, aggregate_path(@project, field_name, row, :status_id => "o") %></td>
23
  <td align="center"><%= aggregate_link data, { field_name => row.id, "closed" => 1 }, aggregate_path(@project, field_name, row, :status_id => "c") %></td>
24
  <td align="center"><%= aggregate_link data, { field_name => row.id }, aggregate_path(@project, field_name, row, :status_id => "*") %></td>
25
</tr>
26
<% end %>
27
</tbody>
28
</table>
29
<% end
30
  reset_cycle %>
.svn/pristine/1a/1ac4dbb6341375ce31f3dc814df9fd5800c3148d.svn-base
1
# Mocks out OpenID
2
#
3
# http://www.northpub.com/articles/2007/04/02/testing-openid-support
4
module OpenIdAuthentication
5

  
6
  EXTENSION_FIELDS = {'email'    => 'user@somedomain.com',
7
                      'nickname' => 'cool_user',
8
                      'country'  => 'US',
9
                      'postcode' => '12345',
10
                      'fullname' => 'Cool User',
11
                      'dob'      => '1970-04-01',
12
                      'language' => 'en',
13
                      'timezone' => 'America/New_York'}
14

  
15
  protected
16

  
17
    def authenticate_with_open_id(identity_url = params[:openid_url], options = {}) #:doc:
18
      if User.find_by_identity_url(identity_url) || identity_url.include?('good')
19
        # Don't process registration fields unless it is requested.
20
        unless identity_url.include?('blank') || (options[:required].nil? && options[:optional].nil?)
21
          extension_response_fields = {}
22

  
23
          options[:required].each do |field|
24
            extension_response_fields[field.to_s] = EXTENSION_FIELDS[field.to_s]
25
          end unless options[:required].nil?
26

  
27
          options[:optional].each do |field|
28
            extension_response_fields[field.to_s] = EXTENSION_FIELDS[field.to_s]
29
          end unless options[:optional].nil?
30
        end
31

  
32
        yield Result[:successful], identity_url , extension_response_fields
33
      else
34
        logger.info "OpenID authentication failed: #{identity_url}"
35
        yield Result[:failed], identity_url, nil
36
      end
37
    end
38

  
39
  private
40

  
41
    def add_simple_registration_fields(open_id_response, fields)
42
      open_id_response.add_extension_arg('sreg', 'required', [ fields[:required] ].flatten * ',') if fields[:required]
43
      open_id_response.add_extension_arg('sreg', 'optional', [ fields[:optional] ].flatten * ',') if fields[:optional]
44
    end
45
end
.svn/pristine/1a/1ad12962c58a76f3a2222abf367e284e64a3d8e1.svn-base
1
<!DOCTYPE html>
2
<html lang="en">
3
<head>
4
<meta charset="utf-8" />
5
<title><%=h html_title %></title>
6
<meta name="description" content="<%= Redmine::Info.app_name %>" />
7
<meta name="keywords" content="issue,bug,tracker" />
8
<%= csrf_meta_tag %>
9
<%= favicon %>
10
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'application', :media => 'all' %>
11
<%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
12
<%= javascript_heads %>
13
<%= heads_for_theme %>
14
<%= call_hook :view_layouts_base_html_head %>
15
<!-- page specific tags -->
16
<%= yield :header_tags -%>
17
</head>
18
<body class="<%=h body_css_classes %>">
19
<div id="wrapper">
20
<div id="wrapper2">
21
<div id="wrapper3">
22
<div id="top-menu">
23
    <div id="account">
24
        <%= render_menu :account_menu -%>
25
    </div>
26
    <%= content_tag('div', "#{l(:label_logged_as)} #{link_to_user(User.current, :format => :username)}".html_safe, :id => 'loggedas') if User.current.logged? %>
27
    <%= render_menu :top_menu if User.current.logged? || !Setting.login_required? -%>
28
</div>
29

  
30
<div id="header">
31
    <% if User.current.logged? || !Setting.login_required? %>
32
    <div id="quick-search">
33
        <%= form_tag({:controller => 'search', :action => 'index', :id => @project}, :method => :get ) do %>
34
        <%= hidden_field_tag(controller.default_search_scope, 1, :id => nil) if controller.default_search_scope %>
35
        <label for='q'>
36
          <%= link_to l(:label_search), {:controller => 'search', :action => 'index', :id => @project}, :accesskey => accesskey(:search) %>:
37
        </label>
38
        <%= text_field_tag 'q', @question, :size => 20, :class => 'small', :accesskey => accesskey(:quick_search) %>
39
        <% end %>
40
        <%= render_project_jump_box %>
41
    </div>
42
    <% end %>
43

  
44
    <h1><%= page_header_title %></h1>
45

  
46
    <% if display_main_menu?(@project) %>
47
    <div id="main-menu">
48
        <%= render_main_menu(@project) %>
49
    </div>
50
    <% end %>
51
</div>
52

  
53
<div id="main" class="<%= sidebar_content? ? '' : 'nosidebar' %>">
54
    <div id="sidebar">
55
        <%= yield :sidebar %>
56
        <%= view_layouts_base_sidebar_hook_response %>
57
    </div>
58

  
59
    <div id="content">
60
        <%= render_flash_messages %>
61
        <%= yield %>
62
        <%= call_hook :view_layouts_base_content %>
63
        <div style="clear:both;"></div>
64
    </div>
65
</div>
66
</div>
67

  
68
<div id="ajax-indicator" style="display:none;"><span><%= l(:label_loading) %></span></div>
69
<div id="ajax-modal" style="display:none;"></div>
70

  
71
<div id="footer">
72
  <div class="bgl"><div class="bgr">
73
    Powered by <%= link_to Redmine::Info.app_name, Redmine::Info.url %> &copy; 2006-2013 Jean-Philippe Lang
74
  </div></div>
75
</div>
76
</div>
77
</div>
78
<%= call_hook :view_layouts_base_body_bottom %>
79
</body>
80
</html>
.svn/pristine/1a/1ae20ea87464b5769eed93f455558d2b0e19460e.svn-base
1
class AddUniqueIndexOnCustomFieldsProjects < ActiveRecord::Migration
2
  def up
3
    table_name = "#{CustomField.table_name_prefix}custom_fields_projects#{CustomField.table_name_suffix}"
4
    duplicates = CustomField.connection.select_rows("SELECT custom_field_id, project_id FROM #{table_name} GROUP BY custom_field_id, project_id HAVING COUNT(*) > 1")
5
    duplicates.each do |custom_field_id, project_id|
6
      # Removes duplicate rows
7
      CustomField.connection.execute("DELETE FROM #{table_name} WHERE custom_field_id=#{custom_field_id} AND project_id=#{project_id}")
8
      # And insert one
9
      CustomField.connection.execute("INSERT INTO #{table_name} (custom_field_id, project_id) VALUES (#{custom_field_id}, #{project_id})")
10
    end
11

  
12
    if index_exists? :custom_fields_projects, [:custom_field_id, :project_id]
13
      remove_index :custom_fields_projects, [:custom_field_id, :project_id]
14
    end
15
    add_index :custom_fields_projects, [:custom_field_id, :project_id], :unique => true
16
  end
17

  
18
  def down
19
    if index_exists? :custom_fields_projects, [:custom_field_id, :project_id]
20
      remove_index :custom_fields_projects, [:custom_field_id, :project_id]
21
    end
22
    add_index :custom_fields_projects, [:custom_field_id, :project_id]
23
  end
24
end
.svn/pristine/1a/1ae3258fdcdf6aa143d4aa4fdfd79484152c6554.svn-base
1
# encoding: utf-8
2
#
3
# Redmine - project management software
4
# Copyright (C) 2006-2013  Jean-Philippe Lang
5
#
6
# This program is free software; you can redistribute it and/or
7
# modify it under the terms of the GNU General Public License
8
# as published by the Free Software Foundation; either version 2
9
# of the License, or (at your option) any later version.
10
#
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
# GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License
17
# along with this program; if not, write to the Free Software
18
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19

  
20
module MembersHelper
21
  def render_principals_for_new_members(project)
22
    scope = Principal.active.sorted.not_member_of(project).like(params[:q])
23
    principal_count = scope.count
24
    principal_pages = Redmine::Pagination::Paginator.new principal_count, 100, params['page']
25
    principals = scope.offset(principal_pages.offset).limit(principal_pages.per_page).all
26

  
27
    s = content_tag('div', principals_check_box_tags('membership[user_ids][]', principals), :id => 'principals')
28

  
29
    links = pagination_links_full(principal_pages, principal_count, :per_page_links => false) {|text, parameters, options|
30
      link_to text, autocomplete_project_memberships_path(project, parameters.merge(:q => params[:q], :format => 'js')), :remote => true
31
    }
32

  
33
    s + content_tag('p', links, :class => 'pagination')
34
  end
35
end

Also available in: Unified diff