Merged rails-3.2 branch.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9528 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2012-04-25 17:17:49 +00:00
parent 34e20c4373
commit 5e57a1a9d9
457 changed files with 20215 additions and 5352 deletions
+9
View File
@@ -143,3 +143,12 @@ custom_fields_010:
field_format: bool
default_value: 0
editable: true
custom_fields_011:
id: 11
name: Binary
type: CustomField
possible_values:
- !binary |
SGXDqWzDp2prc2Tigqw2NTTDuQ==
- Other value
field_format: list
+2 -2
View File
@@ -6,7 +6,7 @@ repositories_001:
root_url: file:///<%= Rails.root %>/tmp/test/subversion_repository
password: ""
login: ""
type: Subversion
type: Repository::Subversion
is_default: true
repositories_002:
project_id: 2
@@ -15,5 +15,5 @@ repositories_002:
root_url: svn://localhost
password: ""
login: ""
type: Subversion
type: Repository::Subversion
is_default: true
+13 -13
View File
@@ -318,7 +318,7 @@ class IssuesControllerTest < ActionController::TestCase
get :index, :format => 'csv'
assert_response :success
assert_not_nil assigns(:issues)
assert_equal 'text/csv', @response.content_type
assert_equal 'text/csv; header=present', @response.content_type
assert @response.body.starts_with?("#,")
lines = @response.body.chomp.split("\n")
assert_equal assigns(:query).columns.size + 1, lines[0].split(',').size
@@ -328,14 +328,14 @@ class IssuesControllerTest < ActionController::TestCase
get :index, :project_id => 1, :format => 'csv'
assert_response :success
assert_not_nil assigns(:issues)
assert_equal 'text/csv', @response.content_type
assert_equal 'text/csv; header=present', @response.content_type
end
def test_index_csv_with_description
get :index, :format => 'csv', :description => '1'
assert_response :success
assert_not_nil assigns(:issues)
assert_equal 'text/csv', @response.content_type
assert_equal 'text/csv; header=present', @response.content_type
assert @response.body.starts_with?("#,")
lines = @response.body.chomp.split("\n")
assert_equal assigns(:query).columns.size + 2, lines[0].split(',').size
@@ -347,7 +347,7 @@ class IssuesControllerTest < ActionController::TestCase
get :index, :format => 'csv', :set_filter => '1', :c => %w(subject spent_hours)
assert_response :success
assert_equal 'text/csv', @response.content_type
assert_equal 'text/csv; header=present', @response.content_type
lines = @response.body.chomp.split("\n")
assert_include "#{issue.id},#{issue.subject},7.33", lines
end
@@ -356,7 +356,7 @@ class IssuesControllerTest < ActionController::TestCase
get :index, :format => 'csv', :columns => 'all'
assert_response :success
assert_not_nil assigns(:issues)
assert_equal 'text/csv', @response.content_type
assert_equal 'text/csv; header=present', @response.content_type
assert @response.body.starts_with?("#,")
lines = @response.body.chomp.split("\n")
assert_equal assigns(:query).available_columns.size + 1, lines[0].split(',').size
@@ -391,7 +391,7 @@ class IssuesControllerTest < ActionController::TestCase
:f => ['subject'],
:op => '=', :values => [str_utf8],
:format => 'csv'
assert_equal 'text/csv', @response.content_type
assert_equal 'text/csv; header=present', @response.content_type
lines = @response.body.chomp.split("\n")
s1 = "\xaa\xac\xbaA"
if str_utf8.respond_to?(:force_encoding)
@@ -419,7 +419,7 @@ class IssuesControllerTest < ActionController::TestCase
:c => ['status', 'subject'],
:format => 'csv',
:set_filter => 1
assert_equal 'text/csv', @response.content_type
assert_equal 'text/csv; header=present', @response.content_type
lines = @response.body.chomp.split("\n")
s1 = "\xaa\xac\xbaA" # status
if str_utf8.respond_to?(:force_encoding)
@@ -454,7 +454,7 @@ class IssuesControllerTest < ActionController::TestCase
:c => ['estimated_hours', 'subject'],
:format => 'csv',
:set_filter => 1
assert_equal 'text/csv', @response.content_type
assert_equal 'text/csv; header=present', @response.content_type
lines = @response.body.chomp.split("\n")
assert_equal "#{issue.id},1234.50,#{str1}", lines[1]
@@ -483,7 +483,7 @@ class IssuesControllerTest < ActionController::TestCase
:c => ['estimated_hours', 'subject'],
:format => 'csv',
:set_filter => 1
assert_equal 'text/csv', @response.content_type
assert_equal 'text/csv; header=present', @response.content_type
lines = @response.body.chomp.split("\n")
assert_equal "#{issue.id};1234,50;#{str1}", lines[1]
@@ -1357,7 +1357,7 @@ class IssuesControllerTest < ActionController::TestCase
:attributes => {:name => 'issue[tracker_id]'},
:child => {:tag => 'option', :attributes => {:value => '3', :selected => 'selected'}}
assert_tag 'textarea',
:attributes => {:name => 'issue[description]'}, :content => 'Prefilled'
:attributes => {:name => 'issue[description]'}, :content => "\nPrefilled"
assert_tag 'input',
:attributes => {:name => 'issue[custom_field_values][2]', :value => 'Custom field value'}
end
@@ -1727,7 +1727,7 @@ class IssuesControllerTest < ActionController::TestCase
assert_template 'new'
assert_tag :textarea, :attributes => { :name => 'issue[description]' },
:content => 'This is a description'
:content => "\nThis is a description"
assert_tag :select, :attributes => { :name => 'issue[priority_id]' },
:child => { :tag => 'option', :attributes => { :selected => 'selected',
:value => '6' },
@@ -2621,7 +2621,7 @@ class IssuesControllerTest < ActionController::TestCase
assert_template 'edit'
assert_error_tag :descendant => {:content => /Activity can't be blank/}
assert_tag :textarea, :attributes => { :name => 'notes' }, :content => notes
assert_tag :textarea, :attributes => { :name => 'notes' }, :content => "\n"+notes
assert_tag :input, :attributes => { :name => 'time_entry[hours]', :value => "2z" }
end
@@ -2640,7 +2640,7 @@ class IssuesControllerTest < ActionController::TestCase
assert_error_tag :descendant => {:content => /Activity can't be blank/}
assert_error_tag :descendant => {:content => /Hours can't be blank/}
assert_tag :textarea, :attributes => { :name => 'notes' }, :content => notes
assert_tag :textarea, :attributes => { :name => 'notes' }, :content => "\n"+notes
assert_tag :input, :attributes => { :name => 'time_entry[comments]', :value => "this is my comment" }
end
+1 -1
View File
@@ -140,7 +140,7 @@ class QueriesControllerTest < ActionController::TestCase
def test_create_with_failure
@request.session[:user_id] = 2
assert_no_difference 'Query.count' do
assert_no_difference '::Query.count' do
post :create, :project_id => 'ecookbook', :query => {:name => ''}
end
assert_response :success
@@ -62,12 +62,26 @@ class RepositoriesSubversionControllerTest < ActionController::TestCase
entry = assigns(:entries).detect {|e| e.name == 'subversion_test'}
assert_not_nil entry
assert_equal 'dir', entry.kind
assert_select 'tr.dir a[href=/projects/subproject1/repository/show/subversion_test]'
assert_tag 'input', :attributes => {:name => 'rev'}
assert_tag 'a', :content => 'Statistics'
assert_tag 'a', :content => 'Atom'
end
def test_show_non_default
Repository::Subversion.create(:project => @project,
:url => self.class.subversion_repository_url,
:is_default => false, :identifier => 'svn')
get :show, :id => PRJ_ID, :repository_id => 'svn'
assert_response :success
assert_template 'show'
assert_select 'tr.dir a[href=/projects/subproject1/repository/svn/show/subversion_test]'
# Repository menu should link to the main repo
assert_select '#main-menu a[href=/projects/subproject1/repository]'
end
def test_browse_directory
assert_equal 0, @repository.changesets.count
@repository.fetch_changesets
@@ -136,7 +136,7 @@ class TimeEntryReportsControllerTest < ActionController::TestCase
get :report, :columns => 'month', :from => "2007-01-01", :to => "2007-06-30",
:criteria => ["project", "member", "activity"], :format => "csv"
assert_response :success
assert_equal 'text/csv', @response.content_type
assert_equal 'text/csv; header=present', @response.content_type
lines = @response.body.chomp.split("\n")
# Headers
assert_equal 'Project,Member,Activity,2007-1,2007-2,2007-3,2007-4,2007-5,2007-6,Total',
@@ -150,7 +150,7 @@ class TimeEntryReportsControllerTest < ActionController::TestCase
:from => "2007-01-01", :to => "2007-06-30",
:criteria => ["project", "member", "activity"], :format => "csv"
assert_response :success
assert_equal 'text/csv', @response.content_type
assert_equal 'text/csv; header=present', @response.content_type
lines = @response.body.chomp.split("\n")
# Headers
assert_equal 'Project,Member,Activity,2007-1,2007-2,2007-3,2007-4,2007-5,2007-6,Total',
@@ -188,7 +188,7 @@ class TimeEntryReportsControllerTest < ActionController::TestCase
:from => "2011-11-11", :to => "2011-11-11",
:criteria => ["member"], :format => "csv"
assert_response :success
assert_equal 'text/csv', @response.content_type
assert_equal 'text/csv; header=present', @response.content_type
lines = @response.body.chomp.split("\n")
# Headers
s1 = "\xa6\xa8\xad\xfb,2011-11-11,\xc1`\xadp"
@@ -239,7 +239,7 @@ class TimeEntryReportsControllerTest < ActionController::TestCase
:from => "2011-11-11", :to => "2011-11-11",
:criteria => ["member"], :format => "csv"
assert_response :success
assert_equal 'text/csv', @response.content_type
assert_equal 'text/csv; header=present', @response.content_type
lines = @response.body.chomp.split("\n")
# Headers
s1 = "\xa6\xa8\xad\xfb,2011-11-11,\xc1`\xadp"
@@ -280,7 +280,7 @@ class TimeEntryReportsControllerTest < ActionController::TestCase
:from => "2011-11-11", :to => "2011-11-11",
:criteria => ["member"], :format => "csv"
assert_response :success
assert_equal 'text/csv', @response.content_type
assert_equal 'text/csv; header=present', @response.content_type
lines = @response.body.chomp.split("\n")
# Headers
s1 = "Membre;2011-11-11;Total"
+6 -6
View File
@@ -561,7 +561,7 @@ class TimelogControllerTest < ActionController::TestCase
Setting.date_format = '%m/%d/%Y'
get :index, :format => 'csv'
assert_response :success
assert_equal 'text/csv', @response.content_type
assert_equal 'text/csv; header=present', @response.content_type
assert @response.body.include?("Date,User,Activity,Project,Issue,Tracker,Subject,Hours,Comment,Overtime\n")
assert @response.body.include?("\n04/21/2007,redMine Admin,Design,eCookbook,3,Bug,Error 281 when updating a recipe,1.0,\"\",\"\"\n")
end
@@ -570,7 +570,7 @@ class TimelogControllerTest < ActionController::TestCase
Setting.date_format = '%m/%d/%Y'
get :index, :project_id => 1, :format => 'csv'
assert_response :success
assert_equal 'text/csv', @response.content_type
assert_equal 'text/csv; header=present', @response.content_type
assert @response.body.include?("Date,User,Activity,Project,Issue,Tracker,Subject,Hours,Comment,Overtime\n")
assert @response.body.include?("\n04/21/2007,redMine Admin,Design,eCookbook,3,Bug,Error 281 when updating a recipe,1.0,\"\",\"\"\n")
end
@@ -616,7 +616,7 @@ class TimelogControllerTest < ActionController::TestCase
get :index, :project_id => 1, :format => 'csv',
:from => '2011-11-10', :to => '2011-11-10'
assert_response :success
assert_equal 'text/csv', @response.content_type
assert_equal 'text/csv; header=present', @response.content_type
ar = @response.body.chomp.split("\n")
s1 = "\xa4\xe9\xb4\xc1"
if str_utf8.respond_to?(:force_encoding)
@@ -653,7 +653,7 @@ class TimelogControllerTest < ActionController::TestCase
get :index, :project_id => 1, :format => 'csv',
:from => '2011-11-10', :to => '2011-11-10'
assert_response :success
assert_equal 'text/csv', @response.content_type
assert_equal 'text/csv; header=present', @response.content_type
ar = @response.body.chomp.split("\n")
s1 = "\xa4\xe9\xb4\xc1"
if str_utf8.respond_to?(:force_encoding)
@@ -690,7 +690,7 @@ class TimelogControllerTest < ActionController::TestCase
get :index, :project_id => 1, :format => 'csv',
:from => '2011-11-10', :to => '2011-11-10'
assert_response :success
assert_equal 'text/csv', @response.content_type
assert_equal 'text/csv; header=present', @response.content_type
ar = @response.body.chomp.split("\n")
s2 = ar[1].split(",")[7]
@@ -724,7 +724,7 @@ class TimelogControllerTest < ActionController::TestCase
get :index, :project_id => 1, :format => 'csv',
:from => '2011-11-10', :to => '2011-11-10'
assert_response :success
assert_equal 'text/csv', @response.content_type
assert_equal 'text/csv; header=present', @response.content_type
ar = @response.body.chomp.split("\n")
s2 = ar[1].split(";")[7]
+10 -1
View File
@@ -84,10 +84,19 @@ class WatchersControllerTest < ActionController::TestCase
assert_select_rjs :replace_html, 'ajax-modal'
end
def test_new_for_new_record
def test_new_for_new_record_with_id
@request.session[:user_id] = 2
xhr :get, :new, :project_id => 1
assert_response :success
assert_equal Project.find(1), assigns(:project)
assert_select_rjs :replace_html, 'ajax-modal'
end
def test_new_for_new_record_with_identifier
@request.session[:user_id] = 2
xhr :get, :new, :project_id => 'ecookbook'
assert_response :success
assert_equal Project.find(1), assigns(:project)
assert_select_rjs :replace_html, 'ajax-modal'
end
+3 -3
View File
@@ -198,7 +198,7 @@ class WikiControllerTest < ActionController::TestCase
assert_tag 'textarea',
:attributes => { :name => 'content[text]' },
:content => WikiPage.find_by_title('Another_page').content.text
:content => "\n"+WikiPage.find_by_title('Another_page').content.text
end
def test_edit_section
@@ -213,7 +213,7 @@ class WikiControllerTest < ActionController::TestCase
assert_tag 'textarea',
:attributes => { :name => 'content[text]' },
:content => section
:content => "\n"+section
assert_tag 'input',
:attributes => { :name => 'section', :type => 'hidden', :value => '2' }
assert_tag 'input',
@@ -294,7 +294,7 @@ class WikiControllerTest < ActionController::TestCase
assert_template 'edit'
assert_error_tag :descendant => {:content => /Comment is too long/}
assert_tag :tag => 'textarea', :attributes => {:id => 'content_text'}, :content => 'edited'
assert_tag :tag => 'textarea', :attributes => {:id => 'content_text'}, :content => "\nedited"
assert_tag :tag => 'input', :attributes => {:id => 'content_version', :value => '1'}
end
@@ -75,7 +75,7 @@ class ApiTest::IssueRelationsTest < ActionController::IntegrationTest
end
assert_response :unprocessable_entity
assert_tag :errors, :child => {:tag => 'error', :content => 'relation_type is not included in the list'}
assert_tag :errors, :child => {:tag => 'error', :content => /relation_type is not included in the list/}
end
end
end
@@ -167,7 +167,7 @@ class ApiTest::MembershipsTest < ActionController::IntegrationTest
assert_response :unprocessable_entity
assert_equal 'application/xml', @response.content_type
assert_tag 'errors', :child => {:tag => 'error', :content => "member_roles is invalid"}
assert_tag 'errors', :child => {:tag => 'error', :content => /member_roles is invalid/}
end
end
end
+2 -2
View File
@@ -215,14 +215,14 @@ class IssuesTest < ActionController::IntegrationTest
assert_not_equal subject, Issue.find(1).subject
post '/issues/1', {:issue => {:subject => subject}}, credentials('jsmith')
assert_response 405
assert_response 404
assert_not_equal subject, Issue.find(1).subject
end
def test_get_watch_should_be_invalid
assert_no_difference 'Watcher.count' do
get '/watchers/watch?object_type=issue&object_id=1', {}, credentials('jsmith')
assert_response 405
assert_response 404
end
end
end
+1 -1
View File
@@ -45,7 +45,7 @@ class ProjectsTest < ActionController::IntegrationTest
def test_modules_should_not_allow_get
assert_no_difference 'EnabledModule.count' do
get '/projects/1/modules', {:enabled_module_names => ['']}, credentials('jsmith')
assert_response :method_not_allowed
assert_response 404
end
end
end
+2 -2
View File
@@ -21,11 +21,11 @@ class RoutingActivitiesTest < ActionController::IntegrationTest
def test_activities
assert_routing(
{ :method => 'get', :path => "/activity" },
{ :controller => 'activities', :action => 'index', :id => nil }
{ :controller => 'activities', :action => 'index' }
)
assert_routing(
{ :method => 'get', :path => "/activity.atom" },
{ :controller => 'activities', :action => 'index', :id => nil, :format => 'atom' }
{ :controller => 'activities', :action => 'index', :format => 'atom' }
)
assert_routing(
{ :method => 'get', :path => "/projects/33/activity" },
@@ -21,7 +21,7 @@ class RoutingRepositoriesTest < ActionController::IntegrationTest
def setup
@path_hash = repository_path_hash(%w[path to file.c])
assert_equal "path/to/file.c", @path_hash[:path]
assert_equal %w[path to file.c], @path_hash[:param]
assert_equal "path/to/file.c", @path_hash[:param]
end
def test_repositories_resources
@@ -124,7 +124,7 @@ class RoutingRepositoriesTest < ActionController::IntegrationTest
{ :method => 'get',
:path => "/projects/redmine/repository/revisions/2457/show" },
{ :controller => 'repositories', :action => 'show', :id => 'redmine',
:path => empty_path_param, :rev => '2457' }
:rev => '2457' }
)
assert_routing(
{ :method => 'get',
@@ -136,7 +136,7 @@ class RoutingRepositoriesTest < ActionController::IntegrationTest
{ :method => 'get',
:path => "/projects/redmine/repository/revisions/2457/changes" },
{ :controller => 'repositories', :action => 'changes', :id => 'redmine',
:path => empty_path_param, :rev => '2457' }
:rev => '2457' }
)
assert_routing(
{ :method => 'get',
@@ -205,7 +205,7 @@ class RoutingRepositoriesTest < ActionController::IntegrationTest
{ :method => 'get',
:path => "/projects/redmine/repository/foo/revisions/2457/show" },
{ :controller => 'repositories', :action => 'show', :id => 'redmine', :repository_id => 'foo',
:path => empty_path_param, :rev => '2457' }
:rev => '2457' }
)
assert_routing(
{ :method => 'get',
@@ -217,7 +217,7 @@ class RoutingRepositoriesTest < ActionController::IntegrationTest
{ :method => 'get',
:path => "/projects/redmine/repository/foo/revisions/2457/changes" },
{ :controller => 'repositories', :action => 'changes', :id => 'redmine', :repository_id => 'foo',
:path => empty_path_param, :rev => '2457' }
:rev => '2457' }
)
assert_routing(
{ :method => 'get',
+7 -5
View File
@@ -90,11 +90,13 @@ class RoutingWikiTest < ActionController::IntegrationTest
{ :controller => 'wiki', :action => 'rename', :project_id => '22',
:id => 'ladida' }
)
assert_routing(
{ :method => 'post', :path => "/projects/567/wiki/CookBook_documentation/preview" },
{ :controller => 'wiki', :action => 'preview', :project_id => '567',
:id => 'CookBook_documentation' }
)
["post", "put"].each do |method|
assert_routing(
{ :method => method, :path => "/projects/567/wiki/CookBook_documentation/preview" },
{ :controller => 'wiki', :action => 'preview', :project_id => '567',
:id => 'CookBook_documentation' }
)
end
assert_routing(
{ :method => 'post', :path => "/projects/22/wiki/ladida/rename" },
{ :controller => 'wiki', :action => 'rename', :project_id => '22',
+19 -8
View File
@@ -15,15 +15,18 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#require 'shoulda'
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'test_help'
require 'rails/test_help'
require Rails.root.join('test', 'mocks', 'open_id_authentication_mock.rb').to_s
require File.expand_path(File.dirname(__FILE__) + '/object_helpers')
include ObjectHelpers
class ActiveSupport::TestCase
include ActionDispatch::TestProcess
# Transactional fixtures accelerate your tests by wrapping each test method
# in a transaction that's rolled back on completion. This ensures that the
# test database remains unchanged so your fixtures don't have to be reloaded
@@ -58,12 +61,11 @@ class ActiveSupport::TestCase
end
def uploaded_test_file(name, mime)
ActionController::TestUploadedFile.new(
ActiveSupport::TestCase.fixture_path + "/files/#{name}", mime, true)
fixture_file_upload("files/#{name}", mime, true)
end
def credentials(user, password=nil)
{:authorization => ActionController::HttpAuthentication::Basic.encode_credentials(user, password || user)}
{'HTTP_AUTHORIZATION' => ActionController::HttpAuthentication::Basic.encode_credentials(user, password || user)}
end
# Mock out a file
@@ -146,7 +148,7 @@ class ActiveSupport::TestCase
def repository_path_hash(arr)
hs = {}
hs[:path] = arr.join("/")
hs[:param] = arr
hs[:param] = arr.join("/")
hs
end
@@ -179,7 +181,7 @@ class ActiveSupport::TestCase
end
def mail_body(mail)
mail.body
mail.parts.first.body.encoded
end
# Shoulda macros
@@ -417,9 +419,13 @@ class ActiveSupport::TestCase
def self.should_respond_with_content_type_based_on_url(url)
case
when url.match(/xml/i)
should_respond_with_content_type :xml
should "respond with XML" do
assert_equal 'application/xml', @response.content_type
end
when url.match(/json/i)
should_respond_with_content_type :json
should "respond with JSON" do
assert_equal 'application/json', @response.content_type
end
else
raise "Unknown content type for should_respond_with_content_type_based_on_url: #{url}"
end
@@ -458,6 +464,11 @@ class ActiveSupport::TestCase
end
end
def self.should_respond_with(status)
should "respond with #{status}" do
assert_response status
end
end
end
# Simple module to "namespace" all of the API tests
+11
View File
@@ -75,6 +75,17 @@ class CustomFieldTest < ActiveSupport::TestCase
assert_equal ["One value", "And another one"], field.possible_values
end
if "string".respond_to?(:encoding)
def test_possible_values_stored_as_binary_should_be_utf8_encoded
field = CustomField.find(11)
assert_kind_of Array, field.possible_values
assert field.possible_values.size > 0
field.possible_values.each do |value|
assert_equal "UTF-8", value.encoding.name
end
end
end
def test_destroy
field = CustomField.find(1)
assert field.destroy
+1 -1
View File
@@ -79,7 +79,7 @@ class ApplicationHelperTest < ActionView::TestCase
# two exclamation marks
'http://example.net/path!602815048C7B5C20!302.html' => '<a class="external" href="http://example.net/path!602815048C7B5C20!302.html">http://example.net/path!602815048C7B5C20!302.html</a>',
# escaping
'http://foo"bar' => '<a class="external" href="http://foo&quot;bar">http://foo"bar</a>',
'http://foo"bar' => '<a class="external" href="http://foo&quot;bar">http://foo&quot;bar</a>',
# wrap in angle brackets
'<http://foo.bar>' => '&lt;<a class="external" href="http://foo.bar">http://foo.bar</a>&gt;'
}
+15 -11
View File
@@ -1033,11 +1033,12 @@ class IssueTest < ActiveSupport::TestCase
assert IssueRelation.create!(:issue_from => Issue.find(2),
:issue_to => Issue.find(3),
:relation_type => IssueRelation::TYPE_PRECEDES)
# Validation skipping
assert IssueRelation.new(:issue_from => Issue.find(3),
:issue_to => Issue.find(1),
:relation_type => IssueRelation::TYPE_PRECEDES).save(false)
r = IssueRelation.create!(:issue_from => Issue.find(3),
:issue_to => Issue.find(7),
:relation_type => IssueRelation::TYPE_PRECEDES)
IssueRelation.update_all("issue_to_id = 1", ["id = ?", r.id])
assert_equal [2, 3], Issue.find(1).all_dependent_issues.collect(&:id).sort
end
@@ -1052,13 +1053,16 @@ class IssueTest < ActiveSupport::TestCase
assert IssueRelation.create!(:issue_from => Issue.find(3),
:issue_to => Issue.find(8),
:relation_type => IssueRelation::TYPE_RELATES)
# Validation skipping
assert IssueRelation.new(:issue_from => Issue.find(8),
:issue_to => Issue.find(2),
:relation_type => IssueRelation::TYPE_RELATES).save(false)
assert IssueRelation.new(:issue_from => Issue.find(3),
:issue_to => Issue.find(1),
:relation_type => IssueRelation::TYPE_RELATES).save(false)
r = IssueRelation.create!(:issue_from => Issue.find(8),
:issue_to => Issue.find(7),
:relation_type => IssueRelation::TYPE_RELATES)
IssueRelation.update_all("issue_to_id = 2", ["id = ?", r.id])
r = IssueRelation.create!(:issue_from => Issue.find(3),
:issue_to => Issue.find(7),
:relation_type => IssueRelation::TYPE_RELATES)
IssueRelation.update_all("issue_to_id = 1", ["id = ?", r.id])
assert_equal [2, 3, 8], Issue.find(1).all_dependent_issues.collect(&:id).sort
end
+1 -1
View File
@@ -17,7 +17,7 @@
require File.expand_path('../../../../test_helper', __FILE__)
class Redmine::Hook::ManagerTest < ActiveSupport::TestCase
class Redmine::Hook::ManagerTest < ActionView::TestCase
fixtures :issues
@@ -21,6 +21,7 @@ class Redmine::WikiFormatting::MacrosTest < ActionView::TestCase
include ApplicationHelper
include ActionView::Helpers::TextHelper
include ActionView::Helpers::SanitizeHelper
include ERB::Util
extend ActionView::Helpers::SanitizeHelper::ClassMethods
fixtures :projects, :roles, :enabled_modules, :users,
+10 -22
View File
@@ -19,7 +19,7 @@ require File.expand_path('../../test_helper', __FILE__)
class MailerTest < ActiveSupport::TestCase
include Redmine::I18n
include ActionController::Assertions::SelectorAssertions
include ActionDispatch::Assertions::SelectorAssertions
fixtures :projects, :enabled_modules, :issues, :users, :members,
:member_roles, :roles, :documents, :attachments, :news,
:tokens, :journals, :journal_details, :changesets, :trackers,
@@ -78,7 +78,6 @@ class MailerTest < ActiveSupport::TestCase
relative_url_root = Redmine::Utils.relative_url_root
Setting.host_name = 'mydomain.foo/rdm'
Setting.protocol = 'http'
Redmine::Utils.relative_url_root = '/rdm'
journal = Journal.find(3)
assert Mailer.deliver_issue_edit(journal)
@@ -111,9 +110,6 @@ class MailerTest < ActiveSupport::TestCase
'http://mydomain.foo/rdm/attachments/download/4/source.rb',
:text => 'source.rb'
end
ensure
# restore it
Redmine::Utils.relative_url_root = relative_url_root
end
def test_generated_links_with_prefix_and_no_relative_url_root
@@ -164,15 +160,15 @@ class MailerTest < ActiveSupport::TestCase
Mailer.deliver_issue_add(issue)
mail = last_email
assert_not_nil mail
assert_equal 'OOF', mail.header_string('X-Auto-Response-Suppress')
assert_equal 'auto-generated', mail.header_string('Auto-Submitted')
assert_equal 'OOF', mail.header['X-Auto-Response-Suppress'].to_s
assert_equal 'auto-generated', mail.header['Auto-Submitted'].to_s
end
def test_email_headers_should_include_sender
issue = Issue.find(1)
Mailer.deliver_issue_add(issue)
mail = last_email
assert_equal issue.author.login, mail.header_string('X-Redmine-Sender')
assert_equal issue.author.login, mail.header['X-Redmine-Sender'].to_s
end
def test_plain_text_mail
@@ -180,7 +176,7 @@ class MailerTest < ActiveSupport::TestCase
journal = Journal.find(2)
Mailer.deliver_issue_edit(journal)
mail = last_email
assert_equal "text/plain", mail.content_type
assert_equal "text/plain; charset=UTF-8", mail.content_type
assert_equal 0, mail.parts.size
assert !mail.encoded.include?('href')
end
@@ -199,7 +195,7 @@ class MailerTest < ActiveSupport::TestCase
Mailer.deliver_test_email(User.find(1))
end
mail = last_email
assert_equal 'redmine@example.net', mail.from_addrs.first.address
assert_equal 'redmine@example.net', mail.from_addrs.first
end
def test_from_header_with_phrase
@@ -207,8 +203,8 @@ class MailerTest < ActiveSupport::TestCase
Mailer.deliver_test_email(User.find(1))
end
mail = last_email
assert_equal 'redmine@example.net', mail.from_addrs.first.address
assert_equal 'Redmine app', mail.from_addrs.first.name
assert_equal 'redmine@example.net', mail.from_addrs.first
assert_equal 'Redmine app <redmine@example.net>', mail.header['From'].to_s
end
def test_should_not_send_email_without_recipient
@@ -245,7 +241,7 @@ class MailerTest < ActiveSupport::TestCase
Mailer.deliver_issue_edit(journal)
mail = last_email
assert_equal Mailer.message_id_for(journal), mail.message_id
assert_equal Mailer.message_id_for(journal.issue), mail.references.first.to_s
assert_include Mailer.message_id_for(journal.issue), mail.references
assert_select_email do
# link to the update
assert_select "a[href=?]",
@@ -272,7 +268,7 @@ class MailerTest < ActiveSupport::TestCase
Mailer.deliver_message_posted(message)
mail = last_email
assert_equal Mailer.message_id_for(message), mail.message_id
assert_equal Mailer.message_id_for(message.parent), mail.references.first.to_s
assert_include Mailer.message_id_for(message.parent), mail.references
assert_select_email do
# link to the reply
assert_select "a[href=?]",
@@ -528,14 +524,6 @@ class MailerTest < ActiveSupport::TestCase
# should restore perform_deliveries
assert ActionMailer::Base.perform_deliveries
end
def test_tmail_to_header_field_should_not_include_blank_lines
mail = TMail::Mail.new
mail.to = ["a.user@example.com", "v.user2@example.com", "e.smith@example.com", "info@example.com", "v.pupkin@example.com",
"b.user@example.com", "w.user2@example.com", "f.smith@example.com", "info2@example.com", "w.pupkin@example.com"]
assert !mail.encoded.strip.split("\r\n").detect(&:blank?), "#{mail.encoded} malformed"
end
def test_layout_should_include_the_emails_header
with_settings :emails_header => "*Header content*" do
+1 -1
View File
@@ -141,7 +141,7 @@ class UserTest < ActiveSupport::TestCase
u2 = User.new(:firstname => "new", :lastname => "user", :mail => "newuser2@somenet.foo")
u2.login = 'newuser1'
assert u2.save(false)
assert u2.save(:validate => false)
user = User.find(u2.id)
user.firstname = "firstname"
+1 -1
View File
@@ -157,7 +157,7 @@ class WatcherTest < ActiveSupport::TestCase
def test_prune_all
user = User.find(9)
Watcher.new(:watchable => Issue.find(4), :user => User.find(9)).save(false)
Watcher.new(:watchable => Issue.find(4), :user => User.find(9)).save(:validate => false)
assert Watcher.prune > 0
assert !Issue.find(4).watched_by?(user)