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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

49 lines
983 B
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
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
2019-12-21 20:55:43 +05:30
author { nil }
2018-03-17 18:26:18 +05:30
end
git_commit do
commit = RepoHelpers.sample_commit
if author
commit.author_email = author.email
commit.author_name = author.name
end
commit
end
2019-03-02 22:35:43 +05:30
2017-09-10 17:25:29 +05:30
project
2016-06-02 11:05:42 +05:30
2019-03-02 22:35:43 +05:30
skip_create # Commits cannot be persisted
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|
2022-07-23 23:45:48 +05:30
author = evaluator.author || build_stubbed(:author)
stub_method(commit, :author) { author }
stub_method(commit, :parent_ids) { [] }
2019-03-02 22:35:43 +05:30
end
trait :merge_commit do
after(:build) do |commit|
2022-07-23 23:45:48 +05:30
stub_method(commit, :parent_ids) { Array.new(2) { SecureRandom.hex(20) } }
2019-03-02 22:35:43 +05:30
end
2017-08-17 22:00:37 +05:30
end
trait :without_author do
after(:build) do |commit|
2022-07-23 23:45:48 +05:30
stub_method(commit, :author) { nil }
2017-08-17 22:00:37 +05:30
end
end
2016-06-02 11:05:42 +05:30
end
end