diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
commit | 7e9c479f7de77702622631cff2628a9c8dcbc627 (patch) | |
tree | c8f718a08e110ad7e1894510980d2155a6549197 /spec/services/users/set_status_service_spec.rb | |
parent | e852b0ae16db4052c1c567d9efa4facc81146e88 (diff) |
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'spec/services/users/set_status_service_spec.rb')
-rw-r--r-- | spec/services/users/set_status_service_spec.rb | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/spec/services/users/set_status_service_spec.rb b/spec/services/users/set_status_service_spec.rb index 54489adceb0..69cd647eaeb 100644 --- a/spec/services/users/set_status_service_spec.rb +++ b/spec/services/users/set_status_service_spec.rb @@ -9,13 +9,14 @@ RSpec.describe Users::SetStatusService do describe '#execute' do context 'when params are set' do - let(:params) { { emoji: 'taurus', message: 'a random status' } } + let(:params) { { emoji: 'taurus', message: 'a random status', availability: 'busy' } } it 'creates a status' do service.execute expect(current_user.status.emoji).to eq('taurus') expect(current_user.status.message).to eq('a random status') + expect(current_user.status.availability).to eq('busy') end it 'updates a status if it already existed' do @@ -25,13 +26,33 @@ RSpec.describe Users::SetStatusService do expect(current_user.status.message).to eq('a random status') end + it 'returns true' do + create(:user_status, user: current_user) + expect(service.execute).to be(true) + end + + context 'when the given availability value is not valid' do + let(:params) { { availability: 'not a valid value' } } + + it 'does not update the status' do + user_status = create(:user_status, user: current_user) + + expect { service.execute }.not_to change { user_status.reload } + end + + it 'returns false' do + create(:user_status, user: current_user) + expect(service.execute).to be(false) + end + end + context 'for another user' do let(:target_user) { create(:user) } let(:params) do { emoji: 'taurus', message: 'a random status', user: target_user } end - context 'the current user is admin' do + context 'the current user is admin', :enable_admin_mode do let(:current_user) { create(:admin) } it 'changes the status when the current user is allowed to do that' do |