diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-06-05 12:51:59 +0200 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-06-05 12:51:59 +0200 |
commit | 79380fe5fb5943179960f4879e174eb977b918d3 (patch) | |
tree | 94953113c8bf5174cf52fb78d90e28a8c14c20c7 /spec/factories | |
parent | 3801a0df80306a76dc340ca74427a124a1514dbb (diff) | |
parent | c34107608ecc5c36e80a748eb4c9b88d2b1157cf (diff) | |
download | gitlab-ce-79380fe5fb5943179960f4879e174eb977b918d3.tar.gz |
Merge branch 'master' into feature/gb/persist-pipeline-stages
* master: (524 commits)
Improve user experience around slash commands in instant comments
Fix LFS timeouts when trying to save large files
retryable? is now available for CommitStatus
Resolve "Documentation of `.gitlab-ci.yml` states incorrect example for variables"
Fix test failures
Add slugify project path to CI enviroment variables
Fixed typo: craeted -> created
32118 Make New environment empty state btn lowercase
Expose import_status in Projects API
32832 Remove overflow from comment form for confidential issues and vertically aligns confidential issue icon
Fix test failures
Allow manual bypass of auto_sign_in_with_provider
Fix keys seed
Allow users to be hard-deleted from the API
fixup some classnames and media queries
Enable the Style/PreferredHashMethods cop
Lint our factories creation in addition to their build
Don’t schedule workers from inside transactions
Allow scheduling from after_commit hooks
Forbid Sidekiq scheduling in transactions
...
Conflicts:
app/serializers/pipeline_entity.rb
db/schema.rb
spec/factories/ci/stages.rb
spec/lib/gitlab/import_export/safe_model_attributes.yml
spec/services/ci/create_pipeline_service_spec.rb
spec/spec_helper.rb
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/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 | 14 | ||||
-rw-r--r-- | spec/factories/services.rb | 7 | ||||
-rw-r--r-- | spec/factories/web_hook_log.rb | 14 | ||||
-rw-r--r-- | spec/factories/wiki_directories.rb | 2 |
15 files changed, 106 insertions, 39 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 884661e1030..d3c8bf9d54f 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::LegacyStage 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/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 7a76f5f8afc..19a85e5a38f 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 # @@ -109,6 +111,18 @@ FactoryGirl.define do merge_requests_access_level: merge_requests_access_level, repository_access_level: evaluator.repository_access_level ) + + # Normally the class Projects::CreateService is used for creating + # projects, and this class takes care of making sure the owner and current + # user have access to the project. Our specs don't use said service class, + # thus we must manually refresh things here. + owner = project.owner + + if owner && owner.is_a?(User) && !project.pending_delete + project.members.create!(user: owner, access_level: Gitlab::Access::MASTER) + end + + project.group&.refresh_members_authorized_projects end end diff --git a/spec/factories/services.rb b/spec/factories/services.rb index 28ddd0da753..e7366a7fd1c 100644 --- a/spec/factories/services.rb +++ b/spec/factories/services.rb @@ -20,7 +20,6 @@ FactoryGirl.define do project factory: :empty_project active true properties({ - namespace: 'somepath', api_url: 'https://kubernetes.example.com', token: 'a' * 40 }) @@ -34,4 +33,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/web_hook_log.rb b/spec/factories/web_hook_log.rb new file mode 100644 index 00000000000..230b3f6b26e --- /dev/null +++ b/spec/factories/web_hook_log.rb @@ -0,0 +1,14 @@ +FactoryGirl.define do + factory :web_hook_log do + web_hook factory: :project_hook + trigger 'push_hooks' + url { generate(:url) } + request_headers {} + request_data {} + response_headers {} + response_body '' + response_status '200' + execution_duration 2.0 + internal_error_message nil + 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 |