16ceae895e
* Move is_assigned? and is_being_xx? methods to IssueCommonality This is behavior merge requests have in common with issues. Moved methods to IssueCommonality role. Put specs directly into merge_request_spec because setup differs for issues and MRs specifically in the "closed" factory to use. * Add MergeRequestObserver. Parallels IssueObserver in almost every way. Ripe for refactoring. * Rename MailerObserver to NoteObserver With merge request observing moved out of MailerObserver, all that was left was Note logic. Renamed to NoteObserver, added tests and updated application config for new observer names. Refactored NoteObserver to use the note's author and not rely on current_user. * Set current_user for MergeRequestObserver IssueObserver and MergeRequestObserver are the only observers that need a reference to the current_user that they cannot look up on the objects they are observing.
153 lines
2.7 KiB
Ruby
153 lines
2.7 KiB
Ruby
# Backwards compatibility with the old method
|
|
def Factory(type, *args)
|
|
FactoryGirl.create(type, *args)
|
|
end
|
|
|
|
module Factory
|
|
def self.create(type, *args)
|
|
FactoryGirl.create(type, *args)
|
|
end
|
|
|
|
def self.new(type, *args)
|
|
FactoryGirl.build(type, *args)
|
|
end
|
|
def self.attributes(type, *args)
|
|
FactoryGirl.attributes_for(type, *args)
|
|
end
|
|
end
|
|
|
|
FactoryGirl.define do
|
|
sequence :sentence, aliases: [:title, :content] do
|
|
Faker::Lorem.sentence
|
|
end
|
|
|
|
sequence :name, aliases: [:file_name] do
|
|
Faker::Name.name
|
|
end
|
|
|
|
sequence(:url) { Faker::Internet.uri('http') }
|
|
|
|
factory :user, aliases: [:author, :assignee, :owner] do
|
|
email { Faker::Internet.email }
|
|
name
|
|
password "123456"
|
|
password_confirmation { password }
|
|
|
|
trait :admin do
|
|
admin true
|
|
end
|
|
|
|
factory :admin, traits: [:admin]
|
|
end
|
|
|
|
factory :project do
|
|
sequence(:name) { |n| "project#{n}" }
|
|
path { name.downcase.gsub(/\s/, '_') }
|
|
code { name.downcase.gsub(/\s/, '_') }
|
|
owner
|
|
end
|
|
|
|
factory :group do
|
|
sequence(:name) { |n| "group#{n}" }
|
|
code { name.downcase.gsub(/\s/, '_') }
|
|
owner
|
|
end
|
|
|
|
factory :users_project do
|
|
user
|
|
project
|
|
end
|
|
|
|
factory :issue do
|
|
title
|
|
author
|
|
project
|
|
|
|
trait :closed do
|
|
closed true
|
|
end
|
|
|
|
factory :closed_issue, traits: [:closed]
|
|
end
|
|
|
|
factory :merge_request do
|
|
title
|
|
author
|
|
project
|
|
source_branch "master"
|
|
target_branch "stable"
|
|
|
|
trait :closed do
|
|
closed true
|
|
end
|
|
|
|
factory :closed_merge_request, traits: [:closed]
|
|
end
|
|
|
|
factory :note do
|
|
project
|
|
note "Note"
|
|
end
|
|
|
|
factory :event do
|
|
factory :closed_issue_event do
|
|
project
|
|
action Event::Closed
|
|
target factory: :closed_issue
|
|
author factory: :user
|
|
end
|
|
end
|
|
|
|
factory :key do
|
|
title
|
|
key do
|
|
"ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0="
|
|
end
|
|
|
|
factory :deploy_key do
|
|
project
|
|
end
|
|
|
|
factory :personal_key do
|
|
user
|
|
end
|
|
|
|
factory :key_with_a_space_in_the_middle do
|
|
key do
|
|
"ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa ++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0="
|
|
end
|
|
end
|
|
end
|
|
|
|
factory :milestone do
|
|
title
|
|
project
|
|
end
|
|
|
|
factory :system_hook do
|
|
url
|
|
end
|
|
|
|
factory :project_hook do
|
|
url
|
|
end
|
|
|
|
factory :wiki do
|
|
title
|
|
content
|
|
user
|
|
end
|
|
|
|
factory :snippet do
|
|
project
|
|
author
|
|
title
|
|
content
|
|
file_name
|
|
end
|
|
|
|
factory :protected_branch do
|
|
name
|
|
project
|
|
end
|
|
end
|