summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.rubocop.yml1
-rw-r--r--app/controllers/ci/admin/application_controller.rb4
-rw-r--r--lib/ci/api/entities.rb9
-rw-r--r--spec/controllers/ci/projects_controller_spec.rb13
-rw-r--r--spec/features/ci/runners_spec.rb4
-rw-r--r--spec/lib/ci/gitlab_ci_yaml_processor_spec.rb38
-rw-r--r--spec/models/ci/build_spec.rb2
-rw-r--r--spec/models/ci/project_services/hip_chat_service_spec.rb1
-rw-r--r--spec/models/ci/service_spec.rb6
-rw-r--r--spec/models/ci/web_hook_spec.rb6
-rw-r--r--spec/requests/ci/api/builds_spec.rb24
-rw-r--r--spec/requests/ci/api/projects_spec.rb2
-rw-r--r--spec/requests/ci/api/triggers_spec.rb4
-rw-r--r--spec/services/ci/event_service_spec.rb4
-rw-r--r--spec/services/ci/web_hook_service_spec.rb8
-rw-r--r--spec/support/stub_gitlab_calls.rb20
16 files changed, 72 insertions, 74 deletions
diff --git a/.rubocop.yml b/.rubocop.yml
index ea4d365761e..f372e2f6ba8 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -998,6 +998,7 @@ AllCops:
- 'tmp/**/*'
- 'bin/**/*'
- 'lib/backup/**/*'
+ - 'lib/ci/backup/**/*'
- 'lib/tasks/**/*'
- 'lib/email_validator.rb'
- 'lib/gitlab/upgrader.rb'
diff --git a/app/controllers/ci/admin/application_controller.rb b/app/controllers/ci/admin/application_controller.rb
index 430fae14c7d..4ec2dc9c2cf 100644
--- a/app/controllers/ci/admin/application_controller.rb
+++ b/app/controllers/ci/admin/application_controller.rb
@@ -1,8 +1,8 @@
module Ci
module Admin
class ApplicationController < Ci::ApplicationController
- before_filter :authenticate_user!
- before_filter :authenticate_admin!
+ before_action :authenticate_user!
+ before_action :authenticate_admin!
layout "ci/admin"
end
diff --git a/lib/ci/api/entities.rb b/lib/ci/api/entities.rb
index 07f25129663..f47bc1236b8 100644
--- a/lib/ci/api/entities.rb
+++ b/lib/ci/api/entities.rb
@@ -11,16 +11,13 @@ module Ci
expose :builds
end
- class BuildOptions < Grape::Entity
- expose :image
- expose :services
- end
-
class Build < Grape::Entity
expose :id, :commands, :ref, :sha, :project_id, :repo_url,
:before_sha, :allow_git_fetch, :project_name
- expose :options, using: BuildOptions
+ expose :options do |model|
+ model.options
+ end
expose :timeout do |model|
model.timeout
diff --git a/spec/controllers/ci/projects_controller_spec.rb b/spec/controllers/ci/projects_controller_spec.rb
index f710e2a3808..b7eb4eac673 100644
--- a/spec/controllers/ci/projects_controller_spec.rb
+++ b/spec/controllers/ci/projects_controller_spec.rb
@@ -7,26 +7,29 @@ describe Ci::ProjectsController do
describe "POST #build" do
it 'should respond 200 if params is ok' do
- post :build, id: @project.id,
+ post :build, {
+ id: @project.id,
ref: 'master',
before: '2aa371379db71ac89ae20843fcff3b3477cf1a1d',
after: '1c8a9df454ef68c22c2a33cca8232bb50849e5c5',
token: @project.token,
ci_yaml_file: gitlab_ci_yaml,
commits: [ { message: "Message" } ]
-
+ }
expect(response).to be_success
expect(response.code).to eq('201')
end
it 'should respond 400 if push about removed branch' do
- post :build, id: @project.id,
+ post :build, {
+ id: @project.id,
ref: 'master',
before: '2aa371379db71ac89ae20843fcff3b3477cf1a1d',
after: '0000000000000000000000000000000000000000',
token: @project.token,
ci_yaml_file: gitlab_ci_yaml
+ }
expect(response).not_to be_success
expect(response.code).to eq('400')
@@ -49,7 +52,7 @@ describe Ci::ProjectsController do
let(:project_dump) { YAML.load File.read(Rails.root.join('spec/support/gitlab_stubs/raw_project.yml')) }
let(:gitlab_url) { GitlabCi.config.gitlab_server.url }
- let (:user_data) do
+ let(:user_data) do
data = JSON.parse File.read(Rails.root.join('spec/support/gitlab_stubs/user.json'))
data.merge("url" => gitlab_url)
end
@@ -85,7 +88,7 @@ describe Ci::ProjectsController do
describe "GET /gitlab" do
let(:gitlab_url) { GitlabCi.config.gitlab_server.url }
- let (:user_data) do
+ let(:user_data) do
data = JSON.parse File.read(Rails.root.join('spec/support/gitlab_stubs/user.json'))
data.merge("url" => gitlab_url)
end
diff --git a/spec/features/ci/runners_spec.rb b/spec/features/ci/runners_spec.rb
index ea28170bb2c..8eea0c4441f 100644
--- a/spec/features/ci/runners_spec.rb
+++ b/spec/features/ci/runners_spec.rb
@@ -13,8 +13,8 @@ describe "Runners" do
# all projects should be authorized for user
allow_any_instance_of(Network).to receive(:projects).and_return([
- OpenStruct.new({id: @project.gitlab_id}),
- OpenStruct.new({id: @project2.gitlab_id})
+ OpenStruct.new({ id: @project.gitlab_id }),
+ OpenStruct.new({ id: @project2.gitlab_id })
])
@shared_runner = FactoryGirl.create :shared_runner
diff --git a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
index c99add3f716..b60b4505145 100644
--- a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
+++ b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
@@ -3,12 +3,12 @@ require 'spec_helper'
describe Ci::GitlabCiYamlProcessor do
describe "#builds_for_ref" do
- let (:type) { 'test' }
+ let(:type) { 'test' }
it "returns builds if no branch specified" do
config = YAML.dump({
before_script: ["pwd"],
- rspec: {script: "rspec"}
+ rspec: { script: "rspec" }
})
config_processor = GitlabCiYamlProcessor.new(config)
@@ -29,7 +29,7 @@ describe Ci::GitlabCiYamlProcessor do
it "does not return builds if only has another branch" do
config = YAML.dump({
before_script: ["pwd"],
- rspec: {script: "rspec", only: ["deploy"]}
+ rspec: { script: "rspec", only: ["deploy"] }
})
config_processor = GitlabCiYamlProcessor.new(config)
@@ -40,7 +40,7 @@ describe Ci::GitlabCiYamlProcessor do
it "does not return builds if only has regexp with another branch" do
config = YAML.dump({
before_script: ["pwd"],
- rspec: {script: "rspec", only: ["/^deploy$/"]}
+ rspec: { script: "rspec", only: ["/^deploy$/"] }
})
config_processor = GitlabCiYamlProcessor.new(config)
@@ -51,7 +51,7 @@ describe Ci::GitlabCiYamlProcessor do
it "returns builds if only has specified this branch" do
config = YAML.dump({
before_script: ["pwd"],
- rspec: {script: "rspec", only: ["master"]}
+ rspec: { script: "rspec", only: ["master"] }
})
config_processor = GitlabCiYamlProcessor.new(config)
@@ -62,7 +62,7 @@ describe Ci::GitlabCiYamlProcessor do
it "does not build tags" do
config = YAML.dump({
before_script: ["pwd"],
- rspec: {script: "rspec", except: ["tags"]}
+ rspec: { script: "rspec", except: ["tags"] }
})
config_processor = GitlabCiYamlProcessor.new(config)
@@ -73,7 +73,7 @@ describe Ci::GitlabCiYamlProcessor do
it "returns builds if only has a list of branches including specified" do
config = YAML.dump({
before_script: ["pwd"],
- rspec: {script: "rspec", type: type, only: ["master", "deploy"]}
+ rspec: { script: "rspec", type: type, only: ["master", "deploy"] }
})
config_processor = GitlabCiYamlProcessor.new(config)
@@ -85,10 +85,10 @@ describe Ci::GitlabCiYamlProcessor do
config = YAML.dump({
before_script: ["pwd"],
- build: {script: "build", type: "build", only: ["master", "deploy"]},
- rspec: {script: "rspec", type: type, only: ["master", "deploy"]},
- staging: {script: "deploy", type: "deploy", only: ["master", "deploy"]},
- production: {script: "deploy", type: "deploy", only: ["master", "deploy"]},
+ build: { script: "build", type: "build", only: ["master", "deploy"] },
+ rspec: { script: "rspec", type: type, only: ["master", "deploy"] },
+ staging: { script: "deploy", type: "deploy", only: ["master", "deploy"] },
+ production: { script: "deploy", type: "deploy", only: ["master", "deploy"] },
})
config_processor = GitlabCiYamlProcessor.new(config)
@@ -105,7 +105,7 @@ describe Ci::GitlabCiYamlProcessor do
image: "ruby:2.1",
services: ["mysql"],
before_script: ["pwd"],
- rspec: {script: "rspec"}
+ rspec: { script: "rspec" }
})
config_processor = GitlabCiYamlProcessor.new(config)
@@ -128,10 +128,10 @@ describe Ci::GitlabCiYamlProcessor do
it "returns image and service when overridden for job" do
config = YAML.dump({
- image: "ruby:2.1",
- services: ["mysql"],
+ image: "ruby:2.1",
+ services: ["mysql"],
before_script: ["pwd"],
- rspec: { image: "ruby:2.5", services: ["postgresql"], script: "rspec" }
+ rspec: { image: "ruby:2.5", services: ["postgresql"], script: "rspec" }
})
config_processor = GitlabCiYamlProcessor.new(config)
@@ -162,7 +162,7 @@ describe Ci::GitlabCiYamlProcessor do
config = YAML.dump({
variables: variables,
before_script: ["pwd"],
- rspec: {script: "rspec"}
+ rspec: { script: "rspec" }
})
config_processor = GitlabCiYamlProcessor.new(config)
@@ -197,7 +197,7 @@ describe Ci::GitlabCiYamlProcessor do
end
it "returns errors if job image parameter is invalid" do
- config = YAML.dump({rspec: { script: "test", image: ["test"] } })
+ config = YAML.dump({ rspec: { script: "test", image: ["test"] } })
expect do
GitlabCiYamlProcessor.new(config)
end.to raise_error(GitlabCiYamlProcessor::ValidationError, "rspec job: image should be a string")
@@ -239,7 +239,7 @@ describe Ci::GitlabCiYamlProcessor do
end
it "returns errors if there are unknown parameters that are hashes, but doesn't have a script" do
- config = YAML.dump({ extra: {services: "test" } })
+ config = YAML.dump({ extra: { services: "test" } })
expect do
GitlabCiYamlProcessor.new(config)
end.to raise_error(GitlabCiYamlProcessor::ValidationError, "Unknown parameter: extra")
@@ -267,7 +267,7 @@ describe Ci::GitlabCiYamlProcessor do
end
it "returns errors if job stage is not a pre-defined stage" do
- config = YAML.dump({rspec: { script: "test", type: "acceptance", allow_failure: "string" } })
+ config = YAML.dump({ rspec: { script: "test", type: "acceptance", allow_failure: "string" } })
expect do
GitlabCiYamlProcessor.new(config)
end.to raise_error(GitlabCiYamlProcessor::ValidationError, "rspec job: stage parameter should be build, test, deploy")
diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb
index 4f57003565a..dacdf38a875 100644
--- a/spec/models/ci/build_spec.rb
+++ b/spec/models/ci/build_spec.rb
@@ -56,7 +56,7 @@ describe Ci::Build do
end
let(:create_from_build) { Ci::Build.create_from build }
- it ('there should be a pending task') do
+ it 'there should be a pending task' do
expect(Ci::Build.pending.count(:all)).to eq 0
create_from_build
expect(Ci::Build.pending.count(:all)).to be > 0
diff --git a/spec/models/ci/project_services/hip_chat_service_spec.rb b/spec/models/ci/project_services/hip_chat_service_spec.rb
index 33a3a8109e5..59deb19c23a 100644
--- a/spec/models/ci/project_services/hip_chat_service_spec.rb
+++ b/spec/models/ci/project_services/hip_chat_service_spec.rb
@@ -72,4 +72,3 @@ describe Ci::HipChatService do
end
end
end
-
diff --git a/spec/models/ci/service_spec.rb b/spec/models/ci/service_spec.rb
index 8c4df391555..04807a705eb 100644
--- a/spec/models/ci/service_spec.rb
+++ b/spec/models/ci/service_spec.rb
@@ -29,9 +29,9 @@ describe Ci::Service do
end
describe "Testable" do
- let (:project) { FactoryGirl.create :ci_project }
- let (:commit) { FactoryGirl.create :ci_commit, project: project }
- let (:build) { FactoryGirl.create :ci_build, commit: commit }
+ let(:project) { FactoryGirl.create :ci_project }
+ let(:commit) { FactoryGirl.create :ci_commit, project: project }
+ let(:build) { FactoryGirl.create :ci_build, commit: commit }
before do
allow(@service).to receive_messages(
diff --git a/spec/models/ci/web_hook_spec.rb b/spec/models/ci/web_hook_spec.rb
index bb58f645caf..66170d111a9 100644
--- a/spec/models/ci/web_hook_spec.rb
+++ b/spec/models/ci/web_hook_spec.rb
@@ -36,7 +36,7 @@ describe Ci::WebHook do
before(:each) do
@web_hook = FactoryGirl.create(:ci_web_hook)
@project = @web_hook.project
- @data = { before: 'oldrev', after: 'newrev', ref: 'ref'}
+ @data = { before: 'oldrev', after: 'newrev', ref: 'ref' }
WebMock.stub_request(:post, @web_hook.url)
end
@@ -56,9 +56,7 @@ describe Ci::WebHook do
it "catches exceptions" do
expect(WebHook).to receive(:post).and_raise("Some HTTP Post error")
- expect {
- @web_hook.execute(@data)
- }.to raise_error
+ expect{ @web_hook.execute(@data) }.to raise_error
end
end
end
diff --git a/spec/requests/ci/api/builds_spec.rb b/spec/requests/ci/api/builds_spec.rb
index 61f9d940c3b..c25d1823306 100644
--- a/spec/requests/ci/api/builds_spec.rb
+++ b/spec/requests/ci/api/builds_spec.rb
@@ -11,7 +11,7 @@ describe Ci::API::API do
let(:shared_project) { FactoryGirl.create(:ci_project, name: "SharedProject") }
before do
- FactoryGirl.create :runner_project, project_id: project.id, runner_id: runner.id
+ FactoryGirl.create :ci_runner_project, project_id: project.id, runner_id: runner.id
end
describe "POST /builds/register" do
@@ -20,7 +20,7 @@ describe Ci::API::API do
commit.create_builds
build = commit.builds.first
- post api("/builds/register"), token: runner.token, info: { platform: :darwin }
+ post ci_api("/builds/register"), token: runner.token, info: { platform: :darwin }
expect(response.status).to eq(201)
expect(json_response['sha']).to eq(build.sha)
@@ -28,7 +28,7 @@ describe Ci::API::API do
end
it "should return 404 error if no pending build found" do
- post api("/builds/register"), token: runner.token
+ post ci_api("/builds/register"), token: runner.token
expect(response.status).to eq(404)
end
@@ -37,7 +37,7 @@ describe Ci::API::API do
commit = FactoryGirl.create(:ci_commit, project: shared_project)
FactoryGirl.create(:ci_build, commit: commit, status: 'pending' )
- post api("/builds/register"), token: runner.token
+ post ci_api("/builds/register"), token: runner.token
expect(response.status).to eq(404)
end
@@ -46,7 +46,7 @@ describe Ci::API::API do
commit = FactoryGirl.create(:ci_commit, project: project)
FactoryGirl.create(:ci_build, commit: commit, status: 'pending' )
- post api("/builds/register"), token: shared_runner.token
+ post ci_api("/builds/register"), token: shared_runner.token
expect(response.status).to eq(404)
end
@@ -55,7 +55,7 @@ describe Ci::API::API do
commit = FactoryGirl.create(:ci_commit, project: project)
commit.create_builds
- post api("/builds/register"), token: runner.token, info: { platform: :darwin }
+ post ci_api("/builds/register"), token: runner.token, info: { platform: :darwin }
expect(response.status).to eq(201)
expect(json_response["options"]).to eq({ "image" => "ruby:2.1", "services" => ["postgres"] })
@@ -64,9 +64,9 @@ describe Ci::API::API do
it "returns variables" do
commit = FactoryGirl.create(:ci_commit, project: project)
commit.create_builds
- project.variables << Variable.new(key: "SECRET_KEY", value: "secret_value")
+ project.variables << Ci::Variable.new(key: "SECRET_KEY", value: "secret_value")
- post api("/builds/register"), token: runner.token, info: { platform: :darwin }
+ post ci_api("/builds/register"), token: runner.token, info: { platform: :darwin }
expect(response.status).to eq(201)
expect(json_response["variables"]).to eq([
@@ -81,9 +81,9 @@ describe Ci::API::API do
trigger_request = FactoryGirl.create(:ci_trigger_request_with_variables, commit: commit, trigger: trigger)
commit.create_builds(trigger_request)
- project.variables << Variable.new(key: "SECRET_KEY", value: "secret_value")
+ project.variables << Ci::Variable.new(key: "SECRET_KEY", value: "secret_value")
- post api("/builds/register"), token: runner.token, info: { platform: :darwin }
+ post ci_api("/builds/register"), token: runner.token, info: { platform: :darwin }
expect(response.status).to eq(201)
expect(json_response["variables"]).to eq([
@@ -100,14 +100,14 @@ describe Ci::API::API do
it "should update a running build" do
build.run!
- put api("/builds/#{build.id}"), token: runner.token
+ put ci_api("/builds/#{build.id}"), token: runner.token
expect(response.status).to eq(200)
end
it 'Should not override trace information when no trace is given' do
build.run!
build.update!(trace: 'hello_world')
- put api("/builds/#{build.id}"), token: runner.token
+ put ci_api("/builds/#{build.id}"), token: runner.token
expect(build.reload.trace).to eq 'hello_world'
end
end
diff --git a/spec/requests/ci/api/projects_spec.rb b/spec/requests/ci/api/projects_spec.rb
index a0072b62fbf..2adae52e79e 100644
--- a/spec/requests/ci/api/projects_spec.rb
+++ b/spec/requests/ci/api/projects_spec.rb
@@ -62,7 +62,7 @@ describe Ci::API::API do
let!(:project) { FactoryGirl.create(:ci_project) }
context "Valid Webhook URL" do
- let!(:webhook) { {web_hook: "http://example.com/sth/1/ala_ma_kota" } }
+ let!(:webhook) { { web_hook: "http://example.com/sth/1/ala_ma_kota" } }
before do
options.merge!(webhook)
diff --git a/spec/requests/ci/api/triggers_spec.rb b/spec/requests/ci/api/triggers_spec.rb
index 97847bec2af..ff6fdbdd6f1 100644
--- a/spec/requests/ci/api/triggers_spec.rb
+++ b/spec/requests/ci/api/triggers_spec.rb
@@ -8,11 +8,11 @@ describe Ci::API::API do
let!(:project) { FactoryGirl.create(:ci_project) }
let!(:project2) { FactoryGirl.create(:ci_project) }
let!(:trigger) { FactoryGirl.create(:ci_trigger, project: project, token: trigger_token) }
- let(:options) {
+ let(:options) do
{
token: trigger_token
}
- }
+ end
context 'Handles errors' do
it 'should return bad request if token is missing' do
diff --git a/spec/services/ci/event_service_spec.rb b/spec/services/ci/event_service_spec.rb
index b6ad262152d..bdebab1ac24 100644
--- a/spec/services/ci/event_service_spec.rb
+++ b/spec/services/ci/event_service_spec.rb
@@ -1,8 +1,8 @@
require 'spec_helper'
describe Ci::EventService do
- let (:project) { FactoryGirl.create :project, name: "GitLab / gitlab-shell" }
- let (:user) { double(username: "root", id: 1) }
+ let(:project) { FactoryGirl.create :project, name: "GitLab / gitlab-shell" }
+ let(:user) { double(username: "root", id: 1) }
before do
Event.destroy_all
diff --git a/spec/services/ci/web_hook_service_spec.rb b/spec/services/ci/web_hook_service_spec.rb
index 6f882e6fdad..d2f08959cb1 100644
--- a/spec/services/ci/web_hook_service_spec.rb
+++ b/spec/services/ci/web_hook_service_spec.rb
@@ -1,10 +1,10 @@
require 'spec_helper'
describe Ci::WebHookService do
- let (:project) { FactoryGirl.create :project }
- let (:commit) { FactoryGirl.create :commit, project: project }
- let (:build) { FactoryGirl.create :build, commit: commit }
- let (:hook) { FactoryGirl.create :web_hook, project: project }
+ let(:project) { FactoryGirl.create :project }
+ let(:commit) { FactoryGirl.create :commit, project: project }
+ let(:build) { FactoryGirl.create :build, commit: commit }
+ let(:hook) { FactoryGirl.create :web_hook, project: project }
describe :execute do
it "should execute successfully" do
diff --git a/spec/support/stub_gitlab_calls.rb b/spec/support/stub_gitlab_calls.rb
index 41e4c3e275b..5e6744afda1 100644
--- a/spec/support/stub_gitlab_calls.rb
+++ b/spec/support/stub_gitlab_calls.rb
@@ -24,20 +24,20 @@ module StubGitlabCalls
stub_request(:post, "#{gitlab_url}api/v3/session.json").
with(body: "{\"email\":\"test@test.com\",\"password\":\"123456\"}",
- headers: {'Content-Type'=>'application/json'}).
- to_return(status: 201, body: f, headers: {'Content-Type'=>'application/json'})
+ headers: { 'Content-Type'=>'application/json' }).
+ to_return(status: 201, body: f, headers: { 'Content-Type'=>'application/json' })
end
def stub_user
f = File.read(Rails.root.join('spec/support/gitlab_stubs/user.json'))
stub_request(:get, "#{gitlab_url}api/v3/user?private_token=Wvjy2Krpb7y8xi93owUz").
- with(headers: {'Content-Type'=>'application/json'}).
- to_return(status: 200, body: f, headers: {'Content-Type'=>'application/json'})
+ with(headers: { 'Content-Type'=>'application/json' }).
+ to_return(status: 200, body: f, headers: { 'Content-Type'=>'application/json' })
stub_request(:get, "#{gitlab_url}api/v3/user?access_token=some_token").
- with(headers: {'Content-Type'=>'application/json'}).
- to_return(status: 200, body: f, headers: {'Content-Type'=>'application/json'})
+ with(headers: { 'Content-Type'=>'application/json' }).
+ to_return(status: 200, body: f, headers: { 'Content-Type'=>'application/json' })
end
def stub_project_8
@@ -54,19 +54,19 @@ module StubGitlabCalls
f = File.read(Rails.root.join('spec/support/gitlab_stubs/projects.json'))
stub_request(:get, "#{gitlab_url}api/v3/projects.json?archived=false&ci_enabled_first=true&private_token=Wvjy2Krpb7y8xi93owUz").
- with(headers: {'Content-Type'=>'application/json'}).
- to_return(status: 200, body: f, headers: {'Content-Type'=>'application/json'})
+ with(headers: { 'Content-Type'=>'application/json' }).
+ to_return(status: 200, body: f, headers: { 'Content-Type'=>'application/json' })
end
def stub_projects_owned
stub_request(:get, "#{gitlab_url}api/v3/projects/owned.json?archived=false&ci_enabled_first=true&private_token=Wvjy2Krpb7y8xi93owUz").
- with(headers: {'Content-Type'=>'application/json'}).
+ with(headers: { 'Content-Type'=>'application/json' }).
to_return(status: 200, body: "", headers: {})
end
def stub_ci_enable
stub_request(:put, "#{gitlab_url}api/v3/projects/2/services/gitlab-ci.json?private_token=Wvjy2Krpb7y8xi93owUz").
- with(headers: {'Content-Type'=>'application/json'}).
+ with(headers: { 'Content-Type'=>'application/json' }).
to_return(status: 200, body: "", headers: {})
end