diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-20 23:50:22 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-20 23:50:22 +0000 |
commit | 9dc93a4519d9d5d7be48ff274127136236a3adb3 (patch) | |
tree | 70467ae3692a0e35e5ea56bcb803eb512a10bedb /spec/finders/applications_finder_spec.rb | |
parent | 4b0f34b6d759d6299322b3a54453e930c6121ff0 (diff) | |
download | gitlab-ce-9dc93a4519d9d5d7be48ff274127136236a3adb3.tar.gz |
Add latest changes from gitlab-org/gitlab@13-11-stable-eev13.11.0-rc43
Diffstat (limited to 'spec/finders/applications_finder_spec.rb')
-rw-r--r-- | spec/finders/applications_finder_spec.rb | 40 |
1 files changed, 35 insertions, 5 deletions
diff --git a/spec/finders/applications_finder_spec.rb b/spec/finders/applications_finder_spec.rb index dc615144b88..b6c48d8cdae 100644 --- a/spec/finders/applications_finder_spec.rb +++ b/spec/finders/applications_finder_spec.rb @@ -5,18 +5,48 @@ require 'spec_helper' RSpec.describe ApplicationsFinder do let(:application1) { create(:application, name: 'some_application', owner: nil, redirect_uri: 'http://some_application.url', scopes: '') } let(:application2) { create(:application, name: 'another_application', owner: nil, redirect_uri: 'http://other_application.url', scopes: '') } + let(:user_application) { create(:application, name: 'user_application', owner: create(:user), redirect_uri: 'http://user_application.url', scopes: '') } + let(:group_application) { create(:application, name: 'group_application', owner: create(:group), redirect_uri: 'http://group_application.url', scopes: '') } describe '#execute' do - it 'returns an array of applications' do + it 'returns an array of instance applications' do found = described_class.new.execute expect(found).to match_array([application1, application2]) end - it 'returns the application by id' do - params = { id: application1.id } - found = described_class.new(params).execute - expect(found).to match(application1) + context 'by_id' do + context 'with existing id' do + it 'returns the application' do + params = { id: application1.id } + found = described_class.new(params).execute + + expect(found).to match(application1) + end + end + + context 'with invalid id' do + it 'returns nil for user application' do + params = { id: user_application.id } + found = described_class.new(params).execute + + expect(found).to be_nil + end + + it 'returns nil for group application' do + params = { id: group_application.id } + found = described_class.new(params).execute + + expect(found).to be_nil + end + + it 'returns nil for non-existing application' do + params = { id: non_existing_record_id } + found = described_class.new(params).execute + + expect(found).to be_nil + end + end end end end |