Commit 73987067 authored by Eugenia Grieff's avatar Eugenia Grieff

Add feature specs for group level

Include feature specs for bulk editing
health status at a group level
parent e336d8d2
- type = local_assigns.fetch(:type) - type = local_assigns.fetch(:type)
- bulk_issue_health_status_flag = Feature.enabled?(:bulk_update_health_status) && type == :issues && @project&.group&.feature_available?(:issuable_health_status) - bulk_issue_health_status_flag = Feature.enabled?(:bulk_update_health_status, @project&.group) && type == :issues && @project&.group&.feature_available?(:issuable_health_status)
%aside.issues-bulk-update.js-right-sidebar.right-sidebar{ "aria-live" => "polite", data: { 'signed-in': current_user.present? } } %aside.issues-bulk-update.js-right-sidebar.right-sidebar{ "aria-live" => "polite", data: { 'signed-in': current_user.present? } }
.issuable-sidebar.hidden .issuable-sidebar.hidden
......
- group = local_assigns.fetch(:group) - group = local_assigns.fetch(:group)
- type = local_assigns.fetch(:type) - type = local_assigns.fetch(:type)
- bulk_issue_health_status_flag = Feature.enabled?(:bulk_update_health_status) && type == :issues && @project&.group&.feature_available?(:issuable_health_status) - bulk_issue_health_status_flag = type == :issues && Feature.enabled?(:bulk_update_health_status, group) && group&.feature_available?(:issuable_health_status)
%aside.issues-bulk-update.js-right-sidebar.right-sidebar{ 'aria-live' => 'polite', data: { 'signed-in': current_user.present? } } %aside.issues-bulk-update.js-right-sidebar.right-sidebar{ 'aria-live' => 'polite', data: { 'signed-in': current_user.present? } }
.issuable-sidebar.hidden .issuable-sidebar.hidden
......
...@@ -2,84 +2,110 @@ ...@@ -2,84 +2,110 @@
require 'spec_helper' require 'spec_helper'
describe 'Issues > Health status bulk assignment' do RSpec.describe 'Issues > Health status bulk assignment' do
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
let_it_be(:group) { create(:group, :public) } let_it_be(:group) { create(:group, :public) }
let_it_be(:project) { create(:project, :public, group: group) } let_it_be(:project) { create(:project, :public, group: group) }
let_it_be(:issue1) { create(:issue, project: project, title: "Issue 1") } let_it_be(:issue1) { create(:issue, project: project, title: "Issue 1") }
let_it_be(:issue2) { create(:issue, project: project, title: "Issue 2") } let_it_be(:issue2) { create(:issue, project: project, title: "Issue 2") }
shared_examples 'bulk edit option in sidebar' do |context|
it 'is present when bulk edit is enabled' do
enable_bulk_update(context)
expect(page).to have_css('.issuable-sidebar')
end
it 'is not present when bulk edit is disabled' do
expect(page).not_to have_css('.issuable-sidebar')
end
end
shared_examples 'bulk edit health status' do |context|
before do
enable_bulk_update(context)
end
context 'health_status', :js do
context 'to all issues' do
before do
check 'check-all-issues'
open_health_status_dropdown ['On track']
update_issues
end
it 'updates the health statuses' do
expect(issue1.reload.health_status).to eq 'on_track'
expect(issue2.reload.health_status).to eq 'on_track'
end
end
context 'to an issue' do
before do
check "selected_issue_#{issue1.id}"
open_health_status_dropdown ['At risk']
update_issues
end
it 'updates the checked issue\'s status' do
expect(issue1.reload.health_status).to eq 'at_risk'
expect(issue2.reload.health_status).to eq nil
end
end
end
end
shared_examples 'bulk edit health_status with insufficient permissions' do
it 'cannot bulk assign health_status' do
expect(page).not_to have_button 'Edit issues'
expect(page).not_to have_css '.check-all-issues'
expect(page).not_to have_css '.issue-check'
end
end
context 'as an allowed user', :js do context 'as an allowed user', :js do
before do before do
allow(group).to receive(:feature_enabled?).and_return(true) allow(group).to receive(:feature_enabled?).and_return(true)
stub_licensed_features(issuable_health_status: true) stub_licensed_features(group_bulk_edit: true, issuable_health_status: true)
group.add_maintainer(user) group.add_maintainer(user)
sign_in user sign_in user
end end
context 'sidebar' do context 'at group level' do
it 'is present when bulk edit is enabled' do it_behaves_like 'bulk edit option in sidebar', :group
enable_bulk_update it_behaves_like 'bulk edit health status', :group
expect(page).to have_css('.issuable-sidebar')
end
it 'is not present when bulk edit is disabled' do
expect(page).not_to have_css('.issuable-sidebar')
end
end end
context 'can bulk assign' do context 'at project level' do
before do it_behaves_like 'bulk edit option in sidebar', :project
enable_bulk_update it_behaves_like 'bulk edit health status', :project
end
context 'health_status' do
context 'to all issues' do
before do
check 'check-all-issues'
open_health_status_dropdown ['On track']
update_issues
end
it 'updates the health statuses' do
expect(issue1.reload.health_status).to eq 'on_track'
expect(issue2.reload.health_status).to eq 'on_track'
end
end
context 'to a issue' do
before do
check "selected_issue_#{issue1.id}"
open_health_status_dropdown ['At risk']
update_issues
end
it 'updates the checked issue\'s status' do
expect(issue1.reload.health_status).to eq 'at_risk'
expect(issue2.reload.health_status).to eq nil
end
end
end
end end
end end
context 'as a guest' do context 'as a guest', :js do
before do before do
sign_in user sign_in user
allow(group).to receive(:feature_enabled?).and_return(true) allow(group).to receive(:feature_enabled?).and_return(true)
stub_licensed_features(issuable_health_status: true) stub_licensed_features(issuable_health_status: true)
end
visit project_issues_path(project) context 'at group level' do
before do
visit issues_group_path(group)
end
it_behaves_like 'bulk edit health_status with insufficient permissions'
end end
it 'cannot bulk assign health_status' do context 'at project level' do
expect(page).not_to have_button 'Edit issues' before do
expect(page).not_to have_css '.check-all-issues' visit project_issues_path(project)
expect(page).not_to have_css '.issue-check' end
it_behaves_like 'bulk edit health_status with insufficient permissions'
end end
end end
...@@ -111,8 +137,13 @@ describe 'Issues > Health status bulk assignment' do ...@@ -111,8 +137,13 @@ describe 'Issues > Health status bulk assignment' do
wait_for_requests wait_for_requests
end end
def enable_bulk_update def enable_bulk_update(context)
visit project_issues_path(project) if context == :project
visit project_issues_path(project)
else
visit issues_group_path(group)
end
click_button 'Edit issues' click_button 'Edit issues'
end end
end end
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