2018-03-29 09:47:54 +00:00
|
|
|
require_relative '../support/helpers/repo_helpers'
|
2016-04-13 09:25:42 +00:00
|
|
|
|
2017-12-14 00:13:44 +00:00
|
|
|
FactoryBot.define do
|
2016-04-13 09:25:42 +00:00
|
|
|
factory :commit do
|
2017-11-18 14:06:55 +00:00
|
|
|
transient do
|
|
|
|
author nil
|
|
|
|
end
|
|
|
|
|
|
|
|
git_commit do
|
|
|
|
commit = RepoHelpers.sample_commit
|
|
|
|
|
|
|
|
if author
|
|
|
|
commit.author_email = author.email
|
|
|
|
commit.author_name = author.name
|
|
|
|
end
|
|
|
|
|
|
|
|
commit
|
|
|
|
end
|
2019-02-06 12:33:11 +00:00
|
|
|
|
2017-08-02 19:55:11 +00:00
|
|
|
project
|
2016-04-13 09:25:42 +00:00
|
|
|
|
2019-02-06 12:33:11 +00:00
|
|
|
skip_create # Commits cannot be persisted
|
|
|
|
|
2016-04-13 09:25:42 +00:00
|
|
|
initialize_with do
|
|
|
|
new(git_commit, project)
|
|
|
|
end
|
2017-01-18 10:38:59 +00:00
|
|
|
|
2017-11-18 14:06:55 +00:00
|
|
|
after(:build) do |commit, evaluator|
|
2017-08-04 17:14:04 +00:00
|
|
|
allow(commit).to receive(:author).and_return(evaluator.author || build_stubbed(:author))
|
2019-02-06 12:33:11 +00:00
|
|
|
allow(commit).to receive(:parent_ids).and_return([])
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :merge_commit do
|
|
|
|
after(:build) do |commit|
|
|
|
|
allow(commit).to receive(:parent_ids).and_return(Array.new(2) { SecureRandom.hex(20) })
|
|
|
|
end
|
2017-07-17 19:26:41 +00:00
|
|
|
end
|
|
|
|
|
2017-01-18 10:38:59 +00:00
|
|
|
trait :without_author do
|
2017-07-17 19:26:41 +00:00
|
|
|
after(:build) do |commit|
|
|
|
|
allow(commit).to receive(:author).and_return nil
|
|
|
|
end
|
2017-01-18 10:38:59 +00:00
|
|
|
end
|
2016-04-13 09:25:42 +00:00
|
|
|
end
|
|
|
|
end
|