Skip to content

Commit

Permalink
improve test #13
Browse files Browse the repository at this point in the history
  • Loading branch information
fwolfst committed Sep 24, 2020
1 parent 1858d7e commit ac9746e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 12 deletions.
28 changes: 18 additions & 10 deletions app/views/terms_acceptances/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,21 @@
.content.is-medium.has-text-justified
!= SiteSetting['terms']

= form_with url: terms_acceptance_path, builder: BulmaFormBuilder::FormBuilder do |f|
.field
= label_tag :accept_terms, t('activerecord.attributes.user.tos_agreement')
= f.check_box :accept_terms
.field
= label_tag :read_privacy_terms, t('activerecord.attributes.user.read_privacy_terms')
= f.check_box :read_privacy_terms
.actions
= f.submit t('Save'), class: 'button is-primary'

.columns
.column.is-half
%h2.title
= t('.acceptance')
= form_with url: terms_acceptance_path, builder: BulmaFormBuilder::FormBuilder do |f|
.field
= f.check_box :accept_terms
= label_tag :accept_terms, t('activerecord.attributes.user.tos_agreement')
.field
= f.check_box :read_privacy_terms
= label_tag :read_privacy_terms, t('activerecord.attributes.user.read_privacy_terms')
.actions
= f.submit t('Save'), class: 'button is-primary'
.column.is-half
%h2.title
= t('.actions')
.block
= t('.not-happy?')
26 changes: 24 additions & 2 deletions test/system/tos_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,30 @@ class TosTest < ApplicationSystemTestCase
click_on "Anmelden"

assert_selector '.notification', text: /Du musst/
assert_selector 'button', text: 'gelesen'
assert_selector 'button', text: 'löschen'
assert_selector '.button', text: 'Mein Konto zerstören'
assert_selector '.button', text: 'Zeig mir meine Daten!'

visit root_path

assert_equal terms_acceptance_path, page.current_path

assert_selector '.notification', text: /Du musst/
assert_selector '.button', text: 'Mein Konto zerstören'
assert_selector '.button', text: 'Zeig mir meine Daten!'

#click_on 'Speichern'

assert_selector '.notification', text: /Du musst/

check 'Datenschutzhinweise gelesen'
check 'Stimme AGB zu'

click_on 'Speichern'

assert_selector '.notification', text: /Willkommen/

user.reload
assert_in_delta DateTime.current.to_i, User.last.terms_accepted_at.to_i, 5
end

test "admins can update date of tos changes and user has to re-agree or delete account" do
Expand Down

0 comments on commit ac9746e

Please sign in to comment.