diff options
author | tauriedavis <taurie@gitlab.com> | 2018-05-25 16:17:57 -0700 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2018-06-04 22:22:11 +0200 |
commit | 285ffb223896f2226531be2ba10933414194155c (patch) | |
tree | cd6faec94ab2e4f65b0ed48f458b580b2853fac9 /spec/models/application_setting | |
parent | 35ba75f6b93c77f078ab2cf538a256f8aa534eb3 (diff) | |
download | gitlab-ce-285ffb223896f2226531be2ba10933414194155c.tar.gz |
Messaging on terms page when user already accepted46585-gdpr-terms-acceptance
We show a blue flash banner if the user already accepted, and show a
button allowing them to continue to the application.
Diffstat (limited to 'spec/models/application_setting')
-rw-r--r-- | spec/models/application_setting/term_spec.rb | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/spec/models/application_setting/term_spec.rb b/spec/models/application_setting/term_spec.rb index 1eddf3c56ff..aa49594f4d1 100644 --- a/spec/models/application_setting/term_spec.rb +++ b/spec/models/application_setting/term_spec.rb @@ -12,4 +12,41 @@ describe ApplicationSetting::Term do expect(described_class.latest).to eq(terms) end end + + describe '#accepted_by_user?' do + let(:user) { create(:user) } + let(:term) { create(:term) } + + it 'is true when the user accepted the terms' do + accept_terms(term, user) + + expect(term.accepted_by_user?(user)).to be(true) + end + + it 'is false when the user declined the terms' do + decline_terms(term, user) + + expect(term.accepted_by_user?(user)).to be(false) + end + + it 'does not cause a query when the user accepted the current terms' do + accept_terms(term, user) + + expect { term.accepted_by_user?(user) }.not_to exceed_query_limit(0) + end + + it 'returns false if the currently accepted terms are different' do + accept_terms(create(:term), user) + + expect(term.accepted_by_user?(user)).to be(false) + end + + def accept_terms(term, user) + Users::RespondToTermsService.new(user, term).execute(accepted: true) + end + + def decline_terms(term, user) + Users::RespondToTermsService.new(user, term).execute(accepted: false) + end + end end |