summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG1
-rw-r--r--app/controllers/concerns/global_milestones.rb1
-rw-r--r--app/controllers/dashboard/application_controller.rb6
-rw-r--r--app/controllers/dashboard/labels_controller.rb9
-rw-r--r--app/controllers/dashboard/milestones_controller.rb15
-rw-r--r--app/controllers/dashboard_controller.rb29
-rw-r--r--app/controllers/groups/milestones_controller.rb6
-rw-r--r--app/helpers/labels_helper.rb2
-rw-r--r--app/helpers/milestones_helper.rb2
-rw-r--r--config/routes.rb3
-rw-r--r--spec/features/dashboard_milestones_spec.rb29
11 files changed, 62 insertions, 41 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 572794c3fe5..8e9477d1fe8 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -11,6 +11,7 @@ v 8.6.1 (unreleased)
- Auto collapses the navigation sidebar when resizing. !3343
- Shows error messages when trying to create label in dropdown menu. !3345
- Fixes issue with assign milestone not loading milestone list. !3346
+ - Fix an issue causing the Dashboard/Milestones page to be blank. !3348
v 8.6.0
- Add ability to move issue to another project
diff --git a/app/controllers/concerns/global_milestones.rb b/app/controllers/concerns/global_milestones.rb
index 3e4c0e63601..5c503c5b698 100644
--- a/app/controllers/concerns/global_milestones.rb
+++ b/app/controllers/concerns/global_milestones.rb
@@ -6,7 +6,6 @@ module GlobalMilestones
@milestones = MilestonesFinder.new.execute(@projects, params)
@milestones = GlobalMilestone.build_collection(@milestones)
@milestones = @milestones.sort_by { |x| x.due_date.nil? ? epoch : x.due_date }
- @milestones = Kaminari.paginate_array(@milestones).page(params[:page]).per(ApplicationController::PER_PAGE)
end
def milestone
diff --git a/app/controllers/dashboard/application_controller.rb b/app/controllers/dashboard/application_controller.rb
index 962ea38d6c9..9d3d1c23c28 100644
--- a/app/controllers/dashboard/application_controller.rb
+++ b/app/controllers/dashboard/application_controller.rb
@@ -1,3 +1,9 @@
class Dashboard::ApplicationController < ApplicationController
layout 'dashboard'
+
+ private
+
+ def projects
+ @projects ||= current_user.authorized_projects.sorted_by_activity.non_archived
+ end
end
diff --git a/app/controllers/dashboard/labels_controller.rb b/app/controllers/dashboard/labels_controller.rb
new file mode 100644
index 00000000000..23a4ef21ea2
--- /dev/null
+++ b/app/controllers/dashboard/labels_controller.rb
@@ -0,0 +1,9 @@
+class Dashboard::LabelsController < Dashboard::ApplicationController
+ def index
+ labels = Label.where(project_id: projects).select(:title, :color).uniq(:title)
+
+ respond_to do |format|
+ format.json { render json: labels }
+ end
+ end
+end
diff --git a/app/controllers/dashboard/milestones_controller.rb b/app/controllers/dashboard/milestones_controller.rb
index 2bdce0f8a00..fa9c6c054f0 100644
--- a/app/controllers/dashboard/milestones_controller.rb
+++ b/app/controllers/dashboard/milestones_controller.rb
@@ -2,18 +2,19 @@ class Dashboard::MilestonesController < Dashboard::ApplicationController
include GlobalMilestones
before_action :projects
- before_action :milestones, only: [:index]
before_action :milestone, only: [:show]
def index
+ respond_to do |format|
+ format.html do
+ @milestones = Kaminari.paginate_array(milestones).page(params[:page])
+ end
+ format.json do
+ render json: milestones
+ end
+ end
end
def show
end
-
- private
-
- def projects
- @projects ||= current_user.authorized_projects.sorted_by_activity.non_archived
- end
end
diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb
index b538c7d1608..1dce4a21729 100644
--- a/app/controllers/dashboard_controller.rb
+++ b/app/controllers/dashboard_controller.rb
@@ -3,7 +3,7 @@ class DashboardController < Dashboard::ApplicationController
include MergeRequestsAction
before_action :event_filter, only: :activity
- before_action :projects, only: [:issues, :merge_requests, :labels, :milestones]
+ before_action :projects, only: [:issues, :merge_requests]
respond_to :html
@@ -20,29 +20,6 @@ class DashboardController < Dashboard::ApplicationController
end
end
- def labels
- labels = Label.where(project_id: @projects).select(:title, :color).uniq(:title)
-
- respond_to do |format|
- format.json do
- render json: labels
- end
- end
- end
-
- def milestones
- milestones = Milestone.where(project_id: @projects).active
- epoch = DateTime.parse('1970-01-01')
- grouped_milestones = GlobalMilestone.build_collection(milestones)
- grouped_milestones = grouped_milestones.sort_by { |x| x.due_date.nil? ? epoch : x.due_date }
-
- respond_to do |format|
- format.json do
- render json: grouped_milestones
- end
- end
- end
-
protected
def load_events
@@ -57,8 +34,4 @@ class DashboardController < Dashboard::ApplicationController
@events = @event_filter.apply_filter(@events).with_associations
@events = @events.limit(20).offset(params[:offset] || 0)
end
-
- def projects
- @projects ||= current_user.authorized_projects.sorted_by_activity.non_archived
- end
end
diff --git a/app/controllers/groups/milestones_controller.rb b/app/controllers/groups/milestones_controller.rb
index 0028f072d5b..b23c3022fb5 100644
--- a/app/controllers/groups/milestones_controller.rb
+++ b/app/controllers/groups/milestones_controller.rb
@@ -2,11 +2,15 @@ class Groups::MilestonesController < Groups::ApplicationController
include GlobalMilestones
before_action :group_projects
- before_action :milestones, only: [:index]
before_action :milestone, only: [:show, :update]
before_action :authorize_admin_milestones!, only: [:new, :create, :update]
def index
+ respond_to do |format|
+ format.html do
+ @milestones = Kaminari.paginate_array(milestones).page(params[:page])
+ end
+ end
end
def new
diff --git a/app/helpers/labels_helper.rb b/app/helpers/labels_helper.rb
index ed37176aa6b..94e5a47842e 100644
--- a/app/helpers/labels_helper.rb
+++ b/app/helpers/labels_helper.rb
@@ -114,7 +114,7 @@ module LabelsHelper
if @project
namespace_project_labels_path(@project.namespace, @project, :json)
else
- labels_dashboard_path(:json)
+ dashboard_labels_path(:json)
end
end
diff --git a/app/helpers/milestones_helper.rb b/app/helpers/milestones_helper.rb
index c9d8787bd19..87fc2db6901 100644
--- a/app/helpers/milestones_helper.rb
+++ b/app/helpers/milestones_helper.rb
@@ -50,7 +50,7 @@ module MilestonesHelper
if @project
namespace_project_milestones_path(@project.namespace, @project, :json)
else
- milestones_dashboard_path(:json)
+ dashboard_milestones_path(:json)
end
end
diff --git a/config/routes.rb b/config/routes.rb
index 90d858d7fc1..4a3c23b7c1c 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -351,11 +351,10 @@ Rails.application.routes.draw do
get :issues
get :merge_requests
get :activity
- get :labels
- get :milestones
scope module: :dashboard do
resources :milestones, only: [:index, :show]
+ resources :labels, only: [:index]
resources :groups, only: [:index]
resources :snippets, only: [:index]
diff --git a/spec/features/dashboard_milestones_spec.rb b/spec/features/dashboard_milestones_spec.rb
new file mode 100644
index 00000000000..f32fddbc9fa
--- /dev/null
+++ b/spec/features/dashboard_milestones_spec.rb
@@ -0,0 +1,29 @@
+require 'spec_helper'
+
+feature 'Dashboard > Milestones', feature: true do
+ describe 'as anonymous user' do
+ before do
+ visit dashboard_milestones_path
+ end
+
+ it 'is redirected to sign-in page' do
+ expect(current_path).to eq new_user_session_path
+ end
+ end
+
+ describe 'as logged-in user' do
+ let(:user) { create(:user) }
+ let(:project) { create(:empty_project, namespace: user.namespace) }
+ let!(:milestone) { create(:milestone, project: project) }
+ before do
+ project.team << [user, :master]
+ login_with(user)
+ visit dashboard_milestones_path
+ end
+
+ it 'sees milestones' do
+ expect(current_path).to eq dashboard_milestones_path
+ expect(page).to have_content(milestone.title)
+ end
+ end
+end