summaryrefslogtreecommitdiff
path: root/spec/ci/factories
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ci/factories')
-rw-r--r--spec/ci/factories/builds.rb45
-rw-r--r--spec/ci/factories/commits.rb75
-rw-r--r--spec/ci/factories/events.rb24
-rw-r--r--spec/ci/factories/projects.rb56
-rw-r--r--spec/ci/factories/runner_projects.rb19
-rw-r--r--spec/ci/factories/runners.rb38
-rw-r--r--spec/ci/factories/trigger_requests.rb13
-rw-r--r--spec/ci/factories/triggers.rb9
-rw-r--r--spec/ci/factories/users.rb6
-rw-r--r--spec/ci/factories/web_hook.rb6
10 files changed, 291 insertions, 0 deletions
diff --git a/spec/ci/factories/builds.rb b/spec/ci/factories/builds.rb
new file mode 100644
index 00000000000..346e0002bf5
--- /dev/null
+++ b/spec/ci/factories/builds.rb
@@ -0,0 +1,45 @@
+# == Schema Information
+#
+# Table name: builds
+#
+# id :integer not null, primary key
+# project_id :integer
+# status :string(255)
+# finished_at :datetime
+# trace :text
+# created_at :datetime
+# updated_at :datetime
+# started_at :datetime
+# runner_id :integer
+# commit_id :integer
+# coverage :float
+# commands :text
+# job_id :integer
+# name :string(255)
+# deploy :boolean default(FALSE)
+# options :text
+# allow_failure :boolean default(FALSE), not null
+# stage :string(255)
+# trigger_request_id :integer
+#
+
+# Read about factories at https://github.com/thoughtbot/factory_girl
+
+FactoryGirl.define do
+ factory :build do
+ started_at 'Di 29. Okt 09:51:28 CET 2013'
+ finished_at 'Di 29. Okt 09:53:28 CET 2013'
+ commands 'ls -a'
+ options do
+ {
+ image: "ruby:2.1",
+ services: ["postgres"]
+ }
+ end
+
+ factory :not_started_build do
+ started_at nil
+ finished_at nil
+ end
+ end
+end
diff --git a/spec/ci/factories/commits.rb b/spec/ci/factories/commits.rb
new file mode 100644
index 00000000000..6fdd46fa74b
--- /dev/null
+++ b/spec/ci/factories/commits.rb
@@ -0,0 +1,75 @@
+# == Schema Information
+#
+# Table name: commits
+#
+# id :integer not null, primary key
+# project_id :integer
+# ref :string(255)
+# sha :string(255)
+# before_sha :string(255)
+# push_data :text
+# created_at :datetime
+# updated_at :datetime
+# tag :boolean default(FALSE)
+# yaml_errors :text
+# committed_at :datetime
+#
+
+# Read about factories at https://github.com/thoughtbot/factory_girl
+FactoryGirl.define do
+ factory :commit do
+ ref 'master'
+ before_sha '76de212e80737a608d939f648d959671fb0a0142'
+ sha '97de212e80737a608d939f648d959671fb0a0142'
+ push_data do
+ {
+ ref: 'refs/heads/master',
+ before: '76de212e80737a608d939f648d959671fb0a0142',
+ after: '97de212e80737a608d939f648d959671fb0a0142',
+ user_name: 'Git User',
+ user_email: 'git@example.com',
+ repository: {
+ name: 'test-data',
+ url: 'ssh://git@gitlab.com/test/test-data.git',
+ description: '',
+ homepage: 'http://gitlab.com/test/test-data'
+ },
+ commits: [
+ {
+ id: '97de212e80737a608d939f648d959671fb0a0142',
+ message: 'Test commit message',
+ timestamp: '2014-09-23T13:12:25+02:00',
+ url: 'https://gitlab.com/test/test-data/commit/97de212e80737a608d939f648d959671fb0a0142',
+ author: {
+ name: 'Git User',
+ email: 'git@user.com'
+ }
+ }
+ ],
+ total_commits_count: 1,
+ ci_yaml_file: File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml'))
+ }
+ end
+
+ factory :commit_without_jobs do
+ after(:create) do |commit, evaluator|
+ commit.push_data[:ci_yaml_file] = YAML.dump({})
+ commit.save
+ end
+ end
+
+ factory :commit_with_one_job do
+ after(:create) do |commit, evaluator|
+ commit.push_data[:ci_yaml_file] = YAML.dump({rspec: { script: "ls" }})
+ commit.save
+ end
+ end
+
+ factory :commit_with_two_jobs do
+ after(:create) do |commit, evaluator|
+ commit.push_data[:ci_yaml_file] = YAML.dump({rspec: { script: "ls" }, spinach: { script: "ls" }})
+ commit.save
+ end
+ end
+ end
+end
diff --git a/spec/ci/factories/events.rb b/spec/ci/factories/events.rb
new file mode 100644
index 00000000000..1dfa52e3529
--- /dev/null
+++ b/spec/ci/factories/events.rb
@@ -0,0 +1,24 @@
+# == Schema Information
+#
+# Table name: events
+#
+# id :integer not null, primary key
+# project_id :integer
+# user_id :integer
+# is_admin :integer
+# description :text
+# created_at :datetime
+# updated_at :datetime
+#
+
+FactoryGirl.define do
+ factory :event, class: Event do
+ sequence :description do |n|
+ "updated project settings#{n}"
+ end
+
+ factory :admin_event do
+ is_admin true
+ end
+ end
+end
diff --git a/spec/ci/factories/projects.rb b/spec/ci/factories/projects.rb
new file mode 100644
index 00000000000..fb5b563f2f2
--- /dev/null
+++ b/spec/ci/factories/projects.rb
@@ -0,0 +1,56 @@
+# == Schema Information
+#
+# Table name: projects
+#
+# id :integer not null, primary key
+# name :string(255) not null
+# timeout :integer default(3600), not null
+# created_at :datetime
+# updated_at :datetime
+# token :string(255)
+# default_ref :string(255)
+# path :string(255)
+# always_build :boolean default(FALSE), not null
+# polling_interval :integer
+# public :boolean default(FALSE), not null
+# ssh_url_to_repo :string(255)
+# gitlab_id :integer
+# allow_git_fetch :boolean default(TRUE), not null
+# email_recipients :string(255) default(""), not null
+# email_add_pusher :boolean default(TRUE), not null
+# email_only_broken_builds :boolean default(TRUE), not null
+# skip_refs :string(255)
+# coverage_regex :string(255)
+# shared_runners_enabled :boolean default(FALSE)
+# generated_yaml_config :text
+#
+
+# Read about factories at https://github.com/thoughtbot/factory_girl
+
+FactoryGirl.define do
+ factory :project_without_token, class: Project do
+ sequence :name do |n|
+ "GitLab / gitlab-shell#{n}"
+ end
+
+ default_ref 'master'
+
+ sequence :path do |n|
+ "gitlab/gitlab-shell#{n}"
+ end
+
+ sequence :ssh_url_to_repo do |n|
+ "git@demo.gitlab.com:gitlab/gitlab-shell#{n}.git"
+ end
+
+ sequence :gitlab_id
+
+ factory :project do
+ token 'iPWx6WM4lhHNedGfBpPJNP'
+ end
+
+ factory :public_project do
+ public true
+ end
+ end
+end
diff --git a/spec/ci/factories/runner_projects.rb b/spec/ci/factories/runner_projects.rb
new file mode 100644
index 00000000000..b27632b3429
--- /dev/null
+++ b/spec/ci/factories/runner_projects.rb
@@ -0,0 +1,19 @@
+# == Schema Information
+#
+# Table name: runner_projects
+#
+# id :integer not null, primary key
+# runner_id :integer not null
+# project_id :integer not null
+# created_at :datetime
+# updated_at :datetime
+#
+
+# Read about factories at https://github.com/thoughtbot/factory_girl
+
+FactoryGirl.define do
+ factory :runner_project do
+ runner_id 1
+ project_id 1
+ end
+end
diff --git a/spec/ci/factories/runners.rb b/spec/ci/factories/runners.rb
new file mode 100644
index 00000000000..20a80f03268
--- /dev/null
+++ b/spec/ci/factories/runners.rb
@@ -0,0 +1,38 @@
+# == Schema Information
+#
+# Table name: runners
+#
+# id :integer not null, primary key
+# token :string(255)
+# created_at :datetime
+# updated_at :datetime
+# description :string(255)
+# contacted_at :datetime
+# active :boolean default(TRUE), not null
+# is_shared :boolean default(FALSE)
+# name :string(255)
+# version :string(255)
+# revision :string(255)
+# platform :string(255)
+# architecture :string(255)
+#
+
+# Read about factories at https://github.com/thoughtbot/factory_girl
+
+FactoryGirl.define do
+ factory :runner do
+ sequence :description do |n|
+ "My runner#{n}"
+ end
+
+ platform "darwin"
+
+ factory :shared_runner do
+ is_shared true
+ end
+
+ factory :specific_runner do
+ is_shared false
+ end
+ end
+end
diff --git a/spec/ci/factories/trigger_requests.rb b/spec/ci/factories/trigger_requests.rb
new file mode 100644
index 00000000000..c85d1027ce6
--- /dev/null
+++ b/spec/ci/factories/trigger_requests.rb
@@ -0,0 +1,13 @@
+# Read about factories at https://github.com/thoughtbot/factory_girl
+
+FactoryGirl.define do
+ factory :trigger_request do
+ factory :trigger_request_with_variables do
+ variables do
+ {
+ TRIGGER_KEY: 'TRIGGER_VALUE'
+ }
+ end
+ end
+ end
+end
diff --git a/spec/ci/factories/triggers.rb b/spec/ci/factories/triggers.rb
new file mode 100644
index 00000000000..a5af47b7d7f
--- /dev/null
+++ b/spec/ci/factories/triggers.rb
@@ -0,0 +1,9 @@
+# Read about factories at https://github.com/thoughtbot/factory_girl
+
+FactoryGirl.define do
+ factory :trigger_without_token, class: Trigger do
+ factory :trigger do
+ token 'token'
+ end
+ end
+end
diff --git a/spec/ci/factories/users.rb b/spec/ci/factories/users.rb
new file mode 100644
index 00000000000..26b30eff0e6
--- /dev/null
+++ b/spec/ci/factories/users.rb
@@ -0,0 +1,6 @@
+# Read about factories at https://github.com/thoughtbot/factory_girl
+
+FactoryGirl.define do
+ factory :user do
+ end
+end
diff --git a/spec/ci/factories/web_hook.rb b/spec/ci/factories/web_hook.rb
new file mode 100644
index 00000000000..3c027fb4861
--- /dev/null
+++ b/spec/ci/factories/web_hook.rb
@@ -0,0 +1,6 @@
+FactoryGirl.define do
+ factory :web_hook do
+ sequence(:url) { Faker::Internet.uri('http') }
+ project
+ end
+end