From ebcd503e9372df6b5d3dfecbb548b0bd1e3d1ecb Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 23 Sep 2015 16:01:35 -0400 Subject: Only surface version information on help index to admins Closes #2721 --- app/views/help/index.html.haml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/views/help/index.html.haml b/app/views/help/index.html.haml index ab7ed1b5d95..5e0cf06e15e 100644 --- a/app/views/help/index.html.haml +++ b/app/views/help/index.html.haml @@ -1,10 +1,11 @@ %div %h1 GitLab - %span= Gitlab::VERSION - %small= Gitlab::REVISION - - if current_application_settings.version_check_enabled - = version_status_badge + - if current_user && current_user.admin? + %span= Gitlab::VERSION + %small= Gitlab::REVISION + - if current_application_settings.version_check_enabled + = version_status_badge %p.slead GitLab is open source software to collaborate on code. %br -- cgit v1.2.1 From 316358345aee2e8668f1ab048d57c2176e8788b4 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 23 Sep 2015 16:02:21 -0400 Subject: Make all "Quick help" link text the entire body of the link Prior, it wasn't obvious which parts of each item was an actual link. --- app/views/help/index.html.haml | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/app/views/help/index.html.haml b/app/views/help/index.html.haml index 5e0cf06e15e..8982831e20d 100644 --- a/app/views/help/index.html.haml +++ b/app/views/help/index.html.haml @@ -34,19 +34,8 @@ .panel-heading Quick help %ul.well-list - %li - See our website for - = link_to 'getting help', promo_url + '/getting-help/' - %li - Use the - = link_to 'search bar', '#', onclick: 'Shortcuts.focusSearch(event)' - on the top of this page - %li - Use - = link_to 'shortcuts', '#', onclick: 'Shortcuts.showHelp(event)' - %li - Get a support - = link_to 'subscription', 'https://about.gitlab.com/pricing/' - %li - = link_to 'Compare', 'https://about.gitlab.com/features/#compare' - GitLab editions + %li= link_to 'See our website for getting help', promo_url + '/getting-help/' + %li= link_to 'Use the search bar on the top of this page', '#', onclick: 'Shortcuts.focusSearch(event)' + %li= link_to 'Use shortcuts', '#', onclick: 'Shortcuts.showHelp(event)' + %li= link_to 'Get a support subscription', 'https://about.gitlab.com/pricing/' + %li= link_to 'Compare GitLab editions', 'https://about.gitlab.com/features/#compare' -- cgit v1.2.1 From de844ebf6ce6044b98f0e7e1d2e8cb9d032f7f00 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 23 Sep 2015 16:03:38 -0400 Subject: "fine grained" -> "fine-grained" --- app/views/help/index.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/help/index.html.haml b/app/views/help/index.html.haml index 8982831e20d..b05e960abc6 100644 --- a/app/views/help/index.html.haml +++ b/app/views/help/index.html.haml @@ -9,7 +9,7 @@ %p.slead GitLab is open source software to collaborate on code. %br - Manage git repositories with fine grained access controls that keep your code secure. + Manage git repositories with fine-grained access controls that keep your code secure. %br Perform code reviews and enhance collaboration with merge requests. %br -- cgit v1.2.1 From 73288a8edb10e45348846dc6491db0732945a29c Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 23 Sep 2015 16:03:52 -0400 Subject: Add "Community Edition" to the version info on the help page If the version information was hidden because the user was not an admin, the "GitLab" text looked lonely. This also brings us more in line with EE which shows "Enterprise Edition". --- app/views/help/index.html.haml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/help/index.html.haml b/app/views/help/index.html.haml index b05e960abc6..abffabfc41d 100644 --- a/app/views/help/index.html.haml +++ b/app/views/help/index.html.haml @@ -1,6 +1,7 @@ %div %h1 GitLab + Community Edition - if current_user && current_user.admin? %span= Gitlab::VERSION %small= Gitlab::REVISION -- cgit v1.2.1 From 48cfad9013f1aa4745bf2b07bfd07e34724ba037 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 23 Sep 2015 16:20:58 -0400 Subject: Add a view spec (gasp!) for help/index --- spec/views/help/index.html.haml_spec.rb | 55 +++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 spec/views/help/index.html.haml_spec.rb diff --git a/spec/views/help/index.html.haml_spec.rb b/spec/views/help/index.html.haml_spec.rb new file mode 100644 index 00000000000..4fd561428f6 --- /dev/null +++ b/spec/views/help/index.html.haml_spec.rb @@ -0,0 +1,55 @@ +require 'rails_helper' + +describe 'help/index' do + describe 'version information' do + it 'is hidden from guests' do + stub_user + stub_version('8.0.2', 'abcdefg') + stub_helpers + + render + + expect(rendered).not_to match '8.0.2' + expect(rendered).not_to match 'abcdefg' + end + + it 'is hidden from users' do + stub_user(admin?: false) + stub_version('8.0.2', 'abcdefg') + stub_helpers + + render + + expect(rendered).not_to match '8.0.2' + expect(rendered).not_to match 'abcdefg' + end + + it 'is shown to admins' do + stub_user(admin?: true) + stub_version('8.0.2', 'abcdefg') + stub_helpers + + render + + expect(rendered).to match '8.0.2' + expect(rendered).to match 'abcdefg' + end + end + + def stub_user(messages = {}) + user = messages.empty? ? nil : double(messages) + + allow(view).to receive(:current_user).and_return(user) + end + + def stub_version(version, revision) + stub_const('Gitlab::VERSION', version) + stub_const('Gitlab::REVISION', revision) + end + + def stub_helpers + allow(view).to receive(:markdown).and_return('') + allow(view).to receive(:current_application_settings). + and_return(double.as_null_object) + end +end -- cgit v1.2.1 From be142e6bd687d223dd4a543295d18676f408b7e3 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 23 Sep 2015 16:26:15 -0400 Subject: Move the `version_check_enabled` check from view to helper --- app/helpers/version_check_helper.rb | 2 +- app/views/help/index.html.haml | 3 +-- spec/views/help/index.html.haml_spec.rb | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/app/helpers/version_check_helper.rb b/app/helpers/version_check_helper.rb index f64d730b448..a674564c4ec 100644 --- a/app/helpers/version_check_helper.rb +++ b/app/helpers/version_check_helper.rb @@ -1,6 +1,6 @@ module VersionCheckHelper def version_status_badge - if Rails.env.production? + if Rails.env.production? && current_application_settings.version_check_enabled image_tag VersionCheck.new.url end end diff --git a/app/views/help/index.html.haml b/app/views/help/index.html.haml index abffabfc41d..2333e6fdf1d 100644 --- a/app/views/help/index.html.haml +++ b/app/views/help/index.html.haml @@ -5,8 +5,7 @@ - if current_user && current_user.admin? %span= Gitlab::VERSION %small= Gitlab::REVISION - - if current_application_settings.version_check_enabled - = version_status_badge + = version_status_badge %p.slead GitLab is open source software to collaborate on code. %br diff --git a/spec/views/help/index.html.haml_spec.rb b/spec/views/help/index.html.haml_spec.rb index 4fd561428f6..91cf4cb98c0 100644 --- a/spec/views/help/index.html.haml_spec.rb +++ b/spec/views/help/index.html.haml_spec.rb @@ -49,7 +49,6 @@ describe 'help/index' do def stub_helpers allow(view).to receive(:markdown).and_return('') - allow(view).to receive(:current_application_settings). - and_return(double.as_null_object) + allow(view).to receive(:version_status_badge).and_return('') end end -- cgit v1.2.1 From 45824aabc634e06d9f7dd853e573c153b7bf9a78 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 23 Sep 2015 17:18:15 -0400 Subject: Allow non-admin users to see version information We want users to know what features they have available (and to pressure their admins to upgrade). --- app/views/help/index.html.haml | 2 +- spec/views/help/index.html.haml_spec.rb | 23 +++++------------------ 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/app/views/help/index.html.haml b/app/views/help/index.html.haml index 2333e6fdf1d..57bc91ea5a9 100644 --- a/app/views/help/index.html.haml +++ b/app/views/help/index.html.haml @@ -2,7 +2,7 @@ %h1 GitLab Community Edition - - if current_user && current_user.admin? + - if user_signed_in? %span= Gitlab::VERSION %small= Gitlab::REVISION = version_status_badge diff --git a/spec/views/help/index.html.haml_spec.rb b/spec/views/help/index.html.haml_spec.rb index 91cf4cb98c0..6b07fcfc987 100644 --- a/spec/views/help/index.html.haml_spec.rb +++ b/spec/views/help/index.html.haml_spec.rb @@ -3,18 +3,7 @@ require 'rails_helper' describe 'help/index' do describe 'version information' do it 'is hidden from guests' do - stub_user - stub_version('8.0.2', 'abcdefg') - stub_helpers - - render - - expect(rendered).not_to match '8.0.2' - expect(rendered).not_to match 'abcdefg' - end - - it 'is hidden from users' do - stub_user(admin?: false) + stub_user(nil) stub_version('8.0.2', 'abcdefg') stub_helpers @@ -24,8 +13,8 @@ describe 'help/index' do expect(rendered).not_to match 'abcdefg' end - it 'is shown to admins' do - stub_user(admin?: true) + it 'is shown to users' do + stub_user stub_version('8.0.2', 'abcdefg') stub_helpers @@ -36,10 +25,8 @@ describe 'help/index' do end end - def stub_user(messages = {}) - user = messages.empty? ? nil : double(messages) - - allow(view).to receive(:current_user).and_return(user) + def stub_user(user = double) + allow(view).to receive(:user_signed_in?).and_return(user) end def stub_version(version, revision) -- cgit v1.2.1