From 8490a8ab2a70828e4bb5587c7cc07c750483ef2e Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 25 Feb 2015 04:20:17 -0500 Subject: Rename bulk_update_context_spec to bulk_update_service_spec --- spec/services/issues/bulk_update_context_spec.rb | 110 ----------------------- spec/services/issues/bulk_update_service_spec.rb | 110 +++++++++++++++++++++++ 2 files changed, 110 insertions(+), 110 deletions(-) delete mode 100644 spec/services/issues/bulk_update_context_spec.rb create mode 100644 spec/services/issues/bulk_update_service_spec.rb diff --git a/spec/services/issues/bulk_update_context_spec.rb b/spec/services/issues/bulk_update_context_spec.rb deleted file mode 100644 index eb867f78c5c..00000000000 --- a/spec/services/issues/bulk_update_context_spec.rb +++ /dev/null @@ -1,110 +0,0 @@ -require 'spec_helper' - -describe Issues::BulkUpdateService do - let(:issue) { - create(:issue, project: @project) - } - - before do - @user = create :user - opts = { - name: "GitLab", - namespace: @user.namespace - } - @project = Projects::CreateService.new(@user, opts).execute - end - - describe :close_issue do - - before do - @issues = 5.times.collect do - create(:issue, project: @project) - end - @params = { - update: { - status: 'closed', - issues_ids: @issues.map(&:id) - } - } - end - - it { - result = Issues::BulkUpdateService.new(@project, @user, @params).execute - expect(result[:success]).to be_truthy - expect(result[:count]).to eq(@issues.count) - - expect(@project.issues.opened).to be_empty - expect(@project.issues.closed).not_to be_empty - } - - end - - describe :reopen_issues do - - before do - @issues = 5.times.collect do - create(:closed_issue, project: @project) - end - @params = { - update: { - status: 'reopen', - issues_ids: @issues.map(&:id) - } - } - end - - it { - result = Issues::BulkUpdateService.new(@project, @user, @params).execute - expect(result[:success]).to be_truthy - expect(result[:count]).to eq(@issues.count) - - expect(@project.issues.closed).to be_empty - expect(@project.issues.opened).not_to be_empty - } - - end - - describe :update_assignee do - - before do - @new_assignee = create :user - @params = { - update: { - issues_ids: [issue.id], - assignee_id: @new_assignee.id - } - } - end - - it { - result = Issues::BulkUpdateService.new(@project, @user, @params).execute - expect(result[:success]).to be_truthy - expect(result[:count]).to eq(1) - - expect(@project.issues.first.assignee).to eq(@new_assignee) - } - - end - - describe :update_milestone do - - before do - @milestone = create :milestone - @params = { - update: { - issues_ids: [issue.id], - milestone_id: @milestone.id - } - } - end - - it { - result = Issues::BulkUpdateService.new(@project, @user, @params).execute - expect(result[:success]).to be_truthy - expect(result[:count]).to eq(1) - - expect(@project.issues.first.milestone).to eq(@milestone) - } - end - -end diff --git a/spec/services/issues/bulk_update_service_spec.rb b/spec/services/issues/bulk_update_service_spec.rb new file mode 100644 index 00000000000..eb867f78c5c --- /dev/null +++ b/spec/services/issues/bulk_update_service_spec.rb @@ -0,0 +1,110 @@ +require 'spec_helper' + +describe Issues::BulkUpdateService do + let(:issue) { + create(:issue, project: @project) + } + + before do + @user = create :user + opts = { + name: "GitLab", + namespace: @user.namespace + } + @project = Projects::CreateService.new(@user, opts).execute + end + + describe :close_issue do + + before do + @issues = 5.times.collect do + create(:issue, project: @project) + end + @params = { + update: { + status: 'closed', + issues_ids: @issues.map(&:id) + } + } + end + + it { + result = Issues::BulkUpdateService.new(@project, @user, @params).execute + expect(result[:success]).to be_truthy + expect(result[:count]).to eq(@issues.count) + + expect(@project.issues.opened).to be_empty + expect(@project.issues.closed).not_to be_empty + } + + end + + describe :reopen_issues do + + before do + @issues = 5.times.collect do + create(:closed_issue, project: @project) + end + @params = { + update: { + status: 'reopen', + issues_ids: @issues.map(&:id) + } + } + end + + it { + result = Issues::BulkUpdateService.new(@project, @user, @params).execute + expect(result[:success]).to be_truthy + expect(result[:count]).to eq(@issues.count) + + expect(@project.issues.closed).to be_empty + expect(@project.issues.opened).not_to be_empty + } + + end + + describe :update_assignee do + + before do + @new_assignee = create :user + @params = { + update: { + issues_ids: [issue.id], + assignee_id: @new_assignee.id + } + } + end + + it { + result = Issues::BulkUpdateService.new(@project, @user, @params).execute + expect(result[:success]).to be_truthy + expect(result[:count]).to eq(1) + + expect(@project.issues.first.assignee).to eq(@new_assignee) + } + + end + + describe :update_milestone do + + before do + @milestone = create :milestone + @params = { + update: { + issues_ids: [issue.id], + milestone_id: @milestone.id + } + } + end + + it { + result = Issues::BulkUpdateService.new(@project, @user, @params).execute + expect(result[:success]).to be_truthy + expect(result[:count]).to eq(1) + + expect(@project.issues.first.milestone).to eq(@milestone) + } + end + +end -- cgit v1.2.1 From e53dd7526f69545ca86fc6935ad8077592628772 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 25 Feb 2015 04:29:33 -0500 Subject: Allow mass-unassigning of issues Fixes #867 [ci skip] --- CHANGELOG | 1 + app/assets/javascripts/project_users_select.js.coffee | 2 +- spec/services/issues/bulk_update_service_spec.rb | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index d5b05125110..3f9af5b9f9f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -11,6 +11,7 @@ v 7.9.0 (unreleased) - Fix ordering of imported but unchanged projects (Marco Wessel) - Mobile UI improvements: make aside content expandable - Generalize image upload in drag and drop in markdown to all files (Hannes Rosenögger) + - Fix mass-unassignment of issues (Robert Speicher) v 7.8.1 - Fix run of custom post receive hooks diff --git a/app/assets/javascripts/project_users_select.js.coffee b/app/assets/javascripts/project_users_select.js.coffee index 7fb33926096..885f0d58a6a 100644 --- a/app/assets/javascripts/project_users_select.js.coffee +++ b/app/assets/javascripts/project_users_select.js.coffee @@ -15,7 +15,7 @@ class @ProjectUsersSelect name: 'Unassigned', avatar: null, username: 'none', - id: '' + id: -1 } data.results.unshift(nullUser) diff --git a/spec/services/issues/bulk_update_service_spec.rb b/spec/services/issues/bulk_update_service_spec.rb index eb867f78c5c..504213e667f 100644 --- a/spec/services/issues/bulk_update_service_spec.rb +++ b/spec/services/issues/bulk_update_service_spec.rb @@ -84,6 +84,25 @@ describe Issues::BulkUpdateService do expect(@project.issues.first.assignee).to eq(@new_assignee) } + it 'allows mass-unassigning' do + @project.issues.first.update_attribute(:assignee, @new_assignee) + expect(@project.issues.first.assignee).not_to be_nil + + @params[:update][:assignee_id] = -1 + + Issues::BulkUpdateService.new(@project, @user, @params).execute + expect(@project.issues.first.assignee).to be_nil + end + + it 'does not unassign when assignee_id is not present' do + @project.issues.first.update_attribute(:assignee, @new_assignee) + expect(@project.issues.first.assignee).not_to be_nil + + @params[:update][:assignee_id] = '' + + Issues::BulkUpdateService.new(@project, @user, @params).execute + expect(@project.issues.first.assignee).not_to be_nil + end end describe :update_milestone do -- cgit v1.2.1