diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-03 21:06:49 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-03 21:06:49 +0300 |
commit | ab7cf450ba19cf80b9534f25dc707b33845e3014 (patch) | |
tree | bbfa6aba83c48aea68d79c4179ce576b6eec326d /spec/lib/gitlab | |
parent | 4204cf308596e0e26f578a6e2da88f49c0f4aad9 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab')
-rw-r--r-- | spec/lib/gitlab/ci/build/prerequisite/kubernetes_namespace_spec.rb | 42 | ||||
-rw-r--r-- | spec/lib/gitlab/git/commit_spec.rb | 22 |
2 files changed, 56 insertions, 8 deletions
diff --git a/spec/lib/gitlab/ci/build/prerequisite/kubernetes_namespace_spec.rb b/spec/lib/gitlab/ci/build/prerequisite/kubernetes_namespace_spec.rb index c7a5ac783b3..caa84faa9c1 100644 --- a/spec/lib/gitlab/ci/build/prerequisite/kubernetes_namespace_spec.rb +++ b/spec/lib/gitlab/ci/build/prerequisite/kubernetes_namespace_spec.rb @@ -38,13 +38,29 @@ describe Gitlab::Ci::Build::Prerequisite::KubernetesNamespace do .and_return(double(execute: kubernetes_namespace)) end - it { is_expected.to be_falsey } - - context 'and the service_account_token is blank' do - let(:kubernetes_namespace) { instance_double(Clusters::KubernetesNamespace, service_account_token: nil) } + context 'and the knative version role binding is missing' do + before do + allow(Clusters::KnativeVersionRoleBindingFinder).to receive(:new) + .and_return(double(execute: nil)) + end it { is_expected.to be_truthy } end + + context 'and the knative version role binding already exists' do + before do + allow(Clusters::KnativeVersionRoleBindingFinder).to receive(:new) + .and_return(double(execute: true)) + end + + it { is_expected.to be_falsey } + + context 'and the service_account_token is blank' do + let(:kubernetes_namespace) { instance_double(Clusters::KubernetesNamespace, service_account_token: nil) } + + it { is_expected.to be_truthy } + end + end end end @@ -115,6 +131,24 @@ describe Gitlab::Ci::Build::Prerequisite::KubernetesNamespace do subject end end + + context 'knative version role binding is missing' do + before do + allow(Clusters::KubernetesNamespaceFinder).to receive(:new) + .and_return(double(execute: kubernetes_namespace)) + allow(Clusters::KnativeVersionRoleBindingFinder).to receive(:new) + .and_return(double(execute: nil)) + end + + it 'creates the knative version role binding' do + expect(Clusters::Kubernetes::CreateOrUpdateNamespaceService) + .to receive(:new) + .with(cluster: cluster, kubernetes_namespace: kubernetes_namespace) + .and_return(service) + + subject + end + end end context 'completion is not required' do diff --git a/spec/lib/gitlab/git/commit_spec.rb b/spec/lib/gitlab/git/commit_spec.rb index 6c9467916de..0ab3e513e24 100644 --- a/spec/lib/gitlab/git/commit_spec.rb +++ b/spec/lib/gitlab/git/commit_spec.rb @@ -17,13 +17,13 @@ describe Gitlab::Git::Commit, :seed_helper do @committer = { email: 'mike@smith.com', name: "Mike Smith", - time: Time.now + time: Time.new(2000, 1, 1, 0, 0, 0, "+08:00") } @author = { email: 'john@smith.com', name: "John Smith", - time: Time.now + time: Time.new(2000, 1, 1, 0, 0, 0, "-08:00") } @parents = [rugged_repo.head.target] @@ -48,7 +48,7 @@ describe Gitlab::Git::Commit, :seed_helper do it { expect(@commit.id).to eq(@raw_commit.oid) } it { expect(@commit.sha).to eq(@raw_commit.oid) } it { expect(@commit.safe_message).to eq(@raw_commit.message) } - it { expect(@commit.created_at).to eq(@raw_commit.author[:time]) } + it { expect(@commit.created_at).to eq(@raw_commit.committer[:time]) } it { expect(@commit.date).to eq(@raw_commit.committer[:time]) } it { expect(@commit.author_email).to eq(@author[:email]) } it { expect(@commit.author_name).to eq(@author[:name]) } @@ -79,13 +79,27 @@ describe Gitlab::Git::Commit, :seed_helper do it { expect(commit.id).to eq(id) } it { expect(commit.sha).to eq(id) } it { expect(commit.safe_message).to eq(body) } - it { expect(commit.created_at).to eq(Time.at(committer.date.seconds)) } + it { expect(commit.created_at).to eq(Time.at(committer.date.seconds).utc) } it { expect(commit.author_email).to eq(author.email) } it { expect(commit.author_name).to eq(author.name) } it { expect(commit.committer_name).to eq(committer.name) } it { expect(commit.committer_email).to eq(committer.email) } it { expect(commit.parent_ids).to eq(gitaly_commit.parent_ids) } + context 'non-UTC dates' do + let(:seconds) { Time.now.to_i } + + it 'sets timezones correctly' do + gitaly_commit.author.date.seconds = seconds + gitaly_commit.author.timezone = '-0800' + gitaly_commit.committer.date.seconds = seconds + gitaly_commit.committer.timezone = '+0800' + + expect(commit.authored_date).to eq(Time.at(seconds, in: '-08:00')) + expect(commit.committed_date).to eq(Time.at(seconds, in: '+08:00')) + end + end + context 'body_size != body.size' do let(:body) { (+"").force_encoding('ASCII-8BIT') } |