Merge branch 'release/10.0' into dev

pull/7788/head
ulferts 5 years ago
commit ab03be46ed
No known key found for this signature in database
GPG Key ID: A205708DE1284017
  1. 1
      app/controllers/my_controller.rb
  2. 15
      app/helpers/user_consent_helper.rb
  3. 5
      app/services/set_localization_service.rb
  4. 1
      app/views/account/_user_consent_check.html.erb
  5. 16
      docs/operations/backup/docker/backup.md
  6. 12
      spec/features/auth/consent_auth_stage_spec.rb
  7. 34
      spec/views/account/register.html.erb_spec.rb

@ -32,6 +32,7 @@ class MyController < ApplicationController
include Concerns::PasswordConfirmation
include Concerns::UserPasswordChange
include ActionView::Helpers::TagHelper
layout 'my'
helper_method :gon

@ -28,7 +28,6 @@
#++
module ::UserConsentHelper
def consent_param?
params[:consent_check].present?
end
@ -38,10 +37,18 @@ module ::UserConsentHelper
Setting.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 }
end
def consent_configured?

@ -29,6 +29,7 @@ class SetLocalizationService
def header_language
return unless http_accept_header
accept_lang = parse_qvalues(http_accept_header).first
find_language_or_prefix accept_lang
end
@ -54,13 +55,15 @@ class SetLocalizationService
tmp = tmp.sort_by { |_val, q| -q }
tmp.map! { |val, _q| val }
end
return tmp
tmp
rescue
nil
end
def find_language_or_prefix(language)
return nil unless language
language = language.to_s.downcase
find_language(language) || find_language(language.split('-').first)
end

@ -11,4 +11,3 @@
<%= t('consent.checkbox_label') %>
</label>
</section>

@ -21,3 +21,19 @@ S3 or FTP).
If at any point you want to restore from a backup, just put your backup in
`/var/lib/openproject` on your local host, and re-launch the docker container.
## Dumping the database
**Note:** this only applies for the self-contained OpenProject container not using
an external database but instead a database right in the container.
If you need a SQL dump of your database straight from the container you can do the
following to dump it into the current directory:
```
docker exec $CONTAINER_ID bash -c \
'export PGPASSWORD=openproject && pg_dump -U openproject -h 127.0.0.1' \
> openproject.sql
```
If you don't know the container id (or name) you can find it out using `docker ps`.

@ -28,7 +28,7 @@
require 'spec_helper'
describe 'Authentication Stages', type: :feature, js: true do
describe 'Authentication Stages', type: :feature do
let(:language) { 'en' }
let(:user_password) { 'bob' * 4 }
let(:user) do
@ -84,12 +84,16 @@ describe 'Authentication Stages', type: :feature, js: true do
expect_logged_in
end
end
context 'when enabled, localized consent exists',
with_settings: { consent_info: { de: '# Einwilligung', en: '# Consent header!' } } do
let(:consent_required) { true }
let(:language) { 'de' }
it 'should show localized consent' do
before do
Capybara.current_session.driver.header('Accept-Language', 'de')
end
it 'should show localized consent as defined by the accept language header (ignoring users language)' do
login_with user.login, user_password
expect(page).to have_selector('.account-consent')
@ -97,7 +101,7 @@ describe 'Authentication Stages', type: :feature, js: true do
end
end
context 'when enabled, but consent exists', with_settings: { consent_info: { en: '# Consent header!' } } do
context 'when enabled, but consent exists', js: true, with_settings: { consent_info: { en: '# Consent header!' } } do
let(:consent_required) { true }
after do

@ -114,4 +114,38 @@ describe 'account/register', type: :view do
end
end
end
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
end
end

Loading…
Cancel
Save