Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-10-17 00:07:22 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-10-17 00:07:22 +0300
commite924e9e7cb9df21b3bc3d51d5f955da28ba3a225 (patch)
tree598ccb6f09e55ad06e628a90d27628f20ae693fe /spec/lib/gitlab
parent8e45d25f7dde6508839ffee719c0ddc2cf6b12d3 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab')
-rw-r--r--spec/lib/gitlab/danger/roulette_spec.rb16
-rw-r--r--spec/lib/gitlab/danger/teammate_spec.rb22
-rw-r--r--spec/lib/gitlab/regex_spec.rb11
3 files changed, 37 insertions, 12 deletions
diff --git a/spec/lib/gitlab/danger/roulette_spec.rb b/spec/lib/gitlab/danger/roulette_spec.rb
index 121c5d8ecd9..4d41e2c45aa 100644
--- a/spec/lib/gitlab/danger/roulette_spec.rb
+++ b/spec/lib/gitlab/danger/roulette_spec.rb
@@ -104,11 +104,13 @@ describe Gitlab::Danger::Roulette do
let(:person2) { Gitlab::Danger::Teammate.new('username' => 'godfat') }
let(:author) { Gitlab::Danger::Teammate.new('username' => 'filipa') }
let(:ooo) { Gitlab::Danger::Teammate.new('username' => 'jacopo-beschi') }
+ let(:no_capacity) { Gitlab::Danger::Teammate.new('username' => 'uncharged') }
before do
- stub_person_message(person1, 'making GitLab magic')
- stub_person_message(person2, 'making GitLab magic')
- stub_person_message(ooo, 'OOO till 15th')
+ stub_person_status(person1, message: 'making GitLab magic')
+ stub_person_status(person2, message: 'making GitLab magic')
+ stub_person_status(ooo, message: 'OOO till 15th')
+ stub_person_status(no_capacity, message: 'At capacity for the next few days', emoji: 'red_circle')
# we don't stub Filipa, as she is the author and
# we should not fire request checking for her
@@ -131,10 +133,14 @@ describe Gitlab::Danger::Roulette do
expect(subject.spin_for_person([author], random: Random.new)).to be_nil
end
+ it 'excludes person with no capacity' do
+ expect(subject.spin_for_person([no_capacity], random: Random.new)).to be_nil
+ end
+
private
- def stub_person_message(person, message)
- body = { message: message }.to_json
+ def stub_person_status(person, message: 'dummy message', emoji: 'unicorn')
+ body = { message: message, emoji: emoji }.to_json
WebMock
.stub_request(:get, "https://gitlab.com/api/v4/users/#{person.username}/status")
diff --git a/spec/lib/gitlab/danger/teammate_spec.rb b/spec/lib/gitlab/danger/teammate_spec.rb
index 36486cbbc7d..1e9cf0017be 100644
--- a/spec/lib/gitlab/danger/teammate_spec.rb
+++ b/spec/lib/gitlab/danger/teammate_spec.rb
@@ -135,17 +135,17 @@ describe Gitlab::Danger::Teammate do
end
end
- describe '#out_of_office?' do
+ describe '#available?' do
using RSpec::Parameterized::TableSyntax
let(:capabilities) { ['dry head'] }
where(:status, :result) do
- nil | false
- {} | false
- { message: 'dear reader' } | false
- { message: 'OOO: massage' } | true
- { message: 'love it SOOO much' } | true
+ {} | true
+ { message: 'dear reader' } | true
+ { message: 'OOO: massage' } | false
+ { message: 'love it SOOO much' } | false
+ { emoji: 'red_circle' } | false
end
with_them do
@@ -154,7 +154,15 @@ describe Gitlab::Danger::Teammate do
.and_return(status&.stringify_keys)
end
- it { expect(subject.out_of_office?).to be result }
+ it { expect(subject.available?).to be result }
+ end
+
+ it 'returns true if request fails' do
+ expect(Gitlab::Danger::RequestHelper).to receive(:http_get_json)
+ .exactly(2).times
+ .and_raise(Gitlab::Danger::RequestHelper::HTTPError.new)
+
+ expect(subject.available?).to be true
end
end
end
diff --git a/spec/lib/gitlab/regex_spec.rb b/spec/lib/gitlab/regex_spec.rb
index 3036e3a9754..b557baed258 100644
--- a/spec/lib/gitlab/regex_spec.rb
+++ b/spec/lib/gitlab/regex_spec.rb
@@ -64,4 +64,15 @@ describe Gitlab::Regex do
it { is_expected.not_to match('.my/image') }
it { is_expected.not_to match('my/image.') }
end
+
+ describe '.aws_account_id_regex' do
+ subject { described_class.aws_arn_regex }
+
+ it { is_expected.to match('arn:aws:iam::123456789012:role/role-name') }
+ it { is_expected.to match('arn:aws:s3:::bucket/key') }
+ it { is_expected.to match('arn:aws:ec2:us-east-1:123456789012:volume/vol-1') }
+ it { is_expected.to match('arn:aws:rds:us-east-1:123456789012:pg:prod') }
+ it { is_expected.not_to match('123456789012') }
+ it { is_expected.not_to match('role/role-name') }
+ end
end