Skip to content
Browse files

Allow nil commit author and message

It should fix [#132].
  • Loading branch information...
1 parent b8b8cb8 commit 1e116a04a6e9f4320a6e9c813fa05902e0348fc7 @sr sr committed Apr 5, 2009
Showing with 11 additions and 7 deletions.
  1. +2 −1 lib/integrity/commit.rb
  2. +2 −2 lib/integrity/migrations.rb
  3. +4 −0 test/unit/commit_test.rb
  4. +3 −4 test/unit/project_test.rb
View
3 lib/integrity/commit.rb
@@ -21,7 +21,8 @@ def message
end
def author
- attribute_get(:author) || Author.load('<Commit author not loaded> <<Commit author not loaded>>', :author)
+ attribute_get(:author) ||
+ Author.load('<Commit author not loaded> <<Commit author not loaded>>', :author)
end
def short_identifier
View
4 lib/integrity/migrations.rb
@@ -84,8 +84,8 @@ class ::Integrity::Build
create_table :integrity_commits do
column :id, Integer, :serial => true
column :identifier, String, :nullable => false
- column :message, String, :nullable => false, :length => 255
- column :author, String, :nullable => false, :length => 255
+ column :message, String, :nullable => true, :length => 255
+ column :author, String, :nullable => true, :length => 255
column :committed_at, DateTime, :nullable => false
column :created_at, DateTime
column :updated_at, DateTime
View
4 test/unit/commit_test.rb
@@ -32,6 +32,8 @@ class CommitTest < Test::Unit::TestCase
commit.author.name.should == "Nicolás Sanguinetti"
commit.author.email.should == "contacto@nicolassanguinetti.info"
commit.author.full.should == "Nicolás Sanguinetti <contacto@nicolassanguinetti.info>"
+
+ Commit.gen(:author => nil).author.to_s.should =~ /not loaded/
end
it "raises ArgumentError with invalid author" do
@@ -41,6 +43,8 @@ class CommitTest < Test::Unit::TestCase
it "has a commit message" do
commit = Commit.gen(:message => "This commit rocks")
commit.message.should == "This commit rocks"
+
+ Commit.gen(:message => nil).message.should =~ /not loaded/
end
it "has a commit date" do
View
7 test/unit/project_test.rb
@@ -352,13 +352,12 @@ class ProjectTest < Test::Unit::TestCase
}.should change(Commit, :count).by(1)
build = Build.all.last
- build.commit.should be(@project.last_commit)
+ build.commit.should == @project.last_commit
@project.last_commit.should be_pending
- @project.last_commit.identifier.should be("FOOBAR")
-
+ @project.last_commit.identifier.should == "FOOBAR"
@project.last_commit.author.name.should == "<Commit author not loaded>"
- @project.last_commit.message.should == "<Commit message not loaded>"
+ @project.last_commit.message.should == "<Commit message not loaded>"
end
end
end

0 comments on commit 1e116a0

Please sign in to comment.
Something went wrong with that request. Please try again.