summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlfredo Sumaran <alfredo@gitlab.com>2016-05-06 15:58:21 -0500
committerAlfredo Sumaran <alfredo@gitlab.com>2016-06-03 17:14:23 -0500
commitd84f1180d8687c694f64f76a5a91a3dae7d178bf (patch)
treec29639ecf8f69121c2f0de9b72919095513cf6f2
parentdbf9df1dd2719acaa0c540efdc37502297f34a92 (diff)
downloadgitlab-ce-d84f1180d8687c694f64f76a5a91a3dae7d178bf.tar.gz
Bulk assignment tests
-rw-r--r--spec/features/issues/bulk_assigment_labels_spec.rb158
1 files changed, 120 insertions, 38 deletions
diff --git a/spec/features/issues/bulk_assigment_labels_spec.rb b/spec/features/issues/bulk_assigment_labels_spec.rb
index b99729ffd09..df080a4c661 100644
--- a/spec/features/issues/bulk_assigment_labels_spec.rb
+++ b/spec/features/issues/bulk_assigment_labels_spec.rb
@@ -3,80 +3,147 @@ require 'rails_helper'
feature 'Issues > Labels bulk assignment', feature: true do
include WaitForAjax
- let(:user) { create(:user) }
- let!(:project) { create(:project) }
- let!(:issue1) { create(:issue, project: project, title: "Issue 1") }
- let!(:issue2) { create(:issue, project: project, title: "Issue 2") }
-
- before do
- create(:label, project: project, title: 'bug')
- create(:label, project: project, title: 'feature')
- end
+ let(:user) { create(:user) }
+ let!(:project) { create(:project) }
+ let!(:issue1) { create(:issue, project: project, title: "Issue 1") }
+ let!(:issue2) { create(:issue, project: project, title: "Issue 2") }
+ let!(:bug) { create(:label, project: project, title: 'bug') }
+ let!(:feature) { create(:label, project: project, title: 'feature') }
context 'as a allowed user', js: true do
before do
project.team << [user, :master]
- login_as user
- visit namespace_project_issues_path(project.namespace, project)
+ login_as user
end
- context 'can bulk assign a label' do
- context 'to all issues' do
- before do
- check 'check_all_issues'
- open_labels_dropdown ['bug']
- click_button 'Update issues'
+ context 'can bulk assign' do
+ before do
+ visit namespace_project_issues_path(project.namespace, project)
+ end
+
+ context 'a label' do
+ context 'to all issues' do
+ before do
+ check 'check_all_issues'
+ open_labels_dropdown ['bug']
+ click_button 'Update issues'
+ end
+
+ it do
+ expect(find("#issue_#{issue1.id}")).to have_content 'bug'
+ expect(find("#issue_#{issue2.id}")).to have_content 'bug'
+ end
end
- it do
- expect(find("#issue_#{issue1.id}")).to have_content 'bug'
- expect(find("#issue_#{issue2.id}")).to have_content 'bug'
+ context 'to a issue' do
+ before do
+ check "selected_issue_#{issue1.id}"
+ open_labels_dropdown ['bug']
+ click_button 'Update issues'
+ end
+
+ it do
+ expect(find("#issue_#{issue1.id}")).to have_content 'bug'
+ expect(find("#issue_#{issue2.id}")).not_to have_content 'bug'
+ end
end
end
- context 'to a issue' do
+ context 'multiple labels' do
+ context 'to all issues' do
+ before do
+ check 'check_all_issues'
+ open_labels_dropdown ['bug', 'feature']
+ click_button 'Update issues'
+ end
+
+ it do
+ expect(find("#issue_#{issue1.id}")).to have_content 'bug'
+ expect(find("#issue_#{issue1.id}")).to have_content 'feature'
+ expect(find("#issue_#{issue2.id}")).to have_content 'bug'
+ expect(find("#issue_#{issue2.id}")).to have_content 'feature'
+ end
+ end
+
+ context 'to a issue' do
+ before do
+ check "selected_issue_#{issue1.id}"
+ open_labels_dropdown ['bug', 'feature']
+ click_button 'Update issues'
+ end
+
+ it do
+ expect(find("#issue_#{issue1.id}")).to have_content 'bug'
+ expect(find("#issue_#{issue1.id}")).to have_content 'feature'
+ expect(find("#issue_#{issue2.id}")).not_to have_content 'bug'
+ expect(find("#issue_#{issue2.id}")).not_to have_content 'feature'
+ end
+ end
+ end
+ end
+
+ context 'can bulk un-assign' do
+ context 'all labels to all issues' do
before do
- check "selected_issue_#{issue1.id}"
- open_labels_dropdown ['bug']
+ issue1.labels << bug
+ issue1.labels << feature
+ issue2.labels << bug
+ issue2.labels << feature
+
+ visit namespace_project_issues_path(project.namespace, project)
+
+ check 'check_all_issues'
+ unmark_labels_in_dropdown ['bug', 'feature']
click_button 'Update issues'
end
it do
- expect(find("#issue_#{issue1.id}")).to have_content 'bug'
+ expect(find("#issue_#{issue1.id}")).not_to have_content 'bug'
+ expect(find("#issue_#{issue1.id}")).not_to have_content 'feature'
expect(find("#issue_#{issue2.id}")).not_to have_content 'bug'
+ expect(find("#issue_#{issue2.id}")).not_to have_content 'feature'
end
end
- end
- context 'can bulk assign multiple labels' do
- context 'to all issues' do
+ context 'a label to a issue' do
before do
- check 'check_all_issues'
- open_labels_dropdown ['bug', 'feature']
+ issue1.labels << bug
+ issue2.labels << feature
+
+ visit namespace_project_issues_path(project.namespace, project)
+
+ check_issue issue1
+ unmark_labels_in_dropdown ['bug']
click_button 'Update issues'
end
it do
- expect(find("#issue_#{issue1.id}")).to have_content 'bug'
- expect(find("#issue_#{issue1.id}")).to have_content 'feature'
- expect(find("#issue_#{issue2.id}")).to have_content 'bug'
+ expect(find("#issue_#{issue1.id}")).not_to have_content 'bug'
expect(find("#issue_#{issue2.id}")).to have_content 'feature'
end
end
- context 'to a issue' do
+ context 'a label and keep the others label' do
before do
- check "selected_issue_#{issue1.id}"
- open_labels_dropdown ['bug', 'feature']
+ issue1.labels << bug
+ issue1.labels << feature
+ issue2.labels << bug
+ issue2.labels << feature
+
+ visit namespace_project_issues_path(project.namespace, project)
+
+ check_issue issue1
+ check_issue issue2
+ unmark_labels_in_dropdown ['bug']
click_button 'Update issues'
end
it do
- expect(find("#issue_#{issue1.id}")).to have_content 'bug'
+ expect(find("#issue_#{issue1.id}")).not_to have_content 'bug'
expect(find("#issue_#{issue1.id}")).to have_content 'feature'
expect(find("#issue_#{issue2.id}")).not_to have_content 'bug'
- expect(find("#issue_#{issue2.id}")).not_to have_content 'feature'
+ expect(find("#issue_#{issue2.id}")).to have_content 'feature'
end
end
end
@@ -97,13 +164,28 @@ feature 'Issues > Labels bulk assignment', feature: true do
end
end
- def open_labels_dropdown(items = [])
+ def open_labels_dropdown(items = [], unmark = false)
page.within('.issues_bulk_update') do
click_button 'Label'
wait_for_ajax
items.map do |item|
click_link item
end
+ if unmark
+ items.map do |item|
+ click_link item
+ end
+ end
+ end
+ end
+
+ def unmark_labels_in_dropdown(items = [])
+ open_labels_dropdown(items, true)
+ end
+
+ def check_issue(issue)
+ page.within('.issues-list') do
+ check "selected_issue_#{issue.id}"
end
end
end