mirror of
https://github.com/redmine/redmine.git
synced 2025-11-15 17:56:03 +01:00
cleanup: rubocop: fix Layout/IndentFirstArgument in test/unit/repository_test.rb
git-svn-id: http://svn.redmine.org/redmine/trunk@19224 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -48,11 +48,13 @@ class RepositoryTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
def test_blank_log_encoding_error_message
|
def test_blank_log_encoding_error_message
|
||||||
set_language_if_valid 'en'
|
set_language_if_valid 'en'
|
||||||
repo = Repository::Bazaar.new(
|
repo =
|
||||||
:project => Project.find(3),
|
Repository::Bazaar.
|
||||||
:url => "/test",
|
new(
|
||||||
:log_encoding => ''
|
:project => Project.find(3),
|
||||||
)
|
:url => "/test",
|
||||||
|
:log_encoding => ''
|
||||||
|
)
|
||||||
assert !repo.save
|
assert !repo.save
|
||||||
assert_include "Commit messages encoding cannot be blank",
|
assert_include "Commit messages encoding cannot be blank",
|
||||||
repo.errors.full_messages
|
repo.errors.full_messages
|
||||||
@@ -60,10 +62,12 @@ class RepositoryTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
def test_blank_log_encoding_error_message_fr
|
def test_blank_log_encoding_error_message_fr
|
||||||
set_language_if_valid 'fr'
|
set_language_if_valid 'fr'
|
||||||
repo = Repository::Bazaar.new(
|
repo =
|
||||||
:project => Project.find(3),
|
Repository::Bazaar.
|
||||||
:url => "/test"
|
new(
|
||||||
)
|
:project => Project.find(3),
|
||||||
|
:url => "/test"
|
||||||
|
)
|
||||||
assert !repo.save
|
assert !repo.save
|
||||||
assert_include 'Encodage des messages de commit doit être renseigné(e)', repo.errors.full_messages
|
assert_include 'Encodage des messages de commit doit être renseigné(e)', repo.errors.full_messages
|
||||||
end
|
end
|
||||||
@@ -111,19 +115,23 @@ class RepositoryTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_first_repository_should_be_set_as_default
|
def test_first_repository_should_be_set_as_default
|
||||||
repository1 = Repository::Subversion.new(
|
repository1 =
|
||||||
:project => Project.find(3),
|
Repository::Subversion.
|
||||||
:identifier => 'svn1',
|
new(
|
||||||
:url => 'file:///svn1'
|
:project => Project.find(3),
|
||||||
)
|
:identifier => 'svn1',
|
||||||
|
:url => 'file:///svn1'
|
||||||
|
)
|
||||||
assert repository1.save
|
assert repository1.save
|
||||||
assert repository1.is_default?
|
assert repository1.is_default?
|
||||||
|
|
||||||
repository2 = Repository::Subversion.new(
|
repository2 =
|
||||||
:project => Project.find(3),
|
Repository::Subversion.
|
||||||
:identifier => 'svn2',
|
new(
|
||||||
:url => 'file:///svn2'
|
:project => Project.find(3),
|
||||||
)
|
:identifier => 'svn2',
|
||||||
|
:url => 'file:///svn2'
|
||||||
|
)
|
||||||
assert repository2.save
|
assert repository2.save
|
||||||
assert !repository2.is_default?
|
assert !repository2.is_default?
|
||||||
|
|
||||||
@@ -133,20 +141,24 @@ class RepositoryTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
def test_default_repository_should_be_one
|
def test_default_repository_should_be_one
|
||||||
assert_equal 0, Project.find(3).repositories.count
|
assert_equal 0, Project.find(3).repositories.count
|
||||||
repository1 = Repository::Subversion.new(
|
repository1 =
|
||||||
:project => Project.find(3),
|
Repository::Subversion.
|
||||||
:identifier => 'svn1',
|
new(
|
||||||
:url => 'file:///svn1'
|
:project => Project.find(3),
|
||||||
)
|
:identifier => 'svn1',
|
||||||
|
:url => 'file:///svn1'
|
||||||
|
)
|
||||||
assert repository1.save
|
assert repository1.save
|
||||||
assert repository1.is_default?
|
assert repository1.is_default?
|
||||||
|
|
||||||
repository2 = Repository::Subversion.new(
|
repository2 =
|
||||||
:project => Project.find(3),
|
Repository::Subversion.
|
||||||
:identifier => 'svn2',
|
new(
|
||||||
:url => 'file:///svn2',
|
:project => Project.find(3),
|
||||||
:is_default => true
|
:identifier => 'svn2',
|
||||||
)
|
:url => 'file:///svn2',
|
||||||
|
:is_default => true
|
||||||
|
)
|
||||||
assert repository2.save
|
assert repository2.save
|
||||||
assert repository2.is_default?
|
assert repository2.is_default?
|
||||||
repository1.reload
|
repository1.reload
|
||||||
@@ -157,11 +169,13 @@ class RepositoryTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_identifier_should_accept_letters_digits_dashes_and_underscores
|
def test_identifier_should_accept_letters_digits_dashes_and_underscores
|
||||||
r = Repository::Subversion.new(
|
r =
|
||||||
:project_id => 3,
|
Repository::Subversion.
|
||||||
:identifier => 'svn-123_45',
|
new(
|
||||||
:url => 'file:///svn'
|
:project_id => 3,
|
||||||
)
|
:identifier => 'svn-123_45',
|
||||||
|
:url => 'file:///svn'
|
||||||
|
)
|
||||||
assert r.save
|
assert r.save
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -226,8 +240,12 @@ class RepositoryTest < ActiveSupport::TestCase
|
|||||||
def test_should_not_create_with_disabled_scm
|
def test_should_not_create_with_disabled_scm
|
||||||
# disable Subversion
|
# disable Subversion
|
||||||
with_settings :enabled_scm => ['Mercurial', 'Git'] do
|
with_settings :enabled_scm => ['Mercurial', 'Git'] do
|
||||||
repository = Repository::Subversion.new(
|
repository =
|
||||||
:project => Project.find(3), :url => "svn://localhost")
|
Repository::Subversion.
|
||||||
|
new(
|
||||||
|
:project => Project.find(3),
|
||||||
|
:url => "svn://localhost"
|
||||||
|
)
|
||||||
assert !repository.save
|
assert !repository.save
|
||||||
assert_include I18n.translate('activerecord.errors.messages.invalid'),
|
assert_include I18n.translate('activerecord.errors.messages.invalid'),
|
||||||
repository.errors[:type]
|
repository.errors[:type]
|
||||||
@@ -271,9 +289,11 @@ class RepositoryTest < ActiveSupport::TestCase
|
|||||||
ActionMailer::Base.deliveries.first(2).each do |mail|
|
ActionMailer::Base.deliveries.first(2).each do |mail|
|
||||||
assert_not_nil mail
|
assert_not_nil mail
|
||||||
assert mail.subject.starts_with?(
|
assert mail.subject.starts_with?(
|
||||||
"[#{fixed_issue.project.name} - #{fixed_issue.tracker.name} ##{fixed_issue.id}]")
|
"[#{fixed_issue.project.name} - #{fixed_issue.tracker.name} ##{fixed_issue.id}]"
|
||||||
|
)
|
||||||
assert_mail_body_match(
|
assert_mail_body_match(
|
||||||
"Status changed from #{old_status} to #{fixed_issue.status}", mail)
|
"Status changed from #{old_status} to #{fixed_issue.status}", mail
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
# ignoring commits referencing an issue of another project
|
# ignoring commits referencing an issue of another project
|
||||||
@@ -281,9 +301,12 @@ class RepositoryTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_for_changeset_comments_strip
|
def test_for_changeset_comments_strip
|
||||||
repository = Repository::Mercurial.create(
|
repository =
|
||||||
:project => Project.find(4),
|
Repository::Mercurial.
|
||||||
:url => '/foo/bar/baz' )
|
create(
|
||||||
|
:project => Project.find(4),
|
||||||
|
:url => '/foo/bar/baz'
|
||||||
|
)
|
||||||
long_whitespace = " "
|
long_whitespace = " "
|
||||||
expected_comment = "This is a loooooooooooooooooooooooooooong comment"
|
expected_comment = "This is a loooooooooooooooooooooooooooong comment"
|
||||||
comment = +"#{expected_comment}#{long_whitespace}\n"
|
comment = +"#{expected_comment}#{long_whitespace}\n"
|
||||||
@@ -301,11 +324,14 @@ class RepositoryTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_for_urls_strip_cvs
|
def test_for_urls_strip_cvs
|
||||||
repository = Repository::Cvs.create(
|
repository =
|
||||||
:project => Project.find(4),
|
Repository::Cvs.
|
||||||
:url => ' :pserver:login:password@host:/path/to/the/repository',
|
create(
|
||||||
:root_url => 'foo ',
|
:project => Project.find(4),
|
||||||
:log_encoding => 'UTF-8')
|
:url => ' :pserver:login:password@host:/path/to/the/repository',
|
||||||
|
:root_url => 'foo ',
|
||||||
|
:log_encoding => 'UTF-8'
|
||||||
|
)
|
||||||
assert repository.save
|
assert repository.save
|
||||||
repository.reload
|
repository.reload
|
||||||
assert_equal ':pserver:login:password@host:/path/to/the/repository',
|
assert_equal ':pserver:login:password@host:/path/to/the/repository',
|
||||||
@@ -314,18 +340,24 @@ class RepositoryTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_for_urls_strip_subversion
|
def test_for_urls_strip_subversion
|
||||||
repository = Repository::Subversion.create(
|
repository =
|
||||||
:project => Project.find(4),
|
Repository::Subversion.
|
||||||
:url => ' file:///dummy ')
|
create(
|
||||||
|
:project => Project.find(4),
|
||||||
|
:url => ' file:///dummy '
|
||||||
|
)
|
||||||
assert repository.save
|
assert repository.save
|
||||||
repository.reload
|
repository.reload
|
||||||
assert_equal 'file:///dummy', repository.url
|
assert_equal 'file:///dummy', repository.url
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_for_urls_strip_git
|
def test_for_urls_strip_git
|
||||||
repository = Repository::Git.create(
|
repository =
|
||||||
:project => Project.find(4),
|
Repository::Git.
|
||||||
:url => ' c:\dummy ')
|
create(
|
||||||
|
:project => Project.find(4),
|
||||||
|
:url => ' c:\dummy '
|
||||||
|
)
|
||||||
assert repository.save
|
assert repository.save
|
||||||
repository.reload
|
repository.reload
|
||||||
assert_equal 'c:\dummy', repository.url
|
assert_equal 'c:\dummy', repository.url
|
||||||
@@ -333,7 +365,8 @@ class RepositoryTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
def test_manual_user_mapping
|
def test_manual_user_mapping
|
||||||
assert_no_difference "Changeset.where('user_id <> 2').count" do
|
assert_no_difference "Changeset.where('user_id <> 2').count" do
|
||||||
c = Changeset.create!(
|
c = Changeset.
|
||||||
|
create!(
|
||||||
:repository => @repository,
|
:repository => @repository,
|
||||||
:committer => 'foo',
|
:committer => 'foo',
|
||||||
:committed_on => Time.now,
|
:committed_on => Time.now,
|
||||||
@@ -344,7 +377,8 @@ class RepositoryTest < ActiveSupport::TestCase
|
|||||||
@repository.committer_ids = {'foo' => '2'}
|
@repository.committer_ids = {'foo' => '2'}
|
||||||
assert_equal User.find(2), c.reload.user
|
assert_equal User.find(2), c.reload.user
|
||||||
# committer is now mapped
|
# committer is now mapped
|
||||||
c = Changeset.create!(
|
c = Changeset.
|
||||||
|
create!(
|
||||||
:repository => @repository,
|
:repository => @repository,
|
||||||
:committer => 'foo',
|
:committer => 'foo',
|
||||||
:committed_on => Time.now,
|
:committed_on => Time.now,
|
||||||
@@ -356,24 +390,26 @@ class RepositoryTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_auto_user_mapping_by_username
|
def test_auto_user_mapping_by_username
|
||||||
c = Changeset.create!(
|
c = Changeset.
|
||||||
:repository => @repository,
|
create!(
|
||||||
:committer => 'jsmith',
|
:repository => @repository,
|
||||||
:committed_on => Time.now,
|
:committer => 'jsmith',
|
||||||
:revision => 100,
|
:committed_on => Time.now,
|
||||||
:comments => 'Committed by john.'
|
:revision => 100,
|
||||||
)
|
:comments => 'Committed by john.'
|
||||||
|
)
|
||||||
assert_equal User.find(2), c.user
|
assert_equal User.find(2), c.user
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_auto_user_mapping_by_email
|
def test_auto_user_mapping_by_email
|
||||||
c = Changeset.create!(
|
c = Changeset.
|
||||||
:repository => @repository,
|
create!(
|
||||||
:committer => 'john <jsmith@somenet.foo>',
|
:repository => @repository,
|
||||||
:committed_on => Time.now,
|
:committer => 'john <jsmith@somenet.foo>',
|
||||||
:revision => 100,
|
:committed_on => Time.now,
|
||||||
:comments => 'Committed by john.'
|
:revision => 100,
|
||||||
)
|
:comments => 'Committed by john.'
|
||||||
|
)
|
||||||
assert_equal User.find(2), c.user
|
assert_equal User.find(2), c.user
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user