diff --git a/lib/integrity/commit.rb b/lib/integrity/commit.rb index 29b44d2c..c8700650 100644 --- a/lib/integrity/commit.rb +++ b/lib/integrity/commit.rb @@ -21,7 +21,8 @@ def message end def author - attribute_get(:author) || Author.load(' <>', :author) + attribute_get(:author) || + Author.load(' <>', :author) end def short_identifier diff --git a/lib/integrity/migrations.rb b/lib/integrity/migrations.rb index 2f544f69..720030c0 100644 --- a/lib/integrity/migrations.rb +++ b/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 diff --git a/test/unit/commit_test.rb b/test/unit/commit_test.rb index 4b25886a..ca227571 100644 --- a/test/unit/commit_test.rb +++ b/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 " + + 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 diff --git a/test/unit/project_test.rb b/test/unit/project_test.rb index feb5f539..b464895e 100644 --- a/test/unit/project_test.rb +++ b/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 == "" - @project.last_commit.message.should == "" + @project.last_commit.message.should == "" end end end