summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2015-12-11 14:37:16 +0100
committerKamil Trzcinski <ayufan@ayufan.eu>2015-12-11 18:02:10 +0100
commitdd8102f2d1acd803793777b26c84d7c6e977b8e2 (patch)
tree42be96d61c921b6fa76e05fc3c796b5af62a976d
parent513d551c8f7078e263d31ef2c30a1f72cbab3fae (diff)
downloadgitlab-ce-dd8102f2d1acd803793777b26c84d7c6e977b8e2.tar.gz
Fix specs
-rw-r--r--app/models/project.rb6
-rw-r--r--app/views/projects/commit/_builds.html.haml8
-rw-r--r--app/views/projects/triggers/index.html.haml2
-rw-r--r--lib/gitlab/backend/grack_auth.rb2
-rw-r--r--spec/models/build_spec.rb2
-rw-r--r--spec/models/commit_status_spec.rb3
-rw-r--r--spec/services/create_commit_builds_service_spec.rb4
7 files changed, 15 insertions, 12 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index ba04470c64e..e1f7bf971e3 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -830,11 +830,13 @@ class Project < ActiveRecord::Base
end
def valid_runners_token? token
- self.token && self.token == token
+ self.runners_token && self.runners_token == token
end
+ # TODO (ayufan): For now we use runners_token (backward compatibility)
+ # In 8.4 every build will have its own individual token valid for time of build
def valid_build_token? token
- self.token && self.token == token
+ self.builds_enabled? && self.runners_token && self.runners_token == token
end
def build_coverage_enabled?
diff --git a/app/views/projects/commit/_builds.html.haml b/app/views/projects/commit/_builds.html.haml
index e65a5a9c2de..329aaa0bb8b 100644
--- a/app/views/projects/commit/_builds.html.haml
+++ b/app/views/projects/commit/_builds.html.haml
@@ -39,12 +39,12 @@
%th Name
%th Duration
%th Finished at
- - if @ci_commit.project.coverage_enabled?
+ - if @ci_commit.project.build_coverage_enabled?
%th Coverage
%th
- @ci_commit.refs.each do |ref|
= render partial: "projects/commit_statuses/commit_status", collection: @ci_commit.statuses.for_ref(ref).latest.ordered,
- locals: { coverage: @ci_commit.project.coverage_enabled?, stage: true, allow_retry: true }
+ locals: { coverage: @ci_commit.project.build_coverage_enabled?, stage: true, allow_retry: true }
- if @ci_commit.retried.any?
.gray-content-block.second-block
@@ -61,8 +61,8 @@
%th Name
%th Duration
%th Finished at
- - if @ci_commit.project.coverage_enabled?
+ - if @ci_commit.project.build_coverage_enabled?
%th Coverage
%th
= render partial: "projects/commit_statuses/commit_status", collection: @ci_commit.retried,
- locals: { coverage: @ci_commit.project.coverage_enabled?, stage: true }
+ locals: { coverage: @ci_commit.project.build_coverage_enabled?, stage: true }
diff --git a/app/views/projects/triggers/index.html.haml b/app/views/projects/triggers/index.html.haml
index fb3794764c5..bd346c4b8e6 100644
--- a/app/views/projects/triggers/index.html.haml
+++ b/app/views/projects/triggers/index.html.haml
@@ -68,4 +68,4 @@
-F token=TOKEN \
-F "ref=REF_NAME" \
-F "variables[RUN_NIGHTLY_BUILD]=true" \
- #{builds_trigger_url(@project.id, 'TOKEN')}
+ #{builds_trigger_url(@project.id)}
diff --git a/lib/gitlab/backend/grack_auth.rb b/lib/gitlab/backend/grack_auth.rb
index d854c1c8683..cdcaae8094c 100644
--- a/lib/gitlab/backend/grack_auth.rb
+++ b/lib/gitlab/backend/grack_auth.rb
@@ -78,7 +78,7 @@ module Grack
underscored_service = matched_login['s'].underscore
if underscored_service == 'gitlab_ci'
- return project && project.builds_enabled? && project.valid_build_token?(password)
+ return project && project.valid_build_token?(password)
elsif Service.available_services_names.include?(underscored_service)
service_method = "#{underscored_service}_service"
service = project.send(service_method)
diff --git a/spec/models/build_spec.rb b/spec/models/build_spec.rb
index 1fd475d205e..96b6f1dbca6 100644
--- a/spec/models/build_spec.rb
+++ b/spec/models/build_spec.rb
@@ -386,7 +386,7 @@ describe Ci::Build, models: true do
it { is_expected.to be_a(String) }
it { is_expected.to end_with(".git") }
it { is_expected.to start_with(project.web_url[0..6]) }
- it { is_expected.to include(project.token) }
+ it { is_expected.to include(build.token) }
it { is_expected.to include('gitlab-ci-token') }
it { is_expected.to include(project.web_url[7..-1]) }
end
diff --git a/spec/models/commit_status_spec.rb b/spec/models/commit_status_spec.rb
index 6131191f0fa..b8f901b3433 100644
--- a/spec/models/commit_status_spec.rb
+++ b/spec/models/commit_status_spec.rb
@@ -39,12 +39,13 @@ describe CommitStatus, models: true do
it { is_expected.to belong_to(:commit) }
it { is_expected.to belong_to(:user) }
+ it { is_expected.to belong_to(:project) }
+
it { is_expected.to validate_presence_of(:name) }
it { is_expected.to validate_inclusion_of(:status).in_array(%w(pending running failed success canceled)) }
it { is_expected.to delegate_method(:sha).to(:commit) }
it { is_expected.to delegate_method(:short_sha).to(:commit) }
- it { is_expected.to delegate_method(:project).to(:commit) }
it { is_expected.to respond_to :success? }
it { is_expected.to respond_to :failed? }
diff --git a/spec/services/create_commit_builds_service_spec.rb b/spec/services/create_commit_builds_service_spec.rb
index ae56f0b3a9a..798c480b81a 100644
--- a/spec/services/create_commit_builds_service_spec.rb
+++ b/spec/services/create_commit_builds_service_spec.rb
@@ -20,11 +20,11 @@ describe CreateCommitBuildsService, services: true do
)
end
- it { expect(commit).to be_kind_of(Commit) }
+ it { expect(commit).to be_kind_of(Ci::Commit) }
it { expect(commit).to be_valid }
it { expect(commit).to be_persisted }
it { expect(commit).to eq(project.ci_commits.last) }
- it { expect(commit.builds.first).to be_kind_of(Build) }
+ it { expect(commit.builds.first).to be_kind_of(Ci::Build) }
end
context "skip tag if there is no build for it" do