Commit 2368ffd9 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'dashboard-milestone-tabs-loading-async' into 'master'

Fixed dashboard milestone tabs not loading

Closes #33477

See merge request !12023
parents e80df8f2 c0c82368
......@@ -46,8 +46,10 @@ module MilestoneActions
def milestone_redirect_path
if @project
namespace_project_milestone_path(@project.namespace, @project, @milestone)
else
elsif @group
group_milestone_path(@group, @milestone.safe_title, title: @milestone.title)
else
dashboard_milestone_path(@milestone.safe_title, title: @milestone.title)
end
end
end
class Dashboard::MilestonesController < Dashboard::ApplicationController
include MilestoneActions
before_action :projects
before_action :milestone, only: [:show]
before_action :milestone, only: [:show, :merge_requests, :participants, :labels]
def index
respond_to do |format|
......
......@@ -121,6 +121,8 @@ module MilestonesHelper
merge_requests_namespace_project_milestone_path(@project.namespace, @project, milestone, format: :json)
elsif @group
merge_requests_group_milestone_path(@group, milestone.safe_title, title: milestone.title, format: :json)
else
merge_requests_dashboard_milestone_path(milestone, title: milestone.title, format: :json)
end
end
......@@ -129,6 +131,8 @@ module MilestonesHelper
participants_namespace_project_milestone_path(@project.namespace, @project, milestone, format: :json)
elsif @group
participants_group_milestone_path(@group, milestone.safe_title, title: milestone.title, format: :json)
else
participants_dashboard_milestone_path(milestone, title: milestone.title, format: :json)
end
end
......@@ -137,6 +141,8 @@ module MilestonesHelper
labels_namespace_project_milestone_path(@project.namespace, @project, milestone, format: :json)
elsif @group
labels_group_milestone_path(@group, milestone.safe_title, title: milestone.title, format: :json)
else
labels_dashboard_milestone_path(milestone, title: milestone.title, format: :json)
end
end
end
---
title: Fixed dashboard milestone tabs not loading
merge_request:
author:
......@@ -4,7 +4,13 @@ resource :dashboard, controller: 'dashboard', only: [] do
get :activity
scope module: :dashboard do
resources :milestones, only: [:index, :show]
resources :milestones, only: [:index, :show] do
member do
get :merge_requests
get :participants
get :labels
end
end
resources :labels, only: [:index]
resources :groups, only: [:index]
......
require 'spec_helper'
describe Dashboard::MilestonesController do
let(:project) { create(:empty_project) }
let(:user) { create(:user) }
let(:project_milestone) { create(:milestone, project: project) }
let(:milestone) do
DashboardMilestone.build(
[project],
project_milestone.title
)
end
let(:issue) { create(:issue, project: project, milestone: project_milestone) }
let!(:label) { create(:label, project: project, title: 'Issue Label', issues: [issue]) }
let!(:merge_request) { create(:merge_request, source_project: project, target_project: project, milestone: project_milestone) }
let(:milestone_path) { dashboard_milestone_path(milestone.safe_title, title: milestone.title) }
before do
sign_in(user)
project.team << [user, :master]
end
it_behaves_like 'milestone tabs'
describe "#show" do
render_views
def view_milestone
get :show, id: milestone.safe_title, title: milestone.title
end
it 'shows milestone page' do
view_milestone
expect(response).to have_http_status(200)
end
end
end
require 'spec_helper'
describe 'Dashboard milestone tabs', :js, :feature do
let(:user) { create(:user) }
let(:project) { create(:empty_project) }
let!(:label) { create(:label, project: project) }
let(:project_milestone) { create(:milestone, project: project) }
let(:milestone) do
DashboardMilestone.build(
[project],
project_milestone.title
)
end
let!(:merge_request) { create(:labeled_merge_request, source_project: project, target_project: project, milestone: project_milestone, labels: [label]) }
before do
project.add_master(user)
login_as(user)
visit dashboard_milestone_path(milestone.safe_title, title: milestone.title)
end
it 'loads merge requests async' do
click_link 'Merge Requests'
expect(page).to have_selector('.merge_requests-sortable-list')
end
it 'loads participants async' do
click_link 'Participants'
expect(page).to have_selector('#tab-participants .bordered-list')
end
it 'loads labels async' do
click_link 'Labels'
expect(page).to have_selector('#tab-labels .bordered-list')
end
end
shared_examples 'milestone tabs' do
def go(path, extra_params = {})
params = if milestone.is_a?(GlobalMilestone)
{ group_id: group.to_param, id: milestone.safe_title, title: milestone.title }
else
{ namespace_id: project.namespace.to_param, project_id: project, id: milestone.iid }
end
params =
case milestone
when DashboardMilestone
{ id: milestone.safe_title, title: milestone.title }
when GroupMilestone
{ group_id: group.to_param, id: milestone.safe_title, title: milestone.title }
else
{ namespace_id: project.namespace.to_param, project_id: project, id: milestone.iid }
end
get path, params.merge(extra_params)
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment