summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrpereira2 <rpereira@gitlab.com>2019-02-01 16:17:59 +0530
committerrpereira2 <rpereira@gitlab.com>2019-02-06 21:04:36 +0530
commit0703802ecb91148b7416a43c817c0c9539946b90 (patch)
tree2462e4edd032d7a287aecb1be3b223afb3910f68
parent363c80dc30fb425331723b369663baffbfe238fb (diff)
downloadgitlab-ce-0703802ecb91148b7416a43c817c0c9539946b90.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.rb14
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