refactor wiki commit logic into Gollum::Committer class
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
require File.expand_path(File.join(File.dirname(__FILE__), "helper"))
|
||||
|
||||
context "Wiki" do
|
||||
setup do
|
||||
@wiki = Gollum::Wiki.new(testpath("examples/lotr.git"))
|
||||
end
|
||||
|
||||
test "normalizes commit hash" do
|
||||
commit = {:message => 'abc'}
|
||||
name = @wiki.repo.config['user.name']
|
||||
email = @wiki.repo.config['user.email']
|
||||
committer = Gollum::Committer.new(@wiki, commit)
|
||||
assert_equal name, committer.actor.name
|
||||
assert_equal email, committer.actor.email
|
||||
|
||||
commit[:name] = 'bob'
|
||||
commit[:email] = ''
|
||||
committer = Gollum::Committer.new(@wiki, commit)
|
||||
assert_equal 'bob', committer.actor.name
|
||||
assert_equal email, committer.actor.email
|
||||
|
||||
commit[:email] = 'foo@bar.com'
|
||||
committer = Gollum::Committer.new(@wiki, commit)
|
||||
assert_equal 'bob', committer.actor.name
|
||||
assert_equal 'foo@bar.com', committer.actor.email
|
||||
end
|
||||
end
|
||||
@@ -44,23 +44,6 @@ context "Wiki" do
|
||||
assert_equal 4, @wiki.size
|
||||
end
|
||||
|
||||
test "normalizes commit hash" do
|
||||
commit = {:message => 'abc'}
|
||||
name = @wiki.repo.config['user.name']
|
||||
email = @wiki.repo.config['user.email']
|
||||
assert_equal({:message => 'abc', :name => name, :email => email},
|
||||
@wiki.normalize_commit(commit.dup))
|
||||
|
||||
commit[:name] = 'bob'
|
||||
commit[:email] = ''
|
||||
assert_equal({:message => 'abc', :name => 'bob', :email => email},
|
||||
@wiki.normalize_commit(commit.dup))
|
||||
|
||||
commit[:email] = 'foo@bar.com'
|
||||
assert_equal({:message => 'abc', :name => 'bob', :email => 'foo@bar.com'},
|
||||
@wiki.normalize_commit(commit.dup))
|
||||
end
|
||||
|
||||
test "text_data" do
|
||||
wiki = Gollum::Wiki.new(testpath("examples/yubiwa.git"))
|
||||
if String.instance_methods.include?(:encoding)
|
||||
|
||||
Reference in New Issue
Block a user