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)
- 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? } }
.issuable-sidebar.hidden
......
- group = local_assigns.fetch(:group)
- 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? } }
.issuable-sidebar.hidden
......
......@@ -2,84 +2,110 @@
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(:group) { create(:group, :public) }
let_it_be(:project) { create(:project, :public, group: group) }
let_it_be(:issue1) { create(:issue, project: project, title: "Issue 1") }
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
before do
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)
sign_in user
end
context 'sidebar' do
it 'is present when bulk edit is enabled' do
enable_bulk_update
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
context 'at group level' do
it_behaves_like 'bulk edit option in sidebar', :group
it_behaves_like 'bulk edit health status', :group
end
context 'can bulk assign' do
before do
enable_bulk_update
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
context 'at project level' do
it_behaves_like 'bulk edit option in sidebar', :project
it_behaves_like 'bulk edit health status', :project
end
end
context 'as a guest' do
context 'as a guest', :js do
before do
sign_in user
allow(group).to receive(:feature_enabled?).and_return(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
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'
context 'at project level' do
before do
visit project_issues_path(project)
end
it_behaves_like 'bulk edit health_status with insufficient permissions'
end
end
......@@ -111,8 +137,13 @@ describe 'Issues > Health status bulk assignment' do
wait_for_requests
end
def enable_bulk_update
visit project_issues_path(project)
def enable_bulk_update(context)
if context == :project
visit project_issues_path(project)
else
visit issues_group_path(group)
end
click_button 'Edit issues'
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