Revision 1297:0a574315af3e .svn/pristine/4c
| .svn/pristine/4c/4c88c6058655e1eb05ec3a1a293a556537a3380e.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 QueriesHelperTest < ActionView::TestCase |
|
| 21 |
include QueriesHelper |
|
| 22 |
include Redmine::I18n |
|
| 23 |
|
|
| 24 |
fixtures :projects, :enabled_modules, :users, :members, |
|
| 25 |
:member_roles, :roles, :trackers, :issue_statuses, |
|
| 26 |
:issue_categories, :enumerations, :issues, |
|
| 27 |
:watchers, :custom_fields, :custom_values, :versions, |
|
| 28 |
:queries, |
|
| 29 |
:projects_trackers, |
|
| 30 |
:custom_fields_trackers |
|
| 31 |
|
|
| 32 |
def test_order |
|
| 33 |
User.current = User.find_by_login('admin')
|
|
| 34 |
query = Query.new(:project => nil, :name => '_') |
|
| 35 |
assert_equal 30, query.available_filters.size |
|
| 36 |
fo = filters_options(query) |
|
| 37 |
assert_equal 31, fo.size |
|
| 38 |
assert_equal [], fo[0] |
|
| 39 |
assert_equal "status_id", fo[1][1] |
|
| 40 |
assert_equal "project_id", fo[2][1] |
|
| 41 |
assert_equal "tracker_id", fo[3][1] |
|
| 42 |
assert_equal "priority_id", fo[4][1] |
|
| 43 |
assert_equal "watcher_id", fo[17][1] |
|
| 44 |
assert_equal "is_private", fo[18][1] |
|
| 45 |
end |
|
| 46 |
|
|
| 47 |
def test_order_custom_fields |
|
| 48 |
set_language_if_valid 'en' |
|
| 49 |
field = UserCustomField.new( |
|
| 50 |
:name => 'order test', :field_format => 'string', |
|
| 51 |
:is_for_all => true, :is_filter => true |
|
| 52 |
) |
|
| 53 |
assert field.save |
|
| 54 |
User.current = User.find_by_login('admin')
|
|
| 55 |
query = Query.new(:project => nil, :name => '_') |
|
| 56 |
assert_equal 32, query.available_filters.size |
|
| 57 |
fo = filters_options(query) |
|
| 58 |
assert_equal 33, fo.size |
|
| 59 |
assert_equal "Searchable field", fo[19][0] |
|
| 60 |
assert_equal "Database", fo[20][0] |
|
| 61 |
assert_equal "Project's Development status", fo[21][0] |
|
| 62 |
assert_equal "Assignee's order test", fo[22][0] |
|
| 63 |
assert_equal "Author's order test", fo[23][0] |
|
| 64 |
end |
|
| 65 |
end |
|
| .svn/pristine/4c/4c8a16342f0eed8d7b98e1ecd16d21a60462a3df.svn-base | ||
|---|---|---|
| 1 |
<h2>Hello</h2> |
|
| 2 |
|
|
| 3 |
<p class="icon icon-example-works"><%= l(:text_say_hello) %></p> |
|
| 4 |
|
|
| 5 |
<p><label>Example setting</label>: <%= @value %></p> |
|
| 6 |
|
|
| 7 |
<%= link_to('Good bye', :action => 'say_goodbye', :id => @project) if User.current.allowed_to?(:example_say_goodbye, @project) %>
|
|
| 8 |
|
|
| 9 |
<% content_for :sidebar do %> |
|
| 10 |
<p>Adding content to the sidebar...</p> |
|
| 11 |
<% end %> |
|
| 12 |
|
|
| 13 |
<% content_for :header_tags do %> |
|
| 14 |
<%= stylesheet_link_tag 'example', :plugin => 'sample_plugin', :media => "screen" %> |
|
| 15 |
<% end %> |
|
| .svn/pristine/4c/4c8e100ee7d3597387e1269a2cf346b1bfb61a50.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 UsersTest < ActionController::IntegrationTest |
|
| 21 |
fixtures :users |
|
| 22 |
|
|
| 23 |
def test_destroy_should_not_accept_get_requests |
|
| 24 |
assert_no_difference 'User.count' do |
|
| 25 |
get '/users/destroy/2', {}, credentials('admin')
|
|
| 26 |
assert_response 404 |
|
| 27 |
end |
|
| 28 |
end |
|
| 29 |
end |
|
| .svn/pristine/4c/4c998cfe872582fc9c34765173f146ee719b1024.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 RepositoriesDarcsControllerTest < ActionController::TestCase |
|
| 21 |
tests RepositoriesController |
|
| 22 |
|
|
| 23 |
fixtures :projects, :users, :roles, :members, :member_roles, |
|
| 24 |
:repositories, :enabled_modules |
|
| 25 |
|
|
| 26 |
REPOSITORY_PATH = Rails.root.join('tmp/test/darcs_repository').to_s
|
|
| 27 |
PRJ_ID = 3 |
|
| 28 |
NUM_REV = 6 |
|
| 29 |
|
|
| 30 |
def setup |
|
| 31 |
User.current = nil |
|
| 32 |
@project = Project.find(PRJ_ID) |
|
| 33 |
@repository = Repository::Darcs.create( |
|
| 34 |
:project => @project, |
|
| 35 |
:url => REPOSITORY_PATH, |
|
| 36 |
:log_encoding => 'UTF-8' |
|
| 37 |
) |
|
| 38 |
assert @repository |
|
| 39 |
end |
|
| 40 |
|
|
| 41 |
if File.directory?(REPOSITORY_PATH) |
|
| 42 |
def test_get_new |
|
| 43 |
@request.session[:user_id] = 1 |
|
| 44 |
@project.repository.destroy |
|
| 45 |
get :new, :project_id => 'subproject1', :repository_scm => 'Darcs' |
|
| 46 |
assert_response :success |
|
| 47 |
assert_template 'new' |
|
| 48 |
assert_kind_of Repository::Darcs, assigns(:repository) |
|
| 49 |
assert assigns(:repository).new_record? |
|
| 50 |
end |
|
| 51 |
|
|
| 52 |
def test_browse_root |
|
| 53 |
assert_equal 0, @repository.changesets.count |
|
| 54 |
@repository.fetch_changesets |
|
| 55 |
@project.reload |
|
| 56 |
assert_equal NUM_REV, @repository.changesets.count |
|
| 57 |
get :show, :id => PRJ_ID |
|
| 58 |
assert_response :success |
|
| 59 |
assert_template 'show' |
|
| 60 |
assert_not_nil assigns(:entries) |
|
| 61 |
assert_equal 3, assigns(:entries).size |
|
| 62 |
assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'}
|
|
| 63 |
assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'}
|
|
| 64 |
assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'}
|
|
| 65 |
end |
|
| 66 |
|
|
| 67 |
def test_browse_directory |
|
| 68 |
assert_equal 0, @repository.changesets.count |
|
| 69 |
@repository.fetch_changesets |
|
| 70 |
@project.reload |
|
| 71 |
assert_equal NUM_REV, @repository.changesets.count |
|
| 72 |
get :show, :id => PRJ_ID, :path => repository_path_hash(['images'])[:param] |
|
| 73 |
assert_response :success |
|
| 74 |
assert_template 'show' |
|
| 75 |
assert_not_nil assigns(:entries) |
|
| 76 |
assert_equal ['delete.png', 'edit.png'], assigns(:entries).collect(&:name) |
|
| 77 |
entry = assigns(:entries).detect {|e| e.name == 'edit.png'}
|
|
| 78 |
assert_not_nil entry |
|
| 79 |
assert_equal 'file', entry.kind |
|
| 80 |
assert_equal 'images/edit.png', entry.path |
|
| 81 |
end |
|
| 82 |
|
|
| 83 |
def test_browse_at_given_revision |
|
| 84 |
assert_equal 0, @repository.changesets.count |
|
| 85 |
@repository.fetch_changesets |
|
| 86 |
@project.reload |
|
| 87 |
assert_equal NUM_REV, @repository.changesets.count |
|
| 88 |
get :show, :id => PRJ_ID, :path => repository_path_hash(['images'])[:param], |
|
| 89 |
:rev => 1 |
|
| 90 |
assert_response :success |
|
| 91 |
assert_template 'show' |
|
| 92 |
assert_not_nil assigns(:entries) |
|
| 93 |
assert_equal ['delete.png'], assigns(:entries).collect(&:name) |
|
| 94 |
end |
|
| 95 |
|
|
| 96 |
def test_changes |
|
| 97 |
assert_equal 0, @repository.changesets.count |
|
| 98 |
@repository.fetch_changesets |
|
| 99 |
@project.reload |
|
| 100 |
assert_equal NUM_REV, @repository.changesets.count |
|
| 101 |
get :changes, :id => PRJ_ID, |
|
| 102 |
:path => repository_path_hash(['images', 'edit.png'])[:param] |
|
| 103 |
assert_response :success |
|
| 104 |
assert_template 'changes' |
|
| 105 |
assert_tag :tag => 'h2', :content => 'edit.png' |
|
| 106 |
end |
|
| 107 |
|
|
| 108 |
def test_diff |
|
| 109 |
assert_equal 0, @repository.changesets.count |
|
| 110 |
@repository.fetch_changesets |
|
| 111 |
@project.reload |
|
| 112 |
assert_equal NUM_REV, @repository.changesets.count |
|
| 113 |
# Full diff of changeset 5 |
|
| 114 |
['inline', 'sbs'].each do |dt| |
|
| 115 |
get :diff, :id => PRJ_ID, :rev => 5, :type => dt |
|
| 116 |
assert_response :success |
|
| 117 |
assert_template 'diff' |
|
| 118 |
# Line 22 removed |
|
| 119 |
assert_tag :tag => 'th', |
|
| 120 |
:content => '22', |
|
| 121 |
:sibling => { :tag => 'td',
|
|
| 122 |
:attributes => { :class => /diff_out/ },
|
|
| 123 |
:content => /def remove/ } |
|
| 124 |
end |
|
| 125 |
end |
|
| 126 |
|
|
| 127 |
def test_destroy_valid_repository |
|
| 128 |
@request.session[:user_id] = 1 # admin |
|
| 129 |
assert_equal 0, @repository.changesets.count |
|
| 130 |
@repository.fetch_changesets |
|
| 131 |
@project.reload |
|
| 132 |
assert_equal NUM_REV, @repository.changesets.count |
|
| 133 |
|
|
| 134 |
assert_difference 'Repository.count', -1 do |
|
| 135 |
delete :destroy, :id => @repository.id |
|
| 136 |
end |
|
| 137 |
assert_response 302 |
|
| 138 |
@project.reload |
|
| 139 |
assert_nil @project.repository |
|
| 140 |
end |
|
| 141 |
|
|
| 142 |
def test_destroy_invalid_repository |
|
| 143 |
@request.session[:user_id] = 1 # admin |
|
| 144 |
@project.repository.destroy |
|
| 145 |
@repository = Repository::Darcs.create!( |
|
| 146 |
:project => @project, |
|
| 147 |
:url => "/invalid", |
|
| 148 |
:log_encoding => 'UTF-8' |
|
| 149 |
) |
|
| 150 |
@repository.fetch_changesets |
|
| 151 |
@project.reload |
|
| 152 |
assert_equal 0, @repository.changesets.count |
|
| 153 |
|
|
| 154 |
assert_difference 'Repository.count', -1 do |
|
| 155 |
delete :destroy, :id => @repository.id |
|
| 156 |
end |
|
| 157 |
assert_response 302 |
|
| 158 |
@project.reload |
|
| 159 |
assert_nil @project.repository |
|
| 160 |
end |
|
| 161 |
else |
|
| 162 |
puts "Darcs test repository NOT FOUND. Skipping functional tests !!!" |
|
| 163 |
def test_fake; assert true end |
|
| 164 |
end |
|
| 165 |
end |
|
| .svn/pristine/4c/4cd6357962628f4e7adbb5bc6619f8171595a014.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 Search |
|
| 20 |
|
|
| 21 |
mattr_accessor :available_search_types |
|
| 22 |
|
|
| 23 |
@@available_search_types = [] |
|
| 24 |
|
|
| 25 |
class << self |
|
| 26 |
def map(&block) |
|
| 27 |
yield self |
|
| 28 |
end |
|
| 29 |
|
|
| 30 |
# Registers a search provider |
|
| 31 |
def register(search_type, options={})
|
|
| 32 |
search_type = search_type.to_s |
|
| 33 |
@@available_search_types << search_type unless @@available_search_types.include?(search_type) |
|
| 34 |
end |
|
| 35 |
end |
|
| 36 |
|
|
| 37 |
module Controller |
|
| 38 |
def self.included(base) |
|
| 39 |
base.extend(ClassMethods) |
|
| 40 |
end |
|
| 41 |
|
|
| 42 |
module ClassMethods |
|
| 43 |
@@default_search_scopes = Hash.new {|hash, key| hash[key] = {:default => nil, :actions => {}}}
|
|
| 44 |
mattr_accessor :default_search_scopes |
|
| 45 |
|
|
| 46 |
# Set the default search scope for a controller or specific actions |
|
| 47 |
# Examples: |
|
| 48 |
# * search_scope :issues # => sets the search scope to :issues for the whole controller |
|
| 49 |
# * search_scope :issues, :only => :index |
|
| 50 |
# * search_scope :issues, :only => [:index, :show] |
|
| 51 |
def default_search_scope(id, options = {})
|
|
| 52 |
if actions = options[:only] |
|
| 53 |
actions = [] << actions unless actions.is_a?(Array) |
|
| 54 |
actions.each {|a| default_search_scopes[controller_name.to_sym][:actions][a.to_sym] = id.to_s}
|
|
| 55 |
else |
|
| 56 |
default_search_scopes[controller_name.to_sym][:default] = id.to_s |
|
| 57 |
end |
|
| 58 |
end |
|
| 59 |
end |
|
| 60 |
|
|
| 61 |
def default_search_scopes |
|
| 62 |
self.class.default_search_scopes |
|
| 63 |
end |
|
| 64 |
|
|
| 65 |
# Returns the default search scope according to the current action |
|
| 66 |
def default_search_scope |
|
| 67 |
@default_search_scope ||= default_search_scopes[controller_name.to_sym][:actions][action_name.to_sym] || |
|
| 68 |
default_search_scopes[controller_name.to_sym][:default] |
|
| 69 |
end |
|
| 70 |
end |
|
| 71 |
end |
|
| 72 |
end |
|
Also available in: Unified diff