Skip to content

Commit

Permalink
Allow nil commit author and message
Browse files Browse the repository at this point in the history
It should fix [integrity#132].
  • Loading branch information
sr committed Apr 5, 2009
1 parent b8b8cb8 commit 1e116a0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
3 changes: 2 additions & 1 deletion lib/integrity/commit.rb
Expand Up @@ -21,7 +21,8 @@ def message
end end


def author 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 end


def short_identifier def short_identifier
Expand Down
4 changes: 2 additions & 2 deletions lib/integrity/migrations.rb
Expand Up @@ -84,8 +84,8 @@ class ::Integrity::Build
create_table :integrity_commits do create_table :integrity_commits do
column :id, Integer, :serial => true column :id, Integer, :serial => true
column :identifier, String, :nullable => false column :identifier, String, :nullable => false
column :message, String, :nullable => false, :length => 255 column :message, String, :nullable => true, :length => 255
column :author, String, :nullable => false, :length => 255 column :author, String, :nullable => true, :length => 255
column :committed_at, DateTime, :nullable => false column :committed_at, DateTime, :nullable => false
column :created_at, DateTime column :created_at, DateTime
column :updated_at, DateTime column :updated_at, DateTime
Expand Down
4 changes: 4 additions & 0 deletions test/unit/commit_test.rb
Expand Up @@ -32,6 +32,8 @@ class CommitTest < Test::Unit::TestCase
commit.author.name.should == "Nicolás Sanguinetti" commit.author.name.should == "Nicolás Sanguinetti"
commit.author.email.should == "contacto@nicolassanguinetti.info" commit.author.email.should == "contacto@nicolassanguinetti.info"
commit.author.full.should == "Nicolás Sanguinetti <contacto@nicolassanguinetti.info>" commit.author.full.should == "Nicolás Sanguinetti <contacto@nicolassanguinetti.info>"

Commit.gen(:author => nil).author.to_s.should =~ /not loaded/
end end


it "raises ArgumentError with invalid author" do it "raises ArgumentError with invalid author" do
Expand All @@ -41,6 +43,8 @@ class CommitTest < Test::Unit::TestCase
it "has a commit message" do it "has a commit message" do
commit = Commit.gen(:message => "This commit rocks") commit = Commit.gen(:message => "This commit rocks")
commit.message.should == "This commit rocks" commit.message.should == "This commit rocks"

Commit.gen(:message => nil).message.should =~ /not loaded/
end end


it "has a commit date" do it "has a commit date" do
Expand Down
7 changes: 3 additions & 4 deletions test/unit/project_test.rb
Expand Up @@ -352,13 +352,12 @@ class ProjectTest < Test::Unit::TestCase
}.should change(Commit, :count).by(1) }.should change(Commit, :count).by(1)


build = Build.all.last 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.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.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 end
end end

0 comments on commit 1e116a0

Please sign in to comment.