From eae27d1ecbfec7ea928b27e0ffc96abeb4a49f7a Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 23 Sep 2015 16:16:45 +0200 Subject: Move CI charts to project graphs area Signed-off-by: Dmitriy Zaporozhets --- app/controllers/ci/charts_controller.rb | 24 --------------- app/controllers/projects/graphs_controller.rb | 10 +++++++ app/views/ci/charts/_build_times.haml | 21 ------------- app/views/ci/charts/_builds.haml | 41 -------------------------- app/views/ci/charts/_overall.haml | 21 ------------- app/views/ci/charts/show.html.haml | 4 --- app/views/layouts/ci/_nav_project.html.haml | 6 ---- app/views/projects/graphs/_head.html.haml | 4 +++ app/views/projects/graphs/ci.html.haml | 6 ++++ app/views/projects/graphs/ci/_build_times.haml | 21 +++++++++++++ app/views/projects/graphs/ci/_builds.haml | 41 ++++++++++++++++++++++++++ app/views/projects/graphs/ci/_overall.haml | 22 ++++++++++++++ config/routes.rb | 1 + features/project/graph.feature | 6 ++++ features/steps/project/graph.rb | 22 ++++++++++++-- spec/features/ci/projects_spec.rb | 12 -------- 16 files changed, 131 insertions(+), 131 deletions(-) delete mode 100644 app/controllers/ci/charts_controller.rb delete mode 100644 app/views/ci/charts/_build_times.haml delete mode 100644 app/views/ci/charts/_builds.haml delete mode 100644 app/views/ci/charts/_overall.haml delete mode 100644 app/views/ci/charts/show.html.haml create mode 100644 app/views/projects/graphs/ci.html.haml create mode 100644 app/views/projects/graphs/ci/_build_times.haml create mode 100644 app/views/projects/graphs/ci/_builds.haml create mode 100644 app/views/projects/graphs/ci/_overall.haml diff --git a/app/controllers/ci/charts_controller.rb b/app/controllers/ci/charts_controller.rb deleted file mode 100644 index aa875e70987..00000000000 --- a/app/controllers/ci/charts_controller.rb +++ /dev/null @@ -1,24 +0,0 @@ -module Ci - class ChartsController < Ci::ApplicationController - before_action :authenticate_user! - before_action :project - before_action :authorize_access_project! - before_action :authorize_manage_project! - - layout 'ci/project' - - def show - @charts = {} - @charts[:week] = Ci::Charts::WeekChart.new(@project) - @charts[:month] = Ci::Charts::MonthChart.new(@project) - @charts[:year] = Ci::Charts::YearChart.new(@project) - @charts[:build_times] = Ci::Charts::BuildTime.new(@project) - end - - protected - - def project - @project = Ci::Project.find(params[:project_id]) - end - end -end diff --git a/app/controllers/projects/graphs_controller.rb b/app/controllers/projects/graphs_controller.rb index 0b6f7f5c91e..8bc5746a42c 100644 --- a/app/controllers/projects/graphs_controller.rb +++ b/app/controllers/projects/graphs_controller.rb @@ -23,6 +23,16 @@ class Projects::GraphsController < Projects::ApplicationController @commits_per_month = @commits_graph.commits_per_month end + def ci + ci_project = @project.gitlab_ci_project + + @charts = {} + @charts[:week] = Ci::Charts::WeekChart.new(ci_project) + @charts[:month] = Ci::Charts::MonthChart.new(ci_project) + @charts[:year] = Ci::Charts::YearChart.new(ci_project) + @charts[:build_times] = Ci::Charts::BuildTime.new(ci_project) + end + private def fetch_graph diff --git a/app/views/ci/charts/_build_times.haml b/app/views/ci/charts/_build_times.haml deleted file mode 100644 index c3c2f572414..00000000000 --- a/app/views/ci/charts/_build_times.haml +++ /dev/null @@ -1,21 +0,0 @@ -%fieldset - %legend - Commit duration in minutes for last 30 commits - - %canvas#build_timesChart.padded{width: 800, height: 300} - -:javascript - var data = { - labels : #{@charts[:build_times].labels.to_json}, - datasets : [ - { - fillColor : "#4A3", - strokeColor : "rgba(151,187,205,1)", - pointColor : "rgba(151,187,205,1)", - pointStrokeColor : "#fff", - data : #{@charts[:build_times].build_times.to_json} - } - ] - } - var ctx = $("#build_timesChart").get(0).getContext("2d"); - new Chart(ctx).Line(data,{"scaleOverlay": true}); diff --git a/app/views/ci/charts/_builds.haml b/app/views/ci/charts/_builds.haml deleted file mode 100644 index 1b0039fb834..00000000000 --- a/app/views/ci/charts/_builds.haml +++ /dev/null @@ -1,41 +0,0 @@ -%fieldset - %legend - Builds chart for last week - (#{date_from_to(Date.today - 7.days, Date.today)}) - - %canvas#weekChart.padded{width: 800, height: 200} - -%fieldset - %legend - Builds chart for last month - (#{date_from_to(Date.today - 30.days, Date.today)}) - - %canvas#monthChart.padded{width: 800, height: 300} - -%fieldset - %legend Builds chart for last year - %canvas#yearChart.padded{width: 800, height: 400} - -- [:week, :month, :year].each do |scope| - :javascript - var data = { - labels : #{@charts[scope].labels.to_json}, - datasets : [ - { - fillColor : "rgba(220,220,220,0.5)", - strokeColor : "rgba(220,220,220,1)", - pointColor : "rgba(220,220,220,1)", - pointStrokeColor : "#EEE", - data : #{@charts[scope].total.to_json} - }, - { - fillColor : "#4A3", - strokeColor : "rgba(151,187,205,1)", - pointColor : "rgba(151,187,205,1)", - pointStrokeColor : "#fff", - data : #{@charts[scope].success.to_json} - } - ] - } - var ctx = $("##{scope}Chart").get(0).getContext("2d"); - new Chart(ctx).Line(data,{"scaleOverlay": true}); diff --git a/app/views/ci/charts/_overall.haml b/app/views/ci/charts/_overall.haml deleted file mode 100644 index f522f35a629..00000000000 --- a/app/views/ci/charts/_overall.haml +++ /dev/null @@ -1,21 +0,0 @@ -%fieldset - %legend Overall - %p - Total: - %strong= pluralize @project.builds.count(:all), 'build' - %p - Successful: - %strong= pluralize @project.builds.success.count(:all), 'build' - %p - Failed: - %strong= pluralize @project.builds.failed.count(:all), 'build' - - %p - Success ratio: - %strong - #{success_ratio(@project.builds.success, @project.builds.failed)}% - - %p - Commits covered: - %strong - = @project.commits.count(:all) diff --git a/app/views/ci/charts/show.html.haml b/app/views/ci/charts/show.html.haml deleted file mode 100644 index 0497f037721..00000000000 --- a/app/views/ci/charts/show.html.haml +++ /dev/null @@ -1,4 +0,0 @@ -#charts.ci-charts - = render 'builds' - = render 'build_times' -= render 'overall' diff --git a/app/views/layouts/ci/_nav_project.html.haml b/app/views/layouts/ci/_nav_project.html.haml index cb1dece073c..284735e45c4 100644 --- a/app/views/layouts/ci/_nav_project.html.haml +++ b/app/views/layouts/ci/_nav_project.html.haml @@ -10,12 +10,6 @@ %span Commits %span.count= @project.commits.count - - if can?(current_user, :admin_project, gl_project) - = nav_link path: 'charts#show' do - = link_to ci_project_charts_path(@project) do - = icon('bar-chart fw') - %span - Charts = nav_link path: ['runners#index', 'runners#show', 'runners#edit'] do = link_to ci_project_runners_path(@project) do = icon('cog fw') diff --git a/app/views/projects/graphs/_head.html.haml b/app/views/projects/graphs/_head.html.haml index 9383df13305..bbfaf422a82 100644 --- a/app/views/projects/graphs/_head.html.haml +++ b/app/views/projects/graphs/_head.html.haml @@ -3,3 +3,7 @@ = link_to 'Contributors', namespace_project_graph_path = nav_link(action: :commits) do = link_to 'Commits', commits_namespace_project_graph_path + - if @project.gitlab_ci? + = nav_link(action: :ci) do + = link_to ci_namespace_project_graph_path do + Continuous Integration diff --git a/app/views/projects/graphs/ci.html.haml b/app/views/projects/graphs/ci.html.haml new file mode 100644 index 00000000000..2e07b67f8c0 --- /dev/null +++ b/app/views/projects/graphs/ci.html.haml @@ -0,0 +1,6 @@ +- page_title "Continuous Integration", "Graphs" += render 'head' +#charts.ci-charts + = render 'projects/graphs/ci/builds' + = render 'projects/graphs/ci/build_times' += render 'projects/graphs/ci/overall' diff --git a/app/views/projects/graphs/ci/_build_times.haml b/app/views/projects/graphs/ci/_build_times.haml new file mode 100644 index 00000000000..c3c2f572414 --- /dev/null +++ b/app/views/projects/graphs/ci/_build_times.haml @@ -0,0 +1,21 @@ +%fieldset + %legend + Commit duration in minutes for last 30 commits + + %canvas#build_timesChart.padded{width: 800, height: 300} + +:javascript + var data = { + labels : #{@charts[:build_times].labels.to_json}, + datasets : [ + { + fillColor : "#4A3", + strokeColor : "rgba(151,187,205,1)", + pointColor : "rgba(151,187,205,1)", + pointStrokeColor : "#fff", + data : #{@charts[:build_times].build_times.to_json} + } + ] + } + var ctx = $("#build_timesChart").get(0).getContext("2d"); + new Chart(ctx).Line(data,{"scaleOverlay": true}); diff --git a/app/views/projects/graphs/ci/_builds.haml b/app/views/projects/graphs/ci/_builds.haml new file mode 100644 index 00000000000..1b0039fb834 --- /dev/null +++ b/app/views/projects/graphs/ci/_builds.haml @@ -0,0 +1,41 @@ +%fieldset + %legend + Builds chart for last week + (#{date_from_to(Date.today - 7.days, Date.today)}) + + %canvas#weekChart.padded{width: 800, height: 200} + +%fieldset + %legend + Builds chart for last month + (#{date_from_to(Date.today - 30.days, Date.today)}) + + %canvas#monthChart.padded{width: 800, height: 300} + +%fieldset + %legend Builds chart for last year + %canvas#yearChart.padded{width: 800, height: 400} + +- [:week, :month, :year].each do |scope| + :javascript + var data = { + labels : #{@charts[scope].labels.to_json}, + datasets : [ + { + fillColor : "rgba(220,220,220,0.5)", + strokeColor : "rgba(220,220,220,1)", + pointColor : "rgba(220,220,220,1)", + pointStrokeColor : "#EEE", + data : #{@charts[scope].total.to_json} + }, + { + fillColor : "#4A3", + strokeColor : "rgba(151,187,205,1)", + pointColor : "rgba(151,187,205,1)", + pointStrokeColor : "#fff", + data : #{@charts[scope].success.to_json} + } + ] + } + var ctx = $("##{scope}Chart").get(0).getContext("2d"); + new Chart(ctx).Line(data,{"scaleOverlay": true}); diff --git a/app/views/projects/graphs/ci/_overall.haml b/app/views/projects/graphs/ci/_overall.haml new file mode 100644 index 00000000000..9550d719471 --- /dev/null +++ b/app/views/projects/graphs/ci/_overall.haml @@ -0,0 +1,22 @@ +- ci_project = @project.gitlab_ci_project +%fieldset + %legend Overall + %p + Total: + %strong= pluralize ci_project.builds.count(:all), 'build' + %p + Successful: + %strong= pluralize ci_project.builds.success.count(:all), 'build' + %p + Failed: + %strong= pluralize ci_project.builds.failed.count(:all), 'build' + + %p + Success ratio: + %strong + #{success_ratio(ci_project.builds.success, ci_project.builds.failed)}% + + %p + Commits covered: + %strong + = ci_project.commits.count(:all) diff --git a/config/routes.rb b/config/routes.rb index 512dda7b547..4a07c449b4e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -511,6 +511,7 @@ Gitlab::Application.routes.draw do resources :graphs, only: [:show], constraints: { id: /(?:[^.]|\.(?!json$))+/, format: /json/ } do member do get :commits + get :ci end end diff --git a/features/project/graph.feature b/features/project/graph.feature index 89064242c1c..2acd65aea5f 100644 --- a/features/project/graph.feature +++ b/features/project/graph.feature @@ -12,3 +12,9 @@ Feature: Project Graph Scenario: I should see project commits graphs When I visit project "Shop" commits graph page Then page should have commits graphs + + @javascript + Scenario: I should see project ci graphs + Given project "Shop" has CI enabled + When I visit project "Shop" CI graph page + Then page should have CI graphs diff --git a/features/steps/project/graph.rb b/features/steps/project/graph.rb index 5e7e573a6ab..9f9d099961d 100644 --- a/features/steps/project/graph.rb +++ b/features/steps/project/graph.rb @@ -7,12 +7,10 @@ class Spinach::Features::ProjectGraph < Spinach::FeatureSteps end When 'I visit project "Shop" graph page' do - project = Project.find_by(name: "Shop") visit namespace_project_graph_path(project.namespace, project, "master") end step 'I visit project "Shop" commits graph page' do - project = Project.find_by(name: "Shop") visit commits_namespace_project_graph_path(project.namespace, project, "master") end @@ -20,4 +18,24 @@ class Spinach::Features::ProjectGraph < Spinach::FeatureSteps expect(page).to have_content "Commit statistics for master" expect(page).to have_content "Commits per day of month" end + + step 'I visit project "Shop" CI graph page' do + visit ci_namespace_project_graph_path(project.namespace, project, 'master') + end + + step 'project "Shop" has CI enabled' do + project.enable_ci(@user) + end + + step 'page should have CI graphs' do + expect(page).to have_content 'Overall' + expect(page).to have_content 'Builds chart for last week' + expect(page).to have_content 'Builds chart for last month' + expect(page).to have_content 'Builds chart for last year' + expect(page).to have_content 'Commit duration in minutes for last 30 commits' + end + + def project + project ||= Project.find_by(name: "Shop") + end end diff --git a/spec/features/ci/projects_spec.rb b/spec/features/ci/projects_spec.rb index ff17aeca447..2ae6a7a29f8 100644 --- a/spec/features/ci/projects_spec.rb +++ b/spec/features/ci/projects_spec.rb @@ -45,16 +45,4 @@ describe "Projects" do expect(find_field('Timeout').value).to eq '70' end end - - describe "GET /ci/projects/:id/charts" do - before do - visit ci_project_charts_path(@project) - end - - it { expect(page).to have_content 'Overall' } - it { expect(page).to have_content 'Builds chart for last week' } - it { expect(page).to have_content 'Builds chart for last month' } - it { expect(page).to have_content 'Builds chart for last year' } - it { expect(page).to have_content 'Commit duration in minutes for last 30 commits' } - end end -- cgit v1.2.1 From d538955ac89c0bffd5b0d5ebff73f81c4efb21ee Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 23 Sep 2015 16:17:07 +0200 Subject: Update CHANGELOG Signed-off-by: Dmitriy Zaporozhets --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index 4ee55016576..067ac37815d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,7 @@ Please view this file on the master branch, on stable branches it's out of date. v 8.1.0 (unreleased) - Show CI status on all pages where commits list is rendered - Automatically enable CI when push .gitlab-ci.yml file to repository + - Move CI charts to project graphs area v 8.0.1 - Improve CI migration procedure and documentation -- cgit v1.2.1 From 150fb81ef90cba74bf7828e652e052b9ababcdf8 Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Wed, 23 Sep 2015 08:21:51 -0700 Subject: Remove git refs used internally by GitLab from network graph Closes #2702 --- CHANGELOG | 1 + app/helpers/graph_helper.rb | 5 ++++- spec/helpers/graph_helper_spec.rb | 16 ++++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 spec/helpers/graph_helper_spec.rb diff --git a/CHANGELOG b/CHANGELOG index 1cb338f16da..b0540151fce 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ Please view this file on the master branch, on stable branches it's out of date. v 8.0.1 + - Remove git refs used internally by GitLab from network graph (Stan Hu) - Improve CI migration procedure and documentation v 8.0.0 diff --git a/app/helpers/graph_helper.rb b/app/helpers/graph_helper.rb index e1dda20de85..1e372d5631d 100644 --- a/app/helpers/graph_helper.rb +++ b/app/helpers/graph_helper.rb @@ -1,7 +1,10 @@ module GraphHelper def get_refs(repo, commit) refs = "" - refs << commit.ref_names(repo).join(' ') + # Commit::ref_names already strips the refs/XXX from important refs (e.g. refs/heads/XXX) + # so anything leftover is internally used by GitLab + commit_refs = commit.ref_names(repo).reject{ |name| name.starts_with?('refs/') } + refs << commit_refs.join(' ') # append note count refs << "[#{@graph.notes[commit.id]}]" if @graph.notes[commit.id] > 0 diff --git a/spec/helpers/graph_helper_spec.rb b/spec/helpers/graph_helper_spec.rb new file mode 100644 index 00000000000..4acf38771b7 --- /dev/null +++ b/spec/helpers/graph_helper_spec.rb @@ -0,0 +1,16 @@ +require 'spec_helper' + +describe GraphHelper do + describe '#get_refs' do + let(:project) { create(:project) } + let(:commit) { project.commit("master") } + let(:graph) { Network::Graph.new(project, 'master', commit, '') } + + it 'filter our refs used by GitLab' do + allow(commit).to receive(:ref_names).and_return(['refs/merge-requests/abc', 'master', 'refs/tmp/xyz']) + self.instance_variable_set(:@graph, graph) + refs = get_refs(project.repository, commit) + expect(refs).to eq('master') + end + end +end -- cgit v1.2.1 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 From 64e12d5853b44c945a43a9ed7fc7046138884426 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 24 Sep 2015 09:44:38 +0200 Subject: Add header for ci graphs and check that it is enabled Signed-off-by: Dmitriy Zaporozhets --- app/controllers/projects/application_controller.rb | 7 +++++++ app/views/projects/graphs/ci.html.haml | 1 + 2 files changed, 8 insertions(+) diff --git a/app/controllers/projects/application_controller.rb b/app/controllers/projects/application_controller.rb index ee88d49b400..e8af4c092da 100644 --- a/app/controllers/projects/application_controller.rb +++ b/app/controllers/projects/application_controller.rb @@ -1,6 +1,7 @@ class Projects::ApplicationController < ApplicationController before_action :project before_action :repository + before_action :ci_enabled, only: :ci layout 'project' def authenticate_user! @@ -25,4 +26,10 @@ class Projects::ApplicationController < ApplicationController ) end end + + private + + def ci_enabled + return render_404 unless @project.gitlab_ci? + end end diff --git a/app/views/projects/graphs/ci.html.haml b/app/views/projects/graphs/ci.html.haml index 2e07b67f8c0..4f69cc64f7c 100644 --- a/app/views/projects/graphs/ci.html.haml +++ b/app/views/projects/graphs/ci.html.haml @@ -1,4 +1,5 @@ - page_title "Continuous Integration", "Graphs" += render "header_title" = render 'head' #charts.ci-charts = render 'projects/graphs/ci/builds' -- cgit v1.2.1 From 50cff3e4006ef2d57ebcb258c619a42af00bddc0 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 24 Sep 2015 09:47:52 +0200 Subject: Check for CI enabled in correct place Signed-off-by: Dmitriy Zaporozhets --- app/controllers/projects/application_controller.rb | 1 - app/controllers/projects/graphs_controller.rb | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/projects/application_controller.rb b/app/controllers/projects/application_controller.rb index e8af4c092da..48c922f450c 100644 --- a/app/controllers/projects/application_controller.rb +++ b/app/controllers/projects/application_controller.rb @@ -1,7 +1,6 @@ class Projects::ApplicationController < ApplicationController before_action :project before_action :repository - before_action :ci_enabled, only: :ci layout 'project' def authenticate_user! diff --git a/app/controllers/projects/graphs_controller.rb b/app/controllers/projects/graphs_controller.rb index 8bc5746a42c..418b92040bc 100644 --- a/app/controllers/projects/graphs_controller.rb +++ b/app/controllers/projects/graphs_controller.rb @@ -5,6 +5,7 @@ class Projects::GraphsController < Projects::ApplicationController before_action :require_non_empty_project before_action :assign_ref_vars before_action :authorize_download_code! + before_action :ci_enabled, only: :ci def show respond_to do |format| -- cgit v1.2.1