debian-mirror-gitlab/spec/factories/commits.rb

36 lines
696 B
Ruby
Raw Normal View History

2018-10-15 14:42:47 +05:30
require_relative '../support/helpers/repo_helpers'
2016-06-02 11:05:42 +05:30
2018-03-17 18:26:18 +05:30
FactoryBot.define do
2016-06-02 11:05:42 +05:30
factory :commit do
2018-03-17 18:26:18 +05:30
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
2017-09-10 17:25:29 +05:30
project
2016-06-02 11:05:42 +05:30
initialize_with do
new(git_commit, project)
end
2017-08-17 22:00:37 +05:30
2018-03-17 18:26:18 +05:30
after(:build) do |commit, evaluator|
allow(commit).to receive(:author).and_return(evaluator.author || build_stubbed(:author))
2017-08-17 22:00:37 +05:30
end
trait :without_author do
after(:build) do |commit|
allow(commit).to receive(:author).and_return nil
end
end
2016-06-02 11:05:42 +05:30
end
end