[Git][noosfero/noosfero][master] 2 commits: Fix invitation_to method to return nil if there is no invitation
Rodrigo Souto
gitlab at mg.gitlab.com
Mon May 28 19:10:01 BRT 2018
Rodrigo Souto pushed to branch master at Noosfero / noosfero
Commits:
6301bdc6 by mendesiasmin at 2018-05-28T14:48:10Z
Fix invitation_to method to return nil if there is no invitation
- - - - -
63fd715e by Rodrigo Souto at 2018-05-28T22:09:33Z
Merge branch 'fix-event-invitations' into 'master'
Fix invitation_to method to return nil if there is no invitation
See merge request noosfero/noosfero!1505
- - - - -
2 changed files:
- app/models/event_invitation.rb
- test/unit/event_invitation_test.rb
Changes:
=====================================
app/models/event_invitation.rb
=====================================
--- a/app/models/event_invitation.rb
+++ b/app/models/event_invitation.rb
@@ -31,10 +31,6 @@ class EventInvitation < ApplicationRecord
where "event_id = '?' AND decision = '?'",
event, EventInvitation::DECISIONS['unconfirmed'] if event }
- scope :invitation_to, -> event, person {
- find_by "event_id = '?' AND guest_id = '?'",
- event, person if event && person }
-
def valid_decision?
unless EventInvitation::DECISIONS.has_value? decision
errors.add(:decision, :invalid)
@@ -51,4 +47,7 @@ class EventInvitation < ApplicationRecord
EventInvitation::DECISIONS.key(decision)
end
+ def self.invitation_to event, person
+ event.invitations.find_by(guest: person)
+ end
end
=====================================
test/unit/event_invitation_test.rb
=====================================
--- a/test/unit/event_invitation_test.rb
+++ b/test/unit/event_invitation_test.rb
@@ -96,6 +96,13 @@ class EventInvitationTest < ActiveSupport::TestCase
assert_equal invitation, EventInvitation.invitation_to(event, guest)
end
+ should 'return nil if there is no invitation for person' do
+ event = fast_create(Event)
+ guest = fast_create(Person)
+
+ assert_equal nil, EventInvitation.invitation_to(event, guest)
+ end
+
should 'return confirmed invitations to event' do
event = fast_create(Event)
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/6b48387cdc3d4a645e1b4b212913ed974382d052...63fd715ed88bbf8b7f469f16b214d1f9a2fd2d21
--
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/6b48387cdc3d4a645e1b4b212913ed974382d052...63fd715ed88bbf8b7f469f16b214d1f9a2fd2d21
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20180528/181dc3d0/attachment-0001.html>
More information about the Noosfero-dev
mailing list