GitLab ist jetzt auf dem neuesten Stand! Die jüngsten Probleme wurden behoben. Wir entschuldigen uns für die dadurch verursachten Unannehmlichkeiten.

Commit 0bf9be8a authored by jplang's avatar jplang

Set User.current to nil before unit tests.

git-svn-id: https://svn.redmine.org/redmine/trunk@17761 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 2766df97
......@@ -23,6 +23,7 @@ class ActivityTest < ActiveSupport::TestCase
:wikis, :wiki_pages, :wiki_contents, :wiki_content_versions
def setup
User.current = nil
@project = Project.find(1)
end
......
......@@ -26,6 +26,7 @@ class AttachmentTest < ActiveSupport::TestCase
self.use_transactional_tests = false
def setup
User.current = nil
set_tmp_attachments_directory
end
......
......@@ -22,6 +22,7 @@ class AuthSourceLdapTest < ActiveSupport::TestCase
fixtures :auth_sources
def setup
User.current = nil
end
def test_initialize
......
......@@ -25,6 +25,7 @@ class BoardTest < ActiveSupport::TestCase
include Redmine::I18n
def setup
User.current = nil
@project = Project.find(1)
end
......
......@@ -32,6 +32,10 @@ class ChangesetTest < ActiveSupport::TestCase
:trackers, :projects_trackers,
:enabled_modules, :roles
def setup
User.current = nil
end
def test_ref_keywords_any
ActionMailer::Base.deliveries.clear
Setting.commit_ref_keywords = '*'
......
......@@ -22,6 +22,7 @@ class CommentTest < ActiveSupport::TestCase
:user_preferences, :roles, :members, :member_roles
def setup
User.current = nil
@jsmith = User.find(2)
@news = News.find(1)
end
......
......@@ -21,6 +21,7 @@ class CustomFieldUserFormatTest < ActiveSupport::TestCase
fixtures :custom_fields, :projects, :members, :users, :member_roles, :trackers, :issues
def setup
User.current = nil
@field = IssueCustomField.create!(:name => 'Tester', :field_format => 'user')
end
......
......@@ -21,6 +21,7 @@ class CustomFieldVersionFormatTest < ActiveSupport::TestCase
fixtures :custom_fields, :projects, :members, :users, :member_roles, :trackers, :issues, :versions
def setup
User.current = nil
@field = IssueCustomField.create!(:name => 'Tester', :field_format => 'version')
end
......
......@@ -20,6 +20,10 @@ require File.expand_path('../../test_helper', __FILE__)
class CustomValueTest < ActiveSupport::TestCase
fixtures :custom_fields, :custom_values, :users
def setup
User.current = nil
end
def test_new_without_value_should_set_default_value
field = CustomField.generate!(:default_value => 'Default string')
......
......@@ -21,6 +21,10 @@ class DefaultDataTest < ActiveSupport::TestCase
include Redmine::I18n
fixtures :roles
def setup
User.current = nil
end
def test_no_data
assert !Redmine::DefaultData::Loader::no_data?
clear_data
......
......@@ -20,6 +20,10 @@ require File.expand_path('../../test_helper', __FILE__)
class DocumentCategoryTest < ActiveSupport::TestCase
fixtures :enumerations, :documents, :issues
def setup
User.current = nil
end
def test_should_be_an_enumeration
assert DocumentCategory.ancestors.include?(Enumeration)
end
......
......@@ -20,6 +20,10 @@ require File.expand_path('../../test_helper', __FILE__)
class EnabledModuleTest < ActiveSupport::TestCase
fixtures :projects, :trackers, :issue_statuses, :wikis
def setup
User.current = nil
end
def test_enabling_wiki_should_create_a_wiki
CustomField.delete_all
project = Project.create!(:name => 'Project with wiki', :identifier => 'wikiproject', :enabled_module_names => [])
......
......@@ -20,6 +20,10 @@ require File.expand_path('../../test_helper', __FILE__)
class EnumerationTest < ActiveSupport::TestCase
fixtures :enumerations, :issues, :custom_fields, :custom_values
def setup
User.current = nil
end
def test_objects_count
# low priority
assert_equal 6, Enumeration.find(4).objects_count
......
......@@ -28,6 +28,10 @@ class GroupTest < ActiveSupport::TestCase
include Redmine::I18n
def setup
User.current = nil
end
def test_create
g = Group.new(:name => 'New group')
assert g.save
......
......@@ -21,6 +21,7 @@ class IssueCategoryTest < ActiveSupport::TestCase
fixtures :issue_categories, :issues, :users, :groups_users
def setup
User.current = nil
@category = IssueCategory.find(1)
end
......
......@@ -22,6 +22,11 @@ class IssueCustomFieldTest < ActiveSupport::TestCase
fixtures :roles
def setup
User.current = nil
@category = IssueCategory.find(1)
end
def test_custom_field_with_visible_set_to_false_should_validate_roles
set_language_if_valid 'en'
field = IssueCustomField.new(:name => 'Field', :field_format => 'string', :visible => false)
......
......@@ -35,6 +35,7 @@ class IssueImportTest < ActiveSupport::TestCase
include Redmine::I18n
def setup
User.current = nil
set_language_if_valid 'en'
end
......
......@@ -28,6 +28,7 @@ class IssueNestedSetConcurrencyTest < ActiveSupport::TestCase
def setup
skip if sqlite? || mysql?
User.current = nil
CustomField.delete_all
end
......
......@@ -20,6 +20,10 @@ require File.expand_path('../../test_helper', __FILE__)
class IssuePriorityTest < ActiveSupport::TestCase
fixtures :enumerations, :issues
def setup
User.current = nil
end
def test_named_scope
assert_equal Enumeration.find_by_name('Normal'), Enumeration.named('normal').first
end
......
......@@ -33,6 +33,10 @@ class IssueRelationTest < ActiveSupport::TestCase
include Redmine::I18n
def setup
User.current = nil
end
def test_create
from = Issue.find(1)
to = Issue.find(2)
......
......@@ -26,6 +26,10 @@ class IssueScopesTest < ActiveSupport::TestCase
:issues,
:custom_fields, :custom_fields_projects, :custom_fields_trackers, :custom_values
def setup
User.current = nil
end
def test_cross_project_scope_without_project_should_return_all_issues
ids = Issue.cross_project_scope(nil).pluck(:id).sort
assert_equal Issue.pluck(:id).sort, ids
......
......@@ -28,6 +28,10 @@ class IssueStatusTest < ActiveSupport::TestCase
:issues, :journals, :journal_details,
:custom_fields, :custom_fields_projects, :custom_fields_trackers, :custom_values
def setup
User.current = nil
end
def test_create
status = IssueStatus.new :name => "Assigned"
assert !status.save
......
......@@ -25,6 +25,10 @@ class IssueSubtaskingTest < ActiveSupport::TestCase
:enabled_modules,
:workflows
def setup
User.current = nil
end
def test_leaf_planning_fields_should_be_editable
issue = Issue.generate!
user = User.find(1)
......
......@@ -29,6 +29,10 @@ class IssueTransactionTest < ActiveSupport::TestCase
self.use_transactional_tests = false
def setup
User.current = nil
end
def test_invalid_move_to_another_project
lft1 = new_issue_lft
parent1 = Issue.generate!
......
......@@ -23,6 +23,7 @@ class JournalObserverTest < ActiveSupport::TestCase
:users, :email_addresses, :roles
def setup
User.current = nil
ActionMailer::Base.deliveries.clear
@journal = Journal.find 1
end
......
......@@ -26,6 +26,7 @@ class AttachmentFormatVisibilityTest < ActionView::TestCase
:versions, :issues
def setup
User.current = nil
set_tmp_attachments_directory
end
......
......@@ -23,6 +23,7 @@ class Redmine::BoolFieldFormatTest < ActionView::TestCase
include Redmine::I18n
def setup
User.current = nil
set_language_if_valid 'en'
end
......
......@@ -22,6 +22,7 @@ class Redmine::EnumerationFieldFormatTest < ActionView::TestCase
include ApplicationHelper
def setup
User.current = nil
set_language_if_valid 'en'
@field = IssueCustomField.create!(:name => 'List', :field_format => 'enumeration', :is_required => false)
@foo = CustomFieldEnumeration.new(:name => 'Foo')
......
......@@ -21,6 +21,7 @@ class Redmine::FieldFormatTest < ActionView::TestCase
include ApplicationHelper
def setup
User.current = nil
set_language_if_valid 'en'
end
......
......@@ -19,6 +19,11 @@ require File.expand_path('../../../../../test_helper', __FILE__)
require 'redmine/field_format'
class Redmine::LinkFieldFormatTest < ActionView::TestCase
def setup
User.current = nil
end
def test_link_field_should_substitute_value
field = IssueCustomField.new(:field_format => 'link', :url_pattern => 'http://foo/%value%')
custom_value = CustomValue.new(:custom_field => field, :customized => Issue.new, :value => "bar")
......
......@@ -23,6 +23,7 @@ class Redmine::ListFieldFormatTest < ActionView::TestCase
include Redmine::I18n
def setup
User.current = nil
set_language_if_valid 'en'
end
......
......@@ -21,6 +21,10 @@ require 'redmine/field_format'
class Redmine::NumericFieldFormatTest < ActionView::TestCase
include ApplicationHelper
def setup
User.current = nil
end
def test_integer_field_with_url_pattern_should_format_as_link
field = IssueCustomField.new(:field_format => 'int', :url_pattern => 'http://foo/%value%')
custom_value = CustomValue.new(:custom_field => field, :customized => Issue.new, :value => "3")
......
......@@ -25,6 +25,10 @@ class Redmine::UserFieldFormatTest < ActionView::TestCase
:enumerations,
:custom_fields, :custom_fields_trackers, :custom_fields_projects
def setup
User.current = nil
end
def test_user_role_should_reject_blank_values
field = IssueCustomField.new(:name => 'Foo', :field_format => 'user', :user_role => ["1", ""])
field.save!
......
......@@ -35,6 +35,7 @@ class MemberTest < ActiveSupport::TestCase
include Redmine::I18n
def setup
User.current = nil
@jsmith = Member.find(1)
end
......
......@@ -22,6 +22,7 @@ class MessageTest < ActiveSupport::TestCase
:users, :watchers, :enabled_modules
def setup
User.current = nil
@board = Board.find(1)
@user = User.find(1)
end
......
......@@ -25,6 +25,7 @@ class NewsTest < ActiveSupport::TestCase
end
def setup
User.current = nil
end
def test_create_should_send_email_notification
......
......@@ -22,6 +22,7 @@ class ProjectMembersInheritanceTest < ActiveSupport::TestCase
:projects, :trackers, :issue_statuses
def setup
User.current = nil
@parent = Project.generate!
@member = Member.create!(:principal => User.find(2), :project => @parent, :role_ids => [1, 2])
assert_equal 2, @member.reload.roles.size
......
......@@ -21,6 +21,7 @@ class ProjectNestedSetConcurrencyTest < ActiveSupport::TestCase
self.use_transactional_tests = false
def setup
User.current = nil
CustomField.delete_all
end
......
......@@ -20,6 +20,7 @@ require File.expand_path('../../test_helper', __FILE__)
class ProjectNestedSetTest < ActiveSupport::TestCase
def setup
User.current = nil
Project.delete_all
Tracker.delete_all
EnabledModule.delete_all
......
......@@ -48,6 +48,7 @@ class RepositoryBazaarTest < ActiveSupport::TestCase
CHAR_1_LATIN1_HEX = "\xdc".force_encoding('ASCII-8BIT')
def setup
User.current = nil
@project = Project.find(3)
@repository = Repository::Bazaar.create(
:project => @project, :url => REPOSITORY_PATH_TRUNK,
......
......@@ -29,6 +29,7 @@ class RepositoryCvsTest < ActiveSupport::TestCase
CHANGESETS_NUM = 7
def setup
User.current = nil
@project = Project.find(3)
@repository = Repository::Cvs.create(:project => @project,
:root_url => REPOSITORY_PATH,
......
......@@ -25,6 +25,7 @@ class RepositoryFilesystemTest < ActiveSupport::TestCase
REPOSITORY_PATH = Rails.root.join('tmp/test/filesystem_repository').to_s
def setup
User.current = nil
@project = Project.find(3)
Setting.enabled_scm << 'Filesystem' unless Setting.enabled_scm.include?('Filesystem')
@repository = Repository::Filesystem.create(
......
......@@ -40,6 +40,7 @@ class RepositoryGitTest < ActiveSupport::TestCase
JRUBY_SKIP_STR = "TODO: This test fails in JRuby"
def setup
User.current = nil
@project = Project.find(3)
@repository = Repository::Git.create(
:project => @project,
......
......@@ -29,6 +29,7 @@ class RepositoryMercurialTest < ActiveSupport::TestCase
BRANCH_CHAR_1 = "branch-#{CHAR_1_HEX}-01".force_encoding('UTF-8')
def setup
User.current = nil
@project = Project.find(3)
@repository = Repository::Mercurial.create(
:project => @project,
......
......@@ -25,6 +25,7 @@ class RepositorySubversionTest < ActiveSupport::TestCase
NUM_REV = 11
def setup
User.current = nil
@project = Project.find(3)
@repository = Repository::Subversion.create(:project => @project,
:url => self.class.subversion_repository_url)
......
......@@ -38,6 +38,7 @@ class RepositoryTest < ActiveSupport::TestCase
include Redmine::I18n
def setup
User.current = nil
@repository = Project.find(1).repository
end
......
......@@ -20,6 +20,10 @@ require File.expand_path('../../test_helper', __FILE__)
class RoleTest < ActiveSupport::TestCase
fixtures :roles, :workflows, :trackers
def setup
User.current = nil
end
def test_sorted_scope
assert_equal Role.all.sort, Role.sorted.to_a
end
......
......@@ -37,6 +37,7 @@ class SearchTest < ActiveSupport::TestCase
:changesets
def setup
User.current = nil
@project = Project.find(1)
@issue_keyword = '%unable to print recipes%'
@issue = Issue.find(1)
......
......@@ -21,6 +21,10 @@ require File.expand_path('../../test_helper', __FILE__)
class SettingTest < ActiveSupport::TestCase
def setup
User.current = nil
end
def teardown
Setting.delete_all
Setting.clear_cache
......
......@@ -30,6 +30,10 @@ class TimeEntryActivityTest < ActiveSupport::TestCase
include Redmine::I18n
def setup
User.current = nil
end
def test_should_be_an_enumeration
assert TimeEntryActivity.ancestors.include?(Enumeration)
end
......
......@@ -28,6 +28,10 @@ class TimeEntryQueryTest < ActiveSupport::TestCase
:enabled_modules,
:custom_fields, :custom_fields_trackers, :custom_fields_projects
def setup
User.current = nil
end
def test_filter_values_without_project_should_be_arrays
q = TimeEntryQuery.new
assert_nil q.project
......
......@@ -20,6 +20,10 @@ require File.expand_path('../../test_helper', __FILE__)
class TokenTest < ActiveSupport::TestCase
fixtures :tokens, :users, :email_addresses
def setup
User.current = nil
end
def test_create
token = Token.new
token.save
......
......@@ -20,6 +20,10 @@ require File.expand_path('../../test_helper', __FILE__)
class TrackerTest < ActiveSupport::TestCase
fixtures :trackers, :workflows, :issue_statuses, :roles, :issues, :projects, :projects_trackers, :enabled_modules
def setup
User.current = nil
end
def test_sorted_scope
assert_equal Tracker.all.sort, Tracker.sorted.to_a
end
......
......@@ -20,6 +20,10 @@ require File.expand_path('../../test_helper', __FILE__)
class UserPreferenceTest < ActiveSupport::TestCase
fixtures :users, :user_preferences
def setup
User.current = nil
end
def test_hide_mail_should_default_to_true
preference = UserPreference.new
assert_equal true, preference.hide_mail
......
......@@ -22,6 +22,10 @@ class VersionTest < ActiveSupport::TestCase
:enumerations, :versions, :projects_trackers,
:custom_fields, :custom_fields_trackers, :custom_fields_projects
def setup
User.current = nil
end
def test_create
v = Version.new(:project => Project.find(1), :name => '1.1',
:effective_date => '2011-03-25')
......
......@@ -25,6 +25,7 @@ class WatcherTest < ActiveSupport::TestCase
:watchers
def setup
User.current = nil
@user = User.find(1)
@issue = Issue.find(1)
end
......
......@@ -24,6 +24,7 @@ class WikiContentTest < ActiveSupport::TestCase
:wikis, :wiki_pages, :wiki_contents, :wiki_content_versions
def setup
User.current = nil
@wiki = Wiki.find(1)
@page = @wiki.pages.first
end
......
......@@ -21,6 +21,7 @@ class WikiContentVersionTest < ActiveSupport::TestCase
fixtures :projects, :users, :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions
def setup
User.current = nil
end
def test_should_respond_to_attachments
......
......@@ -21,6 +21,7 @@ class WikiPageTest < ActiveSupport::TestCase
fixtures :projects, :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions
def setup
User.current = nil
@wiki = Wiki.find(1)
@page = @wiki.pages.first
end
......
......@@ -21,6 +21,7 @@ class WikiRedirectTest < ActiveSupport::TestCase
fixtures :projects, :wikis, :wiki_pages
def setup
User.current = nil
@wiki = Wiki.find(1)
@original = WikiPage.create(:wiki => @wiki, :title => 'Original title')
end
......
......@@ -22,6 +22,10 @@ require File.expand_path('../../test_helper', __FILE__)
class WikiTest < ActiveSupport::TestCase
fixtures :projects, :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions
def setup
User.current = nil
end