-
Notifications
You must be signed in to change notification settings - Fork 73
Remove hack in the Invitations backend
#4370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
8680652
326bb70
02eb1e6
e1dd3b7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -4,10 +4,7 @@ module User::Invitations | |||||
| included do | ||||||
| after_commit :accept_invitation, :on => :create | ||||||
|
|
||||||
| attr_accessor :invitation | ||||||
|
|
||||||
| # TODO: refactor to make this work removing above attribute. | ||||||
| # has_one :invitation | ||||||
| has_one :invitation # rubocop:disable Rails/HasManyOrHasOneDependent -- before_destroy :destroy_invitation handles it | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if this will also work without rubocop exclusions
Suggested change
This will communicate intent without ugliness, also I hope rubocop will understand this was intentional and not complain as well |
||||||
|
|
||||||
| before_destroy :destroy_invitation | ||||||
| end | ||||||
|
|
@@ -18,7 +15,8 @@ def accept_invitation | |||||
|
|
||||||
| def destroy_invitation | ||||||
| if account # some tests fail because of account being nil | ||||||
| invit = account.invitations.find_by_email(email) || account.invitations.find_by_user_id(id) # || eventually invitation | ||||||
| invitations = account.invitations | ||||||
| invit = invitations.find_by(email: email) || invitations.find_by(user_id: id) | ||||||
| # halt the destruction if the destruction of invitation failed | ||||||
| throw :abort if invit && invit.destroy == false | ||||||
| end | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -334,6 +334,7 @@ class SsoSignupTest < ActiveSupport::TestCase | |
| assert_equal result.username, user_data[:username] | ||
| assert result.active? | ||
| assert authentication_strategy.error_message.blank? | ||
| assert invitation.reload.accepted? | ||
| end | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm gonna ignore these, I don't see the problem on the duplication, these are tests. |
||
| end | ||
| end | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -258,6 +258,7 @@ class SsoSignupTest < ActiveSupport::TestCase | |
| assert_equal result.username, user_data[:username] | ||
| assert result.active? | ||
| assert authentication_strategy.error_message.blank? | ||
| assert invitation.reload.accepted? | ||
| end | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| end | ||
| end | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand if we want to remove this method. But as it is, I think it makes more sense to stay as it was. With the change, I don't think the association will be present in the object.