diff options
author | rpereira2 <rpereira@gitlab.com> | 2019-01-28 16:19:10 +0530 |
---|---|---|
committer | rpereira2 <rpereira@gitlab.com> | 2019-02-06 21:04:36 +0530 |
commit | 1660eeed25b447f3bcfb28ff914abc14212b452c (patch) | |
tree | 191667132702b187ac013255d57b9c17a10e013d | |
parent | d4edaf313ab1aa03a78b3a72cdb21b8c3d17c663 (diff) | |
download | gitlab-ce-1660eeed25b447f3bcfb28ff914abc14212b452c.tar.gz |
Add specs for org and project name methods
-rw-r--r-- | spec/models/error_tracking/project_error_tracking_setting_spec.rb | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/spec/models/error_tracking/project_error_tracking_setting_spec.rb b/spec/models/error_tracking/project_error_tracking_setting_spec.rb index d30228b863c..85d0e30d748 100644 --- a/spec/models/error_tracking/project_error_tracking_setting_spec.rb +++ b/spec/models/error_tracking/project_error_tracking_setting_spec.rb @@ -227,6 +227,47 @@ describe ErrorTracking::ProjectErrorTrackingSetting do it_behaves_like 'name from api_url', :project_name, 'Project Slug' end + context 'names from api_url' do + shared_examples_for 'name from api_url' do |name, titleized_slug| + let(:name_with_equals) { :"#{name}=" } + + context 'name is present in DB' do + it 'returns name from DB' do + subject.public_send(name_with_equals, 'Sentry name') + subject.api_url = 'http://gitlab.com/api/0/projects/org-slug/project-slug' + + expect(subject.public_send(name)).to eq('Sentry name') + end + end + + context 'name is null in DB' do + it 'titleizes and returns slug from api_url' do + subject.public_send(name_with_equals, nil) + subject.api_url = 'http://gitlab.com/api/0/projects/org-slug/project-slug' + + expect(subject.public_send(name)).to eq(titleized_slug) + end + + it 'returns nil when api_url is incorrect' do + subject.public_send(name_with_equals, nil) + subject.api_url = 'http://gitlab.com/api/0/projects/' + + expect(subject.public_send(name)).to be_nil + end + + it 'returns nil when api_url is blank' do + subject.public_send(name_with_equals, nil) + subject.api_url = nil + + expect(subject.public_send(name)).to be_nil + end + end + end + + it_behaves_like 'name from api_url', :organization_name, 'Org Slug' + it_behaves_like 'name from api_url', :project_name, 'Project Slug' + end + describe '.build_api_url_from' do it 'correctly builds api_url with slugs' do api_url = described_class.build_api_url_from( |