diff options
author | Pawel Chojnacki <pawel@chojnacki.ws> | 2017-06-07 11:27:52 +0300 |
---|---|---|
committer | Pawel Chojnacki <pawel@chojnacki.ws> | 2017-06-07 11:27:52 +0300 |
commit | dbb3c28088b63c8cf40a90c599b6eedb4dfbbb66 (patch) | |
tree | 9e6c4d495e45355ef62c56c0c3e102f95220f89f /spec/factories | |
parent | a924152219c1367bf494f3f387d050ac3ff2d7d3 (diff) | |
parent | dddc54aa0aea4088e5a233d18a62cb2435590fe9 (diff) |
Merge remote-tracking branch 'upstream/master' into 28717-additional-metrics-review-branch
# Conflicts:
# app/models/project_services/prometheus_service.rb
# app/views/projects/services/_form.html.haml
Diffstat (limited to 'spec/factories')
-rw-r--r-- | spec/factories/ci/builds.rb | 3 | ||||
-rw-r--r-- | spec/factories/ci/pipelines.rb | 22 | ||||
-rw-r--r-- | spec/factories/ci/stages.rb | 2 | ||||
-rw-r--r-- | spec/factories/ci/trigger_requests.rb | 4 | ||||
-rw-r--r-- | spec/factories/ci/variables.rb | 4 | ||||
-rw-r--r-- | spec/factories/commits.rb | 9 | ||||
-rw-r--r-- | spec/factories/conversational_development_index_metrics.rb | 33 | ||||
-rw-r--r-- | spec/factories/file_uploaders.rb (renamed from spec/factories/file_uploader.rb) | 2 | ||||
-rw-r--r-- | spec/factories/forked_project_links.rb | 4 | ||||
-rw-r--r-- | spec/factories/keys.rb | 19 | ||||
-rw-r--r-- | spec/factories/project_statistics.rb | 8 | ||||
-rw-r--r-- | spec/factories/project_wikis.rb | 2 | ||||
-rw-r--r-- | spec/factories/projects.rb | 18 | ||||
-rw-r--r-- | spec/factories/services.rb | 6 | ||||
-rw-r--r-- | spec/factories/wiki_directories.rb | 2 |
15 files changed, 100 insertions, 38 deletions
diff --git a/spec/factories/ci/builds.rb b/spec/factories/ci/builds.rb index f5e99fdf00b..0bb5a86d9b9 100644 --- a/spec/factories/ci/builds.rb +++ b/spec/factories/ci/builds.rb @@ -64,7 +64,8 @@ FactoryGirl.define do trait :teardown_environment do environment 'staging' options environment: { name: 'staging', - action: 'stop' } + action: 'stop', + url: 'http://staging.example.com/$CI_JOB_NAME' } end trait :allowed_to_fail do diff --git a/spec/factories/ci/pipelines.rb b/spec/factories/ci/pipelines.rb index 361c5b9a49e..35803f0c37f 100644 --- a/spec/factories/ci/pipelines.rb +++ b/spec/factories/ci/pipelines.rb @@ -1,5 +1,6 @@ FactoryGirl.define do factory :ci_empty_pipeline, class: Ci::Pipeline do + source :push ref 'master' sha '97de212e80737a608d939f648d959671fb0a0142' status 'pending' @@ -8,14 +9,14 @@ FactoryGirl.define do factory :ci_pipeline_without_jobs do after(:build) do |pipeline| - allow(pipeline).to receive(:ci_yaml_file) { YAML.dump({}) } + pipeline.instance_variable_set(:@ci_yaml_file, YAML.dump({})) end end factory :ci_pipeline_with_one_job do after(:build) do |pipeline| allow(pipeline).to receive(:ci_yaml_file) do - YAML.dump({ rspec: { script: "ls" } }) + pipeline.instance_variable_set(:@ci_yaml_file, YAML.dump({ rspec: { script: "ls" } })) end end end @@ -33,17 +34,14 @@ FactoryGirl.define do transient { config nil } after(:build) do |pipeline, evaluator| - allow(pipeline).to receive(:ci_yaml_file) do - if evaluator.config - YAML.dump(evaluator.config) - else - File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml')) - end - end + if evaluator.config + pipeline.instance_variable_set(:@ci_yaml_file, YAML.dump(evaluator.config)) - # Populates pipeline with errors - # - pipeline.config_processor if evaluator.config + # Populates pipeline with errors + pipeline.config_processor if evaluator.config + else + pipeline.instance_variable_set(:@ci_yaml_file, File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml'))) + end end trait :invalid do diff --git a/spec/factories/ci/stages.rb b/spec/factories/ci/stages.rb index 7f557b25ccb..d37eabb3e8c 100644 --- a/spec/factories/ci/stages.rb +++ b/spec/factories/ci/stages.rb @@ -1,5 +1,7 @@ FactoryGirl.define do factory :ci_stage, class: Ci::Stage do + skip_create + transient do name 'test' status nil diff --git a/spec/factories/ci/trigger_requests.rb b/spec/factories/ci/trigger_requests.rb index b8d8fab0e0b..10e0ab4fd3c 100644 --- a/spec/factories/ci/trigger_requests.rb +++ b/spec/factories/ci/trigger_requests.rb @@ -1,8 +1,8 @@ FactoryGirl.define do factory :ci_trigger_request, class: Ci::TriggerRequest do - factory :ci_trigger_request_with_variables do - trigger factory: :ci_trigger + trigger factory: :ci_trigger + factory :ci_trigger_request_with_variables do variables do { TRIGGER_KEY_1: 'TRIGGER_VALUE_1', diff --git a/spec/factories/ci/variables.rb b/spec/factories/ci/variables.rb index c5fba597c1c..f83366136fd 100644 --- a/spec/factories/ci/variables.rb +++ b/spec/factories/ci/variables.rb @@ -3,6 +3,10 @@ FactoryGirl.define do sequence(:key) { |n| "VARIABLE_#{n}" } value 'VARIABLE_VALUE' + trait(:protected) do + protected true + end + project factory: :empty_project end end diff --git a/spec/factories/commits.rb b/spec/factories/commits.rb index 89e260cf65b..36b9645438a 100644 --- a/spec/factories/commits.rb +++ b/spec/factories/commits.rb @@ -4,19 +4,14 @@ FactoryGirl.define do factory :commit do git_commit RepoHelpers.sample_commit project factory: :empty_project + author { build(:author) } initialize_with do new(git_commit, project) end - after(:build) do |commit| - allow(commit).to receive(:author).and_return build(:author) - end - trait :without_author do - after(:build) do |commit| - allow(commit).to receive(:author).and_return nil - end + author nil end end end diff --git a/spec/factories/conversational_development_index_metrics.rb b/spec/factories/conversational_development_index_metrics.rb new file mode 100644 index 00000000000..a5412629195 --- /dev/null +++ b/spec/factories/conversational_development_index_metrics.rb @@ -0,0 +1,33 @@ +FactoryGirl.define do + factory :conversational_development_index_metric, class: ConversationalDevelopmentIndex::Metric do + leader_issues 9.256 + instance_issues 1.234 + + leader_notes 30.33333 + instance_notes 28.123 + + leader_milestones 16.2456 + instance_milestones 1.234 + + leader_boards 5.2123 + instance_boards 3.254 + + leader_merge_requests 1.2 + instance_merge_requests 0.6 + + leader_ci_pipelines 12.1234 + instance_ci_pipelines 2.344 + + leader_environments 3.3333 + instance_environments 2.2222 + + leader_deployments 1.200 + instance_deployments 0.771 + + leader_projects_prometheus_active 0.111 + instance_projects_prometheus_active 0.109 + + leader_service_desk_issues 15.891 + instance_service_desk_issues 13.345 + end +end diff --git a/spec/factories/file_uploader.rb b/spec/factories/file_uploaders.rb index bc74aeecc3b..d397dd705a5 100644 --- a/spec/factories/file_uploader.rb +++ b/spec/factories/file_uploaders.rb @@ -1,5 +1,7 @@ FactoryGirl.define do factory :file_uploader do + skip_create + project factory: :empty_project secret nil diff --git a/spec/factories/forked_project_links.rb b/spec/factories/forked_project_links.rb index b16c1272e68..66b0f248959 100644 --- a/spec/factories/forked_project_links.rb +++ b/spec/factories/forked_project_links.rb @@ -7,5 +7,9 @@ FactoryGirl.define do link.forked_from_project.reload link.forked_to_project.reload end + + trait :forked_to_empty_project do + association :forked_to_project, factory: :empty_project + end end end diff --git a/spec/factories/keys.rb b/spec/factories/keys.rb index 4e140102492..a13b6e3596e 100644 --- a/spec/factories/keys.rb +++ b/spec/factories/keys.rb @@ -1,27 +1,18 @@ +require_relative '../support/helpers/key_generator_helper' + FactoryGirl.define do factory :key do title - key do - 'ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0= dummy@gitlab.com' - end + key { Spec::Support::Helpers::KeyGeneratorHelper.new(1024).generate + ' dummy@gitlab.com' } - factory :deploy_key, class: 'DeployKey' do - key do - 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDFf6RYK3qu/RKF/3ndJmL5xgMLp3O96x8lTay+QGZ0+9FnnAXMdUqBq/ZU6d/gyMB4IaW3nHzM1w049++yAB6UPCzMB8Uo27K5/jyZCtj7Vm9PFNjF/8am1kp46c/SeYicQgQaSBdzIW3UDEa1Ef68qroOlvpi9PYZ/tA7M0YP0K5PXX+E36zaIRnJVMPT3f2k+GnrxtjafZrwFdpOP/Fol5BQLBgcsyiU+LM1SuaCrzd8c9vyaTA1CxrkxaZh+buAi0PmdDtaDrHd42gqZkXCKavyvgM5o2CkQ5LJHCgzpXy05qNFzmThBSkb+XtoxbyagBiGbVZtSVow6Xa7qewz' - end - end + factory :deploy_key, class: 'DeployKey' factory :personal_key do user end factory :another_key do - key do - 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDmTillFzNTrrGgwaCKaSj+QCz81E6jBc/s9av0+3b1Hwfxgkqjl4nAK/OD2NjgyrONDTDfR8cRN4eAAy6nY8GLkOyYBDyuc5nTMqs5z3yVuTwf3koGm/YQQCmo91psZ2BgDFTor8SVEE5Mm1D1k3JDMhDFxzzrOtRYFPci9lskTJaBjpqWZ4E9rDTD2q/QZntCqbC3wE9uSemRQB5f8kik7vD/AD8VQXuzKladrZKkzkONCPWsXDspUitjM8HkQdOf0PsYn1CMUC1xKYbCxkg5TkEosIwGv6CoEArUrdu/4+10LVslq494mAvEItywzrluCLCnwELfW+h/m8UHoVhZ' - end - - factory :another_deploy_key, class: 'DeployKey' do - end + factory :another_deploy_key, class: 'DeployKey' end factory :write_access_key, class: 'DeployKey' do diff --git a/spec/factories/project_statistics.rb b/spec/factories/project_statistics.rb index 72d43096216..6c2ed7c6581 100644 --- a/spec/factories/project_statistics.rb +++ b/spec/factories/project_statistics.rb @@ -1,6 +1,10 @@ FactoryGirl.define do factory :project_statistics do - project { create :project } - namespace { project.namespace } + project + + initialize_with do + # statistics are automatically created when a project is created + project&.statistics || new + end end end diff --git a/spec/factories/project_wikis.rb b/spec/factories/project_wikis.rb index a3403fd76ae..ae222d5e69a 100644 --- a/spec/factories/project_wikis.rb +++ b/spec/factories/project_wikis.rb @@ -1,5 +1,7 @@ FactoryGirl.define do factory :project_wiki do + skip_create + project factory: :empty_project user factory: :user initialize_with { new(project, user) } diff --git a/spec/factories/projects.rb b/spec/factories/projects.rb index e8a9b688319..e17e50db143 100644 --- a/spec/factories/projects.rb +++ b/spec/factories/projects.rb @@ -1,3 +1,5 @@ +require_relative '../support/test_env' + FactoryGirl.define do # Project without repository # @@ -24,6 +26,22 @@ FactoryGirl.define do visibility_level Gitlab::VisibilityLevel::PRIVATE end + trait :import_scheduled do + import_status :scheduled + end + + trait :import_started do + import_status :started + end + + trait :import_finished do + import_status :finished + end + + trait :import_failed do + import_status :failed + end + trait :archived do archived true end diff --git a/spec/factories/services.rb b/spec/factories/services.rb index 412dd82c929..30bc25cf88a 100644 --- a/spec/factories/services.rb +++ b/spec/factories/services.rb @@ -41,4 +41,10 @@ FactoryGirl.define do project_key: 'jira-key' ) end + + factory :hipchat_service do + project factory: :empty_project + type 'HipchatService' + token 'test_token' + end end diff --git a/spec/factories/wiki_directories.rb b/spec/factories/wiki_directories.rb index 3f3c864ac2b..3b4cfc380b8 100644 --- a/spec/factories/wiki_directories.rb +++ b/spec/factories/wiki_directories.rb @@ -1,5 +1,7 @@ FactoryGirl.define do factory :wiki_directory do + skip_create + slug '/path_up_to/dir' initialize_with { new(slug) } end |