2019-07-25 01:11:48 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-29 05:47:54 -04:00
|
|
|
require_relative '../support/helpers/repo_helpers'
|
2016-04-13 05:25:42 -04:00
|
|
|
|
2017-12-13 19:13:44 -05:00
|
|
|
FactoryBot.define do
|
2016-04-13 05:25:42 -04:00
|
|
|
factory :commit do
|
2017-11-18 09:06:55 -05: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 07:33:11 -05:00
|
|
|
|
2017-08-02 15:55:11 -04:00
|
|
|
project
|
2016-04-13 05:25:42 -04:00
|
|
|
|
2019-02-06 07:33:11 -05:00
|
|
|
skip_create # Commits cannot be persisted
|
|
|
|
|
2016-04-13 05:25:42 -04:00
|
|
|
initialize_with do
|
|
|
|
new(git_commit, project)
|
|
|
|
end
|
2017-01-18 05:38:59 -05:00
|
|
|
|
2017-11-18 09:06:55 -05:00
|
|
|
after(:build) do |commit, evaluator|
|
2017-08-04 13:14:04 -04:00
|
|
|
allow(commit).to receive(:author).and_return(evaluator.author || build_stubbed(:author))
|
2019-02-06 07:33:11 -05: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 15:26:41 -04:00
|
|
|
end
|
|
|
|
|
2017-01-18 05:38:59 -05:00
|
|
|
trait :without_author do
|
2017-07-17 15:26:41 -04:00
|
|
|
after(:build) do |commit|
|
|
|
|
allow(commit).to receive(:author).and_return nil
|
|
|
|
end
|
2017-01-18 05:38:59 -05:00
|
|
|
end
|
2016-04-13 05:25:42 -04:00
|
|
|
end
|
|
|
|
end
|