Commit 33381463920369a5915bfda25ee148a84b64285a
Committed by
Dmitriy Zaporozhets
1 parent
b1021806
Added option to remove issue assignee on project issue page and issue edit page
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> Conflicts: CHANGELOG
Showing
3 changed files
with
66 additions
and
1 deletions
Show diff stats
CHANGELOG
app/assets/javascripts/project_users_select.js.coffee
| @@ -10,6 +10,16 @@ | @@ -10,6 +10,16 @@ | ||
| 10 | query: (query) -> | 10 | query: (query) -> |
| 11 | Api.projectUsers project_id, query.term, (users) -> | 11 | Api.projectUsers project_id, query.term, (users) -> |
| 12 | data = { results: users } | 12 | data = { results: users } |
| 13 | + | ||
| 14 | + nullUser = { | ||
| 15 | + name: 'Unassigned', | ||
| 16 | + avatar: null, | ||
| 17 | + username: 'none', | ||
| 18 | + id: '' | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + data.results.unshift(nullUser) | ||
| 22 | + | ||
| 13 | query.callback(data) | 23 | query.callback(data) |
| 14 | 24 | ||
| 15 | initSelection: (element, callback) -> | 25 | initSelection: (element, callback) -> |
| @@ -35,8 +45,13 @@ | @@ -35,8 +45,13 @@ | ||
| 35 | else | 45 | else |
| 36 | avatar = gon.relative_url_root + "/assets/no_avatar.png" | 46 | avatar = gon.relative_url_root + "/assets/no_avatar.png" |
| 37 | 47 | ||
| 48 | + if user.id == '' | ||
| 49 | + avatarMarkup = '' | ||
| 50 | + else | ||
| 51 | + avatarMarkup = "<div class='user-image'><img class='avatar s24' src='#{avatar}'></div>" | ||
| 52 | + | ||
| 38 | "<div class='user-result'> | 53 | "<div class='user-result'> |
| 39 | - <div class='user-image'><img class='avatar s24' src='#{avatar}'></div> | 54 | + #{avatarMarkup} |
| 40 | <div class='user-name'>#{user.name}</div> | 55 | <div class='user-name'>#{user.name}</div> |
| 41 | <div class='user-username'>#{user.username}</div> | 56 | <div class='user-username'>#{user.username}</div> |
| 42 | </div>" | 57 | </div>" |
spec/features/issues_spec.rb
| @@ -43,6 +43,31 @@ describe "Issues" do | @@ -43,6 +43,31 @@ describe "Issues" do | ||
| 43 | page.should have_content project.name | 43 | page.should have_content project.name |
| 44 | end | 44 | end |
| 45 | end | 45 | end |
| 46 | + | ||
| 47 | + end | ||
| 48 | + | ||
| 49 | + describe "Editing issue assignee" do | ||
| 50 | + let!(:issue) do | ||
| 51 | + create(:issue, | ||
| 52 | + author: @user, | ||
| 53 | + assignee: @user, | ||
| 54 | + project: project) | ||
| 55 | + end | ||
| 56 | + | ||
| 57 | + it 'allows user to select unasigned', :js => true do | ||
| 58 | + visit edit_project_issue_path(project, issue) | ||
| 59 | + | ||
| 60 | + page.should have_content "Assign to #{@user.name}" | ||
| 61 | + | ||
| 62 | + page.first('#s2id_issue_assignee_id').click | ||
| 63 | + sleep 2 # wait for ajax stuff to complete | ||
| 64 | + page.first('.user-result').click | ||
| 65 | + | ||
| 66 | + click_button "Save changes" | ||
| 67 | + | ||
| 68 | + page.should have_content "Assignee: Select assignee" | ||
| 69 | + issue.reload.assignee.should be_nil | ||
| 70 | + end | ||
| 46 | end | 71 | end |
| 47 | 72 | ||
| 48 | describe "Filter issue" do | 73 | describe "Filter issue" do |
| @@ -245,6 +270,28 @@ describe "Issues" do | @@ -245,6 +270,28 @@ describe "Issues" do | ||
| 245 | page.should have_content milestone.title | 270 | page.should have_content milestone.title |
| 246 | end | 271 | end |
| 247 | end | 272 | end |
| 273 | + | ||
| 274 | + describe 'removing assignee' do | ||
| 275 | + let(:user2) { create(:user) } | ||
| 276 | + | ||
| 277 | + before :each do | ||
| 278 | + issue.assignee = user2 | ||
| 279 | + issue.save | ||
| 280 | + end | ||
| 281 | + | ||
| 282 | + it 'allows user to remove assignee', :js => true do | ||
| 283 | + visit project_issue_path(project, issue) | ||
| 284 | + page.should have_content "Assignee: #{user2.name}" | ||
| 285 | + | ||
| 286 | + page.first('#s2id_issue_assignee_id').click | ||
| 287 | + sleep 2 # wait for ajax stuff to complete | ||
| 288 | + page.first('.user-result').click | ||
| 289 | + | ||
| 290 | + page.should have_content "Assignee: Unassigned" | ||
| 291 | + sleep 2 # wait for ajax stuff to complete | ||
| 292 | + issue.reload.assignee.should be_nil | ||
| 293 | + end | ||
| 294 | + end | ||
| 248 | end | 295 | end |
| 249 | 296 | ||
| 250 | def first_issue | 297 | def first_issue |