diff options
author | Grzegorz Bizon <grzegorz.bizon@ntsn.pl> | 2015-12-14 11:46:02 +0100 |
---|---|---|
committer | Grzegorz Bizon <grzegorz.bizon@ntsn.pl> | 2015-12-14 12:26:40 +0100 |
commit | 2ec93abed7a1a3aa49b3267342824e0743de0f54 (patch) | |
tree | 7d3381dd4bd1f4d73ba234a56742edf491baa515 /spec/requests/ci/api/builds_spec.rb | |
parent | bc1cfd384f4f972ad887b0501280b9f94d4c94ac (diff) | |
parent | c81023435795766411c5954a4676ebb215af40a6 (diff) | |
download | gitlab-ce-2ec93abed7a1a3aa49b3267342824e0743de0f54.tar.gz |
Merge branch 'master' into ci/persist-registration-token
* master: (66 commits)
Fix runners admin view
Fix migrations
Rename mention of gitlab-git-http-server to gitlab-workhorse
Bump Redis requirement to 2.8 for Sidekiq 4 requirements
Fix wording on runner setup page
add details on how to change saml button label
Fix tests
Move awards back to gray panel and few improvements to sidebar
Few UI improvements to new sidebar implementation
Fix tests for new issuable sidebar
Update changelog
Implement new sidebar for merge request page
Make edit link on issuable sidebar works
Redesign issue page for new sidebar
Move awards css to separate file
Implement issuable sidebar partial
Update CHANGELOG
Clarify cache behavior
Run builds from projects with enabled CI
Use Gitlab::Git instead of Ci::Git
...
Conflicts:
db/schema.rb
Diffstat (limited to 'spec/requests/ci/api/builds_spec.rb')
-rw-r--r-- | spec/requests/ci/api/builds_spec.rb | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/spec/requests/ci/api/builds_spec.rb b/spec/requests/ci/api/builds_spec.rb index c2be045099d..c27e87c4acc 100644 --- a/spec/requests/ci/api/builds_spec.rb +++ b/spec/requests/ci/api/builds_spec.rb @@ -4,8 +4,7 @@ describe Ci::API::API do include ApiHelpers let(:runner) { FactoryGirl.create(:ci_runner, tag_list: ["mysql", "ruby"]) } - let(:project) { FactoryGirl.create(:ci_project) } - let(:gl_project) { project.gl_project } + let(:project) { FactoryGirl.create(:empty_project) } before do stub_ci_commit_to_return_yaml_file @@ -13,16 +12,15 @@ describe Ci::API::API do describe "Builds API for runners" do let(:shared_runner) { FactoryGirl.create(:ci_runner, token: "SharedRunner") } - let(:shared_project) { FactoryGirl.create(:ci_project, name: "SharedProject") } - let(:shared_gl_project) { shared_project.gl_project } + let(:shared_project) { FactoryGirl.create(:empty_project, name: "SharedProject") } before do - FactoryGirl.create :ci_runner_project, project_id: project.id, runner_id: runner.id + FactoryGirl.create :ci_runner_project, project: project, runner: runner end describe "POST /builds/register" do it "should start a build" do - commit = FactoryGirl.create(:ci_commit, gl_project: gl_project) + commit = FactoryGirl.create(:ci_commit, project: project) commit.create_builds('master', false, nil) build = commit.builds.first @@ -40,7 +38,7 @@ describe Ci::API::API do end it "should return 404 error if no builds for specific runner" do - commit = FactoryGirl.create(:ci_commit, gl_project: shared_gl_project) + commit = FactoryGirl.create(:ci_commit, project: shared_project) FactoryGirl.create(:ci_build, commit: commit, status: 'pending') post ci_api("/builds/register"), token: runner.token @@ -49,7 +47,7 @@ describe Ci::API::API do end it "should return 404 error if no builds for shared runner" do - commit = FactoryGirl.create(:ci_commit, gl_project: gl_project) + commit = FactoryGirl.create(:ci_commit, project: project) FactoryGirl.create(:ci_build, commit: commit, status: 'pending') post ci_api("/builds/register"), token: shared_runner.token @@ -58,7 +56,7 @@ describe Ci::API::API do end it "returns options" do - commit = FactoryGirl.create(:ci_commit, gl_project: gl_project) + commit = FactoryGirl.create(:ci_commit, project: project) commit.create_builds('master', false, nil) post ci_api("/builds/register"), token: runner.token, info: { platform: :darwin } @@ -68,7 +66,7 @@ describe Ci::API::API do end it "returns variables" do - commit = FactoryGirl.create(:ci_commit, gl_project: gl_project) + commit = FactoryGirl.create(:ci_commit, project: project) commit.create_builds('master', false, nil) project.variables << Ci::Variable.new(key: "SECRET_KEY", value: "secret_value") @@ -85,7 +83,7 @@ describe Ci::API::API do it "returns variables for triggers" do trigger = FactoryGirl.create(:ci_trigger, project: project) - commit = FactoryGirl.create(:ci_commit, gl_project: gl_project) + commit = FactoryGirl.create(:ci_commit, project: project) trigger_request = FactoryGirl.create(:ci_trigger_request_with_variables, commit: commit, trigger: trigger) commit.create_builds('master', false, nil, trigger_request) @@ -106,7 +104,7 @@ describe Ci::API::API do end describe "PUT /builds/:id" do - let(:commit) { FactoryGirl.create(:ci_commit, gl_project: gl_project)} + let(:commit) { FactoryGirl.create(:ci_commit, project: project)} let(:build) { FactoryGirl.create(:ci_build, commit: commit, runner_id: runner.id) } it "should update a running build" do @@ -126,14 +124,14 @@ describe Ci::API::API do context "Artifacts" do let(:file_upload) { fixture_file_upload(Rails.root + 'spec/fixtures/banana_sample.gif', 'image/gif') } let(:file_upload2) { fixture_file_upload(Rails.root + 'spec/fixtures/dk.png', 'image/gif') } - let(:commit) { FactoryGirl.create(:ci_commit, gl_project: gl_project) } + let(:commit) { FactoryGirl.create(:ci_commit, project: project) } let(:build) { FactoryGirl.create(:ci_build, commit: commit, runner_id: runner.id) } let(:authorize_url) { ci_api("/builds/#{build.id}/artifacts/authorize") } let(:post_url) { ci_api("/builds/#{build.id}/artifacts") } let(:delete_url) { ci_api("/builds/#{build.id}/artifacts") } let(:get_url) { ci_api("/builds/#{build.id}/artifacts") } let(:headers) { { "GitLab-Workhorse" => "1.0" } } - let(:headers_with_token) { headers.merge(Ci::API::Helpers::BUILD_TOKEN_HEADER => build.project.token) } + let(:headers_with_token) { headers.merge(Ci::API::Helpers::BUILD_TOKEN_HEADER => build.token) } describe "POST /builds/:id/artifacts/authorize" do context "should authorize posting artifact to running build" do @@ -142,7 +140,7 @@ describe Ci::API::API do end it "using token as parameter" do - post authorize_url, { token: build.project.token }, headers + post authorize_url, { token: build.token }, headers expect(response.status).to eq(200) expect(json_response["TempPath"]).to_not be_nil end @@ -161,7 +159,7 @@ describe Ci::API::API do it "using token as parameter" do stub_application_setting(max_artifacts_size: 0) - post authorize_url, { token: build.project.token, filesize: 100 }, headers + post authorize_url, { token: build.token, filesize: 100 }, headers expect(response.status).to eq(413) end @@ -241,7 +239,7 @@ describe Ci::API::API do end it do - post post_url, { token: build.project.token }, {} + post post_url, { token: build.token }, {} expect(response.status).to eq(403) end end @@ -281,12 +279,12 @@ describe Ci::API::API do describe "DELETE /builds/:id/artifacts" do before do build.run! - post delete_url, token: build.project.token, file: file_upload + post delete_url, token: build.token, file: file_upload end it "should delete artifact build" do build.success - delete delete_url, token: build.project.token + delete delete_url, token: build.token expect(response.status).to eq(200) end end @@ -298,12 +296,12 @@ describe Ci::API::API do it "should download artifact" do build.update_attributes(artifacts_file: file_upload) - get get_url, token: build.project.token + get get_url, token: build.token expect(response.status).to eq(200) end it "should fail to download if no artifact uploaded" do - get get_url, token: build.project.token + get get_url, token: build.token expect(response.status).to eq(404) end end |