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

Escape App title in Email and extend test cases

Henriette Darge79ba82823c80
diff --git a/app/views/sharing_mailer/shared_work_package.html.erb b/app/views/sharing_mailer/shared_work_package.html.erb
index 82d5aec8679..066b0a49352 100644
--- a/app/views/sharing_mailer/shared_work_package.html.erb
+++ b/app/views/sharing_mailer/shared_work_package.html.erb
@@ -55,7 +55,7 @@
</tr>
<tr>
<td style="color: #333333;font-size: 16px;">
- <%= t('mail.sharing.work_packages.create_account', instance: Setting.app_title).html_safe %>
+ <%= t('mail.sharing.work_packages.create_account', instance: Setting.app_title) %>
</td>
</tr>
</table>
diff --git a/lib/primer/open_project/forms/user_autocompleter.html.erb b/lib/primer/open_project/forms/user_autocompleter.html.erb
index 07cbf0fa93d..ad8c7003a2d 100644
--- a/lib/primer/open_project/forms/user_autocompleter.html.erb
+++ b/lib/primer/open_project/forms/user_autocompleter.html.erb
@@ -1,6 +1,6 @@
<%= render(FormControl.new(input: @input)) do %>
<%= angular_component_tag 'opce-user-autocompleter',
- data: @autocomplete_options.delete(:data) { {} },
+ data: @data_attributes,
inputs: @autocomplete_options.merge(
classes: "ng-select--primerized #{@input.invalid? ? '-error' : ''}",
inputName: builder.field_name(@input.name),
diff --git a/lib/primer/open_project/forms/user_autocompleter.rb b/lib/primer/open_project/forms/user_autocompleter.rb
index 58c195fc215..e03a85889a0 100644
--- a/lib/primer/open_project/forms/user_autocompleter.rb
+++ b/lib/primer/open_project/forms/user_autocompleter.rb
@@ -12,6 +12,7 @@ module Primer
def initialize(input:, autocomplete_options:)
super()
@input = input
+ @data_attributes = autocomplete_options.delete(:data) { {} }
@autocomplete_options = autocomplete_options
end
end
diff --git a/spec/features/work_packages/share_spec.rb b/spec/features/work_packages/share_spec.rb
index 05188bf7b0f..1988654ccf8 100644
--- a/spec/features/work_packages/share_spec.rb
+++ b/spec/features/work_packages/share_spec.rb
@@ -284,8 +284,8 @@ RSpec.describe 'Work package sharing',
end
context 'when having global invite permission' do
- shared_let(:global_manage_user) { create(:user, global_permissions: %i[manage_user create_user]) }
- let(:current_user) { global_manage_user }
+ let(:global_manager_user) { create(:user, global_permissions: %i[manage_user create_user]) }
+ let(:current_user) { global_manager_user }
it 'allows inviting and directly sharing with a user who is not part of the instance yet' do
work_package_page.visit!
@@ -294,23 +294,38 @@ RSpec.describe 'Work package sharing',
share_modal.expect_open
share_modal.expect_shared_count_of(6)
+ # Invite a user that does not exist yet
share_modal.create_and_invite_user('[email protected]', 'View')
+ # New user is shown in the list of shares
share_modal.expect_shared_count_of(7)
+ # New user is created
new_user = User.last
share_modal.expect_shared_with(new_user, 'View', position: 1)
perform_enqueued_jobs
# Only one combined email for create and share should be send out
expect(ActionMailer::Base.deliveries.size).to eq(1)
+
+ # The new user can be interacted with
+ share_modal.change_role(new_user, 'Comment')
+ share_modal.expect_shared_with(new_user, 'Comment', position: 1)
+ share_modal.expect_shared_count_of(7)
+
+ # The new user can be updated
+ share_modal.invite_user(new_user, 'Edit')
+ share_modal.expect_shared_with(new_user, 'Edit', position: 1)
+ share_modal.expect_shared_count_of(7)
+
+ # The new user can be deleted
+ share_modal.remove_user(new_user)
+ share_modal.expect_not_shared_with(new_user)
+ share_modal.expect_shared_count_of(6)
end
end
context 'when lacking global invite permission' do
- shared_let(:global_manage_user) { create(:user, global_permissions: %i[]) }
- let(:current_user) { global_manage_user }
-
it 'does not allow creating a user who is not part of the instance yet' do
work_package_page.visit!
click_button 'Share'
@@ -318,9 +333,11 @@ RSpec.describe 'Work package sharing',
share_modal.expect_open
share_modal.expect_shared_count_of(6)
+ # Search for a user that does not exist
share_modal.search_user('[email protected]')
- share_modal.expect_no_ng_option("", "Send invite to\"[email protected]\"", results_selector: "body")
+ # There is no option to directly create and share the WP for the unknown email address
+ share_modal.expect_no_ng_option("", 'Send invite to"[email protected]"', results_selector: "body")
share_modal.expect_ng_option("", "No items found", results_selector: "body")
end
end