diff options
author | Mayra Cabrera <mcabrera@gitlab.com> | 2018-05-08 23:33:12 +0300 |
---|---|---|
committer | Mayra Cabrera <mcabrera@gitlab.com> | 2018-05-08 23:33:12 +0300 |
commit | c92f1d893cc5f114ec1e00251b3d1dcec78fab28 (patch) | |
tree | 8935a699fba25feb3ce0672acacf89c4e7836e2e /app/services/users/respond_to_terms_service.rb | |
parent | 4babf79aa1e8e2ec315f31fba0d3646825322d91 (diff) | |
parent | d122279fb0a28f248e6cdba339cb1bcd96a91477 (diff) |
Merge branch '10-8-stable-prepare-rc4' into '10-8-stable'
Prepare 10.8 RC4 release
See merge request gitlab-org/gitlab-ce!18784
Diffstat (limited to 'app/services/users/respond_to_terms_service.rb')
-rw-r--r-- | app/services/users/respond_to_terms_service.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/app/services/users/respond_to_terms_service.rb b/app/services/users/respond_to_terms_service.rb new file mode 100644 index 00000000000..06d660186cf --- /dev/null +++ b/app/services/users/respond_to_terms_service.rb @@ -0,0 +1,24 @@ +module Users + class RespondToTermsService + def initialize(user, term) + @user, @term = user, term + end + + def execute(accepted:) + agreement = @user.term_agreements.find_or_initialize_by(term: @term) + agreement.accepted = accepted + + if agreement.save + store_accepted_term(accepted) + end + + agreement + end + + private + + def store_accepted_term(accepted) + @user.update_column(:accepted_term_id, accepted ? @term.id : nil) + end + end +end |