Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

[#51679] Can not add invited users to existing groups

Pavel Balashoufaa1bc18a024
diff --git a/app/views/groups/_users.html.erb b/app/views/groups/_users.html.erb
index 0156d6421ac..32fd094c0e8 100644
--- a/app/views/groups/_users.html.erb
+++ b/app/views/groups/_users.html.erb
@@ -42,12 +42,10 @@ See COPYRIGHT and LICENSE files for more details.
</div>
<div class="grid-content medium-6 -visible-overflow">
- <% users = User
- .user
- .active
- .not_in_group(@group)
- .limit(1) %>
- <% if users.any? %>
+ <% if User.user
+ .not_in_group(@group)
+ .where(status: [User.statuses[:active], User.statuses[:invited]])
+ .exists? %>
<%= styled_form_tag(members_of_group_path(@group), method: :post) do %>
<fieldset class="form--fieldset">
diff --git a/spec/features/groups/group_memberships_spec.rb b/spec/features/groups/group_memberships_spec.rb
index 6044195abe7..d86ac755239 100644
--- a/spec/features/groups/group_memberships_spec.rb
+++ b/spec/features/groups/group_memberships_spec.rb
@@ -66,6 +66,24 @@ RSpec.describe 'group memberships through groups page', :js, :with_cuprite do
expect(members_page).to have_user 'Hannibal Smith', roles: ['Manager']
end
+ context 'when there are only invited users not in the group' do
+ let!(:peter) { create(:invited_user, firstname: 'Peter', lastname: 'Pan') }
+ let!(:hannibal) { create(:invited_user, firstname: 'Hannibal', lastname: 'Smith') }
+ let(:group_members) { [admin] }
+
+ it 'is possible to add an invited user' do
+ visit "/admin/groups/#{group.id}/edit?tab=users"
+
+ # autocomplete section has been rendered
+ expect(page).to have_text('NEW USER')
+ expect(page).to have_text('Add')
+
+ group_page.add_user! 'Hannibal'
+ expect(page).to have_text 'Successful update'
+ expect(page).to have_text('Hannibal Smith')
+ end
+ end
+
context 'given a group with members in a project' do
let(:group_members) { [peter, hannibal] }
let(:project_members) { { group => [manager] } }