Revision 1297:0a574315af3e .svn/pristine/4e
| .svn/pristine/4e/4e41004227c3289cb2b10e8f3de41eb2d30436ae.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/pop' |
|
| 19 |
|
|
| 20 |
module Redmine |
|
| 21 |
module POP3 |
|
| 22 |
class << self |
|
| 23 |
def check(pop_options={}, options={})
|
|
| 24 |
host = pop_options[:host] || '127.0.0.1' |
|
| 25 |
port = pop_options[:port] || '110' |
|
| 26 |
apop = (pop_options[:apop].to_s == '1') |
|
| 27 |
delete_unprocessed = (pop_options[:delete_unprocessed].to_s == '1') |
|
| 28 |
|
|
| 29 |
pop = Net::POP3.APOP(apop).new(host,port) |
|
| 30 |
logger.debug "Connecting to #{host}..." if logger && logger.debug?
|
|
| 31 |
pop.start(pop_options[:username], pop_options[:password]) do |pop_session| |
|
| 32 |
if pop_session.mails.empty? |
|
| 33 |
logger.debug "No email to process" if logger && logger.debug? |
|
| 34 |
else |
|
| 35 |
logger.debug "#{pop_session.mails.size} email(s) to process..." if logger && logger.debug?
|
|
| 36 |
pop_session.each_mail do |msg| |
|
| 37 |
message = msg.pop |
|
| 38 |
message_id = (message =~ /^Message-I[dD]: (.*)/ ? $1 : '').strip |
|
| 39 |
if MailHandler.receive(message, options) |
|
| 40 |
msg.delete |
|
| 41 |
logger.debug "--> Message #{message_id} processed and deleted from the server" if logger && logger.debug?
|
|
| 42 |
else |
|
| 43 |
if delete_unprocessed |
|
| 44 |
msg.delete |
|
| 45 |
logger.debug "--> Message #{message_id} NOT processed and deleted from the server" if logger && logger.debug?
|
|
| 46 |
else |
|
| 47 |
logger.debug "--> Message #{message_id} NOT processed and left on the server" if logger && logger.debug?
|
|
| 48 |
end |
|
| 49 |
end |
|
| 50 |
end |
|
| 51 |
end |
|
| 52 |
end |
|
| 53 |
end |
|
| 54 |
|
|
| 55 |
private |
|
| 56 |
|
|
| 57 |
def logger |
|
| 58 |
::Rails.logger |
|
| 59 |
end |
|
| 60 |
end |
|
| 61 |
end |
|
| 62 |
end |
|
| .svn/pristine/4e/4e6c628c00f1ea0177c61db44ecdad4a9212f134.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 RoleTest < ActiveSupport::TestCase |
|
| 21 |
fixtures :roles, :workflows, :trackers |
|
| 22 |
|
|
| 23 |
def test_sorted_scope |
|
| 24 |
assert_equal Role.all.sort, Role.sorted.all |
|
| 25 |
end |
|
| 26 |
|
|
| 27 |
def test_givable_scope |
|
| 28 |
assert_equal Role.all.reject(&:builtin?).sort, Role.givable.all |
|
| 29 |
end |
|
| 30 |
|
|
| 31 |
def test_builtin_scope |
|
| 32 |
assert_equal Role.all.select(&:builtin?).sort, Role.builtin(true).all.sort |
|
| 33 |
assert_equal Role.all.reject(&:builtin?).sort, Role.builtin(false).all.sort |
|
| 34 |
end |
|
| 35 |
|
|
| 36 |
def test_copy_from |
|
| 37 |
role = Role.find(1) |
|
| 38 |
copy = Role.new.copy_from(role) |
|
| 39 |
|
|
| 40 |
assert_nil copy.id |
|
| 41 |
assert_equal '', copy.name |
|
| 42 |
assert_equal role.permissions, copy.permissions |
|
| 43 |
|
|
| 44 |
copy.name = 'Copy' |
|
| 45 |
assert copy.save |
|
| 46 |
end |
|
| 47 |
|
|
| 48 |
def test_copy_workflows |
|
| 49 |
source = Role.find(1) |
|
| 50 |
assert_equal 90, source.workflow_rules.size |
|
| 51 |
|
|
| 52 |
target = Role.new(:name => 'Target') |
|
| 53 |
assert target.save |
|
| 54 |
target.workflow_rules.copy(source) |
|
| 55 |
target.reload |
|
| 56 |
assert_equal 90, target.workflow_rules.size |
|
| 57 |
end |
|
| 58 |
|
|
| 59 |
def test_permissions_should_be_unserialized_with_its_coder |
|
| 60 |
Role::PermissionsAttributeCoder.expects(:load).once |
|
| 61 |
Role.find(1).permissions |
|
| 62 |
end |
|
| 63 |
|
|
| 64 |
def test_add_permission |
|
| 65 |
role = Role.find(1) |
|
| 66 |
size = role.permissions.size |
|
| 67 |
role.add_permission!("apermission", "anotherpermission")
|
|
| 68 |
role.reload |
|
| 69 |
assert role.permissions.include?(:anotherpermission) |
|
| 70 |
assert_equal size + 2, role.permissions.size |
|
| 71 |
end |
|
| 72 |
|
|
| 73 |
def test_remove_permission |
|
| 74 |
role = Role.find(1) |
|
| 75 |
size = role.permissions.size |
|
| 76 |
perm = role.permissions[0..1] |
|
| 77 |
role.remove_permission!(*perm) |
|
| 78 |
role.reload |
|
| 79 |
assert ! role.permissions.include?(perm[0]) |
|
| 80 |
assert_equal size - 2, role.permissions.size |
|
| 81 |
end |
|
| 82 |
|
|
| 83 |
def test_name |
|
| 84 |
I18n.locale = 'fr' |
|
| 85 |
assert_equal 'Manager', Role.find(1).name |
|
| 86 |
assert_equal 'Anonyme', Role.anonymous.name |
|
| 87 |
assert_equal 'Non membre', Role.non_member.name |
|
| 88 |
end |
|
| 89 |
|
|
| 90 |
def test_find_all_givable |
|
| 91 |
assert_equal Role.all.reject(&:builtin?).sort, Role.find_all_givable |
|
| 92 |
end |
|
| 93 |
|
|
| 94 |
context "#anonymous" do |
|
| 95 |
should "return the anonymous role" do |
|
| 96 |
role = Role.anonymous |
|
| 97 |
assert role.builtin? |
|
| 98 |
assert_equal Role::BUILTIN_ANONYMOUS, role.builtin |
|
| 99 |
end |
|
| 100 |
|
|
| 101 |
context "with a missing anonymous role" do |
|
| 102 |
setup do |
|
| 103 |
Role.delete_all("builtin = #{Role::BUILTIN_ANONYMOUS}")
|
|
| 104 |
end |
|
| 105 |
|
|
| 106 |
should "create a new anonymous role" do |
|
| 107 |
assert_difference('Role.count') do
|
|
| 108 |
Role.anonymous |
|
| 109 |
end |
|
| 110 |
end |
|
| 111 |
|
|
| 112 |
should "return the anonymous role" do |
|
| 113 |
role = Role.anonymous |
|
| 114 |
assert role.builtin? |
|
| 115 |
assert_equal Role::BUILTIN_ANONYMOUS, role.builtin |
|
| 116 |
end |
|
| 117 |
end |
|
| 118 |
end |
|
| 119 |
|
|
| 120 |
context "#non_member" do |
|
| 121 |
should "return the non-member role" do |
|
| 122 |
role = Role.non_member |
|
| 123 |
assert role.builtin? |
|
| 124 |
assert_equal Role::BUILTIN_NON_MEMBER, role.builtin |
|
| 125 |
end |
|
| 126 |
|
|
| 127 |
context "with a missing non-member role" do |
|
| 128 |
setup do |
|
| 129 |
Role.delete_all("builtin = #{Role::BUILTIN_NON_MEMBER}")
|
|
| 130 |
end |
|
| 131 |
|
|
| 132 |
should "create a new non-member role" do |
|
| 133 |
assert_difference('Role.count') do
|
|
| 134 |
Role.non_member |
|
| 135 |
end |
|
| 136 |
end |
|
| 137 |
|
|
| 138 |
should "return the non-member role" do |
|
| 139 |
role = Role.non_member |
|
| 140 |
assert role.builtin? |
|
| 141 |
assert_equal Role::BUILTIN_NON_MEMBER, role.builtin |
|
| 142 |
end |
|
| 143 |
end |
|
| 144 |
end |
|
| 145 |
end |
|
| .svn/pristine/4e/4e8ea0df2bcad47fe62855e09a9ca0f2f38daa1e.svn-base | ||
|---|---|---|
| 1 |
class AddRolePosition < ActiveRecord::Migration |
|
| 2 |
def self.up |
|
| 3 |
add_column :roles, :position, :integer, :default => 1 |
|
| 4 |
Role.all.each_with_index {|role, i| role.update_attribute(:position, i+1)}
|
|
| 5 |
end |
|
| 6 |
|
|
| 7 |
def self.down |
|
| 8 |
remove_column :roles, :position |
|
| 9 |
end |
|
| 10 |
end |
|
| .svn/pristine/4e/4e92a0fc74ebc49a3b3786a7872bd71f9a74effb.svn-base | ||
|---|---|---|
| 1 |
$('#all_attributes').html('<%= escape_javascript(render :partial => 'form') %>');
|
|
| 2 |
|
|
| 3 |
<% if User.current.allowed_to?(:log_time, @issue.project) %> |
|
| 4 |
$('#log_time').show();
|
|
| 5 |
<% else %> |
|
| 6 |
$('#log_time').hide();
|
|
| 7 |
<% end %> |
|
| .svn/pristine/4e/4e9dba91f9f1e14e761643510fc2e1252decf990.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 |
begin |
|
| 20 |
require 'mocha' |
|
| 21 |
|
|
| 22 |
class DarcsAdapterTest < ActiveSupport::TestCase |
|
| 23 |
REPOSITORY_PATH = Rails.root.join('tmp/test/darcs_repository').to_s
|
|
| 24 |
|
|
| 25 |
if File.directory?(REPOSITORY_PATH) |
|
| 26 |
def setup |
|
| 27 |
@adapter = Redmine::Scm::Adapters::DarcsAdapter.new(REPOSITORY_PATH) |
|
| 28 |
end |
|
| 29 |
|
|
| 30 |
def test_darcsversion |
|
| 31 |
to_test = { "1.0.9 (release)\n" => [1,0,9] ,
|
|
| 32 |
"2.2.0 (release)\n" => [2,2,0] } |
|
| 33 |
to_test.each do |s, v| |
|
| 34 |
test_darcsversion_for(s, v) |
|
| 35 |
end |
|
| 36 |
end |
|
| 37 |
|
|
| 38 |
def test_revisions |
|
| 39 |
id1 = '20080308225258-98289-761f654d669045eabee90b91b53a21ce5593cadf.gz' |
|
| 40 |
revs = @adapter.revisions('', nil, nil, {:with_path => true})
|
|
| 41 |
assert_equal 6, revs.size |
|
| 42 |
assert_equal id1, revs[5].scmid |
|
| 43 |
paths = revs[5].paths |
|
| 44 |
assert_equal 5, paths.size |
|
| 45 |
assert_equal 'A', paths[0][:action] |
|
| 46 |
assert_equal '/README', paths[0][:path] |
|
| 47 |
assert_equal 'A', paths[1][:action] |
|
| 48 |
assert_equal '/images', paths[1][:path] |
|
| 49 |
end |
|
| 50 |
|
|
| 51 |
private |
|
| 52 |
|
|
| 53 |
def test_darcsversion_for(darcsversion, version) |
|
| 54 |
@adapter.class.expects(:darcs_binary_version_from_command_line).returns(darcsversion) |
|
| 55 |
assert_equal version, @adapter.class.darcs_binary_version |
|
| 56 |
end |
|
| 57 |
|
|
| 58 |
else |
|
| 59 |
puts "Darcs test repository NOT FOUND. Skipping unit tests !!!" |
|
| 60 |
def test_fake; assert true end |
|
| 61 |
end |
|
| 62 |
end |
|
| 63 |
|
|
| 64 |
rescue LoadError |
|
| 65 |
class DarcsMochaFake < ActiveSupport::TestCase |
|
| 66 |
def test_fake; assert(false, "Requires mocha to run those tests") end |
|
| 67 |
end |
|
| 68 |
end |
|
| 69 |
|
|
| .svn/pristine/4e/4ed99aa85a5cef8603d38788ee6606bb9b047f2c.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 QueriesControllerTest < ActionController::TestCase |
|
| 21 |
fixtures :projects, :users, :members, :member_roles, :roles, :trackers, :issue_statuses, :issue_categories, :enumerations, :issues, :custom_fields, :custom_values, :queries, :enabled_modules |
|
| 22 |
|
|
| 23 |
def setup |
|
| 24 |
User.current = nil |
|
| 25 |
end |
|
| 26 |
|
|
| 27 |
def test_new_project_query |
|
| 28 |
@request.session[:user_id] = 2 |
|
| 29 |
get :new, :project_id => 1 |
|
| 30 |
assert_response :success |
|
| 31 |
assert_template 'new' |
|
| 32 |
assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
|
|
| 33 |
:name => 'query[is_public]', |
|
| 34 |
:checked => nil } |
|
| 35 |
assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
|
|
| 36 |
:name => 'query_is_for_all', |
|
| 37 |
:checked => nil, |
|
| 38 |
:disabled => nil } |
|
| 39 |
assert_select 'select[name=?]', 'c[]' do |
|
| 40 |
assert_select 'option[value=tracker]' |
|
| 41 |
assert_select 'option[value=subject]' |
|
| 42 |
end |
|
| 43 |
end |
|
| 44 |
|
|
| 45 |
def test_new_global_query |
|
| 46 |
@request.session[:user_id] = 2 |
|
| 47 |
get :new |
|
| 48 |
assert_response :success |
|
| 49 |
assert_template 'new' |
|
| 50 |
assert_no_tag :tag => 'input', :attributes => { :type => 'checkbox',
|
|
| 51 |
:name => 'query[is_public]' } |
|
| 52 |
assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
|
|
| 53 |
:name => 'query_is_for_all', |
|
| 54 |
:checked => 'checked', |
|
| 55 |
:disabled => nil } |
|
| 56 |
end |
|
| 57 |
|
|
| 58 |
def test_new_on_invalid_project |
|
| 59 |
@request.session[:user_id] = 2 |
|
| 60 |
get :new, :project_id => 'invalid' |
|
| 61 |
assert_response 404 |
|
| 62 |
end |
|
| 63 |
|
|
| 64 |
def test_create_project_public_query |
|
| 65 |
@request.session[:user_id] = 2 |
|
| 66 |
post :create, |
|
| 67 |
:project_id => 'ecookbook', |
|
| 68 |
:default_columns => '1', |
|
| 69 |
:f => ["status_id", "assigned_to_id"], |
|
| 70 |
:op => {"assigned_to_id" => "=", "status_id" => "o"},
|
|
| 71 |
:v => { "assigned_to_id" => ["1"], "status_id" => ["1"]},
|
|
| 72 |
:query => {"name" => "test_new_project_public_query", "is_public" => "1"}
|
|
| 73 |
|
|
| 74 |
q = Query.find_by_name('test_new_project_public_query')
|
|
| 75 |
assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook', :query_id => q |
|
| 76 |
assert q.is_public? |
|
| 77 |
assert q.has_default_columns? |
|
| 78 |
assert q.valid? |
|
| 79 |
end |
|
| 80 |
|
|
| 81 |
def test_create_project_private_query |
|
| 82 |
@request.session[:user_id] = 3 |
|
| 83 |
post :create, |
|
| 84 |
:project_id => 'ecookbook', |
|
| 85 |
:default_columns => '1', |
|
| 86 |
:fields => ["status_id", "assigned_to_id"], |
|
| 87 |
:operators => {"assigned_to_id" => "=", "status_id" => "o"},
|
|
| 88 |
:values => { "assigned_to_id" => ["1"], "status_id" => ["1"]},
|
|
| 89 |
:query => {"name" => "test_new_project_private_query", "is_public" => "1"}
|
|
| 90 |
|
|
| 91 |
q = Query.find_by_name('test_new_project_private_query')
|
|
| 92 |
assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook', :query_id => q |
|
| 93 |
assert !q.is_public? |
|
| 94 |
assert q.has_default_columns? |
|
| 95 |
assert q.valid? |
|
| 96 |
end |
|
| 97 |
|
|
| 98 |
def test_create_global_private_query_with_custom_columns |
|
| 99 |
@request.session[:user_id] = 3 |
|
| 100 |
post :create, |
|
| 101 |
:fields => ["status_id", "assigned_to_id"], |
|
| 102 |
:operators => {"assigned_to_id" => "=", "status_id" => "o"},
|
|
| 103 |
:values => { "assigned_to_id" => ["me"], "status_id" => ["1"]},
|
|
| 104 |
:query => {"name" => "test_new_global_private_query", "is_public" => "1"},
|
|
| 105 |
:c => ["", "tracker", "subject", "priority", "category"] |
|
| 106 |
|
|
| 107 |
q = Query.find_by_name('test_new_global_private_query')
|
|
| 108 |
assert_redirected_to :controller => 'issues', :action => 'index', :project_id => nil, :query_id => q |
|
| 109 |
assert !q.is_public? |
|
| 110 |
assert !q.has_default_columns? |
|
| 111 |
assert_equal [:tracker, :subject, :priority, :category], q.columns.collect {|c| c.name}
|
|
| 112 |
assert q.valid? |
|
| 113 |
end |
|
| 114 |
|
|
| 115 |
def test_create_global_query_with_custom_filters |
|
| 116 |
@request.session[:user_id] = 3 |
|
| 117 |
post :create, |
|
| 118 |
:fields => ["assigned_to_id"], |
|
| 119 |
:operators => {"assigned_to_id" => "="},
|
|
| 120 |
:values => { "assigned_to_id" => ["me"]},
|
|
| 121 |
:query => {"name" => "test_new_global_query"}
|
|
| 122 |
|
|
| 123 |
q = Query.find_by_name('test_new_global_query')
|
|
| 124 |
assert_redirected_to :controller => 'issues', :action => 'index', :project_id => nil, :query_id => q |
|
| 125 |
assert !q.has_filter?(:status_id) |
|
| 126 |
assert_equal ['assigned_to_id'], q.filters.keys |
|
| 127 |
assert q.valid? |
|
| 128 |
end |
|
| 129 |
|
|
| 130 |
def test_create_with_sort |
|
| 131 |
@request.session[:user_id] = 1 |
|
| 132 |
post :create, |
|
| 133 |
:default_columns => '1', |
|
| 134 |
:operators => {"status_id" => "o"},
|
|
| 135 |
:values => {"status_id" => ["1"]},
|
|
| 136 |
:query => {:name => "test_new_with_sort",
|
|
| 137 |
:is_public => "1", |
|
| 138 |
:sort_criteria => {"0" => ["due_date", "desc"], "1" => ["tracker", ""]}}
|
|
| 139 |
|
|
| 140 |
query = Query.find_by_name("test_new_with_sort")
|
|
| 141 |
assert_not_nil query |
|
| 142 |
assert_equal [['due_date', 'desc'], ['tracker', 'asc']], query.sort_criteria |
|
| 143 |
end |
|
| 144 |
|
|
| 145 |
def test_create_with_failure |
|
| 146 |
@request.session[:user_id] = 2 |
|
| 147 |
assert_no_difference '::Query.count' do |
|
| 148 |
post :create, :project_id => 'ecookbook', :query => {:name => ''}
|
|
| 149 |
end |
|
| 150 |
assert_response :success |
|
| 151 |
assert_template 'new' |
|
| 152 |
assert_select 'input[name=?]', 'query[name]' |
|
| 153 |
end |
|
| 154 |
|
|
| 155 |
def test_edit_global_public_query |
|
| 156 |
@request.session[:user_id] = 1 |
|
| 157 |
get :edit, :id => 4 |
|
| 158 |
assert_response :success |
|
| 159 |
assert_template 'edit' |
|
| 160 |
assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
|
|
| 161 |
:name => 'query[is_public]', |
|
| 162 |
:checked => 'checked' } |
|
| 163 |
assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
|
|
| 164 |
:name => 'query_is_for_all', |
|
| 165 |
:checked => 'checked', |
|
| 166 |
:disabled => 'disabled' } |
|
| 167 |
end |
|
| 168 |
|
|
| 169 |
def test_edit_global_private_query |
|
| 170 |
@request.session[:user_id] = 3 |
|
| 171 |
get :edit, :id => 3 |
|
| 172 |
assert_response :success |
|
| 173 |
assert_template 'edit' |
|
| 174 |
assert_no_tag :tag => 'input', :attributes => { :type => 'checkbox',
|
|
| 175 |
:name => 'query[is_public]' } |
|
| 176 |
assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
|
|
| 177 |
:name => 'query_is_for_all', |
|
| 178 |
:checked => 'checked', |
|
| 179 |
:disabled => 'disabled' } |
|
| 180 |
end |
|
| 181 |
|
|
| 182 |
def test_edit_project_private_query |
|
| 183 |
@request.session[:user_id] = 3 |
|
| 184 |
get :edit, :id => 2 |
|
| 185 |
assert_response :success |
|
| 186 |
assert_template 'edit' |
|
| 187 |
assert_no_tag :tag => 'input', :attributes => { :type => 'checkbox',
|
|
| 188 |
:name => 'query[is_public]' } |
|
| 189 |
assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
|
|
| 190 |
:name => 'query_is_for_all', |
|
| 191 |
:checked => nil, |
|
| 192 |
:disabled => nil } |
|
| 193 |
end |
|
| 194 |
|
|
| 195 |
def test_edit_project_public_query |
|
| 196 |
@request.session[:user_id] = 2 |
|
| 197 |
get :edit, :id => 1 |
|
| 198 |
assert_response :success |
|
| 199 |
assert_template 'edit' |
|
| 200 |
assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
|
|
| 201 |
:name => 'query[is_public]', |
|
| 202 |
:checked => 'checked' |
|
| 203 |
} |
|
| 204 |
assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
|
|
| 205 |
:name => 'query_is_for_all', |
|
| 206 |
:checked => nil, |
|
| 207 |
:disabled => 'disabled' } |
|
| 208 |
end |
|
| 209 |
|
|
| 210 |
def test_edit_sort_criteria |
|
| 211 |
@request.session[:user_id] = 1 |
|
| 212 |
get :edit, :id => 5 |
|
| 213 |
assert_response :success |
|
| 214 |
assert_template 'edit' |
|
| 215 |
assert_tag :tag => 'select', :attributes => { :name => 'query[sort_criteria][0][]' },
|
|
| 216 |
:child => { :tag => 'option', :attributes => { :value => 'priority',
|
|
| 217 |
:selected => 'selected' } } |
|
| 218 |
assert_tag :tag => 'select', :attributes => { :name => 'query[sort_criteria][0][]' },
|
|
| 219 |
:child => { :tag => 'option', :attributes => { :value => 'desc',
|
|
| 220 |
:selected => 'selected' } } |
|
| 221 |
end |
|
| 222 |
|
|
| 223 |
def test_edit_invalid_query |
|
| 224 |
@request.session[:user_id] = 2 |
|
| 225 |
get :edit, :id => 99 |
|
| 226 |
assert_response 404 |
|
| 227 |
end |
|
| 228 |
|
|
| 229 |
def test_udpate_global_private_query |
|
| 230 |
@request.session[:user_id] = 3 |
|
| 231 |
put :update, |
|
| 232 |
:id => 3, |
|
| 233 |
:default_columns => '1', |
|
| 234 |
:fields => ["status_id", "assigned_to_id"], |
|
| 235 |
:operators => {"assigned_to_id" => "=", "status_id" => "o"},
|
|
| 236 |
:values => { "assigned_to_id" => ["me"], "status_id" => ["1"]},
|
|
| 237 |
:query => {"name" => "test_edit_global_private_query", "is_public" => "1"}
|
|
| 238 |
|
|
| 239 |
assert_redirected_to :controller => 'issues', :action => 'index', :query_id => 3 |
|
| 240 |
q = Query.find_by_name('test_edit_global_private_query')
|
|
| 241 |
assert !q.is_public? |
|
| 242 |
assert q.has_default_columns? |
|
| 243 |
assert q.valid? |
|
| 244 |
end |
|
| 245 |
|
|
| 246 |
def test_update_global_public_query |
|
| 247 |
@request.session[:user_id] = 1 |
|
| 248 |
put :update, |
|
| 249 |
:id => 4, |
|
| 250 |
:default_columns => '1', |
|
| 251 |
:fields => ["status_id", "assigned_to_id"], |
|
| 252 |
:operators => {"assigned_to_id" => "=", "status_id" => "o"},
|
|
| 253 |
:values => { "assigned_to_id" => ["1"], "status_id" => ["1"]},
|
|
| 254 |
:query => {"name" => "test_edit_global_public_query", "is_public" => "1"}
|
|
| 255 |
|
|
| 256 |
assert_redirected_to :controller => 'issues', :action => 'index', :query_id => 4 |
|
| 257 |
q = Query.find_by_name('test_edit_global_public_query')
|
|
| 258 |
assert q.is_public? |
|
| 259 |
assert q.has_default_columns? |
|
| 260 |
assert q.valid? |
|
| 261 |
end |
|
| 262 |
|
|
| 263 |
def test_update_with_failure |
|
| 264 |
@request.session[:user_id] = 1 |
|
| 265 |
put :update, :id => 4, :query => {:name => ''}
|
|
| 266 |
assert_response :success |
|
| 267 |
assert_template 'edit' |
|
| 268 |
end |
|
| 269 |
|
|
| 270 |
def test_destroy |
|
| 271 |
@request.session[:user_id] = 2 |
|
| 272 |
delete :destroy, :id => 1 |
|
| 273 |
assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook', :set_filter => 1, :query_id => nil |
|
| 274 |
assert_nil Query.find_by_id(1) |
|
| 275 |
end |
|
| 276 |
|
|
| 277 |
def test_backslash_should_be_escaped_in_filters |
|
| 278 |
@request.session[:user_id] = 2 |
|
| 279 |
get :new, :subject => 'foo/bar' |
|
| 280 |
assert_response :success |
|
| 281 |
assert_template 'new' |
|
| 282 |
assert_include 'addFilter("subject", "=", ["foo\/bar"]);', response.body
|
|
| 283 |
end |
|
| 284 |
end |
|
| .svn/pristine/4e/4edcfd6c816045bb7c9936fb062160ba608a38e6.svn-base | ||
|---|---|---|
| 1 |
module RFPDF |
|
| 2 |
module TemplateHandlers |
|
| 3 |
# class Base < ::ActionView::TemplateHandlers::ERB |
|
| 4 |
|
|
| 5 |
# def compile(template) |
|
| 6 |
# src = "_rfpdf_compile_setup;" + super |
|
| 7 |
# end |
|
| 8 |
# end |
|
| 9 |
end |
|
| 10 |
end |
|
| 11 |
|
|
| 12 |
|
|
Also available in: Unified diff