diff options
author | rpereira2 <rpereira@gitlab.com> | 2019-02-01 16:17:59 +0530 |
---|---|---|
committer | rpereira2 <rpereira@gitlab.com> | 2019-02-07 10:37:04 +0530 |
commit | 82cc7c0f07369ad1050d2f3b52c9aa5e5d48f760 (patch) | |
tree | ad484e21eb6b84312470dc1140363e220d61ca0d | |
parent | 501d60be68705878ef4dbabab5990bda11d340ba (diff) | |
download | gitlab-ce-82cc7c0f07369ad1050d2f3b52c9aa5e5d48f760.tar.gz |
Refactor model and spec
- Move some specs into contexts
- Let get_slugs method take a parameter and return a specific slug.
- Add rescues when using Addressable::URI.
-rw-r--r-- | spec/models/error_tracking/project_error_tracking_setting_spec.rb | 14 |
1 files changed, 7 insertions, 7 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 0d35216811c..dcecc4aa94f 100644 --- a/spec/models/error_tracking/project_error_tracking_setting_spec.rb +++ b/spec/models/error_tracking/project_error_tracking_setting_spec.rb @@ -229,11 +229,9 @@ describe ErrorTracking::ProjectErrorTrackingSetting do 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[name] = 'Sentry name' subject.api_url = 'http://gitlab.com/api/0/projects/org-slug/project-slug' expect(subject.public_send(name)).to eq('Sentry name') @@ -242,21 +240,21 @@ describe ErrorTracking::ProjectErrorTrackingSetting do context 'name is null in DB' do it 'titleizes and returns slug from api_url' do - subject.public_send(name_with_equals, nil) + subject[name] = 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[name] = 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[name] = nil subject.api_url = nil expect(subject.public_send(name)).to be_nil @@ -323,9 +321,11 @@ describe ErrorTracking::ProjectErrorTrackingSetting do end describe '#api_host' do - it 'extracts the api_host from api_url' do + before do subject.api_url = 'https://example.com/api/0/projects/org-slug/proj-slug/' + end + it 'extracts the api_host from api_url' do expect(subject.api_host).to eq('https://example.com/') end end |