summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-09-09 13:37:50 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-09-09 13:37:50 +0200
commit76c6aeb9bc9855e9a65bb08db862e92ac923255e (patch)
tree3494f9854f8f9e2c14f909c7132691f652d13ebc /spec
parent3d6fed54f0dc551d8c7ba9a03f4dfbd2203552b5 (diff)
downloadgitlab-ce-76c6aeb9bc9855e9a65bb08db862e92ac923255e.tar.gz
Merge CI factories and CI spec/support with GitLab
Diffstat (limited to 'spec')
-rw-r--r--spec/ci/factories/users.rb6
-rw-r--r--spec/ci/spec_helper.rb60
-rw-r--r--spec/ci/support/api_helpers.rb35
-rw-r--r--spec/ci/support/db_cleaner.rb39
-rw-r--r--spec/ci/support/login_helpers.rb22
-rw-r--r--spec/ci/support/monkey_patches/oauth2.rb7
-rw-r--r--spec/controllers/ci/commits_controller_spec.rb (renamed from spec/ci/controllers/commits_controller_spec.rb)8
-rw-r--r--spec/controllers/ci/projects_controller_spec.rb (renamed from spec/ci/controllers/projects_controller_spec.rb)0
-rw-r--r--spec/factories/ci/builds.rb (renamed from spec/ci/factories/builds.rb)2
-rw-r--r--spec/factories/ci/commits.rb (renamed from spec/ci/factories/commits.rb)8
-rw-r--r--spec/factories/ci/events.rb (renamed from spec/ci/factories/events.rb)2
-rw-r--r--spec/factories/ci/projects.rb (renamed from spec/ci/factories/projects.rb)6
-rw-r--r--spec/factories/ci/runner_projects.rb (renamed from spec/ci/factories/runner_projects.rb)2
-rw-r--r--spec/factories/ci/runners.rb (renamed from spec/ci/factories/runners.rb)2
-rw-r--r--spec/factories/ci/trigger_requests.rb (renamed from spec/ci/factories/trigger_requests.rb)0
-rw-r--r--spec/factories/ci/triggers.rb (renamed from spec/ci/factories/triggers.rb)2
-rw-r--r--spec/factories/ci/web_hook.rb (renamed from spec/ci/factories/web_hook.rb)2
-rw-r--r--spec/spec_helper.rb3
-rw-r--r--spec/support/gitlab_stubs/gitlab_ci.yml (renamed from spec/ci/support/gitlab_stubs/gitlab_ci.yml)0
-rw-r--r--spec/support/gitlab_stubs/project_8.json (renamed from spec/ci/support/gitlab_stubs/project_8.json)0
-rw-r--r--spec/support/gitlab_stubs/project_8_hooks.json (renamed from spec/ci/support/gitlab_stubs/project_8_hooks.json)0
-rw-r--r--spec/support/gitlab_stubs/projects.json (renamed from spec/ci/support/gitlab_stubs/projects.json)0
-rw-r--r--spec/support/gitlab_stubs/raw_project.yml (renamed from spec/ci/support/gitlab_stubs/raw_project.yml)0
-rw-r--r--spec/support/gitlab_stubs/session.json (renamed from spec/ci/support/gitlab_stubs/session.json)0
-rw-r--r--spec/support/gitlab_stubs/user.json (renamed from spec/ci/support/gitlab_stubs/user.json)0
-rw-r--r--spec/support/setup_builds_storage.rb (renamed from spec/ci/support/setup_builds_storage.rb)0
-rw-r--r--spec/support/stub_gitlab_calls.rb (renamed from spec/ci/support/stub_gitlab_calls.rb)0
-rw-r--r--spec/support/stub_gitlab_data.rb (renamed from spec/ci/support/stub_gitlab_data.rb)0
28 files changed, 20 insertions, 186 deletions
diff --git a/spec/ci/factories/users.rb b/spec/ci/factories/users.rb
deleted file mode 100644
index 26b30eff0e6..00000000000
--- a/spec/ci/factories/users.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-# Read about factories at https://github.com/thoughtbot/factory_girl
-
-FactoryGirl.define do
- factory :user do
- end
-end
diff --git a/spec/ci/spec_helper.rb b/spec/ci/spec_helper.rb
deleted file mode 100644
index 54d3068845d..00000000000
--- a/spec/ci/spec_helper.rb
+++ /dev/null
@@ -1,60 +0,0 @@
-if ENV['SIMPLECOV']
- require 'simplecov'
- SimpleCov.start
-end
-
-if ENV['COVERALLS']
- require 'coveralls'
- Coveralls.wear!('rails')
-end
-
-ENV["RAILS_ENV"] ||= 'test'
-require File.expand_path("../../config/environment", __FILE__)
-require 'rspec/rails'
-require 'rspec/autorun'
-require 'sidekiq/testing/inline'
-require 'capybara/poltergeist'
-
-Capybara.javascript_driver = :poltergeist
-Capybara.default_wait_time = 10
-
-# Requires supporting ruby files with custom matchers and macros, etc,
-# in spec/support/ and its subdirectories.
-Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
-
-require 'webmock/rspec'
-WebMock.disable_net_connect!(allow_localhost: true)
-
-RSpec.configure do |config|
- config.include LoginHelpers, type: :feature
-
- config.include StubGitlabCalls
- config.include StubGitlabData
-
- # ## Mock Framework
- #
- # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
- #
- # config.mock_with :mocha
- # config.mock_with :flexmock
- # config.mock_with :rr
-
- # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
- config.fixture_path = "#{::Rails.root}/spec/fixtures"
-
- # If you're not using ActiveRecord, or you'd prefer not to run each of your
- # examples within a transaction, remove the following line or assign false
- # instead of true.
- config.use_transactional_fixtures = false
-
- # If true, the base class of anonymous controllers will be inferred
- # automatically. This will be the default behavior in future versions of
- # rspec-rails.
- config.infer_base_class_for_anonymous_controllers = false
-
- # Run specs in random order to surface order dependencies. If you find an
- # order dependency and want to debug it, you can fix the order by providing
- # the seed, which is printed after each run.
- # --seed 1234
- config.order = "random"
-end
diff --git a/spec/ci/support/api_helpers.rb b/spec/ci/support/api_helpers.rb
deleted file mode 100644
index 555980f2ea7..00000000000
--- a/spec/ci/support/api_helpers.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-module ApiHelpers
- # Public: Prepend a request path with the path to the API
- #
- # path - Path to append
- # user - User object - If provided, automatically appends private_token query
- # string for authenticated requests
- #
- # Examples
- #
- # >> api('/issues')
- # => "/api/v2/issues"
- #
- # >> api('/issues', User.last)
- # => "/api/v2/issues?private_token=..."
- #
- # >> api('/issues?foo=bar', User.last)
- # => "/api/v2/issues?foo=bar&private_token=..."
- #
- # Returns the relative path to the requested API resource
- def api(path, user = nil)
- "/api/#{API::API.version}#{path}" +
-
- # Normalize query string
- (path.index('?') ? '' : '?') +
-
- # Append private_token if given a User object
- (user.respond_to?(:private_token) ?
- "&private_token=#{user.private_token}" : "")
- end
-
- def json_response
- JSON.parse(response.body)
- end
-
-end
diff --git a/spec/ci/support/db_cleaner.rb b/spec/ci/support/db_cleaner.rb
deleted file mode 100644
index d2d532d9738..00000000000
--- a/spec/ci/support/db_cleaner.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-# RSpec.configure do |config|
-
-# config.around(:each) do |example|
-# DatabaseCleaner.strategy = :transaction
-# DatabaseCleaner.clean_with(:truncation)
-# DatabaseCleaner.cleaning do
-# example.run
-# end
-# end
-
-# config.around(:each, js: true) do |example|
-# DatabaseCleaner.strategy = :truncation
-# DatabaseCleaner.clean_with(:truncation)
-# DatabaseCleaner.cleaning do
-# example.run
-# end
-# end
-# end
-RSpec.configure do |config|
- config.before(:suite) do
- DatabaseCleaner.clean_with(:truncation)
- end
-
- config.before(:each) do
- DatabaseCleaner.strategy = :transaction
- end
-
- config.before(:each, :js => true) do
- DatabaseCleaner.strategy = :truncation
- end
-
- config.before(:each) do
- DatabaseCleaner.start
- end
-
- config.after(:each) do
- DatabaseCleaner.clean
- end
-end
diff --git a/spec/ci/support/login_helpers.rb b/spec/ci/support/login_helpers.rb
deleted file mode 100644
index ebd9693f8a4..00000000000
--- a/spec/ci/support/login_helpers.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-module LoginHelpers
- def login_as(role)
- raise 'Only :user allowed' unless role == :user
- stub_gitlab_calls
- login_with(:user)
- end
-
- # Internal: Login as the specified user
- #
- # user - User instance to login with
- def login_with(user)
- visit callback_user_sessions_path(code: "some_auth_code_here")
- end
-
- def logout
- click_link "Logout" rescue nil
- end
-
- def skip_admin_auth
- ApplicationController.any_instance.stub(authenticate_admin!: true)
- end
-end
diff --git a/spec/ci/support/monkey_patches/oauth2.rb b/spec/ci/support/monkey_patches/oauth2.rb
deleted file mode 100644
index dfd5e319f00..00000000000
--- a/spec/ci/support/monkey_patches/oauth2.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-module OAuth2
- class Client
- def get_token(params, access_token_opts = {}, access_token_class = AccessToken)
- OpenStruct.new(token: "some_token")
- end
- end
-end \ No newline at end of file
diff --git a/spec/ci/controllers/commits_controller_spec.rb b/spec/controllers/ci/commits_controller_spec.rb
index f32d6f8c126..b71e7505731 100644
--- a/spec/ci/controllers/commits_controller_spec.rb
+++ b/spec/controllers/ci/commits_controller_spec.rb
@@ -1,13 +1,13 @@
require "spec_helper"
-describe CommitsController do
+describe Ci::CommitsController do
before do
- @project = FactoryGirl.create :project
+ @project = FactoryGirl.create :ci_project
end
describe "GET /status" do
it "returns status of commit" do
- commit = FactoryGirl.create :commit, project: @project
+ commit = FactoryGirl.create :ci_commit, project: @project
get :status, id: commit.sha, ref_id: commit.ref, project_id: @project.id
expect(response).to be_success
@@ -16,7 +16,7 @@ describe CommitsController do
end
it "returns not_found status" do
- commit = FactoryGirl.create :commit, project: @project
+ commit = FactoryGirl.create :ci_commit, project: @project
get :status, id: commit.sha, ref_id: "deploy", project_id: @project.id
expect(response).to be_success
diff --git a/spec/ci/controllers/projects_controller_spec.rb b/spec/controllers/ci/projects_controller_spec.rb
index 0069a782511..0069a782511 100644
--- a/spec/ci/controllers/projects_controller_spec.rb
+++ b/spec/controllers/ci/projects_controller_spec.rb
diff --git a/spec/ci/factories/builds.rb b/spec/factories/ci/builds.rb
index 346e0002bf5..35a84b1e6eb 100644
--- a/spec/ci/factories/builds.rb
+++ b/spec/factories/ci/builds.rb
@@ -26,7 +26,7 @@
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
- factory :build do
+ factory :ci_build, class: Ci::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'
diff --git a/spec/ci/factories/commits.rb b/spec/factories/ci/commits.rb
index 6fdd46fa74b..c1d42b607c3 100644
--- a/spec/ci/factories/commits.rb
+++ b/spec/factories/ci/commits.rb
@@ -17,7 +17,7 @@
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
- factory :commit do
+ factory :ci_commit, class: Ci::Commit do
ref 'master'
before_sha '76de212e80737a608d939f648d959671fb0a0142'
sha '97de212e80737a608d939f648d959671fb0a0142'
@@ -51,21 +51,21 @@ FactoryGirl.define do
}
end
- factory :commit_without_jobs do
+ factory :ci_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
+ factory :ci_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
+ factory :ci_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
diff --git a/spec/ci/factories/events.rb b/spec/factories/ci/events.rb
index 1dfa52e3529..03450751596 100644
--- a/spec/ci/factories/events.rb
+++ b/spec/factories/ci/events.rb
@@ -12,7 +12,7 @@
#
FactoryGirl.define do
- factory :event, class: Event do
+ factory :ci_event, class: Ci::Event do
sequence :description do |n|
"updated project settings#{n}"
end
diff --git a/spec/ci/factories/projects.rb b/spec/factories/ci/projects.rb
index fb5b563f2f2..e6be88fa585 100644
--- a/spec/ci/factories/projects.rb
+++ b/spec/factories/ci/projects.rb
@@ -28,7 +28,7 @@
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
- factory :project_without_token, class: Project do
+ factory :ci_project_without_token, class: Ci::Project do
sequence :name do |n|
"GitLab / gitlab-shell#{n}"
end
@@ -45,11 +45,11 @@ FactoryGirl.define do
sequence :gitlab_id
- factory :project do
+ factory :ci_project do
token 'iPWx6WM4lhHNedGfBpPJNP'
end
- factory :public_project do
+ factory :ci_public_project do
public true
end
end
diff --git a/spec/ci/factories/runner_projects.rb b/spec/factories/ci/runner_projects.rb
index b27632b3429..3aa14ca434d 100644
--- a/spec/ci/factories/runner_projects.rb
+++ b/spec/factories/ci/runner_projects.rb
@@ -12,7 +12,7 @@
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
- factory :runner_project do
+ factory :ci_runner_project, class: Ci::RunnerProject do
runner_id 1
project_id 1
end
diff --git a/spec/ci/factories/runners.rb b/spec/factories/ci/runners.rb
index 20a80f03268..fec56b438fa 100644
--- a/spec/ci/factories/runners.rb
+++ b/spec/factories/ci/runners.rb
@@ -20,7 +20,7 @@
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
- factory :runner do
+ factory :ci_runner, class: Ci::Runner do
sequence :description do |n|
"My runner#{n}"
end
diff --git a/spec/ci/factories/trigger_requests.rb b/spec/factories/ci/trigger_requests.rb
index c85d1027ce6..c85d1027ce6 100644
--- a/spec/ci/factories/trigger_requests.rb
+++ b/spec/factories/ci/trigger_requests.rb
diff --git a/spec/ci/factories/triggers.rb b/spec/factories/ci/triggers.rb
index a5af47b7d7f..38cd3cbceb6 100644
--- a/spec/ci/factories/triggers.rb
+++ b/spec/factories/ci/triggers.rb
@@ -1,7 +1,7 @@
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
- factory :trigger_without_token, class: Trigger do
+ factory :ci_trigger_without_token, class: Ci::Trigger do
factory :trigger do
token 'token'
end
diff --git a/spec/ci/factories/web_hook.rb b/spec/factories/ci/web_hook.rb
index 3c027fb4861..1fde5805c94 100644
--- a/spec/ci/factories/web_hook.rb
+++ b/spec/factories/ci/web_hook.rb
@@ -1,5 +1,5 @@
FactoryGirl.define do
- factory :web_hook do
+ factory :ci_web_hook, class: Ci::WebHook do
sequence(:url) { Faker::Internet.uri('http') }
project
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index d0f1873ee2d..8442d3f4445 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -29,6 +29,9 @@ RSpec.configure do |config|
config.include LoginHelpers, type: :request
config.include StubConfiguration
config.include TestEnv
+ config.include StubGitlabCalls
+ config.include StubGitlabData
+
config.infer_spec_type_from_file_location!
config.raise_errors_for_deprecations!
diff --git a/spec/ci/support/gitlab_stubs/gitlab_ci.yml b/spec/support/gitlab_stubs/gitlab_ci.yml
index 3482145404e..3482145404e 100644
--- a/spec/ci/support/gitlab_stubs/gitlab_ci.yml
+++ b/spec/support/gitlab_stubs/gitlab_ci.yml
diff --git a/spec/ci/support/gitlab_stubs/project_8.json b/spec/support/gitlab_stubs/project_8.json
index f0a9fce859c..f0a9fce859c 100644
--- a/spec/ci/support/gitlab_stubs/project_8.json
+++ b/spec/support/gitlab_stubs/project_8.json
diff --git a/spec/ci/support/gitlab_stubs/project_8_hooks.json b/spec/support/gitlab_stubs/project_8_hooks.json
index 93d51406d63..93d51406d63 100644
--- a/spec/ci/support/gitlab_stubs/project_8_hooks.json
+++ b/spec/support/gitlab_stubs/project_8_hooks.json
diff --git a/spec/ci/support/gitlab_stubs/projects.json b/spec/support/gitlab_stubs/projects.json
index ca42c14c5d8..ca42c14c5d8 100644
--- a/spec/ci/support/gitlab_stubs/projects.json
+++ b/spec/support/gitlab_stubs/projects.json
diff --git a/spec/ci/support/gitlab_stubs/raw_project.yml b/spec/support/gitlab_stubs/raw_project.yml
index df2ce223d1f..df2ce223d1f 100644
--- a/spec/ci/support/gitlab_stubs/raw_project.yml
+++ b/spec/support/gitlab_stubs/raw_project.yml
diff --git a/spec/ci/support/gitlab_stubs/session.json b/spec/support/gitlab_stubs/session.json
index ce8dfe5ae75..ce8dfe5ae75 100644
--- a/spec/ci/support/gitlab_stubs/session.json
+++ b/spec/support/gitlab_stubs/session.json
diff --git a/spec/ci/support/gitlab_stubs/user.json b/spec/support/gitlab_stubs/user.json
index ce8dfe5ae75..ce8dfe5ae75 100644
--- a/spec/ci/support/gitlab_stubs/user.json
+++ b/spec/support/gitlab_stubs/user.json
diff --git a/spec/ci/support/setup_builds_storage.rb b/spec/support/setup_builds_storage.rb
index cafc8dee918..cafc8dee918 100644
--- a/spec/ci/support/setup_builds_storage.rb
+++ b/spec/support/setup_builds_storage.rb
diff --git a/spec/ci/support/stub_gitlab_calls.rb b/spec/support/stub_gitlab_calls.rb
index 931ef963c0f..931ef963c0f 100644
--- a/spec/ci/support/stub_gitlab_calls.rb
+++ b/spec/support/stub_gitlab_calls.rb
diff --git a/spec/ci/support/stub_gitlab_data.rb b/spec/support/stub_gitlab_data.rb
index fa402f35b95..fa402f35b95 100644
--- a/spec/ci/support/stub_gitlab_data.rb
+++ b/spec/support/stub_gitlab_data.rb