diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-17 00:07:22 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-17 00:07:22 +0300 |
commit | e924e9e7cb9df21b3bc3d51d5f955da28ba3a225 (patch) | |
tree | 598ccb6f09e55ad06e628a90d27628f20ae693fe /spec/lib/gitlab/danger | |
parent | 8e45d25f7dde6508839ffee719c0ddc2cf6b12d3 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/danger')
-rw-r--r-- | spec/lib/gitlab/danger/roulette_spec.rb | 16 | ||||
-rw-r--r-- | spec/lib/gitlab/danger/teammate_spec.rb | 22 |
2 files changed, 26 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 |