From 3ada1d7ec38c48f3f69c5bd2efde4a9546c71ec1 Mon Sep 17 00:00:00 2001 From: Jason Blanchard Date: Sun, 2 Mar 2014 12:29:01 -0500 Subject: [PATCH] Added option to remove issue assignee on project issue page and issue edit page --- CHANGELOG | 3 +- .../project_users_select.js.coffee | 17 ++++++- spec/features/issues_spec.rb | 47 +++++++++++++++++++ 3 files changed, 65 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index d530e063af3..ab420399263 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,6 +7,7 @@ v 6.7.0 - Piwik Integration (Sebastian Winkler) - Show contribution guide link for new issue form (Jeroen van Baarsen) - Fix CI status for merge requests from fork + - Added option to remove issue assignee on project issue page and issue edit page (Jason Blanchard) v 6.6.2 - Fix 500 error on branch/tag create or remove via UI @@ -664,4 +665,4 @@ v 0.8.0 - stability - security fixes - increased test coverage - - email notification \ No newline at end of file + - email notification diff --git a/app/assets/javascripts/project_users_select.js.coffee b/app/assets/javascripts/project_users_select.js.coffee index aa8b70d9b8a..03fad41c490 100644 --- a/app/assets/javascripts/project_users_select.js.coffee +++ b/app/assets/javascripts/project_users_select.js.coffee @@ -10,6 +10,16 @@ query: (query) -> Api.projectUsers project_id, query.term, (users) -> data = { results: users } + + nullUser = { + name: 'Unassigned', + avatar: null, + username: 'none', + id: '' + } + + data.results.unshift(nullUser) + query.callback(data) initSelection: (element, callback) -> @@ -35,8 +45,13 @@ else avatar = gon.relative_url_root + "/assets/no_avatar.png" + if user.id == '' + avatarMarkup = '' + else + avatarMarkup = "
" + "
-
+ #{avatarMarkup}
#{user.name}
#{user.username}
" diff --git a/spec/features/issues_spec.rb b/spec/features/issues_spec.rb index ffe6d02d2f2..b9dab7846b1 100644 --- a/spec/features/issues_spec.rb +++ b/spec/features/issues_spec.rb @@ -43,6 +43,31 @@ describe "Issues" do page.should have_content project.name end end + + end + + describe "Editing issue assignee" do + let!(:issue) do + create(:issue, + author: @user, + assignee: @user, + project: project) + end + + it 'allows user to select unasigned', :js => true do + visit edit_project_issue_path(project, issue) + + page.should have_content "Assign to #{@user.name}" + + page.first('#s2id_issue_assignee_id').click + sleep 2 # wait for ajax stuff to complete + page.first('.user-result').click + + click_button "Save changes" + + page.should have_content "Assignee: Select assignee" + issue.reload.assignee.should be_nil + end end describe "Filter issue" do @@ -245,6 +270,28 @@ describe "Issues" do page.should have_content milestone.title end end + + describe 'removing assignee' do + let(:user2) { create(:user) } + + before :each do + issue.assignee = user2 + issue.save + end + + it 'allows user to remove assignee', :js => true do + visit project_issue_path(project, issue) + page.should have_content "Assignee: #{user2.name}" + + page.first('#s2id_issue_assignee_id').click + sleep 2 # wait for ajax stuff to complete + page.first('.user-result').click + + page.should have_content "Assignee: Unassigned" + sleep 2 # wait for ajax stuff to complete + issue.reload.assignee.should be_nil + end + end end def first_issue