Commit f0c852a1 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Merge branch '9079-extract-the-ee-specific-codes-in-spec-factories-notes-rb' into 'master'

Extract the EE specific codes in spec/factories/notes.rb

Closes #9079

See merge request gitlab-org/gitlab-ee!9269
parents 3c397105 fd994b66
...@@ -831,6 +831,29 @@ should remain working as-is when EE is running without a license. ...@@ -831,6 +831,29 @@ should remain working as-is when EE is running without a license.
Instead place EE specs in the `ee/spec` folder. Instead place EE specs in the `ee/spec` folder.
### Code in `spec/factories`
Use `FactoryBot.modify` to extend factories already defined in CE.
Note that you cannot define new factories (even nested ones) inside the `FactoryBot.modify` block. You can do so in a
separate `FactoryBot.define` block as shown in the example below:
```ruby
# ee/spec/factories/notes.rb
FactoryBot.modify do
factory :note do
trait :on_epic do
noteable { create(:epic) }
project nil
end
end
end
FactoryBot.define do
factory :note_on_epic, parent: :note, traits: [:on_epic]
end
```
## JavaScript code in `assets/javascripts/` ## JavaScript code in `assets/javascripts/`
To separate EE-specific JS-files we should also move the files into an `ee` folder. To separate EE-specific JS-files we should also move the files into an `ee` folder.
......
# frozen_string_literal: true
FactoryBot.modify do
factory :note do
trait :on_epic do
noteable { create(:epic) }
project nil
end
end
end
FactoryBot.define do
factory :note_on_epic, parent: :note, traits: [:on_epic]
end
...@@ -14,7 +14,6 @@ FactoryBot.define do ...@@ -14,7 +14,6 @@ FactoryBot.define do
factory :note_on_merge_request, traits: [:on_merge_request] factory :note_on_merge_request, traits: [:on_merge_request]
factory :note_on_project_snippet, traits: [:on_project_snippet] factory :note_on_project_snippet, traits: [:on_project_snippet]
factory :note_on_personal_snippet, traits: [:on_personal_snippet] factory :note_on_personal_snippet, traits: [:on_personal_snippet]
factory :note_on_epic, traits: [:on_epic]
factory :system_note, traits: [:system] factory :system_note, traits: [:system]
factory :discussion_note, class: DiscussionNote factory :discussion_note, class: DiscussionNote
...@@ -134,11 +133,6 @@ FactoryBot.define do ...@@ -134,11 +133,6 @@ FactoryBot.define do
project nil project nil
end end
trait :on_epic do
noteable { create(:epic) }
project nil
end
trait :system do trait :system do
system true system true
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment