From a6658fa4d3bda741e9f6efa67716f70465c047eb Mon Sep 17 00:00:00 2001
From: Sven Fuchs <me@svenfuchs.com>
Date: Sun, 19 Jun 2016 00:02:11 +0200
Subject: [PATCH] get rid of spec_helper_core

---
 .rspec                                        |   1 +
 Rakefile                                      |  43 +-
 lib/travis/api/app.rb                         |  15 +-
 lib/travis/api/app/endpoint/requests.rb       |   5 +
 spec/active_record_postgres_variables_spec.rb |   2 -
 spec/integration/error_handling_spec.rb       |   4 +-
 spec/integration/formats_handling_spec.rb     |   4 +-
 spec/integration/responders_spec.rb           |   2 -
 spec/integration/routes.backup.rb             |  23 -
 spec/integration/scopes_spec.rb               |   2 -
 spec/integration/settings_endpoint_spec.rb    |   2 -
 .../singleton_settings_endpoint_spec.rb       |   2 -
 spec/integration/uptime_spec.rb               |   4 +-
 spec/integration/v2/branches_spec.rb          |   4 +-
 spec/integration/v2/builds_spec.rb            |   4 +-
 spec/integration/v2/hooks_spec.rb             |   3 +-
 spec/integration/v2/jobs_spec.rb              |   4 +-
 spec/integration/v2/repositories_spec.rb      |   7 +-
 spec/integration/v2/requests_spec.rb          |   3 +-
 spec/integration/v2/settings/env_vars_spec.rb |   4 +-
 spec/integration/v2/settings/ssh_key_spec.rb  |   4 +-
 spec/integration/v2/users_spec.rb             |   4 +-
 spec/integration/v2_spec.backup.rb            |   2 -
 spec/integration/version_spec.rb              |   2 -
 spec/spec_helper.rb                           |  92 +-
 spec/spec_helper_core.rb                      |  59 --
 spec/support/private_key.rb                   |  28 +
 spec/support/test_helpers.rb                  |  29 +
 spec/unit/access_token_spec.rb                |   2 -
 spec/unit/app_spec.rb                         |   2 -
 spec/unit/cors_spec.rb                        |   2 -
 spec/unit/default_spec.rb                     |   4 +-
 spec/unit/endpoint/accounts_spec.rb           |   4 +-
 .../authorization/user_manager_spec.rb        |   2 -
 spec/unit/endpoint/authorization_spec.rb      |   2 -
 spec/unit/endpoint/branches_spec.rb           |   2 -
 spec/unit/endpoint/builds_spec.rb             |   6 +-
 spec/unit/endpoint/endpoints_spec.rb          |   2 -
 spec/unit/endpoint/hooks_spec.rb              |   2 -
 spec/unit/endpoint/jobs_spec.rb               |   4 +-
 spec/unit/endpoint/lint_spec.rb               |   4 +-
 spec/unit/endpoint/logs_spec.rb               |   4 +-
 spec/unit/endpoint/repos_spec.rb              |   4 +-
 spec/unit/endpoint/requests/throttle_spec.rb  |   2 -
 spec/unit/endpoint/users_spec.rb              |   4 +-
 spec/unit/endpoint_spec.rb                    |   4 +-
 spec/unit/extensions/expose_pattern_spec.rb   |   4 +-
 spec/unit/extensions/scoping_spec.rb          |   2 -
 spec/unit/extensions/smart_constants_spec.rb  |   2 -
 spec/unit/extensions/subclass_tracker_spec.rb |   2 -
 spec/unit/helpers/accept_spec.rb              |   2 -
 spec/unit/helpers/json_renderer_spec.rb       |   1 -
 spec/unit/middleware/logging_spec.rb          |   2 -
 spec/unit/middleware/scope_check_spec.rb      |   4 +-
 .../middleware/user_agent_tracker_spec.rb     |   2 -
 spec/unit/responders/json_spec.rb             |   2 -
 spec/unit/responders/service_spec.rb          |   2 -
 spec/unit/serialize/v2/http/accounts_spec.rb  |   2 -
 .../serialize/v2/http/annotations_spec.rb     |   2 -
 spec/unit/serialize/v2/http/branch_spec.rb    |   2 -
 spec/unit/serialize/v2/http/branches_spec.rb  |   2 -
 .../unit/serialize/v2/http/broadcasts_spec.rb |   2 -
 spec/unit/serialize/v2/http/build_spec.rb     |   2 -
 spec/unit/serialize/v2/http/builds_spec.rb    |   2 -
 spec/unit/serialize/v2/http/caches_spec.rb    |   2 -
 spec/unit/serialize/v2/http/env_var_spec.rb   |   2 -
 spec/unit/serialize/v2/http/hooks_spec.rb     |   2 -
 spec/unit/serialize/v2/http/job_spec.rb       |   2 -
 spec/unit/serialize/v2/http/jobs_spec.rb      |   2 -
 spec/unit/serialize/v2/http/log_spec.rb       |   2 -
 .../serialize/v2/http/permissions_spec.rb     |   2 -
 .../serialize/v2/http/repositories_spec.rb    |   2 -
 .../unit/serialize/v2/http/repository_spec.rb |   2 -
 spec/unit/serialize/v2/http/request_spec.rb   |   2 -
 spec/unit/serialize/v2/http/requests_spec.rb  |   2 -
 spec/unit/serialize/v2/http/ssl_key_spec.rb   |   2 -
 spec/unit/serialize/v2/http/user_spec.rb      |   2 -
 spec/v3/error_handling_spec.rb                |   4 +-
 spec/v3/extensions/belongs_to_spec.rb         |   2 -
 spec/v3/metrics_spec.rb                       |   2 -
 spec/v3/models/cron_spec.rb                   |   1 -
 spec/v3/queries/cron_spec.rb                  |   2 -
 spec/v3/renderer/avatar_url_spec.rb           |   2 -
 spec/v3/result_spec.rb                        |   2 -
 spec/v3/service_index_spec.rb                 |   4 +-
 .../accounts/for_current_user_spec.rb         |   4 +-
 spec/v3/services/branch/find_spec.rb          |   4 +-
 spec/v3/services/branches/find_spec.rb        |   4 +-
 .../broadcasts/for_current_user_spec.rb       |   4 +-
 spec/v3/services/build/cancel_spec.rb         |   4 +-
 spec/v3/services/build/find_spec.rb           |   4 +-
 spec/v3/services/build/restart_spec.rb        |   4 +-
 spec/v3/services/builds/find_spec.rb          |   4 +-
 spec/v3/services/cron/create_spec.rb          |   4 +-
 spec/v3/services/cron/delete_spec.rb          |   4 +-
 spec/v3/services/cron/find_spec.rb            |   4 +-
 spec/v3/services/cron/for_branch_spec.rb      |   4 +-
 spec/v3/services/crons/for_repository_spec.rb |   4 +-
 spec/v3/services/job/cancel_spec.rb           |   4 +-
 spec/v3/services/job/debug_sepc.rb            |   6 +-
 spec/v3/services/job/find_spec.rb             |   4 +-
 spec/v3/services/job/restart_spec.rb          |   4 +-
 spec/v3/services/jobs/find_spec.rb            |   4 +-
 spec/v3/services/lint/lint_spec.rb            |   4 +-
 spec/v3/services/organization/find_spec.rb    |   4 +-
 .../organizations/for_current_user_spec.rb    |   4 +-
 spec/v3/services/owner/find_spec.rb           |   4 +-
 .../repositories/for_current_user_spec.rb     |   4 +-
 .../services/repositories/for_owner_spec.rb   |   4 +-
 spec/v3/services/repository/disable_spec.rb   |   4 +-
 spec/v3/services/repository/enable_spec.rb    |   4 +-
 spec/v3/services/repository/find_spec.rb      |   4 +-
 spec/v3/services/repository/star_spec.rb      |   6 +-
 spec/v3/services/repository/unstar_spec.rb    |   6 +-
 spec/v3/services/requests/create_spec.rb      |   4 +-
 spec/v3/services/requests/find_spec.rb        |   4 +-
 spec/v3/services/settings_spec.rb             |  10 +-
 spec/v3/services/user/current_spec.rb         |   4 +-
 spec/v3/services/user/find_spec.rb            |   4 +-
 spec/v3/services/user/sync_spec.rb            |   4 +-
 spec_core/core/model/build/compat_spec.rb     |   7 -
 spec_core/core/model/organization_spec.rb     |  22 -
 .../services/find_daily_repos_stats_spec.rb   |  22 -
 .../services/find_daily_tests_stats_spec.rb   |  17 -
 .../model/annotation_provider_spec.rb         |   7 +-
 spec_core/{core => }/model/annotation_spec.rb |   4 -
 spec_core/{core => }/model/broadcast_spec.rb  |   4 -
 .../model/build/config/dist_spec.rb           |   0
 .../model/build/config/group_spec.rb          |   0
 .../model/build/config/matrix_spec.rb         |   3 -
 .../model/build/config/obfuscate_spec.rb      |   6 +-
 .../{core => }/model/build/config_spec.rb     |   4 -
 .../model/build/denormalize_spec.rb           |   4 -
 .../{core => }/model/build/matrix_spec.rb     |  10 +-
 .../{core => }/model/build/metrics_spec.rb    |   4 +-
 .../model/build/result_message_spec.rb        |   2 -
 .../{core => }/model/build/states_spec.rb     |   4 -
 .../model/build/update_branch_spec.rb         |   6 +-
 spec_core/{core => }/model/build_spec.rb      |   6 +-
 spec_core/{core => }/model/commit_spec.rb     |   4 -
 .../{core => }/model/encrypted_column_spec.rb |   2 -
 .../{core => }/model/job/cleanup_spec.rb      |   4 -
 spec_core/{core => }/model/job/queue_spec.rb  |   2 -
 spec_core/{core => }/model/job/test_spec.rb   |   4 -
 spec_core/{core => }/model/job_spec.rb        |  45 +-
 spec_core/model/organization_spec.rb          |  18 +
 spec_core/{core => }/model/permission_spec.rb |   4 -
 .../model/repository/settings/ssh_key_spec.rb |   2 -
 .../model/repository/settings_spec.rb         |   2 -
 .../model/repository/status_image_spec.rb     |   4 -
 spec_core/{core => }/model/repository_spec.rb |  16 +-
 .../{core => }/model/request/approval_spec.rb |   2 -
 .../{core => }/model/request/branches_spec.rb |   2 -
 .../{core => }/model/request/states_spec.rb   |   4 -
 spec_core/{core => }/model/request_spec.rb    |   4 -
 spec_core/{core => }/model/ssl_key_spec.rb    |   4 -
 spec_core/{core => }/model/token_spec.rb      |   4 -
 spec_core/{core => }/model/url_spec.rb        |   4 -
 spec_core/{core => }/model/user/oauth_spec.rb |   4 -
 spec_core/{core => }/model/user_spec.rb       |  17 +-
 .../{core => }/services/cancel_build_spec.rb  |   4 -
 .../{core => }/services/cancel_job_spec.rb    |   4 -
 .../{core => }/services/find_admin_spec.rb    |   2 -
 .../services/find_annotation_spec.rb          |   4 -
 .../{core => }/services/find_branch_spec.rb   |   4 -
 .../{core => }/services/find_branches_spec.rb |   4 -
 .../{core => }/services/find_build_spec.rb    |   4 -
 .../{core => }/services/find_builds_spec.rb   |   4 +-
 .../{core => }/services/find_caches_spec.rb   |   6 +-
 .../{core => }/services/find_hooks_spec.rb    |   4 -
 .../{core => }/services/find_job_spec.rb      |   4 -
 .../{core => }/services/find_jobs_spec.rb     |   4 -
 .../{core => }/services/find_log_spec.rb      |   4 -
 .../{core => }/services/find_repo_key_spec.rb |   6 +-
 .../services/find_repo_settings_spec.rb       |   4 -
 .../{core => }/services/find_repo_spec.rb     |   4 -
 .../{core => }/services/find_repos_spec.rb    |   4 +-
 .../{core => }/services/find_request_spec.rb  |   4 -
 .../{core => }/services/find_requests_spec.rb |   4 -
 .../services/find_user_accounts_spec.rb       |   4 -
 .../services/next_build_number_spec.rb        |   3 -
 .../services/regenerate_repo_key_spec.rb      |   4 -
 .../{core => }/services/remove_log_spec.rb    |   6 -
 .../{core => }/services/reset_model_spec.rb   |   4 -
 .../{core => }/services/sync_user_spec.rb     |   2 -
 .../services/update_annotation_spec.rb        |   4 -
 .../{core => }/services/update_hook_spec.rb   |   2 -
 .../{core => }/services/update_job_spec.rb    |   4 +-
 .../{core => }/services/update_log_spec.rb    |   2 -
 .../{core => }/services/update_user_spec.rb   |   2 -
 spec_core/{core => }/services_spec.rb         |   2 -
 travis-api.gemspec                            | 811 +-----------------
 .../lib/travis/event/handler/metrics.rb       |   2 +-
 .../lib/travis/model/repository.rb            |   6 +-
 vendor/travis-core/lib/travis/model/user.rb   |   7 +-
 vendor/travis-core/lib/travis/services.rb     |   2 -
 .../travis/services/find_daily_repos_stats.rb |  23 -
 .../travis/services/find_daily_tests_stats.rb |  23 -
 .../lib/{travis_core => travis}/version.rb    |   2 +-
 vendor/travis-core/travis-core.gemspec        |   4 +-
 200 files changed, 280 insertions(+), 1651 deletions(-)
 delete mode 100644 spec/integration/routes.backup.rb
 delete mode 100644 spec/spec_helper_core.rb
 create mode 100644 spec/support/private_key.rb
 create mode 100644 spec/support/test_helpers.rb
 delete mode 100644 spec_core/core/model/build/compat_spec.rb
 delete mode 100644 spec_core/core/model/organization_spec.rb
 delete mode 100644 spec_core/core/services/find_daily_repos_stats_spec.rb
 delete mode 100644 spec_core/core/services/find_daily_tests_stats_spec.rb
 rename spec_core/{core => }/model/annotation_provider_spec.rb (93%)
 rename spec_core/{core => }/model/annotation_spec.rb (89%)
 rename spec_core/{core => }/model/broadcast_spec.rb (98%)
 rename spec_core/{core => }/model/build/config/dist_spec.rb (100%)
 rename spec_core/{core => }/model/build/config/group_spec.rb (100%)
 rename spec_core/{core => }/model/build/config/matrix_spec.rb (86%)
 rename spec_core/{core => }/model/build/config/obfuscate_spec.rb (97%)
 rename spec_core/{core => }/model/build/config_spec.rb (98%)
 rename spec_core/{core => }/model/build/denormalize_spec.rb (96%)
 rename spec_core/{core => }/model/build/matrix_spec.rb (99%)
 rename spec_core/{core => }/model/build/metrics_spec.rb (87%)
 rename spec_core/{core => }/model/build/result_message_spec.rb (99%)
 rename spec_core/{core => }/model/build/states_spec.rb (99%)
 rename spec_core/{core => }/model/build/update_branch_spec.rb (93%)
 rename spec_core/{core => }/model/build_spec.rb (99%)
 rename spec_core/{core => }/model/commit_spec.rb (97%)
 rename spec_core/{core => }/model/encrypted_column_spec.rb (99%)
 rename spec_core/{core => }/model/job/cleanup_spec.rb (94%)
 rename spec_core/{core => }/model/job/queue_spec.rb (99%)
 rename spec_core/{core => }/model/job/test_spec.rb (98%)
 rename spec_core/{core => }/model/job_spec.rb (92%)
 create mode 100644 spec_core/model/organization_spec.rb
 rename spec_core/{core => }/model/permission_spec.rb (89%)
 rename spec_core/{core => }/model/repository/settings/ssh_key_spec.rb (99%)
 rename spec_core/{core => }/model/repository/settings_spec.rb (99%)
 rename spec_core/{core => }/model/repository/status_image_spec.rb (98%)
 rename spec_core/{core => }/model/repository_spec.rb (97%)
 rename spec_core/{core => }/model/request/approval_spec.rb (99%)
 rename spec_core/{core => }/model/request/branches_spec.rb (99%)
 rename spec_core/{core => }/model/request/states_spec.rb (99%)
 rename spec_core/{core => }/model/request_spec.rb (98%)
 rename spec_core/{core => }/model/ssl_key_spec.rb (98%)
 rename spec_core/{core => }/model/token_spec.rb (82%)
 rename spec_core/{core => }/model/url_spec.rb (92%)
 rename spec_core/{core => }/model/user/oauth_spec.rb (92%)
 rename spec_core/{core => }/model/user_spec.rb (94%)
 rename spec_core/{core => }/services/cancel_build_spec.rb (96%)
 rename spec_core/{core => }/services/cancel_job_spec.rb (95%)
 rename spec_core/{core => }/services/find_admin_spec.rb (99%)
 rename spec_core/{core => }/services/find_annotation_spec.rb (90%)
 rename spec_core/{core => }/services/find_branch_spec.rb (94%)
 rename spec_core/{core => }/services/find_branches_spec.rb (94%)
 rename spec_core/{core => }/services/find_build_spec.rb (97%)
 rename spec_core/{core => }/services/find_builds_spec.rb (98%)
 rename spec_core/{core => }/services/find_caches_spec.rb (96%)
 rename spec_core/{core => }/services/find_hooks_spec.rb (96%)
 rename spec_core/{core => }/services/find_job_spec.rb (96%)
 rename spec_core/{core => }/services/find_jobs_spec.rb (97%)
 rename spec_core/{core => }/services/find_log_spec.rb (94%)
 rename spec_core/{core => }/services/find_repo_key_spec.rb (93%)
 rename spec_core/{core => }/services/find_repo_settings_spec.rb (94%)
 rename spec_core/{core => }/services/find_repo_spec.rb (94%)
 rename spec_core/{core => }/services/find_repos_spec.rb (98%)
 rename spec_core/{core => }/services/find_request_spec.rb (92%)
 rename spec_core/{core => }/services/find_requests_spec.rb (97%)
 rename spec_core/{core => }/services/find_user_accounts_spec.rb (96%)
 rename spec_core/{core => }/services/next_build_number_spec.rb (95%)
 rename spec_core/{core => }/services/regenerate_repo_key_spec.rb (93%)
 rename spec_core/{core => }/services/remove_log_spec.rb (97%)
 rename spec_core/{core => }/services/reset_model_spec.rb (98%)
 rename spec_core/{core => }/services/sync_user_spec.rb (97%)
 rename spec_core/{core => }/services/update_annotation_spec.rb (97%)
 rename spec_core/{core => }/services/update_hook_spec.rb (98%)
 rename spec_core/{core => }/services/update_job_spec.rb (99%)
 rename spec_core/{core => }/services/update_log_spec.rb (97%)
 rename spec_core/{core => }/services/update_user_spec.rb (95%)
 rename spec_core/{core => }/services_spec.rb (98%)
 delete mode 100644 vendor/travis-core/lib/travis/services/find_daily_repos_stats.rb
 delete mode 100644 vendor/travis-core/lib/travis/services/find_daily_tests_stats.rb
 rename vendor/travis-core/lib/{travis_core => travis}/version.rb (57%)

diff --git a/.rspec b/.rspec
index 8db79e75..586e4f62 100644
--- a/.rspec
+++ b/.rspec
@@ -1,2 +1,3 @@
+--require spec_helper
 --colour
 --tty
diff --git a/Rakefile b/Rakefile
index da93db47..a48da4b0 100644
--- a/Rakefile
+++ b/Rakefile
@@ -9,30 +9,39 @@ namespace :db do
   end
 end
 
-begin
-  require 'rspec'
-  require 'rspec/core/rake_task'
-  RSpec::Core::RakeTask.new(:spec)
+# begin
+#   require 'rspec'
+#   require 'rspec/core/rake_task'
+#   RSpec::Core::RakeTask.new(:spec)
+#
+#   RSpec::Core::RakeTask.new(:spec_core) do |t|
+#     t.pattern = 'spec_core/**{,/*/**}/*_spec.rb'
+#   end
+#
+#   task :default => [:spec, :spec_core]
+# rescue LoadError => e
+#   puts e.inspect
+# end
 
-  RSpec::Core::RakeTask.new(:spec_core) do |t|
-    t.pattern = 'spec_core/**{,/*/**}/*_spec.rb'
+# not sure how else to include the spec_helper
+namespace :spec do
+  desc 'Run api specs'
+  task :api do
+    sh 'bundle exec rspec -r spec_helper spec'
   end
 
-  task :default => [:spec, :spec_core]
-rescue LoadError => e
-  puts e.inspect
+  desc 'Run core specs'
+  task :core do
+    sh 'bundle exec rspec -r spec_helper spec_core'
+  end
 end
 
+task :default => %w(spec:api spec:core)
+
 desc "generate gemspec"
 task 'travis-api.gemspec' do
   content = File.read 'travis-api.gemspec'
 
-  fields = {
-    authors: `git shortlog -sn`.scan(/[^\d\s].*/),
-    email:   `git shortlog -sne`.scan(/[^<]+@[^>]+/),
-    files:   `git ls-files`.split("\n").reject { |f| f =~ /^(\.|Gemfile)/ }
-  }
-
   fields.each do |field, values|
     updated = "  s.#{field} = ["
     updated << values.map { |v| "\n    %p" % v }.join(',')
@@ -43,7 +52,3 @@ task 'travis-api.gemspec' do
   File.open('travis-api.gemspec', 'w') { |f| f << content }
 end
 task default: 'travis-api.gemspec'
-
-## can this be removed? what other rakefiles need to be included?
-# tasks_path = File.expand_path('../lib/tasks/*.rake', __FILE__)
-# Dir.glob(tasks_path).each { |r| import r }
diff --git a/lib/travis/api/app.rb b/lib/travis/api/app.rb
index a0ca55b4..1e1ec814 100644
--- a/lib/travis/api/app.rb
+++ b/lib/travis/api/app.rb
@@ -92,14 +92,13 @@ module Travis::Api
 
     def initialize
       @app = Rack::Builder.app do
-
-        if stackprof = ENV['STACKPROF']
-          require 'stackprof'
-          modes = ['wall', 'cpu', 'object', 'custom']
-          mode  = modes.include?(stackprof) ? stackprof.to_sym : :cpu
-          Travis.logger.info "Setting up profiler: #{mode}"
-          use StackProf::Middleware, enabled: true, save_every: 1, mode: mode
-        end
+        # if stackprof = ENV['STACKPROF']
+        #   require 'stackprof'
+        #   modes = ['wall', 'cpu', 'object', 'custom']
+        #   mode  = modes.include?(stackprof) ? stackprof.to_sym : :cpu
+        #   Travis.logger.info "Setting up profiler: #{mode}"
+        #   use StackProf::Middleware, enabled: true, save_every: 1, mode: mode
+        # end
 
         extend StackInstrumentation
         use Travis::Api::App::Middleware::Skylight
diff --git a/lib/travis/api/app/endpoint/requests.rb b/lib/travis/api/app/endpoint/requests.rb
index a72506b9..cf67b9a7 100644
--- a/lib/travis/api/app/endpoint/requests.rb
+++ b/lib/travis/api/app/endpoint/requests.rb
@@ -22,6 +22,11 @@ class Travis::Api::App
           status 404
         else
           # DEPRECATED: this will be removed by 1st of December
+          #
+          # TODO It seems this endpoint is still in use, quite a bit:
+          # https://metrics.librato.com/s/metrics/api.request.restart?duration=2419200&q=api.request.restart
+          #
+          # I think we need to properly deprecate this by publishing a blog post.
           Metriks.meter("api.request.restart").mark
           respond_with service(:reset_model, params)
         end
diff --git a/spec/active_record_postgres_variables_spec.rb b/spec/active_record_postgres_variables_spec.rb
index 2acab155..0fd5a702 100644
--- a/spec/active_record_postgres_variables_spec.rb
+++ b/spec/active_record_postgres_variables_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe "ActiveRecordPostgresVariables" do
   let(:variables) {{ foo: 'bar' }}
   let(:database_options) { Travis.config.database.merge(variables: variables) }
diff --git a/spec/integration/error_handling_spec.rb b/spec/integration/error_handling_spec.rb
index 246a0eb7..4faedbc2 100644
--- a/spec/integration/error_handling_spec.rb
+++ b/spec/integration/error_handling_spec.rb
@@ -1,8 +1,6 @@
-require 'spec_helper'
 require 'sentry-raven'
 
-describe 'Exception' do
-
+describe 'Exception', set_app: true do
   class FixRaven < Struct.new(:app)
     def call(env)
       requested_at = env['requested_at']
diff --git a/spec/integration/formats_handling_spec.rb b/spec/integration/formats_handling_spec.rb
index efda70b5..f37b5bf9 100644
--- a/spec/integration/formats_handling_spec.rb
+++ b/spec/integration/formats_handling_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe 'App' do
+describe 'App', set_app: true do
   before do
     FactoryGirl.create(:test, :number => '3.1', :queue => 'builds.common')
 
diff --git a/spec/integration/responders_spec.rb b/spec/integration/responders_spec.rb
index 2dc2cb78..a73b8c48 100644
--- a/spec/integration/responders_spec.rb
+++ b/spec/integration/responders_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe 'App' do
   before do
     FactoryGirl.create(:test, :number => '3.1', :queue => 'builds.common')
diff --git a/spec/integration/routes.backup.rb b/spec/integration/routes.backup.rb
deleted file mode 100644
index 6ca53cb2..00000000
--- a/spec/integration/routes.backup.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-  # api = lambda do
-  #   constraints :format => 'json' do
-  #     resources :repositories, :only => [:index, :show] do
-  #       resources :builds,     :only => [:index, :show]
-  #     end
-  #     resources :builds,       :only => [:index, :show]
-  #     resources :branches,     :only => :index
-  #     resources :jobs,         :only => [:index, :show]
-  #     resources :workers,      :only => :index
-
-  #     get 'service_hooks',     :to => 'service_hooks#index'
-  #     put 'service_hooks/:id', :to => 'service_hooks#update', :id => /[\w-]*:[\w.-]*/
-  #   end
-
-  #   constraints :owner_name => /[^\/]+/, :name => /[^\/]+/ do
-  #     get ':owner_name/:name.json',            :to => 'repositories#show', :format => :json
-  #     get ':owner_name/:name/builds.json',     :to => 'builds#index',      :format => :json
-  #     get ':owner_name/:name/builds/:id.json', :to => 'builds#show',       :format => :json
-  #     get ':owner_name/:name.png',             :to => 'repositories#show', :format => :png
-  #     get ':owner_name/:name/cc.xml',          :to => 'repositories#show', :format => :xml, :schema => 'cctray'
-  #   end
-  # end
-
diff --git a/spec/integration/scopes_spec.rb b/spec/integration/scopes_spec.rb
index 8ab3d9de..b827d324 100644
--- a/spec/integration/scopes_spec.rb
+++ b/spec/integration/scopes_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe 'App' do
   before do
     FactoryGirl.create(:test, :number => '3.1', :queue => 'builds.common')
diff --git a/spec/integration/settings_endpoint_spec.rb b/spec/integration/settings_endpoint_spec.rb
index cc895029..e3a3efa1 100644
--- a/spec/integration/settings_endpoint_spec.rb
+++ b/spec/integration/settings_endpoint_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe Travis::Api::App::SettingsEndpoint do
   let(:repo)    { Repository.by_slug('svenfuchs/minimal').first }
   let(:headers) { { 'HTTP_ACCEPT' => 'application/vnd.travis-ci.2+json' } }
diff --git a/spec/integration/singleton_settings_endpoint_spec.rb b/spec/integration/singleton_settings_endpoint_spec.rb
index dd62100a..310e0e00 100644
--- a/spec/integration/singleton_settings_endpoint_spec.rb
+++ b/spec/integration/singleton_settings_endpoint_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe Travis::Api::App::SettingsEndpoint do
   let(:repo)    { Repository.by_slug('svenfuchs/minimal').first }
   let(:headers) { { 'HTTP_ACCEPT' => 'application/vnd.travis-ci.2+json' } }
diff --git a/spec/integration/uptime_spec.rb b/spec/integration/uptime_spec.rb
index 055e2166..9da3eadd 100644
--- a/spec/integration/uptime_spec.rb
+++ b/spec/integration/uptime_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe 'Uptime' do
+describe 'Uptime', set_app: true do
   after do
     ActiveRecord::Base.connection.unstub(:execute)
   end
diff --git a/spec/integration/v2/branches_spec.rb b/spec/integration/v2/branches_spec.rb
index 3e54ecc8..a10ce387 100644
--- a/spec/integration/v2/branches_spec.rb
+++ b/spec/integration/v2/branches_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe 'Branches' do
+describe 'Branches', set_app: true do
   let(:repo)    { Repository.by_slug('svenfuchs/minimal').first }
   let(:headers) { { 'HTTP_ACCEPT' => 'application/vnd.travis-ci.2+json' } }
 
diff --git a/spec/integration/v2/builds_spec.rb b/spec/integration/v2/builds_spec.rb
index e3f77141..5670c46a 100644
--- a/spec/integration/v2/builds_spec.rb
+++ b/spec/integration/v2/builds_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe 'Builds' do
+describe 'Builds', set_app: true do
   let(:repo)  { Repository.by_slug('svenfuchs/minimal').first }
   let(:build) { repo.builds.first }
   let(:headers) { { 'HTTP_ACCEPT' => 'application/vnd.travis-ci.2+json' } }
diff --git a/spec/integration/v2/hooks_spec.rb b/spec/integration/v2/hooks_spec.rb
index 29bfa977..403247c6 100644
--- a/spec/integration/v2/hooks_spec.rb
+++ b/spec/integration/v2/hooks_spec.rb
@@ -1,7 +1,6 @@
-require 'spec_helper'
 require 'travis/testing/payloads'
 
-describe 'Hooks' do
+describe 'Hooks', set_app: true do
   before(:each) do
     user.permissions.create repository: repo, admin: true
   end
diff --git a/spec/integration/v2/jobs_spec.rb b/spec/integration/v2/jobs_spec.rb
index 6b82a1a7..f618088e 100644
--- a/spec/integration/v2/jobs_spec.rb
+++ b/spec/integration/v2/jobs_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe 'Jobs' do
+describe 'Jobs', set_app: true do
   let!(:jobs) {[
     FactoryGirl.create(:test, :number => '3.1', :queue => 'builds.common'),
     FactoryGirl.create(:test, :number => '3.2', :queue => 'builds.common')
diff --git a/spec/integration/v2/repositories_spec.rb b/spec/integration/v2/repositories_spec.rb
index c3bbe09f..c4be1d74 100644
--- a/spec/integration/v2/repositories_spec.rb
+++ b/spec/integration/v2/repositories_spec.rb
@@ -1,7 +1,6 @@
 # encoding: utf-8
-require 'spec_helper'
 
-describe 'Repos' do
+describe 'Repos', set_app: true do
   let(:repo)    { Repository.by_slug('svenfuchs/minimal').first }
   let(:headers) { { 'HTTP_ACCEPT' => 'application/vnd.travis-ci.2+json' } }
 
@@ -31,12 +30,14 @@ describe 'Repos' do
     before { user.permissions.create!(:repository_id => repo.id, :admin => true, :push => true) }
 
     it 'POST /repos/:id/key' do
+      repo.regenerate_key!
       expect {
         response = post "/repos/#{repo.id}/key", {}, headers
       }.to change { repo.reload.key.private_key }
     end
 
     it 'POST /repos/:owner/:name/key' do
+      repo.regenerate_key!
       expect {
         response = post "/repos/#{repo.slug}/key", {}, headers
       }.to change { repo.reload.key.private_key }
@@ -86,11 +87,13 @@ describe 'Repos' do
   end
 
   it 'GET /repos/:id/key' do
+    repo.regenerate_key!
     response = get "/repos/#{repo.id}/key", {}, headers
     response.should deliver_json_for(repo.key, version: 'v2')
   end
 
   it 'GET /repos/:slug/key' do
+    repo.regenerate_key!
     response = get "/repos/#{repo.slug}/key", {}, headers
     response.should deliver_json_for(repo.key, version: 'v2')
   end
diff --git a/spec/integration/v2/requests_spec.rb b/spec/integration/v2/requests_spec.rb
index d786e396..0ed0b43f 100644
--- a/spec/integration/v2/requests_spec.rb
+++ b/spec/integration/v2/requests_spec.rb
@@ -1,7 +1,6 @@
-require 'spec_helper'
 require 'json'
 
-describe 'Requests' do
+describe 'Requests', set_app: true do
   let(:repo)    { Factory.create(:repository) }
   let(:request) { Factory.create(:request, repository: repo) }
   let(:user)    { Factory.create(:user) }
diff --git a/spec/integration/v2/settings/env_vars_spec.rb b/spec/integration/v2/settings/env_vars_spec.rb
index c7427211..36befea4 100644
--- a/spec/integration/v2/settings/env_vars_spec.rb
+++ b/spec/integration/v2/settings/env_vars_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe Travis::Api::App::SettingsEndpoint do
+describe Travis::Api::App::SettingsEndpoint, set_app: true do
   let(:repo)    { Repository.by_slug('svenfuchs/minimal').first }
   let(:headers) { { 'HTTP_ACCEPT' => 'application/vnd.travis-ci.2+json' } }
 
diff --git a/spec/integration/v2/settings/ssh_key_spec.rb b/spec/integration/v2/settings/ssh_key_spec.rb
index 9f7ae8d1..a2b628bb 100644
--- a/spec/integration/v2/settings/ssh_key_spec.rb
+++ b/spec/integration/v2/settings/ssh_key_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe 'ssh keys endpoint' do
+describe 'ssh keys endpoint', set_app: true do
   let(:repo)    { Factory(:repository) }
   let(:headers) { { 'HTTP_ACCEPT' => 'application/vnd.travis-ci.2+json' } }
 
diff --git a/spec/integration/v2/users_spec.rb b/spec/integration/v2/users_spec.rb
index 1653227e..ee80e1dd 100644
--- a/spec/integration/v2/users_spec.rb
+++ b/spec/integration/v2/users_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe 'Users' do
+describe 'Users', set_app: true do
   let(:user)    { User.first }
   let(:token)   { Travis::Api::App::AccessToken.create(user: user, app_id: -1) }
   let(:headers) { { 'HTTP_ACCEPT' => 'application/vnd.travis-ci.2+json', 'HTTP_AUTHORIZATION' => "token #{token}" } }
diff --git a/spec/integration/v2_spec.backup.rb b/spec/integration/v2_spec.backup.rb
index 78945d87..eb66981f 100644
--- a/spec/integration/v2_spec.backup.rb
+++ b/spec/integration/v2_spec.backup.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe 'v2' do
   let(:format)     { :json }
   let(:params)     { { :controller => controller, :action => action, :format => format } }
diff --git a/spec/integration/version_spec.rb b/spec/integration/version_spec.rb
index fcab65e9..717f2976 100644
--- a/spec/integration/version_spec.rb
+++ b/spec/integration/version_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe 'App' do
   before do
     add_endpoint '/foo' do
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 66d6ae0d..b414cfea 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,57 +1,28 @@
 ENV['RACK_ENV'] = ENV['RAILS_ENV'] = ENV['ENV'] = 'test'
 
-require 'support/coverage'
+require 'support/coverage' unless ENV['SKIP_COVERAGE']
 
 require 'rspec'
 require 'rspec/its'
 require 'database_cleaner'
-require 'sinatra/test_helpers'
 require 'logger'
 require 'gh'
 require 'multi_json'
+require 'pry'
+require 'stackprof'
 
 require 'travis/api/app'
 require 'travis/testing'
 require 'travis/testing/scenario'
 require 'travis/testing/factories'
 require 'travis/testing/matchers'
-require 'support/matchers'
 require 'support/formats'
-
-require 'pry'
-
-Travis.logger = Logger.new(StringIO.new)
-Travis::Api::App.setup
-Travis.config.client_domain = "www.example.com"
-Travis.config.endpoints.ssh_key = true
-
-module TestHelpers
-  include Sinatra::TestHelpers
-
-  def custom_endpoints
-    @custom_endpoints ||= []
-  end
-
-  def add_settings_endpoint(name, options = {})
-    if options[:singleton]
-      Travis::Api::App::SingletonSettingsEndpoint.subclass(name)
-    else
-      Travis::Api::App::SettingsEndpoint.subclass(name)
-    end
-    set_app Travis::Api::App.new
-  end
-
-  def add_endpoint(prefix, &block)
-    endpoint = Sinatra.new(Travis::Api::App::Endpoint, &block)
-    endpoint.set(prefix: prefix)
-    set_app Travis::Api::App.new
-    custom_endpoints << endpoint
-  end
-
-  def parsed_body
-    MultiJson.decode(body)
-  end
-end
+require 'support/gcs'
+require 'support/matchers'
+require 'support/payloads'
+require 'support/private_key'
+require 'support/s3'
+require 'support/test_helpers'
 
 RSpec.configure do |c|
   c.mock_framework = :mocha
@@ -59,52 +30,33 @@ RSpec.configure do |c|
   c.include TestHelpers
 
   c.before :suite do
-    DatabaseCleaner.strategy = :transaction
+    Travis.logger = Logger.new(StringIO.new)
+    Travis::Api::App.setup
+    Travis.config.client_domain = "www.example.com"
+    Travis.config.endpoints.ssh_key = true
+
     DatabaseCleaner.clean_with :truncation
+    DatabaseCleaner.strategy = :transaction
+
     Scenario.default
   end
 
   c.before :each do
     DatabaseCleaner.start
-    ::Redis.connect(url: Travis.config.redis.url).flushdb
-    Travis.config.oauth2 ||= {}
+    Redis.new.flushall
     Travis.config.oauth2.scope = "user:email,public_repo"
+    # set_app Travis::Api::App.new
+  end
+
+  c.before :each, set_app: true do
     set_app Travis::Api::App.new
   end
 
   c.after :each do
+    # puts DatabaseCleaner.connections.map(&:strategy).map(&:class).map(&:name).join(', ')
     DatabaseCleaner.clean
     custom_endpoints.each do |endpoint|
       endpoint.superclass.direct_subclasses.delete(endpoint)
     end
   end
 end
-
-TEST_PRIVATE_KEY = "-----BEGIN RSA PRIVATE KEY-----
-MIIEpAIBAAKCAQEA6Dm1n+fc0ILeLWeiwqsWs1MZaGAfccrmpvuxfcE9UaJp2POy
-079g+mdiBgtWfnQlU84YX31rU2x9GJwnb8G6UcvkEjqczOgHHmELtaNmrRH1g8qO
-fJpzXB8XiNib1L3TDs7qYMKLDCbl2bWrcO7Dol9bSqIeb7f9rzkCd4tuXObL3pMD
-/VIW5uzeVqLBAc0Er+qw6U7clnMnHHMekXt4JSRfauSCxktR2FzigoQbJc8t4iWO
-rmNi5Q84VkXB3X7PO/eajUw+RJOl6FnPN1Zh08ceqcqmSMM4RzeVQaczXg7P92P4
-mRF41R97jIJyzUGwheb2Z4Q2rltck4V7R5BvMwIDAQABAoIBAE4O3+MRH+MiqiXe
-+RGwSqAaZab08Hzic+dbIQ0hQEhJbITVXZ3ZbXKd/5ACjZ9R0R47X2vxj3rqM55r
-FsJ0/vjxrQcHlp81uvbWLgZvF1tDdyBGnOB7Vh14AgQoszCuYdxPZu8BVZXPGWG1
-tBvw1eelX91VYx+wW+BjLFYckws8kPCPY6WEnng0wQGShGqyTOJa1T4M1ethHYF+
-ddNx+fVLkEf2vL59popuJMOAyVa1jvU7D3VZ67qhlxWAvQxZeEP0vFZHeWPjvRF1
-orxiGuwLCG+Rgq1XSVJjMNf1qE3gZTlDg+u3ORKbRx2xlhiqpkHxLx7QtCmELwtD
-Dqvf8ukCgYEA/SoQwyfMp4t19FLI4tV0rp3Yn7ZSAqRtMVrLVAIQoJzDXv9BaJFS
-xb6enxRAjy+Rg10H8ijh8Z9Z3a4g3JViHQsWMrf9rL2/7M07vraIUIQoVo7yTeGa
-MXnTuKmBZFGEAM9CzqAVao1Om10TRFNLgiLAU3ZEFi8J1DYWkhzrJp0CgYEA6tOa
-V15MP3sJSlOTszshXKbwf6iXfjHbdpGUXmd9X3AMzOvl/CEGS2q46lwJISubHWKF
-BOKk1thumM4Zu6dx89hLEoXhFycgUV/KJYl54ZfhY079Ri7SZUYIqDR04BRJC2d6
-mO16Y//UwqgTaZ/lS/S791iWPTjVNEgSlRbQHA8CgYALiOEeoy+V6qrDKQpyG1un
-oRV/oWT3LdqzxvlAqJ9tUfcs2uB2DTkCPX8orFmMrJQqshBsniQ9SA9mJErnAf9o
-Z1rpkKyENFkMRwWT2Ok5EexslTLBDahi3LQi08ZLddNX3hmjJHQVWL7eIU2BbXIh
-ScgNhXPwts/x1U0N9zdXmQKBgQC4O6W2cAQQNd5XEvUpQ/XrtAmxjjq0xjbxckve
-OQFy0/0m9NiuE9bVaniDXgvHm2eKCVZlO8+pw4oZlnE3+an8brCParvrJ0ZCsY1u
-H8qgxEEPYdRxsKBe1jBKj0U23JNmQBw+SOqh9AAfbDA2yTzjd7HU4AqXI7SZ3QW/
-NHO33wKBgQCqxUmocyqKy5NEBPMmeHWapuSY47bdDaE139vRWV6M47oxzxF8QnQV
-1TGWsshK04QO8wsfzIa9/SjZkU17QVkz7LXbq4hPmiZjhP/H+roCeoDEyHFdkq6B
-bm/edpYemlJlQhEYtecwvD57NZbVuaqX4Culz9WdSsw4I56hD+QjHQ==
------END RSA PRIVATE KEY-----
-"
diff --git a/spec/spec_helper_core.rb b/spec/spec_helper_core.rb
deleted file mode 100644
index 47aea2e9..00000000
--- a/spec/spec_helper_core.rb
+++ /dev/null
@@ -1,59 +0,0 @@
-ENV['RAILS_ENV'] = ENV['ENV'] = 'test'
-
-require 'simplecov' unless RUBY_ENGINE == 'jruby'
-
-RSpec.configure do |c|
-  c.before(:each) { Time.now.utc.tap { | now| Time.stubs(:now).returns(now) } }
-end
-
-require 'support'
-
-require 'travis'
-
-require 'travis/model'
-require 'travis/states_cache'
-require 'travis/testing'
-
-require 'travis/support'
-require 'travis/testing/matchers'
-
-require 'gh'
-require 'mocha/api'
-require 'stringio'
-require 'logger'
-require 'patches/rspec_hash_diff'
-
-Travis.logger = Logger.new(StringIO.new)
-Travis.services = Travis::Services
-ActionMailer::Base.delivery_method = :test
-
-include Mocha::API
-
-RSpec.configure do |c|
-  c.mock_with :mocha
-  c.alias_example_to :fit, :focused => true
-  c.filter_run :focus => true
-  c.run_all_when_everything_filtered = true
-  # c.backtrace_clean_patterns.clear
-
-  c.before :each do
-    Travis.logger.level = Logger::INFO
-    Travis::Event.instance_variable_set(:@queues, nil)
-    Travis::Event.instance_variable_set(:@subscriptions, nil)
-    Travis::Event.stubs(:subscribers).returns []
-    Travis.config.oauth2 ||= {}
-    Travis.config.oauth2.scope = 'public_repo,user'
-    Travis.config.repository.ssl_key.size = 1024
-    Travis::Github.stubs(:scopes_for).returns(['public_repo', 'user'])
-    GH.reset
-  end
-end
-
-# this keeps Model.inspect from exploding which happens for
-# expected method calls in tests that do not use a db connection
-require 'active_record'
-ActiveRecord::Base.class_eval do
-  def self.inspect
-    super
-  end
-end
diff --git a/spec/support/private_key.rb b/spec/support/private_key.rb
new file mode 100644
index 00000000..c0216264
--- /dev/null
+++ b/spec/support/private_key.rb
@@ -0,0 +1,28 @@
+TEST_PRIVATE_KEY = "-----BEGIN RSA PRIVATE KEY-----
+MIIEpAIBAAKCAQEA6Dm1n+fc0ILeLWeiwqsWs1MZaGAfccrmpvuxfcE9UaJp2POy
+079g+mdiBgtWfnQlU84YX31rU2x9GJwnb8G6UcvkEjqczOgHHmELtaNmrRH1g8qO
+fJpzXB8XiNib1L3TDs7qYMKLDCbl2bWrcO7Dol9bSqIeb7f9rzkCd4tuXObL3pMD
+/VIW5uzeVqLBAc0Er+qw6U7clnMnHHMekXt4JSRfauSCxktR2FzigoQbJc8t4iWO
+rmNi5Q84VkXB3X7PO/eajUw+RJOl6FnPN1Zh08ceqcqmSMM4RzeVQaczXg7P92P4
+mRF41R97jIJyzUGwheb2Z4Q2rltck4V7R5BvMwIDAQABAoIBAE4O3+MRH+MiqiXe
++RGwSqAaZab08Hzic+dbIQ0hQEhJbITVXZ3ZbXKd/5ACjZ9R0R47X2vxj3rqM55r
+FsJ0/vjxrQcHlp81uvbWLgZvF1tDdyBGnOB7Vh14AgQoszCuYdxPZu8BVZXPGWG1
+tBvw1eelX91VYx+wW+BjLFYckws8kPCPY6WEnng0wQGShGqyTOJa1T4M1ethHYF+
+ddNx+fVLkEf2vL59popuJMOAyVa1jvU7D3VZ67qhlxWAvQxZeEP0vFZHeWPjvRF1
+orxiGuwLCG+Rgq1XSVJjMNf1qE3gZTlDg+u3ORKbRx2xlhiqpkHxLx7QtCmELwtD
+Dqvf8ukCgYEA/SoQwyfMp4t19FLI4tV0rp3Yn7ZSAqRtMVrLVAIQoJzDXv9BaJFS
+xb6enxRAjy+Rg10H8ijh8Z9Z3a4g3JViHQsWMrf9rL2/7M07vraIUIQoVo7yTeGa
+MXnTuKmBZFGEAM9CzqAVao1Om10TRFNLgiLAU3ZEFi8J1DYWkhzrJp0CgYEA6tOa
+V15MP3sJSlOTszshXKbwf6iXfjHbdpGUXmd9X3AMzOvl/CEGS2q46lwJISubHWKF
+BOKk1thumM4Zu6dx89hLEoXhFycgUV/KJYl54ZfhY079Ri7SZUYIqDR04BRJC2d6
+mO16Y//UwqgTaZ/lS/S791iWPTjVNEgSlRbQHA8CgYALiOEeoy+V6qrDKQpyG1un
+oRV/oWT3LdqzxvlAqJ9tUfcs2uB2DTkCPX8orFmMrJQqshBsniQ9SA9mJErnAf9o
+Z1rpkKyENFkMRwWT2Ok5EexslTLBDahi3LQi08ZLddNX3hmjJHQVWL7eIU2BbXIh
+ScgNhXPwts/x1U0N9zdXmQKBgQC4O6W2cAQQNd5XEvUpQ/XrtAmxjjq0xjbxckve
+OQFy0/0m9NiuE9bVaniDXgvHm2eKCVZlO8+pw4oZlnE3+an8brCParvrJ0ZCsY1u
+H8qgxEEPYdRxsKBe1jBKj0U23JNmQBw+SOqh9AAfbDA2yTzjd7HU4AqXI7SZ3QW/
+NHO33wKBgQCqxUmocyqKy5NEBPMmeHWapuSY47bdDaE139vRWV6M47oxzxF8QnQV
+1TGWsshK04QO8wsfzIa9/SjZkU17QVkz7LXbq4hPmiZjhP/H+roCeoDEyHFdkq6B
+bm/edpYemlJlQhEYtecwvD57NZbVuaqX4Culz9WdSsw4I56hD+QjHQ==
+-----END RSA PRIVATE KEY-----
+"
diff --git a/spec/support/test_helpers.rb b/spec/support/test_helpers.rb
new file mode 100644
index 00000000..7a0989f3
--- /dev/null
+++ b/spec/support/test_helpers.rb
@@ -0,0 +1,29 @@
+require 'sinatra/test_helpers'
+
+module TestHelpers
+  include Sinatra::TestHelpers
+
+  def custom_endpoints
+    @custom_endpoints ||= []
+  end
+
+  def add_settings_endpoint(name, options = {})
+    if options[:singleton]
+      Travis::Api::App::SingletonSettingsEndpoint.subclass(name)
+    else
+      Travis::Api::App::SettingsEndpoint.subclass(name)
+    end
+    set_app Travis::Api::App.new
+  end
+
+  def add_endpoint(prefix, &block)
+    endpoint = Sinatra.new(Travis::Api::App::Endpoint, &block)
+    endpoint.set(prefix: prefix)
+    set_app Travis::Api::App.new
+    custom_endpoints << endpoint
+  end
+
+  def parsed_body
+    MultiJson.decode(body)
+  end
+end
diff --git a/spec/unit/access_token_spec.rb b/spec/unit/access_token_spec.rb
index 41017245..05a2fc9b 100644
--- a/spec/unit/access_token_spec.rb
+++ b/spec/unit/access_token_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe Travis::Api::App::AccessToken do
   it 'errors out on wrong type of :expires_in argument' do
     expect {
diff --git a/spec/unit/app_spec.rb b/spec/unit/app_spec.rb
index 1c3394c2..f59cad7b 100644
--- a/spec/unit/app_spec.rb
+++ b/spec/unit/app_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe Travis::Api::App do
   describe :setup? do
     it 'indicates if #setup has been called' do
diff --git a/spec/unit/cors_spec.rb b/spec/unit/cors_spec.rb
index a1e5e994..eb90a7a0 100644
--- a/spec/unit/cors_spec.rb
+++ b/spec/unit/cors_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe Travis::Api::App::Cors do
   before do
     mock_app do
diff --git a/spec/unit/default_spec.rb b/spec/unit/default_spec.rb
index 98e0df3b..7fc33238 100644
--- a/spec/unit/default_spec.rb
+++ b/spec/unit/default_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe Travis::Api::App::Endpoint::Home do
+describe Travis::Api::App::Endpoint::Home, set_app: true do
   describe 'GET /' do
     it 'replies with a json response by default' do
       get('/')["Content-Type"].should include("json")
diff --git a/spec/unit/endpoint/accounts_spec.rb b/spec/unit/endpoint/accounts_spec.rb
index dd74059e..034b7dbc 100644
--- a/spec/unit/endpoint/accounts_spec.rb
+++ b/spec/unit/endpoint/accounts_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe Travis::Api::App::Endpoint::Accounts do
+describe Travis::Api::App::Endpoint::Accounts, set_app: true do
   include Travis::Testing::Stubs
   let(:access_token) { Travis::Api::App::AccessToken.create(user: user, app_id: -1) }
 
diff --git a/spec/unit/endpoint/authorization/user_manager_spec.rb b/spec/unit/endpoint/authorization/user_manager_spec.rb
index 4b5b5c04..0dd28728 100644
--- a/spec/unit/endpoint/authorization/user_manager_spec.rb
+++ b/spec/unit/endpoint/authorization/user_manager_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe Travis::Api::App::Endpoint::Authorization::UserManager do
   let(:manager) { described_class.new(data, 'abc123') }
 
diff --git a/spec/unit/endpoint/authorization_spec.rb b/spec/unit/endpoint/authorization_spec.rb
index 2634968c..5ca8b830 100644
--- a/spec/unit/endpoint/authorization_spec.rb
+++ b/spec/unit/endpoint/authorization_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe Travis::Api::App::Endpoint::Authorization do
   include Travis::Testing::Stubs
 
diff --git a/spec/unit/endpoint/branches_spec.rb b/spec/unit/endpoint/branches_spec.rb
index 03923cfd..30b78137 100644
--- a/spec/unit/endpoint/branches_spec.rb
+++ b/spec/unit/endpoint/branches_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe Travis::Api::App::Endpoint::Branches do
   it 'has to be tested'
 end
diff --git a/spec/unit/endpoint/builds_spec.rb b/spec/unit/endpoint/builds_spec.rb
index 1c7654e8..387a1fac 100644
--- a/spec/unit/endpoint/builds_spec.rb
+++ b/spec/unit/endpoint/builds_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe Travis::Api::App::Endpoint::Builds do
+describe Travis::Api::App::Endpoint::Builds, set_app: true do
   include Travis::Testing::Stubs
 
   it 'works with default options' do
@@ -38,5 +36,5 @@ describe Travis::Api::App::Endpoint::Builds do
       end
     end
   end
-  
+
 end
diff --git a/spec/unit/endpoint/endpoints_spec.rb b/spec/unit/endpoint/endpoints_spec.rb
index 6676ef3b..2b3b17e7 100644
--- a/spec/unit/endpoint/endpoints_spec.rb
+++ b/spec/unit/endpoint/endpoints_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe Travis::Api::App::Endpoint::Endpoints do
   it 'has to be tested'
 end
diff --git a/spec/unit/endpoint/hooks_spec.rb b/spec/unit/endpoint/hooks_spec.rb
index e9c9af1e..60d6d8ef 100644
--- a/spec/unit/endpoint/hooks_spec.rb
+++ b/spec/unit/endpoint/hooks_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe Travis::Api::App::Endpoint::Hooks do
   it 'has to be tested'
 end
diff --git a/spec/unit/endpoint/jobs_spec.rb b/spec/unit/endpoint/jobs_spec.rb
index ca9e143c..fd8de64e 100644
--- a/spec/unit/endpoint/jobs_spec.rb
+++ b/spec/unit/endpoint/jobs_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe Travis::Api::App::Endpoint::Jobs do
+describe Travis::Api::App::Endpoint::Jobs, set_app: true do
   let(:job) { Factory(:test) }
   let(:provider) { Factory(:annotation_provider) }
 
diff --git a/spec/unit/endpoint/lint_spec.rb b/spec/unit/endpoint/lint_spec.rb
index 025130de..e96861d6 100644
--- a/spec/unit/endpoint/lint_spec.rb
+++ b/spec/unit/endpoint/lint_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe Travis::Api::App::Endpoint::Lint do
+describe Travis::Api::App::Endpoint::Lint, set_app: true do
   let(:content) { "foo: bar" }
   let(:body) { "{\"lint\":{\"warnings\":[{\"key\":[],\"message\":\"unexpected key \\\"foo\\\", dropping\"},{\"key\":[],\"message\":\"missing key \\\"language\\\", defaulting to \\\"ruby\\\"\"}]}}" }
 
diff --git a/spec/unit/endpoint/logs_spec.rb b/spec/unit/endpoint/logs_spec.rb
index 7f13049f..216dd3b4 100644
--- a/spec/unit/endpoint/logs_spec.rb
+++ b/spec/unit/endpoint/logs_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe Travis::Api::App::Endpoint::Logs do
+describe Travis::Api::App::Endpoint::Logs, set_app: true do
   let(:job)  { Factory(:test) }
 
   describe "GET /logs/:id/" do
diff --git a/spec/unit/endpoint/repos_spec.rb b/spec/unit/endpoint/repos_spec.rb
index 67dc5d89..61f5f9aa 100644
--- a/spec/unit/endpoint/repos_spec.rb
+++ b/spec/unit/endpoint/repos_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe Travis::Api::App::Endpoint::Repos do
+describe Travis::Api::App::Endpoint::Repos, set_app: true do
   before do
     described_class.get('/spec/match/:id')   { "id"   }
     described_class.get('/spec/match/:name') { "name" }
diff --git a/spec/unit/endpoint/requests/throttle_spec.rb b/spec/unit/endpoint/requests/throttle_spec.rb
index b0d0470a..bdd2e0d7 100644
--- a/spec/unit/endpoint/requests/throttle_spec.rb
+++ b/spec/unit/endpoint/requests/throttle_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe Travis::Api::App::Services::ScheduleRequest::Throttle do
   let(:repo) { Factory(:repository) }
   subject    { described_class.new(repo.slug) }
diff --git a/spec/unit/endpoint/users_spec.rb b/spec/unit/endpoint/users_spec.rb
index 7af2ac06..140c0119 100644
--- a/spec/unit/endpoint/users_spec.rb
+++ b/spec/unit/endpoint/users_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe Travis::Api::App::Endpoint::Users do
+describe Travis::Api::App::Endpoint::Users, set_app: true do
   include Travis::Testing::Stubs
   let(:access_token) { Travis::Api::App::AccessToken.create(user: user, app_id: -1) }
 
diff --git a/spec/unit/endpoint_spec.rb b/spec/unit/endpoint_spec.rb
index d5a01f6b..3878e8a6 100644
--- a/spec/unit/endpoint_spec.rb
+++ b/spec/unit/endpoint_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe Travis::Api::App::Endpoint do
+describe Travis::Api::App::Endpoint, set_app: true do
   class MyEndpoint < Travis::Api::App::Endpoint
     set :prefix, '/my_endpoint'
     get('/') { 'ok' }
diff --git a/spec/unit/extensions/expose_pattern_spec.rb b/spec/unit/extensions/expose_pattern_spec.rb
index 1952665d..21743abf 100644
--- a/spec/unit/extensions/expose_pattern_spec.rb
+++ b/spec/unit/extensions/expose_pattern_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 class Foo < Sinatra::Base
   register Travis::Api::App::Extensions::ExposePattern
 
@@ -20,4 +18,4 @@ describe Travis::Api::App::Extensions::ExposePattern do
     get('/foo').should be_ok
     headers['X-Endpoint'].should be == 'Foo'
   end
-end
\ No newline at end of file
+end
diff --git a/spec/unit/extensions/scoping_spec.rb b/spec/unit/extensions/scoping_spec.rb
index 80e1152a..84296c1b 100644
--- a/spec/unit/extensions/scoping_spec.rb
+++ b/spec/unit/extensions/scoping_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe Travis::Api::App::Extensions::Scoping do
   include Travis::Testing::Stubs
 
diff --git a/spec/unit/extensions/smart_constants_spec.rb b/spec/unit/extensions/smart_constants_spec.rb
index 5b8ada59..fade61ce 100644
--- a/spec/unit/extensions/smart_constants_spec.rb
+++ b/spec/unit/extensions/smart_constants_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe Travis::Api::App::Extensions::SmartConstants do
   let(:some_app) do
     Sinatra.new { register Travis::Api::App::Extensions::SmartConstants }
diff --git a/spec/unit/extensions/subclass_tracker_spec.rb b/spec/unit/extensions/subclass_tracker_spec.rb
index 181d2d15..f4afaae4 100644
--- a/spec/unit/extensions/subclass_tracker_spec.rb
+++ b/spec/unit/extensions/subclass_tracker_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe Travis::Api::App::Extensions::SubclassTracker do
   let!(:root) { Sinatra.new { register Travis::Api::App::Extensions::SubclassTracker } }
   let!(:left) { Class.new(root) }
diff --git a/spec/unit/helpers/accept_spec.rb b/spec/unit/helpers/accept_spec.rb
index 6c32ef87..6f15d6dc 100644
--- a/spec/unit/helpers/accept_spec.rb
+++ b/spec/unit/helpers/accept_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 module Travis::Api::App::Helpers
   describe Accept do
     class FakeApp < Struct.new(:env)
diff --git a/spec/unit/helpers/json_renderer_spec.rb b/spec/unit/helpers/json_renderer_spec.rb
index bbb7b606..43d22f47 100644
--- a/spec/unit/helpers/json_renderer_spec.rb
+++ b/spec/unit/helpers/json_renderer_spec.rb
@@ -1,4 +1,3 @@
-require 'spec_helper'
 require 'json'
 
 # describe Travis::Api::App::Helpers::JsonRenderer do
diff --git a/spec/unit/middleware/logging_spec.rb b/spec/unit/middleware/logging_spec.rb
index a530d77b..48fdbf7a 100644
--- a/spec/unit/middleware/logging_spec.rb
+++ b/spec/unit/middleware/logging_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe Travis::Api::App::Middleware::Logging do
   it 'configures ActiveRecord' do
     ActiveRecord::Base.logger.should == Travis.logger
diff --git a/spec/unit/middleware/scope_check_spec.rb b/spec/unit/middleware/scope_check_spec.rb
index f8307ee3..2677faeb 100644
--- a/spec/unit/middleware/scope_check_spec.rb
+++ b/spec/unit/middleware/scope_check_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe Travis::Api::App::Middleware::ScopeCheck do
   include Travis::Testing::Stubs
 
@@ -83,4 +81,4 @@ describe Travis::Api::App::Middleware::ScopeCheck do
     authorize access_token.to_s, 'x'
     get('/token').body.should == access_token.to_s
   end
-end
\ No newline at end of file
+end
diff --git a/spec/unit/middleware/user_agent_tracker_spec.rb b/spec/unit/middleware/user_agent_tracker_spec.rb
index 1e5ebe00..4c9d74df 100644
--- a/spec/unit/middleware/user_agent_tracker_spec.rb
+++ b/spec/unit/middleware/user_agent_tracker_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe Travis::Api::App::Middleware::UserAgentTracker do
   before do
     mock_app do
diff --git a/spec/unit/responders/json_spec.rb b/spec/unit/responders/json_spec.rb
index c6b934d1..4e421694 100644
--- a/spec/unit/responders/json_spec.rb
+++ b/spec/unit/responders/json_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 module Travis::Api::App::Responders
   describe Json do
     class MyJson < Json
diff --git a/spec/unit/responders/service_spec.rb b/spec/unit/responders/service_spec.rb
index 5ee9412f..9de700f3 100644
--- a/spec/unit/responders/service_spec.rb
+++ b/spec/unit/responders/service_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe Travis::Api::App::Responders::Service do
   class MyService < Travis::Api::App::Responders::Service
   end
diff --git a/spec/unit/serialize/v2/http/accounts_spec.rb b/spec/unit/serialize/v2/http/accounts_spec.rb
index acd17699..2591ff12 100644
--- a/spec/unit/serialize/v2/http/accounts_spec.rb
+++ b/spec/unit/serialize/v2/http/accounts_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe Travis::Api::Serialize::V2::Http::Accounts do
   include Travis::Testing::Stubs, Support::Formats
 
diff --git a/spec/unit/serialize/v2/http/annotations_spec.rb b/spec/unit/serialize/v2/http/annotations_spec.rb
index 995a2b94..1e3d815e 100644
--- a/spec/unit/serialize/v2/http/annotations_spec.rb
+++ b/spec/unit/serialize/v2/http/annotations_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe Travis::Api::Serialize::V2::Http::Annotations do
   include Travis::Testing::Stubs, Support::Formats
 
diff --git a/spec/unit/serialize/v2/http/branch_spec.rb b/spec/unit/serialize/v2/http/branch_spec.rb
index 68c37b98..c3e2cc68 100644
--- a/spec/unit/serialize/v2/http/branch_spec.rb
+++ b/spec/unit/serialize/v2/http/branch_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe Travis::Api::Serialize::V2::Http::Branch do
   include Travis::Testing::Stubs, Support::Formats
 
diff --git a/spec/unit/serialize/v2/http/branches_spec.rb b/spec/unit/serialize/v2/http/branches_spec.rb
index 0e560f64..baf66501 100644
--- a/spec/unit/serialize/v2/http/branches_spec.rb
+++ b/spec/unit/serialize/v2/http/branches_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe Travis::Api::Serialize::V2::Http::Branches do
   include Travis::Testing::Stubs, Support::Formats
 
diff --git a/spec/unit/serialize/v2/http/broadcasts_spec.rb b/spec/unit/serialize/v2/http/broadcasts_spec.rb
index 85ed3fe9..9d7e93ae 100644
--- a/spec/unit/serialize/v2/http/broadcasts_spec.rb
+++ b/spec/unit/serialize/v2/http/broadcasts_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe Travis::Api::Serialize::V2::Http::Broadcasts do
   include Support::Formats
 
diff --git a/spec/unit/serialize/v2/http/build_spec.rb b/spec/unit/serialize/v2/http/build_spec.rb
index d9558f8b..c21be563 100644
--- a/spec/unit/serialize/v2/http/build_spec.rb
+++ b/spec/unit/serialize/v2/http/build_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe Travis::Api::Serialize::V2::Http::Build do
   include Travis::Testing::Stubs, Support::Formats
 
diff --git a/spec/unit/serialize/v2/http/builds_spec.rb b/spec/unit/serialize/v2/http/builds_spec.rb
index 3a587257..9946e099 100644
--- a/spec/unit/serialize/v2/http/builds_spec.rb
+++ b/spec/unit/serialize/v2/http/builds_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe Travis::Api::Serialize::V2::Http::Builds do
   include Travis::Testing::Stubs, Support::Formats
 
diff --git a/spec/unit/serialize/v2/http/caches_spec.rb b/spec/unit/serialize/v2/http/caches_spec.rb
index 0fd41c89..97d80c24 100644
--- a/spec/unit/serialize/v2/http/caches_spec.rb
+++ b/spec/unit/serialize/v2/http/caches_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe Travis::Api::Serialize::V2::Http::Caches do
   include Travis::Testing::Stubs, Support::Formats
   let(:data) { described_class.new([cache]).data }
diff --git a/spec/unit/serialize/v2/http/env_var_spec.rb b/spec/unit/serialize/v2/http/env_var_spec.rb
index f5510f36..8d997aba 100644
--- a/spec/unit/serialize/v2/http/env_var_spec.rb
+++ b/spec/unit/serialize/v2/http/env_var_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe Travis::Api::Serialize::V2::Http::EnvVar do
   let(:env_var) { Repository::Settings::EnvVar.new(name: 'FOO', value: 'bar', public: true) }
   let(:data) { described_class.new(env_var) }
diff --git a/spec/unit/serialize/v2/http/hooks_spec.rb b/spec/unit/serialize/v2/http/hooks_spec.rb
index f084e849..bdcaac69 100644
--- a/spec/unit/serialize/v2/http/hooks_spec.rb
+++ b/spec/unit/serialize/v2/http/hooks_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe Travis::Api::Serialize::V2::Http::Hooks do
   include Travis::Testing::Stubs
 
diff --git a/spec/unit/serialize/v2/http/job_spec.rb b/spec/unit/serialize/v2/http/job_spec.rb
index d8c0fcf9..416cb7a4 100644
--- a/spec/unit/serialize/v2/http/job_spec.rb
+++ b/spec/unit/serialize/v2/http/job_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe Travis::Api::Serialize::V2::Http::Job do
   include Travis::Testing::Stubs, Support::Formats
 
diff --git a/spec/unit/serialize/v2/http/jobs_spec.rb b/spec/unit/serialize/v2/http/jobs_spec.rb
index ef9a11d8..7b78c9f8 100644
--- a/spec/unit/serialize/v2/http/jobs_spec.rb
+++ b/spec/unit/serialize/v2/http/jobs_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe Travis::Api::Serialize::V2::Http::Jobs do
   include Travis::Testing::Stubs, Support::Formats
 
diff --git a/spec/unit/serialize/v2/http/log_spec.rb b/spec/unit/serialize/v2/http/log_spec.rb
index 5ea45cf1..7c3d28f3 100644
--- a/spec/unit/serialize/v2/http/log_spec.rb
+++ b/spec/unit/serialize/v2/http/log_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe Travis::Api::Serialize::V2::Http::Log do
   include Travis::Testing::Stubs
 
diff --git a/spec/unit/serialize/v2/http/permissions_spec.rb b/spec/unit/serialize/v2/http/permissions_spec.rb
index 0eb7ba7f..38574e3d 100644
--- a/spec/unit/serialize/v2/http/permissions_spec.rb
+++ b/spec/unit/serialize/v2/http/permissions_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe Travis::Api::Serialize::V2::Http::Permissions do
   include Travis::Testing::Stubs
 
diff --git a/spec/unit/serialize/v2/http/repositories_spec.rb b/spec/unit/serialize/v2/http/repositories_spec.rb
index 35f212fb..42905dc3 100644
--- a/spec/unit/serialize/v2/http/repositories_spec.rb
+++ b/spec/unit/serialize/v2/http/repositories_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe Travis::Api::Serialize::V2::Http::Repositories do
   include Travis::Testing::Stubs, Support::Formats
 
diff --git a/spec/unit/serialize/v2/http/repository_spec.rb b/spec/unit/serialize/v2/http/repository_spec.rb
index 7597daca..eaed102b 100644
--- a/spec/unit/serialize/v2/http/repository_spec.rb
+++ b/spec/unit/serialize/v2/http/repository_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe Travis::Api::Serialize::V2::Http::Repository do
   include Travis::Testing::Stubs
   include Support::Formats
diff --git a/spec/unit/serialize/v2/http/request_spec.rb b/spec/unit/serialize/v2/http/request_spec.rb
index 5d604dc7..5ac5987f 100644
--- a/spec/unit/serialize/v2/http/request_spec.rb
+++ b/spec/unit/serialize/v2/http/request_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe Travis::Api::Serialize::V2::Http::Request do
   include Travis::Testing::Stubs, Support::Formats
 
diff --git a/spec/unit/serialize/v2/http/requests_spec.rb b/spec/unit/serialize/v2/http/requests_spec.rb
index 130eedf9..1f57d5a4 100644
--- a/spec/unit/serialize/v2/http/requests_spec.rb
+++ b/spec/unit/serialize/v2/http/requests_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe Travis::Api::Serialize::V2::Http::Requests do
   include Travis::Testing::Stubs, Support::Formats
 
diff --git a/spec/unit/serialize/v2/http/ssl_key_spec.rb b/spec/unit/serialize/v2/http/ssl_key_spec.rb
index c2c3918e..0bd6da21 100644
--- a/spec/unit/serialize/v2/http/ssl_key_spec.rb
+++ b/spec/unit/serialize/v2/http/ssl_key_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe Travis::Api::Serialize::V2::Http::SslKey do
   include Travis::Testing::Stubs
   include Support::Formats
diff --git a/spec/unit/serialize/v2/http/user_spec.rb b/spec/unit/serialize/v2/http/user_spec.rb
index 8bb5d4ae..45b58fca 100644
--- a/spec/unit/serialize/v2/http/user_spec.rb
+++ b/spec/unit/serialize/v2/http/user_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe Travis::Api::Serialize::V2::Http::User do
   include Travis::Testing::Stubs, Support::Formats
 
diff --git a/spec/v3/error_handling_spec.rb b/spec/v3/error_handling_spec.rb
index b86bf917..bbca73f4 100644
--- a/spec/v3/error_handling_spec.rb
+++ b/spec/v3/error_handling_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe Travis::API::V3::ServiceIndex do
+describe Travis::API::V3::ServiceIndex, set_app: true do
   let(:headers) {{  }}
   let(:path)      { "/v3/repo/1/enable"         }
   let(:json)      { JSON.load(response.body) }
diff --git a/spec/v3/extensions/belongs_to_spec.rb b/spec/v3/extensions/belongs_to_spec.rb
index 8ed9d92a..047a726c 100644
--- a/spec/v3/extensions/belongs_to_spec.rb
+++ b/spec/v3/extensions/belongs_to_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe Travis::API::V3::Extensions::BelongsTo do
   describe 'reading polymorphic relation' do
     subject(:repo) { Travis::API::V3::Models::Repository.first }
diff --git a/spec/v3/metrics_spec.rb b/spec/v3/metrics_spec.rb
index a5afe054..4acf0dd9 100644
--- a/spec/v3/metrics_spec.rb
+++ b/spec/v3/metrics_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe Travis::API::V3::Metrics do
   class TestProcessor
     attr_reader :times, :marks, :queue
diff --git a/spec/v3/models/cron_spec.rb b/spec/v3/models/cron_spec.rb
index 0ce18c94..cbbac817 100644
--- a/spec/v3/models/cron_spec.rb
+++ b/spec/v3/models/cron_spec.rb
@@ -1,4 +1,3 @@
-require 'spec_helper'
 require 'timecop'
 
 describe Travis::API::V3::Models::Cron do
diff --git a/spec/v3/queries/cron_spec.rb b/spec/v3/queries/cron_spec.rb
index bb4c559a..9a995d46 100644
--- a/spec/v3/queries/cron_spec.rb
+++ b/spec/v3/queries/cron_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe Travis::API::V3::Queries::Crons do
   let(:user) { Travis::API::V3::Models::User.find_by_login('svenfuchs') }
   let(:repo) { Travis::API::V3::Models::Repository.where(owner_name: 'svenfuchs', name: 'minimal').first }
diff --git a/spec/v3/renderer/avatar_url_spec.rb b/spec/v3/renderer/avatar_url_spec.rb
index e8c84b69..1fb1ffa9 100644
--- a/spec/v3/renderer/avatar_url_spec.rb
+++ b/spec/v3/renderer/avatar_url_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe Travis::API::V3::Renderer::AvatarURL do
   let(:object) { Object.new }
   subject { Travis::API::V3::Renderer::AvatarURL.avatar_url(object) }
diff --git a/spec/v3/result_spec.rb b/spec/v3/result_spec.rb
index 360d686c..a5083b7d 100644
--- a/spec/v3/result_spec.rb
+++ b/spec/v3/result_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe Travis::API::V3::Result do
   let(:access_control) { Object.new }
   subject(:result) { described_class.new(access_control, :example, []) }
diff --git a/spec/v3/service_index_spec.rb b/spec/v3/service_index_spec.rb
index 74c4ce69..68f2bab9 100644
--- a/spec/v3/service_index_spec.rb
+++ b/spec/v3/service_index_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe Travis::API::V3::ServiceIndex do
+describe Travis::API::V3::ServiceIndex, set_app: true do
   let(:headers)   {{                        }}
   let(:path)      { '/'                      }
   let(:json)      { JSON.load(response.body) }
diff --git a/spec/v3/services/accounts/for_current_user_spec.rb b/spec/v3/services/accounts/for_current_user_spec.rb
index e81a4f59..d36dcd92 100644
--- a/spec/v3/services/accounts/for_current_user_spec.rb
+++ b/spec/v3/services/accounts/for_current_user_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe Travis::API::V3::Services::Accounts::ForCurrentUser do
+describe Travis::API::V3::Services::Accounts::ForCurrentUser, set_app: true do
   let(:repo) { Travis::API::V3::Models::Repository.where(owner_name: 'svenfuchs', name: 'minimal').first }
 
   let(:token)   { Travis::Api::App::AccessToken.create(user: repo.owner, app_id: 1) }
diff --git a/spec/v3/services/branch/find_spec.rb b/spec/v3/services/branch/find_spec.rb
index 702fb324..199716b9 100644
--- a/spec/v3/services/branch/find_spec.rb
+++ b/spec/v3/services/branch/find_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe Travis::API::V3::Services::Repository::Find do
+describe Travis::API::V3::Services::Repository::Find, set_app: true do
   let(:repo)  { Travis::API::V3::Models::Repository.where(owner_name: 'svenfuchs', name: 'minimal').first }
   let(:build) { repo.builds.first }
   let(:jobs)  { Travis::API::V3::Models::Build.find(build.id).jobs }
diff --git a/spec/v3/services/branches/find_spec.rb b/spec/v3/services/branches/find_spec.rb
index 3a930db5..02f0cbc7 100644
--- a/spec/v3/services/branches/find_spec.rb
+++ b/spec/v3/services/branches/find_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe Travis::API::V3::Services::Branches::Find do
+describe Travis::API::V3::Services::Branches::Find, set_app: true do
   let(:repo)   { Travis::API::V3::Models::Repository.where(owner_name: 'svenfuchs', name: 'minimal').first }
   let(:branch) { Travis::API::V3::Models::Branch.where(repository_id: repo.id).first }
   let(:build)  { branch.last_build }
diff --git a/spec/v3/services/broadcasts/for_current_user_spec.rb b/spec/v3/services/broadcasts/for_current_user_spec.rb
index e3d6a77b..7baf85c7 100644
--- a/spec/v3/services/broadcasts/for_current_user_spec.rb
+++ b/spec/v3/services/broadcasts/for_current_user_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe Travis::API::V3::Services::Broadcasts::ForCurrentUser do
+describe Travis::API::V3::Services::Broadcasts::ForCurrentUser, set_app: true do
   let(:repo)    { Travis::API::V3::Models::Repository.where(owner_name: 'svenfuchs', name: 'minimal').first }
   let(:token)   { Travis::Api::App::AccessToken.create(user: repo.owner, app_id: 1) }
   let(:headers) {{ 'HTTP_AUTHORIZATION' => "token #{token}"                        }}
diff --git a/spec/v3/services/build/cancel_spec.rb b/spec/v3/services/build/cancel_spec.rb
index 00c63c54..b6304547 100644
--- a/spec/v3/services/build/cancel_spec.rb
+++ b/spec/v3/services/build/cancel_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe Travis::API::V3::Services::Build::Cancel do
+describe Travis::API::V3::Services::Build::Cancel, set_app: true do
   let(:repo) { Travis::API::V3::Models::Repository.where(owner_name: 'svenfuchs', name: 'minimal').first }
   let(:build) { repo.builds.first }
   let(:sidekiq_payload) { JSON.load(Sidekiq::Client.last['args'].last.to_json) }
diff --git a/spec/v3/services/build/find_spec.rb b/spec/v3/services/build/find_spec.rb
index e77b4a25..7fa784a7 100644
--- a/spec/v3/services/build/find_spec.rb
+++ b/spec/v3/services/build/find_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe Travis::API::V3::Services::Build::Find do
+describe Travis::API::V3::Services::Build::Find, set_app: true do
   let(:repo) { Travis::API::V3::Models::Repository.where(owner_name: 'svenfuchs', name: 'minimal').first }
   let(:build) { repo.builds.first }
   let(:jobs)  { Travis::API::V3::Models::Build.find(build.id).jobs }
diff --git a/spec/v3/services/build/restart_spec.rb b/spec/v3/services/build/restart_spec.rb
index 048f2307..78d6d5b6 100644
--- a/spec/v3/services/build/restart_spec.rb
+++ b/spec/v3/services/build/restart_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe Travis::API::V3::Services::Build::Restart do
+describe Travis::API::V3::Services::Build::Restart, set_app: true do
   let(:repo) { Travis::API::V3::Models::Repository.where(owner_name: 'svenfuchs', name: 'minimal').first }
   let(:build) { repo.builds.first }
   let(:sidekiq_payload) { JSON.load(Sidekiq::Client.last['args'].last.to_json) }
diff --git a/spec/v3/services/builds/find_spec.rb b/spec/v3/services/builds/find_spec.rb
index 5042c2a7..12948ded 100644
--- a/spec/v3/services/builds/find_spec.rb
+++ b/spec/v3/services/builds/find_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe Travis::API::V3::Services::Builds::Find do
+describe Travis::API::V3::Services::Builds::Find, set_app: true do
   let(:repo) { Travis::API::V3::Models::Repository.where(owner_name: 'svenfuchs', name: 'minimal').first }
   let(:build) { repo.builds.first }
   let(:jobs)  { Travis::API::V3::Models::Build.find(build.id).jobs }
diff --git a/spec/v3/services/cron/create_spec.rb b/spec/v3/services/cron/create_spec.rb
index 859e6a27..9cecfae2 100644
--- a/spec/v3/services/cron/create_spec.rb
+++ b/spec/v3/services/cron/create_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe Travis::API::V3::Services::Cron::Create do
+describe Travis::API::V3::Services::Cron::Create, set_app: true do
   let(:repo) { Travis::API::V3::Models::Repository.where(owner_name: 'svenfuchs', name: 'minimal').first }
   let(:branch) { Travis::API::V3::Models::Branch.where(repository_id: repo).first }
   let(:non_existing_branch) { Travis::API::V3::Models::Branch.create(repository: repo, name: 'cron-test', exists_on_github: false) }
diff --git a/spec/v3/services/cron/delete_spec.rb b/spec/v3/services/cron/delete_spec.rb
index 54a3b056..34c69cdd 100644
--- a/spec/v3/services/cron/delete_spec.rb
+++ b/spec/v3/services/cron/delete_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe Travis::API::V3::Services::Cron::Delete do
+describe Travis::API::V3::Services::Cron::Delete, set_app: true do
   let(:repo) { Travis::API::V3::Models::Repository.where(owner_name: 'svenfuchs', name: 'minimal').first }
   let(:branch) { Travis::API::V3::Models::Branch.where(repository_id: repo).first }
   let(:cron)  { Travis::API::V3::Models::Cron.create(branch: branch, interval:'daily') }
diff --git a/spec/v3/services/cron/find_spec.rb b/spec/v3/services/cron/find_spec.rb
index e75e15c0..4c6d33a0 100644
--- a/spec/v3/services/cron/find_spec.rb
+++ b/spec/v3/services/cron/find_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe Travis::API::V3::Services::Cron::Find do
+describe Travis::API::V3::Services::Cron::Find, set_app: true do
   let(:repo) { Travis::API::V3::Models::Repository.where(owner_name: 'svenfuchs', name: 'minimal').first }
   let(:branch) { Travis::API::V3::Models::Branch.where(repository_id: repo).first }
   let(:cron)  { Travis::API::V3::Models::Cron.create(branch: branch, interval:'daily') }
diff --git a/spec/v3/services/cron/for_branch_spec.rb b/spec/v3/services/cron/for_branch_spec.rb
index c5509074..5ce98d1a 100644
--- a/spec/v3/services/cron/for_branch_spec.rb
+++ b/spec/v3/services/cron/for_branch_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe Travis::API::V3::Services::Cron::ForBranch do
+describe Travis::API::V3::Services::Cron::ForBranch, set_app: true do
   let(:repo) { Travis::API::V3::Models::Repository.where(owner_name: 'svenfuchs', name: 'minimal').first }
   let(:branch) { Travis::API::V3::Models::Branch.where(repository_id: repo).first }
   let(:cron)  { Travis::API::V3::Models::Cron.create(branch: branch, interval:'daily') }
diff --git a/spec/v3/services/crons/for_repository_spec.rb b/spec/v3/services/crons/for_repository_spec.rb
index f81b8e7b..ca59886d 100644
--- a/spec/v3/services/crons/for_repository_spec.rb
+++ b/spec/v3/services/crons/for_repository_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe Travis::API::V3::Services::Crons::ForRepository do
+describe Travis::API::V3::Services::Crons::ForRepository, set_app: true do
   let(:repo) { Travis::API::V3::Models::Repository.where(owner_name: 'svenfuchs', name: 'minimal').first }
   let(:branch) { Travis::API::V3::Models::Branch.where(repository_id: repo).first }
   let(:cron)  { Travis::API::V3::Models::Cron.create(branch: branch, interval:'daily') }
diff --git a/spec/v3/services/job/cancel_spec.rb b/spec/v3/services/job/cancel_spec.rb
index b429cfa6..f55a9a7d 100644
--- a/spec/v3/services/job/cancel_spec.rb
+++ b/spec/v3/services/job/cancel_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe Travis::API::V3::Services::Job::Cancel do
+describe Travis::API::V3::Services::Job::Cancel, set_app: true do
   let(:repo)  { Travis::API::V3::Models::Repository.where(owner_name: 'svenfuchs', name: 'minimal').first }
   let(:build) { repo.builds.first }
   let(:job)   { build.jobs.first}
diff --git a/spec/v3/services/job/debug_sepc.rb b/spec/v3/services/job/debug_sepc.rb
index 03fe80fb..dcf9eb07 100644
--- a/spec/v3/services/job/debug_sepc.rb
+++ b/spec/v3/services/job/debug_sepc.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe Travis::API::V3::Services::Job::Debug do
+describe Travis::API::V3::Services::Job::Debug, set_app: true do
   let(:repo) { Travis::API::V3::Models::Repository.where(owner_name: 'svenfuchs', name: 'minimal').first }
   let(:owner_type)  { repo.owner_type.constantize }
   let(:owner)       { owner_type.find(repo.owner_id)}
@@ -67,4 +65,4 @@ describe Travis::API::V3::Services::Job::Debug do
       end
     end
   end
-end
\ No newline at end of file
+end
diff --git a/spec/v3/services/job/find_spec.rb b/spec/v3/services/job/find_spec.rb
index cc2e6967..7c69500d 100644
--- a/spec/v3/services/job/find_spec.rb
+++ b/spec/v3/services/job/find_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe Travis::API::V3::Services::Job::Find do
+describe Travis::API::V3::Services::Job::Find, set_app: true do
   let(:repo) { Travis::API::V3::Models::Repository.where(owner_name: 'svenfuchs', name: 'minimal').first }
   let(:owner_href)  { repo.owner_type.downcase }
   let(:owner_type)  { repo.owner_type.constantize }
diff --git a/spec/v3/services/job/restart_spec.rb b/spec/v3/services/job/restart_spec.rb
index fde730f6..3ea85898 100644
--- a/spec/v3/services/job/restart_spec.rb
+++ b/spec/v3/services/job/restart_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe Travis::API::V3::Services::Job::Restart do
+describe Travis::API::V3::Services::Job::Restart, set_app: true do
   let(:repo)  { Travis::API::V3::Models::Repository.where(owner_name: 'svenfuchs', name: 'minimal').first }
   let(:build) { repo.builds.first }
   let(:job)   { build.jobs.first }
diff --git a/spec/v3/services/jobs/find_spec.rb b/spec/v3/services/jobs/find_spec.rb
index 12ffa4fa..1ee4d39b 100644
--- a/spec/v3/services/jobs/find_spec.rb
+++ b/spec/v3/services/jobs/find_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe Travis::API::V3::Services::Jobs::Find do
+describe Travis::API::V3::Services::Jobs::Find, set_app: true do
   let(:repo)  { Travis::API::V3::Models::Repository.where(owner_name: 'svenfuchs', name: 'minimal').first }
   let(:build) { repo.builds.first }
   let(:jobs)  { Travis::API::V3::Models::Build.find(build.id).jobs }
diff --git a/spec/v3/services/lint/lint_spec.rb b/spec/v3/services/lint/lint_spec.rb
index affa8f14..8de652b8 100644
--- a/spec/v3/services/lint/lint_spec.rb
+++ b/spec/v3/services/lint/lint_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe Travis::API::V3::Services::Lint::Lint do
+describe Travis::API::V3::Services::Lint::Lint, set_app: true do
     let(:content) { "foo: bar" }
     let(:parsed_body) { JSON.load(last_response.body) }
     let(:headers) {{ 'CONTENT_TYPE' => 'text/yaml'}}
diff --git a/spec/v3/services/organization/find_spec.rb b/spec/v3/services/organization/find_spec.rb
index 216265f6..fabd2bcc 100644
--- a/spec/v3/services/organization/find_spec.rb
+++ b/spec/v3/services/organization/find_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe Travis::API::V3::Services::Organization::Find do
+describe Travis::API::V3::Services::Organization::Find, set_app: true do
   let(:org) { Travis::API::V3::Models::Organization.new(login: 'example-org') }
   before    { org.save!                              }
   after     { org.delete                             }
diff --git a/spec/v3/services/organizations/for_current_user_spec.rb b/spec/v3/services/organizations/for_current_user_spec.rb
index 92fe0cfa..42ebff9b 100644
--- a/spec/v3/services/organizations/for_current_user_spec.rb
+++ b/spec/v3/services/organizations/for_current_user_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe Travis::API::V3::Services::Organizations::ForCurrentUser do
+describe Travis::API::V3::Services::Organizations::ForCurrentUser, set_app: true do
   let(:repo) { Travis::API::V3::Models::Repository.where(owner_name: 'svenfuchs', name: 'minimal').first }
 
   let(:token)   { Travis::Api::App::AccessToken.create(user: repo.owner, app_id: 1) }
diff --git a/spec/v3/services/owner/find_spec.rb b/spec/v3/services/owner/find_spec.rb
index 6ad095da..ddab6ccf 100644
--- a/spec/v3/services/owner/find_spec.rb
+++ b/spec/v3/services/owner/find_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe Travis::API::V3::Services::Owner::Find do
+describe Travis::API::V3::Services::Owner::Find, set_app: true do
   describe "organization" do
     let(:org) { Travis::API::V3::Models::Organization.new(login: 'example-org', github_id: 1234) }
     before    { org.save!                              }
diff --git a/spec/v3/services/repositories/for_current_user_spec.rb b/spec/v3/services/repositories/for_current_user_spec.rb
index 83ffc360..f724bbb7 100644
--- a/spec/v3/services/repositories/for_current_user_spec.rb
+++ b/spec/v3/services/repositories/for_current_user_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe Travis::API::V3::Services::Repositories::ForCurrentUser do
+describe Travis::API::V3::Services::Repositories::ForCurrentUser, set_app: true do
   let(:repo)  { Travis::API::V3::Models::Repository.where(owner_name: 'svenfuchs', name: 'minimal').first }
   let(:build) { repo.builds.first }
   let(:jobs)  { Travis::API::V3::Models::Build.find(build.id).jobs }
diff --git a/spec/v3/services/repositories/for_owner_spec.rb b/spec/v3/services/repositories/for_owner_spec.rb
index b3bb8adc..feca85ac 100644
--- a/spec/v3/services/repositories/for_owner_spec.rb
+++ b/spec/v3/services/repositories/for_owner_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe Travis::API::V3::Services::Repositories::ForOwner do
+describe Travis::API::V3::Services::Repositories::ForOwner, set_app: true do
   let(:repo)  { Travis::API::V3::Models::Repository.where(owner_name: 'svenfuchs', name: 'minimal').first }
   let(:build) { repo.builds.first }
   let(:jobs)  { Travis::API::V3::Models::Build.find(build.id).jobs }
diff --git a/spec/v3/services/repository/disable_spec.rb b/spec/v3/services/repository/disable_spec.rb
index 991c2dd8..fa63fc08 100644
--- a/spec/v3/services/repository/disable_spec.rb
+++ b/spec/v3/services/repository/disable_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe Travis::API::V3::Services::Repository::Disable do
+describe Travis::API::V3::Services::Repository::Disable, set_app: true do
   let(:repo)  { Travis::API::V3::Models::Repository.where(owner_name: 'svenfuchs', name: 'minimal').first }
 
   before do
diff --git a/spec/v3/services/repository/enable_spec.rb b/spec/v3/services/repository/enable_spec.rb
index fca71c2e..e6f2dfa4 100644
--- a/spec/v3/services/repository/enable_spec.rb
+++ b/spec/v3/services/repository/enable_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe Travis::API::V3::Services::Repository::Enable do
+describe Travis::API::V3::Services::Repository::Enable, set_app: true do
   let(:repo)  { Travis::API::V3::Models::Repository.where(owner_name: 'svenfuchs', name: 'minimal').first }
 
   before do
diff --git a/spec/v3/services/repository/find_spec.rb b/spec/v3/services/repository/find_spec.rb
index 1e602988..0527d5e9 100644
--- a/spec/v3/services/repository/find_spec.rb
+++ b/spec/v3/services/repository/find_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe Travis::API::V3::Services::Repository::Find do
+describe Travis::API::V3::Services::Repository::Find, set_app: true do
   let(:repo) { Travis::API::V3::Models::Repository.where(owner_name: 'svenfuchs', name: 'minimal').first }
   let(:build) { repo.builds.first }
   let(:jobs)  { Travis::API::V3::Models::Build.find(build.id).jobs }
diff --git a/spec/v3/services/repository/star_spec.rb b/spec/v3/services/repository/star_spec.rb
index f682768a..17502921 100644
--- a/spec/v3/services/repository/star_spec.rb
+++ b/spec/v3/services/repository/star_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe Travis::API::V3::Services::Repository::Star do
+describe Travis::API::V3::Services::Repository::Star, set_app: true do
   let(:repo)  { Travis::API::V3::Models::Repository.where(owner_name: 'svenfuchs', name: 'minimal').first }
 
   describe "not authenticated" do
@@ -62,7 +60,7 @@ describe Travis::API::V3::Services::Repository::Star do
     }}
   end
 
-  describe "existing repository, push access" 
+  describe "existing repository, push access"
     #  this requires stubing a github request, which is difficult, so has been omitted for now
 
 end
diff --git a/spec/v3/services/repository/unstar_spec.rb b/spec/v3/services/repository/unstar_spec.rb
index 0778f4af..813c9bb8 100644
--- a/spec/v3/services/repository/unstar_spec.rb
+++ b/spec/v3/services/repository/unstar_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe Travis::API::V3::Services::Repository::Unstar do
+describe Travis::API::V3::Services::Repository::Unstar, set_app: true do
   let(:repo)  { Travis::API::V3::Models::Repository.where(owner_name: 'svenfuchs', name: 'minimal').first }
 
   describe "not authenticated" do
@@ -64,5 +62,5 @@ describe Travis::API::V3::Services::Repository::Unstar do
 
   describe "existing repository, push access"
   #  this requires stubing a github request, which is difficult, so has been omitted for now
-  
+
 end
diff --git a/spec/v3/services/requests/create_spec.rb b/spec/v3/services/requests/create_spec.rb
index c0dfb035..d0c2f98f 100644
--- a/spec/v3/services/requests/create_spec.rb
+++ b/spec/v3/services/requests/create_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe Travis::API::V3::Services::Requests::Create do
+describe Travis::API::V3::Services::Requests::Create, set_app: true do
   let(:repo) { Travis::API::V3::Models::Repository.where(owner_name: 'svenfuchs', name: 'minimal').first }
   let(:sidekiq_payload) { JSON.load(Sidekiq::Client.last['args'].last[:payload]).deep_symbolize_keys }
   let(:sidekiq_params) { Sidekiq::Client.last['args'].last.deep_symbolize_keys }
diff --git a/spec/v3/services/requests/find_spec.rb b/spec/v3/services/requests/find_spec.rb
index f6a8bd7c..276324d0 100644
--- a/spec/v3/services/requests/find_spec.rb
+++ b/spec/v3/services/requests/find_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe Travis::API::V3::Services::Requests::Find do
+describe Travis::API::V3::Services::Requests::Find, set_app: true do
   let(:repo) { Travis::API::V3::Models::Repository.where(owner_name: 'svenfuchs', name: 'minimal').first }
   let(:request) { repo.requests.first }
 
diff --git a/spec/v3/services/settings_spec.rb b/spec/v3/services/settings_spec.rb
index f1c93ff9..b8189275 100644
--- a/spec/v3/services/settings_spec.rb
+++ b/spec/v3/services/settings_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe Travis::API::V3::Services::Settings do
+describe Travis::API::V3::Services::Settings, set_app: true do
   let(:repo)  { Travis::API::V3::Models::Repository.where(owner_name: 'svenfuchs', name: 'minimal').first_or_create }
   let(:token) { Travis::Api::App::AccessToken.create(user: repo.owner, app_id: 1) }
   let(:auth_headers) { { 'HTTP_AUTHORIZATION' => "token #{token}" } }
@@ -45,7 +43,7 @@ describe Travis::API::V3::Services::Settings do
           'build_pull_requests' => true,
           'maximum_number_of_builds' => 0
         )
-      end 
+      end
     end
 
     describe 'authenticated, existing repo, repo has some settings' do
@@ -63,7 +61,7 @@ describe Travis::API::V3::Services::Settings do
           'build_pull_requests' => true,
           'maximum_number_of_builds' => 0
         )
-      end 
+      end
     end
   end
 
@@ -116,7 +114,7 @@ describe Travis::API::V3::Services::Settings do
           'build_pull_requests' => true,
           'maximum_number_of_builds' => 20
         )
-      end 
+      end
     end
   end
 end
diff --git a/spec/v3/services/user/current_spec.rb b/spec/v3/services/user/current_spec.rb
index 4557ee2b..d960757a 100644
--- a/spec/v3/services/user/current_spec.rb
+++ b/spec/v3/services/user/current_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe Travis::API::V3::Services::User::Current do
+describe Travis::API::V3::Services::User::Current, set_app: true do
   let(:user) { Travis::API::V3::Models::User.find_by_login('svenfuchs') }
 
   let(:token)   { Travis::Api::App::AccessToken.create(user: user, app_id: 1) }
diff --git a/spec/v3/services/user/find_spec.rb b/spec/v3/services/user/find_spec.rb
index 9155cb63..3652686f 100644
--- a/spec/v3/services/user/find_spec.rb
+++ b/spec/v3/services/user/find_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe Travis::API::V3::Services::User::Find do
+describe Travis::API::V3::Services::User::Find, set_app: true do
   let(:user) { Travis::API::V3::Models::User.find_by_login('svenfuchs') }
 
   let(:token)   { Travis::Api::App::AccessToken.create(user: user, app_id: 1) }
diff --git a/spec/v3/services/user/sync_spec.rb b/spec/v3/services/user/sync_spec.rb
index 316d41f9..de29168a 100644
--- a/spec/v3/services/user/sync_spec.rb
+++ b/spec/v3/services/user/sync_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe Travis::API::V3::Services::User::Sync do
+describe Travis::API::V3::Services::User::Sync, set_app: true do
   let(:user)  { Travis::API::V3::Models::User.find_by_login('svenfuchs') }
   let(:user2) { Travis::API::V3::Models::User.create(login: 'carlad', is_syncing: true) }
   let(:sidekiq_payload) { JSON.load(Sidekiq::Client.last['args'].last.to_json) }
diff --git a/spec_core/core/model/build/compat_spec.rb b/spec_core/core/model/build/compat_spec.rb
deleted file mode 100644
index 3e5495e2..00000000
--- a/spec_core/core/model/build/compat_spec.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# require 'spec_helper_core'
-#
-# describe Build::Compat do
-#   include Support::ActiveRecord
-#
-#   let(:build) { Factory(:build, :result => nil) }
-# end
diff --git a/spec_core/core/model/organization_spec.rb b/spec_core/core/model/organization_spec.rb
deleted file mode 100644
index 27a0f2e4..00000000
--- a/spec_core/core/model/organization_spec.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-require 'spec_helper_core'
-
-describe User do
-  include Support::ActiveRecord
-
-    let(:org)    { Factory.create(:org, :login => 'travis-organization') }
-
-    describe 'educational_org' do
-      after do
-        Travis::Features.deactivate_owner(:educational_org, org)
-      end
-
-      it 'returns true if organization is flagged as educational_org' do
-        Travis::Features.activate_owner(:educational_org, org)
-        org.education?.should be true
-      end
-
-      it 'returns false if the organization has not been flagged as educational_org' do
-        org.education?.should be false
-      end
-    end
-end
diff --git a/spec_core/core/services/find_daily_repos_stats_spec.rb b/spec_core/core/services/find_daily_repos_stats_spec.rb
deleted file mode 100644
index 63f1cbdb..00000000
--- a/spec_core/core/services/find_daily_repos_stats_spec.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-require 'spec_helper'
-require 'travis/testing/scenario'
-
-describe Travis::Services::FindDailyReposStats do
-  include Support::ActiveRecord
-
-  let(:service) { described_class.new(stub('user'), {}) }
-
-  before { Scenario.default }
-
-  it 'should include the date' do
-    stats = service.run
-    expect(stats.size).to eq(1)
-    stats.first['date'].should == Repository.first.created_at.to_date.to_s(:date)
-  end
-
-  it 'should include the number per day' do
-    stats = service.run
-    expect(stats.size).to eq(1)
-    stats.first['count'].to_i.should == 2
-  end
-end
diff --git a/spec_core/core/services/find_daily_tests_stats_spec.rb b/spec_core/core/services/find_daily_tests_stats_spec.rb
deleted file mode 100644
index a9aa43c7..00000000
--- a/spec_core/core/services/find_daily_tests_stats_spec.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-require 'spec_helper'
-require 'travis/testing/scenario'
-
-describe Travis::Services::FindDailyTestsStats do
-  include Support::ActiveRecord
-
-  let(:service) { described_class.new(stub('user'), {}) }
-
-  before { Scenario.default }
-
-  it 'should return the jobs per day' do
-    stats = service.run
-    expect(stats.size).to eq(1)
-    stats.first['date'].should == Job.first.created_at.to_date.to_s(:date)
-    stats.first['count'].to_i.should == 13
-  end
-end
diff --git a/spec_core/core/model/annotation_provider_spec.rb b/spec_core/model/annotation_provider_spec.rb
similarity index 93%
rename from spec_core/core/model/annotation_provider_spec.rb
rename to spec_core/model/annotation_provider_spec.rb
index a0244269..026c805b 100644
--- a/spec_core/core/model/annotation_provider_spec.rb
+++ b/spec_core/model/annotation_provider_spec.rb
@@ -1,12 +1,7 @@
-require 'spec_helper_core'
-
 describe AnnotationProvider do
-  include Support::ActiveRecord
-
   let(:provider) { Factory(:annotation_provider) }
 
-
-  describe '.authenticate_provider', truncation: true do
+  describe '.authenticate_provider' do
     context 'given a valid username and key' do
       it 'authenticates the provider' do
         described_class.authenticate_provider(provider.api_username, provider.api_key).should eq(provider)
diff --git a/spec_core/core/model/annotation_spec.rb b/spec_core/model/annotation_spec.rb
similarity index 89%
rename from spec_core/core/model/annotation_spec.rb
rename to spec_core/model/annotation_spec.rb
index 0ace11c9..95f0e6a9 100644
--- a/spec_core/core/model/annotation_spec.rb
+++ b/spec_core/model/annotation_spec.rb
@@ -1,8 +1,4 @@
-require 'spec_helper_core'
-
 describe Annotation do
-  include Support::ActiveRecord
-
   let(:annotation) { Factory.build(:annotation) }
 
   describe 'validations' do
diff --git a/spec_core/core/model/broadcast_spec.rb b/spec_core/model/broadcast_spec.rb
similarity index 98%
rename from spec_core/core/model/broadcast_spec.rb
rename to spec_core/model/broadcast_spec.rb
index a3480e05..dd0b8db0 100644
--- a/spec_core/core/model/broadcast_spec.rb
+++ b/spec_core/model/broadcast_spec.rb
@@ -1,8 +1,4 @@
-require 'spec_helper_core'
-
 describe Broadcast do
-  include Support::ActiveRecord
-
   let(:org)  { Factory(:org) }
   let(:repo) { Factory(:repository) }
   let(:user) { Factory(:user) }
diff --git a/spec_core/core/model/build/config/dist_spec.rb b/spec_core/model/build/config/dist_spec.rb
similarity index 100%
rename from spec_core/core/model/build/config/dist_spec.rb
rename to spec_core/model/build/config/dist_spec.rb
diff --git a/spec_core/core/model/build/config/group_spec.rb b/spec_core/model/build/config/group_spec.rb
similarity index 100%
rename from spec_core/core/model/build/config/group_spec.rb
rename to spec_core/model/build/config/group_spec.rb
diff --git a/spec_core/core/model/build/config/matrix_spec.rb b/spec_core/model/build/config/matrix_spec.rb
similarity index 86%
rename from spec_core/core/model/build/config/matrix_spec.rb
rename to spec_core/model/build/config/matrix_spec.rb
index f2ced0e5..fb4bdafd 100644
--- a/spec_core/core/model/build/config/matrix_spec.rb
+++ b/spec_core/model/build/config/matrix_spec.rb
@@ -1,9 +1,6 @@
-require 'spec_helper_core'
 require 'core_ext/hash/deep_symbolize_keys'
 
 describe Build::Config::Matrix do
-  include Support::ActiveRecord
-
   it 'can handle nil values in exclude matrix' do
     -> { Build::Config::Matrix.new(matrix: { exclude: [nil] }).expand }.should_not raise_error
   end
diff --git a/spec_core/core/model/build/config/obfuscate_spec.rb b/spec_core/model/build/config/obfuscate_spec.rb
similarity index 97%
rename from spec_core/core/model/build/config/obfuscate_spec.rb
rename to spec_core/model/build/config/obfuscate_spec.rb
index 838de065..61fa07df 100644
--- a/spec_core/core/model/build/config/obfuscate_spec.rb
+++ b/spec_core/model/build/config/obfuscate_spec.rb
@@ -1,11 +1,9 @@
-require 'spec_helper_core'
-
 describe Build::Config::Obfuscate do
-  include Support::ActiveRecord
-
   let(:repo)  { Factory(:repository) }
   let(:build) { Build.new(repository: repo) }
 
+  before { repo.regenerate_key! }
+
   it 'normalizes env vars which are hashes to strings' do
     encrypted = repo.key.secure.encrypt('BAR=barbaz')
     build.config = {
diff --git a/spec_core/core/model/build/config_spec.rb b/spec_core/model/build/config_spec.rb
similarity index 98%
rename from spec_core/core/model/build/config_spec.rb
rename to spec_core/model/build/config_spec.rb
index 708786a8..5f91ac05 100644
--- a/spec_core/core/model/build/config_spec.rb
+++ b/spec_core/model/build/config_spec.rb
@@ -1,8 +1,4 @@
-require 'spec_helper_core'
-
 describe Build::Config do
-  include Support::ActiveRecord
-
   it 'keeps the given env if it is an array' do
     config = YAML.load %(
       env:
diff --git a/spec_core/core/model/build/denormalize_spec.rb b/spec_core/model/build/denormalize_spec.rb
similarity index 96%
rename from spec_core/core/model/build/denormalize_spec.rb
rename to spec_core/model/build/denormalize_spec.rb
index 0077bb40..d3bb80f9 100644
--- a/spec_core/core/model/build/denormalize_spec.rb
+++ b/spec_core/model/build/denormalize_spec.rb
@@ -1,8 +1,4 @@
-require 'spec_helper_core'
-
 describe Build, 'denormalization' do
-  include Support::ActiveRecord
-
   let(:build) { Factory(:build, state: :started, duration: 30) }
 
   describe 'on build:started' do
diff --git a/spec_core/core/model/build/matrix_spec.rb b/spec_core/model/build/matrix_spec.rb
similarity index 99%
rename from spec_core/core/model/build/matrix_spec.rb
rename to spec_core/model/build/matrix_spec.rb
index d3a76bd2..83165cba 100644
--- a/spec_core/core/model/build/matrix_spec.rb
+++ b/spec_core/model/build/matrix_spec.rb
@@ -1,8 +1,4 @@
-require 'spec_helper_core'
-
 describe Build, 'matrix' do
-  include Support::ActiveRecord
-
   describe :matrix_finished? do
     context 'if config[:matrix][:finish_fast] is not set' do
       context 'if at least one job has not finished and is not allowed to fail' do
@@ -393,7 +389,7 @@ describe Build, 'matrix' do
     yml
     }
 
-    describe :expand_matrix, truncation: true do
+    describe :expand_matrix do
       it 'does not expand on :os' do
         build = Factory.create(:build, config: { rvm: ['1.9.3', '2.0.0'], os: ['osx', 'linux']})
         build.matrix.map(&:config).should == [
@@ -529,7 +525,8 @@ describe Build, 'matrix' do
 
       it 'adds a sub-build number to the job number' do
         build = Factory(:build, config: multiple_tests_config)
-        build.matrix.map(&:number)[0..3].should == ['1.1', '1.2', '1.3', '1.4']
+        numbers = build.matrix.map(&:number)[0..3].map { |num| num.split('.').last }
+        numbers.should == ['1', '2', '3', '4']
       end
 
       describe :exclude_matrix_config do
@@ -637,6 +634,7 @@ describe Build, 'matrix' do
       end
 
       it 'does not decrypt secure env vars' do
+        repository.regenerate_key!
         env = repository.key.secure.encrypt('FOO=bar').symbolize_keys
         config = { rvm: '1.8.7', gemfile: 'gemfiles/rails-2.3.x', env: env }
         build = Factory(:build, repository: repository, config: config)
diff --git a/spec_core/core/model/build/metrics_spec.rb b/spec_core/model/build/metrics_spec.rb
similarity index 87%
rename from spec_core/core/model/build/metrics_spec.rb
rename to spec_core/model/build/metrics_spec.rb
index cc9b8769..a001a6e2 100644
--- a/spec_core/core/model/build/metrics_spec.rb
+++ b/spec_core/model/build/metrics_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper_core'
-
 class BuildMetricsMock
   include do
     attr_accessor :state, :request
@@ -35,7 +33,7 @@ describe Build::Metrics do
     build.start(started_at: Time.now)
   end
 
-  it 'measures the time it takes from creating the request until starting the build' do
+  xit 'measures the time it takes from creating the request until starting the build' do
     timer.expects(:update).with(60)
     build.start(started_at: Time.now)
   end
diff --git a/spec_core/core/model/build/result_message_spec.rb b/spec_core/model/build/result_message_spec.rb
similarity index 99%
rename from spec_core/core/model/build/result_message_spec.rb
rename to spec_core/model/build/result_message_spec.rb
index 68371312..4ebe5297 100644
--- a/spec_core/core/model/build/result_message_spec.rb
+++ b/spec_core/model/build/result_message_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper_core'
-
 describe Build::ResultMessage do
   def message(data)
     described_class.new(data)
diff --git a/spec_core/core/model/build/states_spec.rb b/spec_core/model/build/states_spec.rb
similarity index 99%
rename from spec_core/core/model/build/states_spec.rb
rename to spec_core/model/build/states_spec.rb
index 86d0a249..e394d913 100644
--- a/spec_core/core/model/build/states_spec.rb
+++ b/spec_core/model/build/states_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper_core'
-
 class BuildMock
   include Build::States
   class << self; def name; 'Build'; end; end
@@ -8,8 +6,6 @@ class BuildMock
 end
 
 describe Build::States do
-  include Support::ActiveRecord
-
   let(:build) { BuildMock.new }
 
   describe 'events' do
diff --git a/spec_core/core/model/build/update_branch_spec.rb b/spec_core/model/build/update_branch_spec.rb
similarity index 93%
rename from spec_core/core/model/build/update_branch_spec.rb
rename to spec_core/model/build/update_branch_spec.rb
index 4a5c0a8e..a34f89da 100644
--- a/spec_core/core/model/build/update_branch_spec.rb
+++ b/spec_core/model/build/update_branch_spec.rb
@@ -1,7 +1,5 @@
-require 'spec_helper_core'
-
-describe Build::UpdateBranch, truncation: true do
-  include Support::ActiveRecord
+describe Build::UpdateBranch do
+  before { DatabaseCleaner.clean_with :truncation }
 
   let(:request) { Factory.create(:request, event_type: event_type) }
   let(:build)   { Factory.build(:build, request: request, state: :started, duration: 30, branch: 'master') }
diff --git a/spec_core/core/model/build_spec.rb b/spec_core/model/build_spec.rb
similarity index 99%
rename from spec_core/core/model/build_spec.rb
rename to spec_core/model/build_spec.rb
index 5e43b209..c9002034 100644
--- a/spec_core/core/model/build_spec.rb
+++ b/spec_core/model/build_spec.rb
@@ -1,7 +1,5 @@
-require 'spec_helper_core'
-
-describe Build, truncation: true do
-  include Support::ActiveRecord
+describe Build do
+  before { DatabaseCleaner.clean_with :truncation }
 
   let(:repository) { Factory(:repository) }
 
diff --git a/spec_core/core/model/commit_spec.rb b/spec_core/model/commit_spec.rb
similarity index 97%
rename from spec_core/core/model/commit_spec.rb
rename to spec_core/model/commit_spec.rb
index 0e7db7bf..54d84977 100644
--- a/spec_core/core/model/commit_spec.rb
+++ b/spec_core/model/commit_spec.rb
@@ -1,8 +1,4 @@
-require 'spec_helper_core'
-
 describe Commit do
-  include Support::ActiveRecord
-
   let(:commit) { Commit.new(:commit => '12345678') }
 
   describe 'pull_request_number' do
diff --git a/spec_core/core/model/encrypted_column_spec.rb b/spec_core/model/encrypted_column_spec.rb
similarity index 99%
rename from spec_core/core/model/encrypted_column_spec.rb
rename to spec_core/model/encrypted_column_spec.rb
index b8cf0006..51211727 100644
--- a/spec_core/core/model/encrypted_column_spec.rb
+++ b/spec_core/model/encrypted_column_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper_core'
-
 class Travis::Model < ActiveRecord::Base
   describe EncryptedColumn do
     def encode str
diff --git a/spec_core/core/model/job/cleanup_spec.rb b/spec_core/model/job/cleanup_spec.rb
similarity index 94%
rename from spec_core/core/model/job/cleanup_spec.rb
rename to spec_core/model/job/cleanup_spec.rb
index 4115da19..70648bb5 100644
--- a/spec_core/core/model/job/cleanup_spec.rb
+++ b/spec_core/model/job/cleanup_spec.rb
@@ -1,8 +1,4 @@
-# require 'spec_helper_core'
-#
 # describe Job::Cleanup do
-#   include Support::ActiveRecord
-#
 #   let(:job) { Factory(:test) }
 #
 #   describe 'scopes' do
diff --git a/spec_core/core/model/job/queue_spec.rb b/spec_core/model/job/queue_spec.rb
similarity index 99%
rename from spec_core/core/model/job/queue_spec.rb
rename to spec_core/model/job/queue_spec.rb
index 10970b36..9e3182ba 100644
--- a/spec_core/core/model/job/queue_spec.rb
+++ b/spec_core/model/job/queue_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper_core'
-
 describe 'Job::Queue' do
   def queue(*args)
     Job::Queue.new(*args)
diff --git a/spec_core/core/model/job/test_spec.rb b/spec_core/model/job/test_spec.rb
similarity index 98%
rename from spec_core/core/model/job/test_spec.rb
rename to spec_core/model/job/test_spec.rb
index c2ebdadf..bd3135f4 100644
--- a/spec_core/core/model/job/test_spec.rb
+++ b/spec_core/model/job/test_spec.rb
@@ -1,8 +1,4 @@
-require 'spec_helper_core'
-
 describe Job::Test do
-  include Support::ActiveRecord
-
   let(:job) { Factory(:test) }
 
   before :each do
diff --git a/spec_core/core/model/job_spec.rb b/spec_core/model/job_spec.rb
similarity index 92%
rename from spec_core/core/model/job_spec.rb
rename to spec_core/model/job_spec.rb
index 2a580a22..14c02f46 100644
--- a/spec_core/core/model/job_spec.rb
+++ b/spec_core/model/job_spec.rb
@@ -1,8 +1,4 @@
-require 'spec_helper_core'
-
 describe Job do
-  include Support::ActiveRecord
-
   describe '.result' do
     it 'returns 1 for failed builds' do
       job = Factory.build(:test, state: :failed)
@@ -62,13 +58,16 @@ describe Job do
 
     it 'returns the duration if both started_at and finished_at are populated' do
       job = Job.new(started_at: 20.seconds.ago, finished_at: 10.seconds.ago)
-      job.duration.should == 10
+      job.duration.should be_within(0.1).of(10)
     end
   end
 
   describe 'obfuscated config' do
+    let(:repo) { Factory(:repository) }
+    before { repo.regenerate_key! }
+
     it 'handles nil env' do
-      job = Job.new(repository: Factory(:repository))
+      job = Job.new(repository: repo)
       job.config = { rvm: '1.8.7', env: nil }
 
       job.obfuscated_config.should == {
@@ -78,7 +77,7 @@ describe Job do
     end
 
     it 'leaves regular vars untouched' do
-      job = Job.new(repository: Factory(:repository))
+      job = Job.new(repository: repo)
       job.expects(:secure_env_enabled?).at_least_once.returns(true)
       job.config = { rvm: '1.8.7', env: 'FOO=foo' }
 
@@ -89,7 +88,7 @@ describe Job do
     end
 
     it 'obfuscates env vars' do
-      job = Job.new(repository: Factory(:repository))
+      job = Job.new(repository: repo)
       job.expects(:secure_env_enabled?).at_least_once.returns(true)
       config = { rvm: '1.8.7',
                  env: [job.repository.key.secure.encrypt('BAR=barbaz'), 'FOO=foo']
@@ -103,7 +102,7 @@ describe Job do
     end
 
     it 'normalizes env vars which are hashes to strings' do
-      job = Job.new(repository: Factory(:repository))
+      job = Job.new(repository: repo)
       job.expects(:secure_env_enabled?).at_least_once.returns(true)
 
       config = { rvm: '1.8.7',
@@ -119,7 +118,7 @@ describe Job do
     end
 
     it 'removes addons config if it is not a hash' do
-      job = Job.new(repository: Factory(:repository))
+      job = Job.new(repository: repo)
       config = { rvm: '1.8.7',
                  addons: "foo",
                }
@@ -131,7 +130,7 @@ describe Job do
     end
 
     it 'removes addons items which are not whitelisted' do
-      job = Job.new(repository: Factory(:repository))
+      job = Job.new(repository: repo)
       config = { rvm: '1.8.7',
                  addons: { sauce_connect: true, firefox: '22.0' },
                }
@@ -146,7 +145,7 @@ describe Job do
     end
 
     it 'removes source key' do
-      job = Job.new(repository: Factory(:repository))
+      job = Job.new(repository: repo)
       config = { rvm: '1.8.7',
                  source_key: '1234'
                }
@@ -159,7 +158,7 @@ describe Job do
 
     context 'when job has secure env disabled' do
       let :job do
-        job = Job.new(repository: Factory(:repository))
+        job = Job.new(repository: repo)
         job.expects(:secure_env_enabled?).returns(false).at_least_once
         job
       end
@@ -215,8 +214,11 @@ describe Job do
   end
 
   describe 'decrypted config' do
+    let(:repo) { Factory(:repository) }
+    before { repo.regenerate_key! }
+
     it 'handles nil env' do
-      job = Job.new(repository: Factory(:repository))
+      job = Job.new(repository: repo)
       job.config = { rvm: '1.8.7', env: nil, global_env: nil }
 
       job.decrypted_config.should == {
@@ -227,7 +229,7 @@ describe Job do
     end
 
     it 'normalizes env vars which are hashes to strings' do
-      job = Job.new(repository: Factory(:repository))
+      job = Job.new(repository: repo)
       job.expects(:secure_env_enabled?).at_least_once.returns(true)
 
       config = { rvm: '1.8.7',
@@ -246,7 +248,7 @@ describe Job do
     end
 
     it 'does not change original config' do
-      job = Job.new(repository: Factory(:repository))
+      job = Job.new(repository: repo)
       job.expects(:secure_env_enabled?).at_least_once.returns(true)
 
       config = {
@@ -263,7 +265,7 @@ describe Job do
     end
 
     it 'leaves regular vars untouched' do
-      job = Job.new(repository: Factory(:repository))
+      job = Job.new(repository: repo)
       job.expects(:secure_env_enabled?).returns(true).at_least_once
       job.config = { rvm: '1.8.7', env: 'FOO=foo', global_env: 'BAR=bar' }
 
@@ -276,7 +278,7 @@ describe Job do
 
     context 'when secure env is not enabled' do
       let :job do
-        job = Job.new(repository: Factory(:repository))
+        job = Job.new(repository: repo)
         job.expects(:secure_env_enabled?).returns(false).at_least_once
         job
       end
@@ -310,7 +312,7 @@ describe Job do
 
     context 'when addons are disabled' do
       let :job do
-        job = Job.new(repository: Factory(:repository))
+        job = Job.new(repository: repo)
         job.expects(:addons_enabled?).returns(false).at_least_once
         job
       end
@@ -359,7 +361,7 @@ describe Job do
 
     context 'when job has secure env enabled' do
       let :job do
-        job = Job.new(repository: Factory(:repository))
+        job = Job.new(repository: repo)
         job.expects(:secure_env_enabled?).returns(true).at_least_once
         job
       end
@@ -395,7 +397,7 @@ describe Job do
 
     context 'when job has addons enabled' do
       let :job do
-        job = Job.new(repository: Factory(:repository))
+        job = Job.new(repository: repo)
         job.expects(:addons_enabled?).returns(true).at_least_once
         job
       end
@@ -450,7 +452,6 @@ describe Job do
           }
         }
       end
-
     end
   end
 
diff --git a/spec_core/model/organization_spec.rb b/spec_core/model/organization_spec.rb
new file mode 100644
index 00000000..eb8c3e32
--- /dev/null
+++ b/spec_core/model/organization_spec.rb
@@ -0,0 +1,18 @@
+describe User do
+  let(:org) { Factory.create(:org, :login => 'travis-organization') }
+
+  describe 'educational_org' do
+    after do
+      Travis::Features.deactivate_owner(:educational_org, org)
+    end
+
+    it 'returns true if organization is flagged as educational_org' do
+      Travis::Features.activate_owner(:educational_org, org)
+      org.education?.should be true
+    end
+
+    it 'returns false if the organization has not been flagged as educational_org' do
+      org.education?.should be false
+    end
+  end
+end
diff --git a/spec_core/core/model/permission_spec.rb b/spec_core/model/permission_spec.rb
similarity index 89%
rename from spec_core/core/model/permission_spec.rb
rename to spec_core/model/permission_spec.rb
index 2b475840..9ce72bb4 100644
--- a/spec_core/core/model/permission_spec.rb
+++ b/spec_core/model/permission_spec.rb
@@ -1,8 +1,4 @@
-require 'spec_helper_core'
-
 describe Permission do
-  include Support::ActiveRecord
-
   describe 'by_roles' do
     before :each do
       Permission::ROLES.each { |role| Permission.create!(role => true) }
diff --git a/spec_core/core/model/repository/settings/ssh_key_spec.rb b/spec_core/model/repository/settings/ssh_key_spec.rb
similarity index 99%
rename from spec_core/core/model/repository/settings/ssh_key_spec.rb
rename to spec_core/model/repository/settings/ssh_key_spec.rb
index d2739643..141282e3 100644
--- a/spec_core/core/model/repository/settings/ssh_key_spec.rb
+++ b/spec_core/model/repository/settings/ssh_key_spec.rb
@@ -1,6 +1,4 @@
 # encoding: utf-8
-require 'spec_helper_core'
-
 describe Repository::Settings::SshKey do
   let(:private_key) {
 "-----BEGIN RSA PRIVATE KEY-----
diff --git a/spec_core/core/model/repository/settings_spec.rb b/spec_core/model/repository/settings_spec.rb
similarity index 99%
rename from spec_core/core/model/repository/settings_spec.rb
rename to spec_core/model/repository/settings_spec.rb
index e2b48caf..1729ab39 100644
--- a/spec_core/core/model/repository/settings_spec.rb
+++ b/spec_core/model/repository/settings_spec.rb
@@ -1,6 +1,4 @@
 # encoding: utf-8
-require 'spec_helper_core'
-
 describe Repository::Settings do
   describe 'env_vars' do
     it 'can be filtered to get only public vars' do
diff --git a/spec_core/core/model/repository/status_image_spec.rb b/spec_core/model/repository/status_image_spec.rb
similarity index 98%
rename from spec_core/core/model/repository/status_image_spec.rb
rename to spec_core/model/repository/status_image_spec.rb
index 1c166cae..9c59fd0d 100644
--- a/spec_core/core/model/repository/status_image_spec.rb
+++ b/spec_core/model/repository/status_image_spec.rb
@@ -1,8 +1,4 @@
-require 'spec_helper_core'
-
 describe Repository::StatusImage do
-  include Support::ActiveRecord
-
   let(:cache)    { stub('states cache', fetch: nil, write: nil, fetch_state: nil) }
   let!(:request) { Factory(:request, event_type: 'push', repository: repo) }
   let!(:build)   { Factory(:build, repository: repo, request: request, state: :passed) }
diff --git a/spec_core/core/model/repository_spec.rb b/spec_core/model/repository_spec.rb
similarity index 97%
rename from spec_core/core/model/repository_spec.rb
rename to spec_core/model/repository_spec.rb
index 90d9b304..56ec3979 100644
--- a/spec_core/core/model/repository_spec.rb
+++ b/spec_core/model/repository_spec.rb
@@ -1,7 +1,5 @@
-require 'spec_helper_core'
-
-describe Repository, truncation: true do
-  include Support::ActiveRecord
+describe Repository do
+  before { DatabaseCleaner.clean_with :truncation }
 
   describe '#last_completed_build' do
     let(:repo)   { Factory(:repository, name: 'foobarbaz', builds: [build1, build2]) }
@@ -23,9 +21,9 @@ describe Repository, truncation: true do
   end
 
   describe '#regenerate_key!' do
+    let(:repo) { Factory(:repository) }
+    before { repo.regenerate_key! }
     it 'regenerates key' do
-      repo = Factory(:repository)
-
       expect { repo.regenerate_key! }.to change { repo.key.private_key }
     end
   end
@@ -303,15 +301,11 @@ describe Repository, truncation: true do
 
   describe "keys" do
     let(:repo) { Factory(:repository) }
+    before { repo.regenerate_key! }
 
     it "should return the public key" do
       repo.public_key.should == repo.key.public_key
     end
-
-    it "should create a new key when the repository is created" do
-      repo = Repository.create!(owner_name: 'travis-ci', name: 'travis-ci')
-      repo.key.should_not be_nil
-    end
   end
 
   describe 'branches' do
diff --git a/spec_core/core/model/request/approval_spec.rb b/spec_core/model/request/approval_spec.rb
similarity index 99%
rename from spec_core/core/model/request/approval_spec.rb
rename to spec_core/model/request/approval_spec.rb
index 50d0727b..58cc2f2f 100644
--- a/spec_core/core/model/request/approval_spec.rb
+++ b/spec_core/model/request/approval_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper_core'
-
 describe Request::Approval do
   include Travis::Testing::Stubs
 
diff --git a/spec_core/core/model/request/branches_spec.rb b/spec_core/model/request/branches_spec.rb
similarity index 99%
rename from spec_core/core/model/request/branches_spec.rb
rename to spec_core/model/request/branches_spec.rb
index 2d8174d4..dcb330f3 100644
--- a/spec_core/core/model/request/branches_spec.rb
+++ b/spec_core/model/request/branches_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper_core'
-
 describe Request::Branches do
   include Travis::Testing::Stubs
 
diff --git a/spec_core/core/model/request/states_spec.rb b/spec_core/model/request/states_spec.rb
similarity index 99%
rename from spec_core/core/model/request/states_spec.rb
rename to spec_core/model/request/states_spec.rb
index 2b08e7b2..eb9c0177 100644
--- a/spec_core/core/model/request/states_spec.rb
+++ b/spec_core/model/request/states_spec.rb
@@ -1,8 +1,4 @@
-require 'spec_helper_core'
-
 describe Request::States do
-  include Support::ActiveRecord
-
   let(:owner)      { User.new(:login => 'joshk') }
   let(:repository) { Repository.new(:name => 'travis-ci', :owner => owner, :owner_name => 'travis-ci') }
   let(:commit)     { Commit.new(:repository => repository, :commit => '12345', :branch => 'master', :message => 'message', :committed_at => Time.now, :compare_url => 'https://github.com/svenfuchs/minimal/compare/master...develop') }
diff --git a/spec_core/core/model/request_spec.rb b/spec_core/model/request_spec.rb
similarity index 98%
rename from spec_core/core/model/request_spec.rb
rename to spec_core/model/request_spec.rb
index 434d617c..d2ee02ae 100644
--- a/spec_core/core/model/request_spec.rb
+++ b/spec_core/model/request_spec.rb
@@ -1,8 +1,4 @@
-require 'spec_helper_core'
-
 describe Request do
-  include Support::ActiveRecord
-
   let(:repo)    { Repository.new(owner_name: 'travis-ci', name: 'travis-ci') }
   let(:commit)  { Commit.new(commit: '12345678') }
   let(:request) { Request.new(repository: repo, commit: commit) }
diff --git a/spec_core/core/model/ssl_key_spec.rb b/spec_core/model/ssl_key_spec.rb
similarity index 98%
rename from spec_core/core/model/ssl_key_spec.rb
rename to spec_core/model/ssl_key_spec.rb
index a621e301..621d9206 100644
--- a/spec_core/core/model/ssl_key_spec.rb
+++ b/spec_core/model/ssl_key_spec.rb
@@ -1,8 +1,4 @@
-require 'spec_helper_core'
-
 describe SslKey do
-  include Support::ActiveRecord
-
   let(:key) { SslKey.new }
 
   before(:each) do
diff --git a/spec_core/core/model/token_spec.rb b/spec_core/model/token_spec.rb
similarity index 82%
rename from spec_core/core/model/token_spec.rb
rename to spec_core/model/token_spec.rb
index 3bdd17ac..c65b23c1 100644
--- a/spec_core/core/model/token_spec.rb
+++ b/spec_core/model/token_spec.rb
@@ -1,8 +1,4 @@
-require 'spec_helper_core'
-
 describe Token do
-  include Support::ActiveRecord
-
   it 'generate_token sets the token to a 20 character value' do
     Token.new.send(:generate_token).length.should == 20
   end
diff --git a/spec_core/core/model/url_spec.rb b/spec_core/model/url_spec.rb
similarity index 92%
rename from spec_core/core/model/url_spec.rb
rename to spec_core/model/url_spec.rb
index 9001ab4f..cad7ef34 100644
--- a/spec_core/core/model/url_spec.rb
+++ b/spec_core/model/url_spec.rb
@@ -1,8 +1,4 @@
-require 'spec_helper_core'
-
 describe Url do
-  include Support::ActiveRecord
-
   subject { Url.create(:url => "http://example.com") }
 
   describe ".shorten" do
diff --git a/spec_core/core/model/user/oauth_spec.rb b/spec_core/model/user/oauth_spec.rb
similarity index 92%
rename from spec_core/core/model/user/oauth_spec.rb
rename to spec_core/model/user/oauth_spec.rb
index 39920520..1f22c805 100644
--- a/spec_core/core/model/user/oauth_spec.rb
+++ b/spec_core/model/user/oauth_spec.rb
@@ -1,8 +1,4 @@
-require 'spec_helper_core'
-
 describe User::Oauth do
-  include Support::ActiveRecord
-
   let(:user)    { Factory(:user, :github_oauth_token => 'token') }
   let(:payload) { GITHUB_PAYLOADS[:oauth] }
 
diff --git a/spec_core/core/model/user_spec.rb b/spec_core/model/user_spec.rb
similarity index 94%
rename from spec_core/core/model/user_spec.rb
rename to spec_core/model/user_spec.rb
index 907e39e2..22bed4c7 100644
--- a/spec_core/core/model/user_spec.rb
+++ b/spec_core/model/user_spec.rb
@@ -1,7 +1,5 @@
-require 'spec_helper_core'
-
-describe User, truncation: true do
-  include Support::ActiveRecord
+describe User do
+  before { User.delete_all }
 
   let(:user)    { Factory(:user, :github_oauth_token => 'token') }
   let(:payload) { GITHUB_PAYLOADS[:oauth] }
@@ -171,22 +169,28 @@ describe User, truncation: true do
     before { user.save! }
 
     it "does not resolve github scopes if the token didn't change" do
+      user.github_scopes = ['public_repo', 'user:email']
+      user.save!
       Travis::Github.expects(:scopes_for).never
       user.save!
     end
 
     it "it resolves github scopes if the token did change" do
+      ENV['ENV'] = 'production' # TODO see user.rb ... move this out of the model.
       Travis::Github.expects(:scopes_for).with(user).returns(['foo', 'bar'])
       user.github_oauth_token = 'new_token'
       user.save!
       user.github_scopes.should be == ['foo', 'bar']
+      ENV['ENV'] = 'test'
     end
 
     it "it resolves github scopes if they haven't been resolved already" do
+      ENV['ENV'] = 'production' # TODO see user.rb ... move this out of the model.
       Travis::Github.expects(:scopes_for).with(user).returns(['foo', 'bar'])
       user.github_scopes = nil
       user.save!
       user.github_scopes.should be == ['foo', 'bar']
+      ENV['ENV'] = 'test'
     end
 
     it 'returns an empty list if the token is missing' do
@@ -197,6 +201,11 @@ describe User, truncation: true do
   end
 
   describe 'correct_scopes?' do
+    before do
+      user.github_scopes = ['public_repo', 'user:email']
+      user.save!
+    end
+
     it "accepts correct scopes" do
       user.should be_correct_scopes
     end
diff --git a/spec_core/core/services/cancel_build_spec.rb b/spec_core/services/cancel_build_spec.rb
similarity index 96%
rename from spec_core/core/services/cancel_build_spec.rb
rename to spec_core/services/cancel_build_spec.rb
index 9a708b29..78cb940b 100644
--- a/spec_core/core/services/cancel_build_spec.rb
+++ b/spec_core/services/cancel_build_spec.rb
@@ -1,8 +1,4 @@
-require 'spec_helper'
-
 describe Travis::Services::CancelBuild do
-  include Support::ActiveRecord
-
   let(:repo)    { Factory(:repository) }
   let!(:job)    { Factory(:test, repository: repo, state: :created) }
   let!(:passed_job) { Factory(:test, repository: repo, state: :passed) }
diff --git a/spec_core/core/services/cancel_job_spec.rb b/spec_core/services/cancel_job_spec.rb
similarity index 95%
rename from spec_core/core/services/cancel_job_spec.rb
rename to spec_core/services/cancel_job_spec.rb
index abf5bb2b..75a7eb31 100644
--- a/spec_core/core/services/cancel_job_spec.rb
+++ b/spec_core/services/cancel_job_spec.rb
@@ -1,8 +1,4 @@
-require 'spec_helper'
-
 describe Travis::Services::CancelJob do
-  include Support::ActiveRecord
-
   let(:repo)    { Factory(:repository) }
   let!(:job)    { Factory(:test, repository: repo, state: :created) }
   let(:params)  { { id: job.id, source: 'tests' } }
diff --git a/spec_core/core/services/find_admin_spec.rb b/spec_core/services/find_admin_spec.rb
similarity index 99%
rename from spec_core/core/services/find_admin_spec.rb
rename to spec_core/services/find_admin_spec.rb
index e4e20aa2..0d6fdd9e 100644
--- a/spec_core/core/services/find_admin_spec.rb
+++ b/spec_core/services/find_admin_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe Travis::Services::FindAdmin do
   include Travis::Testing::Stubs
 
diff --git a/spec_core/core/services/find_annotation_spec.rb b/spec_core/services/find_annotation_spec.rb
similarity index 90%
rename from spec_core/core/services/find_annotation_spec.rb
rename to spec_core/services/find_annotation_spec.rb
index 9b9fa77c..5e0463c7 100644
--- a/spec_core/core/services/find_annotation_spec.rb
+++ b/spec_core/services/find_annotation_spec.rb
@@ -1,8 +1,4 @@
-require 'spec_helper'
-
 describe Travis::Services::FindAnnotations do
-  include Support::ActiveRecord
-
   let(:job) { Factory(:test) }
   let!(:annotation) { Factory(:annotation, job: job) }
   let(:service) { described_class.new(params) }
diff --git a/spec_core/core/services/find_branch_spec.rb b/spec_core/services/find_branch_spec.rb
similarity index 94%
rename from spec_core/core/services/find_branch_spec.rb
rename to spec_core/services/find_branch_spec.rb
index 0394e074..6714ff76 100644
--- a/spec_core/core/services/find_branch_spec.rb
+++ b/spec_core/services/find_branch_spec.rb
@@ -1,8 +1,4 @@
-require 'spec_helper'
-
 describe Travis::Services::FindBranch do
-  include Support::ActiveRecord
-
   let(:repo)    { Factory(:repository, :owner_name => 'travis-ci', :name => 'travis-core') }
   let!(:build)  { Factory(:build, :repository => repo, :state => :finished) }
   let(:service) { described_class.new(stub('user'), params) }
diff --git a/spec_core/core/services/find_branches_spec.rb b/spec_core/services/find_branches_spec.rb
similarity index 94%
rename from spec_core/core/services/find_branches_spec.rb
rename to spec_core/services/find_branches_spec.rb
index d9ca70f2..55f4b233 100644
--- a/spec_core/core/services/find_branches_spec.rb
+++ b/spec_core/services/find_branches_spec.rb
@@ -1,8 +1,4 @@
-require 'spec_helper'
-
 describe Travis::Services::FindBranches do
-  include Support::ActiveRecord
-
   let(:repo)    { Factory(:repository, :owner_name => 'travis-ci', :name => 'travis-core') }
   let!(:build)  { Factory(:build, :repository => repo, :state => :finished) }
   let(:service) { described_class.new(stub('user'), params) }
diff --git a/spec_core/core/services/find_build_spec.rb b/spec_core/services/find_build_spec.rb
similarity index 97%
rename from spec_core/core/services/find_build_spec.rb
rename to spec_core/services/find_build_spec.rb
index ca229e80..7c354c3d 100644
--- a/spec_core/core/services/find_build_spec.rb
+++ b/spec_core/services/find_build_spec.rb
@@ -1,8 +1,4 @@
-require 'spec_helper'
-
 describe Travis::Services::FindBuild do
-  include Support::ActiveRecord
-
   let(:repo)    { Factory(:repository, owner_name: 'travis-ci', name: 'travis-core') }
   let!(:build)  { Factory(:build, repository: repo, state: :finished, number: 1, config: {'sudo' => false}) }
   let(:params)  { { id: build.id } }
diff --git a/spec_core/core/services/find_builds_spec.rb b/spec_core/services/find_builds_spec.rb
similarity index 98%
rename from spec_core/core/services/find_builds_spec.rb
rename to spec_core/services/find_builds_spec.rb
index 4f7e74c5..528cc5fb 100644
--- a/spec_core/core/services/find_builds_spec.rb
+++ b/spec_core/services/find_builds_spec.rb
@@ -1,7 +1,5 @@
-require 'spec_helper'
-
 describe Travis::Services::FindBuilds do
-  include Support::ActiveRecord
+  before { DatabaseCleaner.clean_with :truncation }
 
   let(:repo)    { Factory(:repository, owner_name: 'travis-ci', name: 'travis-core') }
   let!(:push)   { Factory(:build, repository: repo, event_type: 'push', state: :failed, number: 1) }
diff --git a/spec_core/core/services/find_caches_spec.rb b/spec_core/services/find_caches_spec.rb
similarity index 96%
rename from spec_core/core/services/find_caches_spec.rb
rename to spec_core/services/find_caches_spec.rb
index a6bc5dc0..a7c545fa 100644
--- a/spec_core/core/services/find_caches_spec.rb
+++ b/spec_core/services/find_caches_spec.rb
@@ -1,7 +1,5 @@
-require 'spec_helper'
-
 describe Travis::Services::FindCaches do
-  include Support::ActiveRecord, Support::S3, Support::GCS
+  include Support::S3, Support::GCS
 
   let(:user) { User.first || Factory(:user) }
   let(:service) { described_class.new(user, params) }
@@ -73,4 +71,4 @@ describe Travis::Services::FindCaches do
       its(:size) { should be == 0 }
     end
   end
-end
\ No newline at end of file
+end
diff --git a/spec_core/core/services/find_hooks_spec.rb b/spec_core/services/find_hooks_spec.rb
similarity index 96%
rename from spec_core/core/services/find_hooks_spec.rb
rename to spec_core/services/find_hooks_spec.rb
index 6415f211..d2ec0d90 100644
--- a/spec_core/core/services/find_hooks_spec.rb
+++ b/spec_core/services/find_hooks_spec.rb
@@ -1,8 +1,4 @@
-require 'spec_helper'
-
 describe Travis::Services::FindHooks do
-  include Support::ActiveRecord
-
   let(:user)    { User.first || Factory(:user) }
   let(:repo)    { Factory(:repository) }
   let(:push_repo) { Factory(:repository, name: 'push-repo') }
diff --git a/spec_core/core/services/find_job_spec.rb b/spec_core/services/find_job_spec.rb
similarity index 96%
rename from spec_core/core/services/find_job_spec.rb
rename to spec_core/services/find_job_spec.rb
index 85d954b5..ce2eea1b 100644
--- a/spec_core/core/services/find_job_spec.rb
+++ b/spec_core/services/find_job_spec.rb
@@ -1,8 +1,4 @@
-require 'spec_helper'
-
 describe Travis::Services::FindJob do
-  include Support::ActiveRecord
-
   let(:repo)    { Factory(:repository) }
   let!(:job)    { Factory(:test, repository: repo, state: :created, queue: 'builds.linux', config: {'sudo' => false}) }
   let(:params)  { { id: job.id } }
diff --git a/spec_core/core/services/find_jobs_spec.rb b/spec_core/services/find_jobs_spec.rb
similarity index 97%
rename from spec_core/core/services/find_jobs_spec.rb
rename to spec_core/services/find_jobs_spec.rb
index 3b71e271..038ff166 100644
--- a/spec_core/core/services/find_jobs_spec.rb
+++ b/spec_core/services/find_jobs_spec.rb
@@ -1,8 +1,4 @@
-require 'spec_helper'
-
 describe Travis::Services::FindJobs do
-  include Support::ActiveRecord
-
   let(:repo)    { Factory(:repository) }
   let!(:job)    { Factory(:test, :repository => repo, :state => :created, :queue => 'builds.linux') }
   let(:service) { described_class.new(stub('user'), params) }
diff --git a/spec_core/core/services/find_log_spec.rb b/spec_core/services/find_log_spec.rb
similarity index 94%
rename from spec_core/core/services/find_log_spec.rb
rename to spec_core/services/find_log_spec.rb
index 190ff21f..d0cb13b8 100644
--- a/spec_core/core/services/find_log_spec.rb
+++ b/spec_core/services/find_log_spec.rb
@@ -1,8 +1,4 @@
-require 'spec_helper'
-
 describe Travis::Services::FindLog do
-  include Support::ActiveRecord
-
   let!(:job)    { Factory(:test) }
   let(:log)     { job.log }
   let(:service) { described_class.new(stub('user'), params) }
diff --git a/spec_core/core/services/find_repo_key_spec.rb b/spec_core/services/find_repo_key_spec.rb
similarity index 93%
rename from spec_core/core/services/find_repo_key_spec.rb
rename to spec_core/services/find_repo_key_spec.rb
index 70c60fa1..45ff22c7 100644
--- a/spec_core/core/services/find_repo_key_spec.rb
+++ b/spec_core/services/find_repo_key_spec.rb
@@ -1,11 +1,9 @@
-require 'spec_helper'
-
 describe Travis::Services::FindRepoKey do
-  include Support::ActiveRecord
-
   let!(:repo)   { Factory(:repository, :owner_name => 'travis-ci', :name => 'travis-core') }
   let(:service) { described_class.new(stub('user'), params) }
 
+  before { repo.regenerate_key! }
+
   attr_reader :params
 
   describe 'run' do
diff --git a/spec_core/core/services/find_repo_settings_spec.rb b/spec_core/services/find_repo_settings_spec.rb
similarity index 94%
rename from spec_core/core/services/find_repo_settings_spec.rb
rename to spec_core/services/find_repo_settings_spec.rb
index 17842406..d469f302 100644
--- a/spec_core/core/services/find_repo_settings_spec.rb
+++ b/spec_core/services/find_repo_settings_spec.rb
@@ -1,8 +1,4 @@
-require 'spec_helper'
-
 describe Travis::Services::FindRepoSettings do
-  include Support::ActiveRecord
-
   let(:repo)    { Factory(:repository) }
   let(:params)  { { id: repo.id } }
   let(:user)    { Factory(:user) }
diff --git a/spec_core/core/services/find_repo_spec.rb b/spec_core/services/find_repo_spec.rb
similarity index 94%
rename from spec_core/core/services/find_repo_spec.rb
rename to spec_core/services/find_repo_spec.rb
index d13c8372..688c5981 100644
--- a/spec_core/core/services/find_repo_spec.rb
+++ b/spec_core/services/find_repo_spec.rb
@@ -1,8 +1,4 @@
-require 'spec_helper'
-
 describe Travis::Services::FindRepo do
-  include Support::ActiveRecord
-
   let!(:repo)   { Factory(:repository, :owner_name => 'travis-ci', :name => 'travis-core') }
   let(:service) { described_class.new(stub('user'), params) }
 
diff --git a/spec_core/core/services/find_repos_spec.rb b/spec_core/services/find_repos_spec.rb
similarity index 98%
rename from spec_core/core/services/find_repos_spec.rb
rename to spec_core/services/find_repos_spec.rb
index 6033f71e..e21d87a7 100644
--- a/spec_core/core/services/find_repos_spec.rb
+++ b/spec_core/services/find_repos_spec.rb
@@ -1,7 +1,5 @@
-require 'spec_helper'
-
 describe Travis::Services::FindRepos do
-  include Support::ActiveRecord
+  before { DatabaseCleaner.clean_with :truncation }
 
   let!(:repo)   { Factory(:repository, :owner_name => 'travis-ci', :name => 'travis-core', :active => true) }
   let(:service) { described_class.new(stub('user'), params) }
diff --git a/spec_core/core/services/find_request_spec.rb b/spec_core/services/find_request_spec.rb
similarity index 92%
rename from spec_core/core/services/find_request_spec.rb
rename to spec_core/services/find_request_spec.rb
index 559c7989..6a7f6e58 100644
--- a/spec_core/core/services/find_request_spec.rb
+++ b/spec_core/services/find_request_spec.rb
@@ -1,8 +1,4 @@
-require 'spec_helper'
-
 describe Travis::Services::FindRequest do
-  include Support::ActiveRecord
-
   let(:repo)    { Factory(:repository, :owner_name => 'travis-ci', :name => 'travis-core') }
   let!(:request)  { Factory(:request, :repository => repo) }
   let(:params)  { { :id => request.id } }
diff --git a/spec_core/core/services/find_requests_spec.rb b/spec_core/services/find_requests_spec.rb
similarity index 97%
rename from spec_core/core/services/find_requests_spec.rb
rename to spec_core/services/find_requests_spec.rb
index d680c9f1..cb05bce3 100644
--- a/spec_core/core/services/find_requests_spec.rb
+++ b/spec_core/services/find_requests_spec.rb
@@ -1,8 +1,4 @@
-require 'spec_helper'
-
 describe Travis::Services::FindRequests do
-  include Support::ActiveRecord
-
   let(:repo)    { Factory(:repository, :owner_name => 'travis-ci', :name => 'travis-core') }
   let!(:request)  { Factory(:request, :repository => repo) }
   let!(:newer_request)  { Factory(:request, :repository => repo) }
diff --git a/spec_core/core/services/find_user_accounts_spec.rb b/spec_core/services/find_user_accounts_spec.rb
similarity index 96%
rename from spec_core/core/services/find_user_accounts_spec.rb
rename to spec_core/services/find_user_accounts_spec.rb
index 44cb3fcf..23bf75d8 100644
--- a/spec_core/core/services/find_user_accounts_spec.rb
+++ b/spec_core/services/find_user_accounts_spec.rb
@@ -1,8 +1,4 @@
-require 'spec_helper'
-
 describe Travis::Services::FindUserAccounts do
-  include Support::ActiveRecord
-
   let!(:sven)    { Factory(:user, :login => 'sven') }
   let!(:travis)  { Factory(:org, :login => 'travis-ci') }
   let!(:sinatra) { Factory(:org, :login => 'sinatra') }
diff --git a/spec_core/core/services/next_build_number_spec.rb b/spec_core/services/next_build_number_spec.rb
similarity index 95%
rename from spec_core/core/services/next_build_number_spec.rb
rename to spec_core/services/next_build_number_spec.rb
index 887a958b..614b16b7 100644
--- a/spec_core/core/services/next_build_number_spec.rb
+++ b/spec_core/services/next_build_number_spec.rb
@@ -1,9 +1,6 @@
-require 'spec_helper'
 require 'travis/services/next_build_number'
 
 describe Travis::Services::NextBuildNumber do
-  include Support::ActiveRecord
-
   let(:service) { described_class.new(user, params) }
   let!(:user) { Factory(:user) }
   let(:result) { service.run }
diff --git a/spec_core/core/services/regenerate_repo_key_spec.rb b/spec_core/services/regenerate_repo_key_spec.rb
similarity index 93%
rename from spec_core/core/services/regenerate_repo_key_spec.rb
rename to spec_core/services/regenerate_repo_key_spec.rb
index 487839f0..0699e059 100644
--- a/spec_core/core/services/regenerate_repo_key_spec.rb
+++ b/spec_core/services/regenerate_repo_key_spec.rb
@@ -1,8 +1,4 @@
-require 'spec_helper'
-
 describe Travis::Services::RegenerateRepoKey do
-  include Support::ActiveRecord
-
   let(:user)    { User.first || Factory(:user) }
   let!(:repo)   { Factory(:repository, :owner_name => 'travis-ci', :name => 'travis-core') }
   let(:service) { described_class.new(user, :id => repo.id) }
diff --git a/spec_core/core/services/remove_log_spec.rb b/spec_core/services/remove_log_spec.rb
similarity index 97%
rename from spec_core/core/services/remove_log_spec.rb
rename to spec_core/services/remove_log_spec.rb
index 5475d0d5..121a52c0 100644
--- a/spec_core/core/services/remove_log_spec.rb
+++ b/spec_core/services/remove_log_spec.rb
@@ -1,8 +1,4 @@
-require 'spec_helper'
-
 describe Travis::Services::RemoveLog do
-  include Support::ActiveRecord
-
   let(:repo)    { Factory(:repository) }
   let(:job)     { Factory(:test, repository: repo, state: :created) }
   let(:user)    { Factory(:user) }
@@ -87,8 +83,6 @@ describe Travis::Services::RemoveLog do
 end
 
 describe Travis::Services::RemoveLog::Instrument do
-  include Support::ActiveRecord
-
   let(:service)   { Travis::Services::RemoveLog.new(user, params) }
   let(:repo)      { Factory(:repository) }
   let(:user)      { Factory(:user) }
diff --git a/spec_core/core/services/reset_model_spec.rb b/spec_core/services/reset_model_spec.rb
similarity index 98%
rename from spec_core/core/services/reset_model_spec.rb
rename to spec_core/services/reset_model_spec.rb
index c738ec49..02cb33ce 100644
--- a/spec_core/core/services/reset_model_spec.rb
+++ b/spec_core/services/reset_model_spec.rb
@@ -1,8 +1,4 @@
-require 'spec_helper'
-
 describe Travis::Services::ResetModel do
-  include Support::ActiveRecord
-
   let(:user) { User.first || Factory(:user) }
 
   before :each do
diff --git a/spec_core/core/services/sync_user_spec.rb b/spec_core/services/sync_user_spec.rb
similarity index 97%
rename from spec_core/core/services/sync_user_spec.rb
rename to spec_core/services/sync_user_spec.rb
index 2c8a284f..b4c5d583 100644
--- a/spec_core/core/services/sync_user_spec.rb
+++ b/spec_core/services/sync_user_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe Travis::Services::SyncUser do
   include Travis::Testing::Stubs
 
diff --git a/spec_core/core/services/update_annotation_spec.rb b/spec_core/services/update_annotation_spec.rb
similarity index 97%
rename from spec_core/core/services/update_annotation_spec.rb
rename to spec_core/services/update_annotation_spec.rb
index fe94a23b..c535ee80 100644
--- a/spec_core/core/services/update_annotation_spec.rb
+++ b/spec_core/services/update_annotation_spec.rb
@@ -1,8 +1,4 @@
-require 'spec_helper'
-
 describe Travis::Services::UpdateAnnotation do
-  include Support::ActiveRecord
-
   let(:annotation_provider) { Factory(:annotation_provider) }
   let(:job) { Factory(:test) }
   let(:service) { described_class.new(params) }
diff --git a/spec_core/core/services/update_hook_spec.rb b/spec_core/services/update_hook_spec.rb
similarity index 98%
rename from spec_core/core/services/update_hook_spec.rb
rename to spec_core/services/update_hook_spec.rb
index a5dac014..dd4d2fa3 100644
--- a/spec_core/core/services/update_hook_spec.rb
+++ b/spec_core/services/update_hook_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe Travis::Services::UpdateHook do
   include Travis::Testing::Stubs
 
diff --git a/spec_core/core/services/update_job_spec.rb b/spec_core/services/update_job_spec.rb
similarity index 99%
rename from spec_core/core/services/update_job_spec.rb
rename to spec_core/services/update_job_spec.rb
index 5a49db5b..e461a683 100644
--- a/spec_core/core/services/update_job_spec.rb
+++ b/spec_core/services/update_job_spec.rb
@@ -1,7 +1,5 @@
-require 'spec_helper'
-
 describe Travis::Services::UpdateJob do
-  include Support::ActiveRecord
+  before { DatabaseCleaner.clean_with :truncation }
 
   let(:service) { described_class.new(event: event, data: payload) }
   let(:payload) { WORKER_PAYLOADS["job:test:#{event}"].merge('id' => job.id) }
diff --git a/spec_core/core/services/update_log_spec.rb b/spec_core/services/update_log_spec.rb
similarity index 97%
rename from spec_core/core/services/update_log_spec.rb
rename to spec_core/services/update_log_spec.rb
index ebc0a5cd..400be030 100644
--- a/spec_core/core/services/update_log_spec.rb
+++ b/spec_core/services/update_log_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe Travis::Services::UpdateLog do
   include Travis::Testing::Stubs
 
diff --git a/spec_core/core/services/update_user_spec.rb b/spec_core/services/update_user_spec.rb
similarity index 95%
rename from spec_core/core/services/update_user_spec.rb
rename to spec_core/services/update_user_spec.rb
index 9b31107b..38cdfec6 100644
--- a/spec_core/core/services/update_user_spec.rb
+++ b/spec_core/services/update_user_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 describe Travis::Services::UpdateUser do
   include Travis::Testing::Stubs
 
diff --git a/spec_core/core/services_spec.rb b/spec_core/services_spec.rb
similarity index 98%
rename from spec_core/core/services_spec.rb
rename to spec_core/services_spec.rb
index 55cb5124..dd159cae 100644
--- a/spec_core/core/services_spec.rb
+++ b/spec_core/services_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
 module Test
   module Services
     extend Travis::Services::Registry
diff --git a/travis-api.gemspec b/travis-api.gemspec
index 71de225b..6fce569d 100644
--- a/travis-api.gemspec
+++ b/travis-api.gemspec
@@ -7,817 +7,10 @@ Gem::Specification.new do |s|
   s.homepage     = 'http://api.travis-ci.org'
   s.version      = '0.0.1'
   s.require_path = 'lib'
-
-  s.authors = [
-    "Konstantin Haase",
-    "Piotr Sarnacki",
-    "carlad",
-    "Sven Fuchs",
-    "Hiro Asari",
-    "Mathias Meyer",
-    "Josh Kalderimis",
-    "Henrik Hodne",
-    "Steffen Kötte",
-    "Ana Rosas",
-    "Renée Hendricksen",
-    "Tyranja",
-    "Lennard Wolf",
-    "Steffen",
-    "Christopher Weyand",
-    "Jonas Chromik",
-    "Dan Buch",
-    "Joe Corcoran",
-    "Andre Arko",
-    "Erik Michaels-Ober",
-    "C. Scott Ananian",
-    "Igor Wiedler",
-    "Igor",
-    "Lisa P",
-    "Steve Richert",
-    "Brian Ford",
-    "Patrick Williams",
-    "Puneeth Chaganti",
-    "Lucas CHERIFI",
-    "Dan Rice",
-    "Buck Doyle",
-    "James Dennes",
-    "Bryan Goldstein",
-    "Thais Camilo and Konstantin Haase",
-    "Tim Carey-Smith",
-    "rainsun",
-    "Zachary Scott",
-    "Nick Schonning",
-    "María de Antón"
-  ]
-
-  s.email = [
-    "konstantin.mailinglists@googlemail.com",
-    "drogus@gmail.com",
-    "carla@travis-ci.com",
-    "me@svenfuchs.com",
-    "asari.ruby@gmail.com",
-    "meyer@paperplanes.de",
-    "josh.kalderimis@gmail.com",
-    "steffen.koette@gmail.com",
-    "carlad@users.noreply.github.com",
-    "me@henrikhodne.com",
-    "a.rosas10@gmail.com",
-    "renee@travis-ci.org",
-    "tyranja@cassiopeia.uberspace.de",
-    "henrik@hodne.io",
-    "carla@travis-ci.org",
-    "konstantin.haase@gmail.com",
-    "lennardwolf@live.de",
-    "steffen.koette@gmail.com",
-    "Jonas.Chromik@student.hpi.uni-potsdam.de",
-    "christopher.weyand@student.hpi.de",
-    "dan@travis-ci.org",
-    "joe@corcoran.io",
-    "andre@arko.net",
-    "svenfuchs@artweb-design.de",
-    "sferik@gmail.com",
-    "cscott@cscott.net",
-    "steve.richert@gmail.com",
-    "henrik@travis-ci.com",
-    "mail@lislis.de",
-    "igor@travis-ci.org",
-    "bford@engineyard.com",
-    "igorwwwwwwwwwwwwwwwwwwww@users.noreply.github.com",
-    "dan@zoombody.com",
-    "dev+narwen+rkh@rkh.im",
-    "tim@spork.in",
-    "dan@meatballhat.com",
-    "e@zzak.io",
-    "b@chromatin.ca",
-    "brysgo@gmail.com",
-    "MariadeAnton@users.noreply.github.com",
-    "rainsuner@gmail.com",
-    "lucas@cherifi.info",
-    "nschonni@gmail.com",
-    "patrick@bittorrent.com",
-    "punchagan@muse-amuse.in",
-    "jdennes@gmail.com"
-  ]
-
-  s.files = [
-    "CONTRIBUTING.md",
-    "LICENSE",
-    "Procfile",
-    "README.md",
-    "Rakefile",
-    "bin/start-nginx",
-    "config.ru",
-    "config/database.yml",
-    "config/mime.types",
-    "config/nginx.conf.erb",
-    "config/puma-config.rb",
-    "config/ruby_config.sh",
-    "config/unicorn.rb",
-    "lib/active_record_postgres_variables.rb",
-    "lib/conditional_skylight.rb",
-    "lib/tasks/build_update_branch.rake",
-    "lib/tasks/build_update_pull_request_data.rake",
-    "lib/tasks/encrypt_all_data.rake",
-    "lib/travis/api/app.rb",
-    "lib/travis/api/app/access_token.rb",
-    "lib/travis/api/app/base.rb",
-    "lib/travis/api/app/cors.rb",
-    "lib/travis/api/app/endpoint.rb",
-    "lib/travis/api/app/endpoint/accounts.rb",
-    "lib/travis/api/app/endpoint/authorization.rb",
-    "lib/travis/api/app/endpoint/branches.rb",
-    "lib/travis/api/app/endpoint/broadcasts.rb",
-    "lib/travis/api/app/endpoint/builds.rb",
-    "lib/travis/api/app/endpoint/documentation.rb",
-    "lib/travis/api/app/endpoint/endpoints.rb",
-    "lib/travis/api/app/endpoint/env_vars.rb",
-    "lib/travis/api/app/endpoint/home.rb",
-    "lib/travis/api/app/endpoint/hooks.rb",
-    "lib/travis/api/app/endpoint/jobs.rb",
-    "lib/travis/api/app/endpoint/lint.rb",
-    "lib/travis/api/app/endpoint/logs.rb",
-    "lib/travis/api/app/endpoint/repos.rb",
-    "lib/travis/api/app/endpoint/requests.rb",
-    "lib/travis/api/app/endpoint/setting_endpoint.rb",
-    "lib/travis/api/app/endpoint/singleton_settings_endpoint.rb",
-    "lib/travis/api/app/endpoint/uptime.rb",
-    "lib/travis/api/app/endpoint/users.rb",
-    "lib/travis/api/app/error_handling.rb",
-    "lib/travis/api/app/extensions.rb",
-    "lib/travis/api/app/extensions/expose_pattern.rb",
-    "lib/travis/api/app/extensions/scoping.rb",
-    "lib/travis/api/app/extensions/smart_constants.rb",
-    "lib/travis/api/app/extensions/subclass_tracker.rb",
-    "lib/travis/api/app/helpers.rb",
-    "lib/travis/api/app/helpers/accept.rb",
-    "lib/travis/api/app/helpers/current_user.rb",
-    "lib/travis/api/app/helpers/db_follower.rb",
-    "lib/travis/api/app/helpers/flash.rb",
-    "lib/travis/api/app/helpers/mime_types.rb",
-    "lib/travis/api/app/helpers/respond_with.rb",
-    "lib/travis/api/app/middleware.rb",
-    "lib/travis/api/app/middleware/logging.rb",
-    "lib/travis/api/app/middleware/metriks.rb",
-    "lib/travis/api/app/middleware/rewrite.rb",
-    "lib/travis/api/app/middleware/scope_check.rb",
-    "lib/travis/api/app/middleware/skylight.rb",
-    "lib/travis/api/app/middleware/skylight/actual.rb",
-    "lib/travis/api/app/middleware/skylight/dummy.rb",
-    "lib/travis/api/app/middleware/user_agent_tracker.rb",
-    "lib/travis/api/app/responders.rb",
-    "lib/travis/api/app/responders/atom.rb",
-    "lib/travis/api/app/responders/badge.rb",
-    "lib/travis/api/app/responders/base.rb",
-    "lib/travis/api/app/responders/image.rb",
-    "lib/travis/api/app/responders/json.rb",
-    "lib/travis/api/app/responders/plain.rb",
-    "lib/travis/api/app/responders/service.rb",
-    "lib/travis/api/app/responders/xml.rb",
-    "lib/travis/api/app/services/schedule_request.rb",
-    "lib/travis/api/app/stack_instrumentation.rb",
-    "lib/travis/api/attack.rb",
-    "lib/travis/api/enqueue/services/restart_model.rb",
-    "lib/travis/api/instruments.rb",
-    "lib/travis/api/serializer.rb",
-    "lib/travis/api/v2.rb",
-    "lib/travis/api/v2/http.rb",
-    "lib/travis/api/v2/http/accounts.rb",
-    "lib/travis/api/v2/http/annotations.rb",
-    "lib/travis/api/v2/http/branch.rb",
-    "lib/travis/api/v2/http/branches.rb",
-    "lib/travis/api/v2/http/broadcasts.rb",
-    "lib/travis/api/v2/http/build.rb",
-    "lib/travis/api/v2/http/builds.rb",
-    "lib/travis/api/v2/http/caches.rb",
-    "lib/travis/api/v2/http/env_var.rb",
-    "lib/travis/api/v2/http/env_vars.rb",
-    "lib/travis/api/v2/http/error.rb",
-    "lib/travis/api/v2/http/hooks.rb",
-    "lib/travis/api/v2/http/job.rb",
-    "lib/travis/api/v2/http/jobs.rb",
-    "lib/travis/api/v2/http/log.rb",
-    "lib/travis/api/v2/http/permissions.rb",
-    "lib/travis/api/v2/http/repositories.rb",
-    "lib/travis/api/v2/http/repository.rb",
-    "lib/travis/api/v2/http/request.rb",
-    "lib/travis/api/v2/http/requests.rb",
-    "lib/travis/api/v2/http/ssh_key.rb",
-    "lib/travis/api/v2/http/ssl_key.rb",
-    "lib/travis/api/v2/http/user.rb",
-    "lib/travis/api/v2/http/validation_error.rb",
-    "lib/travis/api/v3.rb",
-    "lib/travis/api/v3/access_control.rb",
-    "lib/travis/api/v3/access_control/anonymous.rb",
-    "lib/travis/api/v3/access_control/application.rb",
-    "lib/travis/api/v3/access_control/generic.rb",
-    "lib/travis/api/v3/access_control/legacy_token.rb",
-    "lib/travis/api/v3/access_control/scoped.rb",
-    "lib/travis/api/v3/access_control/signature.rb",
-    "lib/travis/api/v3/access_control/user.rb",
-    "lib/travis/api/v3/constant_resolver.rb",
-    "lib/travis/api/v3/error.rb",
-    "lib/travis/api/v3/extensions/belongs_to.rb",
-    "lib/travis/api/v3/extensions/encrypted_column.rb",
-    "lib/travis/api/v3/features.rb",
-    "lib/travis/api/v3/github.rb",
-    "lib/travis/api/v3/metrics.rb",
-    "lib/travis/api/v3/model.rb",
-    "lib/travis/api/v3/models.rb",
-    "lib/travis/api/v3/models/account.rb",
-    "lib/travis/api/v3/models/branch.rb",
-    "lib/travis/api/v3/models/broadcast.rb",
-    "lib/travis/api/v3/models/build.rb",
-    "lib/travis/api/v3/models/commit.rb",
-    "lib/travis/api/v3/models/cron.rb",
-    "lib/travis/api/v3/models/email.rb",
-    "lib/travis/api/v3/models/job.rb",
-    "lib/travis/api/v3/models/log.rb",
-    "lib/travis/api/v3/models/log_part.rb",
-    "lib/travis/api/v3/models/membership.rb",
-    "lib/travis/api/v3/models/organization.rb",
-    "lib/travis/api/v3/models/permission.rb",
-    "lib/travis/api/v3/models/repository.rb",
-    "lib/travis/api/v3/models/request.rb",
-    "lib/travis/api/v3/models/settings.rb",
-    "lib/travis/api/v3/models/ssl_key.rb",
-    "lib/travis/api/v3/models/star.rb",
-    "lib/travis/api/v3/models/subscription.rb",
-    "lib/travis/api/v3/models/token.rb",
-    "lib/travis/api/v3/models/user.rb",
-    "lib/travis/api/v3/opt_in.rb",
-    "lib/travis/api/v3/paginator.rb",
-    "lib/travis/api/v3/paginator/url_generator.rb",
-    "lib/travis/api/v3/permissions.rb",
-    "lib/travis/api/v3/permissions/account.rb",
-    "lib/travis/api/v3/permissions/build.rb",
-    "lib/travis/api/v3/permissions/cron.rb",
-    "lib/travis/api/v3/permissions/generic.rb",
-    "lib/travis/api/v3/permissions/job.rb",
-    "lib/travis/api/v3/permissions/organization.rb",
-    "lib/travis/api/v3/permissions/repository.rb",
-    "lib/travis/api/v3/permissions/user.rb",
-    "lib/travis/api/v3/queries.rb",
-    "lib/travis/api/v3/queries/accounts.rb",
-    "lib/travis/api/v3/queries/branch.rb",
-    "lib/travis/api/v3/queries/branches.rb",
-    "lib/travis/api/v3/queries/broadcasts.rb",
-    "lib/travis/api/v3/queries/build.rb",
-    "lib/travis/api/v3/queries/builds.rb",
-    "lib/travis/api/v3/queries/cron.rb",
-    "lib/travis/api/v3/queries/crons.rb",
-    "lib/travis/api/v3/queries/job.rb",
-    "lib/travis/api/v3/queries/jobs.rb",
-    "lib/travis/api/v3/queries/organization.rb",
-    "lib/travis/api/v3/queries/organizations.rb",
-    "lib/travis/api/v3/queries/owner.rb",
-    "lib/travis/api/v3/queries/repositories.rb",
-    "lib/travis/api/v3/queries/repository.rb",
-    "lib/travis/api/v3/queries/request.rb",
-    "lib/travis/api/v3/queries/requests.rb",
-    "lib/travis/api/v3/queries/settings.rb",
-    "lib/travis/api/v3/queries/user.rb",
-    "lib/travis/api/v3/query.rb",
-    "lib/travis/api/v3/renderer.rb",
-    "lib/travis/api/v3/renderer/accepted.rb",
-    "lib/travis/api/v3/renderer/account.rb",
-    "lib/travis/api/v3/renderer/accounts.rb",
-    "lib/travis/api/v3/renderer/avatar_url.rb",
-    "lib/travis/api/v3/renderer/branch.rb",
-    "lib/travis/api/v3/renderer/branches.rb",
-    "lib/travis/api/v3/renderer/broadcast.rb",
-    "lib/travis/api/v3/renderer/broadcasts.rb",
-    "lib/travis/api/v3/renderer/build.rb",
-    "lib/travis/api/v3/renderer/builds.rb",
-    "lib/travis/api/v3/renderer/collection_renderer.rb",
-    "lib/travis/api/v3/renderer/commit.rb",
-    "lib/travis/api/v3/renderer/cron.rb",
-    "lib/travis/api/v3/renderer/crons.rb",
-    "lib/travis/api/v3/renderer/error.rb",
-    "lib/travis/api/v3/renderer/job.rb",
-    "lib/travis/api/v3/renderer/jobs.rb",
-    "lib/travis/api/v3/renderer/lint.rb",
-    "lib/travis/api/v3/renderer/model_renderer.rb",
-    "lib/travis/api/v3/renderer/organization.rb",
-    "lib/travis/api/v3/renderer/organizations.rb",
-    "lib/travis/api/v3/renderer/owner.rb",
-    "lib/travis/api/v3/renderer/repositories.rb",
-    "lib/travis/api/v3/renderer/repository.rb",
-    "lib/travis/api/v3/renderer/request.rb",
-    "lib/travis/api/v3/renderer/requests.rb",
-    "lib/travis/api/v3/renderer/settings.rb",
-    "lib/travis/api/v3/renderer/user.rb",
-    "lib/travis/api/v3/result.rb",
-    "lib/travis/api/v3/router.rb",
-    "lib/travis/api/v3/routes.rb",
-    "lib/travis/api/v3/routes/dsl.rb",
-    "lib/travis/api/v3/routes/resource.rb",
-    "lib/travis/api/v3/service.rb",
-    "lib/travis/api/v3/service_index.rb",
-    "lib/travis/api/v3/services.rb",
-    "lib/travis/api/v3/services/accounts/for_current_user.rb",
-    "lib/travis/api/v3/services/branch/find.rb",
-    "lib/travis/api/v3/services/branches/find.rb",
-    "lib/travis/api/v3/services/broadcasts/for_current_user.rb",
-    "lib/travis/api/v3/services/build/cancel.rb",
-    "lib/travis/api/v3/services/build/find.rb",
-    "lib/travis/api/v3/services/build/restart.rb",
-    "lib/travis/api/v3/services/builds/find.rb",
-    "lib/travis/api/v3/services/cron/create.rb",
-    "lib/travis/api/v3/services/cron/delete.rb",
-    "lib/travis/api/v3/services/cron/find.rb",
-    "lib/travis/api/v3/services/cron/for_branch.rb",
-    "lib/travis/api/v3/services/crons/for_repository.rb",
-    "lib/travis/api/v3/services/crons/start.rb",
-    "lib/travis/api/v3/services/job/cancel.rb",
-    "lib/travis/api/v3/services/job/debug.rb",
-    "lib/travis/api/v3/services/job/find.rb",
-    "lib/travis/api/v3/services/job/restart.rb",
-    "lib/travis/api/v3/services/jobs/find.rb",
-    "lib/travis/api/v3/services/lint/lint.rb",
-    "lib/travis/api/v3/services/organization/find.rb",
-    "lib/travis/api/v3/services/organization/sync.rb",
-    "lib/travis/api/v3/services/organizations/for_current_user.rb",
-    "lib/travis/api/v3/services/owner/find.rb",
-    "lib/travis/api/v3/services/repositories/for_current_user.rb",
-    "lib/travis/api/v3/services/repositories/for_owner.rb",
-    "lib/travis/api/v3/services/repository/disable.rb",
-    "lib/travis/api/v3/services/repository/enable.rb",
-    "lib/travis/api/v3/services/repository/find.rb",
-    "lib/travis/api/v3/services/repository/settings.rb",
-    "lib/travis/api/v3/services/repository/star.rb",
-    "lib/travis/api/v3/services/repository/unstar.rb",
-    "lib/travis/api/v3/services/requests/create.rb",
-    "lib/travis/api/v3/services/requests/find.rb",
-    "lib/travis/api/v3/services/settings/find.rb",
-    "lib/travis/api/v3/services/settings/update.rb",
-    "lib/travis/api/v3/services/user/current.rb",
-    "lib/travis/api/v3/services/user/find.rb",
-    "lib/travis/api/v3/services/user/sync.rb",
-    "lib/travis/api/workers/build_cancellation.rb",
-    "lib/travis/api/workers/build_restart.rb",
-    "lib/travis/api/workers/job_cancellation.rb",
-    "lib/travis/api/workers/job_restart.rb",
-    "lib/travis/private_key.rb",
-    "lib/travis/sidekiq.rb",
-    "public/favicon.ico",
-    "public/images/result/canceled.png",
-    "public/images/result/canceled.svg",
-    "public/images/result/error.png",
-    "public/images/result/error.svg",
-    "public/images/result/failing.png",
-    "public/images/result/failing.svg",
-    "public/images/result/passing.png",
-    "public/images/result/passing.svg",
-    "public/images/result/pending.png",
-    "public/images/result/pending.svg",
-    "public/images/result/unknown.png",
-    "public/images/result/unknown.svg",
-    "script/console",
-    "script/repos_stats.rb",
-    "script/server",
-    "script/start_crons",
-    "script/web_concurrency",
-    "spec/active_record_postgres_variables_spec.rb",
-    "spec/integration/error_handling_spec.rb",
-    "spec/integration/formats_handling_spec.rb",
-    "spec/integration/responders_spec.rb",
-    "spec/integration/routes.backup.rb",
-    "spec/integration/scopes_spec.rb",
-    "spec/integration/settings_endpoint_spec.rb",
-    "spec/integration/singleton_settings_endpoint_spec.rb",
-    "spec/integration/uptime_spec.rb",
-    "spec/integration/v2/branches_spec.rb",
-    "spec/integration/v2/builds_spec.rb",
-    "spec/integration/v2/hooks_spec.rb",
-    "spec/integration/v2/jobs_spec.rb",
-    "spec/integration/v2/repositories_spec.rb",
-    "spec/integration/v2/requests_spec.rb",
-    "spec/integration/v2/settings/env_vars_spec.rb",
-    "spec/integration/v2/settings/ssh_key_spec.rb",
-    "spec/integration/v2/users_spec.rb",
-    "spec/integration/v2_spec.backup.rb",
-    "spec/integration/version_spec.rb",
-    "spec/spec_helper.rb",
-    "spec/spec_helper_core.rb",
-    "spec/support.rb",
-    "spec/support/active_record.rb",
-    "spec/support/coverage.rb",
-    "spec/support/formats.rb",
-    "spec/support/gcs.rb",
-    "spec/support/matchers.rb",
-    "spec/support/payloads.rb",
-    "spec/support/s3.rb",
-    "spec/unit/access_token_spec.rb",
-    "spec/unit/api/v2/http/accounts_spec.rb",
-    "spec/unit/api/v2/http/annotations_spec.rb",
-    "spec/unit/api/v2/http/branch_spec.rb",
-    "spec/unit/api/v2/http/branches_spec.rb",
-    "spec/unit/api/v2/http/broadcasts_spec.rb",
-    "spec/unit/api/v2/http/build_spec.rb",
-    "spec/unit/api/v2/http/builds_spec.rb",
-    "spec/unit/api/v2/http/caches_spec.rb",
-    "spec/unit/api/v2/http/env_var_spec.rb",
-    "spec/unit/api/v2/http/hooks_spec.rb",
-    "spec/unit/api/v2/http/job_spec.rb",
-    "spec/unit/api/v2/http/jobs_spec.rb",
-    "spec/unit/api/v2/http/log_spec.rb",
-    "spec/unit/api/v2/http/permissions_spec.rb",
-    "spec/unit/api/v2/http/repositories_spec.rb",
-    "spec/unit/api/v2/http/repository_spec.rb",
-    "spec/unit/api/v2/http/request_spec.rb",
-    "spec/unit/api/v2/http/requests_spec.rb",
-    "spec/unit/api/v2/http/ssl_key_spec.rb",
-    "spec/unit/api/v2/http/user_spec.rb",
-    "spec/unit/app_spec.rb",
-    "spec/unit/cors_spec.rb",
-    "spec/unit/default_spec.rb",
-    "spec/unit/endpoint/accounts_spec.rb",
-    "spec/unit/endpoint/authorization/user_manager_spec.rb",
-    "spec/unit/endpoint/authorization_spec.rb",
-    "spec/unit/endpoint/branches_spec.rb",
-    "spec/unit/endpoint/builds_spec.rb",
-    "spec/unit/endpoint/endpoints_spec.rb",
-    "spec/unit/endpoint/hooks_spec.rb",
-    "spec/unit/endpoint/jobs_spec.rb",
-    "spec/unit/endpoint/lint_spec.rb",
-    "spec/unit/endpoint/logs_spec.rb",
-    "spec/unit/endpoint/repos_spec.rb",
-    "spec/unit/endpoint/requests/throttle_spec.rb",
-    "spec/unit/endpoint/users_spec.rb",
-    "spec/unit/endpoint_spec.rb",
-    "spec/unit/extensions/expose_pattern_spec.rb",
-    "spec/unit/extensions/scoping_spec.rb",
-    "spec/unit/extensions/smart_constants_spec.rb",
-    "spec/unit/extensions/subclass_tracker_spec.rb",
-    "spec/unit/helpers/accept_spec.rb",
-    "spec/unit/helpers/json_renderer_spec.rb",
-    "spec/unit/middleware/logging_spec.rb",
-    "spec/unit/middleware/scope_check_spec.rb",
-    "spec/unit/middleware/user_agent_tracker_spec.rb",
-    "spec/unit/responders/json_spec.rb",
-    "spec/unit/responders/service_spec.rb",
-    "spec/v3/error_handling_spec.rb",
-    "spec/v3/extensions/belongs_to_spec.rb",
-    "spec/v3/metrics_spec.rb",
-    "spec/v3/models/cron_spec.rb",
-    "spec/v3/queries/cron_spec.rb",
-    "spec/v3/renderer/avatar_url_spec.rb",
-    "spec/v3/result_spec.rb",
-    "spec/v3/service_index_spec.rb",
-    "spec/v3/services/accounts/for_current_user_spec.rb",
-    "spec/v3/services/branch/find_spec.rb",
-    "spec/v3/services/branches/find_spec.rb",
-    "spec/v3/services/broadcasts/for_current_user_spec.rb",
-    "spec/v3/services/build/cancel_spec.rb",
-    "spec/v3/services/build/find_spec.rb",
-    "spec/v3/services/build/restart_spec.rb",
-    "spec/v3/services/builds/find_spec.rb",
-    "spec/v3/services/cron/create_spec.rb",
-    "spec/v3/services/cron/delete_spec.rb",
-    "spec/v3/services/cron/find_spec.rb",
-    "spec/v3/services/cron/for_branch_spec.rb",
-    "spec/v3/services/crons/for_repository_spec.rb",
-    "spec/v3/services/job/cancel_spec.rb",
-    "spec/v3/services/job/debug_sepc.rb",
-    "spec/v3/services/job/find_spec.rb",
-    "spec/v3/services/job/restart_spec.rb",
-    "spec/v3/services/jobs/find_spec.rb",
-    "spec/v3/services/lint/lint_spec.rb",
-    "spec/v3/services/organization/find_spec.rb",
-    "spec/v3/services/organizations/for_current_user_spec.rb",
-    "spec/v3/services/owner/find_spec.rb",
-    "spec/v3/services/repositories/for_current_user_spec.rb",
-    "spec/v3/services/repositories/for_owner_spec.rb",
-    "spec/v3/services/repository/disable_spec.rb",
-    "spec/v3/services/repository/enable_spec.rb",
-    "spec/v3/services/repository/find_spec.rb",
-    "spec/v3/services/repository/star_spec.rb",
-    "spec/v3/services/repository/unstar_spec.rb",
-    "spec/v3/services/requests/create_spec.rb",
-    "spec/v3/services/requests/find_spec.rb",
-    "spec/v3/services/settings_spec.rb",
-    "spec/v3/services/user/current_spec.rb",
-    "spec/v3/services/user/find_spec.rb",
-    "spec/v3/services/user/sync_spec.rb",
-    "spec_core/core/model/annotation_provider_spec.rb",
-    "spec_core/core/model/annotation_spec.rb",
-    "spec_core/core/model/broadcast_spec.rb",
-    "spec_core/core/model/build/compat_spec.rb",
-    "spec_core/core/model/build/config/dist_spec.rb",
-    "spec_core/core/model/build/config/group_spec.rb",
-    "spec_core/core/model/build/config/matrix_spec.rb",
-    "spec_core/core/model/build/config/obfuscate_spec.rb",
-    "spec_core/core/model/build/config_spec.rb",
-    "spec_core/core/model/build/denormalize_spec.rb",
-    "spec_core/core/model/build/matrix_spec.rb",
-    "spec_core/core/model/build/metrics_spec.rb",
-    "spec_core/core/model/build/result_message_spec.rb",
-    "spec_core/core/model/build/states_spec.rb",
-    "spec_core/core/model/build/update_branch_spec.rb",
-    "spec_core/core/model/build_spec.rb",
-    "spec_core/core/model/commit_spec.rb",
-    "spec_core/core/model/encrypted_column_spec.rb",
-    "spec_core/core/model/job/cleanup_spec.rb",
-    "spec_core/core/model/job/queue_spec.rb",
-    "spec_core/core/model/job/test_spec.rb",
-    "spec_core/core/model/job_spec.rb",
-    "spec_core/core/model/organization_spec.rb",
-    "spec_core/core/model/permission_spec.rb",
-    "spec_core/core/model/repository/settings/ssh_key_spec.rb",
-    "spec_core/core/model/repository/settings_spec.rb",
-    "spec_core/core/model/repository/status_image_spec.rb",
-    "spec_core/core/model/repository_spec.rb",
-    "spec_core/core/model/request/approval_spec.rb",
-    "spec_core/core/model/request/branches_spec.rb",
-    "spec_core/core/model/request/states_spec.rb",
-    "spec_core/core/model/request_spec.rb",
-    "spec_core/core/model/ssl_key_spec.rb",
-    "spec_core/core/model/token_spec.rb",
-    "spec_core/core/model/url_spec.rb",
-    "spec_core/core/model/user/oauth_spec.rb",
-    "spec_core/core/model/user_spec.rb",
-    "spec_core/core/services/cancel_build_spec.rb",
-    "spec_core/core/services/cancel_job_spec.rb",
-    "spec_core/core/services/find_admin_spec.rb",
-    "spec_core/core/services/find_annotation_spec.rb",
-    "spec_core/core/services/find_branch_spec.rb",
-    "spec_core/core/services/find_branches_spec.rb",
-    "spec_core/core/services/find_build_spec.rb",
-    "spec_core/core/services/find_builds_spec.rb",
-    "spec_core/core/services/find_caches_spec.rb",
-    "spec_core/core/services/find_daily_repos_stats_spec.rb",
-    "spec_core/core/services/find_daily_tests_stats_spec.rb",
-    "spec_core/core/services/find_hooks_spec.rb",
-    "spec_core/core/services/find_job_spec.rb",
-    "spec_core/core/services/find_jobs_spec.rb",
-    "spec_core/core/services/find_log_spec.rb",
-    "spec_core/core/services/find_repo_key_spec.rb",
-    "spec_core/core/services/find_repo_settings_spec.rb",
-    "spec_core/core/services/find_repo_spec.rb",
-    "spec_core/core/services/find_repos_spec.rb",
-    "spec_core/core/services/find_request_spec.rb",
-    "spec_core/core/services/find_requests_spec.rb",
-    "spec_core/core/services/find_user_accounts_spec.rb",
-    "spec_core/core/services/next_build_number_spec.rb",
-    "spec_core/core/services/regenerate_repo_key_spec.rb",
-    "spec_core/core/services/remove_log_spec.rb",
-    "spec_core/core/services/reset_model_spec.rb",
-    "spec_core/core/services/sync_user_spec.rb",
-    "spec_core/core/services/update_annotation_spec.rb",
-    "spec_core/core/services/update_hook_spec.rb",
-    "spec_core/core/services/update_job_spec.rb",
-    "spec_core/core/services/update_log_spec.rb",
-    "spec_core/core/services/update_user_spec.rb",
-    "spec_core/core/services_spec.rb",
-    "tmp/.gitkeep",
-    "travis-api.gemspec",
-    "vendor/travis-core/lib/travis.rb",
-    "vendor/travis-core/lib/travis/addons.rb",
-    "vendor/travis-core/lib/travis/addons/README.markdown",
-    "vendor/travis-core/lib/travis/addons/archive.rb",
-    "vendor/travis-core/lib/travis/addons/archive/event_handler.rb",
-    "vendor/travis-core/lib/travis/addons/archive/task.rb",
-    "vendor/travis-core/lib/travis/addons/campfire.rb",
-    "vendor/travis-core/lib/travis/addons/campfire/event_handler.rb",
-    "vendor/travis-core/lib/travis/addons/campfire/instruments.rb",
-    "vendor/travis-core/lib/travis/addons/email.rb",
-    "vendor/travis-core/lib/travis/addons/email/event_handler.rb",
-    "vendor/travis-core/lib/travis/addons/email/instruments.rb",
-    "vendor/travis-core/lib/travis/addons/flowdock.rb",
-    "vendor/travis-core/lib/travis/addons/flowdock/event_handler.rb",
-    "vendor/travis-core/lib/travis/addons/flowdock/instruments.rb",
-    "vendor/travis-core/lib/travis/addons/github_status.rb",
-    "vendor/travis-core/lib/travis/addons/github_status/event_handler.rb",
-    "vendor/travis-core/lib/travis/addons/github_status/instruments.rb",
-    "vendor/travis-core/lib/travis/addons/hipchat.rb",
-    "vendor/travis-core/lib/travis/addons/hipchat/event_handler.rb",
-    "vendor/travis-core/lib/travis/addons/hipchat/instruments.rb",
-    "vendor/travis-core/lib/travis/addons/irc.rb",
-    "vendor/travis-core/lib/travis/addons/irc/event_handler.rb",
-    "vendor/travis-core/lib/travis/addons/irc/instruments.rb",
-    "vendor/travis-core/lib/travis/addons/pusher.rb",
-    "vendor/travis-core/lib/travis/addons/pusher/event_handler.rb",
-    "vendor/travis-core/lib/travis/addons/pusher/instruments.rb",
-    "vendor/travis-core/lib/travis/addons/pushover.rb",
-    "vendor/travis-core/lib/travis/addons/pushover/event_handler.rb",
-    "vendor/travis-core/lib/travis/addons/pushover/instruments.rb",
-    "vendor/travis-core/lib/travis/addons/slack.rb",
-    "vendor/travis-core/lib/travis/addons/slack/event_handler.rb",
-    "vendor/travis-core/lib/travis/addons/slack/instruments.rb",
-    "vendor/travis-core/lib/travis/addons/sqwiggle.rb",
-    "vendor/travis-core/lib/travis/addons/sqwiggle/event_handler.rb",
-    "vendor/travis-core/lib/travis/addons/sqwiggle/instruments.rb",
-    "vendor/travis-core/lib/travis/addons/states_cache.rb",
-    "vendor/travis-core/lib/travis/addons/states_cache/event_handler.rb",
-    "vendor/travis-core/lib/travis/addons/util.rb",
-    "vendor/travis-core/lib/travis/addons/webhook.rb",
-    "vendor/travis-core/lib/travis/addons/webhook/event_handler.rb",
-    "vendor/travis-core/lib/travis/addons/webhook/instruments.rb",
-    "vendor/travis-core/lib/travis/api.rb",
-    "vendor/travis-core/lib/travis/api/README.markdown",
-    "vendor/travis-core/lib/travis/api/formats.rb",
-    "vendor/travis-core/lib/travis/api/v0.rb",
-    "vendor/travis-core/lib/travis/api/v0/event.rb",
-    "vendor/travis-core/lib/travis/api/v0/event/build.rb",
-    "vendor/travis-core/lib/travis/api/v0/event/job.rb",
-    "vendor/travis-core/lib/travis/api/v0/notification.rb",
-    "vendor/travis-core/lib/travis/api/v0/notification/build.rb",
-    "vendor/travis-core/lib/travis/api/v0/notification/repository.rb",
-    "vendor/travis-core/lib/travis/api/v0/notification/user.rb",
-    "vendor/travis-core/lib/travis/api/v0/pusher.rb",
-    "vendor/travis-core/lib/travis/api/v0/pusher/annotation.rb",
-    "vendor/travis-core/lib/travis/api/v0/pusher/annotation/created.rb",
-    "vendor/travis-core/lib/travis/api/v0/pusher/annotation/updated.rb",
-    "vendor/travis-core/lib/travis/api/v0/pusher/build.rb",
-    "vendor/travis-core/lib/travis/api/v0/pusher/build/canceled.rb",
-    "vendor/travis-core/lib/travis/api/v0/pusher/build/created.rb",
-    "vendor/travis-core/lib/travis/api/v0/pusher/build/finished.rb",
-    "vendor/travis-core/lib/travis/api/v0/pusher/build/received.rb",
-    "vendor/travis-core/lib/travis/api/v0/pusher/build/received/job.rb",
-    "vendor/travis-core/lib/travis/api/v0/pusher/build/started.rb",
-    "vendor/travis-core/lib/travis/api/v0/pusher/build/started/job.rb",
-    "vendor/travis-core/lib/travis/api/v0/pusher/job.rb",
-    "vendor/travis-core/lib/travis/api/v0/pusher/job/canceled.rb",
-    "vendor/travis-core/lib/travis/api/v0/pusher/job/created.rb",
-    "vendor/travis-core/lib/travis/api/v0/pusher/job/finished.rb",
-    "vendor/travis-core/lib/travis/api/v0/pusher/job/log.rb",
-    "vendor/travis-core/lib/travis/api/v0/pusher/job/received.rb",
-    "vendor/travis-core/lib/travis/api/v0/pusher/job/started.rb",
-    "vendor/travis-core/lib/travis/api/v0/worker.rb",
-    "vendor/travis-core/lib/travis/api/v0/worker/job.rb",
-    "vendor/travis-core/lib/travis/api/v0/worker/job/test.rb",
-    "vendor/travis-core/lib/travis/api/v1.rb",
-    "vendor/travis-core/lib/travis/api/v1/archive.rb",
-    "vendor/travis-core/lib/travis/api/v1/archive/build.rb",
-    "vendor/travis-core/lib/travis/api/v1/archive/build/job.rb",
-    "vendor/travis-core/lib/travis/api/v1/helpers.rb",
-    "vendor/travis-core/lib/travis/api/v1/helpers/legacy.rb",
-    "vendor/travis-core/lib/travis/api/v1/http.rb",
-    "vendor/travis-core/lib/travis/api/v1/http/branches.rb",
-    "vendor/travis-core/lib/travis/api/v1/http/build.rb",
-    "vendor/travis-core/lib/travis/api/v1/http/build/job.rb",
-    "vendor/travis-core/lib/travis/api/v1/http/builds.rb",
-    "vendor/travis-core/lib/travis/api/v1/http/hooks.rb",
-    "vendor/travis-core/lib/travis/api/v1/http/job.rb",
-    "vendor/travis-core/lib/travis/api/v1/http/jobs.rb",
-    "vendor/travis-core/lib/travis/api/v1/http/repositories.rb",
-    "vendor/travis-core/lib/travis/api/v1/http/repository.rb",
-    "vendor/travis-core/lib/travis/api/v1/http/user.rb",
-    "vendor/travis-core/lib/travis/api/v1/webhook.rb",
-    "vendor/travis-core/lib/travis/api/v1/webhook/build.rb",
-    "vendor/travis-core/lib/travis/api/v1/webhook/build/finished.rb",
-    "vendor/travis-core/lib/travis/api/v1/webhook/build/finished/job.rb",
-    "vendor/travis-core/lib/travis/api/v2.rb",
-    "vendor/travis-core/lib/travis/commit_command.rb",
-    "vendor/travis-core/lib/travis/config/database.rb",
-    "vendor/travis-core/lib/travis/config/defaults.rb",
-    "vendor/travis-core/lib/travis/config/url.rb",
-    "vendor/travis-core/lib/travis/errors.rb",
-    "vendor/travis-core/lib/travis/event.rb",
-    "vendor/travis-core/lib/travis/event/config.rb",
-    "vendor/travis-core/lib/travis/event/handler.rb",
-    "vendor/travis-core/lib/travis/event/handler/metrics.rb",
-    "vendor/travis-core/lib/travis/event/handler/trail.rb",
-    "vendor/travis-core/lib/travis/event/subscription.rb",
-    "vendor/travis-core/lib/travis/features.rb",
-    "vendor/travis-core/lib/travis/github.rb",
-    "vendor/travis-core/lib/travis/github/education.rb",
-    "vendor/travis-core/lib/travis/github/services.rb",
-    "vendor/travis-core/lib/travis/github/services/find_or_create_org.rb",
-    "vendor/travis-core/lib/travis/github/services/find_or_create_repo.rb",
-    "vendor/travis-core/lib/travis/github/services/find_or_create_user.rb",
-    "vendor/travis-core/lib/travis/github/services/set_hook.rb",
-    "vendor/travis-core/lib/travis/github/services/sync_user.rb",
-    "vendor/travis-core/lib/travis/github/services/sync_user/organizations.rb",
-    "vendor/travis-core/lib/travis/github/services/sync_user/repositories.rb",
-    "vendor/travis-core/lib/travis/github/services/sync_user/repository.rb",
-    "vendor/travis-core/lib/travis/github/services/sync_user/reset_token.rb",
-    "vendor/travis-core/lib/travis/github/services/sync_user/user_info.rb",
-    "vendor/travis-core/lib/travis/mailer.rb",
-    "vendor/travis-core/lib/travis/mailer/user_mailer.rb",
-    "vendor/travis-core/lib/travis/mailer/views/layouts/contact_email.html.erb",
-    "vendor/travis-core/lib/travis/mailer/views/user_mailer/welcome_email.html.erb",
-    "vendor/travis-core/lib/travis/model.rb",
-    "vendor/travis-core/lib/travis/model/account.rb",
-    "vendor/travis-core/lib/travis/model/annotation.rb",
-    "vendor/travis-core/lib/travis/model/annotation_provider.rb",
-    "vendor/travis-core/lib/travis/model/branch.rb",
-    "vendor/travis-core/lib/travis/model/broadcast.rb",
-    "vendor/travis-core/lib/travis/model/build.rb",
-    "vendor/travis-core/lib/travis/model/build/config.rb",
-    "vendor/travis-core/lib/travis/model/build/config/dist.rb",
-    "vendor/travis-core/lib/travis/model/build/config/env.rb",
-    "vendor/travis-core/lib/travis/model/build/config/features.rb",
-    "vendor/travis-core/lib/travis/model/build/config/group.rb",
-    "vendor/travis-core/lib/travis/model/build/config/language.rb",
-    "vendor/travis-core/lib/travis/model/build/config/matrix.rb",
-    "vendor/travis-core/lib/travis/model/build/config/obfuscate.rb",
-    "vendor/travis-core/lib/travis/model/build/config/os.rb",
-    "vendor/travis-core/lib/travis/model/build/config/yaml.rb",
-    "vendor/travis-core/lib/travis/model/build/denormalize.rb",
-    "vendor/travis-core/lib/travis/model/build/matrix.rb",
-    "vendor/travis-core/lib/travis/model/build/metrics.rb",
-    "vendor/travis-core/lib/travis/model/build/result_message.rb",
-    "vendor/travis-core/lib/travis/model/build/states.rb",
-    "vendor/travis-core/lib/travis/model/build/update_branch.rb",
-    "vendor/travis-core/lib/travis/model/commit.rb",
-    "vendor/travis-core/lib/travis/model/email.rb",
-    "vendor/travis-core/lib/travis/model/encrypted_column.rb",
-    "vendor/travis-core/lib/travis/model/env_helpers.rb",
-    "vendor/travis-core/lib/travis/model/job.rb",
-    "vendor/travis-core/lib/travis/model/job/cleanup.rb",
-    "vendor/travis-core/lib/travis/model/job/queue.rb",
-    "vendor/travis-core/lib/travis/model/job/test.rb",
-    "vendor/travis-core/lib/travis/model/log.rb",
-    "vendor/travis-core/lib/travis/model/log/part.rb",
-    "vendor/travis-core/lib/travis/model/logs_model.rb",
-    "vendor/travis-core/lib/travis/model/membership.rb",
-    "vendor/travis-core/lib/travis/model/organization.rb",
-    "vendor/travis-core/lib/travis/model/permission.rb",
-    "vendor/travis-core/lib/travis/model/repository.rb",
-    "vendor/travis-core/lib/travis/model/repository/settings.rb",
-    "vendor/travis-core/lib/travis/model/repository/status_image.rb",
-    "vendor/travis-core/lib/travis/model/request.rb",
-    "vendor/travis-core/lib/travis/model/request/approval.rb",
-    "vendor/travis-core/lib/travis/model/request/branches.rb",
-    "vendor/travis-core/lib/travis/model/request/pull_request.rb",
-    "vendor/travis-core/lib/travis/model/request/states.rb",
-    "vendor/travis-core/lib/travis/model/ssl_key.rb",
-    "vendor/travis-core/lib/travis/model/token.rb",
-    "vendor/travis-core/lib/travis/model/url.rb",
-    "vendor/travis-core/lib/travis/model/user.rb",
-    "vendor/travis-core/lib/travis/model/user/oauth.rb",
-    "vendor/travis-core/lib/travis/model/user/renaming.rb",
-    "vendor/travis-core/lib/travis/notification.rb",
-    "vendor/travis-core/lib/travis/notification/instrument.rb",
-    "vendor/travis-core/lib/travis/notification/instrument/event_handler.rb",
-    "vendor/travis-core/lib/travis/notification/instrument/task.rb",
-    "vendor/travis-core/lib/travis/notification/publisher.rb",
-    "vendor/travis-core/lib/travis/notification/publisher/log.rb",
-    "vendor/travis-core/lib/travis/notification/publisher/memory.rb",
-    "vendor/travis-core/lib/travis/notification/publisher/redis.rb",
-    "vendor/travis-core/lib/travis/overwritable_method_definitions.rb",
-    "vendor/travis-core/lib/travis/redis_pool.rb",
-    "vendor/travis-core/lib/travis/secure_config.rb",
-    "vendor/travis-core/lib/travis/services.rb",
-    "vendor/travis-core/lib/travis/services/base.rb",
-    "vendor/travis-core/lib/travis/services/cancel_build.rb",
-    "vendor/travis-core/lib/travis/services/cancel_job.rb",
-    "vendor/travis-core/lib/travis/services/delete_caches.rb",
-    "vendor/travis-core/lib/travis/services/find_admin.rb",
-    "vendor/travis-core/lib/travis/services/find_annotations.rb",
-    "vendor/travis-core/lib/travis/services/find_branch.rb",
-    "vendor/travis-core/lib/travis/services/find_branches.rb",
-    "vendor/travis-core/lib/travis/services/find_build.rb",
-    "vendor/travis-core/lib/travis/services/find_builds.rb",
-    "vendor/travis-core/lib/travis/services/find_caches.rb",
-    "vendor/travis-core/lib/travis/services/find_daily_repos_stats.rb",
-    "vendor/travis-core/lib/travis/services/find_daily_tests_stats.rb",
-    "vendor/travis-core/lib/travis/services/find_hooks.rb",
-    "vendor/travis-core/lib/travis/services/find_job.rb",
-    "vendor/travis-core/lib/travis/services/find_jobs.rb",
-    "vendor/travis-core/lib/travis/services/find_log.rb",
-    "vendor/travis-core/lib/travis/services/find_repo.rb",
-    "vendor/travis-core/lib/travis/services/find_repo_key.rb",
-    "vendor/travis-core/lib/travis/services/find_repo_settings.rb",
-    "vendor/travis-core/lib/travis/services/find_repos.rb",
-    "vendor/travis-core/lib/travis/services/find_request.rb",
-    "vendor/travis-core/lib/travis/services/find_requests.rb",
-    "vendor/travis-core/lib/travis/services/find_user_accounts.rb",
-    "vendor/travis-core/lib/travis/services/find_user_broadcasts.rb",
-    "vendor/travis-core/lib/travis/services/find_user_permissions.rb",
-    "vendor/travis-core/lib/travis/services/helpers.rb",
-    "vendor/travis-core/lib/travis/services/next_build_number.rb",
-    "vendor/travis-core/lib/travis/services/regenerate_repo_key.rb",
-    "vendor/travis-core/lib/travis/services/registry.rb",
-    "vendor/travis-core/lib/travis/services/remove_log.rb",
-    "vendor/travis-core/lib/travis/services/reset_model.rb",
-    "vendor/travis-core/lib/travis/services/sync_user.rb",
-    "vendor/travis-core/lib/travis/services/update_annotation.rb",
-    "vendor/travis-core/lib/travis/services/update_hook.rb",
-    "vendor/travis-core/lib/travis/services/update_job.rb",
-    "vendor/travis-core/lib/travis/services/update_log.rb",
-    "vendor/travis-core/lib/travis/services/update_user.rb",
-    "vendor/travis-core/lib/travis/settings.rb",
-    "vendor/travis-core/lib/travis/settings/collection.rb",
-    "vendor/travis-core/lib/travis/settings/encrypted_value.rb",
-    "vendor/travis-core/lib/travis/settings/model.rb",
-    "vendor/travis-core/lib/travis/settings/model_extensions.rb",
-    "vendor/travis-core/lib/travis/states_cache.rb",
-    "vendor/travis-core/lib/travis/task.rb",
-    "vendor/travis-core/lib/travis/testing.rb",
-    "vendor/travis-core/lib/travis/testing/factories.rb",
-    "vendor/travis-core/lib/travis/testing/matchers.rb",
-    "vendor/travis-core/lib/travis/testing/payloads.rb",
-    "vendor/travis-core/lib/travis/testing/scenario.rb",
-    "vendor/travis-core/lib/travis/testing/stubs.rb",
-    "vendor/travis-core/lib/travis/testing/stubs/stub.rb",
-    "vendor/travis-core/lib/travis_core/version.rb",
-    "vendor/travis-core/travis-core.gemspec"
-  ]
+  s.authors      = ['Travis CI and others']
+  s.email        = ['contact@travis-ci.org']
 
   s.add_dependency 'travis-support'
-
   s.add_dependency 'pg'
   s.add_dependency 'composite_primary_keys', '~> 5.0'
   s.add_dependency 'sinatra',                '~> 1.3'
diff --git a/vendor/travis-core/lib/travis/event/handler/metrics.rb b/vendor/travis-core/lib/travis/event/handler/metrics.rb
index 0548c7e8..2cbce9f9 100644
--- a/vendor/travis-core/lib/travis/event/handler/metrics.rb
+++ b/vendor/travis-core/lib/travis/event/handler/metrics.rb
@@ -10,7 +10,7 @@ module Travis
 
         def initialize(*)
           super
-          @payload = Api.data(object, type: 'job', for: 'event', version: 'v0', params: data)
+          @payload = Api::Serialize.data(object, type: 'job', for: 'event', version: 'v0', params: data)
         end
 
         def handle?
diff --git a/vendor/travis-core/lib/travis/model/repository.rb b/vendor/travis-core/lib/travis/model/repository.rb
index cc70423d..b287dece 100644
--- a/vendor/travis-core/lib/travis/model/repository.rb
+++ b/vendor/travis-core/lib/travis/model/repository.rb
@@ -28,9 +28,9 @@ class Repository < Travis::Model
   validates :name,       presence: true
   validates :owner_name, presence: true
 
-  before_create do
-    build_key
-  end
+  # before_create do
+  #   build_key
+  # end
 
   delegate :public_key, to: :key
 
diff --git a/vendor/travis-core/lib/travis/model/user.rb b/vendor/travis-core/lib/travis/model/user.rb
index f356632b..692918d0 100644
--- a/vendor/travis-core/lib/travis/model/user.rb
+++ b/vendor/travis-core/lib/travis/model/user.rb
@@ -136,8 +136,13 @@ class User < Travis::Model
 
   protected
 
+    # TODO this accesses GitHub during tests. should move initializing the scopes out of the model.
     def track_github_scopes
-      self.github_scopes = Travis::Github.scopes_for(self) if github_oauth_token_changed? or github_scopes.blank?
+      self.github_scopes = Travis::Github.scopes_for(self) if invalid_github_scopes?
+    end
+
+    def invalid_github_scopes?
+      Travis.env == 'production' and (github_oauth_token_changed? or github_scopes.blank?)
     end
 
     def set_as_recent
diff --git a/vendor/travis-core/lib/travis/services.rb b/vendor/travis-core/lib/travis/services.rb
index b555482e..6d37cdbf 100644
--- a/vendor/travis-core/lib/travis/services.rb
+++ b/vendor/travis-core/lib/travis/services.rb
@@ -46,8 +46,6 @@ require 'travis/services/find_branch'
 require 'travis/services/find_branches'
 require 'travis/services/find_build'
 require 'travis/services/find_builds'
-require 'travis/services/find_daily_repos_stats'
-require 'travis/services/find_daily_tests_stats'
 require 'travis/services/find_caches'
 require 'travis/services/find_hooks'
 require 'travis/services/find_job'
diff --git a/vendor/travis-core/lib/travis/services/find_daily_repos_stats.rb b/vendor/travis-core/lib/travis/services/find_daily_repos_stats.rb
deleted file mode 100644
index 4d9232a8..00000000
--- a/vendor/travis-core/lib/travis/services/find_daily_repos_stats.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-require 'travis/services/base'
-
-module Travis
-  module Services
-    class FindDailyReposStats < Base
-      register :find_daily_repos_stats
-
-      def run
-        select scope(:repository).
-          select(['date(created_at) AS date', 'count(created_at) AS count']).
-          where('last_build_id IS NOT NULL').
-          group('date').
-          order('date').to_sql
-      end
-
-      private
-
-        def select(sql)
-          ActiveRecord::Base.connection.select_all(sql)
-        end
-    end
-  end
-end
diff --git a/vendor/travis-core/lib/travis/services/find_daily_tests_stats.rb b/vendor/travis-core/lib/travis/services/find_daily_tests_stats.rb
deleted file mode 100644
index d1f1adbf..00000000
--- a/vendor/travis-core/lib/travis/services/find_daily_tests_stats.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-require 'travis/services/base'
-
-module Travis
-  module Services
-    class FindDailyTestsStats < Base
-      register :find_daily_tests_stats
-
-      def run
-        select scope(:job).
-          select(['date(created_at) AS date', 'count(created_at) AS count']).
-          group('date').
-          order('date').
-          where(['created_at > ?', 28.days.ago]).to_sql
-      end
-
-      private
-
-        def select(sql)
-          ActiveRecord::Base.connection.select_all(sql)
-        end
-    end
-  end
-end
diff --git a/vendor/travis-core/lib/travis_core/version.rb b/vendor/travis-core/lib/travis/version.rb
similarity index 57%
rename from vendor/travis-core/lib/travis_core/version.rb
rename to vendor/travis-core/lib/travis/version.rb
index f8fc62f6..1214aa54 100644
--- a/vendor/travis-core/lib/travis_core/version.rb
+++ b/vendor/travis-core/lib/travis/version.rb
@@ -1,3 +1,3 @@
-module TravisCore
+module Travis
   VERSION = "0.0.1"
 end
diff --git a/vendor/travis-core/travis-core.gemspec b/vendor/travis-core/travis-core.gemspec
index d34586ec..c189c19f 100644
--- a/vendor/travis-core/travis-core.gemspec
+++ b/vendor/travis-core/travis-core.gemspec
@@ -1,11 +1,11 @@
 # encoding: utf-8
 
 $:.unshift File.expand_path('../lib', __FILE__)
-require 'travis_core/version'
+require 'travis/version'
 
 Gem::Specification.new do |s|
   s.name         = "travis-core"
-  s.version      = TravisCore::VERSION
+  s.version      = Travis::VERSION
   s.authors      = ["Travis CI"]
   s.email        = "contact@travis-ci.org"
   s.homepage     = "https://github.com/travis-ci/travis-core"