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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
render consent info in correct locale
Markus Kahlc6353928652e
diff --git a/app/helpers/user_consent_helper.rb b/app/helpers/user_consent_helper.rbindex 81d2d988e57..a0c3c3b1400 100644--- a/app/helpers/user_consent_helper.rb+++ b/app/helpers/user_consent_helper.rb@@ -38,10 +38,18 @@ module ::UserConsentHelperSetting.consent_required? && consent_configured?end- def user_consent_instructions(user)- language = user.try(:language) || Setting.default_language+ ##+ # Gets consent instructions for the given user.+ #+ # @param user [User] The user to get instructions for.+ # @param locale [String] ISO-639-1 code for the desired locale (e.g. de, en, fr).+ # `I18n.locale` is set for each request individually depending+ # among other things on the user's Accept-Language headers.+ # @return [String] Instructions in the respective language.+ def user_consent_instructions(user, locale: I18n.locale)all = Setting.consent_info- all.fetch(language) { all.values.first }++ all.fetch(locale) { all.values.first }enddef consent_configured?diff --git a/app/views/account/_user_consent_check.html.erb b/app/views/account/_user_consent_check.html.erbindex 42adf4a9198..9d7519588ba 100644--- a/app/views/account/_user_consent_check.html.erb+++ b/app/views/account/_user_consent_check.html.erb@@ -11,4 +11,3 @@<%= t('consent.checkbox_label') %></label></section>-diff --git a/spec/views/account/register.html.erb_spec.rb b/spec/views/account/register.html.erb_spec.rbindex e050899418c..bbeb2c490cf 100644--- a/spec/views/account/register.html.erb_spec.rb+++ b/spec/views/account/register.html.erb_spec.rb@@ -114,4 +114,38 @@ describe 'account/register', type: :view doendendend++ context "with consent required", with_settings: {+ consent_required: true,+ consent_info: {+ en: "You must consent!",+ de: "Du musst zustimmen!"+ }+ } do+ let(:locale) { raise "you have to define the locale" }++ before do+ I18n.with_locale(locale) do+ render+ end+ end++ context "for English (locale: en) users" do+ let(:locale) { :en }++ it "shows the registration page and consent info in English" do+ expect(rendered).to include "new account"+ expect(rendered).to include "consent!"+ end+ end++ context "for German (locale: de) users" do+ let(:locale) { :de }++ it "shows the registration page consent info in German" do+ expect(rendered).to include "Neues Konto"+ expect(rendered).to include "zustimmen!"+ end+ end+ endend