Fixed failing tests
This commit is contained in:
parent
efb74875cf
commit
4e679819f2
|
@ -5,8 +5,7 @@
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
isDiscussionResolved: function () {
|
isDiscussionResolved: function () {
|
||||||
const discussion = CommentsStore.state[this.discussionId],
|
const discussion = CommentsStore.state[this.discussionId];
|
||||||
notes = CommentsStore.notesForDiscussion(this.discussionId);
|
|
||||||
|
|
||||||
return discussion.isResolved();
|
return discussion.isResolved();
|
||||||
},
|
},
|
||||||
|
|
|
@ -11,8 +11,7 @@
|
||||||
},
|
},
|
||||||
data: function() {
|
data: function() {
|
||||||
return {
|
return {
|
||||||
discussions: CommentsStore.state,
|
discussions: CommentsStore.state
|
||||||
loadingObject: CommentsStore.loading,
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -27,7 +26,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
loading: function () {
|
loading: function () {
|
||||||
return this.loadingObject[this.discussionId];
|
return this.discussions[this.discussionId].loading;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
|
@ -27,7 +27,7 @@ $(() => {
|
||||||
const $components = $('resolve-btn, resolve-discussion-btn, jump-to-discussion');
|
const $components = $('resolve-btn, resolve-discussion-btn, jump-to-discussion');
|
||||||
if ($components.length) {
|
if ($components.length) {
|
||||||
$components.each(function () {
|
$components.each(function () {
|
||||||
DiffNotesApp.$compile($(this).get(0))
|
DiffNotesApp.$compile($(this).get(0));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ class DiscussionModel {
|
||||||
constructor (discussionId) {
|
constructor (discussionId) {
|
||||||
this.discussionId = discussionId;
|
this.discussionId = discussionId;
|
||||||
this.notes = {};
|
this.notes = {};
|
||||||
|
this.loading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
createNote (noteId, resolved, user) {
|
createNote (noteId, resolved, user) {
|
||||||
|
|
|
@ -34,10 +34,12 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
resolveAll(namespace, mergeRequestId, discussionId) {
|
resolveAll(namespace, mergeRequestId, discussionId) {
|
||||||
|
const discussion = CommentsStore.state[discussionId];
|
||||||
|
|
||||||
this.setCSRF();
|
this.setCSRF();
|
||||||
Vue.http.options.root = `/${namespace}`;
|
Vue.http.options.root = `/${namespace}`;
|
||||||
|
|
||||||
CommentsStore.loading[discussionId] = true;
|
discussion.loading = true;
|
||||||
|
|
||||||
return this.discussionResource.save({
|
return this.discussionResource.save({
|
||||||
mergeRequestId,
|
mergeRequestId,
|
||||||
|
@ -45,31 +47,28 @@
|
||||||
}, {}).then((response) => {
|
}, {}).then((response) => {
|
||||||
const data = response.data;
|
const data = response.data;
|
||||||
const user = data ? data.resolved_by : null;
|
const user = data ? data.resolved_by : null;
|
||||||
const discussion = CommentsStore.state[discussionId];
|
|
||||||
discussion.resolveAllNotes(user);
|
discussion.resolveAllNotes(user);
|
||||||
|
discussion.loading = false;
|
||||||
CommentsStore.loading[discussionId] = false;
|
|
||||||
|
|
||||||
|
|
||||||
this.updateUpdatedHtml(discussionId, data);
|
this.updateUpdatedHtml(discussionId, data);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
unResolveAll(namespace, mergeRequestId, discussionId) {
|
unResolveAll(namespace, mergeRequestId, discussionId) {
|
||||||
|
const discussion = CommentsStore.state[discussionId];
|
||||||
|
|
||||||
this.setCSRF();
|
this.setCSRF();
|
||||||
Vue.http.options.root = `/${namespace}`;
|
Vue.http.options.root = `/${namespace}`;
|
||||||
|
|
||||||
CommentsStore.loading[discussionId] = true;
|
discussion.loading = true;
|
||||||
|
|
||||||
return this.discussionResource.delete({
|
return this.discussionResource.delete({
|
||||||
mergeRequestId,
|
mergeRequestId,
|
||||||
discussionId
|
discussionId
|
||||||
}, {}).then((response) => {
|
}, {}).then((response) => {
|
||||||
const data = response.data;
|
const data = response.data;
|
||||||
const discussion = CommentsStore.state[discussionId];
|
|
||||||
discussion.unResolveAllNotes();
|
discussion.unResolveAllNotes();
|
||||||
|
discussion.loading = false;
|
||||||
CommentsStore.loading[discussionId] = false;
|
|
||||||
|
|
||||||
this.updateUpdatedHtml(discussionId, data);
|
this.updateUpdatedHtml(discussionId, data);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
((w) => {
|
((w) => {
|
||||||
w.CommentsStore = {
|
w.CommentsStore = {
|
||||||
state: {},
|
state: {},
|
||||||
loading: {},
|
|
||||||
get: function (discussionId, noteId) {
|
get: function (discussionId, noteId) {
|
||||||
return this.state[discussionId].getNote(noteId);
|
return this.state[discussionId].getNote(noteId);
|
||||||
},
|
},
|
||||||
|
@ -10,7 +9,6 @@
|
||||||
if (!this.state[discussionId]) {
|
if (!this.state[discussionId]) {
|
||||||
discussion = new DiscussionModel(discussionId);
|
discussion = new DiscussionModel(discussionId);
|
||||||
Vue.set(this.state, discussionId, discussion);
|
Vue.set(this.state, discussionId, discussion);
|
||||||
Vue.set(this.loading, discussionId, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
discussion.createNote(noteId, resolved, user);
|
discussion.createNote(noteId, resolved, user);
|
||||||
|
@ -27,7 +25,6 @@
|
||||||
|
|
||||||
if (Object.keys(discussion.notes).length === 0) {
|
if (Object.keys(discussion.notes).length === 0) {
|
||||||
Vue.delete(this.state, discussionId);
|
Vue.delete(this.state, discussionId);
|
||||||
Vue.delete(this.loading, discussionId);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
- if access
|
- if access
|
||||||
%span.note-role.hidden-xs= access
|
%span.note-role.hidden-xs= access
|
||||||
|
|
||||||
- if (note.resolvable? && can?(current_user, :resolve_note, note)) || (note.resolved? && !can?(current_user, :resolve_note, note))
|
- if note.resolvable?
|
||||||
%resolve-btn{ ":namespace-path" => "'#{note.project.namespace.path}'",
|
%resolve-btn{ ":namespace-path" => "'#{note.project.namespace.path}'",
|
||||||
":project-path" => "'#{note.project.path}'",
|
":project-path" => "'#{note.project.path}'",
|
||||||
":discussion-id" => "'#{note.discussion_id}'",
|
":discussion-id" => "'#{note.discussion_id}'",
|
||||||
|
@ -30,6 +30,7 @@
|
||||||
":resolved" => note.resolved?,
|
":resolved" => note.resolved?,
|
||||||
":can-resolve" => can?(current_user, :resolve_note, note),
|
":can-resolve" => can?(current_user, :resolve_note, note),
|
||||||
":resolved-by" => "'#{note.resolved_by.try(:name)}'",
|
":resolved-by" => "'#{note.resolved_by.try(:name)}'",
|
||||||
|
"v-show" => "#{(note.resolvable? && can?(current_user, :resolve_note, note)) || (note.resolved? && !can?(current_user, :resolve_note, note))}",
|
||||||
"inline-template" => true,
|
"inline-template" => true,
|
||||||
"v-ref:note_#{note.id}" => true }
|
"v-ref:note_#{note.id}" => true }
|
||||||
|
|
||||||
|
|
|
@ -332,11 +332,7 @@ feature 'Diff notes resolve', feature: true, js: true do
|
||||||
|
|
||||||
it 'does not allow user to mark note as resolved' do
|
it 'does not allow user to mark note as resolved' do
|
||||||
page.within '.diff-content .note' do
|
page.within '.diff-content .note' do
|
||||||
expect(page).to have_selector('.line-resolve-btn.is-disabled')
|
expect(page).not_to have_selector('.line-resolve-btn')
|
||||||
|
|
||||||
find('.line-resolve-btn').click
|
|
||||||
|
|
||||||
expect(page).to have_selector('.line-resolve-btn.is-disabled')
|
|
||||||
end
|
end
|
||||||
|
|
||||||
page.within '.line-resolve-all-container' do
|
page.within '.line-resolve-all-container' do
|
||||||
|
@ -384,11 +380,7 @@ feature 'Diff notes resolve', feature: true, js: true do
|
||||||
|
|
||||||
it 'does not allow user to mark note as resolved' do
|
it 'does not allow user to mark note as resolved' do
|
||||||
page.within '.diff-content .note' do
|
page.within '.diff-content .note' do
|
||||||
expect(page).to have_selector('.line-resolve-btn.is-disabled')
|
expect(page).not_to have_selector('.line-resolve-btn')
|
||||||
|
|
||||||
find('.line-resolve-btn').click
|
|
||||||
|
|
||||||
expect(page).to have_selector('.line-resolve-btn.is-disabled')
|
|
||||||
end
|
end
|
||||||
|
|
||||||
page.within '.line-resolve-all-container' do
|
page.within '.line-resolve-all-container' do
|
||||||
|
|
Loading…
Reference in New Issue