Fixed failing tests

This commit is contained in:
Phil Hughes 2016-07-29 11:52:08 +01:00
parent efb74875cf
commit 4e679819f2
9 changed files with 17 additions and 29 deletions

View File

@ -5,8 +5,7 @@
},
computed: {
isDiscussionResolved: function () {
const discussion = CommentsStore.state[this.discussionId],
notes = CommentsStore.notesForDiscussion(this.discussionId);
const discussion = CommentsStore.state[this.discussionId];
return discussion.isResolved();
},

View File

@ -11,8 +11,7 @@
},
data: function() {
return {
discussions: CommentsStore.state,
loadingObject: CommentsStore.loading,
discussions: CommentsStore.state
};
},
computed: {
@ -27,7 +26,7 @@
}
},
loading: function () {
return this.loadingObject[this.discussionId];
return this.discussions[this.discussionId].loading;
}
},
methods: {

View File

@ -27,7 +27,7 @@ $(() => {
const $components = $('resolve-btn, resolve-discussion-btn, jump-to-discussion');
if ($components.length) {
$components.each(function () {
DiffNotesApp.$compile($(this).get(0))
DiffNotesApp.$compile($(this).get(0));
});
}
}

View File

@ -2,6 +2,7 @@ class DiscussionModel {
constructor (discussionId) {
this.discussionId = discussionId;
this.notes = {};
this.loading = false;
}
createNote (noteId, resolved, user) {

View File

@ -34,10 +34,12 @@
}
resolveAll(namespace, mergeRequestId, discussionId) {
const discussion = CommentsStore.state[discussionId];
this.setCSRF();
Vue.http.options.root = `/${namespace}`;
CommentsStore.loading[discussionId] = true;
discussion.loading = true;
return this.discussionResource.save({
mergeRequestId,
@ -45,31 +47,28 @@
}, {}).then((response) => {
const data = response.data;
const user = data ? data.resolved_by : null;
const discussion = CommentsStore.state[discussionId];
discussion.resolveAllNotes(user);
CommentsStore.loading[discussionId] = false;
discussion.loading = false;
this.updateUpdatedHtml(discussionId, data);
});
}
unResolveAll(namespace, mergeRequestId, discussionId) {
const discussion = CommentsStore.state[discussionId];
this.setCSRF();
Vue.http.options.root = `/${namespace}`;
CommentsStore.loading[discussionId] = true;
discussion.loading = true;
return this.discussionResource.delete({
mergeRequestId,
discussionId
}, {}).then((response) => {
const data = response.data;
const discussion = CommentsStore.state[discussionId];
discussion.unResolveAllNotes();
CommentsStore.loading[discussionId] = false;
discussion.loading = false;
this.updateUpdatedHtml(discussionId, data);
});

View File

@ -1,7 +1,6 @@
((w) => {
w.CommentsStore = {
state: {},
loading: {},
get: function (discussionId, noteId) {
return this.state[discussionId].getNote(noteId);
},
@ -10,7 +9,6 @@
if (!this.state[discussionId]) {
discussion = new DiscussionModel(discussionId);
Vue.set(this.state, discussionId, discussion);
Vue.set(this.loading, discussionId, false);
}
discussion.createNote(noteId, resolved, user);
@ -27,7 +25,6 @@
if (Object.keys(discussion.notes).length === 0) {
Vue.delete(this.state, discussionId);
Vue.delete(this.loading, discussionId);
}
}
};

View File

@ -22,7 +22,7 @@
- if 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}'",
":project-path" => "'#{note.project.path}'",
":discussion-id" => "'#{note.discussion_id}'",
@ -30,6 +30,7 @@
":resolved" => note.resolved?,
":can-resolve" => can?(current_user, :resolve_note, note),
":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,
"v-ref:note_#{note.id}" => true }

View File

@ -332,11 +332,7 @@ feature 'Diff notes resolve', feature: true, js: true do
it 'does not allow user to mark note as resolved' do
page.within '.diff-content .note' do
expect(page).to have_selector('.line-resolve-btn.is-disabled')
find('.line-resolve-btn').click
expect(page).to have_selector('.line-resolve-btn.is-disabled')
expect(page).not_to have_selector('.line-resolve-btn')
end
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
page.within '.diff-content .note' do
expect(page).to have_selector('.line-resolve-btn.is-disabled')
find('.line-resolve-btn').click
expect(page).to have_selector('.line-resolve-btn.is-disabled')
expect(page).not_to have_selector('.line-resolve-btn')
end
page.within '.line-resolve-all-container' do