Commit 925dea21 authored by Phil Hughes's avatar Phil Hughes

Merge branch 'add-issue-board-sidebar-specs' into 'multiple_assignees_review'

Add issue board sidebar specs

See merge request !1790
parents 0f063757 141a24cc
...@@ -5,6 +5,7 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -5,6 +5,7 @@ describe 'Issue Boards', feature: true, js: true do
include WaitForVueResource include WaitForVueResource
let(:user) { create(:user) } let(:user) { create(:user) }
let(:user2) { create(:user) }
let(:project) { create(:empty_project, :public) } let(:project) { create(:empty_project, :public) }
let!(:milestone) { create(:milestone, project: project) } let!(:milestone) { create(:milestone, project: project) }
let!(:development) { create(:label, project: project, name: 'Development') } let!(:development) { create(:label, project: project, name: 'Development') }
...@@ -21,6 +22,7 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -21,6 +22,7 @@ describe 'Issue Boards', feature: true, js: true do
Timecop.freeze Timecop.freeze
project.team << [user, :master] project.team << [user, :master]
project.team.add_developer(user2)
login_as(user) login_as(user)
...@@ -102,6 +104,26 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -102,6 +104,26 @@ describe 'Issue Boards', feature: true, js: true do
expect(card).to have_selector('.avatar') expect(card).to have_selector('.avatar')
end end
it 'adds multiple assignees' do
click_card(card)
page.within('.assignee') do
click_link 'Edit'
wait_for_ajax
page.within('.dropdown-menu-user') do
click_link user.name
click_link user2.name
end
expect(page).to have_content(user.name)
expect(page).to have_content(user2.name)
end
expect(card.all('.avatar').length).to eq(2)
end
it 'removes the assignee' do it 'removes the assignee' do
card_two = first('.board').find('.card:nth-child(2)') card_two = first('.board').find('.card:nth-child(2)')
click_card(card_two) click_card(card_two)
...@@ -113,10 +135,11 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -113,10 +135,11 @@ describe 'Issue Boards', feature: true, js: true do
page.within('.dropdown-menu-user') do page.within('.dropdown-menu-user') do
click_link 'Unassigned' click_link 'Unassigned'
wait_for_vue_resource
end end
find('.dropdown-menu-toggle').click
wait_for_vue_resource
expect(page).to have_content('No assignee') expect(page).to have_content('No assignee')
end end
...@@ -129,7 +152,7 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -129,7 +152,7 @@ describe 'Issue Boards', feature: true, js: true do
page.within(find('.assignee')) do page.within(find('.assignee')) do
expect(page).to have_content('No assignee') expect(page).to have_content('No assignee')
click_link 'assign yourself' click_button 'assign yourself'
wait_for_vue_resource wait_for_vue_resource
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
/* global BoardService */ /* global BoardService */
/* global ListIssue */ /* global ListIssue */
import Vue from 'vue';
import '~/lib/utils/url_utility'; import '~/lib/utils/url_utility';
import '~/boards/models/issue'; import '~/boards/models/issue';
import '~/boards/models/label'; import '~/boards/models/label';
...@@ -28,7 +29,12 @@ describe('Issue model', () => { ...@@ -28,7 +29,12 @@ describe('Issue model', () => {
color: 'red', color: 'red',
description: 'testing' description: 'testing'
}], }],
assignees: [], assignees: [{
id: 1,
name: 'name',
username: 'username',
avatar_url: 'http://avatar_url',
}],
}); });
}); });
...@@ -81,6 +87,33 @@ describe('Issue model', () => { ...@@ -81,6 +87,33 @@ describe('Issue model', () => {
expect(issue.labels.length).toBe(0); expect(issue.labels.length).toBe(0);
}); });
it('adds assignee', () => {
issue.addAssignee({
id: 2,
name: 'Bruce Wayne',
username: 'batman',
avatar_url: 'http://batman',
});
expect(issue.assignees.length).toBe(2);
});
it('finds assignee', () => {
const assignee = issue.findAssignee(issue.assignees[0]);
expect(assignee).toBeDefined();
});
it('removes assignee', () => {
const assignee = issue.findAssignee(issue.assignees[0]);
issue.removeAssignee(assignee);
expect(issue.assignees.length).toBe(0);
});
it('removes all assignees', () => {
issue.removeAllAssignees();
expect(issue.assignees.length).toBe(0);
});
it('sets position to infinity if no position is stored', () => { it('sets position to infinity if no position is stored', () => {
expect(issue.position).toBe(Infinity); expect(issue.position).toBe(Infinity);
}); });
...@@ -97,4 +130,25 @@ describe('Issue model', () => { ...@@ -97,4 +130,25 @@ describe('Issue model', () => {
expect(relativePositionIssue.position).toBe(1); expect(relativePositionIssue.position).toBe(1);
}); });
describe('update', () => {
it('passes assignee ids when there are assignees', (done) => {
spyOn(Vue.http, 'patch').and.callFake((url, data) => {
expect(data.issue.assignee_ids).toEqual([1]);
done();
});
issue.update('url');
});
it('passes assignee ids of [0] when there are no assignees', (done) => {
spyOn(Vue.http, 'patch').and.callFake((url, data) => {
expect(data.issue.assignee_ids).toEqual([0]);
done();
});
issue.removeAllAssignees();
issue.update('url');
});
});
}); });
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