Commit 5564090d authored by Brett Walker's avatar Brett Walker

Fix task lists on closed merge request pages

by checking correct class name
parent defea506
...@@ -24,7 +24,7 @@ function MergeRequest(opts) { ...@@ -24,7 +24,7 @@ function MergeRequest(opts) {
this.initCommitMessageListeners(); this.initCommitMessageListeners();
this.closeReopenReportToggle = IssuablesHelper.initCloseReopenReport(); this.closeReopenReportToggle = IssuablesHelper.initCloseReopenReport();
if ($('a.btn-close').length) { if ($('.description.js-task-list-container').length) {
this.taskList = new TaskList({ this.taskList = new TaskList({
dataType: 'merge_request', dataType: 'merge_request',
fieldName: 'description', fieldName: 'description',
......
---
title: Task lists work correctly again on closed MRs
merge_request: 23714
author:
type: fixed
...@@ -5,7 +5,7 @@ require 'spec_helper' ...@@ -5,7 +5,7 @@ require 'spec_helper'
describe 'Task Lists' do describe 'Task Lists' do
include Warden::Test::Helpers include Warden::Test::Helpers
let(:project) { create(:project, :repository) } let(:project) { create(:project, :public, :repository) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:user2) { create(:user) } let(:user2) { create(:user) }
...@@ -122,6 +122,7 @@ describe 'Task Lists' do ...@@ -122,6 +122,7 @@ describe 'Task Lists' do
it 'provides a summary on Issues#index' do it 'provides a summary on Issues#index' do
visit project_issues_path(project) visit project_issues_path(project)
expect(page).to have_content("2 of 6 tasks completed") expect(page).to have_content("2 of 6 tasks completed")
end end
end end
...@@ -191,6 +192,7 @@ describe 'Task Lists' do ...@@ -191,6 +192,7 @@ describe 'Task Lists' do
it 'is only editable by author', :js do it 'is only editable by author', :js do
visit_issue(project, issue) visit_issue(project, issue)
expect(page).to have_selector('.js-task-list-container') expect(page).to have_selector('.js-task-list-container')
gitlab_sign_out gitlab_sign_out
...@@ -237,10 +239,7 @@ describe 'Task Lists' do ...@@ -237,10 +239,7 @@ describe 'Task Lists' do
visit project_merge_request_path(project, merge) visit project_merge_request_path(project, merge)
end end
describe 'multiple tasks' do shared_examples 'multiple tasks' do
let(:project) { create(:project, :repository) }
let!(:merge) { create(:merge_request, :simple, description: markdown, author: user, source_project: project) }
it 'renders for description' do it 'renders for description' do
visit_merge_request(project, merge) visit_merge_request(project, merge)
...@@ -261,23 +260,40 @@ describe 'Task Lists' do ...@@ -261,23 +260,40 @@ describe 'Task Lists' do
expect(page).to have_selector('a.btn-close') expect(page).to have_selector('a.btn-close')
end end
it 'is only editable by author' do it 'is only editable by author', :js do
visit_merge_request(project, merge) visit_merge_request(project, merge)
expect(page).to have_selector('.js-task-list-container') expect(page).to have_selector('.js-task-list-container')
expect(page).to have_selector('li.task-list-item.enabled', count: 6)
logout(:user) logout(:user)
login_as(user2) login_as(user2)
visit current_path visit current_path
expect(page).not_to have_selector('.js-task-list-container') expect(page).not_to have_selector('.js-task-list-container')
expect(page).to have_selector('li.task-list-item.enabled', count: 0)
expect(page).to have_selector('li.task-list-item input[disabled]', count: 6)
end end
end
context 'when merge request is open' do
let!(:merge) { create(:merge_request, :simple, description: markdown, author: user, source_project: project) }
it_behaves_like 'multiple tasks'
it 'provides a summary on MergeRequests#index' do it 'provides a summary on MergeRequests#index' do
visit project_merge_requests_path(project) visit project_merge_requests_path(project)
expect(page).to have_content("2 of 6 tasks completed") expect(page).to have_content("2 of 6 tasks completed")
end end
end end
context 'when merge request is closed' do
let!(:merge) { create(:merge_request, :closed, :simple, description: markdown, author: user, source_project: project) }
it_behaves_like 'multiple tasks'
end
describe 'single incomplete task' do describe 'single incomplete task' do
let!(:merge) { create(:merge_request, :simple, description: singleIncompleteMarkdown, author: user, source_project: project) } let!(:merge) { create(:merge_request, :simple, description: singleIncompleteMarkdown, author: user, source_project: project) }
...@@ -291,6 +307,7 @@ describe 'Task Lists' do ...@@ -291,6 +307,7 @@ describe 'Task Lists' do
it 'provides a summary on MergeRequests#index' do it 'provides a summary on MergeRequests#index' do
visit project_merge_requests_path(project) visit project_merge_requests_path(project)
expect(page).to have_content("0 of 1 task completed") expect(page).to have_content("0 of 1 task completed")
end end
end 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