diff options
author | rpereira2 <rpereira@gitlab.com> | 2019-05-17 10:00:16 -0400 |
---|---|---|
committer | syasonik <syasonik@gitlab.com> | 2019-05-29 10:53:34 +0100 |
commit | e1ac1b8245a0bfb0d11a4a24c0b0c20479b5218e (patch) | |
tree | dd0e90b494b7461595ed32e50d397f483a7e5eed | |
parent | 716b9fb885cbb0450fc8ae0aacd48a8402af85b8 (diff) | |
download | gitlab-ce-e1ac1b8245a0bfb0d11a4a24c0b0c20479b5218e.tar.gz |
Add helper method and spec
-rw-r--r-- | app/helpers/projects_helper.rb | 4 | ||||
-rw-r--r-- | app/views/projects/settings/operations/_external_dashboard.html.haml | 2 | ||||
-rw-r--r-- | spec/helpers/projects_helper_spec.rb | 22 |
3 files changed, 27 insertions, 1 deletions
diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index f798bfbf703..45cdf3eb0e4 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -342,6 +342,10 @@ module ProjectsHelper description.html_safe % { project_name: project.name } end + + def metrics_external_dashboard_url + @project.metrics_setting&.external_dashboard_url + end private diff --git a/app/views/projects/settings/operations/_external_dashboard.html.haml b/app/views/projects/settings/operations/_external_dashboard.html.haml index 3a6703a28de..f049c35b38d 100644 --- a/app/views/projects/settings/operations/_external_dashboard.html.haml +++ b/app/views/projects/settings/operations/_external_dashboard.html.haml @@ -1,2 +1,2 @@ -.js-operation-settings{ data: { external_dashboard: { path: @project.metrics_setting&.external_dashboard_url, +.js-operation-settings{ data: { external_dashboard: { path: metrics_external_dashboard_url, help_page_path: help_page_path('user/project/operations/link_to_external_dashboard') } } } diff --git a/spec/helpers/projects_helper_spec.rb b/spec/helpers/projects_helper_spec.rb index 83271aa24a3..bc09e65f717 100644 --- a/spec/helpers/projects_helper_spec.rb +++ b/spec/helpers/projects_helper_spec.rb @@ -819,4 +819,26 @@ describe ProjectsHelper do expect(helper.can_import_members?).to eq true end end + + describe '#metrics_external_dashboard_url' do + let(:project) { create(:project) } + + before do + helper.instance_variable_set(:@project, project) + end + + context 'metrics_setting exists' do + let(:metrics_setting) { create(:project_metrics_setting, project: project) } + + it 'returns external_dashboard_url' do + expect(helper.metrics_external_dashboard_url).to eq(metrics_setting.external_dashboard_url) + end + end + + context 'metrics_setting does not exist' do + it 'returns nil' do + expect(helper.metrics_external_dashboard_url).to eq(nil) + end + end + end end |