summaryrefslogtreecommitdiff
path: root/spec/factories/suggestions.rb
blob: 420c59df40e59f19a4f055cc64230b5e5c39cbaa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# frozen_string_literal: true

FactoryBot.define do
  factory :suggestion do
    relative_order { 0 }
    association :note, factory: :diff_note_on_merge_request
    from_content { "    vars = {\n" }
    to_content { "    vars = [\n" }

    trait :unappliable do
      from_content { "foo" }
      to_content { "foo" }
    end

    trait :applied do
      applied { true }
      commit_id { RepoHelpers.sample_commit.id }
    end

    trait :content_from_repo do
      after(:build) do |suggestion, evaluator|
        suggestion.from_content = suggestion.fetch_from_content
      end
    end
  end
end